-
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
Open
singhbalwinder
wants to merge
8
commits into
master
Choose a base branch
from
jroverf/singhbalwinder/eamxx/add-het-frz-p3_rebase1_1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ede97b6
Adds heterogeneous freezing from aerosols in P3 microphysics
singhbalwinder 9be599e
Passes all tests on Compy
singhbalwinder 3a76876
Turn of this feature by default, all P3 tests pass on PM-GPUs
singhbalwinder dcf1f5f
Fixes p3_test by adding new args
singhbalwinder f98ac90
Removes debug statements
singhbalwinder 85b6e6e
Partially remove use_hetfrz_classnuc from arg lists and use runtime_…
singhbalwinder dee8f35
use_hetfrz_classnuc is not controlled only by runtime_options
singhbalwinder 5808e72
Modified CNT function name to more readable name
singhbalwinder 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 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 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 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 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 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
14 changes: 14 additions & 0 deletions
14
components/eamxx/src/physics/p3/eti/p3_ice_classical_nucleation_impl.cpp
This file contains 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,14 @@ | ||
#include "p3_ice_classical_nucleation_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 |
This file contains 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 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
62 changes: 62 additions & 0 deletions
62
components/eamxx/src/physics/p3/impl/p3_ice_classical_nucleation_impl.hpp
This file contains 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,62 @@ | ||
#ifndef P3_ICE_CLASSICAL_NUCLEATION_IMPL_HPP | ||
#define P3_ICE_CLASSICAL_NUCLEATION_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> | ||
::ice_classical_nucleation( | ||
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); | ||
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: | ||
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 |
This file contains 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 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
Oops, something went wrong.
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.
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