Skip to content
This repository was archived by the owner on Jun 14, 2022. It is now read-only.
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
### Added
- Added `pure_records` getter in the `impl_parameter` macro. [#54](https://github.com/feos-org/feos-core/pull/54)
- Implemented `Deref` and `IntoIterator` for `StateVec` for additional vector functionalities of the `StateVec`. [#55](https://github.com/feos-org/feos-core/pull/55)
- Added `StateVec.__len__` and `StateVec.__getitem__` to allow indexing and iterating over `StateVec`s in Python. [#55](https://github.com/feos-org/feos-core/pull/55)
- Added `SegmentCount` trait that allows the construction of parameter sets from arbitrary chemical records. [#56](https://github.com/feos-org/feos-core/pull/56)
- Added `ParameterHetero` trait to generically provide utility functions for parameter sets of heterosegmented Helmholtz energy models. [#56](https://github.com/feos-org/feos-core/pull/56)

### Changed
- Changed datatype for binary parameters in interfaces of the `from_records` and `new_binary` methods for parameters to take either numpy arrays of `f64` or a list of `BinaryRecord` as input. [#54](https://github.com/feos-org/feos-core/pull/54)
- Modified `PhaseDiagram.to_dict` function in Python to account for pure components and mixtures. [#55](https://github.com/feos-org/feos-core/pull/55)
- Changed `StateVec` to a tuple struct. [#55](https://github.com/feos-org/feos-core/pull/55)
- Made `cas` field of `Identifier` optional. [#56](https://github.com/feos-org/feos-core/pull/56)
- Added type parameter to `FromSegments` and made its `from_segments` function fallible for more control over model limitations. [#56](https://github.com/feos-org/feos-core/pull/56)
- Reverted `ChemicalRecord` back to a struct that only contains the structural information (and not segment and bond counts). [#56](https://github.com/feos-org/feos-core/pull/56)

## [0.2.0] - 2022-04-12
### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ thiserror = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
indexmap = "1.7"
either = "1.6"
conv = "0.3"
numpy = { version = "0.16", optional = true }
pyo3 = { version = "0.16", optional = true }

Expand Down
2 changes: 1 addition & 1 deletion src/cubic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl PengRobinsonParameters {
pc: pc[i],
acentric_factor: acentric_factor[i],
};
let id = Identifier::new("1", None, None, None, None, None);
let id = Identifier::default();
PureRecord::new(id, molarweight[i], record, None)
})
.collect();
Expand Down
32 changes: 17 additions & 15 deletions src/joback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
EosResult, EosUnit, EquationOfState, HelmholtzEnergy, IdealGasContribution,
IdealGasContributionDual,
};
use conv::ValueInto;
use ndarray::Array1;
use num_dual::*;
use quantity::QuantityScalar;
Expand Down Expand Up @@ -45,21 +46,22 @@ impl fmt::Display for JobackRecord {

/// Implementation of the combining rules as described in
/// [Joback and Reid, 1987](https://doi.org/10.1080/00986448708960487).
impl FromSegments for JobackRecord {
fn from_segments(segments: &[(Self, f64)]) -> Self {
impl<T: Copy + ValueInto<f64>> FromSegments<T> for JobackRecord {
fn from_segments(segments: &[(Self, T)]) -> Result<Self, ParameterError> {
let mut a = -37.93;
let mut b = 0.21;
let mut c = -3.91e-4;
let mut d = 2.06e-7;
let mut e = 0.0;
segments.iter().for_each(|(s, n)| {
a += s.a * *n;
b += s.b * *n;
c += s.c * *n;
d += s.d * *n;
e += s.e * *n;
let n = (*n).value_into().unwrap();
a += s.a * n;
b += s.b * n;
c += s.c * n;
d += s.d * n;
e += s.e * n;
});
Self { a, b, c, d, e }
Ok(Self { a, b, c, d, e })
}
}

Expand Down Expand Up @@ -167,7 +169,7 @@ mod tests {

use super::*;

#[derive(Deserialize, Clone)]
#[derive(Deserialize, Clone, Debug)]
struct ModelRecord;

#[test]
Expand Down Expand Up @@ -213,7 +215,7 @@ mod tests {
let segment_records: Vec<SegmentRecord<ModelRecord, JobackRecord>> =
serde_json::from_str(segments_json).expect("Unable to parse json.");
let segments = ChemicalRecord::new(
Identifier::new("", None, None, None, None, None),
Identifier::default(),
vec![
String::from("-Cl"),
String::from("-Cl"),
Expand All @@ -226,15 +228,15 @@ mod tests {
],
None,
)
.segment_count(&segment_records)?;
assert_eq!(segments.get(&segment_records[0]), Some(&2.0));
assert_eq!(segments.get(&segment_records[1]), Some(&4.0));
assert_eq!(segments.get(&segment_records[2]), Some(&2.0));
.segment_map(&segment_records)?;
assert_eq!(segments.get(&segment_records[0]), Some(&2));
assert_eq!(segments.get(&segment_records[1]), Some(&4));
assert_eq!(segments.get(&segment_records[2]), Some(&2));
let joback_segments: Vec<_> = segments
.iter()
.map(|(s, &n)| (s.ideal_gas_record.clone().unwrap(), n))
.collect();
let jr = JobackRecord::from_segments(&joback_segments);
let jr = JobackRecord::from_segments(&joback_segments)?;
assert_relative_eq!(
jr.a,
33.3 * 2.0 - 2.14 * 4.0 - 8.25 * 2.0 - 37.93,
Expand Down
Loading