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

Commit

Permalink
Use Joback as ideal gas model for the PR eos (#10)
Browse files Browse the repository at this point in the history
Use Joback as ideal gas model for the PR eos
  • Loading branch information
prehner committed Dec 2, 2021
1 parent c2e6e2b commit 31a3a8c
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/cubic.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::equation_of_state::{EquationOfState, HelmholtzEnergy, HelmholtzEnergyDual};
use crate::joback::JobackRecord;
use crate::equation_of_state::{
EquationOfState, HelmholtzEnergy, HelmholtzEnergyDual, IdealGasContribution,
};
use crate::joback::{Joback, JobackRecord};
use crate::parameter::{Identifier, Parameter, ParameterError, PureRecord};
use crate::si::{GRAM, MOL};
use crate::state::StateHD;
Expand Down Expand Up @@ -144,11 +146,19 @@ impl Parameter for PengRobinsonParameters {

pub struct PengRobinson {
parameters: Rc<PengRobinsonParameters>,
ideal_gas: Joback,
}

impl PengRobinson {
pub fn new(parameters: Rc<PengRobinsonParameters>) -> Self {
Self { parameters }
let ideal_gas = parameters.joback_records.as_ref().map_or_else(
|| Joback::default(parameters.tc.len()),
|j| Joback::new(j.clone()),
);
Self {
parameters,
ideal_gas,
}
}
}

Expand Down Expand Up @@ -204,6 +214,10 @@ impl EquationOfState for PengRobinson {
{
vec![("Peng-Robinson".into(), self.evaluate_residual(state))]
}

fn ideal_gas(&self) -> &dyn IdealGasContribution {
&self.ideal_gas
}
}

impl MolarWeight<SIUnit> for PengRobinson {
Expand Down

0 comments on commit 31a3a8c

Please sign in to comment.