Chemistry solvers
Setup and initialization
- pecans.chemistry.chem_setup.get_initial_conditions(config: dict, specie: str) ndarray[source]
Get the initial conditions for a given chemical specie based on how the configuration specifies it
- Parameters:
config – the configuration object
specie – the name of the chemical specie to load
- Returns:
the array of initial concentrations
- pecans.chemistry.chem_setup.setup_chemistry(config: dict) MechanismInterface[source]
Return the driver function that, when called, will calculate the change in concentrations due to chemistry.
- Parameters:
config – the configuration object. Must include the option “mechanism” in the “CHEMISTRY” section
- Returns:
1) the driver function. All driver functions must be called with dt, temperature, and number density of air followed by keyword-value pairs of all the chemical species in the mechanism. 2) the tuple of species names required by the mechanism.
- Return type:
function, tuple of str
Ideal chemical mechanisms
The ideal module contains the functions necessary to initialize and solve idealized chemistry cases. These are very
simplified chemical models that, rather that explicitly simulating a full chemical mechanism, instead impose some ideal
kinetic model on just a few species. For example, one is a simple first-order loss, where it is just specified that the
only chemical specie in the model has some lifetime.
- pecans.chemistry.ideal.init_explicit_first_order_chem_solver(config: dict) MechanismInterface[source]
Initialization function for the idealized first-order chemistry solver.
This requires only one option in the “mechanism_opts” section, namely “lifetime_seconds”. That value must be the first-order lifetime in seconds, i.e. how long it would take the concentration to decrease to \(1/e\) of its original value. It can take a second, optional option “species_name” which changes the name of the specie in the output file.
- Parameters:
config – the configuration dictionary.
- Returns:
the information needed to run this mechanism
- pecans.chemistry.ideal.init_explicit_two_phases_first_order_chem_solver(config: dict)[source]
Initialization function for the idealized two phases first-order chemistry solver.
- Parameters:
first_lifetime_seconds (int or float) – the first-order lifetime in seconds at the first phase, i.e. how long it would take the concentration to decrease to \(1/e\) of its original value.
second_lifetime_seconds (int or float) – the second-order lifetime in seconds at the second phase, i.e. how long it would take the concentration to decrease to \(1/e\) of its original value.
first_phase_duration (int or float) – the cutoff distance between first phase and second phase, i.e the distance interval it experiences the first phase lifetime in the unit of meter.
species_name – optional, the name that the specie in this mechanism will be referred to by. Default is “A”. Changing this has no real effect on the mechanism, just what it is called in the output.
kwargs – extra keyword arguments not used in this function.
- Returns:
the solver function and a tuple of species names.
- Return type:
function and tuple of str