def test_ionmix(): """Reading an ionmix table""" mpath = "/home/rth/luli/NestedOutflows/NestedOutflows/simulations/NestedOutflows" mat1 = eos.EosMaterial(63720, options={ 'type': 'ionmix', 'abar': 26.9815, 'zbar': 13.0, 'rho_ref': 2.7, 'path': os.path.join(mpath, 'al-imx-32g.cn4') }, units='cgs', backend='tabulated') mat1.save('/tmp/ionmix_63720.ses') mat2 = eos.EosMaterial(63720, tables=['.t_DT'], units='cgs', backend='eospac') temp = np.array([2.000E+03 * eos.eV2K_cst]) rho = np.array([4.480E-01]) # comparing with values in al-imx-32g.imx yield assert_allclose, mat2.Pt_DT(rho, temp), np.array([3.204E+13 + 4.102E+14 ]), 1e-3 yield assert_allclose, mat2.Ut_DT( rho, temp), np.array([1.188E+07 + 1.591E+08]) * 1e7, 1e-4
def test_sesascii(): """ Conversion from ASCII to Binary for SESAME format """ raise SkipTest matbase = 3719 matid_new = int(9e4 + matbase) material = 'Fe' tab_options = { 'type': 'sesascii', 'prescision': 'single', 'path': '/home/rth/luli/eos/sesame/xsesame_ascii' } tables = ['Ut_DT', 'Pt_DT', 'At_DT'] # Reading the ascii file mat_ascii = eos.EosMaterial(matbase, tables=tables, options=tab_options, units='eospac', backend='tabulated') # Writing to binary filename = '/tmp/{0}_sesame_{1}.sesb'.format(material, matid_new) mat_ascii.save(filename, matid=matid_new) # Reopening the binary file mat_bin0 = eos.EosMaterial(matbase, tables=tables, options={}, units='eospac', backend='eospac') mat_bin1 = eos.EosMaterial(matid_new, tables=tables, options={}, units='eospac', backend='eospac') for tab_name in tables: tab0 = getattr(mat_bin0, tab_name) tab1 = getattr(mat_bin1, tab_name) for key in ['D_Array', 'T_Array', 'F_Array']: if not np.allclose(tab0[key], tab1[key]): print tab_name, key, 'failed' yield assert_allclose, tab0[key], tab1[key], 1e-5
def test_consitency_wdv_ideal_gas(): rho = 1e-6 temp = 10*11640 eosmat_gamma = eos.EosMaterial(material, tables=['Pt_DT'], options={'game': 1.6666, 'abar': abar, 'gamc': 1.6666}, units='eospac', backend='gamma') yield assert_allclose, eosmat.Pt_DT(rho, temp), eosmat_gamma.Pt_DT(rho, temp), 1e-5
def setup(): global tables_list, material global sestab tables_list = ['Pt_DT', 'Ut_DT'] material = 7593 sestab = eos.EosMaterial(material, tables=tables_list, options={}, units='eospac')
def setup(): global tables_list, material global tab global X, Y # Load the tables to compute all the derived quantities for all species material = 7593 tab = eos.EosMaterial(material, eos.derived_quantities.keys(), spec=['t', 'e', 'ic'], options={}) # selecting an isotherm at 10 eV Xarr = tab.Pt_DT['R_Array'][2:-1] * 1.1 Yarr = np.array([10, 100, 1000]) * 11640 X, Y = np.meshgrid(Xarr, Yarr, indexing='ij')
def setup(): global tables_list, material global eosmat global abar, gamc, game tables_list = ['.*_DT', '.*_DUt'] material = None gamc, game, abar = 1.66, 1.66, 3.5 eosmat = eos.EosMaterial(material, tables=tables_list, options={ 'game': game, 'gamc': gamc, 'abar': abar }, backend='gamma')
def setup(): global tables_list, material global eosmat global abar, gamc, game tables_list = ['St_DUt', 'Pt_DT', 'T_DUt', 'Ut_DT', 'At_DT', 'Pt_DUt', 'T_DPt', 'Pt_DSt', 'St_DT'] # http://courses.chem.indiana.edu/c360/documents/vanderwaalsconstants.pdf material = None # parameters for water a = 5.537 # bar*L²/mol² b = 0.0305 # L/mol delta = 0.329 abar = 6.0 eosmat = eos.EosMaterial(material, tables=tables_list, options={'delta': delta, 'a': a, 'b': b, 'abar': abar}, units='eospac', backend='vdw')
# <markdowncell> # II. Single material interpolations # ---------------------------------- # <codecell> # Load some tables for the material no 3720 (Aluminium) # options keys accepts regular expressions. For instance # - '.*' would match any table # - '[PU]t_DT' matches 'Pt_DT', 'Ut_DT' # - etc.. mat = eos.EosMaterial(7593, ['Pt_DT', 'Ut_DT','St_DT', 'Pt_DSt'], options={'.*': {'create_tzero': True}, '[PU]t_DT': {'x_convert': 1.0}, 'St_DT': {'linear': True}, }) # see what options are applied for table_name in mat.tables: print table_name, mat.get_table(table_name).options # <codecell> # Separate tables can be accessed as parameters of the 'mat' object for instance 'm.Pt_DT' # this is a shortcut from m.get_table('Pt_DT') # Info values can be acessed as attributes of the EosMaterial class print mat.Pt_DT['Normal_Density'], mat.Pt_DT['Mean_Atomic_Num'] # <codecell>
def test_derived_quantities_zero_order(): """Checking all derived quantities can be computed (e.g. that dependencies are ok)""" for qtty_name, qtty_dict in eos.derived_quantities.iteritems(): ctab = eos.EosMaterial(material, [qtty_name], spec=qtty_dict['spec']) for spec in qtty_dict['spec']: yield ctab.q[qtty_name, spec], X, Y
# 'grid_subsample_default': 0} #tab_options['path'] = os.path.join(NESTED_DIR, tab_options['path']) #mat1 = eos.EosMaterial(7e4+matbase, # options=tab_options, # units='cgs', backend='tabulated') #mat1.save(os.path.join(DATA_DIR, '{0}_ionmix_{1}.sesb').format(material, int(7e4+matbase))) #============================================================================== # Iron #============================================================================== #matbase = 3332 #feosid = 83333 #material = 'Cu' # #feos_opts ={'use_maxwell': False, 'use_softspheres': True, # 'maxwell_temp_arr': None, 'max_materials': 1, # 'grid_subsample_default': 1} # mat2 = eos.EosMaterial(matbase, tables=[tab for tab in avalable_tabs], options=feos_opts, units='cgs', backend='feos') if feos_opts['use_maxwell']: print 'Critical point {3}: {0:.3f} g.cm⁻³, {1:.1f} K, {2:.0f} bar'.format( mat2.Pt_DT['critical_rho'], mat2.Pt_DT['critical_temp'] * 11640, mat2.Pt_DT['critical_P'] * 1e-10 * 1e4, material) mat2.save(os.path.join(DATA_DIR, '{0}_feos_{1}.sesb'.format(material, feosid)), matid=feosid)
'ref': { 'color': 'k', 'ls': 'solid' } } for key in df: df[key] = df[key].sort(columns='temp_source') df['IONMIX, FLASH'].drop_duplicates(inplace=True) df['FEOS, FLASH'].drop_duplicates(subset='temp_source', inplace=True) eos_pars = {'.*': {'linear': True}} matid = 83719 matf = eos.EosMaterial(matid, tables=['Piz_DT', 'Uiz_DT', 'Pe_DT', 'Ue_DT', 'Zfc_DT'], options=eos_pars, units='eospac', backend='eospac') state0 = {"temp": 298, "rho": 2.7} state1 = {"pres": np.logspace(-0.2, 2.2, 100) * 100} # GPa rh = RankineHugoniot.solve(state0, state1, backend='eospac', eos_pars=eos_pars, material=matid, root_opts={'method': 'lm'}) fig = plt.figure(figsize=get_figsize(wf=1.1, hf=0.6)) plt.subplots_adjust(wspace=0.3, hspace=0.3)
def setup_eos(): matid = '99999' tab = eos.EosMaterial(matid, ['Pt_DT', 'T_DPt', 'Ut_DT', 'St_DT', 'gamc_s'], spec=['t'], options={ 'delta': 0.0125, 'a': 5.537, 'b': 0.0305, 'abar': 6.00530 }, units='cgs', backend='vdw') rho_c = tab.Pt_DT['rho_c'] temp_c = tab.Pt_DT['temp_c'] pres_c = tab.Pt_DT['Pt_c'] #print rho_c, temp_c, pres_c eos_tests = {} #st0 = {'rho': 1.01000, 'pres': 1.60770} #st1 = {'rho': 0.59400, 'pres': 1.36136} #eos_tests['WV1'] = [st0, st1] st0 = {'rho': 1.818, 'pres': 3.0, 'G': 4.118} st1 = {'rho': 0.275, 'pres': 0.575, 'G': 0.703} eos_tests['DG1'] = [st0, st1] st0 = {'rho': 0.879, 'pres': 1.090, 'G': -0.031} st1 = {'rho': 0.562, 'pres': 0.885, 'G': -4.016} eos_tests['DG2'] = [st0, st1] st0 = {'rho': 0.879, 'pres': 1.090, 'G': -0.031} st1 = {'rho': 0.275, 'pres': 0.575, 'G': 0.703} eos_tests['DG3'] = [st0, st1] for key in eos_tests: for stateid in range(2): eos_tests[key][stateid]['rho'] *= rho_c eos_tests[key][stateid]['pres'] *= pres_c crho = eos_tests[key][stateid]['rho'] cpres = eos_tests[key][stateid]['pres'] eos_tests[key][stateid]['temp'] = float(tab.T_DPt(crho, cpres)) ctemp = eos_tests[key][stateid]['temp'] eos_tests[key][stateid]['eint'] = float(tab.Ut_DT(crho, ctemp)) eos_tests[key][stateid]['Gamma'] = float(tab.q['Gamma'](crho, ctemp)) eos_tests[key][stateid]['Gamma_e'] = float(tab.q['game0']( crho, ctemp)) - 1 eos_tests[key][stateid]['gamma'] = float(tab.q['gamc_s'](np.array( [crho]), np.array([ctemp]))) try: np.testing.assert_allclose(eos_tests[key][stateid]['G'], tab.q['G3_vdw'](crho, ctemp), rtol=2e-2, err_msg=key + '_' + str(stateid)) except: print(key + '_' + str(stateid), 'failed!') test_data = eos_tests[test_case] t_snapshot = {'DG1': 0.15, 'DG2': 0.45, 'DG3': 0.2} dt = {'DG1': 5e-4, 'DG2': 1.5e-3, 'DG3': 1e-3} treal = lambda tnorm: tnorm * 1.0 * (rho_c / pres_c)**0.5 treal_t = treal(t_snapshot[test_case]) treal_dt = treal(dt[test_case]) return { 'tab': tab, 'state': test_data, 'treal': treal_t, 'dt': treal_dt, 'test': test_case }
Ftab, Fval1, float(Fval2), np.allclose(Fval1, Fval2, rtol=1e-3)) def get_shock_position(d): if (d['pres'].max() - d['pres'].min()) / d['pres'].mean() < 0.2: return np.nan else: idx = np.nanargmin( savgol(d['x'], d['pres'], window_size=5, order=2, deriv=1)) return d['x'][idx] matf = eos.EosMaterial(83719, tables=['Piz_DT', 'Uiz_DT', 'Pe_DT', 'Ue_DT', 'Zfc_DT'], options={'.*': { 'linear': True }}, units='eospac', backend='eospac') feosid = 83719 material = 'Al' feos_opts = { 'use_maxwell': True, 'use_softspheres': True, 'maxwell_temp_arr': None, 'max_materials': 2, 'grid_subsample_default': 0 }