PySDM_examples.Pyrcel.tutorial_settings
1from typing import Dict 2 3import numpy as np 4from pystrict import strict 5 6from PySDM import Formulae 7from PySDM.initialisation.impl.spectrum import Spectrum 8 9 10@strict 11class Settings: 12 def __init__( 13 self, 14 dz: float, 15 n_sd_per_mode: tuple, 16 aerosol_modes_by_kappa: Dict[float, Spectrum], 17 vertical_velocity: float, 18 initial_temperature: float, 19 initial_pressure: float, 20 initial_relative_humidity: float, 21 displacement: float, 22 formulae: Formulae, 23 ): 24 self.formulae = formulae 25 self.n_sd_per_mode = n_sd_per_mode 26 self.aerosol_modes_by_kappa = aerosol_modes_by_kappa 27 28 const = self.formulae.constants 29 self.vertical_velocity = vertical_velocity 30 self.initial_pressure = initial_pressure 31 self.initial_temperature = initial_temperature 32 pv0 = initial_relative_humidity * formulae.saturation_vapour_pressure.pvs_water( 33 initial_temperature 34 ) 35 self.initial_vapour_mixing_ratio = const.eps * pv0 / (initial_pressure - pv0) 36 self.t_max = displacement / vertical_velocity 37 self.timestep = dz / vertical_velocity 38 self.output_interval = self.timestep 39 40 @property 41 def initial_air_density(self): 42 const = self.formulae.constants 43 dry_air_density = ( 44 self.formulae.trivia.p_d( 45 self.initial_pressure, self.initial_vapour_mixing_ratio 46 ) 47 / self.initial_temperature 48 / const.Rd 49 ) 50 return dry_air_density * (1 + self.initial_vapour_mixing_ratio) 51 52 @property 53 def nt(self) -> int: 54 nt = self.t_max / self.timestep 55 nt_int = round(nt) 56 np.testing.assert_almost_equal(nt, nt_int) 57 return nt_int 58 59 @property 60 def steps_per_output_interval(self) -> int: 61 return int(self.output_interval / self.timestep) 62 63 @property 64 def output_steps(self) -> np.ndarray: 65 return np.arange(0, self.nt + 1, self.steps_per_output_interval)
@strict
class
Settings:
11@strict 12class Settings: 13 def __init__( 14 self, 15 dz: float, 16 n_sd_per_mode: tuple, 17 aerosol_modes_by_kappa: Dict[float, Spectrum], 18 vertical_velocity: float, 19 initial_temperature: float, 20 initial_pressure: float, 21 initial_relative_humidity: float, 22 displacement: float, 23 formulae: Formulae, 24 ): 25 self.formulae = formulae 26 self.n_sd_per_mode = n_sd_per_mode 27 self.aerosol_modes_by_kappa = aerosol_modes_by_kappa 28 29 const = self.formulae.constants 30 self.vertical_velocity = vertical_velocity 31 self.initial_pressure = initial_pressure 32 self.initial_temperature = initial_temperature 33 pv0 = initial_relative_humidity * formulae.saturation_vapour_pressure.pvs_water( 34 initial_temperature 35 ) 36 self.initial_vapour_mixing_ratio = const.eps * pv0 / (initial_pressure - pv0) 37 self.t_max = displacement / vertical_velocity 38 self.timestep = dz / vertical_velocity 39 self.output_interval = self.timestep 40 41 @property 42 def initial_air_density(self): 43 const = self.formulae.constants 44 dry_air_density = ( 45 self.formulae.trivia.p_d( 46 self.initial_pressure, self.initial_vapour_mixing_ratio 47 ) 48 / self.initial_temperature 49 / const.Rd 50 ) 51 return dry_air_density * (1 + self.initial_vapour_mixing_ratio) 52 53 @property 54 def nt(self) -> int: 55 nt = self.t_max / self.timestep 56 nt_int = round(nt) 57 np.testing.assert_almost_equal(nt, nt_int) 58 return nt_int 59 60 @property 61 def steps_per_output_interval(self) -> int: 62 return int(self.output_interval / self.timestep) 63 64 @property 65 def output_steps(self) -> np.ndarray: 66 return np.arange(0, self.nt + 1, self.steps_per_output_interval)
Settings( dz: float, n_sd_per_mode: tuple, aerosol_modes_by_kappa: Dict[float, PySDM.initialisation.impl.spectrum.Spectrum], vertical_velocity: float, initial_temperature: float, initial_pressure: float, initial_relative_humidity: float, displacement: float, formulae: PySDM.formulae.Formulae)
13 def __init__( 14 self, 15 dz: float, 16 n_sd_per_mode: tuple, 17 aerosol_modes_by_kappa: Dict[float, Spectrum], 18 vertical_velocity: float, 19 initial_temperature: float, 20 initial_pressure: float, 21 initial_relative_humidity: float, 22 displacement: float, 23 formulae: Formulae, 24 ): 25 self.formulae = formulae 26 self.n_sd_per_mode = n_sd_per_mode 27 self.aerosol_modes_by_kappa = aerosol_modes_by_kappa 28 29 const = self.formulae.constants 30 self.vertical_velocity = vertical_velocity 31 self.initial_pressure = initial_pressure 32 self.initial_temperature = initial_temperature 33 pv0 = initial_relative_humidity * formulae.saturation_vapour_pressure.pvs_water( 34 initial_temperature 35 ) 36 self.initial_vapour_mixing_ratio = const.eps * pv0 / (initial_pressure - pv0) 37 self.t_max = displacement / vertical_velocity 38 self.timestep = dz / vertical_velocity 39 self.output_interval = self.timestep
initial_air_density
41 @property 42 def initial_air_density(self): 43 const = self.formulae.constants 44 dry_air_density = ( 45 self.formulae.trivia.p_d( 46 self.initial_pressure, self.initial_vapour_mixing_ratio 47 ) 48 / self.initial_temperature 49 / const.Rd 50 ) 51 return dry_air_density * (1 + self.initial_vapour_mixing_ratio)