1010
1111
1212class TerminalVelocityMethods (BackendMethods ):
13+
1314 @cached_property
14- def _interpolation_body (self ):
15+ def _gunn_and_kinzer_interpolation_body (self ):
1516 @numba .njit (** self .default_jit_flags )
1617 def body (output , radius , factor , b , c ):
1718 for i in numba .prange (len (radius )): # pylint: disable=not-an-iterable
18- if radius [i ] < 0 :
19- output [i ] = 0
20- else :
19+ if radius [i ] > 0 :
2120 r_id = int (factor * radius [i ])
2221 r_rest = ((factor * radius [i ]) % 1 ) / factor
2322 output [i ] = b [r_id ] + r_rest * c [r_id ]
23+ elif radius [i ] == 0 :
24+ output [i ] = 0
2425
2526 return body
2627
27- def interpolation (self , * , output , radius , factor , b , c ):
28- return self ._interpolation_body (
28+ def gunn_and_kinzer_interpolation (self , * , output , radius , factor , b , c ):
29+ return self ._gunn_and_kinzer_interpolation_body (
2930 output .data , radius .data , factor , b .data , c .data
3031 )
3132
3233 @cached_property
33- def _terminal_velocity_body (self ):
34+ def _rogers_and_yau_terminal_velocity_body (self ):
3435 v_term = self .formulae .terminal_velocity .v_term
3536
3637 @numba .njit (** self .default_jit_flags )
3738 def body (* , values , radius ):
3839 for i in numba .prange (len (values )): # pylint: disable=not-an-iterable
39- values [i ] = v_term (radius [i ])
40+ if radius [i ] >= 0.0 :
41+ values [i ] = v_term (radius [i ])
4042
4143 return body
4244
43- def terminal_velocity (self , * , values , radius ):
44- self ._terminal_velocity_body (values = values , radius = radius )
45+ def rogers_and_yau_terminal_velocity (self , * , values , radius ):
46+ self ._rogers_and_yau_terminal_velocity_body (values = values , radius = radius )
4547
4648 @cached_property
4749 def _power_series_body (self ):
@@ -62,3 +64,64 @@ def power_series(self, *, values, radius, num_terms, prefactors, powers):
6264 prefactors = prefactors ,
6365 powers = powers ,
6466 )
67+
68+ def terminal_velocity_columnar_ice_crystals (
69+ self , * , values , signed_water_mass , cell_id , temperature , pressure
70+ ):
71+ self ._terminal_velocity_columnar_ice_crystals_body (
72+ values = values ,
73+ signed_water_mass = signed_water_mass ,
74+ cell_id = cell_id ,
75+ temperature = temperature ,
76+ pressure = pressure ,
77+ )
78+
79+ @cached_property
80+ def _terminal_velocity_columnar_ice_crystals_body (self ):
81+ v_base_term = self .formulae .terminal_velocity_ice .v_base_term
82+ atmospheric_correction_factor = (
83+ self .formulae .terminal_velocity_ice .atmospheric_correction_factor
84+ )
85+
86+ @numba .njit (** self .default_jit_flags )
87+ def body (* , values , signed_water_mass , cell_id , temperature , pressure ):
88+ for i in numba .prange (len (values )): # pylint: disable=not-an-iterable
89+ if signed_water_mass [i ] < 0 :
90+ cid = cell_id [i ]
91+ correction = atmospheric_correction_factor (
92+ temperature [cid ], pressure [cid ]
93+ )
94+ values [i ] = v_base_term (- signed_water_mass [i ]) * correction
95+
96+ return body
97+
98+ def terminal_velocity_ice_spheres (
99+ self , * , values , signed_water_mass , cell_id , temperature , pressure
100+ ): # pylint: disable=unused-argument
101+ self ._terminal_velocity_ice_spheres_body (
102+ values = values ,
103+ signed_water_mass = signed_water_mass ,
104+ cell_id = cell_id ,
105+ temperature = temperature ,
106+ )
107+
108+ @cached_property
109+ def _terminal_velocity_ice_spheres_body (self ):
110+ v_base_term = self .formulae .terminal_velocity_ice .v_base_term
111+ stokes_prefactor = self .formulae .terminal_velocity_ice .stokes_regime
112+ formulae = self .formulae_flattened
113+
114+ def body (* , values , signed_water_mass , cell_id , temperature ):
115+ for i in numba .prange (len (values )): # pylint: disable=not-an-iterable
116+ if signed_water_mass [i ] < 0 :
117+ cid = cell_id [i ]
118+ radius = formulae .particle_shape_and_density__mass_to_radius (
119+ signed_water_mass [i ]
120+ )
121+ dynamic_viscosity = formulae .air_dynamic_viscosity__eta_air (
122+ temperature [cid ]
123+ )
124+ prefactor = stokes_prefactor (radius , dynamic_viscosity )
125+ values [i ] = v_base_term (prefactor , radius )
126+
127+ return body
0 commit comments