PySDM_examples.Srivastava_1982.settings
1from PySDM.backends import CPU 2from PySDM.physics import constants_defaults 3 4DUMMY_FRAG_MASS = -1 5 6 7class SimProd: 8 def __init__(self, name, plot_title=None, plot_xscale=None, plot_yscale=None): 9 self.name = name 10 self.plot_title = plot_title or name 11 self.plot_yscale = plot_yscale 12 self.plot_xscale = plot_xscale 13 14 15class SimProducts: 16 class PySDM: 17 total_numer = SimProd( 18 name="total numer", 19 plot_title="total droplet numer", 20 plot_xscale="log", 21 plot_yscale="log", 22 ) 23 total_volume = SimProd(name="total volume") 24 super_particle_count = SimProd( 25 name="super-particle count", plot_xscale="log", plot_yscale="log" 26 ) 27 28 class Computed: 29 mean_drop_volume_total_volume_ratio = SimProd( 30 name="mean drop volume / total volume %", 31 plot_title="mean drop mass / total mass %", 32 ) 33 34 @staticmethod 35 def get_prod_by_name(name): 36 for class_obj in (SimProducts.PySDM, SimProducts.Computed): 37 for attribute_str in dir(class_obj): 38 if not attribute_str.startswith("__"): 39 attribute = getattr(class_obj, attribute_str) 40 if attribute.name == name: 41 return attribute 42 return None 43 44 45class Settings: 46 """interprets parameters from Srivastava 1982 in PySDM context""" 47 48 def __init__( 49 self, 50 *, 51 n_sds, 52 dt, 53 dv, 54 total_number, 55 drop_mass_0, 56 srivastava_c, 57 srivastava_beta=None, 58 frag_mass=DUMMY_FRAG_MASS, 59 rho=constants_defaults.rho_w, 60 backend_class=CPU, 61 ): 62 self.backend_class = backend_class 63 64 self.rho = rho 65 self.total_number_0 = total_number 66 self.total_volume = self.total_number_0 * drop_mass_0 / self.rho 67 self.dt = dt 68 self.dv = dv 69 self.frag_mass = frag_mass 70 71 self.prods = ( 72 SimProducts.PySDM.total_volume.name, 73 SimProducts.PySDM.total_numer.name, 74 SimProducts.PySDM.super_particle_count.name, 75 ) 76 self.n_sds = n_sds 77 78 self.srivastava_c = srivastava_c 79 self.srivastava_beta = srivastava_beta
DUMMY_FRAG_MASS =
-1
class
SimProd:
8class SimProd: 9 def __init__(self, name, plot_title=None, plot_xscale=None, plot_yscale=None): 10 self.name = name 11 self.plot_title = plot_title or name 12 self.plot_yscale = plot_yscale 13 self.plot_xscale = plot_xscale
class
SimProducts:
16class SimProducts: 17 class PySDM: 18 total_numer = SimProd( 19 name="total numer", 20 plot_title="total droplet numer", 21 plot_xscale="log", 22 plot_yscale="log", 23 ) 24 total_volume = SimProd(name="total volume") 25 super_particle_count = SimProd( 26 name="super-particle count", plot_xscale="log", plot_yscale="log" 27 ) 28 29 class Computed: 30 mean_drop_volume_total_volume_ratio = SimProd( 31 name="mean drop volume / total volume %", 32 plot_title="mean drop mass / total mass %", 33 ) 34 35 @staticmethod 36 def get_prod_by_name(name): 37 for class_obj in (SimProducts.PySDM, SimProducts.Computed): 38 for attribute_str in dir(class_obj): 39 if not attribute_str.startswith("__"): 40 attribute = getattr(class_obj, attribute_str) 41 if attribute.name == name: 42 return attribute 43 return None
@staticmethod
def
get_prod_by_name(name):
35 @staticmethod 36 def get_prod_by_name(name): 37 for class_obj in (SimProducts.PySDM, SimProducts.Computed): 38 for attribute_str in dir(class_obj): 39 if not attribute_str.startswith("__"): 40 attribute = getattr(class_obj, attribute_str) 41 if attribute.name == name: 42 return attribute 43 return None
class
SimProducts.PySDM:
17 class PySDM: 18 total_numer = SimProd( 19 name="total numer", 20 plot_title="total droplet numer", 21 plot_xscale="log", 22 plot_yscale="log", 23 ) 24 total_volume = SimProd(name="total volume") 25 super_particle_count = SimProd( 26 name="super-particle count", plot_xscale="log", plot_yscale="log" 27 )
total_numer =
<SimProd object>
total_volume =
<SimProd object>
super_particle_count =
<SimProd object>
class
SimProducts.Computed:
29 class Computed: 30 mean_drop_volume_total_volume_ratio = SimProd( 31 name="mean drop volume / total volume %", 32 plot_title="mean drop mass / total mass %", 33 )
mean_drop_volume_total_volume_ratio =
<SimProd object>
class
Settings:
46class Settings: 47 """interprets parameters from Srivastava 1982 in PySDM context""" 48 49 def __init__( 50 self, 51 *, 52 n_sds, 53 dt, 54 dv, 55 total_number, 56 drop_mass_0, 57 srivastava_c, 58 srivastava_beta=None, 59 frag_mass=DUMMY_FRAG_MASS, 60 rho=constants_defaults.rho_w, 61 backend_class=CPU, 62 ): 63 self.backend_class = backend_class 64 65 self.rho = rho 66 self.total_number_0 = total_number 67 self.total_volume = self.total_number_0 * drop_mass_0 / self.rho 68 self.dt = dt 69 self.dv = dv 70 self.frag_mass = frag_mass 71 72 self.prods = ( 73 SimProducts.PySDM.total_volume.name, 74 SimProducts.PySDM.total_numer.name, 75 SimProducts.PySDM.super_particle_count.name, 76 ) 77 self.n_sds = n_sds 78 79 self.srivastava_c = srivastava_c 80 self.srivastava_beta = srivastava_beta
interprets parameters from Srivastava 1982 in PySDM context
Settings( *, n_sds, dt, dv, total_number, drop_mass_0, srivastava_c, srivastava_beta=None, frag_mass=-1, rho=999.9999999999998, backend_class=<class 'PySDM.backends.numba.Numba'>)
49 def __init__( 50 self, 51 *, 52 n_sds, 53 dt, 54 dv, 55 total_number, 56 drop_mass_0, 57 srivastava_c, 58 srivastava_beta=None, 59 frag_mass=DUMMY_FRAG_MASS, 60 rho=constants_defaults.rho_w, 61 backend_class=CPU, 62 ): 63 self.backend_class = backend_class 64 65 self.rho = rho 66 self.total_number_0 = total_number 67 self.total_volume = self.total_number_0 * drop_mass_0 / self.rho 68 self.dt = dt 69 self.dv = dv 70 self.frag_mass = frag_mass 71 72 self.prods = ( 73 SimProducts.PySDM.total_volume.name, 74 SimProducts.PySDM.total_numer.name, 75 SimProducts.PySDM.super_particle_count.name, 76 ) 77 self.n_sds = n_sds 78 79 self.srivastava_c = srivastava_c 80 self.srivastava_beta = srivastava_beta