|
| 1 | +"""commons for homogeneous freezing notebooks""" |
| 2 | + |
| 3 | +from PySDM_examples.Luettmer_homogeneous_freezing.settings import Settings |
| 4 | +from PySDM_examples.Luettmer_homogeneous_freezing.simulation import Simulation |
| 5 | +from PySDM import Formulae |
| 6 | +from PySDM.physics.constants import si |
| 7 | +from PySDM.backends import CPU |
| 8 | + |
| 9 | +formulae = Formulae( |
| 10 | + particle_shape_and_density="MixedPhaseSpheres", |
| 11 | +) |
| 12 | + |
| 13 | + |
| 14 | +def run_simulations(setting): |
| 15 | + |
| 16 | + simulation = { |
| 17 | + "settings": setting, |
| 18 | + "ensemble_member_outputs": [], |
| 19 | + } |
| 20 | + for _ in range(setting["number_of_ensemble_runs"]): |
| 21 | + model_setup = Settings(**simulation["settings"]) |
| 22 | + model_setup.formulae.seed += 1 |
| 23 | + model = Simulation(model_setup) |
| 24 | + simulation["ensemble_member_outputs"].append(model.run()) |
| 25 | + |
| 26 | + return simulation |
| 27 | + |
| 28 | + |
| 29 | +def hom_pure_droplet_freezing_backend(): |
| 30 | + cmn = {"override_jit_flags": {"parallel": False}} |
| 31 | + backends = { |
| 32 | + "threshold": CPU( |
| 33 | + formulae=Formulae( |
| 34 | + particle_shape_and_density="MixedPhaseSpheres", |
| 35 | + homogeneous_ice_nucleation_rate="Null", |
| 36 | + saturation_vapour_pressure="MurphyKoop2005", |
| 37 | + ), |
| 38 | + **cmn, |
| 39 | + ), |
| 40 | + "KoopMurray2016": CPU( |
| 41 | + formulae=Formulae( |
| 42 | + particle_shape_and_density="MixedPhaseSpheres", |
| 43 | + homogeneous_ice_nucleation_rate="KoopMurray2016", |
| 44 | + saturation_vapour_pressure="MurphyKoop2005", |
| 45 | + ), |
| 46 | + **cmn, |
| 47 | + ), |
| 48 | + "Spichtinger2023": CPU( |
| 49 | + formulae=Formulae( |
| 50 | + particle_shape_and_density="MixedPhaseSpheres", |
| 51 | + homogeneous_ice_nucleation_rate="Koop_Correction", |
| 52 | + saturation_vapour_pressure="MurphyKoop2005", |
| 53 | + ), |
| 54 | + **cmn, |
| 55 | + ), |
| 56 | + "Koop2000": CPU( |
| 57 | + formulae=Formulae( |
| 58 | + particle_shape_and_density="MixedPhaseSpheres", |
| 59 | + homogeneous_ice_nucleation_rate="Koop2000", |
| 60 | + saturation_vapour_pressure="MurphyKoop2005", |
| 61 | + ), |
| 62 | + **cmn, |
| 63 | + ), |
| 64 | + "KoopMurray2016_DWA": CPU( |
| 65 | + formulae=Formulae( |
| 66 | + particle_shape_and_density="MixedPhaseSpheres", |
| 67 | + homogeneous_ice_nucleation_rate="KoopMurray2016_DWA", |
| 68 | + saturation_vapour_pressure="MurphyKoop2005", |
| 69 | + ), |
| 70 | + **cmn, |
| 71 | + ), |
| 72 | + } |
| 73 | + return backends |
| 74 | + |
| 75 | + |
| 76 | +def hom_pure_droplet_freezing_standard_setup(): |
| 77 | + standard = { |
| 78 | + "n_sd": int(1e3), |
| 79 | + "w_updraft": 1.0 * si.meter / si.second, |
| 80 | + "T0": 245 * si.kelvin, |
| 81 | + "dz": 1.0 * si.meter, |
| 82 | + "n_ccn": 750 / si.cm**3, |
| 83 | + "r_ccn": 15 * si.nanometer, |
| 84 | + "type_droplet_distribution": "monodisperse", |
| 85 | + "RH_0": 0.995, |
| 86 | + "p0": 500 * si.hectopascals, |
| 87 | + "deposition_enable": True, |
| 88 | + "number_of_ensemble_runs": 1, |
| 89 | + "silent": True, |
| 90 | + } |
| 91 | + return standard |
0 commit comments