[Input] rename --id to --phase in ck2yaml options

The option --phase is consistent with the resulting yaml entry in 'phases'.
The --id option is still supported, with a warning being issued.
This commit is contained in:
Ingmar Schoegl 2019-10-01 13:49:03 -05:00 committed by Ray Speth
parent 3bf09fbd7f
commit b5e4f25454
3 changed files with 29 additions and 16 deletions

View file

@ -78,18 +78,18 @@ public:
void setTransport(shared_ptr<Transport> transport);
//! Accessor for the ThermoPhase object
shared_ptr<ThermoPhase> thermo() {
return m_thermo;
ThermoPhase& thermo() {
return *m_thermo;
}
//! Accessor for the Kinetics object
shared_ptr<Kinetics> kinetics() {
return m_kinetics;
Kinetics& kinetics() {
return *m_kinetics;
}
//! Accessor for the Transport object
shared_ptr<Transport> transport() {
return m_transport;
Transport& transport() {
return *m_transport;
}
protected:

View file

@ -12,7 +12,7 @@ Usage:
[--thermo=<filename>]
[--transport=<filename>]
[--surface=<filename>]
[--id=<phase-id>]
[--phase=<phasename>]
[--output=<filename>]
[--permissive]
[-d | --debug]
@ -32,7 +32,8 @@ specified as 'input' and the surface phase input file should be specified as
'surface'.
The '--permissive' option allows certain recoverable parsing errors (e.g.
duplicate transport data) to be ignored.
duplicate transport data) to be ignored. The '--phase=<phasename>' option
is used to override default phase names (i.e. 'gas').
"""
from collections import defaultdict, OrderedDict
@ -1797,7 +1798,7 @@ class Parser:
if speciesName in self.species_dict:
if len(data) != 7:
raise InputError('Unable to parse line {} of {}:\n"""\n{}"""\n'
'6 transport parameters expected, but found {}.',
'6 transport parameters expected, but found {}.',
line_offset + i, filename, original_line, len(data)-1)
if self.species_dict[speciesName].transport is None:
@ -2024,9 +2025,9 @@ def convert_mech(input_file, thermo_file=None, transport_file=None, surface_file
def main(argv):
longOptions = ['input=', 'thermo=', 'transport=', 'surface=', 'id=',
longOptions = ['input=', 'thermo=', 'transport=', 'surface=', 'phase=',
'output=', 'permissive', 'help', 'debug', 'quiet',
'no-validate']
'no-validate', 'id=']
try:
optlist, args = getopt.getopt(argv, 'dh', longOptions)
@ -2054,7 +2055,13 @@ def main(argv):
quiet = '--quiet' in options
transport_file = options.get('--transport')
surface_file = options.get('--surface')
phase_name = options.get('--id', 'gas')
if '--id' in options:
phase_name = options.get('--id', 'gas')
logging.warning("\nFutureWarning: "
"option '--id=...' is superseded by '--phase=...'")
else:
phase_name = options.get('--phase', 'gas')
if not input_file and not thermo_file:
print('At least one of the arguments "--input=..." or "--thermo=..."'

View file

@ -38,9 +38,9 @@ class Solution(ThermoPhase, Kinetics, Transport):
gas = ct.Solution('diamond.yaml', phase='gas')
diamond = ct.Solution('diamond.yaml', phase='diamond')
The name of the `Solution` object needs to be unique and defaults to the
*phase* specified in the input file. If another object using the same
constituting information already exists, the name is automatically appended
The name of the `Solution` object needs to be unique and defaults to the
*phase* specified in the input file. If another object using the same
constituting information already exists, the name is automatically appended
by a suffix. A custom name can be set via the ``name`` keyword argument of
the constructor, i.e.::
@ -60,6 +60,12 @@ class Solution(ThermoPhase, Kinetics, Transport):
``species`` and ``reactions`` keyword arguments are lists of `Species` and
`Reaction` objects, respectively.
Types of underlying models that form the composite `Solution` object are
queried using the ``thermo_model``, ``kinetics_model`` and
``transport_model`` attributes; further, the ``composite`` attribute is a
shorthand returning a tuple containing the types of the three contitutive
models.
For non-trivial uses cases of this functionality, see the examples
`extract_submechanism.py <https://cantera.org/examples/python/extract_submechanism.py.html>`_
and `mechanism_reduction.py <https://cantera.org/examples/python/mechanism_reduction.py.html>`_.
@ -72,7 +78,7 @@ class Solution(ThermoPhase, Kinetics, Transport):
ideal_gas(name='gas', elements='O H Ar',
species='gri30: all',
reactions='gri30: all',
options=['skip_undeclared_elements', 'skip_undeclared_species',
options=['skip_undeclared_elements', 'skip_undeclared_species',
'skip_undeclared_third_bodies'],
initial_state=state(temperature=300, pressure=101325))'''
gas = ct.Solution(source=cti_def)