-
Notifications
You must be signed in to change notification settings - Fork 1
add implementation and test for MOSAIC function aerosol_water #116
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
1a6c885
add implementation of aerosol_water
zdaq12 efd7208
add verification data
zdaq12 6123f4c
testing logic
zdaq12 38f0317
testing file
zdaq12 2052679
regenerate testing data
zdaq12 06d2d57
update testing tolerances -> all default
zdaq12 1a4b19b
Merge branch 'main' into aerosol_water
zdaq12 ff6869c
Remove duplicate fnlog_gamZ_output_ts_0
zdaq12 ba8f1e4
new testing data for gas_difusivity and fuchs_sutugin
zdaq12 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
4 changes: 2 additions & 2 deletions
4
src/verification/data_sets/mosaic/MTEM_compute_log_gamZ_input_ts_0.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
src/verification/data_sets/mosaic/MTEM_compute_log_gamZ_output_ts_0.py
Large diffs are not rendered by default.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
src/verification/data_sets/mosaic/aerosol_water_input_ts_0.yaml
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,10 @@ | ||
|
|
||
| TChem-atm: | ||
| function: aerosol_water | ||
| input: | ||
| fixed: | ||
| electrolyte: [ 0.77984160884932792E-003, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.32374869443985588E-003, 0.10558591027558305E-003, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000] | ||
| aH2O_a: [ 0.86918676121422112E+000] | ||
| jaerosolstate: [ 2] | ||
| jphase: [ 2] | ||
| jhyst_leg: [ 1] |
25 changes: 25 additions & 0 deletions
25
src/verification/data_sets/mosaic/aerosol_water_output_ts_0.py
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,25 @@ | ||
|
|
||
| # This file was generated by PartMC-mosaic. | ||
|
|
||
| from math import nan as nan, inf as inf | ||
|
|
||
| # Object is just a dynamic container that stores input/output data. | ||
| class Object(object): | ||
| pass | ||
| # Settings are stored here. | ||
| settings = Object() | ||
| # Input is stored here. | ||
| input = Object() | ||
| input.electrolyte=[[ 0.77984160884932792E-003, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.32374869443985588E-003, 0.10558591027558305E-003, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000, 0.00000000000000000E+000,],] | ||
| input.aH2O_a=[[ 0.86918676121422112E+000],] | ||
| input.jaerosolstate=[[ 2],] | ||
| input.jphase=[[ 2],] | ||
| input.jhyst_leg=[[ 1],] | ||
| # Output data is stored here. | ||
| output = Object() | ||
| output.jaerosolstate=[[ 2],] | ||
| output.jphase=[[ 2],] | ||
| output.jhyst_leg=[[ 1],] | ||
| output.aerosol_water=[[ 0.27588384862958057E-012],] | ||
| output.molalities=[[ 0.39938262305308316E+001, 0.20631562926260667E+001, 0.37125449931321697E+001, 0.37125449931321697E+001, 0.57556783407985233E+001, 0.43319966060422557E+001, 0.36061437563583723E+001, 0.19213285418818216E+001, 0.34951712211340586E+001, 0.34951712211340586E+001, 0.49367058281342588E+001, 0.35858101515618990E+001, 0.24386871472805547E+001, 0.19381152331027600E+001, 0.24386871472805547E+001, 0.27333455732066936E+001, 0.27333455732066936E+001, 0.33978613515005995E+001, 0.29236917930711290E+001, 0.26734712617394891E-004, 0.00000000000000000E+000, 0.00000000000000000E+000,],] | ||
| output.aerosol_water=[[ 0.27588384862958057E-012],] |
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
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,88 @@ | ||
| #include "TChem.hpp" | ||
| #include "TChem_Impl_MOSAIC.hpp" | ||
| #include <verification.hpp> | ||
| #include "skywalker.hpp" | ||
|
|
||
| using device_type = typename Tines::UseThisDevice<TChem::exec_space>::type; | ||
| using real_type_1d_view = TChem::real_type_1d_view; | ||
| using ordinal_type = TChem::ordinal_type; | ||
| using namespace skywalker; | ||
| using namespace TChem; | ||
|
|
||
| void aerosol_water(Ensemble *ensemble) { | ||
| ensemble->process([=](const Input &input, Output &output) { | ||
|
|
||
| const auto electrolyte_arr = input.get_array("electrolyte"); | ||
| const auto aH2O_a_arr = input.get_array("aH2O_a"); | ||
| auto jaerosolstate_arr = input.get_array("jaerosolstate"); | ||
| auto jphase_arr = input.get_array("jphase"); | ||
| auto jhyst_leg_arr = input.get_array("jhyst_leg"); | ||
|
|
||
| const auto mmd = TChem::Impl::MosaicModelData<device_type>(); | ||
|
|
||
| real_type_1d_view electrolyte("electrolyte", mmd.nelectrolyte); | ||
| verification::convert_1d_vector_to_1d_view_device(electrolyte_arr, electrolyte); | ||
|
|
||
| real_type_1d_view aH2O_a("aH2O_a", 1); | ||
| verification::convert_1d_vector_to_1d_view_device(aH2O_a_arr, aH2O_a); | ||
|
|
||
| real_type_1d_view jaerosolstate("jaerosolstate", 1); | ||
| verification::convert_1d_vector_to_1d_view_device(jaerosolstate_arr, jaerosolstate); | ||
|
|
||
| real_type_1d_view jphase("jphase", 1); | ||
| verification::convert_1d_vector_to_1d_view_device(jphase_arr, jphase); | ||
|
|
||
| real_type_1d_view jhyst_leg("jhyst_leg", 1); | ||
| verification::convert_1d_vector_to_1d_view_device(jhyst_leg_arr, jhyst_leg); | ||
|
|
||
| real_type_1d_view outputs_aerosol_water("outputs_aerosol_water", 1); | ||
|
|
||
| real_type_1d_view molalities("molalities", mmd.nelectrolyte); | ||
|
|
||
| std::string profile_name ="Verification_test_aerosol_water"; | ||
zdaq12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| using policy_type = | ||
| typename TChem::UseThisTeamPolicy<TChem::exec_space>::type; | ||
| const auto exec_space_instance = TChem::exec_space(); | ||
| const auto host_exec_space = TChem::host_exec_space(); | ||
| policy_type policy(exec_space_instance, 1, Kokkos::AUTO()); | ||
|
|
||
| // Check this routines on GPUs. | ||
| Kokkos::parallel_for( | ||
| profile_name, | ||
| policy, | ||
| KOKKOS_LAMBDA(const typename policy_type::member_type& member) { | ||
|
|
||
| Real& aerosol_water = outputs_aerosol_water(0); | ||
|
|
||
| // Perform the adjustment calculation | ||
| TChem::Impl::MOSAIC<real_type, device_type>::aerosol_water( | ||
| mmd, | ||
| electrolyte, | ||
| aH2O_a(0), | ||
| molalities, | ||
| jaerosolstate(0), | ||
| jphase(0), | ||
| jhyst_leg(0), | ||
| aerosol_water); | ||
| }); | ||
|
|
||
| const auto outputs_aerosol_water_h = Kokkos::create_mirror_view_and_copy(host_exec_space, outputs_aerosol_water); | ||
|
|
||
| Real aerosol_water = outputs_aerosol_water_h(0); | ||
|
|
||
| output.set("aerosol_water", aerosol_water); | ||
|
|
||
| verification::convert_1d_view_device_to_1d_vector(jaerosolstate, jaerosolstate_arr); | ||
| output.set("jaerosolstate", jaerosolstate_arr); | ||
|
|
||
| verification::convert_1d_view_device_to_1d_vector(jhyst_leg, jhyst_leg_arr); | ||
| output.set("jhyst_leg", jhyst_leg_arr); | ||
|
|
||
| verification::convert_1d_view_device_to_1d_vector(jphase, jphase_arr); | ||
| output.set("jphase", jphase_arr); | ||
|
|
||
| std::vector<real_type> molalities_arr(mmd.nelectrolyte); | ||
| verification::convert_1d_view_device_to_1d_vector(molalities, molalities_arr); | ||
| output.set("molalities", molalities_arr); | ||
| }); | ||
| } | ||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number
1.0e-9should be replaced with a named constant to improve code maintainability and clarity about the unit conversion being performed.