Source code for libs.mock_microphys.mock_microphysics_scheme
"""Copyright (c) 2024 MPI-M, Clara Bayley----- Microphysics Test Cases -----File: mock_microphysics_scheme.pyProject: mock_microphysCreated Date: Tuesday 27th February 2024Author: Clara Bayley (CB)Additional Contributors:-----Last Modified: Monday 11th November 2024Modified By: CB-----License: BSD 3-Clause "New" or "Revised" Licensehttps://opensource.org/licenses/BSD-3-Clause-----File Description:class for mock microphysics scheme in Python"""
[docs]classMicrophysicsScheme:"""A class representing a Python microphysics scheme which is a mock-up of the ICON AES one-moment microphysics scheme."""def__init__(self):"""Init the MicrophysicsScheme object (Python only)"""self.name="Python mock-up of an instance of ICON AES microphysics scheme"self.n=0
[docs]definitialize(self):"""Initialize the microphysics scheme. This method performs the initialization steps necessary for the microphysics scheme. """print("microphysics initialisation")
[docs]deffinalize(self):"""Finalize the microphysics scheme. This method performs the finalization steps for the microphysics scheme. """print("microphysics finalisation")
[docs]defrun(self,nvec,ke,ivstart,dt,dz,t,rho,p,qv,qc,qi,qr,qs,qg,qnc):"""Run the microphysics computations. This method executes the microphysics computations. Parameters: nvec (int): Number of horizontal points. ke (int): Number of grid points in vertical direction. ivstart (int): Start index for horizontal direction. dt (np.ndarray): Times-tep for integration of microphysics (s) dz (np.ndarray): Layer thickness of full levels (m). t (np.ndarray): Temperature (K). rho (np.ndarray): Density of moist air (kg/m3) p (np.ndarray): Pressure (Pa). qv (np.ndarray): Specific water vapor content (kg/kg) qc (np.ndarray): Specific cloud water content (kg/kg) qi (np.ndarray): Specific cloud ice content (kg/kg) qr (np.ndarray): Specific rain content (kg/kg) qs (np.ndarray): Specific snow content kg/kg) qg (np.ndarray): Specific graupel content (kg/kg) qnc (np.ndarray): Cloud number concentration. Returns: Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]: - Updated temperature (K). - Updated specific water vapor content (kg/kg) - Updated specific cloud water content (kg/kg) - Updated specific cloud ice content (kg/kg) - Updated specific rain content (kg/kg) - Updated specific snow content kg/kg) - Updated specific graupel content kg/kg) - Updated precipitation rate of rain, grid-scale (kg/(m2*s)) - Updated total precipitation flux """### some mock exchange of mass between vapour and condensate categoriesifself.n%50==0:qv+=(-1)**self.n*0.001qc+=(-1)**(self.n+1)*0.001qi+=(-1)**self.n*0.002qr+=(-1)**(self.n+1)*0.002qs+=(-1)**self.n*0.0003qg+=(-1)**(self.n+1)*0.0003self.n+=1prr_gsp=0.001pflx=0.01returnt,qv,qc,qi,qr,qs,qg,prr_gsp,pflx