Skip to content
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

update to exact integration scheme for radiative cooling #585

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/main/cooling_solver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,26 @@ subroutine exact_cooling(ui, dudt, rho, dt, mu, gamma, Tdust, K2, kappa)
!argument of Y^(-1) in eq 26
dy = -Qref*dt*T_on_u/Tref
y = y + dy
!find new k for eq A7 (not necessarily the same as k for eq A5)
do while(y>yk .AND. k>1)
k = k-1
call calc_cooling_rate(Q, dlnQ_dlnT, rho, Tgrid(k), Tdust, mu, gamma, K2, kappa)
dlnQ_dlnT = log(Qi/Q)/log(Tgrid(k+1)/Tgrid(k))
Qi = Q
! eqs A6 to get Yk
if (abs(dlnQ_dlnT-1.) < tol) then
yk = yk - Qref*Tgrid(k)/(Q*Tref)*log(Tgrid(k)/Tgrid(k+1))
else
yk = yk - Qref*Tgrid(k)/(Q*Tref*(1.-dlnQ_dlnT))*(1.-(Tgrid(k)/Tgrid(k+1))**(dlnQ_dlnT-1.))
endif
enddo
!compute Yinv (eqs A7)
if (abs(dlnQ_dlnT-1.) < tol) then
Temp = max(Tgrid(k)*exp(-Q*Tref*(y-yk)/(Qref*Tgrid(k))),T_floor)
else
Yinv = 1.-(1.-dlnQ_dlnT)*Q*Tref/(Qref*Tgrid(k))*(y-yk)
if (Yinv > 0.) then
Temp = Tgrid(k)*(Yinv**(1./(1.-dlnQ_dlnT)))
Temp = max(Tgrid(k)*(Yinv**(1./(1.-dlnQ_dlnT))),T_floor)
else
Temp = T_floor
endif
Expand Down
Loading