Skip to main content

feos/pets/
parameters.rs

1use feos_core::parameter::Parameters;
2use serde::{Deserialize, Serialize};
3
4/// PeTS parameters for a pure substance.
5#[derive(Serialize, Deserialize, Debug, Clone)]
6pub struct PetsRecord {
7    /// Segment diameter in units of Angstrom
8    pub sigma: f64,
9    /// Energetic parameter in units of Kelvin
10    pub epsilon_k: f64,
11}
12
13impl PetsRecord {
14    /// New PeTS parameters for a pure substance.
15    ///
16    /// # Example
17    ///
18    /// ```
19    /// use feos::pets::PetsRecord;
20    /// let record = PetsRecord::new(3.7, 120.0);
21    /// ```
22    pub fn new(sigma: f64, epsilon_k: f64) -> PetsRecord {
23        PetsRecord { sigma, epsilon_k }
24    }
25}
26
27/// Parameters that modify binary interactions.
28///
29/// $\varepsilon_{k,ij} = (1 - k_{ij})\sqrt{\varepsilon_{k,i} \varepsilon_{k,j}}$
30#[derive(Serialize, Deserialize, Clone, Copy, Default, Debug)]
31pub struct PetsBinaryRecord {
32    pub k_ij: f64,
33}
34
35/// Parameter set for the PeTS equation of state and Helmholtz energy functional.
36pub type PetsParameters = Parameters<PetsRecord, PetsBinaryRecord, ()>;
37
38#[cfg(test)]
39pub mod utils {
40    use super::*;
41    use feos_core::parameter::PureRecord;
42
43    pub fn argon_parameters() -> PetsParameters {
44        let argon_json = r#"
45            {
46                "identifier": {
47                    "cas": "7440-37-1",
48                    "name": "argon",
49                    "iupac_name": "argon",
50                    "smiles": "[Ar]",
51                    "inchi": "InChI=1/Ar",
52                    "formula": "Ar"
53                },
54                "sigma": 3.4050,
55                "epsilon_k": 119.8,
56                "molarweight": 39.948
57            }"#;
58        let argon_record: PureRecord<PetsRecord, ()> =
59            serde_json::from_str(argon_json).expect("Unable to parse json.");
60        PetsParameters::new_pure(argon_record).unwrap()
61    }
62
63    pub fn krypton_parameters() -> PetsParameters {
64        let krypton_json = r#"
65            {
66                "identifier": {
67                    "cas": "7439-90-9",
68                    "name": "krypton",
69                    "iupac_name": "krypton",
70                    "smiles": "[Kr]",
71                    "inchi": "InChI=1S/Kr",
72                    "formula": "Kr"
73                },
74                "sigma": 3.6300,
75                "epsilon_k": 163.10,
76                "molarweight": 83.798
77            }"#;
78        let krypton_record: PureRecord<PetsRecord, ()> =
79            serde_json::from_str(krypton_json).expect("Unable to parse json.");
80        PetsParameters::new_pure(krypton_record).unwrap()
81    }
82
83    pub fn argon_krypton_parameters() -> PetsParameters {
84        let binary_json = r#"[
85            {
86                "identifier": {
87                    "cas": "7440-37-1",
88                    "name": "argon",
89                    "iupac_name": "argon",
90                    "smiles": "[Ar]",
91                    "inchi": "1/Ar",
92                    "formula": "Ar"
93                },
94                "sigma": 3.4050,
95                "epsilon_k": 119.8,
96                "molarweight": 39.948
97            },
98            {
99                "identifier": {
100                    "cas": "7439-90-9",
101                    "name": "krypton",
102                    "iupac_name": "krypton",
103                    "smiles": "[Kr]",
104                    "inchi": "InChI=1S/Kr",
105                    "formula": "Kr"
106                },
107                "sigma": 3.6300,
108                "epsilon_k": 163.10,
109                "molarweight": 83.798
110            }
111        ]"#;
112        let binary_record: [PureRecord<PetsRecord, ()>; 2] =
113            serde_json::from_str(binary_json).expect("Unable to parse json.");
114        PetsParameters::new_binary(binary_record, None, vec![]).unwrap()
115    }
116}