From b9ec65527d154e5e0c35bfa3dab5587e9f42063d Mon Sep 17 00:00:00 2001 From: Philipp Rehner Date: Mon, 4 Sep 2023 15:36:02 +0200 Subject: [PATCH] Make f64 the default inner type for all quantities --- benches/state_creation.rs | 17 +- benches/state_properties.rs | 12 +- feos-core/src/density_iteration.rs | 12 +- feos-core/src/equation_of_state/mod.rs | 18 +-- feos-core/src/equation_of_state/residual.rs | 38 +++-- feos-core/src/joback.rs | 4 +- feos-core/src/phase_equilibria/bubble_dew.rs | 70 ++++---- feos-core/src/phase_equilibria/mod.rs | 12 +- .../phase_equilibria/phase_diagram_binary.rs | 8 +- .../phase_equilibria/phase_diagram_pure.rs | 8 +- .../src/phase_equilibria/phase_envelope.rs | 12 +- feos-core/src/phase_equilibria/tp_flash.rs | 4 +- feos-core/src/phase_equilibria/vle_pure.rs | 22 +-- feos-core/src/si/fmt.rs | 12 +- feos-core/src/si/mod.rs | 150 +++++++++--------- feos-core/src/state/builder.rs | 38 ++--- feos-core/src/state/critical_point.rs | 18 +-- feos-core/src/state/mod.rs | 116 +++++++------- feos-core/src/state/properties.rs | 67 ++++---- feos-core/src/state/residual_properties.rs | 91 +++++------ feos-derive/src/residual.rs | 18 +-- feos-dft/src/adsorption/external_potential.rs | 2 +- feos-dft/src/adsorption/fea_potential.rs | 2 +- feos-dft/src/adsorption/mod.rs | 14 +- feos-dft/src/adsorption/pore.rs | 16 +- feos-dft/src/adsorption/pore3d.rs | 12 +- feos-dft/src/geometry.rs | 10 +- feos-dft/src/ideal_chain_contribution.rs | 2 +- feos-dft/src/interface/mod.rs | 14 +- .../src/interface/surface_tension_diagram.rs | 4 +- feos-dft/src/pdgt.rs | 6 +- feos-dft/src/profile/mod.rs | 6 +- feos-dft/src/profile/properties.rs | 18 +-- feos-dft/src/solvation/pair_correlation.rs | 9 +- feos-dft/src/solvation/solvation_profile.rs | 10 +- feos-dft/src/solver.rs | 14 +- src/association/mod.rs | 4 +- src/estimator/binary_vle.rs | 2 +- src/estimator/diffusion.rs | 2 +- src/estimator/estimator.rs | 3 +- src/estimator/liquid_density.rs | 4 +- src/estimator/thermal_conductivity.rs | 2 +- src/estimator/vapor_pressure.rs | 6 +- src/estimator/viscosity.rs | 2 +- src/pcsaft/eos/mod.rs | 24 +-- src/pcsaft/python.rs | 2 +- src/saftvrqmie/eos/mod.rs | 24 +-- src/saftvrqmie/parameters.rs | 6 +- tests/pcsaft/state_creation_pure.rs | 8 +- 49 files changed, 461 insertions(+), 514 deletions(-) diff --git a/benches/state_creation.rs b/benches/state_creation.rs index a7dc87bad..7396bb566 100644 --- a/benches/state_creation.rs +++ b/benches/state_creation.rs @@ -13,8 +13,8 @@ use std::sync::Arc; fn npt( (eos, t, p, n, rho0): ( &Arc, - Temperature, - Pressure, + Temperature, + Pressure, &Moles>, DensityInitialization, ), @@ -44,18 +44,11 @@ where } /// Evaluate temperature, pressure flash. -fn tp_flash( - (eos, t, p, feed): ( - &Arc, - Temperature, - Pressure, - &Moles>, - ), -) { +fn tp_flash((eos, t, p, feed): (&Arc, Temperature, Pressure, &Moles>)) { PhaseEquilibrium::tp_flash(eos, t, p, feed, None, Default::default(), None).unwrap(); } -fn bubble_point((eos, t, x): (&Arc, Temperature, &Array1)) { +fn bubble_point((eos, t, x): (&Arc, Temperature, &Array1)) { PhaseEquilibrium::bubble_point( eos, t, @@ -67,7 +60,7 @@ fn bubble_point((eos, t, x): (&Arc, Temperature, &Array1((eos, t, y): (&Arc, Temperature, &Array1)) { +fn dew_point((eos, t, y): (&Arc, Temperature, &Array1)) { PhaseEquilibrium::dew_point( eos, t, diff --git a/benches/state_properties.rs b/benches/state_properties.rs index b9f1f6697..0e352e7cf 100644 --- a/benches/state_properties.rs +++ b/benches/state_properties.rs @@ -18,8 +18,8 @@ fn property, Contributions) -> T>( (eos, property, t, v, n, contributions): ( &Arc, F, - Temperature, - Volume, + Temperature, + Volume, &Moles>, Contributions, ), @@ -31,13 +31,7 @@ fn property, Contributions) -> T>( /// Evaluate a property with of a state given the EoS, the property to compute, /// temperature, volume, moles. fn property_no_contributions) -> T>( - (eos, property, t, v, n): ( - &Arc, - F, - Temperature, - Volume, - &Moles>, - ), + (eos, property, t, v, n): (&Arc, F, Temperature, Volume, &Moles>), ) -> T { let state = State::new_nvt(eos, t, v, n).unwrap(); property(&state) diff --git a/feos-core/src/density_iteration.rs b/feos-core/src/density_iteration.rs index ae9249410..f8c81cafd 100644 --- a/feos-core/src/density_iteration.rs +++ b/feos-core/src/density_iteration.rs @@ -7,10 +7,10 @@ use std::sync::Arc; pub fn density_iteration( eos: &Arc, - temperature: Temperature, - pressure: Pressure, + temperature: Temperature, + pressure: Pressure, moles: &Moles>, - initial_density: Density, + initial_density: Density, ) -> EosResult> { let maxdensity = eos.max_density(Some(moles))?; let (abstol, reltol) = (1e-12, 1e-14); @@ -137,10 +137,10 @@ pub fn density_iteration( fn pressure_spinodal( eos: &Arc, - temperature: Temperature, - rho_init: Density, + temperature: Temperature, + rho_init: Density, moles: &Moles>, -) -> EosResult<(Pressure, Density)> { +) -> EosResult<(Pressure, Density)> { let maxiter = 30; let abstol = 1e-8; diff --git a/feos-core/src/equation_of_state/mod.rs b/feos-core/src/equation_of_state/mod.rs index 4a4e90d3e..619bc81a6 100644 --- a/feos-core/src/equation_of_state/mod.rs +++ b/feos-core/src/equation_of_state/mod.rs @@ -83,10 +83,10 @@ impl Residual for EquationOfState { impl EntropyScaling for EquationOfState { fn viscosity_reference( &self, - temperature: Temperature, - volume: Volume, + temperature: Temperature, + volume: Volume, moles: &Moles>, - ) -> EosResult> { + ) -> EosResult { self.residual .viscosity_reference(temperature, volume, moles) } @@ -95,10 +95,10 @@ impl EntropyScaling for EquationOfSta } fn diffusion_reference( &self, - temperature: Temperature, - volume: Volume, + temperature: Temperature, + volume: Volume, moles: &Moles>, - ) -> EosResult> { + ) -> EosResult { self.residual .diffusion_reference(temperature, volume, moles) } @@ -107,10 +107,10 @@ impl EntropyScaling for EquationOfSta } fn thermal_conductivity_reference( &self, - temperature: Temperature, - volume: Volume, + temperature: Temperature, + volume: Volume, moles: &Moles>, - ) -> EosResult> { + ) -> EosResult { self.residual .thermal_conductivity_reference(temperature, volume, moles) } diff --git a/feos-core/src/equation_of_state/residual.rs b/feos-core/src/equation_of_state/residual.rs index 6d2e2a546..344f005eb 100644 --- a/feos-core/src/equation_of_state/residual.rs +++ b/feos-core/src/equation_of_state/residual.rs @@ -77,7 +77,7 @@ pub trait Residual: Components + Send + Sync { /// equilibria and other iterations. It is not explicitly meant to /// be a mathematical limit for the density (if those exist in the /// equation of state anyways). - fn max_density(&self, moles: Option<&Moles>>) -> EosResult> { + fn max_density(&self, moles: Option<&Moles>>) -> EosResult { let mr = self.validate_moles(moles)?.to_reduced(); Ok(Density::from_reduced(self.compute_max_density(&mr))) } @@ -85,9 +85,9 @@ pub trait Residual: Components + Send + Sync { /// Calculate the second virial coefficient $B(T)$ fn second_virial_coefficient( &self, - temperature: Temperature, + temperature: Temperature, moles: Option<&Moles>>, - ) -> EosResult<>>::Output> { + ) -> EosResult<>::Output> { let mr = self.validate_moles(moles)?; let x = (&mr / mr.sum()).into_value(); let mut rho = HyperDual64::zero(); @@ -104,9 +104,9 @@ pub trait Residual: Components + Send + Sync { #[allow(clippy::type_complexity)] fn third_virial_coefficient( &self, - temperature: Temperature, + temperature: Temperature, moles: Option<&Moles>>, - ) -> EosResult<<>>::Output as Div>>::Output> { + ) -> EosResult<<>::Output as Div>::Output> { let mr = self.validate_moles(moles)?; let x = (&mr / mr.sum()).into_value(); let rho = Dual3_64::zero().derivative(); @@ -119,9 +119,9 @@ pub trait Residual: Components + Send + Sync { #[allow(clippy::type_complexity)] fn second_virial_coefficient_temperature_derivative( &self, - temperature: Temperature, + temperature: Temperature, moles: Option<&Moles>>, - ) -> EosResult<<>>::Output as Div>>::Output> { + ) -> EosResult<<>::Output as Div>::Output> { let mr = self.validate_moles(moles)?; let x = (&mr / mr.sum()).into_value(); let mut rho = HyperDual::zero(); @@ -138,12 +138,10 @@ pub trait Residual: Components + Send + Sync { #[allow(clippy::type_complexity)] fn third_virial_coefficient_temperature_derivative( &self, - temperature: Temperature, + temperature: Temperature, moles: Option<&Moles>>, ) -> EosResult< - <<>>::Output as Div>>::Output as Div< - Temperature, - >>::Output, + <<>::Output as Div>::Output as Div>::Output, > { let mr = self.validate_moles(moles)?; let x = (&mr / mr.sum()).into_value(); @@ -160,23 +158,23 @@ pub trait Residual: Components + Send + Sync { pub trait EntropyScaling { fn viscosity_reference( &self, - temperature: Temperature, - volume: Volume, + temperature: Temperature, + volume: Volume, moles: &Moles>, - ) -> EosResult>; + ) -> EosResult; fn viscosity_correlation(&self, s_res: f64, x: &Array1) -> EosResult; fn diffusion_reference( &self, - temperature: Temperature, - volume: Volume, + temperature: Temperature, + volume: Volume, moles: &Moles>, - ) -> EosResult>; + ) -> EosResult; fn diffusion_correlation(&self, s_res: f64, x: &Array1) -> EosResult; fn thermal_conductivity_reference( &self, - temperature: Temperature, - volume: Volume, + temperature: Temperature, + volume: Volume, moles: &Moles>, - ) -> EosResult>; + ) -> EosResult; fn thermal_conductivity_correlation(&self, s_res: f64, x: &Array1) -> EosResult; } diff --git a/feos-core/src/joback.rs b/feos-core/src/joback.rs index 70e42127a..ef83d5ec4 100644 --- a/feos-core/src/joback.rs +++ b/feos-core/src/joback.rs @@ -165,9 +165,9 @@ impl Joback { /// Directly calculates the molar ideal gas heat capacity from the Joback model. pub fn molar_isobaric_heat_capacity( &self, - temperature: Temperature, + temperature: Temperature, molefracs: &Array1, - ) -> EosResult> { + ) -> EosResult { let t = temperature.to_reduced(); let p = &self.parameters; let c_p = (molefracs diff --git a/feos-core/src/phase_equilibria/bubble_dew.rs b/feos-core/src/phase_equilibria/bubble_dew.rs index 53f44f803..54b2bcb3e 100644 --- a/feos-core/src/phase_equilibria/bubble_dew.rs +++ b/feos-core/src/phase_equilibria/bubble_dew.rs @@ -28,7 +28,7 @@ pub trait TemperatureOrPressure: Copy { const IDENTIFIER: &'static str; - fn temperature_pressure(&self, tp_init: Self::Other) -> (Temperature, Pressure); + fn temperature_pressure(&self, tp_init: Self::Other) -> (Temperature, Pressure); fn from_state(state: &State) -> Self::Other; @@ -66,11 +66,11 @@ pub trait TemperatureOrPressure: Copy { ) -> EosResult; } -impl TemperatureOrPressure for Temperature { - type Other = Pressure; +impl TemperatureOrPressure for Temperature { + type Other = Pressure; const IDENTIFIER: &'static str = "temperature"; - fn temperature_pressure(&self, tp_init: Self::Other) -> (Temperature, Pressure) { + fn temperature_pressure(&self, tp_init: Self::Other) -> (Temperature, Pressure) { (*self, tp_init) } @@ -80,8 +80,8 @@ impl TemperatureOrPressure for Temperature { fn linspace( &self, - start: Pressure, - end: Pressure, + start: Pressure, + end: Pressure, n: usize, ) -> (Temperature>, Pressure>) { ( @@ -93,7 +93,7 @@ impl TemperatureOrPressure for Temperature { fn bubble_dew_point( eos: &Arc, temperature: Self, - p_init: Option>, + p_init: Option, molefracs_spec: &Array1, molefracs_init: Option<&Array1>, bubble: bool, @@ -142,8 +142,8 @@ impl TemperatureOrPressure for Temperature { } fn adjust_t_p( - temperature: Temperature, - pressure: &mut Pressure, + temperature: Temperature, + pressure: &mut Pressure, state1: &mut State, state2: &mut State, verbosity: Verbosity, @@ -186,8 +186,8 @@ impl TemperatureOrPressure for Temperature { } fn newton_step( - _: Temperature, - pressure: &mut Pressure, + _: Temperature, + pressure: &mut Pressure, state1: &mut State, state2: &mut State, verbosity: Verbosity, @@ -259,10 +259,10 @@ impl TemperatureOrPressure for Temperature { // used instead of the explicit unit. Maybe the type is too complicated for the // compiler? impl TemperatureOrPressure for Quantity> { - type Other = Temperature; + type Other = Temperature; const IDENTIFIER: &'static str = "pressure"; - fn temperature_pressure(&self, tp_init: Self::Other) -> (Temperature, Pressure) { + fn temperature_pressure(&self, tp_init: Self::Other) -> (Temperature, Pressure) { (tp_init, *self) } @@ -272,8 +272,8 @@ impl TemperatureOrPressure for Quantity> fn linspace( &self, - start: Temperature, - end: Temperature, + start: Temperature, + end: Temperature, n: usize, ) -> (Temperature>, Pressure>) { ( @@ -285,7 +285,7 @@ impl TemperatureOrPressure for Quantity> fn bubble_dew_point( eos: &Arc, pressure: Self, - t_init: Option>, + t_init: Option, molefracs_spec: &Array1, molefracs_init: Option<&Array1>, bubble: bool, @@ -304,8 +304,8 @@ impl TemperatureOrPressure for Quantity> } fn adjust_t_p( - pressure: Pressure, - temperature: &mut Temperature, + pressure: Pressure, + temperature: &mut Temperature, state1: &mut State, state2: &mut State, verbosity: Verbosity, @@ -351,8 +351,8 @@ impl TemperatureOrPressure for Quantity> } fn newton_step( - pressure: Pressure, - temperature: &mut Temperature, + pressure: Pressure, + temperature: &mut Temperature, state1: &mut State, state2: &mut State, verbosity: Verbosity, @@ -525,10 +525,10 @@ impl PhaseEquilibrium { fn starting_pressure_ideal_gas( eos: &Arc, - temperature: Temperature, + temperature: Temperature, molefracs_spec: &Array1, bubble: bool, - ) -> EosResult<(Pressure, Array1)> { + ) -> EosResult<(Pressure, Array1)> { if bubble { Self::starting_pressure_ideal_gas_bubble(eos, temperature, molefracs_spec) } else { @@ -538,9 +538,9 @@ impl PhaseEquilibrium { pub(super) fn starting_pressure_ideal_gas_bubble( eos: &Arc, - temperature: Temperature, + temperature: Temperature, liquid_molefracs: &Array1, - ) -> EosResult<(Pressure, Array1)> { + ) -> EosResult<(Pressure, Array1)> { let m = Moles::from_reduced(liquid_molefracs.to_owned()); let density = 0.75 * eos.max_density(Some(&m))?; let liquid = State::new_nvt(eos, temperature, m.sum() / density, &m)?; @@ -560,10 +560,10 @@ impl PhaseEquilibrium { fn starting_pressure_ideal_gas_dew( eos: &Arc, - temperature: Temperature, + temperature: Temperature, vapor_molefracs: &Array1, - ) -> EosResult<(Pressure, Array1)> { - let mut p: Option> = None; + ) -> EosResult<(Pressure, Array1)> { + let mut p: Option = None; let mut x = vapor_molefracs.clone(); for _ in 0..5 { @@ -592,9 +592,9 @@ impl PhaseEquilibrium { pub(super) fn starting_pressure_spinodal( eos: &Arc, - temperature: Temperature, + temperature: Temperature, molefracs: &Array1, - ) -> EosResult> { + ) -> EosResult { let moles = Moles::from_reduced(molefracs.clone()); let [sp_v, sp_l] = State::spinodal(eos, temperature, Some(&moles), Default::default())?; let pv = sp_v.pressure(Contributions::Total); @@ -605,8 +605,8 @@ impl PhaseEquilibrium { fn starting_x2_bubble( eos: &Arc, - temperature: Temperature, - pressure: Pressure, + temperature: Temperature, + pressure: Pressure, liquid_molefracs: &Array1, vapor_molefracs: Option<&Array1>, ) -> EosResult<[State; 2]> { @@ -627,8 +627,8 @@ fn starting_x2_bubble( fn starting_x2_dew( eos: &Arc, - temperature: Temperature, - pressure: Pressure, + temperature: Temperature, + pressure: Pressure, vapor_molefracs: &Array1, liquid_molefracs: Option<&Array1>, ) -> EosResult<[State; 2]> { @@ -744,8 +744,8 @@ fn bubble_dew( } fn adjust_states( - temperature: Temperature, - pressure: Pressure, + temperature: Temperature, + pressure: Pressure, state1: &mut State, state2: &mut State, moles_state2: Option<&Moles>>, diff --git a/feos-core/src/phase_equilibria/mod.rs b/feos-core/src/phase_equilibria/mod.rs index 8cbf22fc1..ba72fb6fc 100644 --- a/feos-core/src/phase_equilibria/mod.rs +++ b/feos-core/src/phase_equilibria/mod.rs @@ -124,8 +124,8 @@ impl PhaseEquilibrium { /// In general, the two states generated are NOT in an equilibrium. pub fn new_npt( eos: &Arc, - temperature: Temperature, - pressure: Pressure, + temperature: Temperature, + pressure: Pressure, vapor_moles: &Moles>, liquid_moles: &Moles>, ) -> EosResult { @@ -155,8 +155,8 @@ impl PhaseEquilibrium { impl PhaseEquilibrium { pub(super) fn update_pressure( mut self, - temperature: Temperature, - pressure: Pressure, + temperature: Temperature, + pressure: Pressure, ) -> EosResult { for s in self.0.iter_mut() { *s = State::new_npt( @@ -172,7 +172,7 @@ impl PhaseEquilibrium { pub(super) fn update_moles( &mut self, - pressure: Pressure, + pressure: Pressure, moles: [&Moles>; N], ) -> EosResult<()> { for (i, s) in self.0.iter_mut().enumerate() { @@ -188,7 +188,7 @@ impl PhaseEquilibrium { } // Total Gibbs energy excluding the constant contribution RT sum_i N_i ln(\Lambda_i^3) - pub(super) fn total_gibbs_energy(&self) -> Energy { + pub(super) fn total_gibbs_energy(&self) -> Energy { self.0.iter().fold(Energy::from_reduced(0.0), |acc, s| { let ln_rho = s.partial_density.to_reduced().mapv(f64::ln); acc + s.residual_helmholtz_energy() diff --git a/feos-core/src/phase_equilibria/phase_diagram_binary.rs b/feos-core/src/phase_equilibria/phase_diagram_binary.rs index bcde7cdf3..708a7afaa 100644 --- a/feos-core/src/phase_equilibria/phase_diagram_binary.rs +++ b/feos-core/src/phase_equilibria/phase_diagram_binary.rs @@ -366,9 +366,9 @@ impl PhaseEquilibrium { /// system and given temperature. fn heteroazeotrope_t( eos: &Arc, - temperature: Temperature, + temperature: Temperature, x_init: (f64, f64), - p_init: Option>, + p_init: Option, options: SolverOptions, bubble_dew_options: (SolverOptions, SolverOptions), ) -> EosResult { @@ -507,9 +507,9 @@ impl PhaseEquilibrium { /// system and given pressure. fn heteroazeotrope_p( eos: &Arc, - pressure: Pressure, + pressure: Pressure, x_init: (f64, f64), - t_init: Option>, + t_init: Option, options: SolverOptions, bubble_dew_options: (SolverOptions, SolverOptions), ) -> EosResult { diff --git a/feos-core/src/phase_equilibria/phase_diagram_pure.rs b/feos-core/src/phase_equilibria/phase_diagram_pure.rs index 21a270933..831d4a6f5 100644 --- a/feos-core/src/phase_equilibria/phase_diagram_pure.rs +++ b/feos-core/src/phase_equilibria/phase_diagram_pure.rs @@ -34,9 +34,9 @@ impl PhaseDiagram { /// Calculate a phase diagram for a pure component. pub fn pure( eos: &Arc, - min_temperature: Temperature, + min_temperature: Temperature, npoints: usize, - critical_temperature: Option>, + critical_temperature: Option, options: SolverOptions, ) -> EosResult { let mut states = Vec::with_capacity(npoints); @@ -92,11 +92,11 @@ impl PhaseDiagram { pub fn par_pure( eos: &Arc, - min_temperature: Temperature, + min_temperature: Temperature, npoints: usize, chunksize: usize, thread_pool: ThreadPool, - critical_temperature: Option>, + critical_temperature: Option, options: SolverOptions, ) -> EosResult { let sc = State::critical_point(eos, None, critical_temperature, SolverOptions::default())?; diff --git a/feos-core/src/phase_equilibria/phase_envelope.rs b/feos-core/src/phase_equilibria/phase_envelope.rs index 8b6e2e46c..e69fe1a47 100644 --- a/feos-core/src/phase_equilibria/phase_envelope.rs +++ b/feos-core/src/phase_equilibria/phase_envelope.rs @@ -12,9 +12,9 @@ impl PhaseDiagram { pub fn bubble_point_line( eos: &Arc, moles: &Moles>, - min_temperature: Temperature, + min_temperature: Temperature, npoints: usize, - critical_temperature: Option>, + critical_temperature: Option, options: (SolverOptions, SolverOptions), ) -> EosResult { let mut states = Vec::with_capacity(npoints); @@ -61,9 +61,9 @@ impl PhaseDiagram { pub fn dew_point_line( eos: &Arc, moles: &Moles>, - min_temperature: Temperature, + min_temperature: Temperature, npoints: usize, - critical_temperature: Option>, + critical_temperature: Option, options: (SolverOptions, SolverOptions), ) -> EosResult { let mut states = Vec::with_capacity(npoints); @@ -126,9 +126,9 @@ impl PhaseDiagram { pub fn spinodal( eos: &Arc, moles: &Moles>, - min_temperature: Temperature, + min_temperature: Temperature, npoints: usize, - critical_temperature: Option>, + critical_temperature: Option, options: SolverOptions, ) -> EosResult { let mut states = Vec::with_capacity(npoints); diff --git a/feos-core/src/phase_equilibria/tp_flash.rs b/feos-core/src/phase_equilibria/tp_flash.rs index cd76e9494..ea7f0797b 100644 --- a/feos-core/src/phase_equilibria/tp_flash.rs +++ b/feos-core/src/phase_equilibria/tp_flash.rs @@ -20,8 +20,8 @@ impl PhaseEquilibrium { /// containing non-volatile components (e.g. ions). pub fn tp_flash( eos: &Arc, - temperature: Temperature, - pressure: Pressure, + temperature: Temperature, + pressure: Pressure, feed: &Moles>, initial_state: Option<&PhaseEquilibrium>, options: SolverOptions, diff --git a/feos-core/src/phase_equilibria/vle_pure.rs b/feos-core/src/phase_equilibria/vle_pure.rs index 1aac3266a..492b3566e 100644 --- a/feos-core/src/phase_equilibria/vle_pure.rs +++ b/feos-core/src/phase_equilibria/vle_pure.rs @@ -33,7 +33,7 @@ impl PhaseEquilibrium { /// and given temperature. fn pure_t( eos: &Arc, - temperature: Temperature, + temperature: Temperature, initial_state: Option<&PhaseEquilibrium>, options: SolverOptions, ) -> EosResult { @@ -162,7 +162,7 @@ impl PhaseEquilibrium { /// and given pressure. fn pure_p( eos: &Arc, - pressure: Pressure, + pressure: Pressure, initial_state: Option<&Self>, options: SolverOptions, ) -> EosResult { @@ -258,26 +258,26 @@ impl PhaseEquilibrium { Err(EosError::NotConverged("pure_p".to_owned())) } - fn init_pure_state(initial_state: &Self, temperature: Temperature) -> EosResult { + fn init_pure_state(initial_state: &Self, temperature: Temperature) -> EosResult { let vapor = initial_state.vapor().update_temperature(temperature)?; let liquid = initial_state.liquid().update_temperature(temperature)?; Ok(Self([vapor, liquid])) } - fn init_pure_ideal_gas(eos: &Arc, temperature: Temperature) -> EosResult { + fn init_pure_ideal_gas(eos: &Arc, temperature: Temperature) -> EosResult { let m = Moles::from_reduced(arr1(&[1.0])); let p = Self::starting_pressure_ideal_gas_bubble(eos, temperature, &arr1(&[1.0]))?.0; PhaseEquilibrium::new_npt(eos, temperature, p, &m, &m)?.check_trivial_solution() } - fn init_pure_spinodal(eos: &Arc, temperature: Temperature) -> EosResult { + fn init_pure_spinodal(eos: &Arc, temperature: Temperature) -> EosResult { let p = Self::starting_pressure_spinodal(eos, temperature, &arr1(&[1.0]))?; let m = Moles::from_reduced(arr1(&[1.0])); PhaseEquilibrium::new_npt(eos, temperature, p, &m, &m) } /// Initialize a new VLE for a pure substance for a given pressure. - fn init_pure_p(eos: &Arc, pressure: Pressure) -> EosResult { + fn init_pure_p(eos: &Arc, pressure: Pressure) -> EosResult { let trial_temperatures = [ Temperature::from_reduced(300.0), Temperature::from_reduced(500.0), @@ -352,10 +352,7 @@ impl PhaseEquilibrium { impl PhaseEquilibrium { /// Calculate the pure component vapor pressures of all /// components in the system for the given temperature. - pub fn vapor_pressure( - eos: &Arc, - temperature: Temperature, - ) -> Vec>> { + pub fn vapor_pressure(eos: &Arc, temperature: Temperature) -> Vec> { (0..eos.components()) .map(|i| { let pure_eos = Arc::new(eos.subset(&[i])); @@ -368,10 +365,7 @@ impl PhaseEquilibrium { /// Calculate the pure component boiling temperatures of all /// components in the system for the given pressure. - pub fn boiling_temperature( - eos: &Arc, - pressure: Pressure, - ) -> Vec>> { + pub fn boiling_temperature(eos: &Arc, pressure: Pressure) -> Vec> { (0..eos.components()) .map(|i| { let pure_eos = Arc::new(eos.subset(&[i])); diff --git a/feos-core/src/si/fmt.rs b/feos-core/src/si/fmt.rs index e05e719bc..752ae172d 100644 --- a/feos-core/src/si/fmt.rs +++ b/feos-core/src/si/fmt.rs @@ -101,12 +101,12 @@ impl_fmt!(N2, P2, P1, N1, Z0, Z0, WEBER, "Wb", Some(PETA)); impl_fmt!(N2, Z0, P1, N1, Z0, Z0, TESLA, "T", Some(PETA)); impl_fmt!(N2, P2, P1, N2, Z0, Z0, HENRY, "H", Some(PETA)); -const M2: Area = Quantity(1.0, PhantomData); -const M3: Volume = Quantity(1.0, PhantomData); -const KG: Mass = KILOGRAM; -const JMK: MolarEntropy = Quantity(1.0, PhantomData); -const JKGK: SpecificEntropy = Quantity(1.0, PhantomData); -const WMK: ThermalConductivity = Quantity(1.0, PhantomData); +const M2: Area = Quantity(1.0, PhantomData); +const M3: Volume = Quantity(1.0, PhantomData); +const KG: Mass = KILOGRAM; +const JMK: MolarEntropy = Quantity(1.0, PhantomData); +const JKGK: SpecificEntropy = Quantity(1.0, PhantomData); +const WMK: ThermalConductivity = Quantity(1.0, PhantomData); impl_fmt!(Z0, N3, Z0, Z0, Z0, P1, MOL / M3, "mol/m³", Some(MEGA)); impl_fmt!(Z0, N2, Z0, Z0, Z0, P1, MOL / M2, "mol/m²", Some(MEGA)); diff --git a/feos-core/src/si/mod.rs b/feos-core/src/si/mod.rs index 2df784f69..87335cbf6 100644 --- a/feos-core/src/si/mod.rs +++ b/feos-core/src/si/mod.rs @@ -26,120 +26,120 @@ pub type _Temperature = SIUnit; pub type _Moles = SIUnit; pub type _LuminousIntensity = SIUnit; -pub type Dimensionless = Quantity; -pub type Time = Quantity; -pub type Length = Quantity; -pub type Mass = Quantity; -pub type Current = Quantity; -pub type Temperature = Quantity; -pub type Moles = Quantity; -pub type LuminousIntensity = Quantity; +pub type Dimensionless = Quantity; +pub type Time = Quantity; +pub type Length = Quantity; +pub type Mass = Quantity; +pub type Current = Quantity; +pub type Temperature = Quantity; +pub type Moles = Quantity; +pub type LuminousIntensity = Quantity; pub type _Frequency = Negate<_Time>; -pub type Frequency = Quantity; +pub type Frequency = Quantity; pub type _Velocity = Diff<_Length, _Time>; -pub type Velocity = Quantity; +pub type Velocity = Quantity; pub type _Acceleration = Diff<_Velocity, _Time>; -pub type Acceleration = Quantity; +pub type Acceleration = Quantity; pub type _Force = Sum<_Mass, _Acceleration>; -pub type Force = Quantity; +pub type Force = Quantity; pub type _Area = Sum<_Length, _Length>; -pub type Area = Quantity; +pub type Area = Quantity; pub type _Volume = Sum<_Area, _Length>; -pub type Volume = Quantity; +pub type Volume = Quantity; pub type _Energy = Sum<_Force, _Length>; -pub type Energy = Quantity; +pub type Energy = Quantity; pub type _Pressure = Diff<_Energy, _Volume>; -pub type Pressure = Quantity; +pub type Pressure = Quantity; pub type _Power = Diff<_Energy, _Time>; -pub type Power = Quantity; +pub type Power = Quantity; pub type _Charge = Sum<_Current, _Time>; -pub type Charge = Quantity; +pub type Charge = Quantity; pub type _ElectricPotential = Diff<_Power, _Current>; -pub type ElectricPotential = Quantity; +pub type ElectricPotential = Quantity; pub type _Capacitance = Diff<_Charge, _ElectricPotential>; -pub type Capacitance = Quantity; +pub type Capacitance = Quantity; pub type _Resistance = Diff<_ElectricPotential, _Current>; -pub type Resistance = Quantity; +pub type Resistance = Quantity; pub type _ElectricalConductance = Negate<_Resistance>; -pub type ElectricalConductance = Quantity; +pub type ElectricalConductance = Quantity; pub type _MagneticFlux = Sum<_ElectricPotential, _Time>; -pub type MagneticFlux = Quantity; +pub type MagneticFlux = Quantity; pub type _MagneticFluxDensity = Diff<_MagneticFlux, _Area>; -pub type MagneticFluxDensity = Quantity; +pub type MagneticFluxDensity = Quantity; pub type _Inductance = Diff<_MagneticFlux, _Current>; -pub type Inductance = Quantity; +pub type Inductance = Quantity; pub type _Entropy = Diff<_Energy, _Temperature>; -pub type Entropy = Quantity; +pub type Entropy = Quantity; pub type _EntropyPerTemperature = Diff<_Entropy, _Temperature>; -pub type EntropyPerTemperature = Quantity; +pub type EntropyPerTemperature = Quantity; pub type _MolarEntropy = Diff<_Entropy, _Moles>; -pub type MolarEntropy = Quantity; +pub type MolarEntropy = Quantity; pub type _MolarEnergy = Diff<_Energy, _Moles>; -pub type MolarEnergy = Quantity; +pub type MolarEnergy = Quantity; pub type _SpecificEntropy = Diff<_Entropy, _Mass>; -pub type SpecificEntropy = Quantity; +pub type SpecificEntropy = Quantity; pub type _SpecificEnergy = Diff<_Energy, _Mass>; -pub type SpecificEnergy = Quantity; +pub type SpecificEnergy = Quantity; pub type _MolarWeight = Diff<_Mass, _Moles>; -pub type MolarWeight = Quantity; +pub type MolarWeight = Quantity; pub type _Density = Diff<_Moles, _Volume>; -pub type Density = Quantity; +pub type Density = Quantity; pub type _MassDensity = Diff<_Mass, _Volume>; -pub type MassDensity = Quantity; +pub type MassDensity = Quantity; pub type _PressurePerVolume = Diff<_Pressure, _Volume>; -pub type PressurePerVolume = Quantity; +pub type PressurePerVolume = Quantity; pub type _PressurePerTemperature = Diff<_Pressure, _Temperature>; -pub type PressurePerTemperature = Quantity; +pub type PressurePerTemperature = Quantity; pub type _Compressibility = Negate<_Pressure>; -pub type Compressibility = Quantity; +pub type Compressibility = Quantity; pub type _MolarVolume = Diff<_Volume, _Moles>; -pub type MolarVolume = Quantity; +pub type MolarVolume = Quantity; pub type _EntropyDensity = Diff<_Entropy, _Volume>; -pub type EntropyDensity = Quantity; +pub type EntropyDensity = Quantity; pub type _Viscosity = Sum<_Pressure, _Time>; -pub type Viscosity = Quantity; +pub type Viscosity = Quantity; pub type _Diffusivity = Sum<_Velocity, _Length>; -pub type Diffusivity = Quantity; +pub type Diffusivity = Quantity; pub type _ThermalConductivity = Diff<_Power, Sum<_Length, _Temperature>>; -pub type ThermalConductivity = Quantity; +pub type ThermalConductivity = Quantity; pub type _SurfaceTension = Diff<_Force, _Length>; -pub type SurfaceTension = Quantity; +pub type SurfaceTension = Quantity; -pub const SECOND: Time = Quantity(1.0, PhantomData); -pub const METER: Length = Quantity(1.0, PhantomData); -pub const KILOGRAM: Mass = Quantity(1.0, PhantomData); -pub const AMPERE: Current = Quantity(1.0, PhantomData); -pub const KELVIN: Temperature = Quantity(1.0, PhantomData); -pub const MOL: Moles = Quantity(1.0, PhantomData); -pub const CANDELA: LuminousIntensity = Quantity(1.0, PhantomData); +pub const SECOND: Time = Quantity(1.0, PhantomData); +pub const METER: Length = Quantity(1.0, PhantomData); +pub const KILOGRAM: Mass = Quantity(1.0, PhantomData); +pub const AMPERE: Current = Quantity(1.0, PhantomData); +pub const KELVIN: Temperature = Quantity(1.0, PhantomData); +pub const MOL: Moles = Quantity(1.0, PhantomData); +pub const CANDELA: LuminousIntensity = Quantity(1.0, PhantomData); -pub const HERTZ: Frequency = Quantity(1.0, PhantomData); -pub const NEWTON: Force = Quantity(1.0, PhantomData); -pub const PASCAL: Pressure = Quantity(1.0, PhantomData); -pub const JOULE: Energy = Quantity(1.0, PhantomData); -pub const WATT: Power = Quantity(1.0, PhantomData); -pub const COULOMB: Charge = Quantity(1.0, PhantomData); -pub const VOLT: ElectricPotential = Quantity(1.0, PhantomData); -pub const FARAD: Capacitance = Quantity(1.0, PhantomData); -pub const OHM: Resistance = Quantity(1.0, PhantomData); -pub const SIEMENS: ElectricalConductance = Quantity(1.0, PhantomData); -pub const WEBER: MagneticFlux = Quantity(1.0, PhantomData); -pub const TESLA: MagneticFluxDensity = Quantity(1.0, PhantomData); -pub const HENRY: Inductance = Quantity(1.0, PhantomData); +pub const HERTZ: Frequency = Quantity(1.0, PhantomData); +pub const NEWTON: Force = Quantity(1.0, PhantomData); +pub const PASCAL: Pressure = Quantity(1.0, PhantomData); +pub const JOULE: Energy = Quantity(1.0, PhantomData); +pub const WATT: Power = Quantity(1.0, PhantomData); +pub const COULOMB: Charge = Quantity(1.0, PhantomData); +pub const VOLT: ElectricPotential = Quantity(1.0, PhantomData); +pub const FARAD: Capacitance = Quantity(1.0, PhantomData); +pub const OHM: Resistance = Quantity(1.0, PhantomData); +pub const SIEMENS: ElectricalConductance = Quantity(1.0, PhantomData); +pub const WEBER: MagneticFlux = Quantity(1.0, PhantomData); +pub const TESLA: MagneticFluxDensity = Quantity(1.0, PhantomData); +pub const HENRY: Inductance = Quantity(1.0, PhantomData); -pub const ANGSTROM: Length = Quantity(1e-10, PhantomData); -pub const AMU: Mass = Quantity(1.6605390671738466e-27, PhantomData); -pub const AU: Length = Quantity(149597870700.0, PhantomData); -pub const BAR: Pressure = Quantity(1e5, PhantomData); -pub const CALORIE: Energy = Quantity(4.184, PhantomData); -pub const DAY: Time = Quantity(86400.0, PhantomData); -pub const GRAM: Mass = Quantity(1e-3, PhantomData); -pub const HOUR: Time = Quantity(3600.0, PhantomData); -pub const LITER: Volume = Quantity(1e-3, PhantomData); -pub const MINUTE: Time = Quantity(60.0, PhantomData); +pub const ANGSTROM: Length = Quantity(1e-10, PhantomData); +pub const AMU: Mass = Quantity(1.6605390671738466e-27, PhantomData); +pub const AU: Length = Quantity(149597870700.0, PhantomData); +pub const BAR: Pressure = Quantity(1e5, PhantomData); +pub const CALORIE: Energy = Quantity(4.184, PhantomData); +pub const DAY: Time = Quantity(86400.0, PhantomData); +pub const GRAM: Mass = Quantity(1e-3, PhantomData); +pub const HOUR: Time = Quantity(3600.0, PhantomData); +pub const LITER: Volume = Quantity(1e-3, PhantomData); +pub const MINUTE: Time = Quantity(60.0, PhantomData); /// Angle unit radian $\\left(\text{rad}\\right)$ pub const RADIANS: Angle = Radians(1.0); @@ -147,11 +147,11 @@ pub const RADIANS: Angle = Radians(1.0); pub const DEGREES: Angle = Degrees(1.0); /// Boltzmann constant $\\left(k_\text{B}=1.380649\times 10^{-23}\\,\\frac{\text{J}}{\text{K}}\\right)$ -pub const KB: Entropy = Quantity(1.380649e-23, PhantomData); +pub const KB: Entropy = Quantity(1.380649e-23, PhantomData); /// Avogadro constant $\\left(N_\text{A}=6.02214076\times 10^{23}\\,\text{mol}^{-1}\\right)$ pub const NAV: Quantity> = Quantity(6.02214076e23, PhantomData); /// Ideal gas constant $\\left(R=8.31446261815324\\,\\frac{\text{J}}{\text{molK}}\\right)$ -pub const RGAS: MolarEntropy = Quantity(8.31446261815324, PhantomData); +pub const RGAS: MolarEntropy = Quantity(8.31446261815324, PhantomData); /// Prefix quecto $\\left(\text{q}=10^{-30}\\right)$ pub const QUECTO: f64 = 1e-30; diff --git a/feos-core/src/state/builder.rs b/feos-core/src/state/builder.rs index 02a08bcee..235075096 100644 --- a/feos-core/src/state/builder.rs +++ b/feos-core/src/state/builder.rs @@ -55,19 +55,19 @@ use std::sync::Arc; /// ``` pub struct StateBuilder<'a, E, const IG: bool> { eos: Arc, - temperature: Option>, - volume: Option>, - density: Option>, + temperature: Option, + volume: Option, + density: Option, partial_density: Option<&'a Density>>, - total_moles: Option>, + total_moles: Option, moles: Option<&'a Moles>>, molefracs: Option<&'a Array1>, - pressure: Option>, - molar_enthalpy: Option>, - molar_entropy: Option>, - molar_internal_energy: Option>, + pressure: Option, + molar_enthalpy: Option, + molar_entropy: Option, + molar_internal_energy: Option, density_initialization: DensityInitialization, - initial_temperature: Option>, + initial_temperature: Option, } impl<'a, E: Residual> StateBuilder<'a, E, false> { @@ -94,19 +94,19 @@ impl<'a, E: Residual> StateBuilder<'a, E, false> { impl<'a, E: Residual, const IG: bool> StateBuilder<'a, E, IG> { /// Provide the temperature for the new state. - pub fn temperature(mut self, temperature: Temperature) -> Self { + pub fn temperature(mut self, temperature: Temperature) -> Self { self.temperature = Some(temperature); self } /// Provide the volume for the new state. - pub fn volume(mut self, volume: Volume) -> Self { + pub fn volume(mut self, volume: Volume) -> Self { self.volume = Some(volume); self } /// Provide the density for the new state. - pub fn density(mut self, density: Density) -> Self { + pub fn density(mut self, density: Density) -> Self { self.density = Some(density); self } @@ -118,7 +118,7 @@ impl<'a, E: Residual, const IG: bool> StateBuilder<'a, E, IG> { } /// Provide the total moles for the new state. - pub fn total_moles(mut self, total_moles: Moles) -> Self { + pub fn total_moles(mut self, total_moles: Moles) -> Self { self.total_moles = Some(total_moles); self } @@ -136,7 +136,7 @@ impl<'a, E: Residual, const IG: bool> StateBuilder<'a, E, IG> { } /// Provide the pressure for the new state. - pub fn pressure(mut self, pressure: Pressure) -> Self { + pub fn pressure(mut self, pressure: Pressure) -> Self { self.pressure = Some(pressure); self } @@ -154,7 +154,7 @@ impl<'a, E: Residual, const IG: bool> StateBuilder<'a, E, IG> { } /// Provide an initial density used in density iterations. - pub fn initial_density(mut self, initial_density: Density) -> Self { + pub fn initial_density(mut self, initial_density: Density) -> Self { self.density_initialization = DensityInitialization::InitialDensity(initial_density); self } @@ -162,13 +162,13 @@ impl<'a, E: Residual, const IG: bool> StateBuilder<'a, E, IG> { impl<'a, E: Residual + IdealGas, const IG: bool> StateBuilder<'a, E, IG> { /// Provide the molar enthalpy for the new state. - pub fn molar_enthalpy(mut self, molar_enthalpy: MolarEnergy) -> StateBuilder<'a, E, true> { + pub fn molar_enthalpy(mut self, molar_enthalpy: MolarEnergy) -> StateBuilder<'a, E, true> { self.molar_enthalpy = Some(molar_enthalpy); self.convert() } /// Provide the molar entropy for the new state. - pub fn molar_entropy(mut self, molar_entropy: MolarEntropy) -> StateBuilder<'a, E, true> { + pub fn molar_entropy(mut self, molar_entropy: MolarEntropy) -> StateBuilder<'a, E, true> { self.molar_entropy = Some(molar_entropy); self.convert() } @@ -176,7 +176,7 @@ impl<'a, E: Residual + IdealGas, const IG: bool> StateBuilder<'a, E, IG> { /// Provide the molar internal energy for the new state. pub fn molar_internal_energy( mut self, - molar_internal_energy: MolarEnergy, + molar_internal_energy: MolarEnergy, ) -> StateBuilder<'a, E, true> { self.molar_internal_energy = Some(molar_internal_energy); self.convert() @@ -185,7 +185,7 @@ impl<'a, E: Residual + IdealGas, const IG: bool> StateBuilder<'a, E, IG> { /// Provide an initial temperature used in the Newton solver. pub fn initial_temperature( mut self, - initial_temperature: Temperature, + initial_temperature: Temperature, ) -> StateBuilder<'a, E, true> { self.initial_temperature = Some(initial_temperature); self.convert() diff --git a/feos-core/src/state/critical_point.rs b/feos-core/src/state/critical_point.rs index 10d8886dd..72d34df9e 100644 --- a/feos-core/src/state/critical_point.rs +++ b/feos-core/src/state/critical_point.rs @@ -21,7 +21,7 @@ impl State { /// Calculate the pure component critical point of all components. pub fn critical_point_pure( eos: &Arc, - initial_temperature: Option>, + initial_temperature: Option, options: SolverOptions, ) -> EosResult> { (0..eos.components()) @@ -39,7 +39,7 @@ impl State { pub fn critical_point_binary( eos: &Arc, temperature_or_pressure: TP, - initial_temperature: Option>, + initial_temperature: Option, initial_molefracs: Option<[f64; 2]>, options: SolverOptions, ) -> EosResult @@ -64,7 +64,7 @@ impl State { pub fn critical_point( eos: &Arc, moles: Option<&Moles>>, - initial_temperature: Option>, + initial_temperature: Option, options: SolverOptions, ) -> EosResult { let moles = eos.validate_moles(moles)?; @@ -88,7 +88,7 @@ impl State { fn critical_point_hkm( eos: &Arc, moles: &Moles>, - initial_temperature: Temperature, + initial_temperature: Temperature, options: SolverOptions, ) -> EosResult { let (max_iter, tol, verbosity) = options.unwrap_or(MAX_ITER_CRIT_POINT, TOL_CRIT_POINT); @@ -163,7 +163,7 @@ impl State { /// Calculate the critical point of a binary system for given temperature. fn critical_point_binary_t( eos: &Arc, - temperature: Temperature, + temperature: Temperature, initial_molefracs: Option<[f64; 2]>, options: SolverOptions, ) -> EosResult { @@ -241,8 +241,8 @@ impl State { /// Calculate the critical point of a binary system for given pressure. fn critical_point_binary_p( eos: &Arc, - pressure: Pressure, - initial_temperature: Option>, + pressure: Pressure, + initial_temperature: Option, initial_molefracs: Option<[f64; 2]>, options: SolverOptions, ) -> EosResult { @@ -331,7 +331,7 @@ impl State { pub fn spinodal( eos: &Arc, - temperature: Temperature, + temperature: Temperature, moles: Option<&Moles>>, options: SolverOptions, ) -> EosResult<[Self; 2]> { @@ -357,7 +357,7 @@ impl State { fn calculate_spinodal( eos: &Arc, - temperature: Temperature, + temperature: Temperature, moles: &Moles>, density_initialization: DensityInitialization, options: SolverOptions, diff --git a/feos-core/src/state/mod.rs b/feos-core/src/state/mod.rs index 378db9e61..ef8994564 100644 --- a/feos-core/src/state/mod.rs +++ b/feos-core/src/state/mod.rs @@ -48,7 +48,7 @@ pub enum DensityInitialization { /// Calculate a liquid phase by using the `max_density`. Liquid, /// Use the given density as initial value. - InitialDensity(Density), + InitialDensity(Density), /// Calculate the most stable phase by calculating both a vapor and a liquid /// and return the one with the lower molar Gibbs energy. None, @@ -139,17 +139,17 @@ pub struct State { /// Equation of state pub eos: Arc, /// Temperature $T$ - pub temperature: Temperature, + pub temperature: Temperature, /// Volume $V$ - pub volume: Volume, + pub volume: Volume, /// Mole numbers $N_i$ pub moles: Moles>, /// Total number of moles $N=\sum_iN_i$ - pub total_moles: Moles, + pub total_moles: Moles, /// Partial densities $\rho_i=\frac{N_i}{V}$ pub partial_density: Density>, /// Total density $\rho=\frac{N}{V}=\sum_i\rho_i$ - pub density: Density, + pub density: Density, /// Mole fractions $x_i=\frac{N_i}{N}=\frac{\rho_i}{\rho}$ pub molefracs: Array1, /// Reduced temperature @@ -225,8 +225,8 @@ impl State { /// densities are below the maximum packing fraction. pub fn new_nvt( eos: &Arc, - temperature: Temperature, - volume: Volume, + temperature: Temperature, + volume: Volume, moles: &Moles>, ) -> EosResult { eos.validate_moles(Some(moles))?; @@ -237,8 +237,8 @@ impl State { pub(super) fn new_nvt_unchecked( eos: &Arc, - temperature: Temperature, - volume: Volume, + temperature: Temperature, + volume: Volume, moles: &Moles>, ) -> Self { let t = temperature.to_reduced(); @@ -272,11 +272,7 @@ impl State { /// This function will perform a validation of the given properties, i.e. test for signs /// and if values are finite. It will **not** validate physics, i.e. if the resulting /// densities are below the maximum packing fraction. - pub fn new_pure( - eos: &Arc, - temperature: Temperature, - density: Density, - ) -> EosResult { + pub fn new_pure(eos: &Arc, temperature: Temperature, density: Density) -> EosResult { let moles = Moles::from_reduced(arr1(&[1.0])); Self::new_nvt(eos, temperature, Moles::from_reduced(1.0) / density, &moles) } @@ -296,14 +292,14 @@ impl State { /// When the state cannot be created using the combination of inputs. pub fn new( eos: &Arc, - temperature: Option>, - volume: Option>, - density: Option>, + temperature: Option, + volume: Option, + density: Option, partial_density: Option<&Density>>, - total_moles: Option>, + total_moles: Option, moles: Option<&Moles>>, molefracs: Option<&Array1>, - pressure: Option>, + pressure: Option, density_initialization: DensityInitialization, ) -> EosResult { Self::_new( @@ -323,14 +319,14 @@ impl State { fn _new( eos: &Arc, - temperature: Option>, - volume: Option>, - density: Option>, + temperature: Option, + volume: Option, + density: Option, partial_density: Option<&Density>>, - total_moles: Option>, + total_moles: Option, moles: Option<&Moles>>, molefracs: Option<&Array1>, - pressure: Option>, + pressure: Option, density_initialization: DensityInitialization, ) -> EosResult>>>> { // check for density @@ -416,8 +412,8 @@ impl State { /// influence the calculation with respect to the possible solutions. pub fn new_npt( eos: &Arc, - temperature: Temperature, - pressure: Pressure, + temperature: Temperature, + pressure: Pressure, moles: &Moles>, density_initialization: DensityInitialization, ) -> EosResult { @@ -481,9 +477,9 @@ impl State { /// Return a new `State` for given pressure $p$, volume $V$, temperature $T$ and composition $x_i$. pub fn new_npvx( eos: &Arc, - temperature: Temperature, - pressure: Pressure, - volume: Volume, + temperature: Temperature, + pressure: Pressure, + volume: Volume, molefracs: &Array1, density_initialization: DensityInitialization, ) -> EosResult { @@ -511,19 +507,19 @@ impl State { /// When the state cannot be created using the combination of inputs. pub fn new_full( eos: &Arc, - temperature: Option>, - volume: Option>, - density: Option>, + temperature: Option, + volume: Option, + density: Option, partial_density: Option<&Density>>, - total_moles: Option>, + total_moles: Option, moles: Option<&Moles>>, molefracs: Option<&Array1>, - pressure: Option>, - molar_enthalpy: Option>, - molar_entropy: Option>, - molar_internal_energy: Option>, + pressure: Option, + molar_enthalpy: Option, + molar_entropy: Option, + molar_internal_energy: Option, density_initialization: DensityInitialization, - initial_temperature: Option>, + initial_temperature: Option, ) -> EosResult { let state = Self::_new( eos, @@ -568,11 +564,11 @@ impl State { /// Return a new `State` for given pressure $p$ and molar enthalpy $h$. pub fn new_nph( eos: &Arc, - pressure: Pressure, - molar_enthalpy: MolarEnergy, + pressure: Pressure, + molar_enthalpy: MolarEnergy, moles: &Moles>, density_initialization: DensityInitialization, - initial_temperature: Option>, + initial_temperature: Option, ) -> EosResult { let t0 = initial_temperature.unwrap_or(Temperature::from_reduced(298.15)); let mut density = density_initialization; @@ -589,8 +585,8 @@ impl State { /// Return a new `State` for given temperature $T$ and molar enthalpy $h$. pub fn new_nth( eos: &Arc, - temperature: Temperature, - molar_enthalpy: MolarEnergy, + temperature: Temperature, + molar_enthalpy: MolarEnergy, moles: &Moles>, density_initialization: DensityInitialization, ) -> EosResult { @@ -616,8 +612,8 @@ impl State { /// Return a new `State` for given temperature $T$ and molar entropy $s$. pub fn new_nts( eos: &Arc, - temperature: Temperature, - molar_entropy: MolarEntropy, + temperature: Temperature, + molar_entropy: MolarEntropy, moles: &Moles>, density_initialization: DensityInitialization, ) -> EosResult { @@ -640,11 +636,11 @@ impl State { /// Return a new `State` for given pressure $p$ and molar entropy $s$. pub fn new_nps( eos: &Arc, - pressure: Pressure, - molar_entropy: MolarEntropy, + pressure: Pressure, + molar_entropy: MolarEntropy, moles: &Moles>, density_initialization: DensityInitialization, - initial_temperature: Option>, + initial_temperature: Option, ) -> EosResult { let t0 = initial_temperature.unwrap_or(Temperature::from_reduced(298.15)); let mut density = density_initialization; @@ -661,10 +657,10 @@ impl State { /// Return a new `State` for given volume $V$ and molar internal energy $u$. pub fn new_nvu( eos: &Arc, - volume: Volume, - molar_internal_energy: MolarEnergy, + volume: Volume, + molar_internal_energy: MolarEnergy, moles: &Moles>, - initial_temperature: Option>, + initial_temperature: Option, ) -> EosResult { let t0 = initial_temperature.unwrap_or(Temperature::from_reduced(298.15)); let f = |x0| { @@ -679,7 +675,7 @@ impl State { impl State { /// Update the state with the given temperature - pub fn update_temperature(&self, temperature: Temperature) -> EosResult { + pub fn update_temperature(&self, temperature: Temperature) -> EosResult { Self::new_nvt(&self.eos, temperature, self.volume, &self.moles) } @@ -800,11 +796,7 @@ where /// /// There is no validation of the physical state, e.g. /// if resulting densities are below maximum packing fraction. -fn validate( - temperature: Temperature, - volume: Volume, - moles: &Moles>, -) -> EosResult<()> { +fn validate(temperature: Temperature, volume: Volume, moles: &Moles>) -> EosResult<()> { let t = temperature.to_reduced(); let v = volume.to_reduced(); let m = moles.to_reduced(); @@ -836,12 +828,12 @@ fn validate( #[derive(Clone, Copy)] pub enum TPSpec { - Temperature(Temperature), - Pressure(Pressure), + Temperature(Temperature), + Pressure(Pressure), } -impl From> for TPSpec { - fn from(temperature: Temperature) -> Self { +impl From for TPSpec { + fn from(temperature: Temperature) -> Self { Self::Temperature(temperature) } } @@ -850,7 +842,7 @@ impl From> for TPSpec { // used instead of the explicit unit. Maybe the type is too complicated for the // compiler? impl From>> for TPSpec { - fn from(pressure: Pressure) -> Self { + fn from(pressure: Pressure) -> Self { Self::Pressure(pressure) } } diff --git a/feos-core/src/state/properties.rs b/feos-core/src/state/properties.rs index 9500ff52d..c2a9297f3 100644 --- a/feos-core/src/state/properties.rs +++ b/feos-core/src/state/properties.rs @@ -62,14 +62,14 @@ impl State { pub fn dmu_dt( &self, contributions: Contributions, - ) -> > as Div>>::Output { + ) -> > as Div>::Output { Quantity::from_reduced(Array1::from_shape_fn(self.eos.components(), |i| { self.get_or_compute_derivative(PartialDerivative::SecondMixed(DT, DN(i)), contributions) })) } /// Molar isochoric heat capacity: $c_v=\left(\frac{\partial u}{\partial T}\right)_{V,N_i}$ - pub fn molar_isochoric_heat_capacity(&self, contributions: Contributions) -> MolarEntropy { + pub fn molar_isochoric_heat_capacity(&self, contributions: Contributions) -> MolarEntropy { self.temperature * self.ds_dt(contributions) / self.total_moles } @@ -77,7 +77,7 @@ impl State { pub fn specific_isochoric_heat_capacity( &self, contributions: Contributions, - ) -> SpecificEntropy { + ) -> SpecificEntropy { self.molar_isochoric_heat_capacity(contributions) / self.total_molar_weight() } @@ -85,13 +85,13 @@ impl State { pub fn dc_v_dt( &self, contributions: Contributions, - ) -> as Div>>::Output { + ) -> >::Output { (self.temperature * self.d2s_dt2(contributions) + self.ds_dt(contributions)) / self.total_moles } /// Molar isobaric heat capacity: $c_p=\left(\frac{\partial h}{\partial T}\right)_{p,N_i}$ - pub fn molar_isobaric_heat_capacity(&self, contributions: Contributions) -> MolarEntropy { + pub fn molar_isobaric_heat_capacity(&self, contributions: Contributions) -> MolarEntropy { match contributions { Contributions::Residual => self.residual_molar_isobaric_heat_capacity(), _ => { @@ -103,27 +103,24 @@ impl State { } /// Specific isobaric heat capacity: $c_p^{(m)}=\frac{C_p}{m}$ - pub fn specific_isobaric_heat_capacity( - &self, - contributions: Contributions, - ) -> SpecificEntropy { + pub fn specific_isobaric_heat_capacity(&self, contributions: Contributions) -> SpecificEntropy { self.molar_isobaric_heat_capacity(contributions) / self.total_molar_weight() } /// Entropy: $S=-\left(\frac{\partial A}{\partial T}\right)_{V,N_i}$ - pub fn entropy(&self, contributions: Contributions) -> Entropy { + pub fn entropy(&self, contributions: Contributions) -> Entropy { Entropy::from_reduced( -self.get_or_compute_derivative(PartialDerivative::First(DT), contributions), ) } /// Molar entropy: $s=\frac{S}{N}$ - pub fn molar_entropy(&self, contributions: Contributions) -> MolarEntropy { + pub fn molar_entropy(&self, contributions: Contributions) -> MolarEntropy { self.entropy(contributions) / self.total_moles } /// Specific entropy: $s^{(m)}=\frac{S}{m}$ - pub fn specific_entropy(&self, contributions: Contributions) -> SpecificEntropy { + pub fn specific_entropy(&self, contributions: Contributions) -> SpecificEntropy { self.molar_entropy(contributions) / self.total_molar_weight() } @@ -134,10 +131,7 @@ impl State { } /// Partial derivative of the entropy w.r.t. temperature: $\left(\frac{\partial S}{\partial T}\right)_{V,N_i}$ - pub fn ds_dt( - &self, - contributions: Contributions, - ) -> as Div>>::Output { + pub fn ds_dt(&self, contributions: Contributions) -> >::Output { Quantity::from_reduced( -self.get_or_compute_derivative(PartialDerivative::Second(DT), contributions), ) @@ -147,26 +141,26 @@ impl State { pub fn d2s_dt2( &self, contributions: Contributions, - ) -> < as Div>>::Output as Div>>::Output { + ) -> <>::Output as Div>::Output { Quantity::from_reduced( -self.get_or_compute_derivative(PartialDerivative::Third(DT), contributions), ) } /// Enthalpy: $H=A+TS+pV$ - pub fn enthalpy(&self, contributions: Contributions) -> Energy { + pub fn enthalpy(&self, contributions: Contributions) -> Energy { self.temperature * self.entropy(contributions) + self.helmholtz_energy(contributions) + self.pressure(contributions) * self.volume } /// Molar enthalpy: $h=\frac{H}{N}$ - pub fn molar_enthalpy(&self, contributions: Contributions) -> MolarEnergy { + pub fn molar_enthalpy(&self, contributions: Contributions) -> MolarEnergy { self.enthalpy(contributions) / self.total_moles } /// Specific enthalpy: $h^{(m)}=\frac{H}{m}$ - pub fn specific_enthalpy(&self, contributions: Contributions) -> SpecificEnergy { + pub fn specific_enthalpy(&self, contributions: Contributions) -> SpecificEnergy { self.molar_enthalpy(contributions) / self.total_molar_weight() } @@ -178,73 +172,73 @@ impl State { } /// Helmholtz energy: $A$ - pub fn helmholtz_energy(&self, contributions: Contributions) -> Energy { + pub fn helmholtz_energy(&self, contributions: Contributions) -> Energy { Energy::from_reduced( self.get_or_compute_derivative(PartialDerivative::Zeroth, contributions), ) } /// Molar Helmholtz energy: $a=\frac{A}{N}$ - pub fn molar_helmholtz_energy(&self, contributions: Contributions) -> MolarEnergy { + pub fn molar_helmholtz_energy(&self, contributions: Contributions) -> MolarEnergy { self.helmholtz_energy(contributions) / self.total_moles } /// Specific Helmholtz energy: $a^{(m)}=\frac{A}{m}$ - pub fn specific_helmholtz_energy(&self, contributions: Contributions) -> SpecificEnergy { + pub fn specific_helmholtz_energy(&self, contributions: Contributions) -> SpecificEnergy { self.molar_helmholtz_energy(contributions) / self.total_molar_weight() } /// Internal energy: $U=A+TS$ - pub fn internal_energy(&self, contributions: Contributions) -> Energy { + pub fn internal_energy(&self, contributions: Contributions) -> Energy { self.temperature * self.entropy(contributions) + self.helmholtz_energy(contributions) } /// Molar internal energy: $u=\frac{U}{N}$ - pub fn molar_internal_energy(&self, contributions: Contributions) -> MolarEnergy { + pub fn molar_internal_energy(&self, contributions: Contributions) -> MolarEnergy { self.internal_energy(contributions) / self.total_moles } /// Specific internal energy: $u^{(m)}=\frac{U}{m}$ - pub fn specific_internal_energy(&self, contributions: Contributions) -> SpecificEnergy { + pub fn specific_internal_energy(&self, contributions: Contributions) -> SpecificEnergy { self.molar_internal_energy(contributions) / self.total_molar_weight() } /// Gibbs energy: $G=A+pV$ - pub fn gibbs_energy(&self, contributions: Contributions) -> Energy { + pub fn gibbs_energy(&self, contributions: Contributions) -> Energy { self.pressure(contributions) * self.volume + self.helmholtz_energy(contributions) } /// Molar Gibbs energy: $g=\frac{G}{N}$ - pub fn molar_gibbs_energy(&self, contributions: Contributions) -> MolarEnergy { + pub fn molar_gibbs_energy(&self, contributions: Contributions) -> MolarEnergy { self.gibbs_energy(contributions) / self.total_moles } /// Specific Gibbs energy: $g^{(m)}=\frac{G}{m}$ - pub fn specific_gibbs_energy(&self, contributions: Contributions) -> SpecificEnergy { + pub fn specific_gibbs_energy(&self, contributions: Contributions) -> SpecificEnergy { self.molar_gibbs_energy(contributions) / self.total_molar_weight() } /// Joule Thomson coefficient: $\mu_{JT}=\left(\frac{\partial T}{\partial p}\right)_{H,N_i}$ - pub fn joule_thomson(&self) -> as Div>>::Output { + pub fn joule_thomson(&self) -> >::Output { let c = Contributions::Total; -(self.volume + self.temperature * self.dp_dt(c) / self.dp_dv(c)) / (self.total_moles * self.molar_isobaric_heat_capacity(c)) } /// Isentropic compressibility: $\kappa_s=-\frac{1}{V}\left(\frac{\partial V}{\partial p}\right)_{S,N_i}$ - pub fn isentropic_compressibility(&self) -> >>::Output { + pub fn isentropic_compressibility(&self) -> >::Output { let c = Contributions::Total; -self.molar_isochoric_heat_capacity(c) / (self.molar_isobaric_heat_capacity(c) * self.dp_dv(c) * self.volume) } /// Isenthalpic compressibility: $\kappa_H=-\frac{1}{V}\left(\frac{\partial V}{\partial p}\right)_{H,N_i}$ - pub fn isenthalpic_compressibility(&self) -> >>::Output { + pub fn isenthalpic_compressibility(&self) -> >::Output { self.isentropic_compressibility() * (1.0 + self.grueneisen_parameter()) } /// Thermal expansivity: $\alpha_p=-\frac{1}{V}\left(\frac{\partial V}{\partial T}\right)_{p,N_i}$ - pub fn thermal_expansivity(&self) -> >>::Output { + pub fn thermal_expansivity(&self) -> >::Output { let c = Contributions::Total; -self.dp_dt(c) / self.dp_dv(c) / self.volume } @@ -257,10 +251,7 @@ impl State { } /// Chemical potential $\mu_i$ evaluated for each contribution of the equation of state. - pub fn chemical_potential_contributions( - &self, - component: usize, - ) -> Vec<(String, MolarEnergy)> { + pub fn chemical_potential_contributions(&self, component: usize) -> Vec<(String, MolarEnergy)> { let new_state = self.derive1(DN(component)); let contributions = self.eos.evaluate_residual_contributions(&new_state); let mut res = Vec::with_capacity(contributions.len() + 1); @@ -280,7 +271,7 @@ impl State { } /// Speed of sound: $c=\sqrt{\left(\frac{\partial p}{\partial\rho^{(m)}}\right)_{S,N_i}}$ - pub fn speed_of_sound(&self) -> Velocity { + pub fn speed_of_sound(&self) -> Velocity { (1.0 / (self.density * self.total_molar_weight() * self.isentropic_compressibility())) .sqrt() } diff --git a/feos-core/src/state/residual_properties.rs b/feos-core/src/state/residual_properties.rs index 7f885b6ed..948654e7d 100644 --- a/feos-core/src/state/residual_properties.rs +++ b/feos-core/src/state/residual_properties.rs @@ -56,17 +56,17 @@ impl State { } /// Residual Helmholtz energy $A^\text{res}$ - pub fn residual_helmholtz_energy(&self) -> Energy { + pub fn residual_helmholtz_energy(&self) -> Energy { Energy::from_reduced(self.get_or_compute_derivative_residual(PartialDerivative::Zeroth)) } /// Residual molar Helmholtz energy $a^\text{res}$ - pub fn residual_molar_helmholtz_energy(&self) -> MolarEnergy { + pub fn residual_molar_helmholtz_energy(&self) -> MolarEnergy { self.residual_helmholtz_energy() / self.total_moles } /// Residual Helmholtz energy $A^\text{res}$ evaluated for each contribution of the equation of state. - pub fn residual_helmholtz_energy_contributions(&self) -> Vec<(String, Energy)> { + pub fn residual_helmholtz_energy_contributions(&self) -> Vec<(String, Energy)> { let new_state = self.derive0(); let residual_contributions = self.eos.evaluate_residual_contributions(&new_state); let mut res = Vec::with_capacity(residual_contributions.len()); @@ -77,19 +77,19 @@ impl State { } /// Residual entropy $S^\text{res}=\left(\frac{\partial A^\text{res}}{\partial T}\right)_{V,N_i}$ - pub fn residual_entropy(&self) -> Entropy { + pub fn residual_entropy(&self) -> Entropy { Entropy::from_reduced( -self.get_or_compute_derivative_residual(PartialDerivative::First(DT)), ) } /// Residual entropy $s^\text{res}=\left(\frac{\partial a^\text{res}}{\partial T}\right)_{V,N_i}$ - pub fn residual_molar_entropy(&self) -> MolarEntropy { + pub fn residual_molar_entropy(&self) -> MolarEntropy { self.residual_entropy() / self.total_moles } /// Pressure: $p=-\left(\frac{\partial A}{\partial V}\right)_{T,N_i}$ - pub fn pressure(&self, contributions: Contributions) -> Pressure { + pub fn pressure(&self, contributions: Contributions) -> Pressure { let ideal_gas = self.density * RGAS * self.temperature; let residual = Pressure::from_reduced( -self.get_or_compute_derivative_residual(PartialDerivative::First(DV)), @@ -108,7 +108,7 @@ impl State { pub fn residual_chemical_potential_contributions( &self, component: usize, - ) -> Vec<(String, MolarEnergy)> { + ) -> Vec<(String, MolarEnergy)> { let new_state = self.derive1(DN(component)); let contributions = self.eos.evaluate_residual_contributions(&new_state); let mut res = Vec::with_capacity(contributions.len()); @@ -129,10 +129,7 @@ impl State { // pressure derivatives /// Partial derivative of pressure w.r.t. volume: $\left(\frac{\partial p}{\partial V}\right)_{T,N_i}$ - pub fn dp_dv( - &self, - contributions: Contributions, - ) -> as Div>>::Output { + pub fn dp_dv(&self, contributions: Contributions) -> >::Output { let ideal_gas = -self.density * RGAS * self.temperature / self.volume; let residual = Quantity::from_reduced( -self.get_or_compute_derivative_residual(PartialDerivative::Second(DV)), @@ -141,18 +138,12 @@ impl State { } /// Partial derivative of pressure w.r.t. density: $\left(\frac{\partial p}{\partial \rho}\right)_{T,N_i}$ - pub fn dp_drho( - &self, - contributions: Contributions, - ) -> as Div>>::Output { + pub fn dp_drho(&self, contributions: Contributions) -> >::Output { -self.volume / self.density * self.dp_dv(contributions) } /// Partial derivative of pressure w.r.t. temperature: $\left(\frac{\partial p}{\partial T}\right)_{V,N_i}$ - pub fn dp_dt( - &self, - contributions: Contributions, - ) -> as Div>>::Output { + pub fn dp_dt(&self, contributions: Contributions) -> >::Output { let ideal_gas = self.density * RGAS; let residual = Quantity::from_reduced( -self.get_or_compute_derivative_residual(PartialDerivative::SecondMixed(DV, DT)), @@ -164,7 +155,7 @@ impl State { pub fn dp_dni( &self, contributions: Contributions, - ) -> as Div>>>::Output { + ) -> >>>::Output { let ideal_gas = Quantity::from_vec(vec![ RGAS * self.temperature / self.volume; self.eos.components() @@ -179,7 +170,7 @@ impl State { pub fn d2p_dv2( &self, contributions: Contributions, - ) -> < as Div>>::Output as Div>>::Output { + ) -> <>::Output as Div>::Output { let ideal_gas = 2.0 * self.density * RGAS * self.temperature / (self.volume * self.volume); let residual = Quantity::from_reduced( -self.get_or_compute_derivative_residual(PartialDerivative::Third(DV)), @@ -191,7 +182,7 @@ impl State { pub fn d2p_drho2( &self, contributions: Contributions, - ) -> < as Div>>::Output as Div>>::Output { + ) -> <>::Output as Div>::Output { self.volume / (self.density * self.density) * (self.volume * self.d2p_dv2(contributions) + 2.0 * self.dp_dv(contributions)) } @@ -203,7 +194,7 @@ impl State { } // This function is designed specifically for use in density iterations - pub(crate) fn p_dpdrho(&self) -> (Pressure, as Div>>::Output) { + pub(crate) fn p_dpdrho(&self) -> (Pressure, >::Output) { let dp_dv = self.dp_dv(Contributions::Total); ( self.pressure(Contributions::Total), @@ -220,7 +211,7 @@ impl State { pub fn dmu_dni( &self, contributions: Contributions, - ) -> > as Div>>::Output { + ) -> > as Div>::Output { let n = self.eos.components(); Quantity::from_shape_fn((n, n), |(i, j)| { let ideal_gas = if i == j { @@ -241,9 +232,9 @@ impl State { pub(crate) fn d2pdrho2( &self, ) -> ( - Pressure, - as Div>>::Output, - < as Div>>::Output as Div>>::Output, + Pressure, + >::Output, + <>::Output as Div>::Output, ) { let d2p_dv2 = self.d2p_dv2(Contributions::Total); let dp_dv = self.dp_dv(Contributions::Total); @@ -255,12 +246,12 @@ impl State { } /// Isothermal compressibility: $\kappa_T=-\frac{1}{V}\left(\frac{\partial V}{\partial p}\right)_{T,N_i}$ - pub fn isothermal_compressibility(&self) -> >>::Output { + pub fn isothermal_compressibility(&self) -> >::Output { -1.0 / (self.dp_dv(Contributions::Total) * self.volume) } /// Pressure $p$ evaluated for each contribution of the equation of state. - pub fn pressure_contributions(&self) -> Vec<(String, Pressure)> { + pub fn pressure_contributions(&self) -> Vec<(String, Pressure)> { let new_state = self.derive1(DV); let contributions = self.eos.evaluate_residual_contributions(&new_state); let mut res = Vec::with_capacity(contributions.len() + 1); @@ -274,7 +265,7 @@ impl State { // entropy derivatives /// Partial derivative of the residual entropy w.r.t. temperature: $\left(\frac{\partial S^\text{res}}{\partial T}\right)_{V,N_i}$ - pub fn ds_res_dt(&self) -> as Div>>::Output { + pub fn ds_res_dt(&self) -> >::Output { Quantity::from_reduced( -self.get_or_compute_derivative_residual(PartialDerivative::Second(DT)), ) @@ -283,14 +274,14 @@ impl State { /// Second partial derivative of the residual entropy w.r.t. temperature: $\left(\frac{\partial^2S^\text{res}}{\partial T^2}\right)_{V,N_i}$ pub fn d2s_res_dt2( &self, - ) -> < as Div>>::Output as Div>>::Output { + ) -> <>::Output as Div>::Output { Quantity::from_reduced( -self.get_or_compute_derivative_residual(PartialDerivative::Third(DT)), ) } /// Partial derivative of chemical potential w.r.t. temperature: $\left(\frac{\partial\mu_i}{\partial T}\right)_{V,N_i}$ - pub fn dmu_res_dt(&self) -> > as Div>>::Output { + pub fn dmu_res_dt(&self) -> > as Div>::Output { Quantity::from_reduced(Array1::from_shape_fn(self.eos.components(), |i| { self.get_or_compute_derivative_residual(PartialDerivative::SecondMixed(DT, DN(i))) })) @@ -365,17 +356,17 @@ impl State { } /// Residual molar isochoric heat capacity: $c_v^\text{res}=\left(\frac{\partial u^\text{res}}{\partial T}\right)_{V,N_i}$ - pub fn residual_molar_isochoric_heat_capacity(&self) -> MolarEntropy { + pub fn residual_molar_isochoric_heat_capacity(&self) -> MolarEntropy { self.temperature * self.ds_res_dt() / self.total_moles } /// Partial derivative of the residual molar isochoric heat capacity w.r.t. temperature: $\left(\frac{\partial c_V^\text{res}}{\partial T}\right)_{V,N_i}$ - pub fn dc_v_res_dt(&self) -> as Div>>::Output { + pub fn dc_v_res_dt(&self) -> >::Output { (self.temperature * self.d2s_res_dt2() + self.ds_res_dt()) / self.total_moles } /// Residual molar isobaric heat capacity: $c_p^\text{res}=\left(\frac{\partial h^\text{res}}{\partial T}\right)_{p,N_i}$ - pub fn residual_molar_isobaric_heat_capacity(&self) -> MolarEntropy { + pub fn residual_molar_isobaric_heat_capacity(&self) -> MolarEntropy { self.temperature / self.total_moles * (self.ds_res_dt() - self.dp_dt(Contributions::Total).powi::() / self.dp_dv(Contributions::Total)) @@ -383,29 +374,29 @@ impl State { } /// Residual enthalpy: $H^\text{res}(T,p,\mathbf{n})=A^\text{res}+TS^\text{res}+p^\text{res}V$ - pub fn residual_enthalpy(&self) -> Energy { + pub fn residual_enthalpy(&self) -> Energy { self.temperature * self.residual_entropy() + self.residual_helmholtz_energy() + self.pressure(Contributions::Residual) * self.volume } /// Residual molar enthalpy: $h^\text{res}(T,p,\mathbf{n})=a^\text{res}+Ts^\text{res}+p^\text{res}v$ - pub fn residual_molar_enthalpy(&self) -> MolarEnergy { + pub fn residual_molar_enthalpy(&self) -> MolarEnergy { self.residual_enthalpy() / self.total_moles } /// Residual internal energy: $U^\text{res}(T,V,\mathbf{n})=A^\text{res}+TS^\text{res}$ - pub fn residual_internal_energy(&self) -> Energy { + pub fn residual_internal_energy(&self) -> Energy { self.temperature * self.residual_entropy() + self.residual_helmholtz_energy() } /// Residual molar internal energy: $u^\text{res}(T,V,\mathbf{n})=a^\text{res}+Ts^\text{res}$ - pub fn residual_molar_internal_energy(&self) -> MolarEnergy { + pub fn residual_molar_internal_energy(&self) -> MolarEnergy { self.residual_internal_energy() / self.total_moles } /// Residual Gibbs energy: $G^\text{res}(T,p,\mathbf{n})=A^\text{res}+p^\text{res}V-NRT \ln Z$ - pub fn residual_gibbs_energy(&self) -> Energy { + pub fn residual_gibbs_energy(&self) -> Energy { self.pressure(Contributions::Residual) * self.volume + self.residual_helmholtz_energy() - self.total_moles * RGAS @@ -414,12 +405,12 @@ impl State { } /// Residual Gibbs energy: $g^\text{res}(T,p,\mathbf{n})=a^\text{res}+p^\text{res}v-RT \ln Z$ - pub fn residual_molar_gibbs_energy(&self) -> MolarEnergy { + pub fn residual_molar_gibbs_energy(&self) -> MolarEnergy { self.residual_gibbs_energy() / self.total_moles } /// Total molar weight: $MW=\sum_ix_iMW_i$ - pub fn total_molar_weight(&self) -> MolarWeight { + pub fn total_molar_weight(&self) -> MolarWeight { (self.eos.molar_weight() * Dimensionless::from(&self.molefracs)).sum() } @@ -429,12 +420,12 @@ impl State { } /// Total mass: $m=\sum_im_i=nMW$ - pub fn total_mass(&self) -> Mass { + pub fn total_mass(&self) -> Mass { self.total_moles * self.total_molar_weight() } /// Mass density: $\rho^{(m)}=\frac{m}{V}$ - pub fn mass_density(&self) -> MassDensity { + pub fn mass_density(&self) -> MassDensity { self.density * self.total_molar_weight() } @@ -450,7 +441,7 @@ impl State { /// that implement the [EntropyScaling] trait. impl State { /// Return the viscosity via entropy scaling. - pub fn viscosity(&self) -> EosResult> { + pub fn viscosity(&self) -> EosResult { let s = self.residual_molar_entropy().to_reduced(); Ok(self .eos @@ -468,13 +459,13 @@ impl State { } /// Return the viscosity reference as used in entropy scaling. - pub fn viscosity_reference(&self) -> EosResult> { + pub fn viscosity_reference(&self) -> EosResult { self.eos .viscosity_reference(self.temperature, self.volume, &self.moles) } /// Return the diffusion via entropy scaling. - pub fn diffusion(&self) -> EosResult> { + pub fn diffusion(&self) -> EosResult { let s = self.residual_molar_entropy().to_reduced(); Ok(self .eos @@ -492,13 +483,13 @@ impl State { } /// Return the diffusion reference as used in entropy scaling. - pub fn diffusion_reference(&self) -> EosResult> { + pub fn diffusion_reference(&self) -> EosResult { self.eos .diffusion_reference(self.temperature, self.volume, &self.moles) } /// Return the thermal conductivity via entropy scaling. - pub fn thermal_conductivity(&self) -> EosResult> { + pub fn thermal_conductivity(&self) -> EosResult { let s = self.residual_molar_entropy().to_reduced(); Ok(self .eos @@ -520,7 +511,7 @@ impl State { } /// Return the thermal conductivity reference as used in entropy scaling. - pub fn thermal_conductivity_reference(&self) -> EosResult> { + pub fn thermal_conductivity_reference(&self) -> EosResult { self.eos .thermal_conductivity_reference(self.temperature, self.volume, &self.moles) } diff --git a/feos-derive/src/residual.rs b/feos-derive/src/residual.rs index fcafda7f9..f5dbbd133 100644 --- a/feos-derive/src/residual.rs +++ b/feos-derive/src/residual.rs @@ -100,10 +100,10 @@ fn impl_entropy_scaling( impl EntropyScaling for ResidualModel { fn viscosity_reference( &self, - temperature: Temperature, - volume: Volume, + temperature: Temperature, + volume: Volume, moles: &Moles>, - ) -> EosResult> { + ) -> EosResult { match self { #(#etar,)* _ => unimplemented!(), @@ -119,10 +119,10 @@ fn impl_entropy_scaling( fn diffusion_reference( &self, - temperature: Temperature, - volume: Volume, + temperature: Temperature, + volume: Volume, moles: &Moles>, - ) -> EosResult> { + ) -> EosResult { match self { #(#dr,)* _ => unimplemented!(), @@ -138,10 +138,10 @@ fn impl_entropy_scaling( fn thermal_conductivity_reference( &self, - temperature: Temperature, - volume: Volume, + temperature: Temperature, + volume: Volume, moles: &Moles>, - ) -> EosResult> { + ) -> EosResult { match self { #(#thcr,)* _ => unimplemented!(), diff --git a/feos-dft/src/adsorption/external_potential.rs b/feos-dft/src/adsorption/external_potential.rs index 8d9cdffa4..82888a765 100644 --- a/feos-dft/src/adsorption/external_potential.rs +++ b/feos-dft/src/adsorption/external_potential.rs @@ -57,7 +57,7 @@ pub enum ExternalPotential { sigma_ss: Array1, epsilon_k_ss: Array1, pore_center: [f64; 3], - system_size: [Length; 3], + system_size: [Length; 3], n_grid: [usize; 2], cutoff_radius: Option, }, diff --git a/feos-dft/src/adsorption/fea_potential.rs b/feos-dft/src/adsorption/fea_potential.rs index d112a12df..00ec65fe6 100644 --- a/feos-dft/src/adsorption/fea_potential.rs +++ b/feos-dft/src/adsorption/fea_potential.rs @@ -15,7 +15,7 @@ pub fn calculate_fea_potential( sigma_sf: Array1, epsilon_k_sf: Array1, pore_center: &[f64; 3], - system_size: &[Length; 3], + system_size: &[Length; 3], n_grid: &[usize; 2], temperature: f64, geometry: Geometry, diff --git a/feos-dft/src/adsorption/mod.rs b/feos-dft/src/adsorption/mod.rs index 7109ddc05..34ed30df7 100644 --- a/feos-dft/src/adsorption/mod.rs +++ b/feos-dft/src/adsorption/mod.rs @@ -55,7 +55,7 @@ where /// Calculate an adsorption isotherm (starting at low pressure) pub fn adsorption_isotherm>( functional: &Arc>, - temperature: Temperature, + temperature: Temperature, pressure: &Pressure>, pore: &S, molefracs: Option<&Array1>, @@ -75,7 +75,7 @@ where /// Calculate an desorption isotherm (starting at high pressure) pub fn desorption_isotherm>( functional: &Arc>, - temperature: Temperature, + temperature: Temperature, pressure: &Pressure>, pore: &S, molefracs: Option<&Array1>, @@ -100,7 +100,7 @@ where /// Calculate an equilibrium isotherm pub fn equilibrium_isotherm>( functional: &Arc>, - temperature: Temperature, + temperature: Temperature, pressure: &Pressure>, pore: &S, molefracs: Option<&Array1>, @@ -186,7 +186,7 @@ where fn isotherm>( functional: &Arc>, - temperature: Temperature, + temperature: Temperature, pressure: &Pressure>, pore: &S, molefracs: Option<&Array1>, @@ -248,9 +248,9 @@ where /// Calculate the phase transition from an empty to a filled pore. pub fn phase_equilibrium>( functional: &Arc>, - temperature: Temperature, - p_min: Pressure, - p_max: Pressure, + temperature: Temperature, + p_min: Pressure, + p_max: Pressure, pore: &S, molefracs: Option<&Array1>, solver: Option<&DFTSolver>, diff --git a/feos-dft/src/adsorption/pore.rs b/feos-dft/src/adsorption/pore.rs index c83fad608..bfb0a4fba 100644 --- a/feos-dft/src/adsorption/pore.rs +++ b/feos-dft/src/adsorption/pore.rs @@ -21,7 +21,7 @@ const DEFAULT_GRID_POINTS: usize = 2048; /// Parameters required to specify a 1D pore. pub struct Pore1D { pub geometry: Geometry, - pub pore_size: Length, + pub pore_size: Length, pub potential: ExternalPotential, pub n_grid: Option, pub potential_cutoff: Option, @@ -30,7 +30,7 @@ pub struct Pore1D { impl Pore1D { pub fn new( geometry: Geometry, - pore_size: Length, + pore_size: Length, potential: ExternalPotential, n_grid: Option, potential_cutoff: Option, @@ -56,7 +56,7 @@ pub trait PoreSpecification { ) -> EosResult>; /// Return the pore volume using Helium at 298 K as reference. - fn pore_volume(&self) -> EosResult> + fn pore_volume(&self) -> EosResult where D::Larger: Dimension, { @@ -78,8 +78,8 @@ pub trait PoreSpecification { /// Density profile and properties of a confined system in arbitrary dimensions. pub struct PoreProfile { pub profile: DFTProfile, - pub grand_potential: Option>, - pub interfacial_tension: Option>, + pub grand_potential: Option, + pub interfacial_tension: Option, } /// Density profile and properties of a 1D confined system. @@ -138,7 +138,7 @@ where Ok(&h_ads * b_unit / a_unit) } - pub fn enthalpy_of_adsorption(&self) -> EosResult> { + pub fn enthalpy_of_adsorption(&self) -> EosResult { Ok((self.partial_molar_enthalpy_of_adsorption()? * Dimensionless::from(&self.profile.bulk.molefracs)) .sum()) @@ -200,8 +200,8 @@ impl PoreSpecification for Pore1D { } fn external_potential_1d( - pore_width: Length, - temperature: Temperature, + pore_width: Length, + temperature: Temperature, potential: &ExternalPotential, fluid_parameters: &P, axis: &Axis, diff --git a/feos-dft/src/adsorption/pore3d.rs b/feos-dft/src/adsorption/pore3d.rs index 1cad81f62..acc0703d6 100644 --- a/feos-dft/src/adsorption/pore3d.rs +++ b/feos-dft/src/adsorption/pore3d.rs @@ -12,26 +12,26 @@ use ndarray::Zip; /// Parameters required to specify a 3D pore. pub struct Pore3D { - system_size: [Length; 3], + system_size: [Length; 3], angles: Option<[Angle; 3]>, n_grid: [usize; 3], coordinates: Length>, sigma_ss: Array1, epsilon_k_ss: Array1, potential_cutoff: Option, - cutoff_radius: Option>, + cutoff_radius: Option, } impl Pore3D { pub fn new( - system_size: [Length; 3], + system_size: [Length; 3], angles: Option<[Angle; 3]>, n_grid: [usize; 3], coordinates: Length>, sigma_ss: Array1, epsilon_k_ss: Array1, potential_cutoff: Option, - cutoff_radius: Option>, + cutoff_radius: Option, ) -> Self { Self { system_size, @@ -110,11 +110,11 @@ impl PoreSpecification for Pore3D { pub fn external_potential_3d( functional: &F, axis: [&Axis; 3], - system_size: [Length; 3], + system_size: [Length; 3], coordinates: Array2, sigma_ss: &Array1, epsilon_ss: &Array1, - cutoff_radius: Option>, + cutoff_radius: Option, potential_cutoff: Option, reduced_temperature: f64, ) -> EosResult> { diff --git a/feos-dft/src/geometry.rs b/feos-dft/src/geometry.rs index b9fee8087..5f743eea6 100644 --- a/feos-dft/src/geometry.rs +++ b/feos-dft/src/geometry.rs @@ -106,11 +106,7 @@ impl Axis { /// /// The potential_offset is required to make sure that particles /// can not interact through walls. - pub fn new_cartesian( - points: usize, - length: Length, - potential_offset: Option, - ) -> Self { + pub fn new_cartesian(points: usize, length: Length, potential_offset: Option) -> Self { let potential_offset = potential_offset.unwrap_or(0.0); let l = length.to_reduced() + potential_offset; let cell_size = l / points as f64; @@ -127,7 +123,7 @@ impl Axis { } /// Create a new (equidistant) spherical axis. - pub fn new_spherical(points: usize, length: Length) -> Self { + pub fn new_spherical(points: usize, length: Length) -> Self { let l = length.to_reduced(); let cell_size = l / points as f64; let grid = Array1::linspace(0.5 * cell_size, l - 0.5 * cell_size, points); @@ -145,7 +141,7 @@ impl Axis { } /// Create a new logarithmically scaled cylindrical axis. - pub fn new_polar(points: usize, length: Length) -> Self { + pub fn new_polar(points: usize, length: Length) -> Self { let l = length.to_reduced(); let mut alpha = 0.002_f64; diff --git a/feos-dft/src/ideal_chain_contribution.rs b/feos-dft/src/ideal_chain_contribution.rs index 04e95e573..d42e68a00 100644 --- a/feos-dft/src/ideal_chain_contribution.rs +++ b/feos-dft/src/ideal_chain_contribution.rs @@ -63,7 +63,7 @@ impl IdealChainContribution { pub fn helmholtz_energy_density( &self, - temperature: Temperature, + temperature: Temperature, density: &Density>, ) -> EosResult>> where diff --git a/feos-dft/src/interface/mod.rs b/feos-dft/src/interface/mod.rs index fec06b749..8ad41b2f3 100644 --- a/feos-dft/src/interface/mod.rs +++ b/feos-dft/src/interface/mod.rs @@ -18,8 +18,8 @@ const MIN_WIDTH: f64 = 100.0; pub struct PlanarInterface { pub profile: DFTProfile, pub vle: PhaseEquilibrium, 2>, - pub surface_tension: Option>, - pub equimolar_radius: Option>, + pub surface_tension: Option, + pub equimolar_radius: Option, } impl Clone for PlanarInterface { @@ -63,7 +63,7 @@ impl PlanarInterface { } impl PlanarInterface { - pub fn new(vle: &PhaseEquilibrium, 2>, n_grid: usize, l_grid: Length) -> Self { + pub fn new(vle: &PhaseEquilibrium, 2>, n_grid: usize, l_grid: Length) -> Self { let dft = &vle.vapor().eos; // generate grid @@ -85,8 +85,8 @@ impl PlanarInterface { pub fn from_tanh( vle: &PhaseEquilibrium, 2>, n_grid: usize, - l_grid: Length, - critical_temperature: Temperature, + l_grid: Length, + critical_temperature: Temperature, fix_equimolar_surface: bool, ) -> Self { let mut profile = Self::new(vle, n_grid, l_grid); @@ -237,7 +237,7 @@ impl PlanarInterface { } /// Interface thickness (90-10 number density difference) - pub fn interfacial_thickness(&self) -> EosResult> { + pub fn interfacial_thickness(&self) -> EosResult { let s = self.profile.density.shape(); let rho = self.profile.density.sum_axis(Axis_nd(0)).to_reduced(); let z = self.profile.grid.grids()[0]; @@ -354,7 +354,7 @@ fn interp_symmetric( rho_pdgt: Density>, vle: &PhaseEquilibrium, 2>, z: &Array1, - radius: Length, + radius: Length, ) -> EosResult>> { let reduced_density = Array2::from_shape_fn(rho_pdgt.raw_dim(), |(i, j)| { ((rho_pdgt.get((i, j)) - vle_pdgt.vapor().partial_density.get(i)) diff --git a/feos-dft/src/interface/surface_tension_diagram.rs b/feos-dft/src/interface/surface_tension_diagram.rs index 856dc2670..64acfb2d0 100644 --- a/feos-dft/src/interface/surface_tension_diagram.rs +++ b/feos-dft/src/interface/surface_tension_diagram.rs @@ -18,8 +18,8 @@ impl SurfaceTensionDiagram { dia: &Vec, 2>>, init_densities: Option, n_grid: Option, - l_grid: Option>, - critical_temperature: Option>, + l_grid: Option, + critical_temperature: Option, fix_equimolar_surface: Option, solver: Option<&DFTSolver>, ) -> Self { diff --git a/feos-dft/src/pdgt.rs b/feos-dft/src/pdgt.rs index fa240bb2a..4cd836bef 100644 --- a/feos-dft/src/pdgt.rs +++ b/feos-dft/src/pdgt.rs @@ -118,7 +118,7 @@ impl dyn FunctionalContribution { #[allow(clippy::type_complexity)] pub fn influence_diagonal( &self, - temperature: Temperature, + temperature: Temperature, density: &Density>, ) -> EosResult<(Pressure>, InfluenceParameter>)> { let t = temperature.to_reduced(); @@ -147,8 +147,8 @@ impl DFT { vle: &PhaseEquilibrium, n_grid: usize, reference_component: usize, - z: Option<(&mut Length>, &mut Length)>, - ) -> EosResult<(Density>, SurfaceTension)> { + z: Option<(&mut Length>, &mut Length)>, + ) -> EosResult<(Density>, SurfaceTension)> { // calculate density profile let density = if self.components() == 1 { let delta_rho = (vle.vapor().density - vle.liquid().density) / (n_grid + 1) as f64; diff --git a/feos-dft/src/profile/mod.rs b/feos-dft/src/profile/mod.rs index 0b2278ce5..30a8794ec 100644 --- a/feos-dft/src/profile/mod.rs +++ b/feos-dft/src/profile/mod.rs @@ -100,7 +100,7 @@ pub struct DFTProfile { pub grid: Grid, pub convolver: Arc>, pub dft: Arc>, - pub temperature: Temperature, + pub temperature: Temperature, pub density: Density>, pub specification: Arc>, pub external_potential: Array, @@ -267,7 +267,7 @@ where /// Return the volume of the profile. /// /// In periodic directions, the length is assumed to be 1 Å. - pub fn volume(&self) -> Volume { + pub fn volume(&self) -> Volume { let volume: f64 = self.grid.axes().iter().map(|ax| ax.volume()).product(); Volume::from_reduced(volume * self.grid.functional_determinant()) } @@ -325,7 +325,7 @@ where } /// Return the total number of moles in the system. - pub fn total_moles(&self) -> Moles { + pub fn total_moles(&self) -> Moles { self.moles().sum() } } diff --git a/feos-dft/src/profile/properties.rs b/feos-dft/src/profile/properties.rs index 4c62ee693..50f073f7f 100644 --- a/feos-dft/src/profile/properties.rs +++ b/feos-dft/src/profile/properties.rs @@ -13,12 +13,12 @@ use std::ops::{AddAssign, Div}; use std::sync::Arc; type DrhoDmu = - ::Larger>> as Div>>::Output; -type DnDmu = > as Div>>::Output; -type DrhoDp = > as Div>>::Output; -type DnDp = > as Div>>::Output; -type DrhoDT = > as Div>>::Output; -type DnDT = > as Div>>::Output; + ::Larger>> as Div>::Output; +type DnDmu = > as Div>::Output; +type DrhoDp = > as Div>::Output; +type DnDp = > as Div>::Output; +type DrhoDT = > as Div>::Output; +type DnDT = > as Div>::Output; impl DFTProfile where @@ -50,7 +50,7 @@ where } /// Calculate the grand potential $\Omega$. - pub fn grand_potential(&self) -> EosResult> { + pub fn grand_potential(&self) -> EosResult { Ok(self.integrate(&self.grand_potential_density()?)) } @@ -221,7 +221,7 @@ where /// Calculate the entropy $S$. /// /// Untested with heterosegmented functionals. - pub fn entropy(&self, contributions: Contributions) -> EosResult> { + pub fn entropy(&self, contributions: Contributions) -> EosResult { Ok(self.integrate(&self.entropy_density(contributions)?)) } @@ -266,7 +266,7 @@ where /// Calculate the internal energy $U$. /// /// Untested with heterosegmented functionals. - pub fn internal_energy(&self, contributions: Contributions) -> EosResult> { + pub fn internal_energy(&self, contributions: Contributions) -> EosResult { Ok(self.integrate(&self.internal_energy_density(contributions)?)) } } diff --git a/feos-dft/src/solvation/pair_correlation.rs b/feos-dft/src/solvation/pair_correlation.rs index 556b3d447..23dcad1d1 100644 --- a/feos-dft/src/solvation/pair_correlation.rs +++ b/feos-dft/src/solvation/pair_correlation.rs @@ -19,7 +19,7 @@ pub trait PairPotential { pub struct PairCorrelation { pub profile: DFTProfile, pub pair_correlation_function: Option>, - pub self_solvation_free_energy: Option>, + pub self_solvation_free_energy: Option, pub structure_factor: Option, } @@ -35,12 +35,7 @@ impl Clone for PairCorrelation { } impl PairCorrelation { - pub fn new( - bulk: &State>, - test_particle: usize, - n_grid: usize, - width: Length, - ) -> Self { + pub fn new(bulk: &State>, test_particle: usize, n_grid: usize, width: Length) -> Self { let dft = &bulk.eos; // generate grid diff --git a/feos-dft/src/solvation/solvation_profile.rs b/feos-dft/src/solvation/solvation_profile.rs index 5e462d58e..7473960aa 100644 --- a/feos-dft/src/solvation/solvation_profile.rs +++ b/feos-dft/src/solvation/solvation_profile.rs @@ -12,8 +12,8 @@ use ndarray::Zip; /// Density profile and properties of a solute in a inhomogeneous bulk fluid. pub struct SolvationProfile { pub profile: DFTProfile, - pub grand_potential: Option>, - pub solvation_free_energy: Option>, + pub grand_potential: Option, + pub solvation_free_energy: Option, } impl Clone for SolvationProfile { @@ -57,8 +57,8 @@ impl SolvationProfile { coordinates: Length>, sigma_ss: Array1, epsilon_ss: Array1, - system_size: Option<[Length; 3]>, - cutoff_radius: Option>, + system_size: Option<[Length; 3]>, + cutoff_radius: Option, potential_cutoff: Option, ) -> EosResult { let dft: &F = &bulk.eos; @@ -121,7 +121,7 @@ fn external_potential_3d( coordinates: Array2, sigma_ss: Array1, epsilon_ss: Array1, - cutoff_radius: Option>, + cutoff_radius: Option, potential_cutoff: Option, reduced_temperature: f64, ) -> EosResult> { diff --git a/feos-dft/src/solver.rs b/feos-dft/src/solver.rs index ee5eb8c93..a0418d3d4 100644 --- a/feos-dft/src/solver.rs +++ b/feos-dft/src/solver.rs @@ -310,9 +310,10 @@ where } else { rho + alpha * delta_rho }; - let Ok((_, _, res2, _,_)) = - self.euler_lagrange_equation(&rho_new, rho_bulk, logarithm) else { - continue; + let Ok((_, _, res2, _, _)) = + self.euler_lagrange_equation(&rho_new, rho_bulk, logarithm) + else { + continue; }; if res2 > res0 { continue; @@ -324,9 +325,10 @@ where } else { rho + 0.5 * alpha * delta_rho }; - let Ok((_, _, res1, _,_)) = - self.euler_lagrange_equation(&rho_new, rho_bulk, logarithm) else { - continue; + let Ok((_, _, res1, _, _)) = + self.euler_lagrange_equation(&rho_new, rho_bulk, logarithm) + else { + continue; }; // estimate minimum diff --git a/src/association/mod.rs b/src/association/mod.rs index b7f72af0a..c3c74dff0 100644 --- a/src/association/mod.rs +++ b/src/association/mod.rs @@ -509,7 +509,9 @@ impl Association

