From 34b1b6f1e1630fcb5fa07bfc11241995bdb1882f Mon Sep 17 00:00:00 2001 From: Philipp Rehner Date: Tue, 8 Mar 2022 08:51:18 +0100 Subject: [PATCH] Standardize naming of molar properties and fix typos in docs --- src/parameter/mod.rs | 2 +- src/python/phase_equilibria.rs | 4 ++-- src/python/state.rs | 28 ++++++++++++----------- src/state/builder.rs | 42 +++++++++++++++++----------------- 4 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/parameter/mod.rs b/src/parameter/mod.rs index 8c29876..6e9b0fd 100644 --- a/src/parameter/mod.rs +++ b/src/parameter/mod.rs @@ -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, diff --git a/src/python/phase_equilibria.rs b/src/python/phase_equilibria.rs index 0a9e549..bfd3972 100644 --- a/src/python/phase_equilibria.rs +++ b/src/python/phase_equilibria.rs @@ -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, @@ -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>, diff --git a/src/python/state.rs b/src/python/state.rs index 0106b17..6473a7b 100644 --- a/src/python/state.rs +++ b/src/python/state.rs @@ -22,11 +22,13 @@ 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. @@ -34,7 +36,7 @@ macro_rules! impl_state { /// 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 /// ------- @@ -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); #[pymethods] @@ -62,9 +64,9 @@ macro_rules! impl_state { moles: Option, molefracs: Option<&PyArray1>, pressure: Option, - enthalpy: Option, - entropy: Option, - internal_energy: Option, + molar_enthalpy: Option, + molar_entropy: Option, + molar_internal_energy: Option, density_initialization: Option<&PyAny>, initial_temperature: Option, ) -> PyResult { @@ -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()), )?; diff --git a/src/state/builder.rs b/src/state/builder.rs index 5e6da59..6b43bcc 100644 --- a/src/state/builder.rs +++ b/src/state/builder.rs @@ -63,9 +63,9 @@ pub struct StateBuilder<'a, U: EosUnit, E: EquationOfState> { moles: Option<&'a QuantityArray1>, molefracs: Option<&'a Array1>, pressure: Option>, - enthalpy: Option>, - entropy: Option>, - internal_energy: Option>, + molar_enthalpy: Option>, + molar_entropy: Option>, + molar_internal_energy: Option>, density_initialization: DensityInitialization, initial_temperature: Option>, } @@ -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, } @@ -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) -> Self { - self.enthalpy = Some(enthalpy); + /// Provide the molar enthalpy for the new state. + pub fn molar_enthalpy(mut self, molar_enthalpy: QuantityScalar) -> Self { + self.molar_enthalpy = Some(molar_enthalpy); self } - /// Provide the entropy for the new state. - pub fn entropy(mut self, entropy: QuantityScalar) -> Self { - self.entropy = Some(entropy); + /// Provide the molar entropy for the new state. + pub fn molar_entropy(mut self, molar_entropy: QuantityScalar) -> 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) -> 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) -> Self { + self.molar_internal_energy = Some(molar_internal_energy); self } @@ -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, ) @@ -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, }