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

Verify global model #315

Merged
merged 53 commits into from
Dec 15, 2023
Merged

Verify global model #315

merged 53 commits into from
Dec 15, 2023

Conversation

halungge
Copy link
Contributor

@halungge halungge commented Nov 17, 2023

Add verification for a global model experiment (exclaim_ape_R02B04)

  • makes the experiment parametrizable in the tests: Configuration and serialized data are chosen according to the experiment name.
  • Diffusion: adapt flow and stencil for apply_diffusion_to_w_and_compute_horizontal_gradients_for_turbulence.py to allow for shear_type (see icon-exclaim PR)
  • NonHydrostaticConfig now uses ICON default values as default parameters
  • add calculation of k_start_moist
  • add debug log statements to SolveNonHydro

Further fixes :

  • (FIX) remove dependency of model/common on model/atmosphere/diffusion by moving construction of the diffusion specific types from serialbox data out of common/test_utils
  • (FIX) fix duplicated paths in data_handling.py
  • invert arguments to dallclose such that the reference values comes in second place see
  • remove some unused code from dycore/state_utils and common/test_utils/serialbox_utils.py, VectorTuple type

@halungge
Copy link
Contributor Author

cscs-ci run

@halungge
Copy link
Contributor Author

halungge commented Dec 5, 2023

cscs-ci run

@halungge
Copy link
Contributor Author

halungge commented Dec 5, 2023

launch jenkins spack

@halungge halungge marked this pull request as ready for review December 5, 2023 12:50
@halungge halungge requested a review from abishekg7 December 5, 2023 12:50
@halungge
Copy link
Contributor Author

halungge commented Dec 5, 2023

cscs-ci run

@halungge
Copy link
Contributor Author

halungge commented Dec 5, 2023

launch jenkins spack

@halungge
Copy link
Contributor Author

halungge commented Dec 5, 2023

cscs-ci run

@abishekg7
Copy link
Contributor

launch jenkins spack

@abishekg7
Copy link
Contributor

launch jenkins icon

Copy link
Contributor

@abishekg7 abishekg7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a lot of work! Looks good overall. I mostly have minor comments, but we do need to pay some attention to tolerances.

def test_smagorinski_factor_for_diffusion_type_4(r04b09_diffusion_config):
config = r04b09_diffusion_config
def test_smagorinski_factor_for_diffusion_type_4(experiment):
config = construct_config(experiment, ndyn_substeps=5)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the ndyn_substeps hard-coding here okay?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is hardcoded? I don't understand what you mean?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought ndyn_substeps=5 should go into the part where the rest of the namelist options are present. But if it's a temporary design thing, that's fine.

interpolation_state=interpolation_state,
edge_params=edge_geometry,
cell_params=cell_geometry,
assert dallclose(diffusion.enh_smag_fac.asnumpy(), savepoint.enh_smag_fac(), rtol=1e-7)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these tolerances seem a little high. Is it also the case with blue line?

@@ -1834,9 +1900,11 @@ def run_corrector_step(
vertical_end=self.grid.num_levels,
offset_provider={},
)
# TODO (magdalena) stencil_60 is missing here?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what we are doing about stencil 60? Will it be in a later PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is why I added the TODO. Did not want to fix this in the same PR.

exner_incr: Field[[EdgeDim, KDim], float] # exner increment [- ]
exner_incr: Field[[CellDim, KDim], float] # exner increment [- ]

exner_dyn_incr: Field[[CellDim, KDim], float] = None # exner pressure dynamics increment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably need to add a test for IAU mode

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no IAU mode in greenline. There is no way we are going to do any data assimilation soon in greenline, so I don't see what we should test there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. i meant that we don't have any data assimilation tests at all (blue or greenlines), but we have the stencils. We should think eventually about adding tests for this. Not in this PR ofc.

diagnostic_state_nh.mass_fl_e.asnumpy(),
rtol=1e-10,
savepoint_nonhydro_exit.mass_fl_e().asnumpy(),
rtol=5e-7, # TODO (magdalena) was rtol=1e-10 for local experiment only
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems weird. there are no prescribed tolerances for this stencil in the blueline

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I agree its weird. I have not been able to locate any possible bug, which of course does not mean its not there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add an issue to track this, if we want to get it merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prep_adv.vn_traj.asnumpy(),
rtol=1e-10,
savepoint_nonhydro_exit.vn_traj().asnumpy(),
rtol=5e-7, # TODO (magdalena) was rtol=1e-10 for local experiment only
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these two tolerances are questionable too. different from blueline

def zd_diffcoef(self):
return self._get_field("zd_diffcoef", CellDim, KDim)

@optionally_registered
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It accounts for those fields being present in the global run, because they do not even get allocated there, so they are not registered in the serialbox savepoint.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay thanks!


from icon4py.model.atmosphere.dycore.nh_solve.solve_nonhydro import NonHydrostaticConfig


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess an alternative method would be to define the entire config (diffusion + nonhydro + ...) for LAM or APE experiments, and then individual configs will pick up the config they need. But not sure about pros and cons.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. Where this should go is: some thing ( a class what ever) reads the configuration from file does necessary consistency checks and divides it up into the configuration bits needed for the individual components.

@@ -99,12 +104,13 @@ def apply_diffusion_to_w_and_compute_horizontal_gradients_for_turbulance(
vertical_start: int32,
vertical_end: int32,
):
_apply_diffusion_to_w_and_compute_horizontal_gradients_for_turbulance(
_apply_diffusion_to_w_and_compute_horizontal_gradients_for_turbulence(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for changing this!

Copy link
Contributor

@abishekg7 abishekg7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. You can merge after syncing/testing.

@halungge
Copy link
Contributor Author

cscs-ci run

@halungge
Copy link
Contributor Author

launch jenkins spack

remove empty diagnostic_state.py
remov l_open_ubc from solve_nonhydro.py
@halungge
Copy link
Contributor Author

cscs-ci run

@halungge
Copy link
Contributor Author

launch jenkins spack

Copy link

Mandatory Tests

Please make sure you run these tests via comment before you merge!

  • cscs-ci run
  • launch jenkins spack

Optional Tests

In case your change might affect downstream icon-exclaim, please consider running

  • launch jenkins icon

For more detailed information please look at CI in the EXCLAIM universe.

@halungge
Copy link
Contributor Author

cscs-ci run

@halungge
Copy link
Contributor Author

launch jenkins spack

@halungge halungge merged commit 6e153b5 into main Dec 15, 2023
5 checks passed
@halungge halungge deleted the verify_global_model branch December 12, 2024 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants