-
Notifications
You must be signed in to change notification settings - Fork 1
add implementation and test for MOSAIC function gas_diffusivity #111
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 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
9 changes: 9 additions & 0 deletions
9
src/verification/data_sets/mosaic/gas_diffusivity_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,9 @@ | ||
|
||
TChem-atm: | ||
function: gas_diffusivity | ||
input: | ||
fixed: | ||
T_K: [ 0.29142360000000002E+003] | ||
P: [ 0.98692326671601283E+000] | ||
MW: [ 0.98000000000000000E+002] | ||
Vm: [ 0.42880001068115234E+002] |
19 changes: 19 additions & 0 deletions
19
src/verification/data_sets/mosaic/gas_diffusivity_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,19 @@ | ||
|
||
# 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.T_K=[[ 0.29142360000000002E+003],] | ||
input.P=[[ 0.98692326671601283E+000],] | ||
input.MW=[[ 0.98000000000000000E+002],] | ||
input.Vm=[[ 0.42880001068115234E+002],] | ||
# Output data is stored here. | ||
output = Object() | ||
output.gas_diffusivity=[[ 0.11449280832155644E+000],] |
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,66 @@ | ||
#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 oridinal_type_1d_view = TChem::ordinal_type_1d_view; | ||
using ordinal_type = TChem::ordinal_type; | ||
using namespace skywalker; | ||
using namespace TChem; | ||
|
||
void gas_diffusivity(Ensemble *ensemble) { | ||
ensemble->process([=](const Input &input, Output &output) { | ||
|
||
const auto T_K_arr = input.get_array("T_K"); | ||
const auto P_arr = input.get_array("P"); | ||
const auto MW_arr = input.get_array("MW"); | ||
const auto Vm_arr = input.get_array("Vm"); | ||
|
||
real_type_1d_view T_K("T_K", 1); | ||
verification::convert_1d_vector_to_1d_view_device(T_K_arr, T_K); | ||
|
||
real_type_1d_view P("P", 1); | ||
verification::convert_1d_vector_to_1d_view_device(P_arr, P); | ||
|
||
real_type_1d_view MW("MW", 1); | ||
verification::convert_1d_vector_to_1d_view_device(MW_arr, MW); | ||
|
||
real_type_1d_view Vm("Vm", 1); | ||
verification::convert_1d_vector_to_1d_view_device(Vm_arr, Vm); | ||
|
||
// Reals or int that are defined outside of the parallel_for region are passed as const. | ||
real_type_1d_view outputs_gas_diffusivity("outputs_gas_diffusivity", 1); | ||
|
||
std::string profile_name ="Verification_test_gas_diffusivity"; | ||
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()); | ||
|
||
Kokkos::parallel_for( | ||
profile_name, | ||
policy, | ||
KOKKOS_LAMBDA(const typename policy_type::member_type& member) { | ||
|
||
Real& gas_diffusivity = outputs_gas_diffusivity(0); | ||
|
||
// Perform the adjustment calculation | ||
TChem::Impl::MOSAIC<real_type, device_type>::gas_diffusivity( | ||
T_K(0), | ||
P(0), | ||
MW(0), | ||
Vm(0), | ||
gas_diffusivity); | ||
}); | ||
|
||
const auto outputs_gas_diffusivity_h = Kokkos::create_mirror_view_and_copy(host_exec_space, outputs_gas_diffusivity); | ||
|
||
Real gas_diffusivity = outputs_gas_diffusivity_h(0); | ||
|
||
output.set("gas_diffusivity", gas_diffusivity); | ||
|
||
}); | ||
} |
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.
I wonder if replacing 0.333333 with 1./3. might help reduce the ERROR_THRESHOLDS. Given the simplicity of this expression, I was expecting a smaller error margin to pass the test.