-
Notifications
You must be signed in to change notification settings - Fork 30
Restructure feos-core
#226
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 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
4ab68a9
PC SAFT done. Checking benches
g-bauer c87b261
Extracted d(T), benches are not faster
g-bauer 17c0d85
Added user_defined impl
g-bauer 2a793e6
Added ideal gas implementation to user_defined module
g-bauer 240bcb1
Changes according to review, added SAFTVRQMie
g-bauer ce42df7
Refactored uv-theory
g-bauer dd5f8f6
Refactored PeTs
g-bauer 2106da2
Refactored GC-PCSAFT
g-bauer f45378d
adjust dft
prehner 0069688
Python fixes
prehner b4e0fc1
Removed VirialOrder from Python Interface, resolved deprecated method…
g-bauer 0526e78
Add uvtheory to Cargo feature
g-bauer a2d1ebb
Updated maturin version, updated github actions, changed universal2 c…
g-bauer 7714757
Updated uv-theory name change in Python doc
g-bauer 9b95af7
cleanup
prehner 399866e
checked Rust docs
prehner 5ceb67a
Removed unchanged notebooks, pub keyword in density_iteration and add…
g-bauer 5e2c5d5
Update to uvtheory notebook, added entries to changelogs
g-bauer 2ce3d68
Remove unchanged notebooks
g-bauer 56926a1
updated changelogs
prehner 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
adjust dft
- Loading branch information
commit f45378d830af40d9a1590f01c6634516dec73af0
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
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,115 @@ | ||
| use quote::quote; | ||
| use syn::{DeriveInput, Ident}; | ||
|
|
||
| pub(crate) fn expand_functional_contribution( | ||
| input: DeriveInput, | ||
| ) -> syn::Result<proc_macro2::TokenStream> { | ||
| let ident = input.ident; | ||
| let variants = match input.data { | ||
| syn::Data::Enum(syn::DataEnum { ref variants, .. }) => variants, | ||
| _ => panic!("this derive macro only works on enums"), | ||
| }; | ||
|
|
||
| let functional_contribution = impl_functional_contribution(&ident, variants); | ||
| let display = impl_display(&ident, variants); | ||
| let from = impl_from(&ident, variants); | ||
| Ok(quote! { | ||
| #functional_contribution | ||
| #display | ||
| #from | ||
| }) | ||
| } | ||
|
|
||
| fn impl_functional_contribution( | ||
| ident: &Ident, | ||
| variants: &syn::punctuated::Punctuated<syn::Variant, syn::token::Comma>, | ||
| ) -> proc_macro2::TokenStream { | ||
| let weight_functions = variants.iter().map(|v| { | ||
| let name = &v.ident; | ||
| quote! { | ||
| Self::#name(functional_contribution) => functional_contribution.weight_functions(temperature) | ||
| } | ||
| }); | ||
| let weight_functions_pdgt = variants.iter().map(|v| { | ||
| let name = &v.ident; | ||
| quote! { | ||
| Self::#name(functional_contribution) => functional_contribution.weight_functions_pdgt(temperature) | ||
| } | ||
| }); | ||
| let helmholtz_energy_density = variants.iter().map(|v| { | ||
| let name = &v.ident; | ||
| quote! { | ||
| Self::#name(functional_contribution) => functional_contribution.helmholtz_energy_density(temperature, weighted_densities) | ||
| } | ||
| }); | ||
|
|
||
| quote! { | ||
| impl FunctionalContribution for #ident { | ||
| fn weight_functions<N: DualNum<f64> + Copy+ScalarOperand>(&self, temperature: N) -> WeightFunctionInfo<N> { | ||
| match self { | ||
| #(#weight_functions,)* | ||
| } | ||
| } | ||
| fn weight_functions_pdgt<N: DualNum<f64> + Copy+ScalarOperand>(&self, temperature: N) -> WeightFunctionInfo<N> { | ||
| match self { | ||
| #(#weight_functions_pdgt,)* | ||
| } | ||
| } | ||
| fn helmholtz_energy_density<N: DualNum<f64> + Copy+ScalarOperand>( | ||
| &self, | ||
| temperature: N, | ||
| weighted_densities: ArrayView2<N>, | ||
| ) -> EosResult<Array1<N>> { | ||
| match self { | ||
| #(#helmholtz_energy_density,)* | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fn impl_display( | ||
| ident: &Ident, | ||
| variants: &syn::punctuated::Punctuated<syn::Variant, syn::token::Comma>, | ||
| ) -> proc_macro2::TokenStream { | ||
| let fmt = variants.iter().map(|v| { | ||
| let name = &v.ident; | ||
| quote! { | ||
| Self::#name(functional_contribution) => functional_contribution.fmt(f) | ||
| } | ||
| }); | ||
|
|
||
| quote! { | ||
| impl std::fmt::Display for #ident { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| match self { | ||
| #(#fmt,)* | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fn impl_from( | ||
| ident: &Ident, | ||
| variants: &syn::punctuated::Punctuated<syn::Variant, syn::token::Comma>, | ||
| ) -> proc_macro2::TokenStream { | ||
| let from = variants.iter().map(|v| { | ||
| let name = &v.ident; | ||
| let syn::Fields::Unnamed(syn::FieldsUnnamed { unnamed, .. }) = &v.fields else { | ||
| panic!("All variants must be tuple structs!") | ||
| }; | ||
| let inner = &unnamed.first().unwrap().ty; | ||
| quote! { | ||
| impl From<#inner> for #ident { | ||
| fn from(variant: #inner) -> Self { | ||
| Self::#name(variant) | ||
| } | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| quote! { | ||
| #(#from)* | ||
| } | ||
| } |
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.