-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathcache.rs
More file actions
47 lines (44 loc) · 1.6 KB
/
Copy pathcache.rs
File metadata and controls
47 lines (44 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use nalgebra::allocator::Allocator;
use nalgebra::{DefaultAllocator, Dim, OVector, Scalar};
use quantity::*;
use std::ops::Sub;
use std::sync::OnceLock;
type Diff<T1, T2> = <T1 as Sub<T2>>::Output;
#[derive(Clone, Debug)]
#[expect(clippy::type_complexity)]
pub struct Cache<D: Scalar, N: Dim>
where
DefaultAllocator: Allocator<N>,
{
pub a: OnceLock<MolarEnergy<D>>,
pub da_dt: OnceLock<MolarEntropy<D>>,
pub da_dv: OnceLock<Pressure<D>>,
pub da_dn: OnceLock<MolarEnergy<OVector<D, N>>>,
pub d2a_dt2: OnceLock<Quantity<D, Diff<_MolarEntropy, _Temperature>>>,
pub d2a_dv2: OnceLock<Quantity<D, Diff<_Pressure, _MolarVolume>>>,
pub d2a_dtdv: OnceLock<Quantity<D, Diff<_Pressure, _Temperature>>>,
pub d2a_dndt: OnceLock<Quantity<OVector<D, N>, Diff<_MolarEnergy, _Temperature>>>,
pub d2a_dndv: OnceLock<Quantity<OVector<D, N>, Diff<_Energy, _Volume>>>,
pub d3a_dt3: OnceLock<Quantity<D, Diff<Diff<_MolarEntropy, _Temperature>, _Temperature>>>,
pub d3a_dv3: OnceLock<Quantity<D, Diff<Diff<_Pressure, _MolarVolume>, _MolarVolume>>>,
}
impl<D: Scalar + Copy, N: Dim> Cache<D, N>
where
DefaultAllocator: Allocator<N>,
{
pub fn new() -> Self {
Self {
a: OnceLock::new(),
da_dt: OnceLock::new(),
da_dv: OnceLock::new(),
da_dn: OnceLock::new(),
d2a_dt2: OnceLock::new(),
d2a_dv2: OnceLock::new(),
d2a_dtdv: OnceLock::new(),
d2a_dndt: OnceLock::new(),
d2a_dndv: OnceLock::new(),
d3a_dt3: OnceLock::new(),
d3a_dv3: OnceLock::new(),
}
}
}