pyjac.functional_tester.partially_stirred_reactor module¶
Module for partially stirred reactor simulations.
-
class
pyjac.functional_tester.partially_stirred_reactor.
Stream
(gas, flow)[source]¶ Bases:
object
Class for inlet flow stream into reactor.
Initializes stream object.
Parameters: - gas (
cantera.Solution
) – Constant thermochemical state of this stream. - flow (float) – Flow rate of this stream.
Returns: Return type: None
- gas (
-
class
pyjac.functional_tester.partially_stirred_reactor.
Particle
(gas)[source]¶ Bases:
object
Class for particle in reactor.
Initialize particle object with thermochemical state.
Parameters: gas ( cantera.Solution
) – Initial thermochemical state of particleReturns: Return type: None -
particle_mass
= 0.1¶
-
-
pyjac.functional_tester.partially_stirred_reactor.
equivalence_ratio
(gas, eq_ratio, fuel, oxidizer, complete_products)[source]¶ Calculate the mixture mole fractions from the equivalence ratio.
Given the equivalence ratio, fuel mixture, oxidizer mixture, the products of complete combustion, and any additional species for the mixture, return a string containing the mole fractions of the species, suitable for setting the state of the input ThermoPhase.
Parameters: - gas (
cantera.ThermoPhase
) – Cantera ThermoPhase object containing the desired species. - eq_ratio (float) – Equivalence ratio
- fuel (dict) – Dictionary of molecules in the fuel mixture and the fraction of each molecule in the fuel mixture.
- oxidizer (dict) – Dictionary of molecules in the oxidizer mixture and the fraction of each molecule in the oxidizer mixture.
- complete_products (list of
str
) – List of species in the products of complete combustion.
Returns: reactants – String with reactants and mole fractions (e.g.,
'H2:2.0,O2:1.0'
).Return type: - gas (
-
pyjac.functional_tester.partially_stirred_reactor.
pairwise
(iterable)[source]¶ Takes list of objects and converts into list of pairs.
s -> (s0,s1), (s2,s3), (s4, s5), …
Parameters: iterable (list) – List of objects. Returns: zipped – Zip with pairs of objects from iterable
.Return type: zip
-
pyjac.functional_tester.partially_stirred_reactor.
mix_substep
(particles, dt, tau_mix)[source]¶ Pairwise mixing step.
Parameters: Returns: Return type: None
-
pyjac.functional_tester.partially_stirred_reactor.
reaction_worker
(part_tup)[source]¶ Worker for performing reaction substep given initial state.
Parameters: part_tup (tuple) – Tuple with mechanism file, temperature, pressure, mass fractions, and time step. Returns: p – Thermochemical composition of particle following reaction. Return type: numpy.array
-
pyjac.functional_tester.partially_stirred_reactor.
reaction_substep
(particles, dt, mech)[source]¶ Advance each of the particles in time through reactions.
Parameters: Returns: Return type: None
-
pyjac.functional_tester.partially_stirred_reactor.
select_pairs
(particles, num_pairs, num_skip=0)[source]¶ Randomly select pair(s) of particles and move to end of list.
Parameters: Returns: Return type: None
-
pyjac.functional_tester.partially_stirred_reactor.
inflow
(streams)[source]¶ Determine index of stream for next inflowing particle.
Parameters: streams (list of Stream
) – List of Stream objects for inlet streams.Returns: i_inflow – Index of stream for next inflowing particle. Return type: int
-
pyjac.functional_tester.partially_stirred_reactor.
save_data
(idx, time, particles, data)[source]¶ Save temperature and species mass fraction from all particles to array.
Parameters: Returns: Return type: None
-
pyjac.functional_tester.partially_stirred_reactor.
run_simulation
(mech, case, init_temp, pres, eq_ratio, fuel, oxidizer, complete_products=['CO2', 'H2O', 'N2'], num_part=100, tau_res=0.01, tau_mix=0.001, tau_pair=0.001, num_res=10)[source]¶ Perform partially stirred reactor (PaSR) simulation.
Parameters: - mech (str) – Mechanism filename (in Cantera format).
- case ({'Premixed','Non-premixed'}) – Case of PaSR simulation; {‘Premixed’, ‘Non-premixed’}.
- init_temp (float) – Initial temperature [K].
- pres (float) – Pressure [atm].
- eq_ratio (float) – Equivalence ratio.
- fuel (dict) – Dictionary of molecules in the fuel mixture and the fraction of each molecule in the fuel mixture.
- oxidizer (dict) – Dictionary of molecules in the oxidizer mixture and the fraction of each molecule in the oxidizer mixture.
- complete_products (Optional[list]) – List of species in the products of complete combustion. Optional, default [‘CO2’, ‘H2O’, ‘N2’].
- num_part (Optional[int]) – Number of particles. Optional, default 100.
- tau_res (Optional[float]) – Residence time [s]. Optional, default 10 [ms].
- tau_mix (Optional[float]) – Mixing timescale [s]. Optional, default 1 [ms].
- tau_pair (Optional[float]) – Pairing timescale [s]. Optional, default 1 [ms].
- num_res (Optional[int]) – Numer of residence times to simulate. Optional, default 5.
Returns: particle_data – numpy.array with full particle data.
Return type: numpy.array