def test_ch4_ion(self): cti2yaml.convert(Path(self.test_data_dir).joinpath("ch4_ion.cti"), Path(self.test_work_dir).joinpath("ch4_ion.yaml")) ctiGas, yamlGas = self.checkConversion("ch4_ion") self.checkThermo(ctiGas, yamlGas, [300, 500, 1300, 2000]) self.checkKinetics(ctiGas, yamlGas, [900, 1800], [2e5, 20e5]) self.checkTransport(ctiGas, yamlGas, [298, 1001, 2400])
def loader(self, path): # path is assumed to be the path dictionary surfaces = [] if path['mech'].suffix in ['.yaml', '.yml' ]: # check if it's a yaml cantera file mech_path = str(path['mech']) else: # if not convert into yaml cantera file mech_path = str(path['Cantera_Mech']) if path['mech'].suffix == '.cti': cti2yaml.convert(path['mech'], path['Cantera_Mech']) elif path['mech'].suffix in ['.ctml', '.xml']: raise Exception('not implemented') #ctml2yaml.convert(path['mech'], path['Cantera_Mech']) else: # if not a cantera file, assume chemkin surfaces = self.chemkin2cantera(path) print('Validating mechanism...', end='') try: # This test taken from ck2cti self.yaml_txt = path['Cantera_Mech'].read_text( ) # Storing full text could be bad if large self.gas = ct.Solution(yaml=self.yaml_txt) for surfname in surfaces: phase = ct.Interface(outName, surfname, [self.gas]) print('PASSED.') except RuntimeError as e: print('FAILED.') print(e)
def test_Redlich_Kwong_CO2(self): cti2yaml.convert(Path(self.test_data_dir).joinpath('co2_RK_example.cti'), Path(self.test_work_dir).joinpath('co2_RK_example.yaml')) ctiGas, yamlGas = self.checkConversion('co2_RK_example') for P in [1e5, 2e6, 1.3e7]: yamlGas.TP = ctiGas.TP = 300, P self.checkThermo(ctiGas, yamlGas, [300, 400, 500])
def test_Redlich_Kwong_ndodecane(self): cti2yaml.convert(Path(self.cantera_data).joinpath('nDodecane_Reitz.cti'), Path(self.test_work_dir).joinpath('nDodecane_Reitz.yaml')) ctiGas, yamlGas = self.checkConversion('nDodecane_Reitz') self.checkThermo(ctiGas, yamlGas, [300, 400, 500]) self.checkKinetics(ctiGas, yamlGas, [300, 500, 1300], [1e5, 2e6, 1.4e7], 1e-6)
def test_sofc(self): cti2yaml.convert( Path(self.cantera_data).joinpath('sofc.cti'), Path(self.test_work_dir).joinpath('sofc.yaml')) ctiGas, yamlGas = self.checkConversion('sofc') ctiMetal, yamlMetal = self.checkConversion('sofc', phaseid='metal') ctiOxide, yamlOxide = self.checkConversion('sofc', phaseid='oxide_bulk') ctiMSurf, yamlMSurf = self.checkConversion( 'sofc', ct.Interface, phaseid='metal_surface', ctiphases=[ctiGas, ctiMetal], yamlphases=[yamlGas, yamlMetal]) ctiOSurf, yamlOSurf = self.checkConversion( 'sofc', ct.Interface, phaseid='oxide_surface', ctiphases=[ctiGas, ctiOxide], yamlphases=[yamlGas, yamlOxide]) cti_tpb, yaml_tpb = self.checkConversion( 'sofc', ct.Interface, phaseid='tpb', ctiphases=[ctiMetal, ctiMSurf, ctiOSurf], yamlphases=[yamlMetal, yamlMSurf, yamlOSurf]) self.checkThermo(ctiMSurf, yamlMSurf, [900, 1000, 1100]) self.checkThermo(ctiOSurf, yamlOSurf, [900, 1000, 1100]) ctiMetal.electric_potential = yamlMetal.electric_potential = 2 self.checkKinetics(cti_tpb, yaml_tpb, [900, 1000, 1100], [1e5]) ctiMetal.electric_potential = yamlMetal.electric_potential = 4 self.checkKinetics(cti_tpb, yaml_tpb, [900, 1000, 1100], [1e5])
def test_pdep(self): cti2yaml.convert( Path(self.test_data_dir).joinpath('pdep-test.cti'), Path(self.test_work_dir).joinpath('pdep-test.yaml')) ctiPhase, yamlPhase = self.checkConversion('pdep-test') self.checkKinetics(ctiPhase, yamlPhase, [300, 1000, 2200], [100, ct.one_atm, 2e5, 2e6, 9.9e6])
def test_liquidvapor(self): cti2yaml.convert(Path(self.cantera_data).joinpath('liquidvapor.cti'), Path(self.test_work_dir).joinpath('liquidvapor.yaml')) for name in ['water', 'nitrogen', 'methane', 'hydrogen', 'oxygen', 'hfc134a', 'carbondioxide', 'heptane']: ctiPhase, yamlPhase = self.checkConversion('liquidvapor', name=name) self.checkThermo(ctiPhase, yamlPhase, [1.3 * ctiPhase.min_temp, 0.7 * ctiPhase.max_temp])
def test_ptcombust(self): cti2yaml.convert(Path(self.cantera_data).joinpath('ptcombust.cti'), Path(self.test_work_dir).joinpath('ptcombust.yaml')) ctiGas, yamlGas = self.checkConversion('ptcombust') ctiSurf, yamlSurf = self.checkConversion('ptcombust', ct.Interface, name='Pt_surf', ctiphases=[ctiGas], yamlphases=[yamlGas]) self.checkKinetics(ctiGas, yamlGas, [500, 1200], [1e4, 3e5]) self.checkThermo(ctiSurf, yamlSurf, [400, 800, 1600]) self.checkKinetics(ctiSurf, yamlSurf, [500, 1200], [1e4, 3e5])
def test_diamond(self): cti2yaml.convert(pjoin(self.cantera_data, 'diamond.cti'), 'diamond.yaml') ctiGas, yamlGas = self.checkConversion('diamond', phaseid='gas') ctiSolid, yamlSolid = self.checkConversion('diamond', phaseid='diamond') ctiSurf, yamlSurf = self.checkConversion('diamond', ct.Interface, phaseid='diamond_100', ctiphases=[ctiGas, ctiSolid], yamlphases=[yamlGas, yamlSolid]) self.checkThermo(ctiSolid, yamlSolid, [300, 500]) self.checkThermo(ctiSurf, yamlSurf, [330, 490]) self.checkKinetics(ctiSurf, yamlSurf, [400, 800], [2e5])
def test_ptcombust(self): cti2yaml.convert(pjoin(self.cantera_data, 'ptcombust.cti'), 'ptcombust.yaml') ctiGas, yamlGas = self.checkConversion('ptcombust') ctiSurf, yamlSurf = self.checkConversion('ptcombust', ct.Interface, phaseid='Pt_surf', ctiphases=[ctiGas], yamlphases=[yamlGas]) self.checkKinetics(ctiGas, yamlGas, [500, 1200], [1e4, 3e5]) self.checkThermo(ctiSurf, yamlSurf, [400, 800, 1600]) self.checkKinetics(ctiSurf, yamlSurf, [500, 1200], [1e4, 3e5])
def test_lithium_ion_battery(self): cti2yaml.convert( Path(self.cantera_data).joinpath('lithium_ion_battery.cti'), Path(self.test_work_dir).joinpath('lithium_ion_battery.yaml')) name = 'lithium_ion_battery' ctiAnode, yamlAnode = self.checkConversion(name, phaseid='anode') ctiCathode, yamlCathode = self.checkConversion(name, phaseid='cathode') ctiMetal, yamlMetal = self.checkConversion(name, phaseid='electron') ctiElyt, yamlElyt = self.checkConversion(name, phaseid='electrolyte') ctiAnodeInt, yamlAnodeInt = self.checkConversion( name, phaseid='edge_anode_electrolyte', ctiphases=[ctiAnode, ctiMetal, ctiElyt], yamlphases=[yamlAnode, yamlMetal, yamlElyt]) ctiCathodeInt, yamlCathodeInt = self.checkConversion( name, phaseid='edge_cathode_electrolyte', ctiphases=[ctiCathode, ctiMetal, ctiElyt], yamlphases=[yamlCathode, yamlMetal, yamlElyt]) self.checkThermo(ctiAnode, yamlAnode, [300, 330]) self.checkThermo(ctiCathode, yamlCathode, [300, 330]) ctiAnode.X = yamlAnode.X = [0.7, 0.3] self.checkThermo(ctiAnode, yamlAnode, [300, 330]) ctiCathode.X = yamlCathode.X = [0.2, 0.8] self.checkThermo(ctiCathode, yamlCathode, [300, 330]) for phase in [ ctiAnode, yamlAnode, ctiCathode, yamlCathode, ctiMetal, yamlMetal, ctiElyt, yamlElyt, ctiAnodeInt, yamlAnodeInt, ctiCathodeInt, yamlCathodeInt ]: phase.TP = 300, 1e5 ctiMetal.electric_potential = yamlMetal.electric_potential = 0 ctiElyt.electric_potential = yamlElyt.electric_potential = 1.9 self.checkKinetics(ctiAnodeInt, yamlAnodeInt, [300], [1e5]) ctiMetal.electric_potential = yamlMetal.electric_potential = 2.2 ctiElyt.electric_potential = yamlElyt.electric_potential = 0 self.checkKinetics(ctiCathodeInt, yamlCathodeInt, [300], [1e5])
def setUpClass(cls): super().setUpClass() cti2yaml.convert(Path(cls.cantera_data).joinpath('gri30.cti'), Path(cls.test_work_dir).joinpath('gri30.yaml'))
def setUpClass(cls): super().setUpClass() cti2yaml.convert(pjoin(cls.cantera_data, 'gri30.cti'), 'gri30.yaml')