Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- 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)
- Added `PureRecord`, `SegmentRecord`, `Identifier`, and `IdentifierOption` to `feos.ideal_gas`. [#205](https://github.com/feos-org/feos/pull/205)
- Added implementation of the Joback ideal gas model that was previously part of `feos-core`. [#204](https://github.com/feos-org/feos/pull/204)
- Added an implementation of the ideal gas heat capacity based on DIPPR equations. [#204](https://github.com/feos-org/feos/pull/204)

### Changed
- Split `feos.ideal_gas` into `feos.joback` and `feos.dippr`. [#204](https://github.com/feos-org/feos/pull/204)

## [0.5.1] - 2023-11-23
- Python only: Release the changes introduced in `feos-core` 0.5.1.
Expand Down
5 changes: 5 additions & 0 deletions feos-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
### Added
- 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)
- Added `NoBinaryModelRecord` for models that do not use binary interaction parameters. [#211](https://github.com/feos-org/feos/pull/211)

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

### Removed
- Removed `JobackParameters` and `JobackBinaryRecord`. [#204](https://github.com/feos-org/feos/pull/204)
- Moved the remaining implementation of `Joback` to `feos`. [#204](https://github.com/feos-org/feos/pull/204)

## [0.5.1] - 2023-11-23
### Fixed
- Aligned how binary segment records are treated in Rust and Python. [#200](https://github.com/feos-org/feos/pull/200)
Expand Down
31 changes: 21 additions & 10 deletions feos-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ pub mod cubic;
mod density_iteration;
mod equation_of_state;
mod errors;
pub mod joback;
pub mod parameter;
mod phase_equilibria;
pub mod si;
Expand Down Expand Up @@ -121,8 +120,7 @@ impl SolverOptions {
#[cfg(test)]
mod tests {
use crate::cubic::*;
use crate::equation_of_state::EquationOfState;
use crate::joback::{Joback, JobackParameters, JobackRecord};
use crate::equation_of_state::{Components, EquationOfState, IdealGas};
use crate::parameter::*;
use crate::si::{BAR, KELVIN, MOL, RGAS};
use crate::Contributions;
Expand All @@ -131,6 +129,25 @@ mod tests {
use approx::*;
use std::sync::Arc;

// Only to be able to instantiate an `EquationOfState`
struct NoIdealGas;

impl Components for NoIdealGas {
fn components(&self) -> usize {
1
}

fn subset(&self, _: &[usize]) -> Self {
Self
}
}

impl IdealGas for NoIdealGas {
fn ideal_gas_model(&self) -> &dyn crate::DeBroglieWavelength {
unreachable!()
}
}

fn pure_record_vec() -> Vec<PureRecord<PengRobinsonRecord>> {
let records = r#"[
{
Expand Down Expand Up @@ -175,13 +192,7 @@ mod tests {
let propane = mixture[0].clone();
let parameters = PengRobinsonParameters::new_pure(propane)?;
let residual = Arc::new(PengRobinson::new(Arc::new(parameters)));
let joback_parameters = Arc::new(JobackParameters::new_pure(PureRecord::new(
Identifier::default(),
1.0,
JobackRecord::new(0.0, 0.0, 0.0, 0.0, 0.0),
))?);
let ideal_gas = Arc::new(Joback::new(joback_parameters));
let eos = Arc::new(EquationOfState::new(ideal_gas, residual.clone()));
let eos = Arc::new(EquationOfState::new(Arc::new(NoIdealGas), residual.clone()));

let sr = StateBuilder::new(&residual)
.temperature(300.0 * KELVIN)
Expand Down
31 changes: 31 additions & 0 deletions feos-core/src/parameter/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
//! Structures and traits that can be used to build model parameters for equations of state.

use conv::ValueInto;
use indexmap::{IndexMap, IndexSet};
use ndarray::Array2;
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt;
use std::fs::File;
use std::io;
use std::io::BufReader;
Expand Down Expand Up @@ -345,6 +348,34 @@ where
}
}

/// Dummy struct used for models that do not use binary interaction parameters.
#[derive(Serialize, Deserialize, Clone, Default)]
pub struct NoBinaryModelRecord;

impl From<f64> for NoBinaryModelRecord {
fn from(_: f64) -> Self {
Self
}
}

impl From<NoBinaryModelRecord> for f64 {
fn from(_: NoBinaryModelRecord) -> Self {
0.0 // nasty hack - panic crashes Ipython kernel, actual value is never used
}
}

impl<T: Copy + ValueInto<f64>> FromSegmentsBinary<T> for NoBinaryModelRecord {
fn from_segments_binary(_segments: &[(f64, T, T)]) -> Result<Self, ParameterError> {
Ok(Self)
}
}

impl fmt::Display for NoBinaryModelRecord {
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
Ok(())
}
}

/// Constructor methods for parameters for heterosegmented models.
pub trait ParameterHetero: Sized {
type Chemical: Clone;
Expand Down
1 change: 0 additions & 1 deletion feos-core/src/python/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use pyo3::PyErr;

pub mod cubic;
mod equation_of_state;
pub mod joback;
pub mod parameter;
mod phase_equilibria;
mod state;
Expand Down
17 changes: 14 additions & 3 deletions feos-core/src/python/parameter/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::impl_json_handling;
use crate::parameter::{BinaryRecord, ChemicalRecord, Identifier, ParameterError};
use pyo3::exceptions::PyRuntimeError;
use crate::parameter::{
BinaryRecord, ChemicalRecord, Identifier, NoBinaryModelRecord, ParameterError,
};
use pyo3::exceptions::{PyRuntimeError, PyTypeError};
use pyo3::prelude::*;

impl From<ParameterError> for PyErr {
Expand Down Expand Up @@ -293,6 +295,12 @@ macro_rules! impl_binary_record {
};
}

#[pyclass(name = "NoBinaryModelRecord")]
#[derive(Clone)]
pub struct PyNoBinaryModelRecord(pub NoBinaryModelRecord);

impl_binary_record!(NoBinaryModelRecord, PyNoBinaryModelRecord);

/// Create a record for a binary segment interaction parameter.
///
/// Parameters
Expand Down Expand Up @@ -546,7 +554,10 @@ macro_rules! impl_segment_record {

#[macro_export]
macro_rules! impl_parameter {
($parameter:ty, $py_parameter:ty, $py_model_record:ty, $py_binary_model_record:ty) => {
($parameter:ty, $py_parameter:ty, $py_model_record:ty) => {
impl_parameter!($parameter, $py_parameter, $py_model_record, PyNoBinaryModelRecord);
};
($parameter:ty, $py_parameter:ty, $py_model_record:ty, $py_binary_model_record:ty) => {
#[pymethods]
impl $py_parameter {
/// Creates parameters from records.
Expand Down
2 changes: 1 addition & 1 deletion feos-derive/src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn impl_components(
}
} else {
quote! {
Self::#name(residual) => Self::#name(residual.subset(component_list))
Self::#name(residual) => Self::#name(residual.subset(component_list).into())
}
}
});
Expand Down
18 changes: 18 additions & 0 deletions parameters/ideal_gas/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Parameters for ideal gas models

This directory contains files with parameters for different models for ideal gas heat capacities.
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.

## DIPPR correlations

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.

|file|description|publication(s)|
|-|-|:-:|
[`poling2000.json`](poling2000.json) | correlation parameters published in "The Properties of Gases and Liquids, 5th edition" | |

## Joback group-contribution model

|file|description|publication(s)|
|-|-|:-:|
[`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)|
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,14 @@ @article{Joback1987Jul
issn = {0098-6445},
publisher = {Taylor {\&} Francis},
doi = {10.1080/00986448708960487}
}

@book{poling2000,
title = {The Properties of Gases and Liquids 5E},
author = {Poling, B.E. and Prausnitz, J.M. and O'Connell, J.P.},
isbn = {9780071499996},
lccn = {00061622},
series = {McGraw Hill professional},
year = {2000},
publisher = {McGraw Hill LLC}
}
Loading