Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix documentation bug for YAML format #1002

Merged
merged 2 commits into from
Mar 27, 2021
Merged

Fix documentation bug for YAML format #1002

merged 2 commits into from
Mar 27, 2021

Conversation

leesharma
Copy link
Contributor

Changes proposed in this pull request

  • Fixes the Reaction.listFromFile example syntax in the Solution docs by adding the required second argument (using the gas object created in a previous code example.)

    I'm not sure if this is the best solution: it has the downside of requiring gas to already be initialized to a Kinetics object with the appropriate species, which doesn't seem super useful. I'm new to Cantera, but I couldn't find an easy way to make a "dummy" Kinetics object. Is there a better way to do this?

    Maybe the example should just be removed?

If applicable, fill in the issue number this pull request is fixing

Fixes #1001

Checklist

  • There is a clear use-case for this code change
  • The commit message has a short title & references relevant issues
  • Build passes (scons build & scons test) and unit tests address code coverage
  • The pull request is ready for review

Makes the `Reaction.listFromFile` example valid by adding the required
Kinetics object as the second argument (`gas`, created in the example
above.)

I'm not sure if this is the best solution: it has the major downside of
requiring `gas` to already be initialized to a `Kinetics` object with
the appropriate species. I'm new to Cantera, but I couldn't find an easy
way to make a "dummy" Kinetics object. Is there a better way to do this?

Maybe the example should just be removed?
Copy link
Member

@speth speth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out. While this requirement is a little confusing, you need to know the thermo model of each reactant species in a reaction in order to convert the rate constant to Cantera's internal unit system of mks+kmol. This wasn't necessary before because the XML format already had the rate constants converted to those units, and the CTI sort of cheated and already knew the right units to use for the handful of thermo models that it supported.

@@ -63,7 +63,7 @@ class Solution(ThermoPhase, Kinetics, Transport):
directly in Python::

spec = ct.Species.listFromFile('gri30.yaml')
rxns = ct.Reaction.listFromFile('gri30.yaml')
rxns = ct.Reaction.listFromFile('gri30.yaml', gas)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this to give a complete example, where you first initialize a gas with the species but no reactions, then create the list of reactions? Right now, gas is used before it is defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed an update defining spec_gas explicitly from the species (plus a sentence stating the requirement). It looks a bit contrived, but the example runs without error. What do you think?

@ischoegl
Copy link
Member

One alternative would be to provide a base unit system as a second argument, which however would require the C++ unit system being exposed to Python. Another issue are electrochemical reactions, where the current YAML import requires associated thermo models.

Now the example will run as-is and includes a sentence stating that the
`Kinetics` object is required with YAML.
@speth
Copy link
Member

speth commented Mar 27, 2021

@ischoegl, the unit system isn't really the issue. What is needed to convert the coefficients of the rate constant are the dimensions of the standard concentration for each reactant, along with the dimensions of the phase where the reaction occurs.

Copy link
Member

@speth speth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Maybe an option for making this less awkward would be to get rid of the Reaction.listFromFile constructor and add methods to the Kinetics class for creating a list of Reactions objects from a file, and a method for adding a list of Reaction objects to that Kinetics object, rather than specifying the reactions in the constructor.

@speth speth merged commit a4b9bb5 into Cantera:main Mar 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation bug for YAML format
3 participants