-
Notifications
You must be signed in to change notification settings - Fork 30
Add non-mixed second order derivatives to State property evaluation
#94
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
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8b24b9a
add second (non-mixed) derivative to cache and property evaluation
g-bauer 7db1a5d
renamed derivative to SecondMixed, renamed some tests
g-bauer f448a02
change cache to only store second order derivatives in SecondMixed
g-bauer 3667b4b
remove redundant hashmap entry in cache
g-bauer e1726b8
Add more benchmarks and systems, better names for benchmark groups
g-bauer 524632e
Use derive methods of dual numbers in the derive method for state
g-bauer 806629f
Updated readme for benchmarks, added benchmarks for VLE of pure subst…
g-bauer 51c6284
Implemented HelmholtzEnergy trait for Python StateHD-version that use…
g-bauer 200ef35
Updated changelog of core
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,171 @@ | ||
| use criterion::{criterion_group, criterion_main, Criterion}; | ||
| use feos::pcsaft::{PcSaft, PcSaftParameters}; | ||
| use feos_core::{ | ||
| parameter::{IdentifierOption, Parameter}, | ||
| Contributions, DensityInitialization, EquationOfState, PhaseEquilibrium, State, | ||
| }; | ||
| use ndarray::{Array, Array1}; | ||
| use quantity::si::*; | ||
| use std::sync::Arc; | ||
|
|
||
| /// Evaluate NPT constructor | ||
| fn npt<E: EquationOfState>( | ||
| (eos, t, p, n, rho0): ( | ||
| &Arc<E>, | ||
| SINumber, | ||
| SINumber, | ||
| &SIArray1, | ||
| DensityInitialization<SIUnit>, | ||
| ), | ||
| ) { | ||
| State::new_npt(eos, t, p, n, rho0).unwrap(); | ||
| } | ||
|
|
||
| /// Evaluate critical point constructor | ||
| fn critical_point<E: EquationOfState>((eos, n): (&Arc<E>, Option<&SIArray1>)) { | ||
| State::critical_point(eos, n, None, Default::default()).unwrap(); | ||
| } | ||
|
|
||
| /// VLE for pure substance for given temperature or pressure | ||
| fn pure<E: EquationOfState>((eos, t_or_p): (&Arc<E>, SINumber)) { | ||
| PhaseEquilibrium::pure(eos, t_or_p, None, Default::default()).unwrap(); | ||
| } | ||
|
|
||
| /// Evaluate temperature, pressure flash. | ||
| fn tp_flash<E: EquationOfState>((eos, t, p, feed): (&Arc<E>, SINumber, SINumber, &SIArray1)) { | ||
| PhaseEquilibrium::tp_flash(eos, t, p, feed, None, Default::default(), None).unwrap(); | ||
| } | ||
|
|
||
| fn bubble_point<E: EquationOfState>((eos, t, x): (&Arc<E>, SINumber, &Array1<f64>)) { | ||
| PhaseEquilibrium::bubble_point( | ||
| eos, | ||
| t, | ||
| x, | ||
| None, | ||
| None, | ||
| (Default::default(), Default::default()), | ||
| ) | ||
| .unwrap(); | ||
| } | ||
|
|
||
| fn dew_point<E: EquationOfState>((eos, t, y): (&Arc<E>, SINumber, &Array1<f64>)) { | ||
| PhaseEquilibrium::dew_point( | ||
| eos, | ||
| t, | ||
| y, | ||
| None, | ||
| None, | ||
| (Default::default(), Default::default()), | ||
| ) | ||
| .unwrap(); | ||
| } | ||
|
|
||
| fn bench_states<E: EquationOfState>(c: &mut Criterion, group_name: &str, eos: &Arc<E>) { | ||
| let ncomponents = eos.components(); | ||
| let x = Array::from_elem(ncomponents, 1.0 / ncomponents as f64); | ||
| let n = &x * 100.0 * MOL; | ||
| let crit = State::critical_point(&eos, Some(&n), None, Default::default()).unwrap(); | ||
| let vle = if ncomponents == 1 { | ||
| PhaseEquilibrium::pure(&eos, crit.temperature * 0.95, None, Default::default()).unwrap() | ||
| } else { | ||
| PhaseEquilibrium::tp_flash( | ||
| &eos, | ||
| crit.temperature, | ||
| crit.pressure(Contributions::Total) * 0.95, | ||
| &crit.moles, | ||
| None, | ||
| Default::default(), | ||
| None, | ||
| ) | ||
| .unwrap() | ||
| }; | ||
|
|
||
| let mut group = c.benchmark_group(group_name); | ||
| group.bench_function("new_npt_liquid", |b| { | ||
| b.iter(|| { | ||
| npt(( | ||
| &eos, | ||
| vle.liquid().temperature, | ||
| vle.liquid().pressure(Contributions::Total) * 1.01, | ||
| &n, | ||
| DensityInitialization::Liquid, | ||
| )) | ||
| }) | ||
| }); | ||
| group.bench_function("new_npt_vapor", |b| { | ||
| b.iter(|| { | ||
| npt(( | ||
| &eos, | ||
| vle.vapor().temperature, | ||
| vle.vapor().pressure(Contributions::Total) * 0.99, | ||
| &n, | ||
| DensityInitialization::Vapor, | ||
| )) | ||
| }) | ||
| }); | ||
| group.bench_function("critical_point", |b| { | ||
| b.iter(|| critical_point((&eos, Some(&n)))) | ||
| }); | ||
| if ncomponents != 1 { | ||
| group.bench_function("tp_flash", |b| { | ||
| b.iter(|| { | ||
| tp_flash(( | ||
| &eos, | ||
| crit.temperature, | ||
| crit.pressure(Contributions::Total) * 0.99, | ||
| &n, | ||
| )) | ||
| }) | ||
| }); | ||
|
|
||
| group.bench_function("bubble_point", |b| { | ||
| b.iter(|| bubble_point((&eos, vle.liquid().temperature, &vle.liquid().molefracs))) | ||
| }); | ||
|
|
||
| group.bench_function("dew_point", |b| { | ||
| b.iter(|| dew_point((&eos, vle.vapor().temperature, &vle.vapor().molefracs))) | ||
| }); | ||
| } else { | ||
| group.bench_function("pure_t", |b| { | ||
| b.iter(|| pure((&eos, vle.vapor().temperature))) | ||
| }); | ||
| group.bench_function("pure_p", |b| { | ||
| b.iter(|| pure((&eos, vle.vapor().pressure(Contributions::Total)))) | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| fn pcsaft(c: &mut Criterion) { | ||
| let parameters = PcSaftParameters::from_json( | ||
| vec!["methane"], | ||
| "./parameters/pcsaft/gross2001.json", | ||
| None, | ||
| IdentifierOption::Name, | ||
| ) | ||
| .unwrap(); | ||
| let eos = Arc::new(PcSaft::new(Arc::new(parameters))); | ||
| bench_states(c, "state_creation_pcsaft_methane", &eos); | ||
|
|
||
| let parameters = PcSaftParameters::from_json( | ||
| vec!["methane", "ethane", "propane"], | ||
| "./parameters/pcsaft/gross2001.json", | ||
| None, | ||
| IdentifierOption::Name, | ||
| ) | ||
| .unwrap(); | ||
| let eos = Arc::new(PcSaft::new(Arc::new(parameters))); | ||
| bench_states(c, "state_creation_pcsaft_methane_ethane", &eos); | ||
|
|
||
| let parameters = PcSaftParameters::from_json( | ||
| vec!["methane", "ethane", "propane"], | ||
| "./parameters/pcsaft/gross2001.json", | ||
| None, | ||
| IdentifierOption::Name, | ||
| ) | ||
| .unwrap(); | ||
| let eos = Arc::new(PcSaft::new(Arc::new(parameters))); | ||
| bench_states(c, "state_creation_pcsaft_methane_ethane_propane", &eos); | ||
| } | ||
|
|
||
| criterion_group!(bench, pcsaft); | ||
| 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
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
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.