72 INTEGER,
PARAMETER ::
gray = 1
101 REAL,
PARAMETER ::
texp(8) = (/ 2.0, -7.0, 0.5, -24.0, 3.0, 10.0, -2.5, 0.0 /)
102 REAL,
PARAMETER ::
rexp(8) = (/ 0.0, 0.0, 0.0, 1.0, 2./3., 1./3., 1.0, 0.0 /)
103 REAL,
PARAMETER ::
t0 = 3000
107 CHARACTER(LEN=32) :: source_name =
"thin accretion disk cooling" 144 CLASS(sources_diskcooling) :: this
145 CLASS(mesh_base),
INTENT(IN) :: Mesh
146 CLASS(physics_base),
INTENT(IN) :: Physics
147 CLASS(fluxes_base),
INTENT(IN) :: Fluxes
148 TYPE(Dict_TYP),
POINTER :: config,IO
151 INTEGER :: cooling_func
153 CALL getattr(config,
"stype", stype)
154 CALL this%InitLogging(stype,this%source_name)
158 SELECT TYPE (phys => physics)
163 CALL this%Error(
"InitSources_diskcooling",
"physics not supported")
166 SELECT CASE(cooling_func)
169 SELECT TYPE (mgeo => mesh%Geometry)
173 CALL this%Error(
"InitSources_diskcooling",
"geometry not supported")
176 SELECT TYPE (mgeo => mesh%Geometry)
180 CALL this%Error(
"InitSources_diskcooling",
"geometry not supported")
185 IF (physics%VDIM.GT.2)
THEN 186 CALL this%Error(
"InitSources_diskcooling",
"only 2D simulations supported")
190 CALL getattr(config,
"method",cooling_func)
192 SELECT CASE(cooling_func)
194 IF (physics%constants%GetType().NE.si) &
195 CALL this%Error(
"InitSources_diskcooling",
"only SI units supported for gray cooling")
196 CALL this%cooling%InitLogging(
gray,
"gray cooling")
201 CALL this%cooling%InitLogging(
gammie,
"Gammie cooling")
207 CALL this%cooling%InitLogging(
gammie_sb,
"Gammie cooling (SB)")
212 CALL this%Error(
"UpdateCooling",
"Cooling function not supported!")
216 CALL getattr(config,
"cvis", this%cvis, 0.1)
219 CALL getattr(config,
"Tmin", this%T_0, 1.0e-30)
222 CALL getattr(config,
"Rhomin", this%rho_0, 1.0e-30)
225 CALL getattr(config,
"b_cool", this%b_cool, 1.0e+00)
228 CALL getattr(config,
"b_start", this%b_start, 0.0)
229 CALL getattr(config,
"b_final", this%b_final, this%b_cool)
232 CALL getattr(config,
"t_start", this%t_start, 0.0)
235 CALL getattr(config,
"dt_bdec", this%dt_bdec, -1.0)
241 this%Qcool%data1d(:) = 0.0
242 SELECT CASE(cooling_func)
246 this%ephir%data4d(:,:,:,1) = -mesh%posvec%bcenter(:,:,:,2)/mesh%radius%bcenter(:,:,:)**2
247 this%ephir%data4d(:,:,:,2) = mesh%posvec%bcenter(:,:,:,1)/mesh%radius%bcenter(:,:,:)**2
253 CALL this%SetOutput(mesh,config,io)
254 CALL this%InitSources(mesh,fluxes,physics,config,io)
262 CLASS(sources_diskcooling),
INTENT(IN) :: this
263 CLASS(mesh_base),
INTENT(IN) :: Mesh
265 CHARACTER(LEN=32) :: param_str
267 CALL this%Info(
" cooling function: " // trim(this%cooling%GetName()))
268 SELECT CASE(this%cooling%GetType())
270 WRITE (param_str,
'(ES8.2)') this%T_0
271 CALL this%Info(
" min. temperature: " // trim(param_str))
272 WRITE (param_str,
'(ES8.2)') this%rho_0
273 CALL this%Info(
" minimum density: " // trim(param_str))
275 WRITE (param_str,
'(ES8.2)') this%b_cool
276 CALL this%Info(
" cooling parameter: " // trim(param_str))
278 WRITE (param_str,
'(ES8.2)') this%b_cool
279 CALL this%Info(
" cooling parameter: " // trim(param_str))
280 IF(this%dt_bdec.GE.0.0)
THEN 281 WRITE (param_str,
'(ES8.2)') this%b_start
282 CALL this%Info(
" initial cooling parameter: " // trim(param_str))
283 WRITE (param_str,
'(ES8.2)') this%b_final
284 CALL this%Info(
" final cooling parameter: " // trim(param_str))
285 WRITE (param_str,
'(ES8.2)') this%t_start
286 CALL this%Info(
" starting b_dec time: " // trim(param_str))
287 WRITE (param_str,
'(ES8.2)') this%dt_bdec
288 CALL this%Info(
" operating time: " // trim(param_str))
294 SUBROUTINE setoutput(this,Mesh,config,IO)
297 CLASS(sources_diskcooling) :: this
298 CLASS(mesh_base),
INTENT(IN) :: Mesh
299 TYPE(Dict_TYP),
POINTER :: config,IO
305 CALL getattr(config,
"output/Qcool", valwrite, 0)
306 IF (valwrite .EQ. 1) &
307 CALL setattr(io,
"Qcool", &
308 this%Qcool%data3d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
317 CLASS(sources_diskcooling),
INTENT(INOUT) :: this
318 CLASS(mesh_base),
INTENT(IN) :: Mesh
319 CLASS(physics_base),
INTENT(INOUT) :: Physics
320 CLASS(sources_base),
INTENT(INOUT) :: Sources
321 CLASS(fluxes_base),
INTENT(IN) :: Fluxes
322 REAL,
INTENT(IN) :: time, dt
323 CLASS(marray_compound),
INTENT(INOUT):: pvar,cvar,sterm
325 SELECT TYPE(s => sterm)
327 s%density%data1d(:) = 0.0
328 s%momentum%data1d(:) = 0.0
330 SELECT TYPE(phys => physics)
332 SELECT TYPE(p => pvar)
334 CALL this%UpdateCooling(mesh,phys,sources,time,p)
339 s%energy%data1d(:) = -this%Qcool%data1d(:)
349 CLASS(sources_diskcooling),
INTENT(INOUT) :: this
350 CLASS(mesh_base),
INTENT(IN) :: Mesh
351 CLASS(physics_base),
INTENT(INOUT) :: Physics
352 CLASS(fluxes_base),
INTENT(IN) :: Fluxes
353 CLASS(marray_compound),
INTENT(INOUT) :: pvar,cvar
354 REAL,
INTENT(IN) :: time
355 REAL,
INTENT(OUT) :: dt
361 SELECT TYPE(p => pvar)
363 invdt = maxval(abs(this%Qcool%data1d(:) / p%pressure%data1d(:)), &
364 mask=mesh%without_ghost_zones%mask1d(:))
365 IF (invdt.GT.tiny(invdt)) dt = this%cvis / invdt
370 SUBROUTINE updatecooling(this,Mesh,Physics,Sources,time,pvar)
374 CLASS(sources_diskcooling) :: this
375 CLASS(mesh_base),
INTENT(IN) :: Mesh
376 CLASS(physics_euler),
INTENT(INOUT) :: Physics
377 CLASS(sources_base),
INTENT(INOUT) :: Sources
378 CLASS(statevector_euler),
INTENT(INOUT):: pvar
379 REAL,
INTENT(IN) :: time
381 REAL :: muRgamma,Qfactor
384 IF (this%dt_bdec.GE.0.0)
THEN 385 IF (time .LT. this%t_start)
THEN 386 this%b_cool = this%b_start
387 ELSE IF ((time .GE. this%t_start) .AND. ((time-this%t_start) .LT. &
389 this%b_cool = this%b_start + &
390 (this%b_final-this%b_start)/this%dt_bdec*(time - this%t_start)
391 ELSE IF ((time-this%t_start) .GE. this%dt_bdec)
THEN 392 this%b_cool = this%b_final
397 SELECT CASE(this%cooling%GetType())
400 murgamma = physics%mu/(physics%Constants%RG*physics%gamma)
401 qfactor = 8./3.*physics%Constants%SB
403 this%Qcool%data1d(:) =
lambda_gray(pvar%data2d(:,physics%DENSITY),sources%height%data1d(:), &
404 murgamma*physics%bccsound%data1d(:)*physics%bccsound%data1d(:), &
405 this%rho_0,this%T_0,qfactor)
410 this%Qcool%data3d(:,:,:) =
lambda_gammie(pvar%data4d(:,:,:,physics%PRESSURE) / (physics%gamma-1.), &
411 abs((this%ephir%data4d(:,:,:,1)*pvar%data4d(:,:,:,physics%XVELOCITY) &
412 +this%ephir%data4d(:,:,:,2)*(pvar%data4d(:,:,:,physics%YVELOCITY)&
413 +mesh%OMEGA*mesh%radius%bcenter(:,:,:)))) / this%b_cool)
416 this%Qcool%data1d(:) =
lambda_gammie(pvar%pressure%data1d(:) / (physics%gamma-1.), &
417 mesh%OMEGA/this%b_cool)
425 REAL,
INTENT(IN) :: logrho,logt
433 kappa4(:) = exp(max(-40.0,min(40.0, &
436 tfactor = exp(max(-40.0,min(40.0,10.*(logt-log(
t0)))))
438 kappa_r = 1. /(tiny(kappa_r) + &
439 (1./kappa4(1) + 1./(1.+tfactor)/(kappa4(2)+kappa4(3)))**0.25 &
440 + (1./(kappa4(4)+kappa4(5)+kappa4(6)) + 1./(kappa4(7)+kappa4(8)))**0.25)
459 ELEMENTAL FUNCTION lambda_gray(Sigma,h,Tc,rho0,T0,Qf)
RESULT(Qcool)
462 REAL,
INTENT(IN) :: sigma,h,tc,rho0,
t0,qf
464 REAL :: logrho,logt,kappa,tau,tau_eff,t0tc
468 logrho = -log(max(rho0,
sqrt_twopi * h / sigma))
470 logt = log(max(
t0,tc))
475 tau = 0.5*kappa*sigma
477 tau_eff = 0.5*tau + 1./(3.*tau) + 1./
sqrt_three 481 qcool = qf/tau_eff * exp(4.0*logt) * (1.0-t0tc*t0tc*t0tc*t0tc)
491 ELEMENTAL FUNCTION lambda_gammie(Eint,t_cool_inv)
RESULT(Qcool)
494 REAL,
INTENT(IN) :: eint,t_cool_inv
497 qcool = eint * t_cool_inv
503 CLASS(sources_diskcooling),
INTENT(INOUT) :: this
505 SELECT CASE(this%cooling%GetType())
507 CALL this%Qcool%Destroy()
509 CALL this%Qcool%Destroy()
510 CALL this%ephir%Destroy()
512 CALL this%Qcool%Destroy()
subroutine finalize(this)
Destructor of common class.
real, dimension(8), parameter rexp
integer, parameter, public gray
generic source terms module providing functionaly common to all source terms
subroutine infosources(this, Mesh)
derived class for compound of mesh arrays
base class for mesh arrays
defines properties of a 3D cylindrical mesh
integer, parameter, public gammie_sb
subroutine initsources_diskcooling(this, Mesh, Physics, Fluxes, config, IO)
Constructor of disk cooling module.
subroutine setoutput(this, Mesh, config, IO)
defines properties of a 3D cartesian mesh
real, parameter sqrt_three
Dictionary for generic data types.
integer, parameter, public gammie
physics module for 1D,2D and 3D non-isothermal Euler equations
elemental real function lambda_gammie(Eint, t_cool_inv)
Gammie cooling.
subroutine updatecooling(this, Mesh, Physics, Sources, time, pvar)
Updates the cooling function at each time step.
real, dimension(8), parameter texp
real, dimension(8), parameter logkappa0
base module for numerical flux functions
subroutine externalsources_single(this, Mesh, Physics, Fluxes, Sources, time, dt, pvar, cvar, sterm)
subroutine calctimestep_single(this, Mesh, Physics, Fluxes, pvar, cvar, time, dt)
source terms module for cooling of geometrically thin accretion disks
elemental real function rosselandmeanopacity_new(logrho, logT)
real, parameter sqrt_twopi
elemental real function lambda_gray(Sigma, h, Tc, rho0, T0, Qf)
Gray cooling.