Skip to content
This repository has been archived by the owner on Jun 14, 2022. It is now read-only.

Commit

Permalink
Standardize naming of molar properties and fix typos in docs (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
prehner authored Mar 9, 2022
1 parent b8128cd commit 1d10196
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/parameter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ where
Self::from_records(pure_records, binary_record)
}

/// Return the original pure and binary records that werde used to construct the parameters.
/// Return the original pure and binary records that were used to construct the parameters.
#[allow(clippy::type_complexity)]
fn records(
&self,
Expand Down
4 changes: 2 additions & 2 deletions src/python/phase_equilibria.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ macro_rules! impl_vle_state {
/// RuntimeError
/// When pressure iteration fails or no phase equilibrium is found.
#[staticmethod]
#[pyo3(text_signature = "(eos, temperature, pressure, feed, initial_vle_state=None, max_iter=None, tol=None, verbosity=None, non_volatile_components=None)")]
#[pyo3(text_signature = "(eos, temperature, pressure, feed, init_vle_state=None, max_iter=None, tol=None, verbosity=None, non_volatile_components=None)")]
pub fn tp_flash(
eos: $py_eos,
temperature: PySINumber,
Expand Down Expand Up @@ -676,7 +676,7 @@ macro_rules! impl_vle_state {
/// ------
/// RuntimeError
/// When pressure iteration fails or no phase equilibrium is found.
#[pyo3(text_signature = "($self, initial_vle_state=None, max_iter=None, tol=None, verbosity=None, non_volatile_components=None)")]
#[pyo3(text_signature = "($self, init_vle_state=None, max_iter=None, tol=None, verbosity=None, non_volatile_components=None)")]
pub fn tp_flash(
&self,
init_vle_state: Option<&PyPhaseEquilibrium>,
Expand Down
28 changes: 15 additions & 13 deletions src/python/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@ macro_rules! impl_state {
/// molefracs : numpy.ndarray[float]
/// Molar fraction of each component.
/// pressure : SINumber, optional
/// System pressure.
/// enthalpy : SINumber, optional
/// System enthalpy.
/// entropy : SINumber, optional
/// System entropy.
/// Pressure.
/// molar_enthalpy : SINumber, optional
/// Molar enthalpy.
/// molar_entropy : SINumber, optional
/// Molar entropy.
/// molar_internal_energy: SINumber, optional
/// Molar internal energy
/// density_initialization : {'vapor', 'liquid', SINumber, None}, optional
/// Method used to initialize density for density iteration.
/// 'vapor' and 'liquid' are inferred from the maximum density of the equation of state.
/// If no density or keyword is provided, the vapor and liquid phase is tested and, if
/// different, the result with the lower free energy is returned.
/// initial_temperature : SINumber, optional
/// Initial temperature for temperature iteration. Can improve convergence
/// when the state is specified with pressure and entropy or enthalpy.
/// when the state is specified with pressure and molar entropy or enthalpy.
///
/// Returns
/// -------
Expand All @@ -46,7 +48,7 @@ macro_rules! impl_state {
/// When the state cannot be created using the combination of input.
#[pyclass(name = "State", unsendable)]
#[derive(Clone)]
#[pyo3(text_signature = "(eos, temperature=None, volume=None, density=None, partial_density=None, total_moles=None, moles=None, molefracs=None, pressure=None, enthalpy=None, entropy=None, density_initialization=None, initial_temperature=None)")]
#[pyo3(text_signature = "(eos, temperature=None, volume=None, density=None, partial_density=None, total_moles=None, moles=None, molefracs=None, pressure=None, molar_enthalpy=None, molar_entropy=None, molar_internal_energy=None, density_initialization=None, initial_temperature=None)")]
pub struct PyState(pub State<SIUnit, $eos>);

#[pymethods]
Expand All @@ -62,9 +64,9 @@ macro_rules! impl_state {
moles: Option<PySIArray1>,
molefracs: Option<&PyArray1<f64>>,
pressure: Option<PySINumber>,
enthalpy: Option<PySINumber>,
entropy: Option<PySINumber>,
internal_energy: Option<PySINumber>,
molar_enthalpy: Option<PySINumber>,
molar_entropy: Option<PySINumber>,
molar_internal_energy: Option<PySINumber>,
density_initialization: Option<&PyAny>,
initial_temperature: Option<PySINumber>,
) -> PyResult<Self> {
Expand Down Expand Up @@ -98,9 +100,9 @@ macro_rules! impl_state {
moles.as_deref(),
x.as_ref(),
pressure.map(|s| s.into()),
enthalpy.map(|s| s.into()),
entropy.map(|s| s.into()),
internal_energy.map(|s| s.into()),
molar_enthalpy.map(|s| s.into()),
molar_entropy.map(|s| s.into()),
molar_internal_energy.map(|s| s.into()),
density_init?,
initial_temperature.map(|s| s.into()),
)?;
Expand Down
42 changes: 21 additions & 21 deletions src/state/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ pub struct StateBuilder<'a, U: EosUnit, E: EquationOfState> {
moles: Option<&'a QuantityArray1<U>>,
molefracs: Option<&'a Array1<f64>>,
pressure: Option<QuantityScalar<U>>,
enthalpy: Option<QuantityScalar<U>>,
entropy: Option<QuantityScalar<U>>,
internal_energy: Option<QuantityScalar<U>>,
molar_enthalpy: Option<QuantityScalar<U>>,
molar_entropy: Option<QuantityScalar<U>>,
molar_internal_energy: Option<QuantityScalar<U>>,
density_initialization: DensityInitialization<U>,
initial_temperature: Option<QuantityScalar<U>>,
}
Expand All @@ -83,9 +83,9 @@ impl<'a, U: EosUnit, E: EquationOfState> StateBuilder<'a, U, E> {
moles: None,
molefracs: None,
pressure: None,
enthalpy: None,
entropy: None,
internal_energy: None,
molar_enthalpy: None,
molar_entropy: None,
molar_internal_energy: None,
density_initialization: DensityInitialization::None,
initial_temperature: None,
}
Expand Down Expand Up @@ -139,21 +139,21 @@ impl<'a, U: EosUnit, E: EquationOfState> StateBuilder<'a, U, E> {
self
}

/// Provide the enthalpy for the new state.
pub fn enthalpy(mut self, enthalpy: QuantityScalar<U>) -> Self {
self.enthalpy = Some(enthalpy);
/// Provide the molar enthalpy for the new state.
pub fn molar_enthalpy(mut self, molar_enthalpy: QuantityScalar<U>) -> Self {
self.molar_enthalpy = Some(molar_enthalpy);
self
}

/// Provide the entropy for the new state.
pub fn entropy(mut self, entropy: QuantityScalar<U>) -> Self {
self.entropy = Some(entropy);
/// Provide the molar entropy for the new state.
pub fn molar_entropy(mut self, molar_entropy: QuantityScalar<U>) -> Self {
self.molar_entropy = Some(molar_entropy);
self
}

/// Provide the internal energy for the new state.
pub fn internal_energy(mut self, internal_energy: QuantityScalar<U>) -> Self {
self.internal_energy = Some(internal_energy);
/// Provide the molar internal energy for the new state.
pub fn molar_internal_energy(mut self, molar_internal_energy: QuantityScalar<U>) -> Self {
self.molar_internal_energy = Some(molar_internal_energy);
self
}

Expand Down Expand Up @@ -193,9 +193,9 @@ impl<'a, U: EosUnit, E: EquationOfState> StateBuilder<'a, U, E> {
self.moles,
self.molefracs,
self.pressure,
self.enthalpy,
self.entropy,
self.internal_energy,
self.molar_enthalpy,
self.molar_entropy,
self.molar_internal_energy,
self.density_initialization,
self.initial_temperature,
)
Expand All @@ -214,9 +214,9 @@ impl<'a, U: EosUnit, E: EquationOfState> Clone for StateBuilder<'a, U, E> {
moles: self.moles,
molefracs: self.molefracs,
pressure: self.pressure,
enthalpy: self.enthalpy,
entropy: self.entropy,
internal_energy: self.internal_energy,
molar_enthalpy: self.molar_enthalpy,
molar_entropy: self.molar_entropy,
molar_internal_energy: self.molar_internal_energy,
density_initialization: self.density_initialization,
initial_temperature: self.initial_temperature,
}
Expand Down

0 comments on commit 1d10196

Please sign in to comment.