PySDM_examples.Pyrcel.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 return self.formulae.state_variable_triplet.rho_of_rhod_and_water_vapour_mixing_ratio( 43 rhod=self.formulae.trivia.p_d( 44 self.initial_pressure, self.initial_vapour_mixing_ratio 45 ) 46 / self.initial_temperature 47 / self.formulae.constants.Rd, 48 water_vapour_mixing_ratio=self.initial_vapour_mixing_ratio, 49 ) 50 51 @property 52 def nt(self) -> int: 53 nt = self.t_max / self.timestep 54 nt_int = round(nt) 55 np.testing.assert_almost_equal(nt, nt_int) 56 return nt_int 57 58 @property 59 def steps_per_output_interval(self) -> int: 60 return int(self.output_interval / self.timestep) 61 62 @property 63 def output_steps(self) -> np.ndarray: 64 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 return self.formulae.state_variable_triplet.rho_of_rhod_and_water_vapour_mixing_ratio( 44 rhod=self.formulae.trivia.p_d( 45 self.initial_pressure, self.initial_vapour_mixing_ratio 46 ) 47 / self.initial_temperature 48 / self.formulae.constants.Rd, 49 water_vapour_mixing_ratio=self.initial_vapour_mixing_ratio, 50 ) 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)
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 return self.formulae.state_variable_triplet.rho_of_rhod_and_water_vapour_mixing_ratio( 44 rhod=self.formulae.trivia.p_d( 45 self.initial_pressure, self.initial_vapour_mixing_ratio 46 ) 47 / self.initial_temperature 48 / self.formulae.constants.Rd, 49 water_vapour_mixing_ratio=self.initial_vapour_mixing_ratio, 50 )