{ let mut h: Array2 = Array::zeros([nassoc; 2]); // split arrays - let &[a, b] = delta_ab.shape() else { panic!("wrong shape!") }; + let &[a, b] = delta_ab.shape() else { + panic!("wrong shape!") + }; let c = delta_cc.shape()[0]; let (xa, xc) = x.view().split_at(Axis(0), a + b); let (xa, xb) = xa.split_at(Axis(0), a); diff --git a/src/estimator/binary_vle.rs b/src/estimator/binary_vle.rs index 0f4c28571..b98261cc9 100644 --- a/src/estimator/binary_vle.rs +++ b/src/estimator/binary_vle.rs @@ -106,7 +106,7 @@ pub struct BinaryVlePressure { target: Array1, temperature: Temperature>, pressure: Pressure>, - unit: Pressure, + unit: Pressure, molefracs: Array1, phase: Phase, } diff --git a/src/estimator/diffusion.rs b/src/estimator/diffusion.rs index 7246875ac..c47798a32 100644 --- a/src/estimator/diffusion.rs +++ b/src/estimator/diffusion.rs @@ -10,7 +10,7 @@ use typenum::P2; #[derive(Clone)] pub struct Diffusion { pub target: Array1, - unit: si::Diffusivity, + unit: si::Diffusivity, temperature: Temperature>, pressure: Pressure>, initial_density: Vec, diff --git a/src/estimator/estimator.rs b/src/estimator/estimator.rs index 2c604c687..0d02f38da 100644 --- a/src/estimator/estimator.rs +++ b/src/estimator/estimator.rs @@ -9,7 +9,6 @@ use std::fmt::Display; use std::fmt::Write; use std::sync::Arc; - /// A collection of [`DataSet`]s and weights that can be used to /// evaluate an equation of state versus experimental data. pub struct Estimator { @@ -107,4 +106,4 @@ impl Display for Estimator { } Ok(()) } -} \ No newline at end of file +} diff --git a/src/estimator/liquid_density.rs b/src/estimator/liquid_density.rs index 21cf0fd88..2282c86e8 100644 --- a/src/estimator/liquid_density.rs +++ b/src/estimator/liquid_density.rs @@ -11,7 +11,7 @@ pub struct LiquidDensity { /// mass density pub target: Array1, /// unit of mass density - unit: MassDensity, + unit: MassDensity, /// temperature temperature: Temperature>, /// pressure @@ -88,7 +88,7 @@ impl DataSet for LiquidDensity { pub struct EquilibriumLiquidDensity { pub target: Array1, /// unit of mass density - unit: MassDensity, + unit: MassDensity, /// temperature temperature: Temperature>, /// options for VLE solver diff --git a/src/estimator/thermal_conductivity.rs b/src/estimator/thermal_conductivity.rs index 9ac60e5cc..0686be6a1 100644 --- a/src/estimator/thermal_conductivity.rs +++ b/src/estimator/thermal_conductivity.rs @@ -9,7 +9,7 @@ use std::sync::Arc; #[derive(Clone)] pub struct ThermalConductivity { pub target: Array1, - unit: si::ThermalConductivity, + unit: si::ThermalConductivity, temperature: Temperature>, pressure: Pressure>, initial_density: Vec, diff --git a/src/estimator/vapor_pressure.rs b/src/estimator/vapor_pressure.rs index a0432a0cc..82d01b92f 100644 --- a/src/estimator/vapor_pressure.rs +++ b/src/estimator/vapor_pressure.rs @@ -8,9 +8,9 @@ use std::sync::Arc; #[derive(Clone)] pub struct VaporPressure { pub target: Array1, - unit: Pressure, + unit: Pressure, temperature: Temperature>, - max_temperature: Temperature, + max_temperature: Temperature, datapoints: usize, extrapolate: bool, solver_options: SolverOptions, @@ -29,7 +29,7 @@ impl VaporPressure { target: Pressure>, temperature: Temperature>, extrapolate: bool, - critical_temperature: Option>, + critical_temperature: Option, solver_options: Option, ) -> Self { let datapoints = target.len(); diff --git a/src/estimator/viscosity.rs b/src/estimator/viscosity.rs index 9c1e36e25..bf2a49b54 100644 --- a/src/estimator/viscosity.rs +++ b/src/estimator/viscosity.rs @@ -11,7 +11,7 @@ use std::sync::Arc; #[derive(Clone)] pub struct Viscosity { pub target: Array1, - unit: si::Viscosity, + unit: si::Viscosity, temperature: Temperature>, pressure: Pressure>, initial_density: Vec, diff --git a/src/pcsaft/eos/mod.rs b/src/pcsaft/eos/mod.rs index efe21b697..86af89575 100644 --- a/src/pcsaft/eos/mod.rs +++ b/src/pcsaft/eos/mod.rs @@ -143,12 +143,12 @@ fn omega22(t: f64) -> f64 { #[inline] fn chapman_enskog_thermal_conductivity( - temperature: Temperature, - molarweight: MolarWeight, + temperature: Temperature, + molarweight: MolarWeight, m: f64, sigma: f64, epsilon_k: f64, -) -> ThermalConductivity { +) -> ThermalConductivity { let t = temperature.to_reduced(); 0.083235 * (t * m / (molarweight / (GRAM / MOL)).into_value()).sqrt() / sigma.powi(2) @@ -161,10 +161,10 @@ fn chapman_enskog_thermal_conductivity( impl EntropyScaling for PcSaft { fn viscosity_reference( &self, - temperature: Temperature, - _: Volume, + temperature: Temperature, + _: Volume, moles: &Moles>, - ) -> EosResult> { + ) -> EosResult { let p = &self.parameters; let mw = &p.molarweight; let x = (moles / moles.sum()).into_value(); @@ -209,10 +209,10 @@ impl EntropyScaling for PcSaft { fn diffusion_reference( &self, - temperature: Temperature, - volume: Volume, + temperature: Temperature, + volume: Volume, moles: &Moles>, - ) -> EosResult> { + ) -> EosResult { if self.components() != 1 { return Err(EosError::IncompatibleComponents(self.components(), 1)); } @@ -251,10 +251,10 @@ impl EntropyScaling for PcSaft { // Equation 4 of DOI: 10.1021/acs.iecr.9b04289 fn thermal_conductivity_reference( &self, - temperature: Temperature, - volume: Volume, + temperature: Temperature, + volume: Volume, moles: &Moles>, - ) -> EosResult> { + ) -> EosResult { if self.components() != 1 { return Err(EosError::IncompatibleComponents(self.components(), 1)); } diff --git a/src/pcsaft/python.rs b/src/pcsaft/python.rs index 51081249e..a6c1434eb 100644 --- a/src/pcsaft/python.rs +++ b/src/pcsaft/python.rs @@ -13,7 +13,7 @@ use std::convert::{TryFrom, TryInto}; use std::sync::Arc; /// Pure-substance parameters for the PC-Saft equation of state. -/// +/// /// Parameters /// ---------- /// m : float diff --git a/src/saftvrqmie/eos/mod.rs b/src/saftvrqmie/eos/mod.rs index 672106207..ead65bbe2 100644 --- a/src/saftvrqmie/eos/mod.rs +++ b/src/saftvrqmie/eos/mod.rs @@ -141,12 +141,12 @@ fn omega22(t: f64) -> f64 { #[inline] fn chapman_enskog_thermal_conductivity( - temperature: Temperature, - molarweight: MolarWeight, + temperature: Temperature, + molarweight: MolarWeight, m: f64, sigma: f64, epsilon_k: f64, -) -> ThermalConductivity { +) -> ThermalConductivity { let t = temperature.to_reduced(); 0.083235 * (t * m / (molarweight / (GRAM / MOL)).into_value()).sqrt() / sigma.powi(2) @@ -159,10 +159,10 @@ fn chapman_enskog_thermal_conductivity( impl EntropyScaling for SaftVRQMie { fn viscosity_reference( &self, - temperature: Temperature, - _: Volume, + temperature: Temperature, + _: Volume, moles: &Moles>, - ) -> EosResult> { + ) -> EosResult { let p = &self.parameters; let mw = &p.molarweight; let x = (moles / moles.sum()).into_value(); @@ -209,10 +209,10 @@ impl EntropyScaling for SaftVRQMie { fn diffusion_reference( &self, - temperature: Temperature, - volume: Volume, + temperature: Temperature, + volume: Volume, moles: &Moles>, - ) -> EosResult> { + ) -> EosResult { if self.components() != 1 { return Err(EosError::IncompatibleComponents(self.components(), 1)); } @@ -251,10 +251,10 @@ impl EntropyScaling for SaftVRQMie { // Equation 4 of DOI: 10.1021/acs.iecr.9b04289 fn thermal_conductivity_reference( &self, - temperature: Temperature, - volume: Volume, + temperature: Temperature, + volume: Volume, moles: &Moles>, - ) -> EosResult> { + ) -> EosResult { if self.components() != 1 { return Err(EosError::IncompatibleComponents(self.components(), 1)); } diff --git a/src/saftvrqmie/parameters.rs b/src/saftvrqmie/parameters.rs index 0aba39c28..8bdaa02ed 100644 --- a/src/saftvrqmie/parameters.rs +++ b/src/saftvrqmie/parameters.rs @@ -352,10 +352,10 @@ impl SaftVRQMieParameters { /// - "hydrogen_neon_30K.table" for H-Ne interactions. pub fn lammps_tables( &self, - temperature: Temperature, + temperature: Temperature, n: usize, - r_min: Length, - r_max: Length, + r_min: Length, + r_max: Length, ) -> std::io::Result<()> { let t = temperature.to_reduced(); let rs = Array1::linspace(r_min.to_reduced(), r_max.to_reduced(), n); diff --git a/tests/pcsaft/state_creation_pure.rs b/tests/pcsaft/state_creation_pure.rs index c737635ff..976cc22c1 100644 --- a/tests/pcsaft/state_creation_pure.rs +++ b/tests/pcsaft/state_creation_pure.rs @@ -334,10 +334,10 @@ fn temperature_entropy_vapor() -> Result<(), Box> { fn assert_multiple_states( states: &[(&State, &str)], - pressure: Pressure, - enthalpy: MolarEnergy, - entropy: MolarEntropy, - density: Density, + pressure: Pressure, + enthalpy: MolarEnergy, + entropy: MolarEntropy, + density: Density, max_relative: f64, ) { for (s, name) in states {