Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions src/mam4xx/aging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ class Aging {
Config(const Config &) = default;
~Config() = default;
Config &operator=(const Config &) = default;

// Number of so4(+nh4) monolayers needed to "age" a carbon particle.
// In E3SM this is read in from an input file and would be 8.
// In mam_refactor it is defined in phys_control.F90 as 3.
Real n_so4_monolayers_pcage = 8.0;
};

private:
Expand All @@ -33,13 +38,6 @@ class Aging {
void init(const AeroConfig &aero_config,
const Config &process_config = Config());

// In E3SM this is read in from an input file and would be 8
// In mam_refactor it is defined in phys_control.F90 as 3.

static constexpr Real n_so4_monolayers_pcage = 8.0;
static constexpr Real dr_so4_monolayers_pcage =
n_so4_monolayers_pcage * 4.76e-10;

// validate -- validates the given atmospheric state and prognostics against
// assumptions made by this implementation, returning true if the states are
// valid, false if not
Expand All @@ -66,6 +64,7 @@ namespace aging {
// change due to condenstion and coagulation
KOKKOS_INLINE_FUNCTION
void mam_pcarbon_aging_frac(
const Real n_so4_monolayers_pcage,
const Real dgn_a[AeroConfig::num_modes()], // dry geometric mean diameter of
// number distribution [m]
const Real qaer_cur[AeroConfig::num_aerosol_ids()]
Expand Down Expand Up @@ -152,8 +151,11 @@ void mam_pcarbon_aging_frac(
const Real xferfrac_max = 1.0 - 10.0 * haero::epsilon(); // 1-eps

const Real xferfrac_tmp1 = vol_shell * dgn_a[imom_pc] * fac_volsfc;

// use 1 mol (bi-)sulfate = 65 cm^3 --> 1 molecule = (4.76e-10 m)^3
const Real dr_so4_monolayers_pcage = n_so4_monolayers_pcage * 4.76e-10;
const Real xferfrac_tmp2 =
haero::max(6.0 * Aging::dr_so4_monolayers_pcage * vol_core, 0.0);
haero::max(6.0 * dr_so4_monolayers_pcage * vol_core, 0.0);

if (xferfrac_tmp1 >= xferfrac_tmp2) {
xferfrac_pcage = xferfrac_max;
Expand Down Expand Up @@ -229,6 +231,7 @@ void transfer_cond_coag_mass_to_accum(

KOKKOS_INLINE_FUNCTION
void mam_pcarbon_aging_1subarea(
const Real n_so4_monolayers_pcage,
const Real dgn_a[AeroConfig::num_modes()], // dry geometric mean diameter of
// number distribution [m]
Real qnum_cur[AeroConfig::num_modes()], // aerosol number mixing ratio
Expand Down Expand Up @@ -262,8 +265,9 @@ void mam_pcarbon_aging_1subarea(
const int nsrc = static_cast<int>(ModeIndex::PrimaryCarbon);
const int ndest = static_cast<int>(ModeIndex::Accumulation);

mam_pcarbon_aging_frac(dgn_a, qaer_cur, qaer_del_cond, qaer_del_coag_in,
xferfrac_pcage, frac_cond, frac_coag);
mam_pcarbon_aging_frac(n_so4_monolayers_pcage, dgn_a, qaer_cur, qaer_del_cond,
qaer_del_coag_in, xferfrac_pcage, frac_cond,
frac_coag);
// Note, there are probably optimizations to be done here, closely following
// the Fortran code required extra unpacking of arrays.

Expand Down Expand Up @@ -383,9 +387,9 @@ void aerosol_aging_rates_1box(const int k, const AeroConfig &aero_config,
}

// primary carbon aging
mam_pcarbon_aging_1subarea(dgn_a, qnum_cur, qnum_del_cond, qnum_del_coag,
qaer_cur, qaer_del_cond, qaer_del_coag,
qaer_del_coag_in);
mam_pcarbon_aging_1subarea(config.n_so4_monolayers_pcage, dgn_a, qnum_cur,
qnum_del_cond, qnum_del_coag, qaer_cur,
qaer_del_cond, qaer_del_coag, qaer_del_coag_in);

// compute the tendencies
for (int imode = 0; imode < num_mode; ++imode) {
Expand Down
4 changes: 2 additions & 2 deletions src/mam4xx/convproc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,8 @@ class ConvProc {
// Set nucleation-specific config parameters.
config_ = convproc_config;
Kokkos::resize(scratch1Dviews[q], config_.nlev * aero_model::pcnst);
Kokkos::resize(scratch1Dviews[mu], config_.nlev);
Kokkos::resize(scratch1Dviews[md], config_.nlev);
Kokkos::resize(scratch1Dviews[mu], config_.nlev + 1);
Kokkos::resize(scratch1Dviews[md], config_.nlev + 1);
Kokkos::resize(scratch1Dviews[eudp], config_.nlev);
Kokkos::resize(scratch1Dviews[dudp], config_.nlev);
Kokkos::resize(scratch1Dviews[eddp], config_.nlev);
Expand Down
40 changes: 22 additions & 18 deletions src/mam4xx/mam4_amicphys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1127,11 +1127,12 @@ void mam_amicphys_1subarea(
const int newnuc_h2so4_conc_optaa, const int gaexch_h2so4_uptake_optaa,
const bool do_cond_sub, const bool do_rename_sub, const bool do_newnuc_sub,
const bool do_coag_sub, const Real deltat, const int jsubarea,
const bool iscldy_subarea, const Real afracsub, const Real temp,
const Real pmid, const Real pdel, const Real zmid, const Real pblh,
const Real relhumsub, const Real (&dgn_a)[num_modes],
const Real (&dgn_awet)[num_modes], const Real (&wetdens)[num_modes],
const Real (&qgas1)[max_gas()], const Real (&qgas3)[max_gas()],
const bool iscldy_subarea, const Real n_so4_monolayers_pcage,
const Real afracsub, const Real temp, const Real pmid, const Real pdel,
const Real zmid, const Real pblh, const Real relhumsub,
const Real (&dgn_a)[num_modes], const Real (&dgn_awet)[num_modes],
const Real (&wetdens)[num_modes], const Real (&qgas1)[max_gas()],
const Real (&qgas3)[max_gas()],
// inout
Real (&qgas_cur)[max_gas()], Real (&qgas_delaa)[max_gas()][nqtendaa()],
// in
Expand Down Expand Up @@ -1663,7 +1664,7 @@ void mam_amicphys_1subarea(

if (do_aging_in_subarea) {
mam4::aging::mam_pcarbon_aging_1subarea(
dgn_a, // input
n_so4_monolayers_pcage, dgn_a, // input
qnum_cur, qnum_delsub_cond, qnum_delsub_coag, // in-outs
qaer_cur, qaer_delsub_cond, qaer_delsub_coag, // in-outs
qaer_delsub_coag_in); // in-outs
Expand Down Expand Up @@ -1698,10 +1699,11 @@ void mam_amicphys_1gridcell(
// in
const AmicPhysConfig &config, const Real deltat, const int nsubarea,
const int ncldy_subarea, const bool (&iscldy_subarea)[maxsubarea()],
const Real (&afracsub)[maxsubarea()], const Real temp, const Real pmid,
const Real pdel, const Real zmid, const Real pblh,
const Real (&relhumsub)[maxsubarea()], const Real (&dgn_a)[num_modes],
const Real (&dgn_awet)[num_modes], const Real (&wetdens)[num_modes],
const Real (&afracsub)[maxsubarea()], const Real n_so4_monolayers_pcage,
const Real temp, const Real pmid, const Real pdel, const Real zmid,
const Real pblh, const Real (&relhumsub)[maxsubarea()],
const Real (&dgn_a)[num_modes], const Real (&dgn_awet)[num_modes],
const Real (&wetdens)[num_modes],
const Real (&qsub1)[gas_pcnst][maxsubarea()],
const Real (&qsub2)[gas_pcnst][maxsubarea()],
const Real (&qqcwsub2)[gas_pcnst][maxsubarea()],
Expand Down Expand Up @@ -1909,8 +1911,9 @@ void mam_amicphys_1gridcell(
// in
config.gaexch_h2so4_uptake_optaa, config.newnuc_h2so4_conc_optaa,
do_cond, do_rename, do_newnuc, do_coag, deltat, jsub,
iscldy_subarea[jsub], afracsub[jsub], temp, pmid, pdel, zmid, pblh,
relhumsub[jsub], dgn_a, dgn_awet, wetdens, qgas1, qgas3, qgas4,
iscldy_subarea[jsub], n_so4_monolayers_pcage, afracsub[jsub], temp,
pmid, pdel, zmid, pblh, relhumsub[jsub], dgn_a, dgn_awet, wetdens,
qgas1, qgas3, qgas4,
qgas_delaa, // out
qnum3, // in
qnum4, qnum_delaa, // out
Expand Down Expand Up @@ -2115,9 +2118,10 @@ void get_gcm_tend_diags_from_subareas(
KOKKOS_INLINE_FUNCTION
void modal_aero_amicphys_intr(
// in
const AmicPhysConfig &config, const Real deltat, const Real temp,
const Real pmid, const Real pdel, const Real zm, const Real pblh,
const Real qv, const Real cld,
const AmicPhysConfig &config, const Real deltat,
const Real n_so4_monolayers_pcage, const Real temp, const Real pmid,
const Real pdel, const Real zm, const Real pblh, const Real qv,
const Real cld,
// in/out
Real qq[gas_pcnst], Real qqcw[gas_pcnst],
// in
Expand Down Expand Up @@ -2297,9 +2301,9 @@ void modal_aero_amicphys_intr(
Real qqcwsub_tendaa[gas_pcnst][nqqcwtendaa()][maxsubarea()] = {};
mam_amicphys_1gridcell(
// in
config, deltat, nsubarea, ncldy_subarea, iscldy_subarea, afracsub, temp,
pmid, pdel, zm, pblh, relhumsub, dgn_a, dgn_awet, wetdens, qsub1, qsub2,
qqcwsub2, qsub3, qqcwsub3,
config, deltat, nsubarea, ncldy_subarea, iscldy_subarea, afracsub,
n_so4_monolayers_pcage, temp, pmid, pdel, zm, pblh, relhumsub, dgn_a,
dgn_awet, wetdens, qsub1, qsub2, qqcwsub2, qsub3, qqcwsub3,
// inout
qaerwatsub3, qsub4, qqcwsub4, qaerwatsub4, qsub_tendaa, qqcwsub_tendaa);

Expand Down
14 changes: 8 additions & 6 deletions src/mam4xx/mo_gas_phase_chemdr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@ void mmr2vmr_col(const ThreadTeam &team, const haero::Atmosphere &atm,
KOKKOS_INLINE_FUNCTION
void perform_atmospheric_chemistry_and_microphysics(
const ThreadTeam &team, const Real dt, const Real rlats,
const Real sfc_temp, const Real pressure_sfc, const Real wind_speed,
const Real rain, const Real solar_flux,
const View1D cnst_offline_icol[num_tracer_cnst], const Forcing *forcings_in,
const haero::Atmosphere &atm, const PhotoTableData &photo_table,
const Real chlorine_loading, const mam4::mo_setsox::Config &config_setsox,
const Real n_so4_monolayers_pcage, const Real sfc_temp,
const Real pressure_sfc, const Real wind_speed, const Real rain,
const Real solar_flux, const View1D cnst_offline_icol[num_tracer_cnst],
const Forcing *forcings_in, const haero::Atmosphere &atm,
const PhotoTableData &photo_table, const Real chlorine_loading,
const mam4::mo_setsox::Config &config_setsox,
const AmicPhysConfig &config_amicphys, const Real linoz_psc_T,
const Real zenith_angle_icol, const Real d_sfc_alb_dir_vis_icol,
const View1D &o3_col_dens_i, const View2D &photo_rates_icol,
Expand Down Expand Up @@ -361,7 +362,8 @@ void perform_atmospheric_chemistry_and_microphysics(
// coagulation)
mam4::microphysics::modal_aero_amicphys_intr(
// in
config_amicphys, dt, temp, pmid, pdel, zm, pblh, qv, cldfrac,
config_amicphys, dt, n_so4_monolayers_pcage, temp, pmid, pdel, zm, pblh,
qv, cldfrac,
// out
vmr, vmrcw,
// in
Expand Down
8 changes: 4 additions & 4 deletions src/tests/mam4_aging_unit_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,10 @@ TEST_CASE("mam4_pcarbon_aging_1subarea", "mam4_aging_process") {
qaer_del_coag_in[ispec][imode] = 0.0;
}
}

aging::mam_pcarbon_aging_1subarea(dgn_a, qnum_cur, qnum_del_cond,
qnum_del_coag, qaer_cur, qaer_del_cond,
qaer_del_coag, qaer_del_coag_in);
const Real n_so4_monolayers_pcage = 8;
aging::mam_pcarbon_aging_1subarea(
n_so4_monolayers_pcage, dgn_a, qnum_cur, qnum_del_cond, qnum_del_coag,
qaer_cur, qaer_del_cond, qaer_del_coag, qaer_del_coag_in);

// Passing in zeros for everything should give zeros back
for (int imode = 0; imode < AeroConfig::num_modes(); ++imode) {
Expand Down
8 changes: 4 additions & 4 deletions src/validation/aging/mam_pcarbon_aging_1subarea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ void mam_pcarbon_aging_1subarea(Ensemble *ensemble) {
n += 1;
}
}

const Real n_so4_monolayers_pcage = 8;
aging::mam_pcarbon_aging_1subarea(
dgn_a_f.data(), qnum_cur_f.data(), qnum_del_cond_f.data(),
qnum_del_coag_f.data(), qaer_cur_c, qaer_del_cond_c, qaer_del_coag_c,
qaer_del_coag_in_c);
n_so4_monolayers_pcage, dgn_a_f.data(), qnum_cur_f.data(),
qnum_del_cond_f.data(), qnum_del_coag_f.data(), qaer_cur_c,
qaer_del_cond_c, qaer_del_coag_c, qaer_del_coag_in_c);

n = 0;
for (int imode = 0; imode < AeroConfig::max_agepair(); ++imode) {
Expand Down
8 changes: 4 additions & 4 deletions src/validation/aging/mam_pcarbon_aging_frac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ void mam_pcarbon_aging_frac(Ensemble *ensemble) {
Real xferfrac_pcage;
Real frac_cond;
Real frac_coag;

aging::mam_pcarbon_aging_frac(dgn_a_f.data(), qaer_cur_c, qaer_del_cond_c,
qaer_del_coag_in_c, xferfrac_pcage, frac_cond,
frac_coag);
const Real n_so4_monolayers_pcage = 8;
aging::mam_pcarbon_aging_frac(
n_so4_monolayers_pcage, dgn_a_f.data(), qaer_cur_c, qaer_del_cond_c,
qaer_del_coag_in_c, xferfrac_pcage, frac_cond, frac_coag);

n = 0;
for (int imode = 0; imode < num_modes; ++imode) {
Expand Down