Skip to content

Commit 00a7d50

Browse files
Add -Y to PMF generator and additional ../ to paths (#622)
* Add -Y to PMF generator and additional ../ to paths * simplify code a bit * Change name of output file when Y is specified --------- Co-authored-by: Bruce Perry <bruce.perry@nrel.gov>
1 parent f7fb8e0 commit 00a7d50

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

Docs/sphinx/Utility.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ Generating a PMF file
3434

3535
The script ``cantera_pmf_generator.py`` solves a 1D unstrained premixed flame using `Cantera <https://doi.org/10.5281/zenodo.6387882>`_ and saves it in the appropriate file format for use by the Pele codes. To use this script, first follow the :ref:`CEPTR instructions <sec_ceptr_software>` for setting up ``poetry``. Then return to the ``Utility/PMF/`` directory and run the script: ::
3636

37-
poetry -C ../../Support/ceptr/ run python cantera_pmf_generator.py -m dodecane_lu -f NC12H26 -d 0.01 -o ./
37+
poetry -C ../../../Support/ceptr/ run python cantera_pmf_generator.py -m dodecane_lu -f NC12H26 -d 0.01 -o ./
3838

3939
This example computes a dodecane/air flame using the ``dodecane_lu`` mechanism on a 0.01 m domain, and saves the resulting file to the present directory. You may choose any mechanism included with PelePhysics, as the Cantera ``.yaml`` format is included for all mechanisms. If you choose a reduced mechanism with QSS species, the 1D solution will be obtained using the skeletal version of the mechanism without QSS species being remove, as Cantera does not support QSS by default. In this case, the script will also save a data file with QSS species removed (ending in ``-qssa-removed.dat``) that is suitable for use with the QSS mechanisms in Pele. A range of additional conditions may be specified at the command line. To see the full set of options, use the help feature: ::
4040

41-
poetry -C ../../Support/ceptr/ run python cantera_pmf_generator.py --help
41+
poetry -C ../../../Support/ceptr/ run python cantera_pmf_generator.py --help
4242

4343
Note that when running Cantera, you may need to adjust the domain size to be appropriate for your conditions in order for the solver to converge. At times, you may also need to adjust the solver tolerances and other parameters that are specified within the script.
4444

4545
An additional script is provided to allow plotting of the PMF solutions. This script is used as follows (if no variable index is specified, temperature is plotted by default): ::
4646

47-
poetry -C ../../Support/ceptr/ run python plotPMF.py <pmf-file> <variable-index>
47+
poetry -C ../../../Support/ceptr/ run python plotPMF.py <pmf-file> <variable-index>
4848

4949
.. _sec_turbinflow:
5050

Source/Utility/PMF/cantera_pmf_generator.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
help="Name of PelePhysics mechanism from Mechanisms",
3232
)
3333
parser.add_argument(
34-
"-pp", "--pp_home", default="../../", help="Path to PelePhysics directory"
34+
"-pp", "--pp_home", default="../../../", help="Path to PelePhysics directory"
3535
)
3636
parser.add_argument(
3737
"-f", "--fuel", default="CH4:1", help="Fuel stream mole-basis Cantera composition"
@@ -42,6 +42,12 @@
4242
default="O2:1, N2:3.76",
4343
help="Oxidizer stream mole-basis Cantera composition",
4444
)
45+
parser.add_argument(
46+
"-Y",
47+
"--massfrac",
48+
default=None,
49+
help="String of mass fractions (overrides -f and -ox options)",
50+
)
4551
parser.add_argument(
4652
"-T",
4753
"--temperature",
@@ -74,6 +80,7 @@
7480
mechanism = args.mechanism
7581
fuel_species = args.fuel
7682
ox_species = args.oxidizer
83+
Y_species = args.massfrac
7784

7885
# General
7986
p = args.pressure # pressure [Pa]
@@ -95,7 +102,11 @@
95102

96103
# Print information
97104
label_pre = "pmf-" + mechanism
98-
label = fuel_species.split(":")[0] + "_PHI" + str(phi) + "_T" + str(tin) + "_P" + str(p)
105+
if Y_species is not None:
106+
num_input_species = len([item for item in Y_species.split(',') if ':' in item])
107+
label = "Y" + str(num_input_species) + "_T" + str(tin) + "_P" + str(p)
108+
else:
109+
label = fuel_species.split(":")[0] + "_PHI" + str(phi) + "_T" + str(tin) + "_P" + str(p)
99110

100111
#################
101112
# Find mechanism in PelePhysics
@@ -149,8 +160,14 @@
149160

150161
# Set gas state to that of the unburned gas
151162
gas = Solution(mech_path, "gas")
152-
gas.TP = tin, p
153-
gas.set_equivalence_ratio(phi, fuel_species, ox_species, basis="mole")
163+
if Y_species is None:
164+
gas.TP = tin, p
165+
gas.set_equivalence_ratio(phi, fuel_species, ox_species, basis="mole")
166+
else:
167+
gas.TPY = tin, p, Y_species
168+
print("\nMass fractions read into Cantera:")
169+
for spec, massfrac in zip(gas.species_names, gas.Y):
170+
print(f" {spec}: {massfrac}")
154171

155172
# Create the free laminar premixed flame
156173
f = FreeFlame(gas, initial_grid)

0 commit comments

Comments
 (0)