pyjac.functional_tester.test module¶
Module for testing function (accuracy) of pyJac.
-
class
pyjac.functional_tester.test.
ReactorConstPres
(gas)[source]¶ Bases:
object
Object for constant pressure ODE system.
Parameters: gas ( cantera.Solution
) –cantera.Solution
object with the kinetic systemReturns: Return type: None
-
class
pyjac.functional_tester.test.
ReactorConstVol
(gas)[source]¶ Bases:
object
Object for constant volume ODE system.
Initialize
ReactorConstVol
Parameters: gas ( cantera.Solution
) –cantera.Solution
object with the kinetic systemReturns: Return type: None
-
pyjac.functional_tester.test.
convert_mech
(mech_filename, therm_filename=None)[source]¶ Convert a mechanism and return a string with the filename.
Convert a CHEMKIN format mechanism to the Cantera CTI format using the Cantera built-in script
ck2cti
.Parameters: Returns: mech_filename – Filename of converted mechanism in Cantera
.cti
format.Return type:
-
class
pyjac.functional_tester.test.
AutodiffJacob
(pressure, fwd_spec_map)[source]¶ Bases:
object
Class for
Initialize autodifferentation object.
Parameters: - pressure (float) – Pressure in Pascals
- fwd_spec_map (
numpy.array
) – Map of original species indices to new indices
Returns: Return type: None
-
pyjac.functional_tester.test.
is_pdep
(rxn)[source]¶ Check if reaction is traditionally pressure dependent
Parameters: rxn ( ReacInfo
) – Reaction object of interestReturns: Return type: True
if third-body, falloff, or chemically activated reaction.
-
pyjac.functional_tester.test.
run_pasr
(pasr_input_file, mech_filename, pasr_output_file=None)[source]¶ Run PaSR simulation to get thermochemical data for testing.
Parameters: Returns: state_data – Array with state data (time, temperature, pressure, mass fractions)
Return type: numpy.array
-
class
pyjac.functional_tester.test.
cpyjac_evaluator
(build_dir, gas, module_name='pyjacob', filename='mechanism.h')[source]¶ Bases:
object
Class for pyJac-based Jacobian matrix evaluator
-
check_numbers
(build_dir, gas, filename='mechanism.h')[source]¶ Ensure numbers of species and forward reaction match.
Parameters: Returns: Return type: None
-
check_optimized
(build_dir, gas, filename='mechanism.h')[source]¶ Check if pyJac files were cache-optimized (and thus rearranged)
Parameters: Returns: Return type: None
-
eval_conc
(temp, pres, mass_frac, conc)[source]¶ Evaluate species concentrations at current state.
Parameters: Returns: Return type: None
-
eval_rxn_rates
(temp, pres, conc, fwd_rates, rev_rates)[source]¶ Evaluate reaction rates of progress at current state.
Parameters: Returns: Return type: None
-
get_rxn_pres_mod
(temp, pres, conc, pres_mod)[source]¶ Evaluate reaction rate pressure modifications at current state.
Parameters: Returns: Return type: None
-
eval_spec_rates
(fwd_rates, rev_rates, pres_mod, spec_rates)[source]¶ Evaluate species overall production rates at current state.
Parameters: - fwd_rates (
numpy.array
) – Reaction forward rates of progress, in kmol/m^3/s - rev_rates (
numpy.array
) – Reaction reverse rates of progress, in kmol/m^3/s - pres_mod (
numpy.array
) – Reaction rate pressure modification - spec_rates (
numpy.array
) – Reaction reverse rates of progress, in kmol/m^3/s
Returns: Return type: None
- fwd_rates (
-
eval_jacobian
(t, pres, y, jacob)[source]¶ Evaluate the Jacobian matrix
Parameters: Returns: Return type: None
-
-
class
pyjac.functional_tester.test.
cupyjac_evaluator
(build_dir, gas, state_data)[source]¶ Bases:
pyjac.functional_tester.test.cpyjac_evaluator
Class for CUDA-based pyJac Jacobian matrix evaluator
-
update
(index)[source]¶ Updates evaluator index
Parameters: index (int) – Index of data for evaluating quantities Returns: Return type: None
-
czeros
(shape)[source]¶ Return array of zeros in C ordering.
Parameters: shape (int) – Shape of array Returns: Return type: numpy.array
of zeros with shapeshape
in C ordering
-
eval_conc
(temp, pres, mass_frac, conc)[source]¶ Evaluate species concentrations at current state.
Parameters: Returns: Return type: None
-
eval_rxn_rates
(temp, pres, conc, fwd_rates, rev_rates)[source]¶ Evaluate reaction rates of progress at current state.
Parameters: Returns: Return type: None
-
get_rxn_pres_mod
(temp, pres, conc, pres_mod)[source]¶ Evaluate reaction rate pressure modifications at current state.
Parameters: Returns: Return type: None
-
eval_spec_rates
(fwd_rates, rev_rates, pres_mod, spec_rates)[source]¶ Evaluate species overall production rates at current state.
Parameters: - fwd_rates (
numpy.array
) – Reaction forward rates of progress, in kmol/m^3/s - rev_rates (
numpy.array
) – Reaction reverse rates of progress, in kmol/m^3/s - pres_mod (
numpy.array
) – Reaction rate pressure modification - spec_rates (
numpy.array
) – Reaction reverse rates of progress, in kmol/m^3/s
Returns: Return type: None
- fwd_rates (
-
-
class
pyjac.functional_tester.test.
tchem_evaluator
(build_dir, gas, state_data, mechfile, thermofile, module_name='py_tchem', filename='mechanism.h')[source]¶ Bases:
pyjac.functional_tester.test.cpyjac_evaluator
Class for TChem-based Jacobian matrix evaluator
-
get_conc
(conc)[source]¶ Evaluate species concentrations at current state.
Parameters: conc ( numpy.array
) – Species concentrations, in kmol/m^3Returns: Return type: None
-
get_rxn_rates
(fwd_rates, rev_rates)[source]¶ Evaluate reaction rates of progress at current state.
Parameters: - fwd_rates (
numpy.array
) – Reaction forward rates of progress, in kmol/m^3/s - rev_rates (
numpy.array
) – Reaction reverse rates of progress, in kmol/m^3/s
Returns: Return type: None
- fwd_rates (
-
get_spec_rates
(spec_rates)[source]¶ Evaluate species overall production rates at current state.
Parameters: spec_rates ( numpy.array
) – Reaction reverse rates of progress, in kmol/m^3/sReturns: Return type: None
-
-
pyjac.functional_tester.test.
safe_remove
(file)[source]¶ Try to safely remove a file
Parameters: file (str) – Path for file to be removed Returns: Return type: None
-
pyjac.functional_tester.test.
test
(lang, home_dir, build_dir, mech_filename, therm_filename=None, pasr_input_file='pasr_input.yaml', generate_jacob=True, compile_jacob=True, seed=None, pasr_output_file=None, last_spec=None, cache_optimization=False, no_shared=False, tchem_flag=False, only_rxn=None, do_not_remove=False, condition_numbers=None)[source]¶ Compares pyJac results against Cantera (and optionally TChem) using state data from PaSR simulations.
Parameters: - lang ({'c', 'cuda'}) – Programming language
- home_dir (str) – Path to home directory for testing and data
- build_dir (str) – Path to directory for building Jacobian files
- mech_filename (str) – Chemkin- or Cantera-format mechanism file
- therm_filename (str) – Optional; name of thermodynamic database file (if needed)
- pasr_input_file (str) – Optional; name of YAML-formatted file with PaSR test input
- generate_jacob (bool) – Optional; if
True
, generate Jacobian files. Otherwise, use existing files. - compile_jacob (bool) – Optional; if
True
, compile Jacobian files. Otherwise, using existing. - seed (int) – Optional; random seed for PaSR
- pasr_output_file (str) – Optional; name of output file for saving PaSR results
- last_spec (str) – Optional; name of species to move to last position. If not specified, will try searching for N2, Ar, or He.
- cache_optimization (bool) – If
True
, enable reordering to optimize cache usage - no_shared (bool) – If
True
, do not use GPU shared memory - tchem_flag (bool) – If
True
, compare with TChem results - only_rxn (str) – Optional; string with list of reaction numbers to retain. All other reactions removed.
- do_not_remove (bool) – If
True
, keep all generated files. - condition_numbers (int) – Optional; string with list of conditions numbers to use.
Returns: Return type: None