Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor setter and getter templates for units
* To allow setting properties on the upstream classes, __setattr__ is implemented and checks whether the attribute is defined on this class. This requires setting the phase instance directly into the __dict__ attribute to avoid a recursion error. * Class inheritance is not used here because it is not easy to set attributes on the super class. By design, super() does not allow setting properties, only getting. Furthermore, since the base PureFluid class is defined in Cython, the attributes of that class cannot be set by subclasses at all, again by design. * The PureFluid class implemented here does not inherit from the Solution class implemented here because eventually this Solution class will include methods and properties related to kinetics and transport, which are not implemented for PureFluid. The base PureFluid class is a subclass of ThermoPhase only, whereas the base Solution class is a subclass of ThermoPhase, Kinetics, and Transport. * To reflect the distinction between Solution and ThermoPhase, the template variables are renamed. * Several methods of the PureFluid are getters only, despite having three properties. These attributes are fixed here. TPQ is the only three-property attribute with a setter. * Setter methods now raise a CanteraError if the unit conversion to base units fails due to an AttributeError.
- Loading branch information
1 parent
24e7f0e
commit 09faa1e
Showing
2 changed files
with
175 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters