From c59bf1c60106b77417fb42a1db9d909bdc2da000 Mon Sep 17 00:00:00 2001 From: Philipp Rehner Date: Tue, 11 Aug 2026 16:34:58 +0200 Subject: [PATCH] Update to num-dual v0.15 --- Cargo.toml | 4 +- crates/feos-core/src/ad/mod.rs | 7 +- .../src/ad/properties/boiling_temperature.rs | 2 +- .../ad/properties/bubble_point_pressure.rs | 2 +- .../src/ad/properties/dew_point_pressure.rs | 2 +- .../ad/properties/enthalpy_of_vaporization.rs | 2 +- .../properties/equilibrium_liquid_density.rs | 2 +- .../src/ad/properties/liquid_density.rs | 2 +- crates/feos-core/src/ad/properties/mod.rs | 2 +- .../residual_isobaric_heat_capacity.rs | 2 +- .../src/ad/properties/vapor_pressure.rs | 2 +- crates/feos-core/src/cubic.rs | 4 +- crates/feos-core/src/density_iteration.rs | 2 +- crates/feos-core/src/equation_of_state/mod.rs | 35 +++++----- .../src/equation_of_state/residual.rs | 34 +++++----- crates/feos-core/src/lib.rs | 2 +- .../src/phase_equilibria/bubble_dew.rs | 13 ++-- crates/feos-core/src/phase_equilibria/mod.rs | 13 ++-- .../src/phase_equilibria/px_flashes.rs | 24 +++---- .../src/phase_equilibria/tp_flash.rs | 4 +- .../src/phase_equilibria/vle_pure.rs | 8 ++- crates/feos-core/src/state/composition.rs | 25 +++---- crates/feos-core/src/state/critical_point.rs | 18 ++--- crates/feos-core/src/state/mod.rs | 18 ++--- crates/feos-core/src/state/properties.rs | 4 +- .../src/state/residual_properties.rs | 8 +-- crates/feos-derive/src/dft.rs | 2 +- .../src/functional_contribution.rs | 6 +- crates/feos-derive/src/ideal_gas.rs | 2 +- crates/feos-derive/src/residual.rs | 4 +- crates/feos-dft/src/adsorption/pore.rs | 13 ++-- crates/feos-dft/src/convolver/mod.rs | 16 ++--- .../src/convolver/periodic_convolver.rs | 4 +- crates/feos-dft/src/convolver/transform.rs | 19 +++--- crates/feos-dft/src/functional.rs | 17 +++-- .../feos-dft/src/functional_contribution.rs | 16 +++-- .../feos-dft/src/ideal_chain_contribution.rs | 4 +- crates/feos-dft/src/profile/mod.rs | 9 ++- crates/feos-dft/src/profile/properties.rs | 2 +- crates/feos-dft/src/weight_functions.rs | 8 +-- crates/feos/benches/dual_numbers.rs | 2 +- crates/feos/benches/dual_numbers_saftvrmie.rs | 4 +- crates/feos/src/association/dft.rs | 12 ++-- crates/feos/src/association/mod.rs | 14 ++-- crates/feos/src/epcsaft/eos/born.rs | 2 +- crates/feos/src/epcsaft/eos/dispersion.rs | 6 +- crates/feos/src/epcsaft/eos/hard_chain.rs | 2 +- crates/feos/src/epcsaft/eos/ionic.rs | 4 +- crates/feos/src/epcsaft/eos/mod.rs | 4 +- crates/feos/src/epcsaft/eos/permittivity.rs | 4 +- crates/feos/src/epcsaft/parameters.rs | 10 +-- crates/feos/src/gc_pcsaft/dft/dispersion.rs | 4 +- crates/feos/src/gc_pcsaft/dft/hard_chain.rs | 4 +- crates/feos/src/gc_pcsaft/dft/mod.rs | 12 ++-- crates/feos/src/gc_pcsaft/eos/ad.rs | 18 ++--- crates/feos/src/gc_pcsaft/eos/dispersion.rs | 2 +- crates/feos/src/gc_pcsaft/eos/hard_chain.rs | 2 +- crates/feos/src/gc_pcsaft/eos/mod.rs | 4 +- crates/feos/src/gc_pcsaft/eos/parameter.rs | 6 +- crates/feos/src/gc_pcsaft/eos/polar.rs | 6 +- crates/feos/src/hard_sphere/dft.rs | 10 +-- crates/feos/src/hard_sphere/mod.rs | 12 ++-- crates/feos/src/ideal_gas/dippr.rs | 12 ++-- crates/feos/src/ideal_gas/joback.rs | 23 ++++--- .../src/multiparameter/ideal_gas_function.rs | 2 +- crates/feos/src/multiparameter/mod.rs | 14 ++-- .../src/multiparameter/residual_function.rs | 2 +- crates/feos/src/pcsaft/dft/dispersion.rs | 8 +-- crates/feos/src/pcsaft/dft/hard_chain.rs | 4 +- crates/feos/src/pcsaft/dft/mod.rs | 4 +- crates/feos/src/pcsaft/dft/polar.rs | 14 ++-- .../src/pcsaft/dft/pure_saft_functional.rs | 14 ++-- crates/feos/src/pcsaft/eos/dispersion.rs | 2 +- crates/feos/src/pcsaft/eos/hard_chain.rs | 2 +- crates/feos/src/pcsaft/eos/mod.rs | 10 +-- crates/feos/src/pcsaft/eos/pcsaft_binary.rs | 28 ++++---- crates/feos/src/pcsaft/eos/pcsaft_pure.rs | 22 +++--- crates/feos/src/pcsaft/eos/polar.rs | 12 ++-- crates/feos/src/pets/dft/dispersion.rs | 8 +-- .../feos/src/pets/dft/pure_pets_functional.rs | 8 +-- crates/feos/src/pets/eos/dispersion.rs | 2 +- crates/feos/src/pets/eos/mod.rs | 8 +-- crates/feos/src/saftvrmie/eos/dispersion.rs | 14 ++-- crates/feos/src/saftvrmie/eos/mod.rs | 6 +- crates/feos/src/saftvrmie/parameters.rs | 12 ++-- crates/feos/src/saftvrqmie/dft/dispersion.rs | 8 +-- crates/feos/src/saftvrqmie/dft/mod.rs | 4 +- .../src/saftvrqmie/dft/non_additive_hs.rs | 6 +- crates/feos/src/saftvrqmie/eos/dispersion.rs | 34 +++++----- crates/feos/src/saftvrqmie/eos/hard_sphere.rs | 39 ++++++----- crates/feos/src/saftvrqmie/eos/mod.rs | 6 +- .../src/saftvrqmie/eos/non_additive_hs.rs | 4 +- .../eos/bh/attractive_perturbation.rs | 20 +++--- .../feos/src/uvtheory/eos/bh/hard_sphere.rs | 8 +-- crates/feos/src/uvtheory/eos/bh/mod.rs | 2 +- .../uvtheory/eos/bh/reference_perturbation.rs | 2 +- crates/feos/src/uvtheory/eos/mod.rs | 4 +- .../eos/wca/attractive_perturbation.rs | 18 ++--- .../eos/wca/attractive_perturbation_uvb3.rs | 20 +++--- .../feos/src/uvtheory/eos/wca/hard_sphere.rs | 16 ++--- crates/feos/src/uvtheory/eos/wca/mod.rs | 4 +- .../eos/wca/reference_perturbation.rs | 2 +- .../eos/wca/reference_perturbation_uvb3.rs | 2 +- crates/feos/src/uvtheory/parameters.rs | 8 +-- docs/rustguide/core/equation_of_state.rst | 6 +- docs/rustguide/core/state.rst | 4 +- py-feos/src/ad/mod.rs | 4 +- py-feos/src/user_defined.rs | 68 ++++++++----------- 108 files changed, 524 insertions(+), 503 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d18be3929..76f48e086 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,8 +22,8 @@ keywords = [ categories = ["science"] [workspace.dependencies] -quantity = "0.14" -num-dual = "0.14" +quantity = "0.15" +num-dual = "0.15" ndarray = "0.17" nalgebra = "0.35" thiserror = "2.0" diff --git a/crates/feos-core/src/ad/mod.rs b/crates/feos-core/src/ad/mod.rs index 1965207da..87d6a9b26 100644 --- a/crates/feos-core/src/ad/mod.rs +++ b/crates/feos-core/src/ad/mod.rs @@ -10,7 +10,7 @@ mod properties; pub use dataset::*; pub use properties::*; -pub(crate) type Gradient = DualSVec; +pub(crate) type Gradient = DualSVec; /// A model that can be evaluated with derivatives of its parameters. pub trait ParametersAD: Residual @@ -23,7 +23,7 @@ where /// defines the canonical parameter order. /// /// Set `differentiable` to `false` for fixed parameters. - fn build + Copy>( + fn build + Copy>( f: impl FnMut(&'static str, bool) -> D, ) -> Self::Lifted; @@ -66,8 +66,7 @@ where idx += 1; let mut d = Gradient::

::from(parameter_values[i]); if let Some(seed_idx) = derivative_names.iter().position(|&n| n == name) { - d.eps = - Derivative::<_, _, Const

, _>::derivative_generic(Const::

, U1, seed_idx); + d.eps = Derivative::<_, Const

, _>::derivative_generic(Const::

, U1, seed_idx); } d }) diff --git a/crates/feos-core/src/ad/properties/boiling_temperature.rs b/crates/feos-core/src/ad/properties/boiling_temperature.rs index c597fb30e..8a9b58821 100644 --- a/crates/feos-core/src/ad/properties/boiling_temperature.rs +++ b/crates/feos-core/src/ad/properties/boiling_temperature.rs @@ -22,7 +22,7 @@ where type Unit = _Temperature; const REFERENCE: Temperature = KELVIN; - fn evaluate, D: DualNum + Copy>( + fn evaluate, D: DualNum + Copy>( &self, eos: &E, ) -> FeosResult> { diff --git a/crates/feos-core/src/ad/properties/bubble_point_pressure.rs b/crates/feos-core/src/ad/properties/bubble_point_pressure.rs index 9e838b9f7..75b7260c6 100644 --- a/crates/feos-core/src/ad/properties/bubble_point_pressure.rs +++ b/crates/feos-core/src/ad/properties/bubble_point_pressure.rs @@ -28,7 +28,7 @@ where type Unit = _Pressure; const REFERENCE: Pressure = PASCAL; - fn evaluate, D: DualNum + Copy>( + fn evaluate, D: DualNum + Copy>( &self, eos: &E, ) -> FeosResult> diff --git a/crates/feos-core/src/ad/properties/dew_point_pressure.rs b/crates/feos-core/src/ad/properties/dew_point_pressure.rs index 4ce733484..9b4c813bb 100644 --- a/crates/feos-core/src/ad/properties/dew_point_pressure.rs +++ b/crates/feos-core/src/ad/properties/dew_point_pressure.rs @@ -27,7 +27,7 @@ where type Unit = _Pressure; const REFERENCE: Pressure = PASCAL; - fn evaluate, D: DualNum + Copy>( + fn evaluate, D: DualNum + Copy>( &self, eos: &E, ) -> FeosResult> diff --git a/crates/feos-core/src/ad/properties/enthalpy_of_vaporization.rs b/crates/feos-core/src/ad/properties/enthalpy_of_vaporization.rs index ee0d3d3aa..77b8bb1e9 100644 --- a/crates/feos-core/src/ad/properties/enthalpy_of_vaporization.rs +++ b/crates/feos-core/src/ad/properties/enthalpy_of_vaporization.rs @@ -21,7 +21,7 @@ where type Unit = _MolarEnergy; const REFERENCE: MolarEnergy = MolarEnergy::new(1.0); - fn evaluate, D: DualNum + Copy>( + fn evaluate, D: DualNum + Copy>( &self, eos: &E, ) -> FeosResult> { diff --git a/crates/feos-core/src/ad/properties/equilibrium_liquid_density.rs b/crates/feos-core/src/ad/properties/equilibrium_liquid_density.rs index 85ded0885..fab58a9a8 100644 --- a/crates/feos-core/src/ad/properties/equilibrium_liquid_density.rs +++ b/crates/feos-core/src/ad/properties/equilibrium_liquid_density.rs @@ -21,7 +21,7 @@ where type Unit = _Density; const REFERENCE: Density = Density::new(1000.0); - fn evaluate, D: DualNum + Copy>( + fn evaluate, D: DualNum + Copy>( &self, eos: &E, ) -> FeosResult> { diff --git a/crates/feos-core/src/ad/properties/liquid_density.rs b/crates/feos-core/src/ad/properties/liquid_density.rs index f8992c3fe..1483ab0c4 100644 --- a/crates/feos-core/src/ad/properties/liquid_density.rs +++ b/crates/feos-core/src/ad/properties/liquid_density.rs @@ -23,7 +23,7 @@ where type Unit = _Density; const REFERENCE: Density = Density::new(1000.0); - fn evaluate, D: DualNum + Copy>( + fn evaluate, D: DualNum + Copy>( &self, eos: &E, ) -> FeosResult> { diff --git a/crates/feos-core/src/ad/properties/mod.rs b/crates/feos-core/src/ad/properties/mod.rs index 660716e1d..4f2af32da 100644 --- a/crates/feos-core/src/ad/properties/mod.rs +++ b/crates/feos-core/src/ad/properties/mod.rs @@ -34,7 +34,7 @@ where const REFERENCE: Quantity; /// Evaluate the property for an arbitrary derivative. - fn evaluate, D: DualNum + Copy>( + fn evaluate, D: DualNum + Copy>( &self, eos: &E, ) -> FeosResult>; diff --git a/crates/feos-core/src/ad/properties/residual_isobaric_heat_capacity.rs b/crates/feos-core/src/ad/properties/residual_isobaric_heat_capacity.rs index b8f962757..2dffe6093 100644 --- a/crates/feos-core/src/ad/properties/residual_isobaric_heat_capacity.rs +++ b/crates/feos-core/src/ad/properties/residual_isobaric_heat_capacity.rs @@ -23,7 +23,7 @@ where type Unit = _MolarEntropy; const REFERENCE: MolarEntropy = MolarEntropy::new(1.0); - fn evaluate, D: DualNum + Copy>( + fn evaluate, D: DualNum + Copy>( &self, eos: &E, ) -> FeosResult> { diff --git a/crates/feos-core/src/ad/properties/vapor_pressure.rs b/crates/feos-core/src/ad/properties/vapor_pressure.rs index 8192d3ff0..27f6b1740 100644 --- a/crates/feos-core/src/ad/properties/vapor_pressure.rs +++ b/crates/feos-core/src/ad/properties/vapor_pressure.rs @@ -22,7 +22,7 @@ where type Unit = _Pressure; const REFERENCE: Pressure = PASCAL; - fn evaluate, D: DualNum + Copy>( + fn evaluate, D: DualNum + Copy>( &self, eos: &E, ) -> FeosResult> { diff --git a/crates/feos-core/src/cubic.rs b/crates/feos-core/src/cubic.rs index a12f615e5..c6b392e93 100644 --- a/crates/feos-core/src/cubic.rs +++ b/crates/feos-core/src/cubic.rs @@ -121,11 +121,11 @@ impl ResidualDyn for PengRobinson { self.tc.len() } - fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { + fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { D::from(0.9) / molefracs.dot(&self.b.map(D::from)) } - fn reduced_helmholtz_energy_density_contributions + Copy>( + fn reduced_helmholtz_energy_density_contributions + Copy>( &self, state: &StateHD, ) -> Vec<(&'static str, D)> { diff --git a/crates/feos-core/src/density_iteration.rs b/crates/feos-core/src/density_iteration.rs index e27ca0fba..eb9bd5cdb 100644 --- a/crates/feos-core/src/density_iteration.rs +++ b/crates/feos-core/src/density_iteration.rs @@ -6,7 +6,7 @@ use nalgebra::{DefaultAllocator, Dim, OVector}; use num_dual::{Dual, DualNum, first_derivative}; use quantity::{Density, Pressure, Temperature}; -pub fn density_iteration, N: Dim, D: DualNum + Copy>( +pub fn density_iteration, N: Dim, D: DualNum + Copy>( eos: &E, temperature: Temperature, pressure: Pressure, diff --git a/crates/feos-core/src/equation_of_state/mod.rs b/crates/feos-core/src/equation_of_state/mod.rs index 14e45c07a..4fbb1829f 100644 --- a/crates/feos-core/src/equation_of_state/mod.rs +++ b/crates/feos-core/src/equation_of_state/mod.rs @@ -53,11 +53,11 @@ impl ResidualDyn for EquationOfState, R> { self.residual.components() } - fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { + fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { self.residual.compute_max_density(molefracs) } - fn reduced_helmholtz_energy_density_contributions + Copy>( + fn reduced_helmholtz_energy_density_contributions + Copy>( &self, state: &StateHD, ) -> Vec<(&'static str, D)> { @@ -79,7 +79,7 @@ impl Subset for EquationOfState, R> { } } -impl, D>, D: DualNum + Copy, const N: usize> +impl, D>, D: DualNum + Copy, const N: usize> Residual, D> for EquationOfState<[I; N], R> { fn components(&self) -> usize { @@ -87,11 +87,12 @@ impl, D>, D: DualNum + Copy, const N: usize> } type Real = EquationOfState<[I; N], R::Real>; - type Lifted + Copy> = EquationOfState<[I; N], R::Lifted>; + type Lifted + Copy> = + EquationOfState<[I; N], R::Lifted>; fn re(&self) -> Self::Real { EquationOfState::new(self.ideal_gas.clone(), self.residual.re()) } - fn lift + Copy>(&self) -> Self::Lifted { + fn lift + Copy>(&self) -> Self::Lifted { EquationOfState::new(self.ideal_gas.clone(), self.residual.lift()) } @@ -118,7 +119,7 @@ pub trait IdealGas { /// Implementation of an ideal gas model in terms of the /// logarithm of the cubic thermal de Broglie wavelength /// in units ln(A³) for each component in the system. - fn ln_lambda3 + Copy>(&self, temperature: D) -> D; + fn ln_lambda3 + Copy>(&self, temperature: D) -> D; /// The name of the ideal gas model. fn ideal_gas_model(&self) -> &'static str; @@ -128,9 +129,9 @@ pub trait IdealGas { /// respect to parameters. pub trait IdealGasAD: Clone { type Real: IdealGasAD; - type Lifted + Copy>: IdealGasAD; + type Lifted + Copy>: IdealGasAD; fn re(&self) -> Self::Real; - fn lift + Copy>(&self) -> Self::Lifted; + fn lift + Copy>(&self) -> Self::Lifted; /// Implementation of an ideal gas model in terms of the /// logarithm of the cubic thermal de Broglie wavelength @@ -142,14 +143,14 @@ pub trait IdealGasAD: Clone { } /// A total Helmholtz energy model consisting of a [Residual] model and an [IdealGas] part. -pub trait Total + Copy = f64>: Residual +pub trait Total + Copy = f64>: Residual where DefaultAllocator: Allocator, { type RealTotal: Total; - type LiftedTotal + Copy>: Total; + type LiftedTotal + Copy>: Total; fn re_total(&self) -> Self::RealTotal; - fn lift_total + Copy>(&self) -> Self::LiftedTotal; + fn lift_total + Copy>(&self) -> Self::LiftedTotal; fn ideal_gas_model(&self) -> &'static str; @@ -199,15 +200,15 @@ impl< I: IdealGas + 'static, C: Deref, R>> + Clone, R: ResidualDyn + 'static, - D: DualNum + Copy, + D: DualNum + Copy, > Total for C { type RealTotal = Self; - type LiftedTotal + Copy> = Self; + type LiftedTotal + Copy> = Self; fn re_total(&self) -> Self::RealTotal { self.clone() } - fn lift_total + Copy>(&self) -> Self::LiftedTotal { + fn lift_total + Copy>(&self) -> Self::LiftedTotal { self.clone() } @@ -225,11 +226,11 @@ impl< } } -impl, R: Residual, D>, D: DualNum + Copy, const N: usize> +impl, R: Residual, D>, D: DualNum + Copy, const N: usize> Total, D> for EquationOfState<[I; N], R> { type RealTotal = EquationOfState<[I::Real; N], R::Real>; - type LiftedTotal + Copy> = + type LiftedTotal + Copy> = EquationOfState<[I::Lifted; N], R::Lifted>; fn re_total(&self) -> Self::RealTotal { EquationOfState::new( @@ -237,7 +238,7 @@ impl, R: Residual, D>, D: DualNum + Copy, const N self.residual.re(), ) } - fn lift_total + Copy>(&self) -> Self::LiftedTotal { + fn lift_total + Copy>(&self) -> Self::LiftedTotal { EquationOfState::new( self.ideal_gas.each_ref().map(|i| i.lift()), self.residual.lift(), diff --git a/crates/feos-core/src/equation_of_state/residual.rs b/crates/feos-core/src/equation_of_state/residual.rs index af5fc88f6..5ade6b1c6 100644 --- a/crates/feos-core/src/equation_of_state/residual.rs +++ b/crates/feos-core/src/equation_of_state/residual.rs @@ -15,15 +15,15 @@ type Quot = >::Output; /// Molar weight of all components. /// /// Enables calculation of (mass) specific properties. -pub trait Molarweight + Copy = f64> +pub trait Molarweight + Copy = f64> where DefaultAllocator: Allocator, { fn molar_weight(&self) -> MolarWeight>; } -impl, T: Molarweight, N: Dim, D: DualNum + Copy> Molarweight - for C +impl, T: Molarweight, N: Dim, D: DualNum + Copy> + Molarweight for C where DefaultAllocator: Allocator, { @@ -62,23 +62,25 @@ pub trait ResidualDyn { /// 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 compute_max_density + Copy>(&self, molefracs: &DVector) -> D; + fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D; /// Evaluate the reduced Helmholtz energy density of each individual contribution /// and return them together with a string representation of the contribution. - fn reduced_helmholtz_energy_density_contributions + Copy>( + fn reduced_helmholtz_energy_density_contributions + Copy>( &self, state: &StateHD, ) -> Vec<(&'static str, D)>; } -impl + Clone, T: ResidualDyn, D: DualNum + Copy> Residual for C { +impl + Clone, T: ResidualDyn, D: DualNum + Copy> + Residual for C +{ type Real = Self; - type Lifted + Copy> = Self; + type Lifted + Copy> = Self; fn re(&self) -> Self::Real { self.clone() } - fn lift + Copy>(&self) -> Self::Lifted { + fn lift + Copy>(&self) -> Self::Lifted { self.clone() } fn components(&self) -> usize { @@ -96,7 +98,7 @@ impl + Clone, T: ResidualDyn, D: DualNum + Copy> Resid } /// A residual Helmholtz energy model. -pub trait Residual + Copy = f64>: Clone +pub trait Residual + Copy = f64>: Clone where DefaultAllocator: Allocator, { @@ -114,13 +116,13 @@ where type Real: Residual; /// The residual model with the model parameters lifted to a higher dual number. - type Lifted + Copy>: Residual; + type Lifted + Copy>: Residual; /// Return the real part of the residual model. fn re(&self) -> Self::Real; /// Return the lifted residual model. - fn lift + Copy>(&self) -> Self::Lifted; + fn lift + Copy>(&self) -> Self::Lifted; /// Return the maximum density in Angstrom^-3. /// @@ -303,7 +305,7 @@ where molefracs: &OVector, ) -> (D, D, D, D, D) { let molar_volume = density.recip(); - let (a, da, d2a) = hessian::<_, _, _, U2, _>( + let (a, da, d2a) = hessian::<_, _, U2, _>( partial( |vt: SVector<_, 2>, x: &OVector<_, N>| { let [[v, t]] = vt.data.0; @@ -418,7 +420,7 @@ where } /// Reference values and residual entropy correlations for entropy scaling. -pub trait EntropyScaling + Copy = f64> +pub trait EntropyScaling + Copy = f64> where DefaultAllocator: Allocator, { @@ -445,7 +447,7 @@ where fn thermal_conductivity_correlation(&self, s_res: D, x: &OVector) -> D; } -impl, T: EntropyScaling, N: Dim, D: DualNum + Copy> +impl, T: EntropyScaling, N: Dim, D: DualNum + Copy> EntropyScaling for C where DefaultAllocator: Allocator, @@ -502,11 +504,11 @@ impl ResidualDyn for NoResidual { self.0 } - fn compute_max_density + Copy>(&self, _: &DVector) -> D { + fn compute_max_density + Copy>(&self, _: &DVector) -> D { D::one() } - fn reduced_helmholtz_energy_density_contributions + Copy>( + fn reduced_helmholtz_energy_density_contributions + Copy>( &self, _: &StateHD, ) -> Vec<(&'static str, D)> { diff --git a/crates/feos-core/src/lib.rs b/crates/feos-core/src/lib.rs index 156894648..5a117790f 100644 --- a/crates/feos-core/src/lib.rs +++ b/crates/feos-core/src/lib.rs @@ -221,7 +221,7 @@ mod tests { "NoIdealGas" } - fn ln_lambda3 + Copy>(&self, _: D) -> D { + fn ln_lambda3 + Copy>(&self, _: D) -> D { unreachable!() } } diff --git a/crates/feos-core/src/phase_equilibria/bubble_dew.rs b/crates/feos-core/src/phase_equilibria/bubble_dew.rs index 6d2c9333d..9033df5a2 100644 --- a/crates/feos-core/src/phase_equilibria/bubble_dew.rs +++ b/crates/feos-core/src/phase_equilibria/bubble_dew.rs @@ -23,7 +23,7 @@ const MAX_LNPSTEP: f64 = 0.1; const NEWTON_TOL: f64 = 1e-3; /// Trait that enables functions to be generic over their input unit. -pub trait TemperatureOrPressure + Copy = f64>: Copy { +pub trait TemperatureOrPressure + Copy = f64>: Copy { type Other: Copy; const IDENTIFIER: &'static str; @@ -46,7 +46,7 @@ pub trait TemperatureOrPressure + Copy = f64>: Copy { ) -> (Temperature>, Pressure>); } -impl + Copy> TemperatureOrPressure for Temperature { +impl + Copy> TemperatureOrPressure for Temperature { type Other = Pressure; const IDENTIFIER: &'static str = "temperature"; @@ -86,7 +86,7 @@ impl + Copy> TemperatureOrPressure for Temperature { // For some inexplicable reason this does not compile if the `Pressure` type is // used instead of the explicit unit. Maybe the type is too complicated for the // compiler? -impl + Copy> TemperatureOrPressure +impl + Copy> TemperatureOrPressure for Quantity> { type Other = Temperature; @@ -138,7 +138,8 @@ impl TemperatureOrPressureSpecification { } /// # Bubble and dew point calculations -impl, N: Gradients, D: DualNum + Copy> PhaseEquilibrium +impl, N: Gradients, D: DualNum + Copy> + PhaseEquilibrium where DefaultAllocator: Allocator + Allocator + Allocator, { @@ -399,7 +400,7 @@ where }); // calculate Newton step - let dx = LU::<_, _, Dyn>::new(jac)?.solve(&f); + let dx = LU::<_, Dyn>::new(jac)?.solve(&f); // apply Newton step for i in 0..n { @@ -475,7 +476,7 @@ where }); // calculate Newton step - let dx = LU::<_, _, Dyn>::new(jac)?.solve(&f); + let dx = LU::<_, Dyn>::new(jac)?.solve(&f); // apply Newton step for i in 0..n { diff --git a/crates/feos-core/src/phase_equilibria/mod.rs b/crates/feos-core/src/phase_equilibria/mod.rs index 5ed15a767..ca6fd42b2 100644 --- a/crates/feos-core/src/phase_equilibria/mod.rs +++ b/crates/feos-core/src/phase_equilibria/mod.rs @@ -46,7 +46,7 @@ pub use phase_diagram_pure::PhaseDiagram; /// + [Heteroazeotropes](#heteroazeotropes) /// + [Utility functions](#utility-functions) #[derive(Debug, Clone)] -pub struct PhaseEquilibrium + Copy = f64> +pub struct PhaseEquilibrium + Copy = f64> where DefaultAllocator: Allocator, { @@ -100,7 +100,7 @@ impl PhaseEquilibrium { } } -impl, N: Dim, D: DualNum + Copy> PhaseEquilibrium +impl, N: Dim, D: DualNum + Copy> PhaseEquilibrium where DefaultAllocator: Allocator, { @@ -131,7 +131,7 @@ impl PhaseEquilibrium { } } -impl, N: Dim, D: DualNum + Copy> PhaseEquilibrium +impl, N: Dim, D: DualNum + Copy> PhaseEquilibrium where DefaultAllocator: Allocator, { @@ -164,7 +164,7 @@ where } } -impl, N: Dim, D: DualNum + Copy> PhaseEquilibrium +impl, N: Dim, D: DualNum + Copy> PhaseEquilibrium where DefaultAllocator: Allocator, { @@ -177,7 +177,7 @@ where } } -impl, N: Gradients, const P: usize, D: DualNum + Copy> +impl, N: Gradients, const P: usize, D: DualNum + Copy> PhaseEquilibrium where DefaultAllocator: Allocator, @@ -187,8 +187,7 @@ where } } -impl, N: Gradients, const P: usize, D: DualNum + Copy> - PhaseEquilibrium +impl, N: Gradients, const P: usize, D: DualNum + Copy> PhaseEquilibrium where DefaultAllocator: Allocator, { diff --git a/crates/feos-core/src/phase_equilibria/px_flashes.rs b/crates/feos-core/src/phase_equilibria/px_flashes.rs index aadeffb76..5ee40351f 100644 --- a/crates/feos-core/src/phase_equilibria/px_flashes.rs +++ b/crates/feos-core/src/phase_equilibria/px_flashes.rs @@ -17,7 +17,7 @@ const TOL_PX: f64 = 1e-11; type PXVars = >::Output; type TPVars = >::Output; -impl, N: Gradients + DimAdd + DimAdd, D: DualNum + Copy> +impl, N: Gradients + DimAdd + DimAdd, D: DualNum + Copy> PhaseEquilibrium where DefaultAllocator: Allocator @@ -213,7 +213,7 @@ where } } -fn unpack_variables + Copy, N: Dim + DimAdd>( +fn unpack_variables + Copy, N: Dim + DimAdd>( molefracs: &OVector, variables: &OVector>, ) -> (D, D, D, D, OVector, OVector) @@ -229,7 +229,7 @@ where (t, beta, rho_l, rho_v, x, y) } -fn unpack_tp_variables + Copy, N: Dim + DimAdd>( +fn unpack_tp_variables + Copy, N: Dim + DimAdd>( molefracs: &OVector, variables: &OVector>, ) -> (D, D, D, OVector, OVector) @@ -247,7 +247,7 @@ where trait PXFlash: Sized + Copy { // potential function for which the flash solution is a saddle point. - fn state_function, N: Dim + DimAdd, D: DualNum + Copy>( + fn state_function, N: Dim + DimAdd, D: DualNum + Copy>( eos: &E, variables: OVector>, args: &(D, D, OVector), @@ -255,14 +255,14 @@ trait PXFlash: Sized + Copy { where DefaultAllocator: Allocator + Allocator>; - fn evaluate_property, N: Gradients, D: DualNum + Copy>( + fn evaluate_property, N: Gradients, D: DualNum + Copy>( vle: &PhaseEquilibrium, ) -> Quantity where DefaultAllocator: Allocator; // the potential function for a tp-flash specification (Q = A + V*p_spec) - fn tp_state_function, N: Dim + DimAdd, D: DualNum + Copy>( + fn tp_state_function, N: Dim + DimAdd, D: DualNum + Copy>( eos: &E, variables: OVector>, &(t, p, ref z): &(D, D, OVector), @@ -284,7 +284,7 @@ trait PXFlash: Sized + Copy { // Because the ps and ph flashes are saddle points rather then extrema, // the value of the potential can not be used as convergence criterion. #[expect(clippy::type_complexity)] - fn newton_step, N: Dim + DimAdd, D: DualNum + Copy>( + fn newton_step, N: Dim + DimAdd, D: DualNum + Copy>( eos: &E, variables: &OVector>, specifications: &(D, D, OVector), @@ -327,7 +327,7 @@ trait PXFlash: Sized + Copy { let rho_i_l = rho_l * x; let (hs, dhs) = first_derivative( partial( - |t: Dual<_, _>, args: &(_, OVector<_, _>)| { + |t: Dual<_>, args: &(_, OVector<_, _>)| { let &(p, ref z) = args; let args = (t, p, z.clone_owned()); @@ -403,7 +403,7 @@ trait PXFlash: Sized + Copy { impl PXFlash for SIUnit<-2, 2, 1, 0, 0, -1, 0> { // the potential function for a ph-flash specification (Q = (A + V*p_spec - H_spec) / T) - fn state_function, N: Dim + DimAdd, D: DualNum + Copy>( + fn state_function, N: Dim + DimAdd, D: DualNum + Copy>( eos: &E, variables: OVector>, &(p, h, ref z): &(D, D, OVector), @@ -421,7 +421,7 @@ impl PXFlash for SIUnit<-2, 2, 1, 0, 0, -1, 0> { potential(y, rho_v, t) * beta + potential(x, rho_l, t) * (-beta + 1.0) } - fn evaluate_property, N: Gradients, D: DualNum + Copy>( + fn evaluate_property, N: Gradients, D: DualNum + Copy>( vle: &PhaseEquilibrium, ) -> Quantity where @@ -433,7 +433,7 @@ impl PXFlash for SIUnit<-2, 2, 1, 0, 0, -1, 0> { impl PXFlash for SIUnit<-2, 2, 1, 0, -1, -1, 0> { // the potential function for a ps-flash specification (Q = A + T*S_spec + V*p_spec) - fn state_function, N: Dim + DimAdd, D: DualNum + Copy>( + fn state_function, N: Dim + DimAdd, D: DualNum + Copy>( eos: &E, variables: OVector>, &(p, s, ref z): &(D, D, OVector), @@ -454,7 +454,7 @@ impl PXFlash for SIUnit<-2, 2, 1, 0, -1, -1, 0> { potential(y, rho_v, t) * beta + potential(x, rho_l, t) * (-beta + 1.0) } - fn evaluate_property, N: Gradients, D: DualNum + Copy>( + fn evaluate_property, N: Gradients, D: DualNum + Copy>( vle: &PhaseEquilibrium, ) -> Quantity where diff --git a/crates/feos-core/src/phase_equilibria/tp_flash.rs b/crates/feos-core/src/phase_equilibria/tp_flash.rs index 88b30679e..761ae18e6 100644 --- a/crates/feos-core/src/phase_equilibria/tp_flash.rs +++ b/crates/feos-core/src/phase_equilibria/tp_flash.rs @@ -40,7 +40,7 @@ where } } -impl, D: DualNum + Copy> PhaseEquilibrium { +impl, D: DualNum + Copy> PhaseEquilibrium { /// Perform a Tp-flash calculation for a binary mixture. /// Compared to the version of the algorithm for a generic /// number of components ([tp_flash](PhaseEquilibrium::tp_flash)), @@ -79,7 +79,7 @@ impl, D: DualNum + Copy> PhaseEquilibrium { let [[v_l, v_v, x, y]] = variables.data.0; let beta = (z - x) / (y - x); let eos = eos.lift(); - let molar_gibbs_energy = |x: Dual2Vec<_, _, _>, v| { + let molar_gibbs_energy = |x: Dual2Vec<_, _>, v| { let molefracs = vector![x, -x + 1.0]; let a_res = eos.residual_helmholtz_energy(t, v, &molefracs); let a_ig = (x * (x / v).ln() - (x - 1.0) * ((-x + 1.0) / v).ln() - 1.0) * t; diff --git a/crates/feos-core/src/phase_equilibria/vle_pure.rs b/crates/feos-core/src/phase_equilibria/vle_pure.rs index f58fc6e21..97119283e 100644 --- a/crates/feos-core/src/phase_equilibria/vle_pure.rs +++ b/crates/feos-core/src/phase_equilibria/vle_pure.rs @@ -14,7 +14,8 @@ const MAX_ITER_PURE: usize = 50; const TOL_PURE: f64 = 1e-12; /// # Pure component phase equilibria -impl, N: Gradients, D: DualNum + Copy> PhaseEquilibrium +impl, N: Gradients, D: DualNum + Copy> + PhaseEquilibrium where DefaultAllocator: Allocator + Allocator + Allocator, { @@ -238,7 +239,8 @@ where Ok((p, [rho_v, rho_l])) } -impl, N: Gradients, D: DualNum + Copy> PhaseEquilibrium +impl, N: Gradients, D: DualNum + Copy> + PhaseEquilibrium where DefaultAllocator: Allocator + Allocator + Allocator, { @@ -447,7 +449,7 @@ where // both phases have the same temperature for _ in 0..20 { let h_s = |t, v| { - let (a_res, da_res) = gradient::<_, _, _, U2, _>( + let (a_res, da_res) = gradient::<_, _, U2, _>( partial( |t_v: SVector<_, _>, x| { let [[t, v]] = t_v.data.0; diff --git a/crates/feos-core/src/state/composition.rs b/crates/feos-core/src/state/composition.rs index 973af8ffb..7040a1314 100644 --- a/crates/feos-core/src/state/composition.rs +++ b/crates/feos-core/src/state/composition.rs @@ -21,7 +21,7 @@ use quantity::Moles; /// |N|`&OVector`|-|`Dyn` only| /// |N|`Moles>`|✅| /// |N|`&Moles>`|✅| -pub trait Composition + Copy, N: Dim> +pub trait Composition + Copy, N: Dim> where DefaultAllocator: Allocator, { @@ -34,7 +34,7 @@ where } // trivial implementations -impl + Copy, N: Dim> Composition for (OVector, Moles) +impl + Copy, N: Dim> Composition for (OVector, Moles) where DefaultAllocator: Allocator, { @@ -46,7 +46,8 @@ where } } -impl + Copy, N: Dim> Composition for (OVector, Option>) +impl + Copy, N: Dim> Composition + for (OVector, Option>) where DefaultAllocator: Allocator, { @@ -59,7 +60,7 @@ where } // a pure component needs no specification -impl + Copy> Composition for () { +impl + Copy> Composition for () { fn into_molefracs>( self, _: &E, @@ -67,7 +68,7 @@ impl + Copy> Composition for () { Ok(((vector![D::one()]), None)) } } -impl + Copy> Composition for () { +impl + Copy> Composition for () { fn into_molefracs>( self, eos: &E, @@ -84,7 +85,7 @@ impl + Copy> Composition for () { } // a binary mixture can be specified by a scalar (x1) -impl + Copy> Composition for D { +impl + Copy> Composition for D { fn into_molefracs>( self, _: &E, @@ -111,7 +112,7 @@ impl Composition for f64 { } // a pure component can be specified by the total mole number -impl + Copy> Composition for Moles { +impl + Copy> Composition for Moles { fn into_molefracs>( self, _: &E, @@ -120,7 +121,7 @@ impl + Copy> Composition for Moles { } } -impl + Copy> Composition for Moles { +impl + Copy> Composition for Moles { fn into_molefracs>( self, eos: &E, @@ -140,7 +141,7 @@ impl + Copy> Composition for Moles { // // for a dynamic number of components, it is also possible to specify only the // N-1 first components -impl + Copy, N: Dim> Composition for OVector +impl + Copy, N: Dim> Composition for OVector where DefaultAllocator: Allocator, { @@ -152,7 +153,7 @@ where } } -impl + Copy, N: Dim> Composition for &OVector +impl + Copy, N: Dim> Composition for &OVector where DefaultAllocator: Allocator, { @@ -181,7 +182,7 @@ where } // the mixture can be specified by its moles -impl + Copy, N: Dim> Composition for Moles> +impl + Copy, N: Dim> Composition for Moles> where DefaultAllocator: Allocator, { @@ -193,7 +194,7 @@ where } } -impl + Copy, N: Dim> Composition for &Moles> +impl + Copy, N: Dim> Composition for &Moles> where DefaultAllocator: Allocator, { diff --git a/crates/feos-core/src/state/critical_point.rs b/crates/feos-core/src/state/critical_point.rs index 4de9f9562..5dfe14a26 100644 --- a/crates/feos-core/src/state/critical_point.rs +++ b/crates/feos-core/src/state/critical_point.rs @@ -44,7 +44,7 @@ impl State { } } -impl, N: Gradients, D: DualNum + Copy> State +impl, N: Gradients, D: DualNum + Copy> State where DefaultAllocator: Allocator + Allocator + Allocator, { @@ -91,7 +91,7 @@ where initial_density, options, )?; - let trho = implicit_derivative_vec::<_, _, _, _, U3>( + let trho = implicit_derivative_vec::<_, _, _, U3>( |x, &p| { let t = x[0]; let rho = [x[1], x[2]]; @@ -184,7 +184,7 @@ where for i in 1..=max_iter { // calculate residuals and derivatives w.r.t. temperature and density - let (res, jac) = jacobian::<_, _, _, U2, U2, _>( + let (res, jac) = jacobian::<_, _, U2, U2, _>( |x: SVector, 2>| { SVector::from(criticality_conditions( &eos.lift(), @@ -269,7 +269,7 @@ where for i in 1..=max_iter { // calculate residuals and derivatives w.r.t. partial densities - let (res, jac) = jacobian::<_, _, _, U2, U2, _>( + let (res, jac) = jacobian::<_, _, U2, U2, _>( |rho: SVector, 2>| { let density = rho.sum(); let x = rho / density; @@ -360,7 +360,7 @@ where let p = DualSVec::from_re(p); criticality_conditions_p(&eos.lift(), p, t, partial_density) }; - let (res, jac) = jacobian::<_, _, _, U3, U3, _>(res, &SVector::from([t, rho[0], rho[1]])); + let (res, jac) = jacobian::<_, _, U3, U3, _>(res, &SVector::from([t, rho[0], rho[1]])); // calculate Newton step let delta = jac.lu().solve(&res); @@ -507,7 +507,7 @@ where } } -fn criticality_conditions, N: Gradients, D: DualNum + Copy>( +fn criticality_conditions, N: Gradients, D: DualNum + Copy>( eos: &E, temperature: D, density: D, @@ -548,7 +548,7 @@ where [l, c2] } -fn criticality_conditions_p, N: Gradients, D: DualNum + Copy>( +fn criticality_conditions_p, N: Gradients, D: DualNum + Copy>( eos: &E, pressure: D, temperature: D, @@ -575,7 +575,7 @@ where SVector::from([c1, c2, -p_calc + pressure]) } -fn stability_condition, N: Gradients, D: DualNum + Copy>( +fn stability_condition, N: Gradients, D: DualNum + Copy>( eos: &E, temperature: D, density: D, @@ -598,7 +598,7 @@ where l } -fn dmu_dn, N: Gradients, D: DualNum + Copy>( +fn dmu_dn, N: Gradients, D: DualNum + Copy>( eos: &E, temperature: D, molar_volume: D, diff --git a/crates/feos-core/src/state/mod.rs b/crates/feos-core/src/state/mod.rs index daa7a7ff4..94ea3c6e9 100644 --- a/crates/feos-core/src/state/mod.rs +++ b/crates/feos-core/src/state/mod.rs @@ -64,7 +64,7 @@ impl DensityInitialization { /// Properties are stored as generalized (hyper) dual numbers which allows /// for automatic differentiation. #[derive(Clone, Debug)] -pub struct StateHD + Copy, N: Dim = Dyn> +pub struct StateHD + Copy, N: Dim = Dyn> where DefaultAllocator: Allocator, { @@ -76,7 +76,7 @@ where pub partial_density: OVector, } -impl + Copy> StateHD +impl + Copy> StateHD where DefaultAllocator: Allocator, { @@ -137,7 +137,7 @@ where /// + [Stability analysis](#stability-analysis) /// + [Flash calculations](#flash-calculations) #[derive(Debug, Clone)] -pub struct State + Copy = f64> +pub struct State + Copy = f64> where DefaultAllocator: Allocator, { @@ -157,7 +157,7 @@ where cache: Cache, } -impl + Copy> State +impl + Copy> State where DefaultAllocator: Allocator, { @@ -192,7 +192,7 @@ where } } -impl, N: Dim, D: DualNum + Copy> fmt::Display for State +impl, N: Dim, D: DualNum + Copy> fmt::Display for State where DefaultAllocator: Allocator, { @@ -216,7 +216,7 @@ where } } -impl, N: Dim, D: DualNum + Copy> State +impl, N: Dim, D: DualNum + Copy> State where DefaultAllocator: Allocator, { @@ -403,7 +403,7 @@ where } } -impl, N: Gradients, D: DualNum + Copy> State +impl, N: Gradients, D: DualNum + Copy> State where DefaultAllocator: Allocator, { @@ -600,7 +600,7 @@ fn is_close( (x - y).abs() <= atol + rtol * y.abs() } -fn newton, N: Dim, D: DualNum + Copy, F, X: Copy, Y>( +fn newton, N: Dim, D: DualNum + Copy, F, X: Copy, Y>( mut x0: Quantity, mut f: F, atol: Quantity, @@ -644,7 +644,7 @@ where /// /// There is no validation of the physical state, e.g. /// if resulting densities are below maximum packing fraction. -fn validate>( +fn validate>( temperature: Temperature, density: Density, molefracs: &OVector, diff --git a/crates/feos-core/src/state/properties.rs b/crates/feos-core/src/state/properties.rs index 132bad936..948d77dc0 100644 --- a/crates/feos-core/src/state/properties.rs +++ b/crates/feos-core/src/state/properties.rs @@ -10,7 +10,7 @@ use std::ops::{Div, Neg}; type InvP = Quantity::Output>; type InvT = Quantity::Output>; -impl, N: Gradients, D: DualNum + Copy> State +impl, N: Gradients, D: DualNum + Copy> State where DefaultAllocator: Allocator, { @@ -269,7 +269,7 @@ where } } -impl + Molarweight, N: Gradients, D: DualNum + Copy> State +impl + Molarweight, N: Gradients, D: DualNum + Copy> State where DefaultAllocator: Allocator, { diff --git a/crates/feos-core/src/state/residual_properties.rs b/crates/feos-core/src/state/residual_properties.rs index 184f1aa53..317961a3a 100644 --- a/crates/feos-core/src/state/residual_properties.rs +++ b/crates/feos-core/src/state/residual_properties.rs @@ -12,7 +12,7 @@ type InvP = Quantity::Output>; type POverT = Quantity>::Output>; /// # State properties -impl, N: Gradients, D: DualNum + Copy> State +impl, N: Gradients, D: DualNum + Copy> State where DefaultAllocator: Allocator, { @@ -480,7 +480,7 @@ impl State { } } -impl, N: Gradients, D: DualNum + Copy> State +impl, N: Gradients, D: DualNum + Copy> State where DefaultAllocator: Allocator, { @@ -585,7 +585,7 @@ where } } -impl + Molarweight, N: Gradients, D: DualNum + Copy> State +impl + Molarweight, N: Gradients, D: DualNum + Copy> State where DefaultAllocator: Allocator, { @@ -628,7 +628,7 @@ where /// /// These properties are available for equations of state /// that implement the [EntropyScaling] trait. -impl + EntropyScaling, N: Gradients, D: DualNum + Copy> State +impl + EntropyScaling, N: Gradients, D: DualNum + Copy> State where DefaultAllocator: Allocator, { diff --git a/crates/feos-derive/src/dft.rs b/crates/feos-derive/src/dft.rs index e5dd7a343..185d2f7a1 100644 --- a/crates/feos-derive/src/dft.rs +++ b/crates/feos-derive/src/dft.rs @@ -67,7 +67,7 @@ pub(crate) fn impl_helmholtz_energy_functional( #(#contributions,)* } } - fn bond_lengths + Copy>(&self, temperature: N) -> petgraph::graph::UnGraph<(), N> { + fn bond_lengths + Copy>(&self, temperature: N) -> petgraph::graph::UnGraph<(), N> { match self { #(#bond_lengths,)* _ => petgraph::Graph::with_capacity(0, 0), diff --git a/crates/feos-derive/src/functional_contribution.rs b/crates/feos-derive/src/functional_contribution.rs index 44b8c957a..19519c0ce 100644 --- a/crates/feos-derive/src/functional_contribution.rs +++ b/crates/feos-derive/src/functional_contribution.rs @@ -56,17 +56,17 @@ fn impl_functional_contribution( #(#name,)* } } - fn weight_functions + Copy>(&self, temperature: N) -> feos_dft::WeightFunctionInfo { + fn weight_functions + Copy>(&self, temperature: N) -> feos_dft::WeightFunctionInfo { match self { #(#weight_functions,)* } } - fn weight_functions_pdgt + Copy>(&self, temperature: N) -> feos_dft::WeightFunctionInfo { + fn weight_functions_pdgt + Copy>(&self, temperature: N) -> feos_dft::WeightFunctionInfo { match self { #(#weight_functions_pdgt,)* } } - fn helmholtz_energy_density + Copy>( + fn helmholtz_energy_density + Copy>( &self, temperature: N, weighted_densities: ndarray::ArrayView2, diff --git a/crates/feos-derive/src/ideal_gas.rs b/crates/feos-derive/src/ideal_gas.rs index f9b5eb671..a1058b907 100644 --- a/crates/feos-derive/src/ideal_gas.rs +++ b/crates/feos-derive/src/ideal_gas.rs @@ -42,7 +42,7 @@ fn impl_ideal_gas( }); quote! { impl IdealGas for IdealGasModel { - fn ln_lambda3 + Copy>(&self, temperature: D) -> D { + fn ln_lambda3 + Copy>(&self, temperature: D) -> D { match self { #(#ln_lambda3,)* } diff --git a/crates/feos-derive/src/residual.rs b/crates/feos-derive/src/residual.rs index df3f5367f..1fab1e4bb 100644 --- a/crates/feos-derive/src/residual.rs +++ b/crates/feos-derive/src/residual.rs @@ -56,12 +56,12 @@ fn impl_residual( #(#components,)* } } - fn compute_max_density + Copy>(&self, moles: &DVector) -> D { + fn compute_max_density + Copy>(&self, moles: &DVector) -> D { match self { #(#compute_max_density,)* } } - fn reduced_helmholtz_energy_density_contributions + Copy>(&self, state: &StateHD) -> Vec<(&'static str, D)> { + fn reduced_helmholtz_energy_density_contributions + Copy>(&self, state: &StateHD) -> Vec<(&'static str, D)> { match self { #(#reduced_helmholtz_energy_density_contributions,)* } diff --git a/crates/feos-dft/src/adsorption/pore.rs b/crates/feos-dft/src/adsorption/pore.rs index b59474085..fc3cf93be 100644 --- a/crates/feos-dft/src/adsorption/pore.rs +++ b/crates/feos-dft/src/adsorption/pore.rs @@ -184,7 +184,10 @@ where .dot(&Dimensionless::new(self.profile.bulk.molefracs.clone()))) } - fn _henry_coefficients + Copy + DctNum>(&self, temperature: N) -> DVector { + fn _henry_coefficients + Copy + DctNum>( + &self, + temperature: N, + ) -> DVector { if self.profile.bulk.eos.m().iter().any(|&m| m != 1.0) { panic!( "Henry coefficients can only be calculated for spherical and heterosegmented molecules!" @@ -302,11 +305,11 @@ impl ResidualDyn for Helium { fn components(&self) -> usize { 1 } - fn compute_max_density + Copy>(&self, _: &DVector) -> D { + fn compute_max_density + Copy>(&self, _: &DVector) -> D { D::from(1.0) } - fn reduced_helmholtz_energy_density_contributions + Copy>( + fn reduced_helmholtz_energy_density_contributions + Copy>( &self, state: &StateHD, ) -> Vec<(&'static str, D)> { @@ -342,11 +345,11 @@ impl FluidParameters for &Helium { struct HeliumContribution; impl FunctionalContribution for HeliumContribution { - fn weight_functions + Copy>(&self, _: N) -> WeightFunctionInfo { + fn weight_functions + Copy>(&self, _: N) -> WeightFunctionInfo { unreachable!() } - fn helmholtz_energy_density + Copy>( + fn helmholtz_energy_density + Copy>( &self, _: N, _: ArrayView2, diff --git a/crates/feos-dft/src/convolver/mod.rs b/crates/feos-dft/src/convolver/mod.rs index edca1f7e4..c047bcd0e 100644 --- a/crates/feos-dft/src/convolver/mod.rs +++ b/crates/feos-dft/src/convolver/mod.rs @@ -40,7 +40,7 @@ pub(crate) struct BulkConvolver { weight_constants: Vec>, } -impl + Copy + Send + Sync> BulkConvolver { +impl + Copy + Send + Sync> BulkConvolver { #[expect(clippy::new_ret_no_self)] pub(crate) fn new(weight_functions: Vec>) -> Arc> { let weight_constants = weight_functions @@ -51,7 +51,7 @@ impl + Copy + Send + Sync> BulkConvolver { } } -impl + Copy + Send + Sync> Convolver for BulkConvolver +impl + Copy + Send + Sync> Convolver for BulkConvolver where Array2: Dot, Output = Array1>, { @@ -127,7 +127,7 @@ pub struct ConvolverFFT { impl ConvolverFFT where - T: DctNum + DualNum, + T: DctNum + DualNum, D::Larger: Dimension, D::Smaller: Dimension, ::Larger: Dimension, @@ -159,7 +159,7 @@ where impl ConvolverFFT where - T: DctNum + DualNum, + T: DctNum + DualNum, D::Larger: Dimension, ::Larger: Dimension, { @@ -278,7 +278,7 @@ where impl ConvolverFFT where - T: DctNum + DualNum, + T: DctNum + DualNum, D::Larger: Dimension, ::Larger: Dimension, { @@ -370,7 +370,7 @@ where impl Convolver for ConvolverFFT where - T: DctNum + DualNum, + T: DctNum + DualNum, D::Larger: Dimension, ::Larger: Dimension, { @@ -555,7 +555,7 @@ struct CurvilinearConvolver { impl CurvilinearConvolver where - T: DctNum + DualNum, + T: DctNum + DualNum, D::Larger: Dimension, D::Smaller: Dimension, ::Larger: Dimension, @@ -576,7 +576,7 @@ where impl Convolver for CurvilinearConvolver where - T: DctNum + DualNum, + T: DctNum + DualNum, D::Smaller: Dimension, D::Larger: Dimension, { diff --git a/crates/feos-dft/src/convolver/periodic_convolver.rs b/crates/feos-dft/src/convolver/periodic_convolver.rs index bd594e451..dfb12ff06 100644 --- a/crates/feos-dft/src/convolver/periodic_convolver.rs +++ b/crates/feos-dft/src/convolver/periodic_convolver.rs @@ -26,7 +26,7 @@ pub struct PeriodicConvolver { impl PeriodicConvolver where - T: FftNum + DualNum, + T: FftNum + DualNum, D::Larger: Dimension, ::Larger: Dimension, { @@ -223,7 +223,7 @@ impl PeriodicConvolver { impl Convolver for PeriodicConvolver where - T: FftNum + DualNum, + T: FftNum + DualNum, D::Larger: Dimension, ::Larger: Dimension, { diff --git a/crates/feos-dft/src/convolver/transform.rs b/crates/feos-dft/src/convolver/transform.rs index abe4549e3..30e736d0a 100644 --- a/crates/feos-dft/src/convolver/transform.rs +++ b/crates/feos-dft/src/convolver/transform.rs @@ -24,7 +24,7 @@ impl SinCosTransform { } } -pub(super) trait FourierTransform>: Send + Sync { +pub(super) trait FourierTransform>: Send + Sync { fn forward_transform(&self, f_r: ArrayView1, f_k: ArrayViewMut1, scalar: bool); fn back_transform(&self, f_k: ArrayViewMut1, f_r: ArrayViewMut1, scalar: bool); @@ -34,7 +34,7 @@ pub(super) struct CartesianTransform { dct: Arc>, } -impl + DctNum> CartesianTransform { +impl + DctNum> CartesianTransform { #[expect(clippy::new_ret_no_self)] pub(super) fn new(axis: &Axis) -> (Box>, Array1) { let (s, k) = Self::init(axis); @@ -104,7 +104,7 @@ impl + DctNum> CartesianTransform { } } -impl + DctNum> FourierTransform for CartesianTransform { +impl + DctNum> FourierTransform for CartesianTransform { fn forward_transform(&self, f_r: ArrayView1, mut f_k: ArrayViewMut1, scalar: bool) { if scalar { f_k.slice_mut(s![..-1]).assign(&f_r); @@ -130,7 +130,7 @@ pub(super) struct SphericalTransform { dct: Arc>, } -impl + DctNum> SphericalTransform { +impl + DctNum> SphericalTransform { #[expect(clippy::new_ret_no_self)] pub(super) fn new(axis: &Axis) -> (Box>, Array1) { let points = axis.grid.len(); @@ -189,7 +189,7 @@ impl + DctNum> SphericalTransform { } } -impl + DctNum> FourierTransform for SphericalTransform { +impl + DctNum> FourierTransform for SphericalTransform { fn forward_transform(&self, f_r: ArrayView1, mut f_k: ArrayViewMut1, scalar: bool) { if scalar { self.sine_transform(&f_r * &self.r_grid, f_k.view_mut(), false); @@ -231,7 +231,7 @@ pub(super) struct PolarTransform { l: f64, } -impl + DctNum> PolarTransform { +impl + DctNum> PolarTransform { #[expect(clippy::new_ret_no_self)] pub(super) fn new(axis: &Axis) -> (Box>, Array1) { let points = axis.grid.len(); @@ -318,7 +318,7 @@ impl + DctNum> PolarTransform { } } -impl + DctNum> FourierTransform for PolarTransform { +impl + DctNum> FourierTransform for PolarTransform { fn forward_transform(&self, f_r: ArrayView1, f_k: ArrayViewMut1, scalar: bool) { self.transform(f_r, f_k, scalar, &self.r_grid, &self.k_grid, self.l); } @@ -339,12 +339,13 @@ pub(super) struct NoTransform(); impl NoTransform { #[expect(clippy::new_ret_no_self)] - pub(super) fn new>() -> (Box>, Array1) { + pub(super) fn new>() -> (Box>, Array1) + { (Box::new(Self()), arr1(&[0.0])) } } -impl> FourierTransform for NoTransform { +impl> FourierTransform for NoTransform { fn forward_transform(&self, f: ArrayView1, mut f_k: ArrayViewMut1, _: bool) { f_k.assign(&f); } diff --git a/crates/feos-dft/src/functional.rs b/crates/feos-dft/src/functional.rs index 8bad99d4c..f584f2110 100644 --- a/crates/feos-dft/src/functional.rs +++ b/crates/feos-dft/src/functional.rs @@ -28,7 +28,7 @@ impl HelmholtzEnergyFunctionalDyn self.residual.molecule_shape() } - fn bond_lengths + Copy>(&self, temperature: N) -> UnGraph<(), N> { + fn bond_lengths + Copy>(&self, temperature: N) -> UnGraph<(), N> { self.residual.bond_lengths(temperature) } } @@ -58,7 +58,7 @@ pub trait HelmholtzEnergyFunctionalDyn: ResidualDyn { fn molecule_shape(&self) -> MoleculeShape<'_>; /// Overwrite this, if the functional consists of heterosegmented chains. - fn bond_lengths + Copy>(&self, _temperature: N) -> UnGraph<(), N> { + fn bond_lengths + Copy>(&self, _temperature: N) -> UnGraph<(), N> { Graph::with_capacity(0, 0) } } @@ -76,7 +76,7 @@ pub trait HelmholtzEnergyFunctional: Residual { fn molecule_shape(&self) -> MoleculeShape<'_>; /// Overwrite this, if the functional consists of heterosegmented chains. - fn bond_lengths + Copy>(&self, _temperature: N) -> UnGraph<(), N> { + fn bond_lengths + Copy>(&self, _temperature: N) -> UnGraph<(), N> { Graph::with_capacity(0, 0) } @@ -112,7 +112,7 @@ pub trait HelmholtzEnergyFunctional: Residual { /// Calculate the (residual) intrinsic functional derivative $\frac{\delta\mathcal{\beta F}}{\delta\rho_i(\mathbf{r})}$. #[expect(clippy::type_complexity)] - fn functional_derivative + Copy>( + fn functional_derivative + Copy>( &self, temperature: N, density: &Array, @@ -147,7 +147,7 @@ pub trait HelmholtzEnergyFunctional: Residual { } /// Calculate the bond integrals $I_{\alpha\alpha'}(\mathbf{r})$ - fn bond_integrals + Copy>( + fn bond_integrals + Copy>( &self, temperature: N, exponential: &Array, @@ -228,7 +228,10 @@ pub trait HelmholtzEnergyFunctional: Residual { i } - fn evaluate_bulk + Copy>(&self, state: &StateHD) -> Vec<(&'static str, D)> { + fn evaluate_bulk + Copy>( + &self, + state: &StateHD, + ) -> Vec<(&'static str, D)> { let mut res: Vec<_> = self .contributions() .map(|c| (c.name(), c.bulk_helmholtz_energy_density(state))) @@ -258,7 +261,7 @@ impl + Clone, F: HelmholtzEnergyFunctionalDyn + ResidualDyn F::molecule_shape(self.deref()) } - fn bond_lengths + Copy>(&self, temperature: N) -> UnGraph<(), N> { + fn bond_lengths + Copy>(&self, temperature: N) -> UnGraph<(), N> { F::bond_lengths(self.deref(), temperature) } } diff --git a/crates/feos-dft/src/functional_contribution.rs b/crates/feos-dft/src/functional_contribution.rs index 874df0ac1..ff9e6f9a6 100644 --- a/crates/feos-dft/src/functional_contribution.rs +++ b/crates/feos-dft/src/functional_contribution.rs @@ -11,10 +11,13 @@ pub trait FunctionalContribution: Sync + Send { fn name(&self) -> &'static str; /// Return the weight functions required in this contribution. - fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo; + fn weight_functions + Copy>( + &self, + temperature: N, + ) -> WeightFunctionInfo; /// Overwrite this if the weight functions in pDGT are different than for DFT. - fn weight_functions_pdgt + Copy>( + fn weight_functions_pdgt + Copy>( &self, temperature: N, ) -> WeightFunctionInfo { @@ -22,13 +25,16 @@ pub trait FunctionalContribution: Sync + Send { } /// Return the Helmholtz energy density for the given temperature and weighted densities. - fn helmholtz_energy_density + Copy>( + fn helmholtz_energy_density + Copy>( &self, temperature: N, weighted_densities: ArrayView2, ) -> FeosResult>; - fn bulk_helmholtz_energy_density + Copy>(&self, state: &StateHD) -> N { + fn bulk_helmholtz_energy_density + Copy>( + &self, + state: &StateHD, + ) -> N { // calculate weight functions let weight_functions = self.weight_functions(state.temperature); @@ -46,7 +52,7 @@ pub trait FunctionalContribution: Sync + Send { .unwrap()[0] } - fn first_partial_derivatives + Copy>( + fn first_partial_derivatives + Copy>( &self, temperature: N, weighted_densities: Array2, diff --git a/crates/feos-dft/src/ideal_chain_contribution.rs b/crates/feos-dft/src/ideal_chain_contribution.rs index f054bbbc3..86c9f39e9 100644 --- a/crates/feos-dft/src/ideal_chain_contribution.rs +++ b/crates/feos-dft/src/ideal_chain_contribution.rs @@ -18,7 +18,7 @@ impl IdealChainContribution { } } - pub fn bulk_helmholtz_energy_density + Copy>( + pub fn bulk_helmholtz_energy_density + Copy>( &self, partial_density: &DVector, ) -> D { @@ -43,7 +43,7 @@ impl IdealChainContribution { where D: Dimension, D::Larger: Dimension, - N: DualNum, + N: DualNum, { let mut phi = Array::zeros(density.raw_dim().remove_axis(Axis(0))); for (i, rhoi) in density.outer_iter().enumerate() { diff --git a/crates/feos-dft/src/profile/mod.rs b/crates/feos-dft/src/profile/mod.rs index 6497faa23..37f5e3aa9 100644 --- a/crates/feos-dft/src/profile/mod.rs +++ b/crates/feos-dft/src/profile/mod.rs @@ -180,7 +180,7 @@ impl DFTProfile where D::Larger: Dimension, { - fn integrate_reduced + Copy>(&self, mut profile: Array) -> N { + fn integrate_reduced + Copy>(&self, mut profile: Array) -> N { let (integration_weights, functional_determinant) = self.grid.integration_weights(); for (i, w) in integration_weights.into_iter().enumerate() { @@ -191,7 +191,7 @@ where profile.sum() * functional_determinant } - fn integrate_reduced_comp, N: DualNum + Copy>( + fn integrate_reduced_comp, N: DualNum + Copy>( &self, profile: &ArrayBase, ) -> Array1 { @@ -200,7 +200,10 @@ where }) } - pub(crate) fn integrate_reduced_segments, N: DualNum + Copy>( + pub(crate) fn integrate_reduced_segments< + S: Data, + N: DualNum + Copy, + >( &self, profile: &ArrayBase, ) -> DVector { diff --git a/crates/feos-dft/src/profile/properties.rs b/crates/feos-dft/src/profile/properties.rs index 2fe6a92a9..1c0427b28 100644 --- a/crates/feos-dft/src/profile/properties.rs +++ b/crates/feos-dft/src/profile/properties.rs @@ -82,7 +82,7 @@ where convolver: &dyn Convolver, ) -> FeosResult> where - N: DualNum + Copy, + N: DualNum + Copy, { let density_dual = density.mapv(N::from); let weighted_densities = convolver.weighted_densities(&density_dual); diff --git a/crates/feos-dft/src/weight_functions.rs b/crates/feos-dft/src/weight_functions.rs index e488799a8..912b21a1f 100644 --- a/crates/feos-dft/src/weight_functions.rs +++ b/crates/feos-dft/src/weight_functions.rs @@ -16,7 +16,7 @@ pub struct WeightFunction { pub shape: WeightFunctionShape, } -impl + Copy> WeightFunction { +impl + Copy> WeightFunction { /// Create a new weight function without prefactor pub fn new_unscaled(kernel_radius: DVector, shape: WeightFunctionShape) -> Self { Self { @@ -40,7 +40,7 @@ impl + Copy> WeightFunction { /// Calculates the value of the scalar weight function depending on its shape /// `k_abs` describes the absolute value of the Fourier variable - pub(crate) fn fft_scalar_weight_functions>( + pub(crate) fn fft_scalar_weight_functions>( &self, k_abs: &Array, lanczos: &Option>, @@ -90,7 +90,7 @@ impl + Copy> WeightFunction { /// Calculates the value of the vector weight function depending on its shape /// `k_abs` describes the absolute value of the Fourier variable /// `k` describes the (potentially multi-dimensional) Fourier variable - pub(crate) fn fft_vector_weight_functions>( + pub(crate) fn fft_vector_weight_functions>( &self, k_abs: &Array, k: &Array, @@ -277,7 +277,7 @@ impl WeightFunctionInfo { } } -impl + Copy> WeightFunctionInfo { +impl + Copy> WeightFunctionInfo { /// calculates the matrix of weight constants for this set of weighted densities pub fn weight_constants(&self, k: T, dimensions: usize) -> Array2 { let segments = self.component_index.len(); diff --git a/crates/feos/benches/dual_numbers.rs b/crates/feos/benches/dual_numbers.rs index eb2eff2e4..593da2cae 100644 --- a/crates/feos/benches/dual_numbers.rs +++ b/crates/feos/benches/dual_numbers.rs @@ -26,7 +26,7 @@ fn state_pcsaft(n: usize, eos: &PcSaft) -> State<&PcSaft> { } /// Residual Helmholtz energy given an equation of state and a StateHD. -fn a_res + Copy, E: Residual>((eos, state): (&E, &StateHD)) -> D { +fn a_res + Copy, E: Residual>((eos, state): (&E, &StateHD)) -> D { eos.reduced_residual_helmholtz_energy_density(state) } diff --git a/crates/feos/benches/dual_numbers_saftvrmie.rs b/crates/feos/benches/dual_numbers_saftvrmie.rs index 80f4da09d..a92698f59 100644 --- a/crates/feos/benches/dual_numbers_saftvrmie.rs +++ b/crates/feos/benches/dual_numbers_saftvrmie.rs @@ -30,11 +30,11 @@ fn state_saftvrmie(n: usize, eos: &SaftVRMie) -> State<&SaftVRMie> { } /// Residual Helmholtz energy given an equation of state and a StateHD. -fn a_res + Copy, E: Residual>((eos, state): (&E, &StateHD)) -> D { +fn a_res + Copy, E: Residual>((eos, state): (&E, &StateHD)) -> D { eos.reduced_residual_helmholtz_energy_density(state) } -fn d_hs + Copy>(inp: (&SaftVRMie, D)) -> D { +fn d_hs + Copy>(inp: (&SaftVRMie, D)) -> D { inp.0.params.hs_diameter(inp.1)[0] } diff --git a/crates/feos/src/association/dft.rs b/crates/feos/src/association/dft.rs index 9f2b11e87..b998fa5d3 100644 --- a/crates/feos/src/association/dft.rs +++ b/crates/feos/src/association/dft.rs @@ -15,7 +15,7 @@ impl Association { /// Uses the contact value of hard-sphere pair correlation function and model-specific /// implementations for the bonding volume. #[expect(clippy::too_many_arguments)] - fn yu_wu_association_strength + Copy>( + fn yu_wu_association_strength + Copy>( &self, parameters: &AssociationParameters, model: &A, @@ -98,7 +98,7 @@ where "Association" } - fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { + fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { let p = self.model; let r = p.hs_diameter(temperature) * N::from(0.5); let [_, _, _, c3] = p.geometry_coefficients(temperature); @@ -125,7 +125,7 @@ where ) } - fn helmholtz_energy_density + Copy>( + fn helmholtz_energy_density + Copy>( &self, temperature: N, weighted_densities: ArrayView2, @@ -191,7 +191,7 @@ where } impl<'a, A: AssociationStrength> YuWuAssociationFunctional<'a, A> { - pub fn _helmholtz_energy_density + Copy, S: Data>( + pub fn _helmholtz_energy_density + Copy, S: Data>( &self, temperature: N, rho0: &Array2, @@ -268,7 +268,7 @@ impl<'a, A: AssociationStrength> YuWuAssociationFunctional<'a, A> { } #[expect(clippy::too_many_arguments)] - fn helmholtz_energy_density_ab_analytic + Copy, S: Data>( + fn helmholtz_energy_density_ab_analytic + Copy, S: Data>( &self, parameters: Option<&A::Record>, temperature: N, @@ -307,7 +307,7 @@ impl<'a, A: AssociationStrength> YuWuAssociationFunctional<'a, A> { } #[expect(clippy::too_many_arguments)] - fn helmholtz_energy_density_cc_analytic + Copy, S: Data>( + fn helmholtz_energy_density_cc_analytic + Copy, S: Data>( &self, parameters: Option<&A::Record>, temperature: N, diff --git a/crates/feos/src/association/mod.rs b/crates/feos/src/association/mod.rs index 72bd97a38..7e8f7034f 100644 --- a/crates/feos/src/association/mod.rs +++ b/crates/feos/src/association/mod.rs @@ -25,7 +25,7 @@ pub trait AssociationStrength: HardSphereProperties { type Record; /// Association strength excluding the contact value of the pair correlation function. - fn association_strength_ij + Copy>( + fn association_strength_ij + Copy>( &self, temperature: D, comp_i: usize, @@ -34,7 +34,7 @@ pub trait AssociationStrength: HardSphereProperties { ) -> D; /// Association strength matrix for all association sites. - fn association_strength + Copy>( + fn association_strength + Copy>( &self, state: &StateHD, diameter: &DVector, @@ -91,7 +91,7 @@ impl Association { } #[inline] - pub fn helmholtz_energy_density + Copy>( + pub fn helmholtz_energy_density + Copy>( &self, model: &A, parameters: &AssociationParameters, @@ -136,7 +136,7 @@ impl Association { } } - fn helmholtz_energy_density_ab_analytic + Copy>( + fn helmholtz_energy_density_ab_analytic + Copy>( &self, parameters: &AssociationParameters, state: &StateHD, @@ -158,7 +158,7 @@ impl Association { rhoa * (xa.ln() - xa * 0.5 + 0.5) + rhob * (xb.ln() - xb * 0.5 + 0.5) } - fn helmholtz_energy_density_cc_analytic + Copy>( + fn helmholtz_energy_density_cc_analytic + Copy>( &self, parameters: &AssociationParameters, state: &StateHD, @@ -176,7 +176,7 @@ impl Association { rhoc * (xc.ln() - xc * 0.5 + 0.5) } - fn helmholtz_energy_density_cross_association + Copy>( + fn helmholtz_energy_density_cross_association + Copy>( &self, rho: &DVector, delta_ab: &DMatrix, @@ -232,7 +232,7 @@ impl Association { Ok(rho.dot(&x_dual.map(f))) } - fn newton_step_cross_association + Copy>( + fn newton_step_cross_association + Copy>( x: &mut DVector, delta_ab: &DMatrix, delta_cc: &DMatrix, diff --git a/crates/feos/src/epcsaft/eos/born.rs b/crates/feos/src/epcsaft/eos/born.rs index edd633e0e..74109c7fd 100644 --- a/crates/feos/src/epcsaft/eos/born.rs +++ b/crates/feos/src/epcsaft/eos/born.rs @@ -8,7 +8,7 @@ use num_dual::DualNum; pub struct Born; impl Born { - pub fn helmholtz_energy_density + Copy>( + pub fn helmholtz_energy_density + Copy>( &self, parameters: &ElectrolytePcSaftPars, state: &StateHD, diff --git a/crates/feos/src/epcsaft/eos/dispersion.rs b/crates/feos/src/epcsaft/eos/dispersion.rs index 374fc0c5f..0cdb12c3c 100644 --- a/crates/feos/src/epcsaft/eos/dispersion.rs +++ b/crates/feos/src/epcsaft/eos/dispersion.rs @@ -62,7 +62,7 @@ pub const B2: [f64; 7] = [ pub const T_REF: f64 = 298.15; impl ElectrolytePcSaftPars { - pub fn k_ij_t + Copy>(&self, temperature: D) -> DMatrix { + pub fn k_ij_t + Copy>(&self, temperature: D) -> DMatrix { let n = self.m.len(); let mut k_ij_t = DMatrix::zeros(n, n); @@ -79,7 +79,7 @@ impl ElectrolytePcSaftPars { k_ij_t } - pub fn epsilon_k_ij_t + Copy>(&self, temperature: D) -> DMatrix { + pub fn epsilon_k_ij_t + Copy>(&self, temperature: D) -> DMatrix { let k_ij_t = self.k_ij_t(temperature); let n = self.m.len(); @@ -97,7 +97,7 @@ impl ElectrolytePcSaftPars { pub struct Dispersion; impl Dispersion { - pub fn helmholtz_energy_density + Copy>( + pub fn helmholtz_energy_density + Copy>( &self, parameters: &ElectrolytePcSaftPars, state: &StateHD, diff --git a/crates/feos/src/epcsaft/eos/hard_chain.rs b/crates/feos/src/epcsaft/eos/hard_chain.rs index 534aad267..c467a740b 100644 --- a/crates/feos/src/epcsaft/eos/hard_chain.rs +++ b/crates/feos/src/epcsaft/eos/hard_chain.rs @@ -8,7 +8,7 @@ pub struct HardChain; impl HardChain { #[inline] - pub fn helmholtz_energy_density + Copy>( + pub fn helmholtz_energy_density + Copy>( &self, parameters: &ElectrolytePcSaftPars, state: &StateHD, diff --git a/crates/feos/src/epcsaft/eos/ionic.rs b/crates/feos/src/epcsaft/eos/ionic.rs index d2577d91c..56acf6301 100644 --- a/crates/feos/src/epcsaft/eos/ionic.rs +++ b/crates/feos/src/epcsaft/eos/ionic.rs @@ -12,7 +12,7 @@ const QE: f64 = 1.602176634e-19f64; const BOLTZMANN: f64 = 1.380649e-23; impl ElectrolytePcSaftPars { - pub fn bjerrum_length + Copy>( + pub fn bjerrum_length + Copy>( &self, state: &StateHD, epcsaft_variant: ElectrolytePcSaftVariants, @@ -36,7 +36,7 @@ impl ElectrolytePcSaftPars { pub struct Ionic; impl Ionic { - pub fn helmholtz_energy_density + Copy>( + pub fn helmholtz_energy_density + Copy>( &self, parameters: &ElectrolytePcSaftPars, state: &StateHD, diff --git a/crates/feos/src/epcsaft/eos/mod.rs b/crates/feos/src/epcsaft/eos/mod.rs index 5a0a8c81f..dec36181f 100644 --- a/crates/feos/src/epcsaft/eos/mod.rs +++ b/crates/feos/src/epcsaft/eos/mod.rs @@ -97,7 +97,7 @@ impl ResidualDyn for ElectrolytePcSaft { self.parameters.pure.len() } - fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { + fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { let msigma3 = self .params .m @@ -105,7 +105,7 @@ impl ResidualDyn for ElectrolytePcSaft { (msigma3.map(D::from).dot(molefracs) * FRAC_PI_6).recip() * self.options.max_eta } - fn reduced_helmholtz_energy_density_contributions + Copy>( + fn reduced_helmholtz_energy_density_contributions + Copy>( &self, state: &StateHD, ) -> Vec<(&'static str, D)> { diff --git a/crates/feos/src/epcsaft/eos/permittivity.rs b/crates/feos/src/epcsaft/eos/permittivity.rs index abbc0ac90..0202f1957 100644 --- a/crates/feos/src/epcsaft/eos/permittivity.rs +++ b/crates/feos/src/epcsaft/eos/permittivity.rs @@ -20,11 +20,11 @@ pub enum PermittivityRecord { } #[derive(Clone)] -pub struct Permittivity> { +pub struct Permittivity> { pub permittivity: D, } -impl + Copy> Permittivity { +impl + Copy> Permittivity { pub fn new( state: &StateHD, parameters: &ElectrolytePcSaftPars, diff --git a/crates/feos/src/epcsaft/parameters.rs b/crates/feos/src/epcsaft/parameters.rs index 364de81e1..20d121d63 100644 --- a/crates/feos/src/epcsaft/parameters.rs +++ b/crates/feos/src/epcsaft/parameters.rs @@ -160,7 +160,7 @@ pub struct ElectrolytePcSaftPars { } impl ElectrolytePcSaftPars { - pub fn sigma_t + Copy>(&self, temperature: D) -> DVector { + pub fn sigma_t + Copy>(&self, temperature: D) -> DVector { let mut sigma_t = DVector::from_fn(self.sigma.len(), |i, _| D::from(self.sigma[i])); if let Some(i) = self.water_sigma_t_comp { @@ -171,7 +171,7 @@ impl ElectrolytePcSaftPars { sigma_t } - pub fn sigma_ij_t + Copy>(&self, temperature: D) -> DMatrix { + pub fn sigma_ij_t + Copy>(&self, temperature: D) -> DMatrix { let diameter = self.sigma_t(temperature); let n = diameter.len(); @@ -357,11 +357,11 @@ impl ElectrolytePcSaftPars { } impl HardSphereProperties for ElectrolytePcSaftPars { - fn monomer_shape>(&self, _: N) -> MonomerShape<'_, N> { + fn monomer_shape>(&self, _: N) -> MonomerShape<'_, N> { MonomerShape::NonSpherical(self.m.map(N::from)) } - fn hs_diameter + Copy>(&self, temperature: D) -> DVector { + fn hs_diameter + Copy>(&self, temperature: D) -> DVector { let sigma_t = self.sigma_t(temperature); let ti = temperature.recip() * -3.0; @@ -379,7 +379,7 @@ impl HardSphereProperties for ElectrolytePcSaftPars { impl AssociationStrength for ElectrolytePcSaftPars { type Record = ElectrolytePcSaftAssociationRecord; - fn association_strength_ij + Copy>( + fn association_strength_ij + Copy>( &self, temperature: D, comp_i: usize, diff --git a/crates/feos/src/gc_pcsaft/dft/dispersion.rs b/crates/feos/src/gc_pcsaft/dft/dispersion.rs index 25338e33c..d0bd82ac0 100644 --- a/crates/feos/src/gc_pcsaft/dft/dispersion.rs +++ b/crates/feos/src/gc_pcsaft/dft/dispersion.rs @@ -23,7 +23,7 @@ impl<'a> FunctionalContribution for AttractiveFunctional<'a> { "Attractive functional (GC)" } - fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { + fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { let p = &self.parameters; let d = p.hs_diameter(temperature); @@ -36,7 +36,7 @@ impl<'a> FunctionalContribution for AttractiveFunctional<'a> { ) } - fn helmholtz_energy_density + Copy>( + fn helmholtz_energy_density + Copy>( &self, temperature: N, density: ArrayView2, diff --git a/crates/feos/src/gc_pcsaft/dft/hard_chain.rs b/crates/feos/src/gc_pcsaft/dft/hard_chain.rs index ddf0951a4..ccc33055c 100644 --- a/crates/feos/src/gc_pcsaft/dft/hard_chain.rs +++ b/crates/feos/src/gc_pcsaft/dft/hard_chain.rs @@ -22,7 +22,7 @@ impl<'a> FunctionalContribution for ChainFunctional<'a> { "Hard chain functional (GC)" } - fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { + fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { let p = &self.parameters; let d = p.hs_diameter(temperature); WeightFunctionInfo::new(p.component_index.clone(), true) @@ -44,7 +44,7 @@ impl<'a> FunctionalContribution for ChainFunctional<'a> { ) } - fn helmholtz_energy_density + Copy>( + fn helmholtz_energy_density + Copy>( &self, temperature: N, weighted_densities: ArrayView2, diff --git a/crates/feos/src/gc_pcsaft/dft/mod.rs b/crates/feos/src/gc_pcsaft/dft/mod.rs index 18ba4c793..e30b8014a 100644 --- a/crates/feos/src/gc_pcsaft/dft/mod.rs +++ b/crates/feos/src/gc_pcsaft/dft/mod.rs @@ -78,7 +78,7 @@ impl ResidualDyn for GcPcSaftFunctional { self.parameters.molar_weight.len() } - fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { + fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { let p = &self.params; let msigma3 = p.m.zip_map(&p.sigma, |m, s| m * s.powi(3) * m); let molefracs_segments: DVector<_> = p @@ -90,7 +90,7 @@ impl ResidualDyn for GcPcSaftFunctional { (msigma3.map(D::from).dot(&molefracs_segments) * FRAC_PI_6).recip() * self.options.max_eta } - fn reduced_helmholtz_energy_density_contributions + Copy>( + fn reduced_helmholtz_energy_density_contributions + Copy>( &self, state: &StateHD, ) -> Vec<(&'static str, D)> { @@ -131,7 +131,7 @@ impl HelmholtzEnergyFunctionalDyn for GcPcSaftFunctional { contributions.into_iter() } - fn bond_lengths + Copy>(&self, temperature: N) -> UnGraph<(), N> { + fn bond_lengths + Copy>(&self, temperature: N) -> UnGraph<(), N> { // temperature dependent segment diameter let d = self.params.hs_diameter(temperature); @@ -154,12 +154,12 @@ impl Molarweight for GcPcSaftFunctional { } impl HardSphereProperties for GcPcSaftFunctionalParameters { - fn monomer_shape>(&self, _: N) -> MonomerShape<'_, N> { + fn monomer_shape>(&self, _: N) -> MonomerShape<'_, N> { let m = self.m.map(N::from); MonomerShape::Heterosegmented([m.clone(), m.clone(), m.clone(), m], &self.component_index) } - fn hs_diameter + Copy>(&self, temperature: D) -> DVector { + fn hs_diameter + Copy>(&self, temperature: D) -> DVector { let ti = temperature.recip() * -3.0; DVector::from_fn(self.sigma.len(), |i, _| { -((ti * self.epsilon_k[i]).exp() * 0.12 - 1.0) * self.sigma[i] @@ -170,7 +170,7 @@ impl HardSphereProperties for GcPcSaftFunctionalParameters { impl AssociationStrength for GcPcSaftFunctionalParameters { type Record = GcPcSaftAssociationRecord; - fn association_strength_ij + Copy>( + fn association_strength_ij + Copy>( &self, temperature: D, comp_i: usize, diff --git a/crates/feos/src/gc_pcsaft/eos/ad.rs b/crates/feos/src/gc_pcsaft/eos/ad.rs index 72b251eaa..c7f5d1d41 100644 --- a/crates/feos/src/gc_pcsaft/eos/ad.rs +++ b/crates/feos/src/gc_pcsaft/eos/ad.rs @@ -184,7 +184,7 @@ pub struct GcPcSaftADParameters { pub bonds: [Vec<([usize; 2], D)>; N], } -impl + Copy, const N: usize> GcPcSaftADParameters { +impl + Copy, const N: usize> GcPcSaftADParameters { pub fn re(&self) -> GcPcSaftADParameters { let Self { groups, bonds } = self; let groups = groups.map(|g| g.re()); @@ -195,7 +195,7 @@ impl + Copy, const N: usize> GcPcSaftADParameters { } } -impl + Copy, const N: usize> GcPcSaftADParameters { +impl + Copy, const N: usize> GcPcSaftADParameters { pub fn from_groups( group_map: [&HashMap<&'static str, D>; N], bond_map: [&HashMap<[&'static str; 2], D>; N], @@ -220,17 +220,19 @@ impl + Copy, const N: usize> GcPcSaftADParameters { #[derive(Clone)] pub struct GcPcSaftAD(pub GcPcSaftADParameters); -impl + Copy, const N: usize> Residual, D> for GcPcSaftAD { +impl + Copy, const N: usize> Residual, D> + for GcPcSaftAD +{ fn components(&self) -> usize { N } type Real = GcPcSaftAD; - type Lifted + Copy> = GcPcSaftAD; + type Lifted + Copy> = GcPcSaftAD; fn re(&self) -> Self::Real { GcPcSaftAD(self.0.re()) } - fn lift + Copy>(&self) -> Self::Lifted { + fn lift + Copy>(&self) -> Self::Lifted { let GcPcSaftADParameters { groups, bonds } = &self.0; let groups = groups.map(|x| D2::from_inner(&x)); let bonds = bonds @@ -416,7 +418,7 @@ impl + Copy, const N: usize> Residual, D> for GcPcSaftA } } -fn apply_group_count + Copy, const N: usize>( +fn apply_group_count + Copy, const N: usize>( groups: &SMatrix, x: &SVector, ) -> SMatrix { @@ -426,7 +428,7 @@ fn apply_group_count + Copy, const N: usize>( ms } -fn pair_integral + Copy>(mij1: D, mij2: D, eta: D, eps_ij_t: D) -> D { +fn pair_integral + Copy>(mij1: D, mij2: D, eta: D, eps_ij_t: D) -> D { let mut eta_i = D::one(); let mut j = D::zero(); for (ad, bd) in AD.into_iter().zip(BD) { @@ -438,7 +440,7 @@ fn pair_integral + Copy>(mij1: D, mij2: D, eta: D, eps_ij_t: D) j } -fn triplet_integral + Copy>(mij1: D, mij2: D, eta: D) -> D { +fn triplet_integral + Copy>(mij1: D, mij2: D, eta: D) -> D { let mut eta_i = D::one(); let mut j = D::zero(); for cd in CD { diff --git a/crates/feos/src/gc_pcsaft/eos/dispersion.rs b/crates/feos/src/gc_pcsaft/eos/dispersion.rs index 3f464507d..f9870624b 100644 --- a/crates/feos/src/gc_pcsaft/eos/dispersion.rs +++ b/crates/feos/src/gc_pcsaft/eos/dispersion.rs @@ -62,7 +62,7 @@ pub const B2: [f64; 7] = [ pub(super) struct Dispersion; impl Dispersion { - pub(super) fn helmholtz_energy_density + Copy>( + pub(super) fn helmholtz_energy_density + Copy>( &self, parameters: &GcPcSaftEosParameters, state: &StateHD, diff --git a/crates/feos/src/gc_pcsaft/eos/hard_chain.rs b/crates/feos/src/gc_pcsaft/eos/hard_chain.rs index f67dffda4..e9fec009b 100644 --- a/crates/feos/src/gc_pcsaft/eos/hard_chain.rs +++ b/crates/feos/src/gc_pcsaft/eos/hard_chain.rs @@ -6,7 +6,7 @@ use num_dual::*; pub(super) struct HardChain; impl HardChain { - pub(super) fn helmholtz_energy_density + Copy>( + pub(super) fn helmholtz_energy_density + Copy>( &self, parameters: &GcPcSaftEosParameters, state: &StateHD, diff --git a/crates/feos/src/gc_pcsaft/eos/mod.rs b/crates/feos/src/gc_pcsaft/eos/mod.rs index ae6acf960..3612164db 100644 --- a/crates/feos/src/gc_pcsaft/eos/mod.rs +++ b/crates/feos/src/gc_pcsaft/eos/mod.rs @@ -77,7 +77,7 @@ impl ResidualDyn for GcPcSaft { self.parameters.molar_weight.len() } - fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { + fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { let p = &self.params; let molefracs_segments = DVector::from(p.component_index.clone()).map(|i| molefracs[i]); (p.m.component_mul(&p.sigma.map(|v| v.powi(3))) @@ -88,7 +88,7 @@ impl ResidualDyn for GcPcSaft { * self.options.max_eta } - fn reduced_helmholtz_energy_density_contributions + Copy>( + fn reduced_helmholtz_energy_density_contributions + Copy>( &self, state: &feos_core::StateHD, ) -> Vec<(&'static str, D)> { diff --git a/crates/feos/src/gc_pcsaft/eos/parameter.rs b/crates/feos/src/gc_pcsaft/eos/parameter.rs index ebf1ce5ba..b69dad0b8 100644 --- a/crates/feos/src/gc_pcsaft/eos/parameter.rs +++ b/crates/feos/src/gc_pcsaft/eos/parameter.rs @@ -110,12 +110,12 @@ impl GcPcSaftEosParameters { } impl HardSphereProperties for GcPcSaftEosParameters { - fn monomer_shape>(&self, _: N) -> MonomerShape<'_, N> { + fn monomer_shape>(&self, _: N) -> MonomerShape<'_, N> { let m = self.m.map(N::from); MonomerShape::Heterosegmented([m.clone(), m.clone(), m.clone(), m], &self.component_index) } - fn hs_diameter + Copy>(&self, temperature: D) -> DVector { + fn hs_diameter + Copy>(&self, temperature: D) -> DVector { let ti = temperature.recip() * -3.0; DVector::from_fn(self.sigma.len(), |i, _| { -((ti * self.epsilon_k[i]).exp() * 0.12 - 1.0) * self.sigma[i] @@ -126,7 +126,7 @@ impl HardSphereProperties for GcPcSaftEosParameters { impl AssociationStrength for GcPcSaftEosParameters { type Record = GcPcSaftAssociationRecord; - fn association_strength_ij + Copy>( + fn association_strength_ij + Copy>( &self, temperature: D, comp_i: usize, diff --git a/crates/feos/src/gc_pcsaft/eos/polar.rs b/crates/feos/src/gc_pcsaft/eos/polar.rs index 33073a77b..5f92afdca 100644 --- a/crates/feos/src/gc_pcsaft/eos/polar.rs +++ b/crates/feos/src/gc_pcsaft/eos/polar.rs @@ -31,7 +31,7 @@ pub const CD: [[f64; 3]; 4] = [ pub const PI_SQ_43: f64 = 4.0 * PI * FRAC_PI_3; -fn pair_integral_ij + Copy>(mij1: f64, mij2: f64, eta: D, eps_ij_t: D) -> D { +fn pair_integral_ij + Copy>(mij1: f64, mij2: f64, eta: D, eps_ij_t: D) -> D { let eta2 = eta * eta; let etas = [D::one(), eta, eta2, eta2 * eta, eta2 * eta2]; (0..AD.len()) @@ -43,7 +43,7 @@ fn pair_integral_ij + Copy>(mij1: f64, mij2: f64, eta: D, eps_ij .sum() } -fn triplet_integral_ijk + Copy>(mijk1: f64, mijk2: f64, eta: D) -> D { +fn triplet_integral_ijk + Copy>(mijk1: f64, mijk2: f64, eta: D) -> D { let eta2 = eta * eta; let etas = [D::one(), eta, eta2, eta2 * eta]; (0..CD.len()) @@ -121,7 +121,7 @@ impl Dipole { } impl Dipole { - pub(super) fn helmholtz_energy_density + Copy>( + pub(super) fn helmholtz_energy_density + Copy>( &self, parameters: &GcPcSaftEosParameters, state: &StateHD, diff --git a/crates/feos/src/hard_sphere/dft.rs b/crates/feos/src/hard_sphere/dft.rs index d48d6327a..9c654e01b 100644 --- a/crates/feos/src/hard_sphere/dft.rs +++ b/crates/feos/src/hard_sphere/dft.rs @@ -83,7 +83,7 @@ impl<'p, P: HardSphereProperties + Send + Sync> FunctionalContribution for FMTCo } } - fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { + fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { let r = self.properties.hs_diameter(temperature) * N::from(0.5); let [c0, c1, c2, c3] = self.properties.geometry_coefficients(temperature); match (self.version, r.len()) { @@ -183,7 +183,7 @@ impl<'p, P: HardSphereProperties + Send + Sync> FunctionalContribution for FMTCo } } - fn helmholtz_energy_density + Copy>( + fn helmholtz_energy_density + Copy>( &self, temperature: N, weighted_densities: ArrayView2, @@ -285,7 +285,7 @@ impl HardSphereProperties for HardSphereParameters { MonomerShape::Spherical(self.sigma.len()) } - fn hs_diameter>(&self, _: N) -> DVector { + fn hs_diameter>(&self, _: N) -> DVector { self.sigma.map(N::from) } } @@ -323,11 +323,11 @@ impl ResidualDyn for FMTFunctional { self.properties.sigma.len() } - fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { + fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { molefracs.dot(&self.properties.sigma.map(D::from)).recip() * 1.2 } - fn reduced_helmholtz_energy_density_contributions + Copy>( + fn reduced_helmholtz_energy_density_contributions + Copy>( &self, state: &StateHD, ) -> Vec<(&'static str, D)> { diff --git a/crates/feos/src/hard_sphere/mod.rs b/crates/feos/src/hard_sphere/mod.rs index 40d4936b4..a4a842768 100644 --- a/crates/feos/src/hard_sphere/mod.rs +++ b/crates/feos/src/hard_sphere/mod.rs @@ -27,10 +27,10 @@ pub enum MonomerShape<'a, D> { /// Properties of (generalized) hard sphere systems. pub trait HardSphereProperties { /// The [MonomerShape] used in the model. - fn monomer_shape + Copy>(&self, temperature: D) -> MonomerShape<'_, D>; + fn monomer_shape + Copy>(&self, temperature: D) -> MonomerShape<'_, D>; /// The temperature dependent hard-sphere diameters of every segment. - fn hs_diameter + Copy>(&self, temperature: D) -> DVector; + fn hs_diameter + Copy>(&self, temperature: D) -> DVector; /// For every segment, the index of the component that it is on. fn component_index(&self) -> Cow<'_, [usize]> { @@ -44,7 +44,7 @@ pub trait HardSphereProperties { } /// The geometry coefficients $C_{k,\alpha}$ for every segment. - fn geometry_coefficients + Copy>(&self, temperature: D) -> [DVector; 4] { + fn geometry_coefficients + Copy>(&self, temperature: D) -> [DVector; 4] { match self.monomer_shape(temperature) { MonomerShape::Spherical(n) => { let m = DVector::from_element(n, D::from(1.0)); @@ -56,7 +56,7 @@ pub trait HardSphereProperties { } /// The packing fractions $\zeta_k$. - fn zeta + Copy, const N: usize>( + fn zeta + Copy, const N: usize>( &self, temperature: D, partial_density: &DVector, @@ -94,7 +94,7 @@ impl HardSphere { /// Returns the Helmholtz energy, packing fractions, and temperature dependent diameters without redundant calculations. #[inline] pub fn helmholtz_energy_density_and_properties< - D: DualNum + Copy, + D: DualNum + Copy, P: HardSphereProperties, >( &self, @@ -126,7 +126,7 @@ impl HardSphere { } #[inline] - pub fn helmholtz_energy_density + Copy, P: HardSphereProperties>( + pub fn helmholtz_energy_density + Copy, P: HardSphereProperties>( &self, parameters: &P, state: &StateHD, diff --git a/crates/feos/src/ideal_gas/dippr.rs b/crates/feos/src/ideal_gas/dippr.rs index f976fbe11..7dce54223 100644 --- a/crates/feos/src/ideal_gas/dippr.rs +++ b/crates/feos/src/ideal_gas/dippr.rs @@ -55,7 +55,7 @@ impl Dippr { } } - fn c_p_integral + Copy>(&self, t: D) -> D { + fn c_p_integral + Copy>(&self, t: D) -> D { match self { Self::DIPPR100(coefs) => coefs .iter() @@ -79,7 +79,7 @@ impl Dippr { } } - fn c_p_t_integral + Copy>(&self, t: D) -> D { + fn c_p_t_integral + Copy>(&self, t: D) -> D { match self { Self::DIPPR100(coefs) => { coefs @@ -140,7 +140,7 @@ const RGAS: f64 = 8.31446261815324 * 1000.0; const T0: f64 = 298.15; impl IdealGas for Dippr { - fn ln_lambda3 + Copy>(&self, temperature: D) -> D { + fn ln_lambda3 + Copy>(&self, temperature: D) -> D { let t = temperature; let h = self.c_p_integral(t) - self.c_p_integral(T0); let s = self.c_p_t_integral(t) - self.c_p_t_integral(T0); @@ -152,16 +152,16 @@ impl IdealGas for Dippr { } } -impl + Copy> IdealGasAD for Dippr { +impl + Copy> IdealGasAD for Dippr { type Real = Self; - type Lifted + Copy> = Self; + type Lifted + Copy> = Self; fn re(&self) -> Self::Real { self.clone() } - fn lift + Copy>(&self) -> Self::Lifted { + fn lift + Copy>(&self) -> Self::Lifted { self.clone() } diff --git a/crates/feos/src/ideal_gas/joback.rs b/crates/feos/src/ideal_gas/joback.rs index e30c630b2..85a79097a 100644 --- a/crates/feos/src/ideal_gas/joback.rs +++ b/crates/feos/src/ideal_gas/joback.rs @@ -97,8 +97,11 @@ impl Joback { } } -impl + Copy> Joback { - fn ln_lambda3 + Copy + Mul>(&self, temperature: D2) -> D2 { +impl + Copy> Joback { + fn ln_lambda3 + Copy + Mul>( + &self, + temperature: D2, + ) -> D2 { let [a, b, c, d, e] = self.0; let t = temperature; let t2 = t * t; @@ -119,7 +122,7 @@ impl + Copy> Joback { } impl IdealGas for Joback { - fn ln_lambda3 + Copy>(&self, temperature: D) -> D { + fn ln_lambda3 + Copy>(&self, temperature: D) -> D { self.ln_lambda3(temperature) } @@ -128,13 +131,13 @@ impl IdealGas for Joback { } } -impl + Copy> IdealGasAD for Joback { +impl + Copy> IdealGasAD for Joback { type Real = Joback; - type Lifted + Copy> = Joback; + type Lifted + Copy> = Joback; fn re(&self) -> Self::Real { Joback(self.0.each_ref().map(D::re)) } - fn lift + Copy>(&self) -> Self::Lifted { + fn lift + Copy>(&self) -> Self::Lifted { Joback(self.0.each_ref().map(D2::from_inner)) } @@ -170,7 +173,7 @@ const GROUPS: [&str; 22] = [ "CH_pent", "CH_arom", "C_arom", "CH=O", ">C=O", "OCH3", "OCH2", "HCOO", "COO", "OH", "NH2", ]; -impl + Copy> Joback { +impl + Copy> Joback { pub fn from_groups(group_counts: [D; 22]) -> Self { let a: D = A.into_iter().zip(group_counts).map(|(a, g)| g * a).sum(); let b: D = B.into_iter().zip(group_counts).map(|(b, g)| g * b).sum(); @@ -361,20 +364,20 @@ pub mod test_ad { #[derive(Clone, Copy)] struct NoResidual; - impl + Copy> Residual for NoResidual { + impl + Copy> Residual for NoResidual { fn components(&self) -> usize { 1 } type Real = Self; - type Lifted + Copy> = Self; + type Lifted + Copy> = Self; fn re(&self) -> Self::Real { *self } - fn lift + Copy>(&self) -> Self::Lifted { + fn lift + Copy>(&self) -> Self::Lifted { *self } diff --git a/crates/feos/src/multiparameter/ideal_gas_function.rs b/crates/feos/src/multiparameter/ideal_gas_function.rs index fbd7571bb..8ceeb19c3 100644 --- a/crates/feos/src/multiparameter/ideal_gas_function.rs +++ b/crates/feos/src/multiparameter/ideal_gas_function.rs @@ -86,7 +86,7 @@ pub enum IdealGasFunction { } impl IdealGasFunction { - pub fn evaluate + Copy>(&self, delta: D, tau: D) -> D { + pub fn evaluate + Copy>(&self, delta: D, tau: D) -> D { match *self { IdealGasFunction::IdealGasHelmholtzLead { a1, a2 } => delta.ln() + a1 + tau * a2, IdealGasFunction::IdealGasHelmholtzLogTau { a } => tau.ln() * a, diff --git a/crates/feos/src/multiparameter/mod.rs b/crates/feos/src/multiparameter/mod.rs index fe30093ac..88290769a 100644 --- a/crates/feos/src/multiparameter/mod.rs +++ b/crates/feos/src/multiparameter/mod.rs @@ -83,12 +83,12 @@ impl ResidualDyn for MultiParameter { 1 } - fn compute_max_density + Copy>(&self, _: &DVector) -> D { + fn compute_max_density + Copy>(&self, _: &DVector) -> D { // Not sure what value works well here. This one is based on rho_c = 0.31*rho_max. D::from(6.02214076e-7 * self.rhoc / 0.31) } - fn reduced_helmholtz_energy_density_contributions + Copy>( + fn reduced_helmholtz_energy_density_contributions + Copy>( &self, state: &StateHD, ) -> Vec<(&'static str, D)> { @@ -118,7 +118,7 @@ impl Subset for MultiParameter { } impl IdealGas for MultiParameterIdealGas { - fn ln_lambda3 + Copy>(&self, temperature: D) -> D { + fn ln_lambda3 + Copy>(&self, temperature: D) -> D { let tau = temperature.recip() * self.tc; // bit of a hack to convert from phi^0 into ln Lambda^3 let delta = D::from(E / (6.02214076e-7 * self.rhoc)); @@ -165,7 +165,7 @@ mod test { eos.terms .iter() .map(|f| f.evaluate(delta, tau)) - .sum::>() + .sum::>() }, &SVector::from([delta, tau]), ); @@ -191,7 +191,7 @@ mod test { eos.terms .iter() .map(|f| f.evaluate(delta, tau)) - .sum::>() + .sum::>() }, &SVector::from([delta, tau]), ); @@ -218,7 +218,7 @@ mod test { .terms .iter() .map(|r| r.evaluate(delta, tau)) - .sum::>() + .sum::>() }, &SVector::from([delta, tau]), ); @@ -245,7 +245,7 @@ mod test { .terms .iter() .map(|r| r.evaluate(delta, tau)) - .sum::>() + .sum::>() }, &SVector::from([delta, tau]), ); diff --git a/crates/feos/src/multiparameter/residual_function.rs b/crates/feos/src/multiparameter/residual_function.rs index d39d71062..3116c1db2 100644 --- a/crates/feos/src/multiparameter/residual_function.rs +++ b/crates/feos/src/multiparameter/residual_function.rs @@ -118,7 +118,7 @@ pub enum ResidualFunction { } impl ResidualFunction { - pub fn evaluate + Copy>(&self, delta: D, tau: D) -> D { + pub fn evaluate + Copy>(&self, delta: D, tau: D) -> D { match *self { ResidualFunction::ResidualHelmholtzPower { d, l, n, t } => { let mut pre = delta.powi(d) * tau.powf(t) * n; diff --git a/crates/feos/src/pcsaft/dft/dispersion.rs b/crates/feos/src/pcsaft/dft/dispersion.rs index ec8633599..d682308da 100644 --- a/crates/feos/src/pcsaft/dft/dispersion.rs +++ b/crates/feos/src/pcsaft/dft/dispersion.rs @@ -25,7 +25,7 @@ impl<'a> AttractiveFunctional<'a> { } } -fn att_weight_functions + Copy>( +fn att_weight_functions + Copy>( p: &PcSaftPars, psi: f64, temperature: N, @@ -43,18 +43,18 @@ impl<'a> FunctionalContribution for AttractiveFunctional<'a> { "Attractive functional" } - fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { + fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { att_weight_functions(self.parameters, PSI_DFT, temperature) } - fn weight_functions_pdgt + Copy>( + fn weight_functions_pdgt + Copy>( &self, temperature: N, ) -> WeightFunctionInfo { att_weight_functions(self.parameters, PSI_PDGT, temperature) } - fn helmholtz_energy_density + Copy>( + fn helmholtz_energy_density + Copy>( &self, temperature: N, density: ArrayView2, diff --git a/crates/feos/src/pcsaft/dft/hard_chain.rs b/crates/feos/src/pcsaft/dft/hard_chain.rs index e179d4fcf..e52a48959 100644 --- a/crates/feos/src/pcsaft/dft/hard_chain.rs +++ b/crates/feos/src/pcsaft/dft/hard_chain.rs @@ -22,7 +22,7 @@ impl<'a> FunctionalContribution for ChainFunctional<'a> { "Hard chain functional" } - fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { + fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { let p = &self.parameters; let d = p.hs_diameter(temperature); WeightFunctionInfo::new(DVector::from_fn(d.len(), |i, _| i), true) @@ -48,7 +48,7 @@ impl<'a> FunctionalContribution for ChainFunctional<'a> { ) } - fn helmholtz_energy_density + Copy>( + fn helmholtz_energy_density + Copy>( &self, temperature: N, weighted_densities: ArrayView2, diff --git a/crates/feos/src/pcsaft/dft/mod.rs b/crates/feos/src/pcsaft/dft/mod.rs index 52c16aa4a..4ca78d2ef 100644 --- a/crates/feos/src/pcsaft/dft/mod.rs +++ b/crates/feos/src/pcsaft/dft/mod.rs @@ -80,13 +80,13 @@ impl ResidualDyn for PcSaftFunctional { self.parameters.pure.len() } - fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { + fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { let p = &self.params; let msigma3 = p.m.zip_map(&p.sigma, |m, s| m * s.powi(3)); (msigma3.map(D::from).dot(molefracs) * FRAC_PI_6).recip() * self.options.max_eta } - fn reduced_helmholtz_energy_density_contributions + Copy>( + fn reduced_helmholtz_energy_density_contributions + Copy>( &self, state: &StateHD, ) -> Vec<(&'static str, D)> { diff --git a/crates/feos/src/pcsaft/dft/polar.rs b/crates/feos/src/pcsaft/dft/polar.rs index 58256e161..43cf2395d 100644 --- a/crates/feos/src/pcsaft/dft/polar.rs +++ b/crates/feos/src/pcsaft/dft/polar.rs @@ -8,7 +8,7 @@ use ndarray::*; use num_dual::DualNum; use std::f64::consts::{FRAC_PI_3, PI}; -pub(super) fn helmholtz_energy_density_polar + Copy>( +pub(super) fn helmholtz_energy_density_polar + Copy>( parameters: &PcSaftPars, temperature: N, density: ArrayView2, @@ -36,7 +36,7 @@ pub(super) fn helmholtz_energy_density_polar + Copy>( Ok(phi) } -pub fn pair_integral_ij + Copy>( +pub fn pair_integral_ij + Copy>( mij1: f64, mij2: f64, eta: &Array1, @@ -63,7 +63,7 @@ pub fn pair_integral_ij + Copy>( integral } -pub fn triplet_integral_ijk>( +pub fn triplet_integral_ijk>( mijk1: f64, mijk2: f64, eta: &Array1, @@ -78,7 +78,7 @@ pub fn triplet_integral_ijk>( integral } -fn triplet_integral_ijk_dq>( +fn triplet_integral_ijk_dq>( mijk: f64, eta: &Array1, c: &[[f64; 2]], @@ -91,7 +91,7 @@ fn triplet_integral_ijk_dq>( integral } -fn phi_polar_dipole + Copy>( +fn phi_polar_dipole + Copy>( p: &PcSaftPars, temperature: N, density: ArrayView2, @@ -179,7 +179,7 @@ fn phi_polar_dipole + Copy>( Ok(result) } -fn phi_polar_quadrupole + Copy>( +fn phi_polar_quadrupole + Copy>( p: &PcSaftPars, temperature: N, density: ArrayView2, @@ -267,7 +267,7 @@ fn phi_polar_quadrupole + Copy>( Ok(result) } -fn phi_polar_dipole_quadrupole + Copy>( +fn phi_polar_dipole_quadrupole + Copy>( p: &PcSaftPars, temperature: N, density: ArrayView2, diff --git a/crates/feos/src/pcsaft/dft/pure_saft_functional.rs b/crates/feos/src/pcsaft/dft/pure_saft_functional.rs index 05c26d0e4..a33e02b97 100644 --- a/crates/feos/src/pcsaft/dft/pure_saft_functional.rs +++ b/crates/feos/src/pcsaft/dft/pure_saft_functional.rs @@ -40,7 +40,7 @@ impl<'a> FunctionalContribution for PureFMTAssocFunctional<'a> { "Pure FMT+association" } - fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { + fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { let r = self.parameters.hs_diameter(temperature) * N::from(0.5); WeightFunctionInfo::new(dvector![0], false).extend( vec![ @@ -59,7 +59,7 @@ impl<'a> FunctionalContribution for PureFMTAssocFunctional<'a> { ) } - fn helmholtz_energy_density + Copy>( + fn helmholtz_energy_density + Copy>( &self, temperature: N, weighted_densities: ArrayView2, @@ -150,7 +150,7 @@ impl<'a> FunctionalContribution for PureChainFunctional<'a> { "Pure chain" } - fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { + fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { let d = self.parameters.hs_diameter(temperature); WeightFunctionInfo::new(dvector![0], true) .add( @@ -167,7 +167,7 @@ impl<'a> FunctionalContribution for PureChainFunctional<'a> { ) } - fn helmholtz_energy_density + Copy>( + fn helmholtz_energy_density + Copy>( &self, _: N, weighted_densities: ArrayView2, @@ -200,7 +200,7 @@ impl<'a> FunctionalContribution for PureAttFunctional<'a> { "Pure attractive" } - fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { + fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { let d = self.parameters.hs_diameter(temperature); const PSI: f64 = 1.3862; // Homosegmented DFT (Sauer2017) let psi = N::from(PSI); @@ -210,7 +210,7 @@ impl<'a> FunctionalContribution for PureAttFunctional<'a> { ) } - fn weight_functions_pdgt + Copy>( + fn weight_functions_pdgt + Copy>( &self, temperature: N, ) -> WeightFunctionInfo { @@ -223,7 +223,7 @@ impl<'a> FunctionalContribution for PureAttFunctional<'a> { ) } - fn helmholtz_energy_density + Copy>( + fn helmholtz_energy_density + Copy>( &self, temperature: N, weighted_densities: ArrayView2, diff --git a/crates/feos/src/pcsaft/eos/dispersion.rs b/crates/feos/src/pcsaft/eos/dispersion.rs index 50fb3c1fc..cf75246c0 100644 --- a/crates/feos/src/pcsaft/eos/dispersion.rs +++ b/crates/feos/src/pcsaft/eos/dispersion.rs @@ -62,7 +62,7 @@ pub const B2: [f64; 7] = [ pub struct Dispersion; impl Dispersion { - pub fn helmholtz_energy_density + Copy>( + pub fn helmholtz_energy_density + Copy>( &self, parameters: &PcSaftPars, state: &StateHD, diff --git a/crates/feos/src/pcsaft/eos/hard_chain.rs b/crates/feos/src/pcsaft/eos/hard_chain.rs index e894f695a..9f425edb2 100644 --- a/crates/feos/src/pcsaft/eos/hard_chain.rs +++ b/crates/feos/src/pcsaft/eos/hard_chain.rs @@ -7,7 +7,7 @@ pub struct HardChain; impl HardChain { #[inline] - pub fn helmholtz_energy_density + Copy>( + pub fn helmholtz_energy_density + Copy>( &self, parameters: &PcSaftPars, state: &StateHD, diff --git a/crates/feos/src/pcsaft/eos/mod.rs b/crates/feos/src/pcsaft/eos/mod.rs index aa8e05d0c..2973451be 100644 --- a/crates/feos/src/pcsaft/eos/mod.rs +++ b/crates/feos/src/pcsaft/eos/mod.rs @@ -88,7 +88,7 @@ impl ResidualDyn for PcSaft { self.parameters.pure.len() } - fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { + fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { let msigma3 = self .params .m @@ -96,7 +96,7 @@ impl ResidualDyn for PcSaft { (msigma3.map(D::from).dot(molefracs) * FRAC_PI_6).recip() * self.options.max_eta } - fn reduced_helmholtz_energy_density_contributions + Copy>( + fn reduced_helmholtz_energy_density_contributions + Copy>( &self, state: &StateHD, ) -> Vec<(&'static str, D)> { @@ -167,11 +167,11 @@ impl Molarweight for PcSaft { } impl HardSphereProperties for PcSaftPars { - fn monomer_shape>(&self, _: N) -> MonomerShape<'_, N> { + fn monomer_shape>(&self, _: N) -> MonomerShape<'_, N> { MonomerShape::NonSpherical(self.m.map(N::from)) } - fn hs_diameter + Copy>(&self, temperature: D) -> DVector { + fn hs_diameter + Copy>(&self, temperature: D) -> DVector { let ti = temperature.recip() * -3.0; DVector::from_fn(self.sigma.len(), |i, _| { -((ti * self.epsilon_k[i]).exp() * 0.12 - 1.0) * self.sigma[i] @@ -182,7 +182,7 @@ impl HardSphereProperties for PcSaftPars { impl AssociationStrength for PcSaftPars { type Record = PcSaftAssociationRecord; - fn association_strength_ij + Copy>( + fn association_strength_ij + Copy>( &self, temperature: D, comp_i: usize, diff --git a/crates/feos/src/pcsaft/eos/pcsaft_binary.rs b/crates/feos/src/pcsaft/eos/pcsaft_binary.rs index 160b3bd27..9d2bfba2f 100644 --- a/crates/feos/src/pcsaft/eos/pcsaft_binary.rs +++ b/crates/feos/src/pcsaft/eos/pcsaft_binary.rs @@ -20,7 +20,7 @@ impl PcSaftBinary { } impl ParametersAD for PcSaftBinary { - fn build + Copy>( + fn build + Copy>( mut f: impl FnMut(&'static str, bool) -> D, ) -> PcSaftBinary { PcSaftBinary::new( @@ -44,7 +44,7 @@ impl ParametersAD for PcSaftBinary { } impl ParametersAD for PcSaftBinary { - fn build + Copy>( + fn build + Copy>( mut f: impl FnMut(&'static str, bool) -> D, ) -> PcSaftBinary { PcSaftBinary::new( @@ -75,7 +75,7 @@ impl ParametersAD for PcSaftBinary { } } -fn hard_sphere + Copy>( +fn hard_sphere + Copy>( [m1, m2]: [D; 2], [x1, x2]: [D; 2], [d1, d2]: [D; 2], @@ -109,7 +109,7 @@ fn hard_sphere + Copy>( (hs, etas, zeta2, zeta3, frac_1mz3) } -fn hard_chain + Copy>( +fn hard_chain + Copy>( [m1, m2]: [D; 2], [d1, d2]: [D; 2], [rho1, rho2]: [D; 2], @@ -123,7 +123,7 @@ fn hard_chain + Copy>( } #[expect(clippy::too_many_arguments)] -fn dispersion + Copy>( +fn dispersion + Copy>( [m1, m2]: [D; 2], [sigma1, sigma2]: [D; 2], [epsilon_k1, epsilon_k2]: [D; 2], @@ -174,7 +174,7 @@ fn dispersion + Copy>( } #[expect(clippy::too_many_arguments)] -fn dipoles + Copy>( +fn dipoles + Copy>( [m1, m2]: [D; 2], [sigma1, sigma2]: [D; 2], [sigma11_3, sigma12_3, sigma22_3]: [D; 3], @@ -241,7 +241,7 @@ fn dipoles + Copy>( polar } -fn association + Copy>( +fn association + Copy>( assoc_params: [[D; 4]; 2], [sigma11_3, _, sigma22_3]: [D; 3], t_inv: D, @@ -328,7 +328,7 @@ fn association + Copy>( } #[expect(clippy::too_many_arguments)] -fn helmholtz_energy_density + Copy>( +fn helmholtz_energy_density + Copy>( temperature: D, rho: [D; 2], m: [D; 2], @@ -373,20 +373,20 @@ fn helmholtz_energy_density + Copy>( } } -impl + Copy> Residual for PcSaftBinary { +impl + Copy> Residual for PcSaftBinary { fn components(&self) -> usize { 2 } type Real = PcSaftBinary; - type Lifted + Copy> = PcSaftBinary; + type Lifted + Copy> = PcSaftBinary; fn re(&self) -> Self::Real { PcSaftBinary(( self.0.0.each_ref().map(|x| x.each_ref().map(D::re)), self.0.1.re(), )) } - fn lift + Copy>(&self) -> Self::Lifted { + fn lift + Copy>(&self) -> Self::Lifted { PcSaftBinary(( self.0 .0 @@ -430,20 +430,20 @@ impl + Copy> Residual for PcSaftBinary { } } -impl + Copy> Residual for PcSaftBinary { +impl + Copy> Residual for PcSaftBinary { fn components(&self) -> usize { 2 } type Real = PcSaftBinary; - type Lifted + Copy> = PcSaftBinary; + type Lifted + Copy> = PcSaftBinary; fn re(&self) -> Self::Real { PcSaftBinary(( self.0.0.each_ref().map(|x| x.each_ref().map(D::re)), self.0.1.re(), )) } - fn lift + Copy>(&self) -> Self::Lifted { + fn lift + Copy>(&self) -> Self::Lifted { PcSaftBinary(( self.0 .0 diff --git a/crates/feos/src/pcsaft/eos/pcsaft_pure.rs b/crates/feos/src/pcsaft/eos/pcsaft_pure.rs index 46155f4cf..20f6673a8 100644 --- a/crates/feos/src/pcsaft/eos/pcsaft_pure.rs +++ b/crates/feos/src/pcsaft/eos/pcsaft_pure.rs @@ -11,9 +11,9 @@ const MAX_ETA: f64 = 0.5; /// Optimized implementation of PC-SAFT for a single component. #[derive(Clone, Copy)] -pub struct PcSaftPure + Copy, const N: usize>(pub [D; N]); +pub struct PcSaftPure + Copy, const N: usize>(pub [D; N]); -fn helmholtz_energy_density_non_assoc + Copy>( +fn helmholtz_energy_density_non_assoc + Copy>( m: D, sigma: D, epsilon_k: D, @@ -88,7 +88,7 @@ fn helmholtz_energy_density_non_assoc + Copy>( (hs + hc + disp + dipole, [eta, eta_m1]) } -fn helmholtz_energy_density + Copy>( +fn helmholtz_energy_density + Copy>( parameters: &[D; 8], temperature: D, density: D, @@ -112,17 +112,17 @@ fn helmholtz_energy_density + Copy>( non_assoc + assoc } -impl + Copy> Residual for PcSaftPure { +impl + Copy> Residual for PcSaftPure { fn components(&self) -> usize { 1 } type Real = PcSaftPure; - type Lifted + Copy> = PcSaftPure; + type Lifted + Copy> = PcSaftPure; fn re(&self) -> Self::Real { PcSaftPure(self.0.each_ref().map(D::re)) } - fn lift + Copy>(&self) -> Self::Lifted { + fn lift + Copy>(&self) -> Self::Lifted { PcSaftPure(self.0.each_ref().map(D2::from_inner)) } @@ -147,17 +147,17 @@ impl + Copy> Residual for PcSaftPure { } } -impl + Copy> Residual for PcSaftPure { +impl + Copy> Residual for PcSaftPure { fn components(&self) -> usize { 1 } type Real = PcSaftPure; - type Lifted + Copy> = PcSaftPure; + type Lifted + Copy> = PcSaftPure; fn re(&self) -> Self::Real { PcSaftPure(self.0.each_ref().map(D::re)) } - fn lift + Copy>(&self) -> Self::Lifted { + fn lift + Copy>(&self) -> Self::Lifted { PcSaftPure(self.0.each_ref().map(D2::from_inner)) } @@ -184,7 +184,7 @@ impl + Copy> Residual for PcSaftPure { } impl ParametersAD for PcSaftPure { - fn build + Copy>( + fn build + Copy>( mut f: impl FnMut(&'static str, bool) -> D, ) -> PcSaftPure { PcSaftPure([ @@ -197,7 +197,7 @@ impl ParametersAD for PcSaftPure { } impl ParametersAD for PcSaftPure { - fn build + Copy>( + fn build + Copy>( mut f: impl FnMut(&'static str, bool) -> D, ) -> PcSaftPure { PcSaftPure([ diff --git a/crates/feos/src/pcsaft/eos/polar.rs b/crates/feos/src/pcsaft/eos/polar.rs index 096bdc1c2..f8ad10849 100644 --- a/crates/feos/src/pcsaft/eos/polar.rs +++ b/crates/feos/src/pcsaft/eos/polar.rs @@ -125,7 +125,7 @@ impl MeanSegmentNumbers { } } -fn pair_integral_ij + Copy>( +fn pair_integral_ij + Copy>( mij1: f64, mij2: f64, etas: &[D], @@ -142,7 +142,7 @@ fn pair_integral_ij + Copy>( .sum() } -fn triplet_integral_ijk + Copy>( +fn triplet_integral_ijk + Copy>( mijk1: f64, mijk2: f64, etas: &[D], @@ -153,7 +153,7 @@ fn triplet_integral_ijk + Copy>( .sum() } -fn triplet_integral_ijk_dq + Copy>(mijk: f64, etas: &[D], c: &[[f64; 2]]) -> D { +fn triplet_integral_ijk_dq + Copy>(mijk: f64, etas: &[D], c: &[[f64; 2]]) -> D { (0..c.len()) .map(|i| etas[i] * (c[i][0] + mijk * c[i][1])) .sum() @@ -163,7 +163,7 @@ pub struct Dipole; impl Dipole { #[inline] - pub fn helmholtz_energy_density + Copy>( + pub fn helmholtz_energy_density + Copy>( &self, parameters: &PcSaftPars, state: &StateHD, @@ -236,7 +236,7 @@ pub struct Quadrupole; impl Quadrupole { #[inline] - pub fn helmholtz_energy_density + Copy>( + pub fn helmholtz_energy_density + Copy>( &self, parameters: &PcSaftPars, state: &StateHD, @@ -317,7 +317,7 @@ pub struct DipoleQuadrupole; impl DipoleQuadrupole { #[inline] - pub fn helmholtz_energy_density + Copy>( + pub fn helmholtz_energy_density + Copy>( &self, parameters: &PcSaftPars, state: &StateHD, diff --git a/crates/feos/src/pets/dft/dispersion.rs b/crates/feos/src/pets/dft/dispersion.rs index 915be2be4..d25b08d9b 100644 --- a/crates/feos/src/pets/dft/dispersion.rs +++ b/crates/feos/src/pets/dft/dispersion.rs @@ -23,7 +23,7 @@ impl<'a> AttractiveFunctional<'a> { Self { parameters } } - fn att_weight_functions + Copy>( + fn att_weight_functions + Copy>( &self, psi: f64, temperature: N, @@ -41,18 +41,18 @@ impl<'a> FunctionalContribution for AttractiveFunctional<'a> { "Attractive functional" } - fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { + fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { self.att_weight_functions(PSI_DFT, temperature) } - fn weight_functions_pdgt + Copy>( + fn weight_functions_pdgt + Copy>( &self, temperature: N, ) -> WeightFunctionInfo { self.att_weight_functions(PSI_PDGT, temperature) } - fn helmholtz_energy_density + Copy>( + fn helmholtz_energy_density + Copy>( &self, temperature: N, density: ArrayView2, diff --git a/crates/feos/src/pets/dft/pure_pets_functional.rs b/crates/feos/src/pets/dft/pure_pets_functional.rs index 14efe1b15..1e4b5f073 100644 --- a/crates/feos/src/pets/dft/pure_pets_functional.rs +++ b/crates/feos/src/pets/dft/pure_pets_functional.rs @@ -31,7 +31,7 @@ impl<'a> FunctionalContribution for PureFMTFunctional<'a> { "Pure FMT" } - fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { + fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { let r = self.parameters.hs_diameter(temperature) * N::from(0.5); WeightFunctionInfo::new(dvector![0], false).extend( vec![ @@ -46,7 +46,7 @@ impl<'a> FunctionalContribution for PureFMTFunctional<'a> { ) } - fn helmholtz_energy_density + Copy>( + fn helmholtz_energy_density + Copy>( &self, temperature: N, weighted_densities: ArrayView2, @@ -123,7 +123,7 @@ impl<'a> FunctionalContribution for PureAttFunctional<'a> { "Pure attractive" } - fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { + fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { let d = self.parameters.hs_diameter(temperature); const PSI: f64 = 1.21; // Homosegmented DFT (Heier2018) WeightFunctionInfo::new(dvector![0], false).add( @@ -132,7 +132,7 @@ impl<'a> FunctionalContribution for PureAttFunctional<'a> { ) } - fn helmholtz_energy_density + Copy>( + fn helmholtz_energy_density + Copy>( &self, temperature: N, weighted_densities: ArrayView2, diff --git a/crates/feos/src/pets/eos/dispersion.rs b/crates/feos/src/pets/eos/dispersion.rs index 2215a4225..b3f65c6aa 100644 --- a/crates/feos/src/pets/eos/dispersion.rs +++ b/crates/feos/src/pets/eos/dispersion.rs @@ -24,7 +24,7 @@ pub const B: [f64; 7] = [ ]; impl Pets { - pub fn dispersion_helmholtz_energy_density + Copy>( + pub fn dispersion_helmholtz_energy_density + Copy>( &self, state: &StateHD, ) -> D { diff --git a/crates/feos/src/pets/eos/mod.rs b/crates/feos/src/pets/eos/mod.rs index 5d9b9a666..5fc0c32a6 100644 --- a/crates/feos/src/pets/eos/mod.rs +++ b/crates/feos/src/pets/eos/mod.rs @@ -92,13 +92,13 @@ impl ResidualDyn for Pets { self.parameters.pure.len() } - fn compute_max_density + Copy>(&self, moles: &DVector) -> D { + fn compute_max_density + Copy>(&self, moles: &DVector) -> D { moles.sum() * self.options.max_eta / (self.sigma.map(|v| D::from(v.powi(3))).component_mul(moles)).sum() / FRAC_PI_6 } - fn reduced_helmholtz_energy_density_contributions + Copy>( + fn reduced_helmholtz_energy_density_contributions + Copy>( &self, state: &feos_core::StateHD, ) -> Vec<(&'static str, D)> { @@ -122,11 +122,11 @@ impl Molarweight for Pets { } impl HardSphereProperties for Pets { - fn monomer_shape>(&self, _: N) -> MonomerShape<'_, N> { + fn monomer_shape>(&self, _: N) -> MonomerShape<'_, N> { MonomerShape::Spherical(self.sigma.len()) } - fn hs_diameter + Copy>(&self, temperature: D) -> DVector { + fn hs_diameter + Copy>(&self, temperature: D) -> DVector { let ti = temperature.recip() * -3.052785558; DVector::from_fn(self.sigma.len(), |i, _| { -((ti * self.epsilon_k[i]).exp() * 0.127112544 - 1.0) * self.sigma[i] diff --git a/crates/feos/src/saftvrmie/eos/dispersion.rs b/crates/feos/src/saftvrmie/eos/dispersion.rs index cc35b6f22..eed119411 100644 --- a/crates/feos/src/saftvrmie/eos/dispersion.rs +++ b/crates/feos/src/saftvrmie/eos/dispersion.rs @@ -23,7 +23,7 @@ pub struct Properties { k0: [D; 4], } -impl + Copy + Zero> Properties { +impl + Copy + Zero> Properties { pub(super) fn new( parameters: &SaftVRMiePars, state: &StateHD, @@ -99,7 +99,7 @@ pub(super) const PHI: [[f64; 7]; 6] = [ ]; /// First, second and third order perturbations for dispersive interactions -pub fn helmholtz_energy_density_disp + Copy>( +pub fn helmholtz_energy_density_disp + Copy>( parameters: &SaftVRMiePars, properties: &Properties, state: &StateHD, @@ -195,7 +195,7 @@ pub fn helmholtz_energy_density_disp + Copy>( } /// Combine dispersion and chain contributions -pub fn helmholtz_energy_density_disp_chain + Copy>( +pub fn helmholtz_energy_density_disp_chain + Copy>( parameters: &SaftVRMiePars, properties: &Properties, state: &StateHD, @@ -334,7 +334,7 @@ pub fn helmholtz_energy_density_disp_chain + Copy>( } #[inline] -pub(super) fn zeta_eff + Copy>(zeta: D, lambda: f64) -> D { +pub(super) fn zeta_eff + Copy>(zeta: D, lambda: f64) -> D { let li = 1. / lambda; let li2 = li * li; let li3 = li * li2; @@ -350,14 +350,14 @@ pub(super) fn zeta_eff + Copy>(zeta: D, lambda: f64) -> D { /// Sutherland potential for mixtures (Eq. A 16) divided by 2 PI rho_s d_ij^3 epsilon_k_ij #[inline] -fn a1s_ij + Copy>(zeta_x: D, lambda: f64) -> D { +fn a1s_ij + Copy>(zeta_x: D, lambda: f64) -> D { let zeta_eff = zeta_eff(zeta_x, lambda); -(-zeta_eff * 0.5 + 1.0) / ((-zeta_eff + 1.0).powi(3) * (lambda - 3.0)) } /// Eq. A 12 of Lafitte divided by 2 PI rho_s d_ij^3 epsilon_k_ij #[inline] -fn b_ij + Copy>(zeta_x: D, x0: D, lambda: f64) -> D { +fn b_ij + Copy>(zeta_x: D, x0: D, lambda: f64) -> D { let x0_3ml = x0.powf(3.0 - lambda); let i = -(x0_3ml - 1.0) / (lambda - 3.0); let j = -(x0.powf(4.0 - lambda) * (lambda - 3.0) - x0_3ml * (lambda - 4.0) - 1.0) @@ -367,7 +367,7 @@ fn b_ij + Copy>(zeta_x: D, x0: D, lambda: f64) -> D { /// Calculates x0^l (a1s_ij + b_ij) without prefactor C #[inline] -fn a1s_b_ij + Copy>(zeta_x: D, x0: D, lambda: f64) -> D { +fn a1s_b_ij + Copy>(zeta_x: D, x0: D, lambda: f64) -> D { x0.powf(lambda) * (a1s_ij(zeta_x, lambda) + b_ij(zeta_x, x0, lambda)) } diff --git a/crates/feos/src/saftvrmie/eos/mod.rs b/crates/feos/src/saftvrmie/eos/mod.rs index 780f2fc37..1bdde781f 100644 --- a/crates/feos/src/saftvrmie/eos/mod.rs +++ b/crates/feos/src/saftvrmie/eos/mod.rs @@ -64,7 +64,7 @@ impl ResidualDyn for SaftVRMie { self.params.m.len() } - fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { + fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { let msigma3 = self .params .m @@ -72,7 +72,7 @@ impl ResidualDyn for SaftVRMie { (msigma3.map(D::from).dot(molefracs) * FRAC_PI_6).recip() * self.options.max_eta } - fn reduced_helmholtz_energy_density_contributions + Copy>( + fn reduced_helmholtz_energy_density_contributions + Copy>( &self, state: &StateHD, ) -> Vec<(&'static str, D)> { @@ -120,7 +120,7 @@ impl Molarweight for SaftVRMie { impl AssociationStrength for SaftVRMiePars { type Record = SaftVRMieAssociationRecord; - fn association_strength_ij + Copy>( + fn association_strength_ij + Copy>( &self, temperature: D, comp_i: usize, diff --git a/crates/feos/src/saftvrmie/parameters.rs b/crates/feos/src/saftvrmie/parameters.rs index b40cd524b..fe02875f3 100644 --- a/crates/feos/src/saftvrmie/parameters.rs +++ b/crates/feos/src/saftvrmie/parameters.rs @@ -170,7 +170,7 @@ impl SaftVRMiePars { impl SaftVRMiePars { #[inline] - pub fn hs_diameter_ij + Copy>( + pub fn hs_diameter_ij + Copy>( &self, i: usize, j: usize, @@ -197,7 +197,7 @@ impl SaftVRMiePars { /// /// Method of Aasen et al. /// Using starting value proposed in Clapeyron.jl (Andrés Riedemann) -fn lower_integratal_limit + Copy>(la: f64, lr: f64, c_eps_t: D) -> D { +fn lower_integratal_limit + Copy>(la: f64, lr: f64, c_eps_t: D) -> D { // initial value from repulsive contribution let k = (-c_eps_t.recip() * f64::EPSILON.ln()).ln(); let mut r = (-k / lr).exp(); @@ -219,7 +219,7 @@ fn lower_integratal_limit + Copy>(la: f64, lr: f64, c_eps_t: D) /// f is the function to find the root of. /// Here, f = -beta u_mie(r) - ln(EPS) #[inline] -fn mie_potential_halley + Copy>(r: D, la: f64, lr: f64, c_eps_t: D) -> [D; 3] { +fn mie_potential_halley + Copy>(r: D, la: f64, lr: f64, c_eps_t: D) -> [D; 3] { let ri = r.recip(); let plr = ri.powf(lr); let pla = ri.powf(la); @@ -237,17 +237,17 @@ fn mie_potential_halley + Copy>(r: D, la: f64, lr: f64, c_eps_t: /// Dimensionless Mie potential (divided by kT) #[inline] -fn beta_u_mie + Copy>(r: D, la: f64, lr: f64, sigma: f64, c_eps_t: D) -> D { +fn beta_u_mie + Copy>(r: D, la: f64, lr: f64, sigma: f64, c_eps_t: D) -> D { let ri = r.recip() * sigma; (ri.powf(lr) - ri.powf(la)) * c_eps_t } impl HardSphereProperties for SaftVRMiePars { - fn monomer_shape>(&self, _: N) -> MonomerShape<'_, N> { + fn monomer_shape>(&self, _: N) -> MonomerShape<'_, N> { MonomerShape::NonSpherical(self.m.map(N::from)) } - fn hs_diameter + Copy>(&self, temperature: D) -> DVector { + fn hs_diameter + Copy>(&self, temperature: D) -> DVector { let t_inv = temperature.recip(); DVector::from_fn(self.m.len(), |i, _| self.hs_diameter_ij(i, i, t_inv)) } diff --git a/crates/feos/src/saftvrqmie/dft/dispersion.rs b/crates/feos/src/saftvrqmie/dft/dispersion.rs index 220037cec..a5b2bfcfd 100644 --- a/crates/feos/src/saftvrqmie/dft/dispersion.rs +++ b/crates/feos/src/saftvrqmie/dft/dispersion.rs @@ -22,7 +22,7 @@ impl<'a> AttractiveFunctional<'a> { } } -fn att_weight_functions + Copy>( +fn att_weight_functions + Copy>( p: &SaftVRQMiePars, psi: f64, temperature: N, @@ -39,18 +39,18 @@ impl<'a> FunctionalContribution for AttractiveFunctional<'a> { "Attractive functional" } - fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { + fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { att_weight_functions(self.parameters, PSI_DFT, temperature) } - fn weight_functions_pdgt + Copy>( + fn weight_functions_pdgt + Copy>( &self, temperature: N, ) -> WeightFunctionInfo { att_weight_functions(self.parameters, PSI_PDGT, temperature) } - fn helmholtz_energy_density + Copy>( + fn helmholtz_energy_density + Copy>( &self, temperature: N, density: ArrayView2, diff --git a/crates/feos/src/saftvrqmie/dft/mod.rs b/crates/feos/src/saftvrqmie/dft/mod.rs index 6cde777b4..5608a54dc 100644 --- a/crates/feos/src/saftvrqmie/dft/mod.rs +++ b/crates/feos/src/saftvrqmie/dft/mod.rs @@ -60,11 +60,11 @@ impl HelmholtzEnergyFunctionalDyn for SaftVRQMie { } impl HardSphereProperties for SaftVRQMiePars { - fn monomer_shape>(&self, _: N) -> MonomerShape<'_, N> { + fn monomer_shape>(&self, _: N) -> MonomerShape<'_, N> { MonomerShape::Spherical(self.m.len()) } - fn hs_diameter + Copy>(&self, temperature: D) -> DVector { + fn hs_diameter + Copy>(&self, temperature: D) -> DVector { self.hs_diameter(temperature) } } diff --git a/crates/feos/src/saftvrqmie/dft/non_additive_hs.rs b/crates/feos/src/saftvrqmie/dft/non_additive_hs.rs index a7909ab35..29d931b6c 100644 --- a/crates/feos/src/saftvrqmie/dft/non_additive_hs.rs +++ b/crates/feos/src/saftvrqmie/dft/non_additive_hs.rs @@ -24,7 +24,7 @@ impl<'a> FunctionalContribution for NonAddHardSphereFunctional<'a> { "Non-additive hard-sphere functional" } - fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { + fn weight_functions + Copy>(&self, temperature: N) -> WeightFunctionInfo { let p = &self.parameters; let r = p.hs_diameter(temperature) * N::from(0.5); WeightFunctionInfo::new(DVector::from_fn(r.len(), |i, _| i), false) @@ -50,7 +50,7 @@ impl<'a> FunctionalContribution for NonAddHardSphereFunctional<'a> { ) } - fn helmholtz_energy_density + Copy>( + fn helmholtz_energy_density + Copy>( &self, temperature: N, weighted_densities: ArrayView2, @@ -143,7 +143,7 @@ impl<'a> FunctionalContribution for NonAddHardSphereFunctional<'a> { } } -pub fn non_additive_hs_energy_density + Copy>( +pub fn non_additive_hs_energy_density + Copy>( parameters: &SaftVRQMiePars, d_hs_ij: &Array2, d_hs_add_ij: &Array2, diff --git a/crates/feos/src/saftvrqmie/eos/dispersion.rs b/crates/feos/src/saftvrqmie/eos/dispersion.rs index f4bdfa12b..ae78efea7 100644 --- a/crates/feos/src/saftvrqmie/eos/dispersion.rs +++ b/crates/feos/src/saftvrqmie/eos/dispersion.rs @@ -31,11 +31,11 @@ const PHI: [[f64; 7]; 6] = [ ], ]; -pub struct Alpha> { +pub struct Alpha> { alpha_ij: DMatrix, } -impl + Copy> Alpha { +impl + Copy> Alpha { pub fn new( parameters: &SaftVRQMiePars, sigma_eff_ij: &DMatrix, @@ -90,7 +90,7 @@ impl + Copy> Alpha { pub struct Dispersion; impl Dispersion { - pub fn helmholtz_energy_density + Copy>( + pub fn helmholtz_energy_density + Copy>( &self, parameters: &SaftVRQMiePars, state: &StateHD, @@ -148,7 +148,7 @@ impl Dispersion { #[cfg(feature = "dft")] #[expect(clippy::too_many_arguments)] -pub fn dispersion_energy_density + Copy>( +pub fn dispersion_energy_density + Copy>( parameters: &SaftVRQMiePars, d_hs_ij: &DMatrix, s_eff_ij: &DMatrix, @@ -184,7 +184,7 @@ pub fn dispersion_energy_density + Copy>( rho_s * (a1 * inv_t + a2 * inv_t.powi(2) + a3 * inv_t.powi(3)) } -fn zeta_saft_vrq_mie + Copy>( +fn zeta_saft_vrq_mie + Copy>( m: &DVector, x_s: &DVector, diameter: &DMatrix, @@ -199,7 +199,7 @@ fn zeta_saft_vrq_mie + Copy>( zeta * FRAC_PI_6 * rho_s } -fn first_order_perturbation + Copy>( +fn first_order_perturbation + Copy>( parameters: &SaftVRQMiePars, x_s: &DVector, zeta: D, @@ -239,7 +239,7 @@ fn first_order_perturbation + Copy>( } #[expect(clippy::too_many_arguments)] -fn first_order_perturbation_ij + Copy>( +fn first_order_perturbation_ij + Copy>( lambda_a: f64, lambda_r: f64, epsilon_k: f64, @@ -271,7 +271,7 @@ fn first_order_perturbation_ij + Copy>( a1_ij * c } -fn eta_eff + Copy>(lambda: f64, zeta: D) -> D { +fn eta_eff + Copy>(lambda: f64, zeta: D) -> D { let inv_lambda = DVector::from(vec![ 1.0, 1.0 / lambda, @@ -287,16 +287,16 @@ fn eta_eff + Copy>(lambda: f64, zeta: D) -> D { zeta * (zeta * (zeta * (zeta * c[3] + c[2]) + c[1]) + c[0]) } -fn sutherland + Copy>(lambda: f64, epsilon_k: f64, zeta: D, x0: D) -> D { +fn sutherland + Copy>(lambda: f64, epsilon_k: f64, zeta: D, x0: D) -> D { let ef = eta_eff(lambda, zeta); (-ef * 0.5 + 1.0) * -12.0 * x0.powf(lambda) * epsilon_k / (lambda - 3.0) / (-ef + 1.0).powi(3) } -fn ilambda>(lambda: f64, x0: D) -> D { +fn ilambda>(lambda: f64, x0: D) -> D { -(x0.powf(3.0 - lambda) - 1.0) / (lambda - 3.0) } -fn jlambda>(lambda: f64, x0: D) -> D { +fn jlambda>(lambda: f64, x0: D) -> D { -(x0.powf(4.0 - lambda) * (lambda - 3.0) - x0.powf(3.0 - lambda) * (lambda - 4.0) - 1.0) / ((lambda - 3.0) * (lambda - 4.0)) } @@ -305,7 +305,7 @@ fn jlambda>(lambda: f64, x0: D) -> D { /// B is divided by the packing fraction /// /// \author Morten Hammer, February 2018 -fn b + Copy>(lambda: f64, epsilon_k: f64, zeta: D, x0: D, x0_eff: D) -> D { +fn b + Copy>(lambda: f64, epsilon_k: f64, zeta: D, x0: D, x0_eff: D) -> D { let ilambda = ilambda(lambda, x0_eff); let jlambda = jlambda(lambda, x0_eff); let denum = (-zeta + 1.0).powi(3); @@ -316,7 +316,7 @@ fn b + Copy>(lambda: f64, epsilon_k: f64, zeta: D, x0: D, x0_eff } #[inline] -fn combine_sutherland_and_b + Copy>( +fn combine_sutherland_and_b + Copy>( lambda: f64, epsilon_k: f64, zeta: D, @@ -329,7 +329,7 @@ fn combine_sutherland_and_b + Copy>( } #[expect(clippy::too_many_arguments)] -fn second_order_perturbation + Copy>( +fn second_order_perturbation + Copy>( parameters: &SaftVRQMiePars, alpha: &Alpha, x_s: &DVector, @@ -390,7 +390,7 @@ fn quantum_prefactor_second_order(lambda: f64) -> f64 { } #[expect(clippy::too_many_arguments)] -fn second_order_perturbation_ij + Copy>( +fn second_order_perturbation_ij + Copy>( lambda_a: f64, lambda_r: f64, epsilon_k: f64, @@ -452,7 +452,7 @@ fn second_order_perturbation_ij + Copy>( a2_ij * 0.5 * epsilon_k * c.powi(2) } -fn third_order_perturbation + Copy>( +fn third_order_perturbation + Copy>( parameters: &SaftVRQMiePars, alpha: &Alpha, x_s: &DVector, @@ -471,7 +471,7 @@ fn third_order_perturbation + Copy>( a3 } -fn third_order_perturbation_ij + Copy>( +fn third_order_perturbation_ij + Copy>( i: usize, j: usize, epsilon_k_eff: D, diff --git a/crates/feos/src/saftvrqmie/eos/hard_sphere.rs b/crates/feos/src/saftvrqmie/eos/hard_sphere.rs index 066a19465..5242072e0 100644 --- a/crates/feos/src/saftvrqmie/eos/hard_sphere.rs +++ b/crates/feos/src/saftvrqmie/eos/hard_sphere.rs @@ -62,7 +62,7 @@ const W_K21: [f64; 21] = [ impl SaftVRQMiePars { #[inline] - pub fn hs_diameter + Copy>(&self, temperature: D) -> DVector { + pub fn hs_diameter + Copy>(&self, temperature: D) -> DVector { DVector::from_fn(self.m.len(), |i, _| -> D { let sigma_eff = self.calc_sigma_eff_ij(i, i, temperature); self.hs_diameter_ij(i, i, temperature, sigma_eff) @@ -70,7 +70,7 @@ impl SaftVRQMiePars { } #[inline] - pub fn hs_diameter_ij + Copy>( + pub fn hs_diameter_ij + Copy>( &self, i: usize, j: usize, @@ -89,7 +89,7 @@ impl SaftVRQMiePars { d_hs } - pub fn zero_integrand + Copy>( + pub fn zero_integrand + Copy>( &self, i: usize, j: usize, @@ -118,13 +118,13 @@ impl SaftVRQMiePars { } #[inline] - pub fn epsilon_k_eff + Copy>(&self, temperature: D) -> DVector { + pub fn epsilon_k_eff + Copy>(&self, temperature: D) -> DVector { DVector::from_fn(self.m.len(), |i, _| -> D { self.calc_epsilon_k_eff_ij(i, i, temperature) }) } - pub fn calc_epsilon_k_eff_ij + Copy>( + pub fn calc_epsilon_k_eff_ij + Copy>( &self, i: usize, j: usize, @@ -146,13 +146,13 @@ impl SaftVRQMiePars { } #[inline] - pub fn sigma_eff + Copy>(&self, temperature: D) -> DVector { + pub fn sigma_eff + Copy>(&self, temperature: D) -> DVector { DVector::from_fn(self.m.len(), |i, _| -> D { self.calc_sigma_eff_ij(i, i, temperature) }) } - pub fn calc_sigma_eff_ij + Copy>( + pub fn calc_sigma_eff_ij + Copy>( &self, i: usize, j: usize, @@ -174,12 +174,17 @@ impl SaftVRQMiePars { } #[inline] - pub fn quantum_d_ij>(&self, i: usize, j: usize, temperature: D) -> D { + pub fn quantum_d_ij>( + &self, + i: usize, + j: usize, + temperature: D, + ) -> D { quantum_d_mass(self.mass_ij[(i, j)], temperature) } /// Feynman-Hibbs corrected potential - pub fn qmie_potential_ij + Copy>( + pub fn qmie_potential_ij + Copy>( &self, i: usize, j: usize, @@ -232,14 +237,14 @@ impl SaftVRQMiePars { } #[inline] -pub fn quantum_d_mass>(mass: f64, temperature: D) -> D { +pub fn quantum_d_mass>(mass: f64, temperature: D) -> D { temperature.recip() / mass * D_QM_PREFACTOR } pub struct HardSphere; impl HardSphere { - pub fn helmholtz_energy_density + Copy>( + pub fn helmholtz_energy_density + Copy>( &self, parameters: &SaftVRQMiePars, state: &StateHD, @@ -263,7 +268,7 @@ impl fmt::Display for HardSphere { } } -pub fn zeta + Copy>( +pub fn zeta + Copy>( m: &DVector, partial_density: &DVector, diameter: &DVector, @@ -279,7 +284,7 @@ pub fn zeta + Copy>( zeta } -pub fn zeta_23 + Copy>( +pub fn zeta_23 + Copy>( m: &DVector, molefracs: &DVector, diameter: &DVector, @@ -305,7 +310,7 @@ mod tests { #[test] fn test_quantum_d_mass() { let parameters = hydrogen_fh("1"); - let temperature = 26.7060; + let temperature = 26.7060_f64; let r = 3.5; let u0 = parameters.qmie_potential_ij(0, 0, r, temperature); let eps = 1.0e-5; @@ -320,7 +325,7 @@ mod tests { #[test] fn test_sigma_effective() { let parameters = hydrogen_fh("1"); - let temperature = 26.7060; + let temperature = 26.7060_f64; let sigma_eff = parameters.calc_sigma_eff_ij(0, 0, temperature); println!("{}", sigma_eff - 3.2540054024660556); assert!((sigma_eff - 3.2540054024660556).abs() < 5.0e-7) @@ -329,7 +334,7 @@ mod tests { #[test] fn test_eps_div_k_effective() { let parameters = hydrogen_fh("1"); - let temperature = 26.7060; + let temperature = 26.7060_f64; let epsilon_k_eff = parameters.calc_epsilon_k_eff_ij(0, 0, temperature); println!("{}", epsilon_k_eff - 21.654396207986697); assert!((epsilon_k_eff - 21.654396207986697).abs() < 1.0e-6) @@ -338,7 +343,7 @@ mod tests { #[test] fn test_zero_integrand() { let parameters = hydrogen_fh("1"); - let temperature = 26.706; + let temperature = 26.706_f64; let sigma_eff = parameters.calc_sigma_eff_ij(0, 0, temperature); let r0 = parameters.zero_integrand(0, 0, temperature, sigma_eff); println!("{}", r0 - 2.5265031901173732); diff --git a/crates/feos/src/saftvrqmie/eos/mod.rs b/crates/feos/src/saftvrqmie/eos/mod.rs index 9ec71818d..e77688b26 100644 --- a/crates/feos/src/saftvrqmie/eos/mod.rs +++ b/crates/feos/src/saftvrqmie/eos/mod.rs @@ -73,7 +73,7 @@ pub(crate) struct TemperatureDependentProperties { quantum_d_ij: DMatrix, } -impl + Copy> TemperatureDependentProperties { +impl + Copy> TemperatureDependentProperties { fn new(parameters: &SaftVRQMiePars, temperature: D) -> Self { let n = parameters.m.len(); let sigma_eff_ij = DMatrix::from_fn(n, n, |i, j| -> D { @@ -146,7 +146,7 @@ impl ResidualDyn for SaftVRQMie { self.parameters.pure.len() } - fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { + fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { let msigma3 = self .params .m @@ -154,7 +154,7 @@ impl ResidualDyn for SaftVRQMie { (msigma3.map(D::from).dot(molefracs) * FRAC_PI_6).recip() * self.options.max_eta } - fn reduced_helmholtz_energy_density_contributions + Copy>( + fn reduced_helmholtz_energy_density_contributions + Copy>( &self, state: &StateHD, ) -> Vec<(&'static str, D)> { diff --git a/crates/feos/src/saftvrqmie/eos/non_additive_hs.rs b/crates/feos/src/saftvrqmie/eos/non_additive_hs.rs index d2344123f..9029aca8c 100644 --- a/crates/feos/src/saftvrqmie/eos/non_additive_hs.rs +++ b/crates/feos/src/saftvrqmie/eos/non_additive_hs.rs @@ -9,7 +9,7 @@ use std::f64::consts::PI; pub struct NonAddHardSphere; impl NonAddHardSphere { - pub fn helmholtz_energy_density + Copy>( + pub fn helmholtz_energy_density + Copy>( &self, parameters: &SaftVRQMiePars, state: &StateHD, @@ -27,7 +27,7 @@ impl NonAddHardSphere { } } -pub fn reduced_non_additive_hs_energy + Copy>( +pub fn reduced_non_additive_hs_energy + Copy>( parameters: &SaftVRQMiePars, d_hs_ij: &DMatrix, d_hs_add_ij: &DMatrix, diff --git a/crates/feos/src/uvtheory/eos/bh/attractive_perturbation.rs b/crates/feos/src/uvtheory/eos/bh/attractive_perturbation.rs index e55682c8a..b817306bf 100644 --- a/crates/feos/src/uvtheory/eos/bh/attractive_perturbation.rs +++ b/crates/feos/src/uvtheory/eos/bh/attractive_perturbation.rs @@ -40,7 +40,7 @@ pub(super) struct AttractivePerturbation; impl AttractivePerturbation { /// Helmholtz energy for attractive perturbation, eq. 52 - pub fn helmholtz_energy_density + Copy>( + pub fn helmholtz_energy_density + Copy>( &self, parameters: &UVTheoryPars, state: &StateHD, @@ -74,11 +74,11 @@ impl AttractivePerturbation { } } -fn delta_b12u>(t_x: D, mean_field_constant_x: D, weighted_sigma3_ij: D) -> D { +fn delta_b12u>(t_x: D, mean_field_constant_x: D, weighted_sigma3_ij: D) -> D { -mean_field_constant_x / t_x * 2.0 * PI * weighted_sigma3_ij } -fn residual_virial_coefficient + Copy>( +fn residual_virial_coefficient + Copy>( p: &UVTheoryPars, x: &DVector, t: D, @@ -95,7 +95,7 @@ fn residual_virial_coefficient + Copy>( delta_b2bar } -fn correlation_integral_bh + Copy>( +fn correlation_integral_bh + Copy>( rho_x: D, mean_field_constant_x: D, rep_x: D, @@ -110,7 +110,7 @@ fn correlation_integral_bh + Copy>( /// U-fraction according to Barker-Henderson division. /// Eq. 15 -fn u_fraction_bh + Copy>(rep_x: D, reduced_density: D, one_fluid_beta: D) -> D { +fn u_fraction_bh + Copy>(rep_x: D, reduced_density: D, one_fluid_beta: D) -> D { let mut c = [D::zero(); 4]; let inv_rep = rep_x.recip(); for i in 0..4 { @@ -124,11 +124,11 @@ fn u_fraction_bh + Copy>(rep_x: D, reduced_density: D, one_fluid /// Activation function used for u-fraction according to Barker-Henderson division. /// Eq. 16 -fn activation + Copy>(c: D, one_fluid_beta: D) -> D { +fn activation + Copy>(c: D, one_fluid_beta: D) -> D { one_fluid_beta * c.sqrt() / (one_fluid_beta.powi(2) * c + 1.0).sqrt() } -fn one_fluid_properties + Copy>( +fn one_fluid_properties + Copy>( p: &UVTheoryPars, x: &DVector, t: D, @@ -164,7 +164,7 @@ fn one_fluid_properties + Copy>( ) } -fn coefficients_bh + Copy>(rep: D, att: D, d: D) -> [D; 3] { +fn coefficients_bh + Copy>(rep: D, att: D, d: D) -> [D; 3] { let c11 = d.powd(-rep + 6.0) * ((D::one() * 2.0f64).powd(-rep + 3.0) - d.powd(rep - 3.0)) / (-rep + 3.0) + (-d.powi(3) * 8.0 + 1.0) / 24.0; @@ -182,14 +182,14 @@ fn coefficients_bh + Copy>(rep: D, att: D, d: D) -> [D; 3] { [c1, c2, c3] } -fn delta_b2 + Copy>(reduced_temperature: D, rep: f64, att: f64) -> D { +fn delta_b2 + Copy>(reduced_temperature: D, rep: f64, att: f64) -> D { let rc = 5.0; let alpha = mean_field_constant(rep, att, rc); let yeff = y_eff(reduced_temperature, rep, att); -(yeff * (rc.powi(3) - 1.0) / 3.0 + reduced_temperature.recip() * alpha) * 2.0 * PI } -fn y_eff + Copy>(reduced_temperature: D, rep: f64, att: f64) -> D { +fn y_eff + Copy>(reduced_temperature: D, rep: f64, att: f64) -> D { // optimize: move this part to parameter initialization let rc = 5.0; let rs = 1.0; diff --git a/crates/feos/src/uvtheory/eos/bh/hard_sphere.rs b/crates/feos/src/uvtheory/eos/bh/hard_sphere.rs index 4b1dc97b8..27002073b 100644 --- a/crates/feos/src/uvtheory/eos/bh/hard_sphere.rs +++ b/crates/feos/src/uvtheory/eos/bh/hard_sphere.rs @@ -19,7 +19,7 @@ const BH_CONSTANTS_ETA_A: [[f64; 4]; 4] = [ /// Dimensionless Hard-sphere diameter according to Barker-Henderson division. /// Eq. S23 and S24. impl BarkerHenderson { - pub fn diameter_bh + Copy>( + pub fn diameter_bh + Copy>( parameters: &UVTheoryPars, temperature: D, ) -> DVector { @@ -39,7 +39,7 @@ impl BarkerHenderson { } } -pub(super) fn packing_fraction + Copy>( +pub(super) fn packing_fraction + Copy>( partial_density: &DVector, diameter: &DVector, ) -> D { @@ -48,7 +48,7 @@ pub(super) fn packing_fraction + Copy>( }) } -pub(super) fn packing_fraction_b + Copy>( +pub(super) fn packing_fraction_b + Copy>( parameters: &UVTheoryPars, diameter: &DVector, eta: D, @@ -68,7 +68,7 @@ pub(super) fn packing_fraction_b + Copy>( }) } -pub(super) fn packing_fraction_a + Copy>( +pub(super) fn packing_fraction_a + Copy>( parameters: &UVTheoryPars, diameter: &DVector, eta: D, diff --git a/crates/feos/src/uvtheory/eos/bh/mod.rs b/crates/feos/src/uvtheory/eos/bh/mod.rs index 3a678dd98..b34c8aa0c 100644 --- a/crates/feos/src/uvtheory/eos/bh/mod.rs +++ b/crates/feos/src/uvtheory/eos/bh/mod.rs @@ -12,7 +12,7 @@ mod reference_perturbation; pub struct BarkerHenderson; impl BarkerHenderson { - pub fn residual_helmholtz_energy_contributions + Copy>( + pub fn residual_helmholtz_energy_contributions + Copy>( &self, parameters: &UVTheoryPars, state: &StateHD, diff --git a/crates/feos/src/uvtheory/eos/bh/reference_perturbation.rs b/crates/feos/src/uvtheory/eos/bh/reference_perturbation.rs index 268642d3f..d6360d9f2 100644 --- a/crates/feos/src/uvtheory/eos/bh/reference_perturbation.rs +++ b/crates/feos/src/uvtheory/eos/bh/reference_perturbation.rs @@ -10,7 +10,7 @@ pub(super) struct ReferencePerturbation; impl ReferencePerturbation { /// Helmholtz energy for perturbation reference (Mayer-f), eq. 29 - pub fn helmholtz_energy_density + Copy>( + pub fn helmholtz_energy_density + Copy>( &self, parameters: &UVTheoryPars, state: &StateHD, diff --git a/crates/feos/src/uvtheory/eos/mod.rs b/crates/feos/src/uvtheory/eos/mod.rs index 1957af6e8..c6d98cb86 100644 --- a/crates/feos/src/uvtheory/eos/mod.rs +++ b/crates/feos/src/uvtheory/eos/mod.rs @@ -70,12 +70,12 @@ impl ResidualDyn for UVTheory { self.parameters.pure.len() } - fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { + fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { let sigma3 = self.params.sigma.map(|v| v.powi(3)); (sigma3.map(D::from).dot(molefracs) * FRAC_PI_6).recip() * self.options.max_eta } - fn reduced_helmholtz_energy_density_contributions + Copy>( + fn reduced_helmholtz_energy_density_contributions + Copy>( &self, state: &feos_core::StateHD, ) -> Vec<(&'static str, D)> { diff --git a/crates/feos/src/uvtheory/eos/wca/attractive_perturbation.rs b/crates/feos/src/uvtheory/eos/wca/attractive_perturbation.rs index 1e7e8bc5a..ed6f96a51 100644 --- a/crates/feos/src/uvtheory/eos/wca/attractive_perturbation.rs +++ b/crates/feos/src/uvtheory/eos/wca/attractive_perturbation.rs @@ -72,7 +72,7 @@ pub struct AttractivePerturbation; impl AttractivePerturbation { /// Helmholtz energy for attractive perturbation, eq. 52 - pub fn helmholtz_energy_density + Copy>( + pub fn helmholtz_energy_density + Copy>( &self, parameters: &UVTheoryPars, state: &StateHD, @@ -107,7 +107,7 @@ impl AttractivePerturbation { } // (S43) & (S53) -fn delta_b12u + Copy>( +fn delta_b12u + Copy>( t_x: D, mean_field_constant_x: D, weighted_sigma3_ij: D, @@ -120,7 +120,7 @@ fn delta_b12u + Copy>( * weighted_sigma3_ij } -fn residual_virial_coefficient + Copy>( +fn residual_virial_coefficient + Copy>( p: &UVTheoryPars, x: &DVector, t: D, @@ -144,7 +144,7 @@ fn residual_virial_coefficient + Copy>( delta_b2bar } -fn correlation_integral_wca + Copy>( +fn correlation_integral_wca + Copy>( rho_x: D, mean_field_constant_x: D, rep_x: D, @@ -162,13 +162,13 @@ fn correlation_integral_wca + Copy>( /// U-fraction according to Barker-Henderson division. /// Eq. 15 -fn u_fraction_wca + Copy>(rep_x: D, reduced_density: D) -> D { +fn u_fraction_wca + Copy>(rep_x: D, reduced_density: D) -> D { (reduced_density * CU_WCA[0] + reduced_density.powi(2) * (rep_x.recip() * CU_WCA[2] + CU_WCA[1])) .tanh() } -pub(super) fn one_fluid_properties + Copy>( +pub(super) fn one_fluid_properties + Copy>( p: &UVTheoryPars, x: &DVector, t: D, @@ -209,7 +209,7 @@ pub(super) fn one_fluid_properties + Copy>( } // Coefficients for IWCA from eq. (S55) -fn coefficients_wca + Copy>(rep: D, att: D, d: D) -> [D; 6] { +fn coefficients_wca + Copy>(rep: D, att: D, d: D) -> [D; 6] { let rep_inv = rep.recip(); let rs_x = (rep / att).powd((rep - att).recip()); let tau_x = -d + rs_x; @@ -241,7 +241,7 @@ fn coefficients_wca + Copy>(rep: D, att: D, d: D) -> [D; 6] { [c1, c2, c3, c4, c5, c6] } -fn delta_b2 + Copy>(reduced_temperature: D, rep: f64, att: f64, q: D) -> D { +fn delta_b2 + Copy>(reduced_temperature: D, rep: f64, att: f64, q: D) -> D { let rm = (rep / att).powf(1.0 / (rep - att)); // Check mixing rule!! let rc = 5.0; let alpha = mean_field_constant(rep, att, rc); @@ -253,7 +253,7 @@ fn delta_b2 + Copy>(reduced_temperature: D, rep: f64, att: f64, * PI } -fn y_eff + Copy>(reduced_temperature: D, rep: f64, att: f64) -> D { +fn y_eff + Copy>(reduced_temperature: D, rep: f64, att: f64) -> D { // optimize: move this part to parameter initialization let rc = 5.0; let rs = (rep / att).powf(1.0 / (rep - att)); diff --git a/crates/feos/src/uvtheory/eos/wca/attractive_perturbation_uvb3.rs b/crates/feos/src/uvtheory/eos/wca/attractive_perturbation_uvb3.rs index b6f1772de..b6d36f9fb 100644 --- a/crates/feos/src/uvtheory/eos/wca/attractive_perturbation_uvb3.rs +++ b/crates/feos/src/uvtheory/eos/wca/attractive_perturbation_uvb3.rs @@ -85,7 +85,7 @@ pub(super) struct AttractivePerturbationB3; impl AttractivePerturbationB3 { /// Helmholtz energy for attractive perturbation - pub fn helmholtz_energy_density + Copy>( + pub fn helmholtz_energy_density + Copy>( &self, parameters: &UVTheoryPars, state: &StateHD, @@ -128,7 +128,7 @@ impl AttractivePerturbationB3 { } } -fn delta_b12u + Copy>( +fn delta_b12u + Copy>( t_x: D, mean_field_constant_x: D, weighted_sigma3_ij: D, @@ -141,7 +141,7 @@ fn delta_b12u + Copy>( * weighted_sigma3_ij } -fn residual_virial_coefficient + Copy>( +fn residual_virial_coefficient + Copy>( p: &UVTheoryPars, x: &DVector, t: D, @@ -163,7 +163,7 @@ fn residual_virial_coefficient + Copy>( delta_b2bar } -fn residual_third_virial_coefficient + Copy>( +fn residual_third_virial_coefficient + Copy>( p: &UVTheoryPars, x: &DVector, t: D, @@ -190,7 +190,7 @@ fn residual_third_virial_coefficient + Copy>( } delta_b3bar } -fn correlation_integral_wca + Copy>( +fn correlation_integral_wca + Copy>( rho_x: D, mean_field_constant_x: D, rep_x: D, @@ -207,7 +207,7 @@ fn correlation_integral_wca + Copy>( } /// U-fraction with low temperature correction omega -fn u_fraction_wca + Copy>(rep_x: D, reduced_density: D, t_x: D) -> D { +fn u_fraction_wca + Copy>(rep_x: D, reduced_density: D, t_x: D) -> D { let omega = if t_x.re() < 175.0 { (-t_x * CU_WCA[5] * (reduced_density - CU_WCA[6]).powi(2)).exp() * ((t_x * CU_WCA[7]).tanh().recip() - 1.0).powi(2) @@ -221,7 +221,7 @@ fn u_fraction_wca + Copy>(rep_x: D, reduced_density: D, t_x: D) } // Coefficients for IWCA -fn coefficients_wca + Copy>(rep: D, att: D, d: D) -> [D; 6] { +fn coefficients_wca + Copy>(rep: D, att: D, d: D) -> [D; 6] { let rep_inv = rep.recip(); let rs_x = (rep / att).powd((rep - att).recip()); let tau_x = -d + rs_x; @@ -259,7 +259,7 @@ fn factorial(num: u64) -> u64 { (1..=num).product() } -fn delta_b2 + Copy>(reduced_temperature: D, rep: f64, att: f64, q: D) -> D { +fn delta_b2 + Copy>(reduced_temperature: D, rep: f64, att: f64, q: D) -> D { let rm = (rep / att).powd((rep - att).recip()); let beta = reduced_temperature.recip(); let b20 = q.powi(3) * 2.0 / 3.0 * PI; @@ -293,7 +293,7 @@ fn delta_b2 + Copy>(reduced_temperature: D, rep: f64, att: f64, (b20 - rm.powi(3) * 2.0 / 3.0 * PI - c1) * y - sum_beta * c2 - beta * c3 - beta.powi(2) * c4 } -fn delta_b31u + Copy>( +fn delta_b31u + Copy>( t_x: D, weighted_sigma3_ij: D, rm_x: D, @@ -311,7 +311,7 @@ fn delta_b31u + Copy>( t_x.recip() * 4.0 * mie_prefactor(rep_x, att_x) * PI * k1 * weighted_sigma3_ij.powi(2) } -fn delta_b3 + Copy>( +fn delta_b3 + Copy>( t_x: D, rm_x: f64, rep_x: f64, diff --git a/crates/feos/src/uvtheory/eos/wca/hard_sphere.rs b/crates/feos/src/uvtheory/eos/wca/hard_sphere.rs index 4b7bd916c..a985e2f31 100644 --- a/crates/feos/src/uvtheory/eos/wca/hard_sphere.rs +++ b/crates/feos/src/uvtheory/eos/wca/hard_sphere.rs @@ -49,7 +49,7 @@ pub(super) const WCA_CONSTANTS_ETA_B_UVB3: [[f64; 2]; 3] = [ /// Dimensionless Hard-sphere diameter according to Weeks-Chandler-Andersen division. impl WeeksChandlerAndersen { - pub fn diameter_wca + Copy>( + pub fn diameter_wca + Copy>( parameters: &UVTheoryPars, temperature: D, ) -> DVector { @@ -73,7 +73,7 @@ impl WeeksChandlerAndersen { } } -pub(super) fn dimensionless_diameter_q_wca + Copy>( +pub(super) fn dimensionless_diameter_q_wca + Copy>( t_x: D, rep_x: D, att_x: D, @@ -103,7 +103,7 @@ pub(super) fn dimensionless_diameter_q_wca + Copy>( * rs } -pub(super) fn packing_fraction + Copy>( +pub(super) fn packing_fraction + Copy>( partial_density: &DVector, diameter: &DVector, ) -> D { @@ -113,7 +113,7 @@ pub(super) fn packing_fraction + Copy>( } #[inline] -pub(super) fn dimensionless_length_scale + Copy>( +pub(super) fn dimensionless_length_scale + Copy>( parameters: &UVTheoryPars, temperature: D, ) -> DVector { @@ -133,7 +133,7 @@ pub(super) fn dimensionless_length_scale + Copy>( } #[inline] -pub(super) fn packing_fraction_b + Copy>( +pub(super) fn packing_fraction_b + Copy>( parameters: &UVTheoryPars, eta: D, temperature: D, @@ -155,7 +155,7 @@ pub(super) fn packing_fraction_b + Copy>( }) } -pub(super) fn packing_fraction_b_uvb3 + Copy>( +pub(super) fn packing_fraction_b_uvb3 + Copy>( parameters: &UVTheoryPars, eta: D, temperature: D, @@ -177,7 +177,7 @@ pub(super) fn packing_fraction_b_uvb3 + Copy>( }) } -pub(super) fn packing_fraction_a + Copy>( +pub(super) fn packing_fraction_a + Copy>( parameters: &UVTheoryPars, eta: D, temperature: D, @@ -206,7 +206,7 @@ pub(super) fn packing_fraction_a + Copy>( }) } -pub(super) fn packing_fraction_a_uvb3 + Copy>( +pub(super) fn packing_fraction_a_uvb3 + Copy>( parameters: &UVTheoryPars, eta: D, temperature: D, diff --git a/crates/feos/src/uvtheory/eos/wca/mod.rs b/crates/feos/src/uvtheory/eos/wca/mod.rs index bcd76477f..5a26810f3 100644 --- a/crates/feos/src/uvtheory/eos/wca/mod.rs +++ b/crates/feos/src/uvtheory/eos/wca/mod.rs @@ -17,7 +17,7 @@ use reference_perturbation_uvb3::ReferencePerturbationB3; pub struct WeeksChandlerAndersen; impl WeeksChandlerAndersen { - pub fn residual_helmholtz_energy_contributions + Copy>( + pub fn residual_helmholtz_energy_contributions + Copy>( &self, parameters: &UVTheoryPars, state: &StateHD, @@ -42,7 +42,7 @@ impl WeeksChandlerAndersen { pub struct WeeksChandlerAndersenB3; impl WeeksChandlerAndersenB3 { - pub fn residual_helmholtz_energy_contributions + Copy>( + pub fn residual_helmholtz_energy_contributions + Copy>( &self, parameters: &UVTheoryPars, state: &StateHD, diff --git a/crates/feos/src/uvtheory/eos/wca/reference_perturbation.rs b/crates/feos/src/uvtheory/eos/wca/reference_perturbation.rs index a60551d40..84a046a28 100644 --- a/crates/feos/src/uvtheory/eos/wca/reference_perturbation.rs +++ b/crates/feos/src/uvtheory/eos/wca/reference_perturbation.rs @@ -12,7 +12,7 @@ pub(super) struct ReferencePerturbation; impl ReferencePerturbation { /// Helmholtz energy for perturbation reference (Mayer-f), eq. 29 - pub fn helmholtz_energy_density + Copy>( + pub fn helmholtz_energy_density + Copy>( &self, parameters: &UVTheoryPars, state: &StateHD, diff --git a/crates/feos/src/uvtheory/eos/wca/reference_perturbation_uvb3.rs b/crates/feos/src/uvtheory/eos/wca/reference_perturbation_uvb3.rs index 525cbceb4..b1391feae 100644 --- a/crates/feos/src/uvtheory/eos/wca/reference_perturbation_uvb3.rs +++ b/crates/feos/src/uvtheory/eos/wca/reference_perturbation_uvb3.rs @@ -13,7 +13,7 @@ pub(super) struct ReferencePerturbationB3; impl ReferencePerturbationB3 { /// Helmholtz energy for perturbation reference (Mayer-f), eq. 29 - pub fn helmholtz_energy_density + Copy>( + pub fn helmholtz_energy_density + Copy>( &self, parameters: &UVTheoryPars, state: &StateHD, diff --git a/crates/feos/src/uvtheory/parameters.rs b/crates/feos/src/uvtheory/parameters.rs index 102360b59..67eda3a22 100644 --- a/crates/feos/src/uvtheory/parameters.rs +++ b/crates/feos/src/uvtheory/parameters.rs @@ -34,12 +34,12 @@ const CD_BH: SMatrix = matrix![ 3.71527116894441E-03, 5.05384813757953E-03, 4.91003312452622E-02]; #[inline] -pub fn mie_prefactor + Copy>(rep: D, att: D) -> D { +pub fn mie_prefactor + Copy>(rep: D, att: D) -> D { rep / (rep - att) * (rep / att).powd(att / (rep - att)) } #[inline] -pub fn mean_field_constant + Copy>(rep: D, att: D, x: D) -> D { +pub fn mean_field_constant + Copy>(rep: D, att: D, x: D) -> D { mie_prefactor(rep, att) * (x.powd(-att + 3.0) / (att - 3.0) - x.powd(-rep + 3.0) / (rep - 3.0)) } @@ -123,11 +123,11 @@ fn bh_coefficients(rep: f64, att: f64) -> [f64; 5] { } impl HardSphereProperties for UVTheoryPars { - fn monomer_shape + Copy>(&self, _: D) -> MonomerShape<'_, D> { + fn monomer_shape + Copy>(&self, _: D) -> MonomerShape<'_, D> { MonomerShape::Spherical(self.sigma.len()) } - fn hs_diameter + Copy>(&self, temperature: D) -> DVector { + fn hs_diameter + Copy>(&self, temperature: D) -> DVector { match self.perturbation { Perturbation::BarkerHenderson => BarkerHenderson::diameter_bh(self, temperature), Perturbation::WeeksChandlerAndersen => { diff --git a/docs/rustguide/core/equation_of_state.rst b/docs/rustguide/core/equation_of_state.rst index 92ec9bacf..c087dfaab 100644 --- a/docs/rustguide/core/equation_of_state.rst +++ b/docs/rustguide/core/equation_of_state.rst @@ -69,7 +69,7 @@ The non-object-safe trait to do that is the ``HelmholtzEnergyDual`` trait: .. code-block:: rust // This trait cannot be made into a trait object - pub trait HelmholtzEnergyDual> { + pub trait HelmholtzEnergyDual> { fn helmholtz_energy(&self, state: &StateHD) -> D; } @@ -105,7 +105,7 @@ The residual Helmholtz energy is then computed as sum of all contributions: /// /// For simple equations of state (see e.g. `PengRobinson`) it might be /// easier to overwrite this function instead of implementing `residual`. - fn evaluate_residual>(&self, state: &StateHD) -> D + fn evaluate_residual>(&self, state: &StateHD) -> D where dyn HelmholtzEnergy: HelmholtzEnergyDual, { @@ -156,7 +156,7 @@ The ``IdealGasContribution`` supertrait is assembled from ``IdealGasContribution /// Ideal gas Helmholtz energy contribution that can /// be evaluated using generalized (hyper) dual numbers. - pub trait IdealGasContributionDual> { + pub trait IdealGasContributionDual> { /// The thermal de Broglie wavelength of each component in the form $\ln\left(\frac{\Lambda^3}{\AA^3}\right)$ fn de_broglie_wavelength(&self, temperature: D, components: usize) -> Array1; diff --git a/docs/rustguide/core/state.rst b/docs/rustguide/core/state.rst index 29703ab8a..bdd58b5a9 100644 --- a/docs/rustguide/core/state.rst +++ b/docs/rustguide/core/state.rst @@ -102,7 +102,7 @@ The residual entropy is defined as We need the first derivative of the residual Helmholtz energy with respect to temperature. The first derivative can be computed using a dual number consisting of a real part and *one non-real part* which is a ``Dual64`` struct. -Looking at the signature of the Helmholtz energy function, we see that it takes a ``StateHD`` as input (not a ``State``), where ``D`` is a generalized dual number (``D: DualNum``): +Looking at the signature of the Helmholtz energy function, we see that it takes a ``StateHD`` as input (not a ``State``), where ``D`` is a generalized dual number (``D: DualNum``): .. code-block:: rust @@ -121,7 +121,7 @@ Looking at the signature of the Helmholtz energy function, we see that it takes /// Properties are stored as generalized (hyper) dual numbers which allows /// for automatic differentiation. #[derive(Clone, Debug)] - pub struct StateHD> { + pub struct StateHD> { /// temperature in Kelvin pub temperature: D, /// volume in Angstrom^3 diff --git a/py-feos/src/ad/mod.rs b/py-feos/src/ad/mod.rs index c18525a68..fb257d559 100644 --- a/py-feos/src/ad/mod.rs +++ b/py-feos/src/ad/mod.rs @@ -482,8 +482,8 @@ macro_rules! impl_evaluate_gradients { Bound<'py, PyArray1>, ) where - $(R::Lifted>: Sync,)* - R::Lifted>: Sync + $(R::Lifted>: Sync,)* + R::Lifted>: Sync { let (value, grad, status) = if let Ok(pars) = parameters.extract::>() { diff --git a/py-feos/src/user_defined.rs b/py-feos/src/user_defined.rs index 12792059d..a429bd5d9 100644 --- a/py-feos/src/user_defined.rs +++ b/py-feos/src/user_defined.rs @@ -30,7 +30,7 @@ macro_rules! impl_ideal_gas { "Ideal gas (Python)" } - fn ln_lambda3 + Copy>(&self, temperature: D) -> D { + fn ln_lambda3 + Copy>(&self, temperature: D) -> D { let mut result = D::zero(); $( @@ -103,7 +103,7 @@ macro_rules! impl_residual { }) } - fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { + fn compute_max_density + Copy>(&self, molefracs: &DVector) -> D { let mut rho = D::zero(); $( @@ -123,7 +123,7 @@ macro_rules! impl_residual { panic!("compute_max_density: input data type not understood") } - fn reduced_helmholtz_energy_density_contributions + Copy + >( + fn reduced_helmholtz_energy_density_contributions + Copy + >( &self, state: &StateHD, ) -> Vec<(&'static str, D)> { @@ -250,7 +250,7 @@ macro_rules! impl_dual_state_helmholtz_energy { // No definition of dual number necessary for f64 state!(PyStateF, f64, f64); -dual_number!(PyReal64, Real, f64); +dual_number!(PyReal64, Real, f64); impl_dual_state_helmholtz_energy!(PyStateD, PyDual64, Dual64, f64); @@ -258,73 +258,63 @@ dual_number!(PyDualVec3, DualSVec64<3>, f64); impl_dual_state_helmholtz_energy!( PyStateDualDualVec3, PyDualDualVec3, - Dual, f64>, + Dual>, PyDualVec3 ); impl_dual_state_helmholtz_energy!(PyStateHD, PyHyperDual64, HyperDual64, f64); impl_dual_state_helmholtz_energy!(PyStateD2, PyDual2_64, Dual2_64, f64); impl_dual_state_helmholtz_energy!(PyStateD2Vec2, PyDual2SVec64_2, Dual2SVec64<2>, f64); impl_dual_state_helmholtz_energy!(PyStateD3, PyDual3_64, Dual3_64, f64); -impl_dual_state_helmholtz_energy!(PyStateHDD, PyHyperDualDual64, HyperDual, PyDual64); +impl_dual_state_helmholtz_energy!(PyStateHDD, PyHyperDualDual64, HyperDual, PyDual64); dual_number!(PyDualVec2, DualSVec64<2>, f64); impl_dual_state_helmholtz_energy!( PyStateHDDVec2, PyHyperDualVec2, - HyperDual, f64>, + HyperDual>, PyDualVec2 ); impl_dual_state_helmholtz_energy!( PyStateHDDVec3, PyHyperDualVec3, - HyperDual, f64>, + HyperDual>, PyDualVec3 ); -impl_dual_state_helmholtz_energy!( - PyStateD2D, - PyDual2Dual64, - Dual2, - PyDual64 -); -impl_dual_state_helmholtz_energy!( - PyStateD3D, - PyDual3Dual64, - Dual3, - PyDual64 -); +impl_dual_state_helmholtz_energy!(PyStateD2D, PyDual2Dual64, Dual2, PyDual64); +impl_dual_state_helmholtz_energy!(PyStateD3D, PyDual3Dual64, Dual3, PyDual64); impl_dual_state_helmholtz_energy!( PyStateD3DVec2, PyDual3DualVec2, - Dual3, f64>, + Dual3>, PyDualVec2 ); impl_dual_state_helmholtz_energy!( PyStateD3DVec3, PyDual3DualVec3, - Dual3, f64>, + Dual3>, PyDualVec3 ); impl_ideal_gas!( - PyReal64, Real; + PyReal64, Real; PyDual64, Dual64; PyDualDualVec3, - Dual, f64>; + Dual>; PyHyperDual64, HyperDual64; PyDual2_64, Dual2_64; PyDual3_64, Dual3_64; - PyHyperDualDual64, HyperDual; + PyHyperDualDual64, HyperDual; PyHyperDualVec2, - HyperDual, f64>; + HyperDual>; PyHyperDualVec3, - HyperDual, f64>; + HyperDual>; PyDual2Dual64, - Dual2; + Dual2; PyDual3Dual64, - Dual3; + Dual3; PyDual3DualVec2, - Dual3, f64>; + Dual3>; PyDual3DualVec3, - Dual3, f64> + Dual3> ); impl_residual!( @@ -332,28 +322,28 @@ impl_residual!( PyStateD, PyDual64, Dual64; PyStateDualDualVec3, PyDualDualVec3, - Dual, f64>; + Dual>; PyStateHD, PyHyperDual64, HyperDual64; PyStateD2, PyDual2_64, Dual2_64; PyStateD2Vec2, PyDual2SVec64_2, Dual2SVec64<2>; PyStateD3, PyDual3_64, Dual3_64; - PyStateHDD, PyHyperDualDual64, HyperDual; + PyStateHDD, PyHyperDualDual64, HyperDual; PyStateHDDVec2, PyHyperDualVec2, - HyperDual, f64>; + HyperDual>; PyStateHDDVec3, PyHyperDualVec3, - HyperDual, f64>; + HyperDual>; PyStateD2D, PyDual2Dual64, - Dual2; + Dual2; PyStateD3D, PyDual3Dual64, - Dual3; + Dual3; PyStateD3DVec2, PyDual3DualVec2, - Dual3, f64>; + Dual3>; PyStateD3DVec3, PyDual3DualVec3, - Dual3, f64> + Dual3> );