-
Notifications
You must be signed in to change notification settings - Fork 376
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
EAMxx: Adds aerosols heterogeneous freezing calculations in P3 microphysics #6947
base: master
Are you sure you want to change the base?
Changes from 2 commits
ede97b6
9be599e
3a76876
dcf1f5f
f98ac90
85b6e6e
dee8f35
5808e72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include "p3_CNT_couple_impl.hpp" | ||
|
||
namespace scream { | ||
namespace p3 { | ||
|
||
/* | ||
* Explicit instantiation for doing conservation functions on Reals using the | ||
* default device. | ||
*/ | ||
|
||
template struct Functions<Real,DefaultDevice>; | ||
|
||
} // namespace p3 | ||
} // namespace scream |
singhbalwinder marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#ifndef P3_CNT_COUPLE_IMPL_HPP | ||
#define P3_CNT_COUPLE_IMPL_HPP | ||
|
||
#include "p3_functions.hpp" // for ETI only but harmless for GPU | ||
|
||
namespace scream { | ||
namespace p3 { | ||
|
||
/* | ||
*/ | ||
|
||
template <typename S, typename D> | ||
KOKKOS_FUNCTION | ||
void Functions<S,D> | ||
::CNT_couple( | ||
const Spack& frzimm, const Spack& frzcnt, | ||
const Spack& frzdep, const Spack& rho, | ||
const Spack& qc_incld, const Spack& nc_incld, | ||
const int Iflag, | ||
Spack& ncheti_cnt, Spack& qcheti_cnt, | ||
Spack& nicnt, Spack& qicnt, | ||
Spack& ninuc_cnt, Spack& qinuc_cnt) | ||
{ | ||
constexpr Scalar pi = C::Pi; | ||
constexpr Scalar rho_h2o = C::RHO_H2O; | ||
|
||
// TODO: Verify if qsmall can be unified with other "small" numeric literals | ||
constexpr Scalar qsmall = 1.0e-18; | ||
constexpr Scalar piov3 = pi/3.0; | ||
|
||
// TODO: Verify if 1.0e-18 can be unified with other "small" numeric literals | ||
constexpr Scalar mi0 = 4.0*piov3*900.0*1.0e-18; // BAD_CONSTANT! | ||
|
||
const Spack Zero(0.0); | ||
// minimum mass of new crystal due to freezing of cloud droplets done | ||
// externally (kg) | ||
|
||
const Scalar mi0l_min = (4.0/3.0)*pi*rho_h2o*(4.0e-6)*(4.0e-6)*(4.0e-6); | ||
Spack mi0l = qc_incld/ekat::max(nc_incld,1.0e6/rho); | ||
mi0l = ekat::max(mi0l_min, mi0l); | ||
|
||
const auto mask = qc_incld > qsmall; | ||
switch (Iflag) { | ||
case 1: // cloud droplet immersion freezing | ||
ncheti_cnt.set(mask, frzimm*1.0e6/rho /* frzimm input is in [#/cm3] */ , Zero); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In all these "set" calls, how often do you expect the mask to be true/false? If the mask could often be ALL false (not sometimes, often), then you may consider using if statements, to avoid computing the packs for the true case for nothing (e.g., in the 1st line we have to compute Note: this nano-opt makes sense only if you expect mask to be often false. I assume that's not the case, since qsmall is very small. But I don't know how qc_incld is computed, so maybe it's often 0? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is a good question. I am not sure about that. @kaizhangpnl or @AaronDonahue might know if |
||
qcheti_cnt.set(mask, ncheti_cnt*mi0l, Zero); | ||
break; | ||
case 2: // deposition freezing / contact freezing | ||
nicnt.set(mask, frzcnt*1.0e6/rho, Zero); | ||
qicnt.set(mask, nicnt*mi0l, Zero); | ||
ninuc_cnt.set(mask, frzdep*1.0e6/rho, Zero); | ||
qinuc_cnt.set(mask, ninuc_cnt*mi0, Zero); | ||
break; | ||
default: | ||
singhbalwinder marked this conversation as resolved.
Show resolved
Hide resolved
|
||
EKAT_KERNEL_ERROR_MSG("Error! Unhandled case in switch statement for Iflag in p3_CNT_couple_impl.hpp .\n"); | ||
break; | ||
} | ||
} | ||
} // namespace p3 | ||
} // namespace scream | ||
|
||
#endif |
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.
@singhbalwinder this is the last potential important comment, otherwise, I think the PR is mergeable:
What happens if MAM is inactive? What happens to these variables? Maybe we should make these hidden behind if-else? IF so, make sure to do the same below (around 333):
where in the unused/uneeded case, you can use the buffer.unused or something like that
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.
When MAM is inactive, values for these variables will be picked up from the namelist and will stay the same for the entire simulation. The simulation will run as usual with no impact from these variables.
I can hide it behind an if/else if it is not the desired behavior. Is there a way for P3 to know if MAM4 is active or not? Previously, when I discussed this, the design principle did not allow this, as each parameterization should be able to run independently without the knowledge of other parameterizations/processes. Otherwise, it makes the logic complex (e.g., to decide if different combinations of processes are valid or not). If it has changed, please let me know, and I will add if/else blocks.
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.
If they are defined, then there's no need to worry (I wasn't aware they would be defined; this is a little surprising to me tbh)
For hiding them, I would use the boolean you're adding here (hetfrz). It doesn't matter though, whether these statements are hidden or not, won't make a difference as far as I could tell. I was worried a CIME case would error out if these variables are here, but MAM is inactive. I guess we will pick this up in testing soon enough :)
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 think I would hide these behind the boolean you introduced in this PR. For the other branch of the if, set the buffer.unused or any other dummy values