Skip to content

Commit 0da3f50

Browse files
authored
Add DIPPR correlations for c_p^ig (#211)
1 parent fc5c2bc commit 0da3f50

27 files changed

Lines changed: 5593 additions & 228 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
### Added
99
- Added `EquationOfState.ideal_gas()` to initialize an equation of state that only consists of an ideal gas contribution. [#204](https://github.com/feos-org/feos/pull/204)
1010
- Added `PureRecord`, `SegmentRecord`, `Identifier`, and `IdentifierOption` to `feos.ideal_gas`. [#205](https://github.com/feos-org/feos/pull/205)
11+
- Added implementation of the Joback ideal gas model that was previously part of `feos-core`. [#204](https://github.com/feos-org/feos/pull/204)
12+
- Added an implementation of the ideal gas heat capacity based on DIPPR equations. [#204](https://github.com/feos-org/feos/pull/204)
13+
14+
### Changed
15+
- Split `feos.ideal_gas` into `feos.joback` and `feos.dippr`. [#204](https://github.com/feos-org/feos/pull/204)
1116

1217
## [0.5.1] - 2023-11-23
1318
- Python only: Release the changes introduced in `feos-core` 0.5.1.

feos-core/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## Unreleased
88
### Added
99
- Added `EquationOfState::ideal_gas` to initialize an equation of state that only consists of an ideal gas contribution. [#204](https://github.com/feos-org/feos/pull/204)
10+
- Added `NoBinaryModelRecord` for models that do not use binary interaction parameters. [#211](https://github.com/feos-org/feos/pull/211)
1011

1112
### Changed
1213
- Made members of `JobackRecord` public. [#206](https://github.com/feos-org/feos/pull/206)
1314

15+
### Removed
16+
- Removed `JobackParameters` and `JobackBinaryRecord`. [#204](https://github.com/feos-org/feos/pull/204)
17+
- Moved the remaining implementation of `Joback` to `feos`. [#204](https://github.com/feos-org/feos/pull/204)
18+
1419
## [0.5.1] - 2023-11-23
1520
### Fixed
1621
- Aligned how binary segment records are treated in Rust and Python. [#200](https://github.com/feos-org/feos/pull/200)

feos-core/src/lib.rs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ pub mod cubic;
2727
mod density_iteration;
2828
mod equation_of_state;
2929
mod errors;
30-
pub mod joback;
3130
pub mod parameter;
3231
mod phase_equilibria;
3332
pub mod si;
@@ -121,8 +120,7 @@ impl SolverOptions {
121120
#[cfg(test)]
122121
mod tests {
123122
use crate::cubic::*;
124-
use crate::equation_of_state::EquationOfState;
125-
use crate::joback::{Joback, JobackParameters, JobackRecord};
123+
use crate::equation_of_state::{Components, EquationOfState, IdealGas};
126124
use crate::parameter::*;
127125
use crate::si::{BAR, KELVIN, MOL, RGAS};
128126
use crate::Contributions;
@@ -131,6 +129,25 @@ mod tests {
131129
use approx::*;
132130
use std::sync::Arc;
133131

132+
// Only to be able to instantiate an `EquationOfState`
133+
struct NoIdealGas;
134+
135+
impl Components for NoIdealGas {
136+
fn components(&self) -> usize {
137+
1
138+
}
139+
140+
fn subset(&self, _: &[usize]) -> Self {
141+
Self
142+
}
143+
}
144+
145+
impl IdealGas for NoIdealGas {
146+
fn ideal_gas_model(&self) -> &dyn crate::DeBroglieWavelength {
147+
unreachable!()
148+
}
149+
}
150+
134151
fn pure_record_vec() -> Vec<PureRecord<PengRobinsonRecord>> {
135152
let records = r#"[
136153
{
@@ -175,13 +192,7 @@ mod tests {
175192
let propane = mixture[0].clone();
176193
let parameters = PengRobinsonParameters::new_pure(propane)?;
177194
let residual = Arc::new(PengRobinson::new(Arc::new(parameters)));
178-
let joback_parameters = Arc::new(JobackParameters::new_pure(PureRecord::new(
179-
Identifier::default(),
180-
1.0,
181-
JobackRecord::new(0.0, 0.0, 0.0, 0.0, 0.0),
182-
))?);
183-
let ideal_gas = Arc::new(Joback::new(joback_parameters));
184-
let eos = Arc::new(EquationOfState::new(ideal_gas, residual.clone()));
195+
let eos = Arc::new(EquationOfState::new(Arc::new(NoIdealGas), residual.clone()));
185196

186197
let sr = StateBuilder::new(&residual)
187198
.temperature(300.0 * KELVIN)

feos-core/src/parameter/mod.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
//! Structures and traits that can be used to build model parameters for equations of state.
22
3+
use conv::ValueInto;
34
use indexmap::{IndexMap, IndexSet};
45
use ndarray::Array2;
56
use serde::de::DeserializeOwned;
7+
use serde::{Deserialize, Serialize};
68
use std::collections::HashMap;
9+
use std::fmt;
710
use std::fs::File;
811
use std::io;
912
use std::io::BufReader;
@@ -345,6 +348,34 @@ where
345348
}
346349
}
347350

351+
/// Dummy struct used for models that do not use binary interaction parameters.
352+
#[derive(Serialize, Deserialize, Clone, Default)]
353+
pub struct NoBinaryModelRecord;
354+
355+
impl From<f64> for NoBinaryModelRecord {
356+
fn from(_: f64) -> Self {
357+
Self
358+
}
359+
}
360+
361+
impl From<NoBinaryModelRecord> for f64 {
362+
fn from(_: NoBinaryModelRecord) -> Self {
363+
0.0 // nasty hack - panic crashes Ipython kernel, actual value is never used
364+
}
365+
}
366+
367+
impl<T: Copy + ValueInto<f64>> FromSegmentsBinary<T> for NoBinaryModelRecord {
368+
fn from_segments_binary(_segments: &[(f64, T, T)]) -> Result<Self, ParameterError> {
369+
Ok(Self)
370+
}
371+
}
372+
373+
impl fmt::Display for NoBinaryModelRecord {
374+
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
375+
Ok(())
376+
}
377+
}
378+
348379
/// Constructor methods for parameters for heterosegmented models.
349380
pub trait ParameterHetero: Sized {
350381
type Chemical: Clone;

feos-core/src/python/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use pyo3::PyErr;
44

55
pub mod cubic;
66
mod equation_of_state;
7-
pub mod joback;
87
pub mod parameter;
98
mod phase_equilibria;
109
mod state;

feos-core/src/python/parameter/mod.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use crate::impl_json_handling;
2-
use crate::parameter::{BinaryRecord, ChemicalRecord, Identifier, ParameterError};
3-
use pyo3::exceptions::PyRuntimeError;
2+
use crate::parameter::{
3+
BinaryRecord, ChemicalRecord, Identifier, NoBinaryModelRecord, ParameterError,
4+
};
5+
use pyo3::exceptions::{PyRuntimeError, PyTypeError};
46
use pyo3::prelude::*;
57

68
impl From<ParameterError> for PyErr {
@@ -293,6 +295,12 @@ macro_rules! impl_binary_record {
293295
};
294296
}
295297

298+
#[pyclass(name = "NoBinaryModelRecord")]
299+
#[derive(Clone)]
300+
pub struct PyNoBinaryModelRecord(pub NoBinaryModelRecord);
301+
302+
impl_binary_record!(NoBinaryModelRecord, PyNoBinaryModelRecord);
303+
296304
/// Create a record for a binary segment interaction parameter.
297305
///
298306
/// Parameters
@@ -546,7 +554,10 @@ macro_rules! impl_segment_record {
546554

547555
#[macro_export]
548556
macro_rules! impl_parameter {
549-
($parameter:ty, $py_parameter:ty, $py_model_record:ty, $py_binary_model_record:ty) => {
557+
($parameter:ty, $py_parameter:ty, $py_model_record:ty) => {
558+
impl_parameter!($parameter, $py_parameter, $py_model_record, PyNoBinaryModelRecord);
559+
};
560+
($parameter:ty, $py_parameter:ty, $py_model_record:ty, $py_binary_model_record:ty) => {
550561
#[pymethods]
551562
impl $py_parameter {
552563
/// Creates parameters from records.

feos-derive/src/components.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn impl_components(
3737
}
3838
} else {
3939
quote! {
40-
Self::#name(residual) => Self::#name(residual.subset(component_list))
40+
Self::#name(residual) => Self::#name(residual.subset(component_list).into())
4141
}
4242
}
4343
});

parameters/ideal_gas/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Parameters for ideal gas models
2+
3+
This directory contains files with parameters for different models for ideal gas heat capacities.
4+
The files named according to the pattern `NameYear.json` correspond to published parameters. The corresponding publication is provided in the [`literature.bib`](literature.bib) file.
5+
6+
## DIPPR correlations
7+
8+
The parameters published in the DIPPR database itself are not publicly available. If you have a valid license, contact us to obtain a compatible input file.
9+
10+
|file|description|publication(s)|
11+
|-|-|:-:|
12+
[`poling2000.json`](poling2000.json) | correlation parameters published in "The Properties of Gases and Liquids, 5th edition" | |
13+
14+
## Joback group-contribution model
15+
16+
|file|description|publication(s)|
17+
|-|-|:-:|
18+
[`joback1987.json`](joback1987.json) | group parameters by Joback and Reid; adjusted to the groups of [Sauer et al.](../pcsaft/README.md) | [&#128279;](https://doi.org/10.1080/00986448708960487)|
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,14 @@ @article{Joback1987Jul
1010
issn = {0098-6445},
1111
publisher = {Taylor {\&} Francis},
1212
doi = {10.1080/00986448708960487}
13+
}
14+
15+
@book{poling2000,
16+
title = {The Properties of Gases and Liquids 5E},
17+
author = {Poling, B.E. and Prausnitz, J.M. and O'Connell, J.P.},
18+
isbn = {9780071499996},
19+
lccn = {00061622},
20+
series = {McGraw Hill professional},
21+
year = {2000},
22+
publisher = {McGraw Hill LLC}
1323
}

0 commit comments

Comments
 (0)