Skip to content

Commit 9053de6

Browse files
authored
add implementation and test for MOSAIC function fuchs_sutugin (#112)
* add implementation of fuchs_sutugin * add verification data * testing logic * add const
1 parent 75c6dbc commit 9053de6

File tree

6 files changed

+98
-0
lines changed

6 files changed

+98
-0
lines changed

src/core/impl/TChem_Impl_MOSAIC.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,6 +2566,16 @@ struct MOSAIC{
25662566
b_mtem(5,jA,jE) ))));
25672567
} // fnlog_gamZ
25682568

2569+
KOKKOS_INLINE_FUNCTION static
2570+
void fuchs_sutugin(const real_type& rkn,
2571+
const real_type& a,
2572+
real_type& fuchs_sut) {
2573+
2574+
const real_type rnum = 0.75*a*(1. + rkn);
2575+
const real_type denom = ats<real_type>::pow(rkn, 2.0) + rkn + 0.283*rkn*a + 0.75*a;
2576+
fuchs_sut = rnum/denom;
2577+
} // fuchs_sutugin
2578+
25692579
KOKKOS_INLINE_FUNCTION static
25702580
void gas_diffusivity(const real_type& T_K,
25712581
const real_type& P,
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
TChem-atm:
3+
function: fuchs_sutugin
4+
input:
5+
fixed:
6+
rkn: [ 0.84212889079423601E+001]
7+
a: [ 0.10000000149011612E+000]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
# This file was generated by PartMC-mosaic.
3+
4+
from math import nan as nan, inf as inf
5+
6+
# Object is just a dynamic container that stores input/output data.
7+
class Object(object):
8+
pass
9+
# Settings are stored here.
10+
settings = Object()
11+
# Input is stored here.
12+
input = Object()
13+
input.rkn=[[ 0.84212889079423601E+001],]
14+
input.a=[[ 0.10000000149011612E+000],]
15+
# Output data is stored here.
16+
output = Object()
17+
output.fuchs_sutugin=[[ 0.88709675466146273E-002],]

src/verification/mosaic/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ add_executable(${DRIVER_NAME}.x
99
do_full_deliquescence.cpp
1010
calculate_XT.cpp
1111
fnlog_gamZ.cpp
12+
fuchs_sutugin.cpp
1213
gas_diffusivity.cpp
1314
mean_molecular_speed.cpp
1415
fn_Keq.cpp
@@ -33,6 +34,7 @@ SET(TEST_LIST
3334
do_full_deliquescence_input_ts_0
3435
calculate_XT_input_ts_0
3536
fnlog_gamZ_input_ts_0
37+
fuchs_sutugin_input_ts_0
3638
gas_diffusivity_input_ts_0
3739
mean_molecular_speed_input_ts_0
3840
fn_Keq_input_ts_0
@@ -52,6 +54,7 @@ SET(TEST_BASELINE
5254
do_full_deliquescence_output_ts_0
5355
calculate_XT_output_ts_0
5456
fnlog_gamZ_output_ts_0
57+
fuchs_sutugin_output_ts_0
5558
gas_diffusivity_output_ts_0
5659
mean_molecular_speed_output_ts_0
5760
fn_Keq_output_ts_0
@@ -72,6 +75,7 @@ set(ERROR_THRESHOLDS
7275
${DEFAULT_TOL} # do_full_deliquescence_output_ts_0
7376
${DEFAULT_TOL} # calculate_XT_output_ts_0
7477
1e-6 # fnlog_gamZ_output_ts_0
78+
${DEFAULT_TOL} # fuchs_sutugin_output_ts_0
7579
1e-7 # gas_diffusivity_output_ts_0
7680
${DEFAULT_TOL} # mean_molecular_speed_output_ts_0
7781
1e-6 # fn_Keq_output_ts_0
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#include "TChem.hpp"
2+
#include "TChem_Impl_MOSAIC.hpp"
3+
#include <verification.hpp>
4+
#include "skywalker.hpp"
5+
6+
using device_type = typename Tines::UseThisDevice<TChem::exec_space>::type;
7+
using real_type_1d_view = TChem::real_type_1d_view;
8+
using oridinal_type_1d_view = TChem::ordinal_type_1d_view;
9+
using ordinal_type = TChem::ordinal_type;
10+
using namespace skywalker;
11+
using namespace TChem;
12+
13+
void fuchs_sutugin(Ensemble *ensemble) {
14+
ensemble->process([=](const Input &input, Output &output) {
15+
16+
const auto rkn_arr = input.get_array("rkn");
17+
const auto a_arr = input.get_array("a");
18+
19+
real_type_1d_view rkn("rkn", 1);
20+
verification::convert_1d_vector_to_1d_view_device(rkn_arr, rkn);
21+
22+
real_type_1d_view a("a", 1);
23+
verification::convert_1d_vector_to_1d_view_device(a_arr, a);
24+
25+
// Reals or int that are defined outside of the parallel_for region are passed as const.
26+
real_type_1d_view outputs_fuchs_sutugin("outputs_fuchs_sutugin", 1);
27+
28+
std::string profile_name ="Verification_test_fuchs_sutugin";
29+
using policy_type =
30+
typename TChem::UseThisTeamPolicy<TChem::exec_space>::type;
31+
const auto exec_space_instance = TChem::exec_space();
32+
const auto host_exec_space = TChem::host_exec_space();
33+
policy_type policy(exec_space_instance, 1, Kokkos::AUTO());
34+
35+
Kokkos::parallel_for(
36+
profile_name,
37+
policy,
38+
KOKKOS_LAMBDA(const typename policy_type::member_type& member) {
39+
40+
Real& fuchs_sutugin = outputs_fuchs_sutugin(0);
41+
42+
// Perform the adjustment calculation
43+
TChem::Impl::MOSAIC<real_type, device_type>::fuchs_sutugin(
44+
rkn(0),
45+
a(0),
46+
fuchs_sutugin);
47+
});
48+
49+
const auto outputs_fuchs_sutugin_h = Kokkos::create_mirror_view_and_copy(host_exec_space, outputs_fuchs_sutugin);
50+
51+
Real fuchs_sutugin = outputs_fuchs_sutugin_h(0);
52+
53+
output.set("fuchs_sutugin", fuchs_sutugin);
54+
55+
});
56+
}

src/verification/mosaic/mosaic_driver.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ void calculate_XT(Ensemble *ensemble);
2727

2828
void fnlog_gamZ(Ensemble *ensemble);
2929

30+
void fuchs_sutugin(Ensemble *ensemble);
31+
3032
void gas_diffusivity(Ensemble *ensemble);
3133

3234
void mean_molecular_speed(Ensemble *ensemble);
@@ -82,6 +84,8 @@ int main(int argc, char **argv) {
8284
calculate_XT(ensemble);
8385
} else if (func_name == "fnlog_gamZ") {
8486
fnlog_gamZ(ensemble);
87+
} else if (func_name == "fuchs_sutugin") {
88+
fuchs_sutugin(ensemble);
8589
} else if (func_name == "gas_diffusivity") {
8690
gas_diffusivity(ensemble);
8791
} else if (func_name == "mean_molecular_speed") {

0 commit comments

Comments
 (0)