16 #include <AMReX_FArrayBox.H>
17 #include <AMReX_Geometry.H>
18 #include <AMReX_TableData.H>
19 #include <AMReX_MultiFabUtil.H>
56 using FabPtr = std::shared_ptr<amrex::MultiFab>;
93 Init (
const amrex::MultiFab& cons_in,
94 const amrex::BoxArray& grids,
95 const amrex::Geometry& geom,
96 const amrex::Real& dt_advance,
97 std::unique_ptr<amrex::MultiFab>& z_phys_nd,
98 std::unique_ptr<amrex::MultiFab>& detJ_cc)
override;
150 AMREX_GPU_HOST_DEVICE
154 const int& SAM_moisture_type,
155 const amrex::Real& fac_cond,
156 const amrex::Real& fac_fus,
157 const amrex::Real& fac_sub,
158 const amrex::Real& an,
159 const amrex::Real& bn,
160 const amrex::Array4<amrex::Real>& tabs_array,
161 const amrex::Array4<amrex::Real>& pres_array,
162 const amrex::Array4<amrex::Real>& qv_array,
163 const amrex::Array4<amrex::Real>& qc_array,
164 const amrex::Array4<amrex::Real>& qi_array,
165 const amrex::Array4<amrex::Real>& qn_array,
166 const amrex::Array4<amrex::Real>& qt_array)
169 amrex::Real tol = 1.0e-4;
172 amrex::Real omn, domn;
173 amrex::Real qsat, dqsat;
174 amrex::Real qsatw, dqsatw;
175 amrex::Real qsati, dqsati;
179 amrex::Real fff, dfff, dtabs;
180 amrex::Real lstar, dlstar;
181 amrex::Real lstarw, lstari;
182 amrex::Real delta_qv, delta_qc, delta_qi;
185 amrex::Real
tabs = tabs_array(i,j,k);
186 amrex::Real
pres = pres_array(i,j,k);
205 if (SAM_moisture_type == 1) {
220 }
else if (SAM_moisture_type == 2) {
226 qsat = omn * qsatw + (1.0-omn) * qsati;
227 dqsat = omn * dqsatw + (1.0-omn) * dqsati
228 + domn * qsatw - domn * qsati;
229 lstar = omn * lstarw + (1.0-omn) * lstari;
230 dlstar = domn * lstarw - domn * lstari;
234 fff = -
tabs + tabs_array(i,j,k) + lstar*(qv_array(i,j,k) - qsat);
237 dfff = -1.0 + dlstar*(qv_array(i,j,k) - qsat) - lstar*dqsat;
245 }
while(std::abs(dtabs) > tol && niter < 20);
251 delta_qv = qv_array(i,j,k) - qsat;
252 delta_qc = std::max(-qc_array(i,j,k), delta_qv * omn);
253 delta_qi = std::max(-qi_array(i,j,k), delta_qv * (1.0-omn));
256 qv_array(i,j,k) = qsat;
257 qc_array(i,j,k) += delta_qc;
258 qi_array(i,j,k) += delta_qi;
259 qn_array(i,j,k) = qc_array(i,j,k) + qi_array(i,j,k);
260 qt_array(i,j,k) = qv_array(i,j,k) + qn_array(i,j,k);
268 std::vector<int>& a_idx,
269 std::vector<std::string>& a_names)
const override
274 a_idx.push_back( 8); a_names.push_back(
"RainAccum");
275 a_idx.push_back( 9); a_names.push_back(
"SnowAccum");
276 a_idx.push_back(10); a_names.push_back(
"GraupAccum");
278 a_idx.push_back( 8); a_names.push_back(
"RainAccum");
339 amrex::TableData<amrex::Real, 1>
rho1d;
342 amrex::TableData<amrex::Real, 1>
qt1d;
343 amrex::TableData<amrex::Real, 1>
qv1d;
344 amrex::TableData<amrex::Real, 1>
qn1d;
346 amrex::TableData<amrex::Real, 1>
gamaz;
347 amrex::TableData<amrex::Real, 1>
zmid;
constexpr amrex::Real lfus
Definition: ERF_Constants.H:67
constexpr amrex::Real tbgmax
Definition: ERF_Constants.H:32
constexpr amrex::Real lsub
Definition: ERF_Constants.H:68
constexpr amrex::Real lcond
Definition: ERF_Constants.H:66
constexpr amrex::Real tbgmin
Definition: ERF_Constants.H:31
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:21
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_dtqsatw(amrex::Real t, amrex::Real p, amrex::Real &dtqsatw)
Definition: ERF_Microphysics_Utils.H:154
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_dtqsati(amrex::Real t, amrex::Real p, amrex::Real &dtqsati)
Definition: ERF_Microphysics_Utils.H:149
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_qsatw(amrex::Real t, amrex::Real p, amrex::Real &qsatw)
Definition: ERF_Microphysics_Utils.H:142
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_qsati(amrex::Real t, amrex::Real p, amrex::Real &qsati)
Definition: ERF_Microphysics_Utils.H:135
Definition: ERF_NullMoist.H:8
void Copy_Micro_to_State(amrex::MultiFab &cons_in) override
Definition: ERF_Update_SAM.cpp:15
void Advance(const amrex::Real &dt_advance, const SolverChoice &sc) override
Definition: ERF_SAM.H:123
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real NewtonIterSat(int &i, int &j, int &k, const int &SAM_moisture_type, const amrex::Real &fac_cond, const amrex::Real &fac_fus, const amrex::Real &fac_sub, const amrex::Real &an, const amrex::Real &bn, const amrex::Array4< amrex::Real > &tabs_array, const amrex::Array4< amrex::Real > &pres_array, const amrex::Array4< amrex::Real > &qv_array, const amrex::Array4< amrex::Real > &qc_array, const amrex::Array4< amrex::Real > &qi_array, const amrex::Array4< amrex::Real > &qn_array, const amrex::Array4< amrex::Real > &qt_array)
Definition: ERF_SAM.H:153
int zlo
Definition: ERF_SAM.H:302
void Precip(const SolverChoice &sc)
Definition: ERF_Precip.cpp:10
amrex::TableData< amrex::Real, 1 > rho1d
Definition: ERF_SAM.H:339
amrex::TableData< amrex::Real, 1 > evapr2
Definition: ERF_SAM.H:336
SAM()
Definition: ERF_SAM.H:60
amrex::MultiFab * m_detJ_cc
Definition: ERF_SAM.H:319
void Copy_State_to_Micro(const amrex::MultiFab &cons_in) override
Definition: ERF_Init_SAM.cpp:88
amrex::TableData< amrex::Real, 1 > evapg1
Definition: ERF_SAM.H:333
void Update_Micro_Vars(amrex::MultiFab &cons_in) override
Definition: ERF_SAM.H:109
amrex::TableData< amrex::Real, 1 > accrgi
Definition: ERF_SAM.H:331
std::shared_ptr< amrex::MultiFab > FabPtr
Definition: ERF_SAM.H:56
amrex::TableData< amrex::Real, 1 > evapg2
Definition: ERF_SAM.H:334
void IceFall(const SolverChoice &sc)
Definition: ERF_IceFall.cpp:10
amrex::Array< FabPtr, MicVar::NumVars > mic_fab_vars
Definition: ERF_SAM.H:322
int m_axis
Definition: ERF_SAM.H:305
amrex::Real m_gOcp
Definition: ERF_SAM.H:314
amrex::Real m_rdOcp
Definition: ERF_SAM.H:315
void Cloud(const SolverChoice &sc)
Definition: ERF_Cloud_SAM.cpp:12
int m_qmoist_size
Definition: ERF_SAM.H:284
amrex::MultiFab * m_z_phys_nd
Definition: ERF_SAM.H:318
amrex::Real m_fac_fus
Definition: ERF_SAM.H:312
bool doprecip
Definition: ERF_SAM.H:308
amrex::TableData< amrex::Real, 1 > evaps1
Definition: ERF_SAM.H:329
amrex::BoxArray m_gtoe
Definition: ERF_SAM.H:296
amrex::TableData< amrex::Real, 1 > zmid
Definition: ERF_SAM.H:347
amrex::Vector< int > MicVarMap
Definition: ERF_SAM.H:290
amrex::TableData< amrex::Real, 1 > qv1d
Definition: ERF_SAM.H:343
amrex::Real m_fac_cond
Definition: ERF_SAM.H:311
amrex::TableData< amrex::Real, 1 > accrsi
Definition: ERF_SAM.H:326
amrex::TableData< amrex::Real, 1 > accrrc
Definition: ERF_SAM.H:325
bool docloud
Definition: ERF_SAM.H:308
void Compute_Coefficients()
Definition: ERF_Init_SAM.cpp:140
amrex::TableData< amrex::Real, 1 > pres1d
Definition: ERF_SAM.H:340
int nlev
Definition: ERF_SAM.H:302
int m_qstate_size
Definition: ERF_SAM.H:287
amrex::Geometry m_geom
Definition: ERF_SAM.H:293
amrex::TableData< amrex::Real, 1 > evapr1
Definition: ERF_SAM.H:335
amrex::Real m_fac_sub
Definition: ERF_SAM.H:313
amrex::TableData< amrex::Real, 1 > evaps2
Definition: ERF_SAM.H:330
void Init(const amrex::MultiFab &cons_in, const amrex::BoxArray &grids, const amrex::Geometry &geom, const amrex::Real &dt_advance, std::unique_ptr< amrex::MultiFab > &z_phys_nd, std::unique_ptr< amrex::MultiFab > &detJ_cc) override
Definition: ERF_Init_SAM.cpp:22
amrex::TableData< amrex::Real, 1 > qn1d
Definition: ERF_SAM.H:344
amrex::TableData< amrex::Real, 1 > accrgc
Definition: ERF_SAM.H:332
amrex::TableData< amrex::Real, 1 > accrsc
Definition: ERF_SAM.H:327
amrex::TableData< amrex::Real, 1 > qt1d
Definition: ERF_SAM.H:342
amrex::TableData< amrex::Real, 1 > coefice
Definition: ERF_SAM.H:328
int zhi
Definition: ERF_SAM.H:302
void Define(SolverChoice &sc) override
Definition: ERF_SAM.H:79
int Qstate_Size() override
Definition: ERF_SAM.H:148
void Qmoist_Restart_Vars(const SolverChoice &a_sc, std::vector< int > &a_idx, std::vector< std::string > &a_names) const override
Definition: ERF_SAM.H:267
int Qmoist_Size() override
Definition: ERF_SAM.H:145
void PrecipFall(const SolverChoice &sc)
Definition: ERF_PrecipFall.cpp:15
void Update_State_Vars(amrex::MultiFab &cons_in) override
Definition: ERF_SAM.H:116
amrex::TableData< amrex::Real, 1 > tabs1d
Definition: ERF_SAM.H:341
amrex::TableData< amrex::Real, 1 > gamaz
Definition: ERF_SAM.H:346
amrex::MultiFab * Qmoist_Ptr(const int &varIdx) override
Definition: ERF_SAM.H:135
amrex::Real dt
Definition: ERF_SAM.H:299
@ NumVars
Definition: ERF_SAM.H:50
@ pres
Definition: ERF_SAM.H:33
@ qpr
Definition: ERF_SAM.H:42
@ qci
Definition: ERF_SAM.H:39
@ qv
Definition: ERF_SAM.H:37
@ rho
Definition: ERF_SAM.H:30
@ snow_accum
Definition: ERF_SAM.H:47
@ qpg
Definition: ERF_SAM.H:44
@ omega
Definition: ERF_SAM.H:49
@ qt
Definition: ERF_SAM.H:35
@ qn
Definition: ERF_SAM.H:36
@ rain_accum
Definition: ERF_SAM.H:46
@ theta
Definition: ERF_SAM.H:31
@ qcl
Definition: ERF_SAM.H:38
@ graup_accum
Definition: ERF_SAM.H:48
@ tabs
Definition: ERF_SAM.H:32
@ qps
Definition: ERF_SAM.H:43
@ qp
Definition: ERF_SAM.H:41
Definition: ERF_DataStruct.H:78
amrex::Real rdOcp
Definition: ERF_DataStruct.H:581
amrex::Real c_p
Definition: ERF_DataStruct.H:580
bool do_precip
Definition: ERF_DataStruct.H:641
MoistureType moisture_type
Definition: ERF_DataStruct.H:627
bool do_cloud
Definition: ERF_DataStruct.H:640
int ave_plane
Definition: ERF_DataStruct.H:638