Docstrings updated: types for properties and solver description added
This commit is contained in:
parent
b158a86852
commit
9fc5ea2dc1
|
@ -29,7 +29,7 @@ p_atm = 101325 # Pa
|
||||||
_epsy = 1e-18
|
_epsy = 1e-18
|
||||||
|
|
||||||
|
|
||||||
def lookup(prop_array: FloatArray,
|
def _lookup(prop_array: FloatArray,
|
||||||
temperature: FloatArray | float,
|
temperature: FloatArray | float,
|
||||||
t_offset: float) -> FloatArray:
|
t_offset: float) -> FloatArray:
|
||||||
"""linear interpolates values from the given prop_array
|
"""linear interpolates values from the given prop_array
|
||||||
|
@ -58,8 +58,8 @@ def species(pattern: str = '*', element_names: str | list[str] = [], use_regex:
|
||||||
Args:
|
Args:
|
||||||
pattern: Optional filter for specific molecules
|
pattern: Optional filter for specific molecules
|
||||||
Placeholder characters:
|
Placeholder characters:
|
||||||
# A number including non written ones: 'C#H#' matches 'CH4'
|
# A number including non written ones: 'C#H#' matches 'CH4';
|
||||||
$ Arbitrary element name
|
$ Arbitrary element name;
|
||||||
* Any sequence of characters
|
* Any sequence of characters
|
||||||
element_names:
|
element_names:
|
||||||
restrict results to species that contain only the specified elements.
|
restrict results to species that contain only the specified elements.
|
||||||
|
@ -95,7 +95,17 @@ def species(pattern: str = '*', element_names: str | list[str] = [], use_regex:
|
||||||
|
|
||||||
|
|
||||||
def set_solver(solver: Literal['gibs minimization', 'system of equations']) -> None:
|
def set_solver(solver: Literal['gibs minimization', 'system of equations']) -> None:
|
||||||
"""Select a solver for chemical equilibrium.
|
"""
|
||||||
|
Select a solver for chemical equilibrium.
|
||||||
|
|
||||||
|
Solvers:
|
||||||
|
- **system of equations** (default): Finds the root for a system of
|
||||||
|
equations covering a minimal set of equilibrium equations and elemental balance.
|
||||||
|
The minimal set of equilibrium equations is derived by SVD using the null_space
|
||||||
|
implementation of scipy.
|
||||||
|
|
||||||
|
- **gibs minimization**: Minimizes the total Gibbs Enthalpy while keeping
|
||||||
|
the elemental composition constant using the SLSQP implementation of scipy
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
solver: Name of the solver
|
solver: Name of the solver
|
||||||
|
@ -127,10 +137,10 @@ class fluid_system:
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
species_names (list[str]): List of selected species in the fluid_system
|
species_names (list[str]): List of selected species in the fluid_system
|
||||||
array_molar_mass: Array of the molar masses of the species in the fluid_system
|
array_molar_mass (FloatArray): Array of the molar masses of the species in the fluid_system
|
||||||
array_element_composition: Array of the element composition of the species in the fluid_system.
|
array_element_composition (FloatArray): Array of the element composition of the species in the fluid_system.
|
||||||
Dimension is: (number of species, number of elements)
|
Dimension is: (number of species, number of elements)
|
||||||
array_atomic_mass: Array of the atomic masses of the elements in the fluid_system
|
array_atomic_mass (FloatArray): Array of the atomic masses of the elements in the fluid_system
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, species: list[str] | str, t_min: int = 250, t_max: int = 2000):
|
def __init__(self, species: list[str] | str, t_min: int = 250, t_max: int = 2000):
|
||||||
|
@ -202,7 +212,7 @@ class fluid_system:
|
||||||
Returns:
|
Returns:
|
||||||
Array with the enthalpies of each specie in J/mol
|
Array with the enthalpies of each specie in J/mol
|
||||||
"""
|
"""
|
||||||
return lookup(self._h_array, t, self._t_offset)
|
return _lookup(self._h_array, t, self._t_offset)
|
||||||
|
|
||||||
def get_species_s(self, t: float | FloatArray) -> FloatArray:
|
def get_species_s(self, t: float | FloatArray) -> FloatArray:
|
||||||
"""Get the molar entropies for all species in the fluid system
|
"""Get the molar entropies for all species in the fluid system
|
||||||
|
@ -213,7 +223,7 @@ class fluid_system:
|
||||||
Returns:
|
Returns:
|
||||||
Array with the entropies of each specie in J/mol/K
|
Array with the entropies of each specie in J/mol/K
|
||||||
"""
|
"""
|
||||||
return lookup(self._s_array, t, self._t_offset)
|
return _lookup(self._s_array, t, self._t_offset)
|
||||||
|
|
||||||
def get_species_cp(self, t: float | FloatArray) -> FloatArray:
|
def get_species_cp(self, t: float | FloatArray) -> FloatArray:
|
||||||
"""Get the isobaric molar heat capacity for all species in the fluid system
|
"""Get the isobaric molar heat capacity for all species in the fluid system
|
||||||
|
@ -224,7 +234,7 @@ class fluid_system:
|
||||||
Returns:
|
Returns:
|
||||||
Array with the heat capacities of each specie in J/mol/K
|
Array with the heat capacities of each specie in J/mol/K
|
||||||
"""
|
"""
|
||||||
return lookup(self._cp_array, t, self._t_offset)
|
return _lookup(self._cp_array, t, self._t_offset)
|
||||||
|
|
||||||
# def get_species_g(self, t: float | NDArray[_Float]) -> NDArray[_Float]:
|
# def get_species_g(self, t: float | NDArray[_Float]) -> NDArray[_Float]:
|
||||||
# return lookup(self._g_array, t, self._t_offset)
|
# return lookup(self._g_array, t, self._t_offset)
|
||||||
|
@ -239,7 +249,7 @@ class fluid_system:
|
||||||
Returns:
|
Returns:
|
||||||
Array of gibbs free energy divided by RT (dimensionless)
|
Array of gibbs free energy divided by RT (dimensionless)
|
||||||
"""
|
"""
|
||||||
return lookup(self._g_rt_array, t, self._t_offset)
|
return _lookup(self._g_rt_array, t, self._t_offset)
|
||||||
|
|
||||||
def __add__(self, other: 'fluid_system') -> 'fluid_system':
|
def __add__(self, other: 'fluid_system') -> 'fluid_system':
|
||||||
assert isinstance(other, self.__class__)
|
assert isinstance(other, self.__class__)
|
||||||
|
@ -255,13 +265,12 @@ class fluid:
|
||||||
one or more species.
|
one or more species.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
fs: Reference to the fluid_system used for this fluid
|
species (list[str]): List of species names in the associated fluid_system
|
||||||
species: List of species names in the associated fluid_system
|
array_composition (FloatArray): Array of the molar amounts of the species in the fluid
|
||||||
array_composition: Array of the molar amounts of the species in the fluid
|
array_element_composition (FloatArray): Array of the element composition in the fluid
|
||||||
array_element_composition: Array of the element composition in the fluid
|
array_fractions (FloatArray): Array of the molar fractions of the species in the fluid
|
||||||
array_fractions: Array of the molar fractions of the species in the fluid
|
total (FloatArray | float): Array of the sums of the molar amount of all species
|
||||||
total: Array of the sums of the molar amount of all species
|
fs (fluid_system): Reference to the fluid_system used for this fluid
|
||||||
fs: Reference to the fluid_system used for this fluid
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__array_priority__ = 100
|
__array_priority__ = 100
|
||||||
|
@ -598,7 +607,7 @@ class elements:
|
||||||
"""Represent a fluid by composition of elements.
|
"""Represent a fluid by composition of elements.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
array_element_composition: Array of the element composition
|
array_element_composition (FloatArray): Array of the element composition
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__array_priority__ = 100
|
__array_priority__ = 100
|
||||||
|
|
Loading…
Reference in New Issue