def test_arr(): """ Tests the Arrhenius writer """ ref_ckin_str1 = ('REACTIONS CAL/MOLE MOLES\n\n' '! Block comment\n\n' '! Comment\n' 'H+O2=OH+O 1.000E+15 0.000 25000 ! Comment\n' '! Comment\n\n\n\n' 'END\n\n') ref_ckin_str2 = ('REACTIONS CAL/MOLE MOLES\n\n' '! Block comment\n\n' '! Comment\n' 'H+O2=OH+O 1.000E+15 0.000 25000 ! Comment\n' 'DUP\n' 'H+O2=OH+O 1.000E+15 0.000 25000\n' 'DUP\n' '! Comment\n\n\n\n' 'END\n\n') ref_ckin_str3 = ( 'REACTIONS CAL/MOLE MOLES\n\n' 'H+O2=OH+O 1.000E+15 0.000 25000\n' ' N2/1.400/ AR/1.000/ \n\n\n\n' # note three spaces before \n 'END\n\n') ckin_str1 = writer(ARR_RXN_PARAM_DCT, rxn_cmts_dct=RXN_CMTS_DCT1) ckin_str2 = writer(DUP_ARR_RXN_PARAM_DCT, rxn_cmts_dct=RXN_CMTS_DCT1) ckin_str3 = writer(COLLID_ARR_RXN_PARAM_DCT) assert ckin_str1 == ref_ckin_str1 assert ckin_str2 == ref_ckin_str2 assert ckin_str3 == ref_ckin_str3
def _get_strs(rxn_param_dct): """ Gets two strs after passing a rxn_param_dct through the writer and reader """ first_str = writer(rxn_param_dct) new_rxn_param_dct = parser(first_str, 'cal/mole', 'moles') second_str = writer(new_rxn_param_dct) return first_str, second_str
def test__thermo_read_write(): """ Tests the chemkin_io parsing and writing for thermo """ # Run the writer thermo_str = writer(SPC_NASA7_DCT) # Run the parser new_spc_nasa7_dct = parser(thermo_str) # Run the writer again on the new spc_nasa7_dct new_thermo_str = writer(new_spc_nasa7_dct) assert thermo_str == new_thermo_str
def test_lind(): """ Tests the Lindemann writer """ ref_ckin_str = ('REACTIONS CAL/MOLE MOLES\n\n' 'H+O2(+N2)=OH+O(+N2) 1.000E+12 1.500 50000\n' ' LOW / 1.000E+12 1.500 50000 /\n' ' AR/1.400/ N2/1.700/ \n\n\n\nEND\n\n') ckin_str = writer(LIND_RXN_PARAM_DCT) assert ckin_str == ref_ckin_str
def test_troe(): """ Tests the Troe writer """ ref_ckin_str = ( 'REACTIONS CAL/MOLE MOLES\n\n' 'H+O2(+N2)=OH+O(+N2) 1.000E+12 1.500 50000\n' ' LOW / 1.000E+12 1.500 50000 /\n' ' TROE / 1.500E+00 8.000E+03 1.000E+02 1.000E+03 /\n' ' AR/1.400/ N2/1.700/ \n\n\n\nEND\n\n') ckin_str = writer(TROE_RXN_PARAM_DCT) assert ckin_str == ref_ckin_str
def test_plog(): """ Tests the PLOG writer """ ref_ckin_str = ( 'REACTIONS CAL/MOLE MOLES\n\n' 'H+O2=OH+O 1.000E+15 0.000 25000\n' ' PLOG /1.000E-01 1.000E+15 0.000 25000 /\n' ' PLOG /1.000E+00 1.000E+15 0.000 25000 /\n' ' PLOG /1.000E+00 1.000E+15 0.000 25000 /\n' ' PLOG /1.000E+02 1.000E+15 0.000 25000 /\n\n\n\nEND\n\n') ckin_str = writer(PLOG_RXN_PARAM_DCT) assert ckin_str == ref_ckin_str
def test_cheb(): """ Tests the Chebyshev writer """ ref_ckin_str = ( 'REACTIONS CAL/MOLE MOLES\n\n' 'H+O2(+N2)=OH+O(+N2) 1.000E+00 0.000 0\n' ' TCHEB/ 500.00 2000.00 /\n' ' PCHEB/ 0.03 100.00 /\n' ' CHEB / 6 4 /\n' ' CHEB / -1.620E+01 -1.183E-01 -5.423E-02 -1.476E-02 /\n' ' CHEB / 2.578E+00 1.614E-01 7.359E-02 1.880E-02 /\n' ' CHEB / 1.068E-01 -7.235E-02 -2.733E-02 -3.778E-03 /\n' ' CHEB / 3.955E-02 1.207E-02 3.402E-04 -2.695E-03 /\n' ' CHEB / 8.557E-03 4.345E-03 3.670E-03 1.608E-03 /\n' ' CHEB / 8.599E-04 -1.758E-03 -7.502E-04 7.396E-07 /\n\n\n\n' 'END\n\n') ckin_str = writer(CHEB_RXN_PARAM_DCT) assert ckin_str == ref_ckin_str
def test__write_spc_names(): """ Tests the species names writing """ spc_str = writer(SPC_IDENT_DCT) assert spc_str == SPC_NAMES_STRING_1
def test__elements_write(): """ test chemkin_io.writer.mechanism.elements block """ elem_str = writer(ELEM_TUPLE) assert elem_str == ELEM_STR
def test_dups(): """ Tests the writing of duplicates """ ref_ckin_str1 = ('REACTIONS CAL/MOLE MOLES\n\n' 'H+O2(+N2)=OH+O(+N2) 1.000E+15 0.000 25000\n' ' PLOG / 1.000E-01 1.000E+15 0.000 25000 /\n' ' PLOG / 1.000E+00 1.000E+15 0.000 25000 /\n' ' PLOG / 1.000E+00 1.000E+15 0.000 25000 /\n' ' PLOG / 1.000E+02 1.000E+15 0.000 25000 /\n' 'DUP\n' 'H+O2(+N2)=OH+O(+N2) 1.000E+15 0.000 25000\n' ' PLOG / 1.000E-01 1.000E+15 0.000 25000 /\n' ' PLOG / 1.000E+00 1.000E+15 0.000 25000 /\n' ' PLOG / 1.000E+00 1.000E+15 0.000 25000 /\n' ' PLOG / 1.000E+02 1.000E+15 0.000 25000 /\n' 'DUP\n\n\n\nEND\n\n') ref_ckin_str2 = ( 'REACTIONS CAL/MOLE MOLES\n\n' 'H+O2(+N2)=OH+O(+N2) 1.000E+15 0.000 25000\n' ' PLOG / 1.000E-01 1.000E+15 0.000 25000 /\n' ' PLOG / 1.000E+00 1.000E+15 0.000 25000 /\n' ' PLOG / 1.000E+00 1.000E+15 0.000 25000 /\n' ' PLOG / 1.000E+02 1.000E+15 0.000 25000 /\n' 'DUP\n' 'H+O2(+N2)=OH+O(+N2) 1.000E+00 0.000 0\n' ' TCHEB/ 500.00 2000.00 /\n' ' PCHEB/ 0.03 100.00 /\n' ' CHEB / 6 4 /\n' ' CHEB / -1.620E+01 -1.183E-01 -5.423E-02 -1.476E-02 /\n' ' CHEB / 2.578E+00 1.614E-01 7.359E-02 1.880E-02 /\n' ' CHEB / 1.068E-01 -7.235E-02 -2.733E-02 -3.778E-03 /\n' ' CHEB / 3.955E-02 1.207E-02 3.402E-04 -2.695E-03 /\n' ' CHEB / 8.557E-03 4.345E-03 3.670E-03 1.608E-03 /\n' ' CHEB / 8.599E-04 -1.758E-03 -7.502E-04 7.396E-07 /\n' 'DUP\n\n\n\nEND\n\n') ref_ckin_str3 = ( 'REACTIONS CAL/MOLE MOLES\n\n' 'H+O2(+N2)=OH+O(+N2) 1.000E+00 0.000 0\n' ' TCHEB/ 500.00 2000.00 /\n' ' PCHEB/ 0.03 100.00 /\n' ' CHEB / 6 4 /\n' ' CHEB / -1.620E+01 -1.183E-01 -5.423E-02 -1.476E-02 /\n' ' CHEB / 2.578E+00 1.614E-01 7.359E-02 1.880E-02 /\n' ' CHEB / 1.068E-01 -7.235E-02 -2.733E-02 -3.778E-03 /\n' ' CHEB / 3.955E-02 1.207E-02 3.402E-04 -2.695E-03 /\n' ' CHEB / 8.557E-03 4.345E-03 3.670E-03 1.608E-03 /\n' ' CHEB / 8.599E-04 -1.758E-03 -7.502E-04 7.396E-07 /\n' 'DUP\n' 'H+O2(+N2)=OH+O(+N2) 1.000E+00 0.000 0\n' ' TCHEB/ 500.00 2000.00 /\n' ' PCHEB/ 0.03 100.00 /\n' ' CHEB / 6 4 /\n' ' CHEB / -1.620E+01 -1.183E-01 -5.423E-02 -1.476E-02 /\n' ' CHEB / 2.578E+00 1.614E-01 7.359E-02 1.880E-02 /\n' ' CHEB / 1.068E-01 -7.235E-02 -2.733E-02 -3.778E-03 /\n' ' CHEB / 3.955E-02 1.207E-02 3.402E-04 -2.695E-03 /\n' ' CHEB / 8.557E-03 4.345E-03 3.670E-03 1.608E-03 /\n' ' CHEB / 8.599E-04 -1.758E-03 -7.502E-04 7.396E-07 /\n' 'DUP\n\n\n\nEND\n\n') ref_ckin_str4 = ( 'REACTIONS CAL/MOLE MOLES\n\n' 'H+O2(+N2)=OH+O(+N2) 1.000E+12 1.500 50000\n' ' LOW / 1.000E+12 1.500 50000 /\n' ' TROE / 1.500E+00 8.000E+03 1.000E+02 1.000E+03 /\n' ' AR/1.400/ N2/1.700/ \n' 'DUP\n' 'H+O2(+N2)=OH+O(+N2) 1.000E+12 1.500 50000\n' ' LOW / 1.000E+12 1.500 50000 /\n' ' TROE / 1.500E+00 8.000E+03 1.000E+02 1.000E+03 /\n' ' AR/1.400/ N2/1.700/ \n' 'DUP\n\n\n\nEND\n\n') ref_ckin_str5 = ( 'REACTIONS CAL/MOLE MOLES\n\n' 'H+O2(+N2)=OH+O(+N2) 1.000E+12 1.500 50000\n' ' LOW / 1.000E+12 1.500 50000 /\n' ' AR/1.400/ N2/1.700/ \n' 'DUP\n' 'H+O2(+N2)=OH+O(+N2) 1.000E+12 1.500 50000\n' ' LOW / 1.000E+12 1.500 50000 /\n' ' AR/1.400/ N2/1.700/ \n' 'DUP\n\n\n\nEND\n\n') ckin_str1 = writer(DUP_PLOG_RXN_PARAM_DCT) ckin_str2 = writer(DUP_PLOG_CHEB_RXN_PARAM_DCT) ckin_str3 = writer(DUP_CHEB_RXN_PARAM_DCT) ckin_str4 = writer(DUP_TROE_RXN_PARAM_DCT) ckin_str5 = writer(DUP_LIND_RXN_PARAM_DCT) assert ckin_str1 == ref_ckin_str1 assert ckin_str2 == ref_ckin_str2 assert ckin_str3 == ref_ckin_str3 assert ckin_str4 == ref_ckin_str4 assert ckin_str5 == ref_ckin_str5