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

Changes to solve_nonhydro stencils 57, 58 #356

Merged
merged 9 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,45 @@


@field_operator
def _update_mass_flux(
def _update_mass_volume_flux(
z_contr_w_fl_l: Field[[CellDim, KDim], wpfloat],
rho_ic: Field[[CellDim, KDim], wpfloat],
vwind_impl_wgt: Field[[CellDim], wpfloat],
w: Field[[CellDim, KDim], wpfloat],
mass_flx_ic: Field[[CellDim, KDim], wpfloat],
vol_flx_ic: Field[[CellDim, KDim], wpfloat],
r_nsubsteps: wpfloat,
) -> Field[[CellDim, KDim], wpfloat]:
) -> tuple[Field[[CellDim, KDim], wpfloat], Field[[CellDim, KDim], wpfloat]]:
"""Formerly known as _mo_solve_nonhydro_stencil_58."""
mass_flx_ic_wp = mass_flx_ic + (r_nsubsteps * (z_contr_w_fl_l + rho_ic * vwind_impl_wgt * w))
return mass_flx_ic_wp
z_a = r_nsubsteps * (z_contr_w_fl_l + rho_ic * vwind_impl_wgt * w)
mass_flx_ic_wp = mass_flx_ic + z_a
vol_flx_ic_wp = vol_flx_ic + z_a / rho_ic
return mass_flx_ic_wp, vol_flx_ic_wp


@program(grid_type=GridType.UNSTRUCTURED)
def update_mass_flux(
def update_mass_volume_flux(
z_contr_w_fl_l: Field[[CellDim, KDim], wpfloat],
rho_ic: Field[[CellDim, KDim], wpfloat],
vwind_impl_wgt: Field[[CellDim], wpfloat],
w: Field[[CellDim, KDim], wpfloat],
mass_flx_ic: Field[[CellDim, KDim], wpfloat],
vol_flx_ic: Field[[CellDim, KDim], wpfloat],
r_nsubsteps: wpfloat,
horizontal_start: int32,
horizontal_end: int32,
vertical_start: int32,
vertical_end: int32,
):
_update_mass_flux(
_update_mass_volume_flux(
z_contr_w_fl_l,
rho_ic,
vwind_impl_wgt,
w,
mass_flx_ic,
vol_flx_ic,
r_nsubsteps,
out=mass_flx_ic,
out=(mass_flx_ic, vol_flx_ic),
domain={
CellDim: (horizontal_start, horizontal_end),
KDim: (vertical_start, vertical_end),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@


class TestMoSolveNonhydroStencil58(StencilTest):
PROGRAM = update_mass_flux
OUTPUTS = ("mass_flx_ic",)
PROGRAM = update_mass_volume_flux
OUTPUTS = (
"mass_flx_ic",
"vol_flx_ic",
)

@staticmethod
def reference(
Expand All @@ -33,12 +36,15 @@ def reference(
vwind_impl_wgt: np.array,
w: np.array,
mass_flx_ic: np.array,
vol_flx_ic: np.array,
r_nsubsteps,
**kwargs,
) -> dict:
vwind_impl_wgt = np.expand_dims(vwind_impl_wgt, axis=-1)
mass_flx_ic = mass_flx_ic + (r_nsubsteps * (z_contr_w_fl_l + rho_ic * vwind_impl_wgt * w))
return dict(mass_flx_ic=mass_flx_ic)
z_a = r_nsubsteps * (z_contr_w_fl_l + rho_ic * vwind_impl_wgt * w)
mass_flx_ic = mass_flx_ic + z_a
vol_flx_ic = vol_flx_ic + z_a / rho_ic
return dict(mass_flx_ic=mass_flx_ic, vol_flx_ic=vol_flx_ic)

@pytest.fixture
def input_data(self, grid):
Expand All @@ -47,6 +53,7 @@ def input_data(self, grid):
vwind_impl_wgt = random_field(grid, CellDim, dtype=wpfloat)
w = random_field(grid, CellDim, KDim, dtype=wpfloat)
mass_flx_ic = random_field(grid, CellDim, KDim, dtype=wpfloat)
vol_flx_ic = random_field(grid, CellDim, KDim, dtype=wpfloat)
r_nsubsteps = 7.0

return dict(
Expand All @@ -55,6 +62,7 @@ def input_data(self, grid):
vwind_impl_wgt=vwind_impl_wgt,
w=w,
mass_flx_ic=mass_flx_ic,
vol_flx_ic=vol_flx_ic,
r_nsubsteps=r_nsubsteps,
horizontal_start=int32(0),
horizontal_end=int32(grid.num_cells),
Expand Down
Loading