コード例 #1
0
def test_forces():

    cwd = os.getcwd()
    dir_path = os.path.dirname(os.path.realpath(__file__))
    os.chdir(dir_path)

    solutionDir = "forces/0"
    file = "force.dat"
    caseStructure = [['Ux1', 'Ux3'], ['T1'], ['p1'], ['string10']]
    baseCase = "Cases"

    F = casefoam.time_series(solutionDir, file, caseStructure, baseCase)

    assert F.index.max() == 1
    assert F[1].max() == 1
    assert F[2].max() == 1
    assert F[3].max() == 1
    assert F[4].max() == 2
    assert F[5].max() == 2
    assert F[6].max() == 2
    assert F[7].max() == 3
    assert F[7].max() == 3
    assert F[7].max() == 3

    os.chdir(cwd)
コード例 #2
0
def test_time_series():

    cwd = os.getcwd()
    dir_path = os.path.dirname(os.path.realpath(__file__))
    os.chdir(dir_path)

    solutionDir = "probes"
    file = "probeData"
    caseStructure = [['Ux1', 'Ux3'], ['T1'], ['p1'], ['string10']]
    baseCase = "Cases"

    df = casefoam.time_series(solutionDir, file, caseStructure, baseCase)

    assert df.index.max() == 1
    assert df[1].max() == 1
    assert df[2].max() == 2
    assert df[3].max() == 3
    assert df[4].max() == 4
    assert df[5].max() == 5
    assert df[6].max() == 6
    assert df[7].max() == 7

    os.chdir(cwd)
コード例 #3
0
import matplotlib.pyplot as plt
import casefoam
import seaborn as sns
# output_notebook()
sns.set_style("ticks")

caseStructure = [['gradAlpha', 'RDF', 'heightFunction', 'fitParaboloid'],
                 ['hex'],  # ,'tri'],
                 ['Grid1', 'Grid2', 'Grid3', 'Grid4', 'Grid5', 'Grid6', 'Grid7', 'Grid8', 'Grid9', 'Grid10']]


baseCase = 'Cases'  # 'Cases/isoSurface/explicitGrad/grid1/'
solutionDir = 'reconstructionError/0'
file = 'error.dat'

curv = casefoam.time_series(solutionDir, file, caseStructure, baseCase)
curv = curv[[5, 6, 9, 'var_0', 'var_1', 'var_2']]
curv.columns = ['Curv_max', 'Curv_mean', 'Length', 'Method', 'gridType', 'Res']
curv['DeltaX'] = 0.5/curv['Length']
curv = pd.melt(
    curv, id_vars=curv.columns[2:], value_vars=curv.columns[:2], value_name='curv', var_name='error')


ax = sns.lineplot(x='DeltaX', y='curv', hue='Method', style='error',
                data=curv, markers=True,
                hue_order=['gradAlpha', 'fitParaboloid', 'RDF', 'heightFunction']).set(xscale='log', yscale='log', ylim=(1e-5, 10))
# ax.set()
plt.ylabel('curvature error')
plt.xlabel('Resolution per Radius')
plt.savefig('curv2d_hex.pdf')
curv.to_csv("curv2d_hex.csv", index=False)
コード例 #4
0
import pandas as pd
import matplotlib.pyplot as plt
import casefoam
import numpy as np

caseStructure = [['hex'], ['Grid1', 'Grid2', 'Grid3']]

baseCase = 'Cases'

solutionDir = 'maxU/0'
file = 'fieldMinMax.dat'

sol = casefoam.time_series(solutionDir, file, caseStructure, baseCase)

sol.reset_index(inplace=True)
sol.columns = ['t', 'minU', 'maxU', 'GridType', 'Resolution']
sol = sol.drop(columns='minU')
table = sol[sol['t'] == 0.01]
table = table.drop(columns='t')

table = table.set_index(['GridType', 'Resolution'])

table.to_html("results.html")
table.to_csv("results.csv")
コード例 #5
0
from casefoam import time_series, positional_field
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import casefoam
import numpy as np

caseStructure = [['height_02', 'height_03', 'height_04'],
                 ['grid1', 'grid2', 'grid3']]
baseCase = 'Cases'
probeDir = 'probes/0'
surfaceDir = 'freeSurface'
setDir = 'sample1'

# load probe data
p = time_series(probeDir, 'p', caseStructure, baseCase)
T = time_series(probeDir, 'T', caseStructure, baseCase)
U = time_series(probeDir, 'U', caseStructure, baseCase)
p = p.reset_index()
T = T.reset_index()
U = U.reset_index()

sns.lineplot(x='t', y=1, hue='var_0', style='var_1', data=p)
plt.xlabel('Time $t$')
plt.ylabel('Pressure $p$')

# load surface data
surf = positional_field(surfaceDir, 'p_freeSurface.raw', 0.1, caseStructure,
                        baseCase)

plt.figure()