@@ -606,12 +606,24 @@ function update_jacobian!(alg::ManualSparseJacobian, cache, Y, p, dtγ, t)
606
606
return q / float (dt) / n
607
607
end
608
608
609
- function ∂ρqₗ_err_∂ρqᵪ (tps, ts, cmc, dt, deriv, limit_deriv)
609
+ function ∂ρqₗ_err_∂ρqₗ (tps, ts, cmc, dt, S, pos_lim, neg_lim,
610
+ source_deriv, pos_lim_deriv, neg_lim_deriv)
610
611
FT_inner = eltype (tps)
611
612
q = TD. PhasePartition (tps, ts)
612
613
ρ = TD. air_density (tps, ts)
613
614
614
- S = CMNe. conv_q_vap_to_q_liq_ice_MM2015 (cmc. liquid, tps, q, ρ, Tₐ (tps, ts))
615
+ # set derivatives to 0 if things are getting clipped
616
+ if q. vap < FT (0 )
617
+ pos_lim_deriv = 0
618
+
619
+ if q. liq < FT (0 )
620
+ neg_lim_deriv = 0
621
+
622
+ if q. tot + q. liq < FT (0 )
623
+ S = CMNe. conv_q_vap_to_q_liq_ice_MM2015 (cmc. liquid, tps, q, ρ, Tₐ (tps, ts))
624
+ else
625
+ S = 0
626
+ source_deriv = 0
615
627
616
628
if S > FT_inner (0 )
617
629
if S <= limit (TD. vapor_specific_humidity (q), dt, 2 )
@@ -636,7 +648,7 @@ function update_jacobian!(alg::ManualSparseJacobian, cache, Y, p, dtγ, t)
636
648
end
637
649
end
638
650
639
- function ∂ρqᵢ_err_∂ρqᵪ (tps, ts, cmc, dt, deriv, limit_deriv)
651
+ function ∂ρqᵢ_err_∂ρqᵢ (tps, ts, cmc, dt, deriv, limit_deriv)
640
652
FT_inner = eltype (tps)
641
653
q = TD. PhasePartition (tps, ts)
642
654
ρ = TD. air_density (tps, ts)
0 commit comments