@@ -769,8 +769,10 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_precipitation
769769)
770770
771771 (; params, dt) = p
772+ (; ᶜΦ,) = p. core
772773 thp = CAP. thermodynamics_params (params)
773- cmp = CAP. microphysics_2m_params (params)
774+ cm1p = CAP. microphysics_1m_params (p. params)
775+ cm2p = CAP. microphysics_2m_params (p. params)
774776 cmc = CAP. microphysics_cloud_params (params)
775777
776778 (;
@@ -786,6 +788,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_precipitation
786788 ) = p. precomputed
787789 (; ᶜSqₗᵖ⁰, ᶜSqᵢᵖ⁰, ᶜSqᵣᵖ⁰, ᶜSqₛᵖ⁰, ᶜSnₗᵖ⁰, ᶜSnᵣᵖ⁰, ᶜts⁰, ᶜu⁰) =
788790 p. precomputed
791+ (; ᶜwₗʲs, ᶜwᵢʲs, ᶜwᵣʲs, ᶜwₛʲs, ᶜwₙₗʲs, ᶜwₙᵣʲs, ᶜwₜʲs, ᶜwₕʲs) = p. precomputed
789792
790793 ᶜSᵖ = p. scratch. ᶜtemp_scalar
791794 ᶜS₂ᵖ = p. scratch. ᶜtemp_scalar_2
@@ -801,7 +804,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_precipitation
801804 seasalt_mean_radius,
802805 sulfate_num,
803806 p. tracers. prescribed_aerosols_field,
804- cmp . aerosol,
807+ cm2p . aerosol,
805808 )
806809 else
807810 @. seasalt_num = 0
@@ -811,7 +814,95 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_precipitation
811814
812815 # Compute sources
813816 n = n_mass_flux_subdomains (p. atmos. turbconv_model)
817+ FT = eltype (params)
814818 for j in 1 : n
819+
820+ # compute terminal velocity for precipitation
821+ # TODO sedimentation of snow is based on the 1M scheme
822+ @. ᶜwₙᵣʲs.:($$ j) = getindex (
823+ CM2. rain_terminal_velocity (
824+ cm2p. sb,
825+ cm2p. rtv,
826+ max (zero (Y. c. ρ), Y. c. sgsʲs.:($$ j). q_rai),
827+ ᶜρʲs.:($$ j),
828+ max (zero (Y. c. ρ), Y. c. sgsʲs.:($$ j). n_rai),
829+ ),
830+ 1 ,
831+ )
832+ @. ᶜwᵣʲs.:($$ j) = getindex (
833+ CM2. rain_terminal_velocity (
834+ cm2p. sb,
835+ cm2p. rtv,
836+ max (zero (Y. c. ρ), Y. c. sgsʲs.:($$ j). q_rai),
837+ ᶜρʲs.:($$ j),
838+ max (zero (Y. c. ρ), Y. c. sgsʲs.:($$ j). n_rai),
839+ ),
840+ 2 ,
841+ )
842+ @. ᶜwₛʲs.:($$ j) = CM1. terminal_velocity (
843+ cm1p. ps,
844+ cm1p. tv. snow,
845+ ᶜρʲs.:($$ j),
846+ max (zero (Y. c. ρ), Y. c. sgsʲs.:($$ j). q_sno),
847+ )
848+ # compute sedimentation velocity for cloud condensate [m/s]
849+ # TODO sedimentation of ice is based on the 1M scheme
850+ @. ᶜwₙₗʲs.:($$ j) = getindex (
851+ CM2. cloud_terminal_velocity (
852+ cm2p. sb. pdf_c,
853+ cm2p. ctv,
854+ max (zero (Y. c. ρ), Y. c. sgsʲs.:($$ j). q_liq),
855+ ᶜρʲs.:($$ j),
856+ max (zero (Y. c. ρ), ᶜρʲs.:($$ j) * Y. c. sgsʲs.:($$ j). n_liq),
857+ ),
858+ 1 ,
859+ )
860+ @. ᶜwₗʲs.:($$ j) = getindex (
861+ CM2. cloud_terminal_velocity (
862+ cm2p. sb. pdf_c,
863+ cm2p. ctv,
864+ max (zero (Y. c. ρ), Y. c. sgsʲs.:($$ j). q_liq),
865+ ᶜρʲs.:($$ j),
866+ max (zero (Y. c. ρ), ᶜρʲs.:($$ j) * Y. c. sgsʲs.:($$ j). n_liq),
867+ ),
868+ 2 ,
869+ )
870+ @. ᶜwᵢʲs.:($$ j) = CMNe. terminal_velocity (
871+ cmc. ice,
872+ cmc. Ch2022. small_ice,
873+ ᶜρʲs.:($$ j),
874+ max (zero (Y. c. ρ), Y. c. sgsʲs.:($$ j). q_ice),
875+ )
876+ # compute their contirbutions to energy and total water advection
877+ @. ᶜwₜʲs.:($$ j) = ifelse (
878+ Y. c. sgsʲs.:($$ j). ρa * Y. c. sgsʲs.:($$ j). q_tot > FT (0 ),
879+ (
880+ ᶜwₗʲs.:($$ j) * Y. c. sgsʲs.:($$ j). q_liq +
881+ ᶜwᵢʲs.:($$ j) * Y. c. sgsʲs.:($$ j). q_ice +
882+ ᶜwᵣʲs.:($$ j) * Y. c. sgsʲs.:($$ j). q_rai +
883+ ᶜwₛʲs.:($$ j) * Y. c. sgsʲs.:($$ j). q_sno
884+ ) / Y. c. sgsʲs.:($$ j). q_tot,
885+ FT (0 ),
886+ )
887+ @. ᶜwₕʲs.:($$ j) = ifelse (
888+ Y. c. sgsʲs.:($$ j). ρa * abs (Y. c. sgsʲs.:($$ j). mse) > FT (0 ),
889+ (
890+ ᶜwₗʲs.:($$ j) *
891+ Y. c. sgsʲs.:($$ j). q_liq *
892+ (Iₗ (thp, ᶜtsʲs.:($$ j)) + ᶜΦ) +
893+ ᶜwᵢʲs.:($$ j) *
894+ Y. c. sgsʲs.:($$ j). q_ice *
895+ (Iᵢ (thp, ᶜtsʲs.:($$ j)) + ᶜΦ) +
896+ ᶜwᵣʲs.:($$ j) *
897+ Y. c. sgsʲs.:($$ j). q_rai *
898+ (Iₗ (thp, ᶜtsʲs.:($$ j)) + ᶜΦ) +
899+ ᶜwₛʲs.:($$ j) *
900+ Y. c. sgsʲs.:($$ j). q_sno *
901+ (Iᵢ (thp, ᶜtsʲs.:($$ j)) + ᶜΦ)
902+ ) / abs (Y. c. sgsʲs.:($$ j). mse),
903+ FT (0 ),
904+ )
905+
815906 # Precipitation sources and sinks from the updrafts
816907 compute_warm_precipitation_sources_2M! (
817908 ᶜSᵖ,
@@ -830,7 +921,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_precipitation
830921 Y. c. sgsʲs.:($ j). q_sno,
831922 ᶜtsʲs.:($ j),
832923 dt,
833- cmp ,
924+ cm2p ,
834925 thp,
835926 )
836927 @. ᶜSqᵢᵖʲs.:($$ j) = 0
@@ -870,7 +961,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_precipitation
870961 Y. c. sgsʲs.:($$ j). n_liq + Y. c. sgsʲs.:($$ j). n_rai,
871962 ᶜρʲs.:($$ j),
872963 max (0 , w_component .(Geometry. WVector .(ᶜuʲs.:($$ j)))),
873- (cmp ,),
964+ (cm2p ,),
874965 thp,
875966 ᶜtsʲs.:($$ j),
876967 dt,
@@ -903,7 +994,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_precipitation
903994 ᶜq_sno⁰,
904995 ᶜts⁰,
905996 dt,
906- cmp ,
997+ cm2p ,
907998 thp,
908999 )
9091000 @. ᶜSqᵢᵖ⁰ = 0
@@ -943,7 +1034,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_precipitation
9431034 ᶜn_liq⁰ + ᶜn_rai⁰,
9441035 ᶜρ⁰,
9451036 w_component .(Geometry. WVector .(ᶜu⁰)),
946- (cmp ,),
1037+ (cm2p ,),
9471038 thp,
9481039 ᶜts⁰,
9491040 dt,
0 commit comments