-
Notifications
You must be signed in to change notification settings - Fork 30
Implement SAFT-VR Mie equation of state #237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
fe403db
PC SAFT done. Checking benches
g-bauer e98410a
Changes according to review, added SAFTVRQMie
g-bauer 9b57213
adjust dft
prehner 273f245
Python fixes
prehner 30236ed
Add uvtheory to Cargo feature
g-bauer 2805020
Started impl of SAFT VR Mie
g-bauer 5539f0e
Working dispersion and chain. Association needs evaluation.
g-bauer 9c3da57
Cleanup, removal of old files
g-bauer 61c145a
Improved diameter calculation
g-bauer 0828d67
Finished impl. Added test cases.
g-bauer 3c71bba
Silence warning of unused method
g-bauer 7fd1fcf
Fixed bug from rebasing
g-bauer ab5b87a
Fixed benchmark
g-bauer 9a22b5b
Updated Readme
g-bauer 317c48e
Updated changelog
g-bauer 7f6fff7
Added parameters of Lafitte et al 2013, readme and bib file
g-bauer 658aec4
Fixed integration test
g-bauer d5aec3d
Added example notebook with validation of implementation
g-bauer b8be814
Added docs
g-bauer 681b341
Changed visibility in core and dft. Fixed bug in benches.
g-bauer 47a0c37
Added section for association term in documentation
g-bauer bb2fe9f
Added more examples to notebook
g-bauer d8c0333
removed unused method from hard sphere module, added tests to CI, mov…
g-bauer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| //! Benchmarks for the evaluation of the Helmholtz energy function | ||
| //! for a given `StateHD` for different types of dual numbers. | ||
| //! These should give an idea about the expected slow-down depending | ||
| //! on the dual number type used without the overhead of the `State` | ||
| //! creation. | ||
| use criterion::{criterion_group, criterion_main, Criterion}; | ||
| use feos::hard_sphere::HardSphereProperties; | ||
| use feos::saftvrmie::{test_utils::test_parameters, SaftVRMie, SaftVRMieParameters}; | ||
| use feos_core::si::*; | ||
| use feos_core::{Derivative, Residual, State, StateHD}; | ||
| use ndarray::{Array, ScalarOperand}; | ||
| use num_dual::DualNum; | ||
| use std::sync::Arc; | ||
|
|
||
| /// Helper function to create a state for given parameters. | ||
| /// - temperature is 80% of critical temperature, | ||
| /// - volume is critical volume, | ||
| /// - molefracs (or moles) for equimolar mixture. | ||
| fn state_saftvrmie(parameters: &Arc<SaftVRMieParameters>) -> State<SaftVRMie> { | ||
| let n = parameters.pure_records.len(); | ||
| let eos = Arc::new(SaftVRMie::new(parameters.clone())); | ||
| let moles = Array::from_elem(n, 1.0 / n as f64) * 10.0 * MOL; | ||
| let cp = State::critical_point(&eos, Some(&moles), None, Default::default()).unwrap(); | ||
| let temperature = 0.8 * cp.temperature; | ||
| State::new_nvt(&eos, temperature, cp.volume, &moles).unwrap() | ||
| } | ||
|
|
||
| /// Residual Helmholtz energy given an equation of state and a StateHD. | ||
| fn a_res<D: DualNum<f64> + Copy + ScalarOperand, E: Residual>(inp: (&Arc<E>, &StateHD<D>)) -> D { | ||
| inp.0.residual_helmholtz_energy(inp.1) | ||
| } | ||
|
|
||
| fn d_hs<D: DualNum<f64> + Copy>(inp: (&SaftVRMieParameters, D)) -> D { | ||
| inp.0.hs_diameter(inp.1)[0] | ||
| } | ||
|
|
||
| /// Benchmark for evaluation of the Helmholtz energy for different dual number types. | ||
| fn bench_dual_numbers<E: Residual>( | ||
| c: &mut Criterion, | ||
| group_name: &str, | ||
| state: State<E>, | ||
| parameters: &SaftVRMieParameters, | ||
| ) { | ||
| let mut group = c.benchmark_group(group_name); | ||
| group.bench_function("d_f64", |b| { | ||
| b.iter(|| d_hs((¶meters, state.derive0().temperature))) | ||
| }); | ||
| group.bench_function("d_dual", |b| { | ||
| b.iter(|| d_hs((¶meters, state.derive1(Derivative::DT).temperature))) | ||
| }); | ||
| group.bench_function("d_dual2", |b| { | ||
| b.iter(|| d_hs((¶meters, state.derive2(Derivative::DT).temperature))) | ||
| }); | ||
| group.bench_function("d_hyperdual", |b| { | ||
| b.iter(|| { | ||
| d_hs(( | ||
| ¶meters, | ||
| state | ||
| .derive2_mixed(Derivative::DT, Derivative::DT) | ||
| .temperature, | ||
| )) | ||
| }) | ||
| }); | ||
| group.bench_function("d_dual3", |b| { | ||
| b.iter(|| d_hs((¶meters, state.derive3(Derivative::DT).temperature))) | ||
| }); | ||
|
|
||
| group.bench_function("a_f64", |b| { | ||
| b.iter(|| a_res((&state.eos, &state.derive0()))) | ||
| }); | ||
| group.bench_function("a_dual", |b| { | ||
| b.iter(|| a_res((&state.eos, &state.derive1(Derivative::DV)))) | ||
| }); | ||
| group.bench_function("a_dual2", |b| { | ||
| b.iter(|| a_res((&state.eos, &state.derive2(Derivative::DV)))) | ||
| }); | ||
| group.bench_function("a_hyperdual", |b| { | ||
| b.iter(|| { | ||
| a_res(( | ||
| &state.eos, | ||
| &state.derive2_mixed(Derivative::DV, Derivative::DV), | ||
| )) | ||
| }) | ||
| }); | ||
| group.bench_function("a_dual3", |b| { | ||
| b.iter(|| a_res((&state.eos, &state.derive3(Derivative::DV)))) | ||
| }); | ||
| } | ||
|
|
||
| /// Benchmark for the SAFT VR Mie equation of state | ||
| fn saftvrmie(c: &mut Criterion) { | ||
| let parameters = Arc::new(test_parameters().remove("ethane").unwrap()); | ||
| bench_dual_numbers( | ||
| c, | ||
| "dual_numbers_saftvrmie_ethane", | ||
| state_saftvrmie(¶meters), | ||
| ¶meters, | ||
| ); | ||
| } | ||
|
|
||
| criterion_group!(bench, saftvrmie); | ||
| criterion_main!(bench); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # `feos.saftvrmie` | ||
|
|
||
| Utilities to build `SaftVRMieParameters`. | ||
|
|
||
| ## Example | ||
|
|
||
| ```python | ||
| from feos.saftvrmie import SaftVRMieParameters | ||
|
|
||
| path = 'parameters/saftvrmie/lafitte2013.json' | ||
| parameters = SaftVRMieParameters.from_json(['ethane', 'methane'], path) | ||
| ``` | ||
|
|
||
| ## Data types | ||
|
|
||
| ```{eval-rst} | ||
| .. currentmodule:: feos.saftvrmie | ||
|
|
||
| .. autosummary:: | ||
| :toctree: generated/ | ||
|
|
||
| Identifier | ||
| ChemicalRecord | ||
| PureRecord | ||
| BinaryRecord | ||
| SaftVRMieRecord | ||
| SaftVRMieParameters | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.