|
1 | 1 | use crate::parameters::PcSaftParameters; |
2 | 2 | use feos_core::{EosError, HelmholtzEnergyDual, StateHD}; |
3 | 3 | use ndarray::*; |
4 | | -use ndarray_linalg::Norm; |
| 4 | +use num_dual::linalg::{norm, LU}; |
5 | 5 | use num_dual::*; |
6 | 6 | use std::f64::consts::{FRAC_PI_3, PI}; |
7 | 7 | use std::fmt; |
@@ -92,10 +92,7 @@ pub(crate) fn assoc_site_frac_a<D: DualNum<f64>>(deltarho: D, na: f64) -> D { |
92 | 92 | } |
93 | 93 | } |
94 | 94 |
|
95 | | -impl<D: DualNum<f64> + ScalarOperand> HelmholtzEnergyDual<D> for CrossAssociation |
96 | | -where |
97 | | - Array2<D>: SolveDual<D>, |
98 | | -{ |
| 95 | +impl<D: DualNum<f64> + ScalarOperand> HelmholtzEnergyDual<D> for CrossAssociation { |
99 | 96 | fn helmholtz_energy(&self, state: &StateHD<D>) -> D { |
100 | 97 | let p = &self.parameters; |
101 | 98 |
|
@@ -145,7 +142,6 @@ pub fn helmholtz_energy_density_cross_association<S, D: DualNum<f64> + ScalarOpe |
145 | 142 | ) -> Result<D, EosError> |
146 | 143 | where |
147 | 144 | S: Data<Elem = D>, |
148 | | - Array2<D>: SolveDual<D>, |
149 | 145 | { |
150 | 146 | // check if density is close to 0 |
151 | 147 | if density.sum().re() < f64::EPSILON { |
@@ -224,10 +220,7 @@ fn newton_step_cross_association<D: DualNum<f64> + ScalarOperand>( |
224 | 220 | nb: &Array1<f64>, |
225 | 221 | rho: &Array1<D>, |
226 | 222 | tol: f64, |
227 | | -) -> Result<bool, EosError> |
228 | | -where |
229 | | - Array2<D>: SolveDual<D>, |
230 | | -{ |
| 223 | +) -> Result<bool, EosError> { |
231 | 224 | // gradient |
232 | 225 | let mut g: Array1<D> = Array::zeros(2 * p.nassoc); |
233 | 226 | // Hessian |
@@ -259,10 +252,10 @@ where |
259 | 252 | } |
260 | 253 |
|
261 | 254 | // Newton step |
262 | | - x.assign(&(&*x - &h.solve(&g)?)); |
| 255 | + x.assign(&(&*x - &LU::new(h)?.solve(&g))); |
263 | 256 |
|
264 | 257 | // check convergence |
265 | | - Ok(g.map(D::re).norm() < tol) |
| 258 | + Ok(norm(&g.map(D::re)) < tol) |
266 | 259 | } |
267 | 260 |
|
268 | 261 | #[cfg(test)] |
|
0 commit comments