|
1 | | -use crate::equation_of_state::{EquationOfState, HelmholtzEnergy, HelmholtzEnergyDual}; |
2 | | -use crate::joback::JobackRecord; |
| 1 | +use crate::equation_of_state::{ |
| 2 | + EquationOfState, HelmholtzEnergy, HelmholtzEnergyDual, IdealGasContribution, |
| 3 | +}; |
| 4 | +use crate::joback::{Joback, JobackRecord}; |
3 | 5 | use crate::parameter::{Identifier, Parameter, ParameterError, PureRecord}; |
4 | 6 | use crate::si::{GRAM, MOL}; |
5 | 7 | use crate::state::StateHD; |
@@ -144,11 +146,19 @@ impl Parameter for PengRobinsonParameters { |
144 | 146 |
|
145 | 147 | pub struct PengRobinson { |
146 | 148 | parameters: Rc<PengRobinsonParameters>, |
| 149 | + ideal_gas: Joback, |
147 | 150 | } |
148 | 151 |
|
149 | 152 | impl PengRobinson { |
150 | 153 | pub fn new(parameters: Rc<PengRobinsonParameters>) -> Self { |
151 | | - Self { parameters } |
| 154 | + let ideal_gas = parameters.joback_records.as_ref().map_or_else( |
| 155 | + || Joback::default(parameters.tc.len()), |
| 156 | + |j| Joback::new(j.clone()), |
| 157 | + ); |
| 158 | + Self { |
| 159 | + parameters, |
| 160 | + ideal_gas, |
| 161 | + } |
152 | 162 | } |
153 | 163 | } |
154 | 164 |
|
@@ -204,6 +214,10 @@ impl EquationOfState for PengRobinson { |
204 | 214 | { |
205 | 215 | vec![("Peng-Robinson".into(), self.evaluate_residual(state))] |
206 | 216 | } |
| 217 | + |
| 218 | + fn ideal_gas(&self) -> &dyn IdealGasContribution { |
| 219 | + &self.ideal_gas |
| 220 | + } |
207 | 221 | } |
208 | 222 |
|
209 | 223 | impl MolarWeight<SIUnit> for PengRobinson { |
|
0 commit comments