@@ -56,7 +56,7 @@ function set_precipitation_velocities!(
5656 microphysics_model:: Microphysics1Moment ,
5757 _,
5858)
59- (; ᶜwₗ, ᶜwᵢ, ᶜwᵣ, ᶜwₛ, ᶜwₜqₜ, ᶜwₕhₜ, ᶜts , ᶜu) = p. precomputed
59+ (; ᶜwₗ, ᶜwᵢ, ᶜwᵣ, ᶜwₛ, ᶜwₜqₜ, ᶜwₕhₜ, ᶜT , ᶜu) = p. precomputed
6060 (; ᶜΦ) = p. core
6161 cmc = CAP. microphysics_cloud_params(p. params)
6262 cmp = CAP. microphysics_1m_params(p. params)
@@ -99,10 +99,10 @@ function set_precipitation_velocities!(
9999 ) / Y. c. ρ
100100 @. ᶜwₕhₜ =
101101 Geometry. WVector(
102- ᶜwₗ * Y. c. ρq_liq * (Iₗ(thp, ᶜts ) + ᶜΦ + $ (Kin(ᶜwₗ, ᶜu))) +
103- ᶜwᵢ * Y. c. ρq_ice * (Iᵢ(thp, ᶜts ) + ᶜΦ + $ (Kin(ᶜwᵢ, ᶜu))) +
104- ᶜwᵣ * Y. c. ρq_rai * (Iₗ(thp, ᶜts ) + ᶜΦ + $ (Kin(ᶜwᵣ, ᶜu))) +
105- ᶜwₛ * Y. c. ρq_sno * (Iᵢ(thp, ᶜts ) + ᶜΦ + $ (Kin(ᶜwₛ, ᶜu))),
102+ ᶜwₗ * Y. c. ρq_liq * (Iₗ(thp, ᶜT ) + ᶜΦ + $ (Kin(ᶜwₗ, ᶜu))) +
103+ ᶜwᵢ * Y. c. ρq_ice * (Iᵢ(thp, ᶜT ) + ᶜΦ + $ (Kin(ᶜwᵢ, ᶜu))) +
104+ ᶜwᵣ * Y. c. ρq_rai * (Iₗ(thp, ᶜT ) + ᶜΦ + $ (Kin(ᶜwᵣ, ᶜu))) +
105+ ᶜwₛ * Y. c. ρq_sno * (Iᵢ(thp, ᶜT ) + ᶜΦ + $ (Kin(ᶜwₛ, ᶜu))),
106106 ) / Y. c. ρ
107107 return nothing
108108end
@@ -284,7 +284,7 @@ function set_precipitation_velocities!(
284284 microphysics_model:: Microphysics2Moment ,
285285 _,
286286)
287- (; ᶜwₗ, ᶜwᵢ, ᶜwᵣ, ᶜwₛ, ᶜwₙₗ, ᶜwₙᵣ, ᶜwₜqₜ, ᶜwₕhₜ, ᶜts , ᶜu) = p. precomputed
287+ (; ᶜwₗ, ᶜwᵢ, ᶜwᵣ, ᶜwₛ, ᶜwₙₗ, ᶜwₙᵣ, ᶜwₜqₜ, ᶜwₕhₜ, ᶜT , ᶜu) = p. precomputed
288288 (; ᶜΦ) = p. core
289289
290290 cmc = CAP. microphysics_cloud_params(p. params)
@@ -359,10 +359,10 @@ function set_precipitation_velocities!(
359359 ) / Y. c. ρ
360360 @. ᶜwₕhₜ =
361361 Geometry. WVector(
362- ᶜwₗ * Y. c. ρq_liq * (Iₗ(thp, ᶜts ) + ᶜΦ + $ (Kin(ᶜwₗ, ᶜu))) +
363- ᶜwᵢ * Y. c. ρq_ice * (Iᵢ(thp, ᶜts ) + ᶜΦ + $ (Kin(ᶜwᵢ, ᶜu))) +
364- ᶜwᵣ * Y. c. ρq_rai * (Iₗ(thp, ᶜts ) + ᶜΦ + $ (Kin(ᶜwᵣ, ᶜu))) +
365- ᶜwₛ * Y. c. ρq_sno * (Iᵢ(thp, ᶜts ) + ᶜΦ + $ (Kin(ᶜwₛ, ᶜu))),
362+ ᶜwₗ * Y. c. ρq_liq * (Iₗ(thp, ᶜT ) + ᶜΦ + $ (Kin(ᶜwₗ, ᶜu))) +
363+ ᶜwᵢ * Y. c. ρq_ice * (Iᵢ(thp, ᶜT ) + ᶜΦ + $ (Kin(ᶜwᵢ, ᶜu))) +
364+ ᶜwᵣ * Y. c. ρq_rai * (Iₗ(thp, ᶜT ) + ᶜΦ + $ (Kin(ᶜwᵣ, ᶜu))) +
365+ ᶜwₛ * Y. c. ρq_sno * (Iᵢ(thp, ᶜT ) + ᶜΦ + $ (Kin(ᶜwₛ, ᶜu))),
366366 ) / Y. c. ρ
367367 return nothing
368368end
@@ -555,7 +555,7 @@ function set_precipitation_velocities!(
555555 Y, p, :: NonEquilMoistModel , :: Microphysics2MomentP3 ,
556556)
557557 # # liquid quantities (2M warm rain)
558- (; ᶜwₗ, ᶜwᵣ, ᶜwnₗ, ᶜwnᵣ, ᶜwₜqₜ, ᶜwₕhₜ, ᶜts , ᶜu) = p. precomputed
558+ (; ᶜwₗ, ᶜwᵣ, ᶜwnₗ, ᶜwnᵣ, ᶜwₜqₜ, ᶜwₕhₜ, ᶜT , ᶜu) = p. precomputed
559559 (; ᶜΦ) = p. core
560560
561561 (; ρ, ρq_liq, ρn_liq, ρq_rai, ρn_rai) = Y. c
@@ -606,9 +606,9 @@ function set_precipitation_velocities!(
606606 @. ᶜwₜqₜ = Geometry. WVector(ᶜwₗ * ρq_liq + ᶜwᵢ * ρq_ice + ᶜwᵣ * ρq_rai) / ρ
607607 @. ᶜwₕhₜ =
608608 Geometry. WVector(
609- ᶜwₗ * ρq_liq * (Iₗ(thp, ᶜts ) + ᶜΦ + $ (Kin(ᶜwₗ, ᶜu))) +
610- ᶜwᵢ * ρq_ice * (Iᵢ(thp, ᶜts ) + ᶜΦ + $ (Kin(ᶜwᵢ, ᶜu))) +
611- ᶜwᵣ * ρq_rai * (Iₗ(thp, ᶜts ) + ᶜΦ + $ (Kin(ᶜwᵣ, ᶜu))),
609+ ᶜwₗ * ρq_liq * (Iₗ(thp, ᶜT ) + ᶜΦ + $ (Kin(ᶜwₗ, ᶜu))) +
610+ ᶜwᵢ * ρq_ice * (Iᵢ(thp, ᶜT ) + ᶜΦ + $ (Kin(ᶜwᵢ, ᶜu))) +
611+ ᶜwᵣ * ρq_rai * (Iₗ(thp, ᶜT ) + ᶜΦ + $ (Kin(ᶜwᵣ, ᶜu))),
612612 ) / ρ
613613 return nothing
614614end
@@ -624,22 +624,23 @@ sources from the sub-domains.
624624set_precipitation_cache!(Y, p, _, _) = nothing
625625function set_precipitation_cache!(Y, p, :: Microphysics0Moment , _)
626626 (; params, dt) = p
627- (; ᶜts ) = p. precomputed
627+ (; ᶜT, ᶜq_tot_safe, ᶜq_liq_rai, ᶜq_ice_sno ) = p. precomputed
628628 (; ᶜS_ρq_tot, ᶜS_ρe_tot) = p. precomputed
629629 (; ᶜΦ) = p. core
630630 cm_params = CAP. microphysics_0m_params(params)
631631 thermo_params = CAP. thermodynamics_params(params)
632632 @. ᶜS_ρq_tot =
633633 Y. c. ρ * q_tot_0M_precipitation_sources(
634- thermo_params,
635634 cm_params,
636635 dt,
637636 Y. c. ρq_tot / Y. c. ρ,
638- ᶜts,
637+ ᶜq_tot_safe,
638+ ᶜq_liq_rai,
639+ ᶜq_ice_sno,
639640 )
640641 @. ᶜS_ρe_tot =
641642 ᶜS_ρq_tot *
642- e_tot_0M_precipitation_sources_helper(thermo_params, ᶜts , ᶜΦ)
643+ e_tot_0M_precipitation_sources_helper(thermo_params, ᶜT, ᶜq_liq_rai, ᶜq_ice_sno , ᶜΦ)
643644 return nothing
644645end
645646function set_precipitation_cache!(
@@ -653,7 +654,7 @@ function set_precipitation_cache!(
653654 (; ᶜΦ) = p. core
654655 (; ᶜSqₜᵖ⁰, ᶜSqₜᵖʲs, ᶜρaʲs) = p. precomputed
655656 (; ᶜS_ρq_tot, ᶜS_ρe_tot) = p. precomputed
656- (; ᶜts , ᶜtsʲs) = p. precomputed
657+ (; ᶜT, ᶜq_tot_safe, ᶜq_liq_rai, ᶜq_ice_sno , ᶜtsʲs) = p. precomputed
657658 thermo_params = CAP. thermodynamics_params(p. params)
658659
659660 n = n_mass_flux_subdomains(p. atmos. turbconv_model)
@@ -663,15 +664,20 @@ function set_precipitation_cache!(
663664 @. ᶜS_ρe_tot =
664665 ᶜSqₜᵖ⁰ *
665666 ρ *
666- e_tot_0M_precipitation_sources_helper(thermo_params, ᶜts , ᶜΦ)
667+ e_tot_0M_precipitation_sources_helper(thermo_params, ᶜT, ᶜq_liq_rai, ᶜq_ice_sno , ᶜΦ)
667668 for j in 1 : n
669+ ᶜTʲ = @. lazy(TD. air_temperature(thermo_params, ᶜtsʲs.:($$ j)))
670+ ᶜq_liq_raiʲ = @. lazy(TD. liquid_specific_humidity(thermo_params, ᶜtsʲs.:($$ j)))
671+ ᶜq_ice_snoʲ = @. lazy(TD. ice_specific_humidity(thermo_params, ᶜtsʲs.:($$ j)))
668672 @. ᶜS_ρq_tot += ᶜSqₜᵖʲs.:($$ j) * ᶜρaʲs.:($$ j)
669673 @. ᶜS_ρe_tot +=
670674 ᶜSqₜᵖʲs.:($$ j) *
671675 ᶜρaʲs.:($$ j) *
672676 e_tot_0M_precipitation_sources_helper(
673677 thermo_params,
674- ᶜtsʲs.:($$ j),
678+ ᶜTʲ,
679+ ᶜq_liq_raiʲ,
680+ ᶜq_ice_snoʲ,
675681 ᶜΦ,
676682 )
677683 end
@@ -693,26 +699,34 @@ function set_precipitation_cache!(
693699 n = n_mass_flux_subdomains(p. atmos. turbconv_model)
694700
695701 @. ᶜS_ρq_tot = ᶜSqₜᵖ⁰ * ᶜρa⁰
702+ ᶜT⁰ = @. lazy(TD. air_temperature(thermo_params, ᶜts⁰))
703+ ᶜq_liq_rai⁰ = @. lazy(TD. liquid_specific_humidity(thermo_params, ᶜts⁰))
704+ ᶜq_ice_sno⁰ = @. lazy(TD. ice_specific_humidity(thermo_params, ᶜts⁰))
696705 @. ᶜS_ρe_tot =
697706 ᶜSqₜᵖ⁰ *
698707 ᶜρa⁰ *
699- e_tot_0M_precipitation_sources_helper(thermo_params, ᶜts ⁰, ᶜΦ)
708+ e_tot_0M_precipitation_sources_helper(thermo_params, ᶜT⁰, ᶜq_liq_rai⁰, ᶜq_ice_sno ⁰, ᶜΦ)
700709 for j in 1 : n
710+ ᶜTʲ = @. lazy(TD. air_temperature(thermo_params, ᶜtsʲs.:($$ j)))
711+ ᶜq_liq_raiʲ = @. lazy(TD. liquid_specific_humidity(thermo_params, ᶜtsʲs.:($$ j)))
712+ ᶜq_ice_snoʲ = @. lazy(TD. ice_specific_humidity(thermo_params, ᶜtsʲs.:($$ j)))
701713 @. ᶜS_ρq_tot += ᶜSqₜᵖʲs.:($$ j) * Y. c. sgsʲs.:($$ j). ρa
702714 @. ᶜS_ρe_tot +=
703715 ᶜSqₜᵖʲs.:($$ j) *
704716 Y. c. sgsʲs.:($$ j). ρa *
705717 e_tot_0M_precipitation_sources_helper(
706718 thermo_params,
707- ᶜtsʲs.:($$ j),
719+ ᶜTʲ,
720+ ᶜq_liq_raiʲ,
721+ ᶜq_ice_snoʲ,
708722 ᶜΦ,
709723 )
710724 end
711725 return nothing
712726end
713727function set_precipitation_cache!(Y, p, :: Microphysics1Moment , _)
714728 (; dt) = p
715- (; ᶜts , ᶜwᵣ, ᶜwₛ, ᶜu) = p. precomputed
729+ (; ᶜT , ᶜwᵣ, ᶜwₛ, ᶜu) = p. precomputed
716730 (; ᶜSqₗᵖ, ᶜSqᵢᵖ, ᶜSqᵣᵖ, ᶜSqₛᵖ) = p. precomputed
717731
718732 ᶜq_tot = @. lazy(specific(Y. c. ρq_tot, Y. c. ρ))
@@ -744,7 +758,7 @@ function set_precipitation_cache!(Y, p, ::Microphysics1Moment, _)
744758 ᶜq_ice,
745759 ᶜq_rai,
746760 ᶜq_sno,
747- ᶜts ,
761+ ᶜT ,
748762 dt,
749763 cmp,
750764 thp,
@@ -761,7 +775,7 @@ function set_precipitation_cache!(Y, p, ::Microphysics1Moment, _)
761775 ᶜq_ice,
762776 ᶜq_rai,
763777 ᶜq_sno,
764- ᶜts ,
778+ ᶜT ,
765779 dt,
766780 cmp,
767781 thp,
@@ -790,8 +804,7 @@ function set_precipitation_cache!(
790804end
791805function set_precipitation_cache!(Y, p, :: Microphysics2Moment , _)
792806 (; dt) = p
793- (; ᶜts) = p. precomputed
794- (; ᶜSqₗᵖ, ᶜSqᵢᵖ, ᶜSqᵣᵖ, ᶜSqₛᵖ) = p. precomputed
807+ (; ᶜT, ᶜSqₗᵖ, ᶜSqᵢᵖ, ᶜSqᵣᵖ, ᶜSqₛᵖ) = p. precomputed
795808 (; ᶜSnₗᵖ, ᶜSnᵣᵖ) = p. precomputed
796809
797810 ᶜSᵖ = p. scratch. ᶜtemp_scalar
@@ -818,7 +831,7 @@ function set_precipitation_cache!(Y, p, ::Microphysics2Moment, _)
818831 lazy.(specific.(Y. c. ρq_ice, Y. c. ρ)),
819832 lazy.(specific.(Y. c. ρq_rai, Y. c. ρ)),
820833 lazy.(specific.(Y. c. ρq_sno, Y. c. ρ)),
821- ᶜts ,
834+ ᶜT ,
822835 dt,
823836 cmp,
824837 thp,
@@ -894,7 +907,7 @@ function set_precipitation_surface_fluxes!(
894907 p,
895908 microphysics_model:: Microphysics0Moment ,
896909)
897- (; ᶜts, ᶜT) = p. precomputed # assume ᶜts has been updated
910+ (; ᶜT) = p. precomputed
898911 (; ᶜS_ρq_tot, ᶜS_ρe_tot) = p. precomputed
899912 (; surface_rain_flux, surface_snow_flux) = p. precomputed
900913 (; col_integrated_precip_energy_tendency) = p. conservation_check
0 commit comments