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

Use Joback as ideal gas model for the PR eos #10

Merged
merged 2 commits into from
Dec 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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