Skip to content
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

[NDSL] Feature/evap subl pdf #1008

Merged
merged 59 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
75c155b
First bit of the evap_subl_pdf port. Initial calculation verifies, me…
CharlesKrop Aug 2, 2024
2a637ff
Updates to the evap_subl_pdf loop. meltfrz now verifies (excluding mi…
CharlesKrop Aug 8, 2024
e34e449
Additional minor changes to hystpdf, various other minor QOL changes
CharlesKrop Aug 14, 2024
881811d
Merge branch 'dsl/develop' into feature/evap_subl_pdf
CharlesKrop Aug 14, 2024
b30ae8d
SaturationVaporPressureTable code first pass
FlorianDeconinck Aug 14, 2024
cde8399
QSat_Ice_scalar_exact
FlorianDeconinck Aug 14, 2024
dd15d29
Fix calculation. Table generates OK.
FlorianDeconinck Aug 14, 2024
e6b597c
Fix Murphy and CAM
FlorianDeconinck Aug 14, 2024
5e4e464
Rename estimate_table -> table
FlorianDeconinck Aug 15, 2024
f75089f
Merge branch 'dsl/QSat' into feature/evap_subl_pdf
CharlesKrop Aug 15, 2024
40cc636
Creation of QSat stencil, which still needs a lot of work. Need to pu…
CharlesKrop Aug 16, 2024
4af83f6
Functional QSat module, fails at majority of points but error pattern…
CharlesKrop Aug 26, 2024
7907680
Updates to QSat and a few other minor QOL changes
CharlesKrop Aug 28, 2024
c59d081
One more change that wasn't staged for some reason
CharlesKrop Aug 28, 2024
b80185c
Functional QSat module. Can handle optional RAMP/PASCALS/DQSAT inputs…
CharlesKrop Aug 28, 2024
16ffeb0
Merge branch 'dsl/QSat' into feature/evap_subl_pdf
CharlesKrop Aug 28, 2024
1065cff
More clean up, first attempt at QSat function
CharlesKrop Aug 28, 2024
37209b9
Merge branch 'dsl/QSat' into feature/evap_subl_pdf
CharlesKrop Aug 28, 2024
76b6ec5
Working QSat function. QSat class can still be called outside of sten…
CharlesKrop Aug 28, 2024
8b4bd65
Functional find_klcl port. Verifies at all but 2 points. Two failed c…
CharlesKrop Aug 29, 2024
fdbf8aa
Minor change for improved DQSAT functionality
CharlesKrop Sep 3, 2024
4957707
Merge branch 'dsl/QSat' into feature/evap_subl_pdf
CharlesKrop Sep 3, 2024
035f1a9
Minor change for improved DQSAT functionality
CharlesKrop Sep 3, 2024
509884d
Merge branch 'dsl/QSat' into feature/evap_subl_pdf
CharlesKrop Sep 3, 2024
63e1ed2
Reorganization of functions/stencils from evap_subl_pdf loop to new d…
CharlesKrop Sep 3, 2024
d826f35
Two new functions: QSat_Float_Liquid and QSat_Float_Ice. These two fu…
CharlesKrop Sep 3, 2024
f41b979
Merge commit 'd826f3590a3f5135dddf8a20aa4083fa1511a333' into feature/…
CharlesKrop Sep 3, 2024
1bc2787
Completed (but untested) hystpdf. Lots of problems compiling the sten…
CharlesKrop Sep 5, 2024
5aa9b48
Tiny little bugfix fro QSat_Float_Liquid and QSat_Float_Ice
CharlesKrop Sep 5, 2024
0d3a43e
hystpdf compiles, few fixes to deal with various gt4py/ndsl related e…
CharlesKrop Sep 6, 2024
b4998d6
Fixed indexing error in QSat_Float_Liquid/Ice, and inserted a workaro…
CharlesKrop Sep 6, 2024
5b19522
hystpdf nearly verifies. lots of small errors, potentially rounding/3…
CharlesKrop Sep 9, 2024
5cc9dd6
Code cleanup, ready to be pulled back into main branch
CharlesKrop Sep 10, 2024
d9d13ed
Few more cleanups, modification to translate test to test sat tables
CharlesKrop Sep 10, 2024
b4d35f9
QSat verifies if tables are read in from netcdf (this is the current …
CharlesKrop Sep 11, 2024
203224a
Merge branch 'dsl/QSat' into feature/evap_subl_pdf
CharlesKrop Sep 11, 2024
a93a35e
Merge branch 'dsl/develop' into dsl/QSat
Sep 12, 2024
1c96c31
Fix run tests
Sep 12, 2024
e3c636e
Functional QSat module. Table calculations are still incorrect due to…
CharlesKrop Sep 12, 2024
e1e37a7
Merge branch 'dsl/QSat' into feature/evap_subl_pdf
CharlesKrop Sep 12, 2024
87f19d4
Merged new QSat, manually fixed the qsat bugs that didn't make it pre…
CharlesKrop Sep 12, 2024
d78c1d8
Debugging hystpdf, commiting now to pull new dsl/develop pr with QSat…
CharlesKrop Sep 13, 2024
3dff83a
Merge remote-tracking branch 'origin/dsl/develop' into feature/evap_s…
CharlesKrop Sep 13, 2024
5a4ff4d
Functional hystpdf, verifies... when constants behave
CharlesKrop Sep 23, 2024
d169c33
Merge remote-tracking branch 'origin/dsl/develop' into feature/evap_s…
CharlesKrop Sep 26, 2024
9591abd
Functional, verified evap_subl_pdf loop.
CharlesKrop Sep 26, 2024
d6df177
Update GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSmoist_GridComp/pyMo…
CharlesKrop Sep 26, 2024
c23cd3e
Bunch of changes per Florian's comments on the PR
CharlesKrop Sep 27, 2024
4e535c3
Merge branch 'feature/evap_subl_pdf' of github.com:GEOS-ESM/GEOSgcm_G…
CharlesKrop Sep 27, 2024
52e4a59
Linting (and one file rename)
CharlesKrop Sep 27, 2024
04af119
Update GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSmoist_GridComp/pyMo…
CharlesKrop Sep 27, 2024
4545264
More changes for the PR
CharlesKrop Sep 27, 2024
5bdf728
One last change
CharlesKrop Sep 27, 2024
cf2ee79
Lint
Sep 27, 2024
3ba1a48
Changes per Tobias' comments less a proper variable naming scheme and…
CharlesKrop Oct 7, 2024
f5b88ca
Couple more changes based on Florian & Tobias comments. find_klcl rem…
CharlesKrop Oct 9, 2024
30f19a6
Delete GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSmoist_GridComp/pyMo…
FlorianDeconinck Oct 11, 2024
fd40779
Lint & revert run_tests.sh
Oct 11, 2024
640cd87
ToDo for renaming hystpdf
Oct 11, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
"""This module is the wrapper for the GFDL_1M microphysics scheme (in progress). I/O and error
handling is performed here. Calculations can be found in deeper functions."""

from ndsl import QuantityFactory, StencilFactory, orchestrate
from ndsl.constants import X_DIM, Y_DIM, Z_DIM
from ndsl.dsl.typing import Float, FloatField, FloatFieldIJ
from pyMoist.GFDL_1M.evap_subl_pdf_core import (
evaporate,
hystpdf,
initial_calc,
melt_freeze,
sublimate,
)
from pyMoist.saturation.formulation import SaturationFormulation
from pyMoist.saturation.qsat import QSat
from pyMoist.shared_gt4py_workarounds import get_last, hybrid_index_2dout
from pyMoist.shared_incloud_processes import fix_up_clouds


class GFDL_1M:
"""This class is the wrapper for the GFDL_1M microphysics scheme. I/O and error handling
are perfromed at this level, all calculations are performed within deeper functions.
"""

def __init__(
self,
stencil_factory: StencilFactory,
quantity_factory: QuantityFactory,
formulation: SaturationFormulation = SaturationFormulation.Staars,
use_bergeron: bool = True,
):
if use_bergeron is not True:
raise NotImplementedError(
"Untested option for use_bergeron. Code may be missing or incomplete. \
Disable this error manually to continue."
)

self.stencil_factory = stencil_factory
self.quantity_factory = quantity_factory

# Initalize QSat tables for later calculations
self.qsat = QSat(
self.stencil_factory,
self.quantity_factory,
formulation=formulation,
)

orchestrate(obj=self, config=stencil_factory.config.dace_config)
self._get_last = self.stencil_factory.from_dims_halo(
func=get_last,
compute_dims=[X_DIM, Y_DIM, Z_DIM],
)
self._hybrid_index_2dout = self.stencil_factory.from_dims_halo(
func=hybrid_index_2dout,
compute_dims=[X_DIM, Y_DIM, Z_DIM],
)
self._initial_calc = self.stencil_factory.from_dims_halo(
func=initial_calc,
compute_dims=[X_DIM, Y_DIM, Z_DIM],
)
self._hystpdf = self.stencil_factory.from_dims_halo(
func=hystpdf,
compute_dims=[X_DIM, Y_DIM, Z_DIM],
externals={
"use_bergeron": use_bergeron,
},
)
self._meltfrz = self.stencil_factory.from_dims_halo(
func=melt_freeze,
compute_dims=[X_DIM, Y_DIM, Z_DIM],
)
self._evap = self.stencil_factory.from_dims_halo(
func=evaporate,
compute_dims=[X_DIM, Y_DIM, Z_DIM],
)
self._subl = self.stencil_factory.from_dims_halo(
func=sublimate,
compute_dims=[X_DIM, Y_DIM, Z_DIM],
)
self._fix_up_clouds = self.stencil_factory.from_dims_halo(
func=fix_up_clouds,
compute_dims=[X_DIM, Y_DIM, Z_DIM],
)
self._tmp = self.quantity_factory.zeros([X_DIM, Y_DIM], "n/a")
self._minrhcrit = self.quantity_factory.zeros([X_DIM, Y_DIM, Z_DIM], "n/a")
self._PLEmb_top = self.quantity_factory.zeros([X_DIM, Y_DIM, Z_DIM], "n/a")
self._PLmb_at_klcl = self.quantity_factory.zeros([X_DIM, Y_DIM], "n/a")
self._halo = self.stencil_factory.grid_indexing.n_halo
self._k_mask = self.quantity_factory.zeros([X_DIM, Y_DIM, Z_DIM], "n/a")
self._alpha = self.quantity_factory.zeros([X_DIM, Y_DIM, Z_DIM], "n/a")
self.rhx = self.quantity_factory.zeros([X_DIM, Y_DIM, Z_DIM], "n/a")
self.evapc = self.quantity_factory.zeros([X_DIM, Y_DIM, Z_DIM], "n/a")
self.sublc = self.quantity_factory.zeros([X_DIM, Y_DIM, Z_DIM], "n/a")
for i in range(0, self._k_mask.view[:].shape[0]):
for j in range(0, self._k_mask.view[:].shape[1]):
for k in range(0, self._k_mask.view[:].shape[2]):
self._k_mask.view[i, j, k] = k + 1

def __call__(
self,
EIS: FloatFieldIJ,
dw_land: Float,
dw_ocean: Float,
PDFSHAPE: Float,
TURNRHCRIT_PARAM: Float,
PLmb: FloatField,
KLCL: FloatFieldIJ,
PLEmb: FloatField,
AREA: FloatFieldIJ,
DT_MOIST: Float,
CNV_FRC: FloatFieldIJ,
SRF_TYPE: FloatFieldIJ,
T: FloatField,
QLCN: FloatField,
QICN: FloatField,
QLLS: FloatField,
QILS: FloatField,
CCW_EVAP_EFF: Float,
CCI_EVAP_EFF: Float,
Q: FloatField,
CLLS: FloatField,
CLCN: FloatField,
NACTL: FloatField,
NACTI: FloatField,
QST: FloatField,
LMELTFRZ: bool = True,
):
self.check_flags(LMELTFRZ, PDFSHAPE, CCW_EVAP_EFF, CCI_EVAP_EFF)

self._get_last(PLEmb, self._tmp, self._PLEmb_top)

self._hybrid_index_2dout(PLmb, self._k_mask, KLCL, self._PLmb_at_klcl)

self._initial_calc(
EIS,
dw_land,
dw_ocean,
TURNRHCRIT_PARAM,
self._minrhcrit,
self._PLmb_at_klcl,
PLmb,
self._PLEmb_top,
AREA,
self._alpha,
)

self._hystpdf(
DT_MOIST,
self._alpha,
PDFSHAPE,
CNV_FRC,
SRF_TYPE,
PLmb,
Q,
QLLS,
QLCN,
QILS,
QICN,
T,
CLLS,
CLCN,
NACTL,
NACTI,
self.rhx,
self.qsat.ese,
self.qsat.esw,
self.qsat.esx,
self.qsat.esw.view[0][12316],
self.qsat.esw.view[0][8316],
)

if LMELTFRZ:
self._meltfrz(DT_MOIST, CNV_FRC, SRF_TYPE, T, QLCN, QICN)
self._meltfrz(DT_MOIST, CNV_FRC, SRF_TYPE, T, QLLS, QILS)

if CCW_EVAP_EFF > 0.0:
self._evap(
DT_MOIST,
CCW_EVAP_EFF,
PLmb,
T,
Q,
QLCN,
QICN,
CLCN,
NACTL,
NACTI,
QST,
self.evapc,
)

if CCI_EVAP_EFF > 0.0:
self._subl(
DT_MOIST,
CCW_EVAP_EFF,
PLmb,
T,
Q,
QLCN,
QICN,
CLCN,
NACTL,
NACTI,
QST,
self.sublc,
)

self._fix_up_clouds(Q, T, QLLS, QILS, CLLS, QLCN, QICN, CLCN)

def check_flags(
self,
LMELTFRZ: bool,
PDFSHAPE: Float,
CCW_EVAP_EFF: Float,
CCI_EVAP_EFF: Float,
):
if LMELTFRZ is not True:
raise NotImplementedError(
"Untested option for LMELTFRZ. Code may be missing or incomplete. \
Disable this error manually to continue."
)
if PDFSHAPE != 1:
raise NotImplementedError(
"Untested option for PDFSHAPE. Code may be missing or incomplete. \
Disable this error manually to continue."
)
if CCW_EVAP_EFF <= 0:
raise NotImplementedError(
"Untested option for CCW_EVAP_EFF. Code may be missing or incomplete. \
Disable this error manually to continue."
)
if CCI_EVAP_EFF <= 0:
raise NotImplementedError(
"Untested option for CCI_EVAP_EFF. Code may be missing or incomplete. \
Disable this error manually to continue."
)
Loading
Loading