From b5e4f2545425f8714309536f7f26a0400d7af2fa Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Tue, 1 Oct 2019 13:49:03 -0500 Subject: [PATCH] [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. --- include/cantera/base/SolutionBase.h | 12 ++++++------ interfaces/cython/cantera/ck2yaml.py | 19 +++++++++++++------ interfaces/cython/cantera/composite.py | 14 ++++++++++---- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/include/cantera/base/SolutionBase.h b/include/cantera/base/SolutionBase.h index ea5ee8bb2..cec66ffb1 100644 --- a/include/cantera/base/SolutionBase.h +++ b/include/cantera/base/SolutionBase.h @@ -78,18 +78,18 @@ public: void setTransport(shared_ptr transport); //! Accessor for the ThermoPhase object - shared_ptr thermo() { - return m_thermo; + ThermoPhase& thermo() { + return *m_thermo; } //! Accessor for the Kinetics object - shared_ptr kinetics() { - return m_kinetics; + Kinetics& kinetics() { + return *m_kinetics; } //! Accessor for the Transport object - shared_ptr transport() { - return m_transport; + Transport& transport() { + return *m_transport; } protected: diff --git a/interfaces/cython/cantera/ck2yaml.py b/interfaces/cython/cantera/ck2yaml.py index 43bef62a1..c935822fb 100644 --- a/interfaces/cython/cantera/ck2yaml.py +++ b/interfaces/cython/cantera/ck2yaml.py @@ -12,7 +12,7 @@ Usage: [--thermo=] [--transport=] [--surface=] - [--id=] + [--phase=] [--output=] [--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=' 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=..."' diff --git a/interfaces/cython/cantera/composite.py b/interfaces/cython/cantera/composite.py index 07142a317..1431b6120 100644 --- a/interfaces/cython/cantera/composite.py +++ b/interfaces/cython/cantera/composite.py @@ -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 `_ and `mechanism_reduction.py `_. @@ -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)