PySDM_examples.Arabas_and_Shima_2017.settings
1import numpy as np 2from pystrict import strict 3 4from PySDM import Formulae 5from PySDM.dynamics import condensation 6from PySDM.physics.constants import si 7 8 9@strict 10class Settings: 11 def __init__( 12 self, 13 w_avg: float, 14 N_STP: float, 15 r_dry: float, 16 mass_of_dry_air: float, 17 coord: str = "VolumeLogarithm", 18 ): 19 self.formulae = Formulae( 20 saturation_vapour_pressure="AugustRocheMagnus", 21 condensation_coordinate=coord, 22 ) 23 const = self.formulae.constants 24 self.p0 = 1000 * si.hectopascals 25 self.RH0 = 0.98 26 self.kappa = 0.2 # TODO #441 27 self.T0 = 300 * si.kelvin 28 self.z_half = 150 * si.metres 29 30 pvs = self.formulae.saturation_vapour_pressure.pvs_water(self.T0) 31 self.initial_water_vapour_mixing_ratio = const.eps / ( 32 self.p0 / self.RH0 / pvs - 1 33 ) 34 self.w_avg = w_avg 35 self.r_dry = r_dry 36 self.N_STP = N_STP 37 self.n_in_dv = N_STP / const.rho_STP * mass_of_dry_air 38 self.mass_of_dry_air = mass_of_dry_air 39 self.n_output = 500 40 41 self.rtol_x = condensation.DEFAULTS.rtol_x 42 self.rtol_thd = condensation.DEFAULTS.rtol_thd 43 self.coord = "volume logarithm" 44 self.dt_cond_range = condensation.DEFAULTS.cond_range 45 46 @property 47 def dt_max(self): 48 t_total = 2 * self.z_half / self.w_avg 49 result = t_total / self.n_output 50 if result < 1 * si.centimetre / si.second: 51 result /= 100 # TODO #411 52 return result 53 54 def w(self, t): 55 return self.w_avg * np.pi / 2 * np.sin(np.pi * t / self.z_half * self.w_avg) 56 57 58w_avgs = ( 59 100 * si.centimetre / si.second, 60 # 50 * si.centimetre / si.second, 61 0.2 * si.centimetre / si.second, 62) 63 64N_STPs = (50 / si.centimetre**3, 500 / si.centimetre**3) 65 66r_drys = (0.1 * si.micrometre, 0.05 * si.micrometre) 67 68setups = [] 69for w_i, _w_avg in enumerate(w_avgs): 70 for N_i, _N_STP in enumerate(N_STPs): 71 for rd_i, _r_dry in enumerate(r_drys): 72 if not rd_i == N_i == 1: 73 setups.append( 74 Settings( 75 w_avg=_w_avg, 76 N_STP=_N_STP, 77 r_dry=_r_dry, 78 mass_of_dry_air=1000 * si.kilogram, 79 ) 80 )
@strict
class
Settings:
10@strict 11class Settings: 12 def __init__( 13 self, 14 w_avg: float, 15 N_STP: float, 16 r_dry: float, 17 mass_of_dry_air: float, 18 coord: str = "VolumeLogarithm", 19 ): 20 self.formulae = Formulae( 21 saturation_vapour_pressure="AugustRocheMagnus", 22 condensation_coordinate=coord, 23 ) 24 const = self.formulae.constants 25 self.p0 = 1000 * si.hectopascals 26 self.RH0 = 0.98 27 self.kappa = 0.2 # TODO #441 28 self.T0 = 300 * si.kelvin 29 self.z_half = 150 * si.metres 30 31 pvs = self.formulae.saturation_vapour_pressure.pvs_water(self.T0) 32 self.initial_water_vapour_mixing_ratio = const.eps / ( 33 self.p0 / self.RH0 / pvs - 1 34 ) 35 self.w_avg = w_avg 36 self.r_dry = r_dry 37 self.N_STP = N_STP 38 self.n_in_dv = N_STP / const.rho_STP * mass_of_dry_air 39 self.mass_of_dry_air = mass_of_dry_air 40 self.n_output = 500 41 42 self.rtol_x = condensation.DEFAULTS.rtol_x 43 self.rtol_thd = condensation.DEFAULTS.rtol_thd 44 self.coord = "volume logarithm" 45 self.dt_cond_range = condensation.DEFAULTS.cond_range 46 47 @property 48 def dt_max(self): 49 t_total = 2 * self.z_half / self.w_avg 50 result = t_total / self.n_output 51 if result < 1 * si.centimetre / si.second: 52 result /= 100 # TODO #411 53 return result 54 55 def w(self, t): 56 return self.w_avg * np.pi / 2 * np.sin(np.pi * t / self.z_half * self.w_avg)
Settings( w_avg: float, N_STP: float, r_dry: float, mass_of_dry_air: float, coord: str = 'VolumeLogarithm')
12 def __init__( 13 self, 14 w_avg: float, 15 N_STP: float, 16 r_dry: float, 17 mass_of_dry_air: float, 18 coord: str = "VolumeLogarithm", 19 ): 20 self.formulae = Formulae( 21 saturation_vapour_pressure="AugustRocheMagnus", 22 condensation_coordinate=coord, 23 ) 24 const = self.formulae.constants 25 self.p0 = 1000 * si.hectopascals 26 self.RH0 = 0.98 27 self.kappa = 0.2 # TODO #441 28 self.T0 = 300 * si.kelvin 29 self.z_half = 150 * si.metres 30 31 pvs = self.formulae.saturation_vapour_pressure.pvs_water(self.T0) 32 self.initial_water_vapour_mixing_ratio = const.eps / ( 33 self.p0 / self.RH0 / pvs - 1 34 ) 35 self.w_avg = w_avg 36 self.r_dry = r_dry 37 self.N_STP = N_STP 38 self.n_in_dv = N_STP / const.rho_STP * mass_of_dry_air 39 self.mass_of_dry_air = mass_of_dry_air 40 self.n_output = 500 41 42 self.rtol_x = condensation.DEFAULTS.rtol_x 43 self.rtol_thd = condensation.DEFAULTS.rtol_thd 44 self.coord = "volume logarithm" 45 self.dt_cond_range = condensation.DEFAULTS.cond_range
w_avgs =
(1.0, 0.002)
N_STPs =
(49999999.99999999, 499999999.99999994)
r_drys =
(1e-07, 5e-08)