-
Notifications
You must be signed in to change notification settings - Fork 27
add Jacobain elements for du3^j_err_dq^j and drhoa_err_dq^j #4132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
095d9ba to
a4255f8
Compare
| ∂ᶜρaʲ_err_∂ᶜq_totʲ = | ||
| matrix[@name(c.sgsʲs.:(1).ρa), @name(c.sgsʲs.:(1).q_tot)] | ||
| # set to zero because in the following loop we do += | ||
| @. ∂ᶜρaʲ_err_∂ᶜq_totʲ = zero(typeof(∂ᶜρaʲ_err_∂ᶜq_totʲ)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this (I think in the loop we are doing =)?
| # term to be NaN (0 * ... / 0). The ifelse handles this case explicitly. | ||
| return ρa == 0 ? ρχ / ρ : weight * ρaχ / ρa + (1 - weight) * ρχ / ρ | ||
| # In practice the condition ρa < eps is used to avoid NaNs in autodiff. | ||
| return ρa < eps(typeof(ρ)) ? ρχ / ρ : weight * ρaχ / ρa + (1 - weight) * ρχ / ρ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sets it to grid-mean if ρa is smaller than eps - is that what you want? If so could you update the comment?
szy21
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Just some minor comments.
a4255f8 to
c45833a
Compare
add Jacobain elements for du3^j_err_dq^j and drhoa_err_dq^j
Purpose
In this PR we add Jacobian elements for$\partial u^{3j}_err/\partial q^j$ and $\partial \rho a_err/\partial q^j$ through variations of $\rho^j$ with respect to condensate masses $q$ .
so
We know that
The derivate of$R_m T$ with respect to the condensate mass $q$ is
where$\Delta c_p$ is the difference of $c_p$ of the condensate and water vapor, $LH$ is the latent heat of the condensate ($LH_{v0}$ for liquid and $LH_{v0} + LH_{f0}$ for ice) and $\kappa_m = R_m/c_{v, m}$ . Therefore,