Skip to content
This repository was archived by the owner on Jun 14, 2022. It is now read-only.

Commit 31a3a8c

Browse files
authored
Use Joback as ideal gas model for the PR eos (#10)
Use Joback as ideal gas model for the PR eos
1 parent c2e6e2b commit 31a3a8c

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

src/cubic.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
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};
35
use crate::parameter::{Identifier, Parameter, ParameterError, PureRecord};
46
use crate::si::{GRAM, MOL};
57
use crate::state::StateHD;
@@ -144,11 +146,19 @@ impl Parameter for PengRobinsonParameters {
144146

145147
pub struct PengRobinson {
146148
parameters: Rc<PengRobinsonParameters>,
149+
ideal_gas: Joback,
147150
}
148151

149152
impl PengRobinson {
150153
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+
}
152162
}
153163
}
154164

@@ -204,6 +214,10 @@ impl EquationOfState for PengRobinson {
204214
{
205215
vec![("Peng-Robinson".into(), self.evaluate_residual(state))]
206216
}
217+
218+
fn ideal_gas(&self) -> &dyn IdealGasContribution {
219+
&self.ideal_gas
220+
}
207221
}
208222

209223
impl MolarWeight<SIUnit> for PengRobinson {

0 commit comments

Comments
 (0)