44 REAL,
PARAMETER :: gn = 6.6742d-11
45 REAL,
PARAMETER :: cc = 2.99792458d+8
46 REAL,
PARAMETER :: msun = 1.989d+30
47 REAL,
PARAMETER :: au = 1.49597870691e+11
48 REAL,
PARAMETER :: year = 3.15576e+7
49 REAL,
PARAMETER :: parsec = 0.5/pi*1.296e+6 * au
51 REAL,
PARAMETER :: tsim = 1.0e+4 * year
52 REAL,
PARAMETER :: m_bh = 0.5e+0 * msun
53 REAL,
PARAMETER :: m_disk = 1.0e-1 * m_bh
54 REAL,
PARAMETER :: rs = 2 * gn * m_bh / cc**2
55 REAL,
PARAMETER :: lscale = au
56 REAL,
PARAMETER :: etasgs = 1.0e-6
57 REAL,
PARAMETER :: gamma = 1.4
59 REAL,
PARAMETER :: rmin = 2.0d+0 * lscale
60 REAL,
PARAMETER :: rmax = 3.0d+2 * lscale
61 REAL,
PARAMETER :: zmin = -1.3d+2 * lscale
62 REAL,
PARAMETER :: zmax = 1.3d+2 * lscale
63 REAL,
PARAMETER :: ztan = 1.0e+2 * lscale
69 REAL,
PARAMETER :: z0 = 3.0e+02 * lscale
70 REAL,
PARAMETER :: a0 = 1.0e-01
71 REAL,
PARAMETER :: s0 = 1.5e+02 * lscale
72 REAL,
PARAMETER :: b0 = -1.0
73 REAL,
PARAMETER :: rho_inf = 1.0e-15
74 REAL,
PARAMETER :: p_inf = 1.4e-10
75 INTEGER,
PARAMETER :: problem = euler
77 INTEGER,
PARAMETER :: rres = 100
78 INTEGER,
PARAMETER :: phires = 1
79 INTEGER,
PARAMETER :: zres = 128
81 INTEGER,
PARAMETER :: onum = 1000
82 CHARACTER(LEN=256),
PARAMETER :: odir &
84 CHARACTER(LEN=256),
PARAMETER &
87 CLASS(
fosite),
ALLOCATABLE :: sim
99 CALL initdata(sim%Mesh, sim%Physics, sim%Fluxes, sim%Timedisc, sim%Sources)
110 TYPE(dict_typ),
POINTER :: config
113 TYPE(dict_typ),
POINTER :: mesh, physics, boundary, datafile, logfile, sources, &
114 timedisc,fluxes,stemp
119 "meshtype" / midpoint, &
120 "geometry" / cylindrical, &
133 "problem" / problem, &
142 "variables" / primitive, &
143 "limiter" / minmod, &
154 "western" / custom, &
155 "eastern" / farfield, &
159 "southern" / periodic, &
164 "northern" / periodic, &
166 "bottomer" / farfield, &
171 stemp => dict(
"stype" / gravity, &
172 "pmass/gtype" / pointmass, &
176 CALL setattr(sources,
"grav", stemp)
198 "method" / modified_euler, &
202 "dtlimit" / 1.0e-3, &
203 "maxiter" / 1000000000, &
204 "output/external_sources" / 1, &
205 "output/geometrical_sources" / 1, &
216 datafile => dict(
"fileformat" / vtk, &
218 "filename" / (trim(odir) // trim(ofname)), &
221 "filecycles" / (onum+1))
223 config => dict(
"mesh" / mesh, &
224 "physics" / physics, &
225 "boundary" / boundary, &
227 "sources" / sources, &
228 "timedisc" / timedisc, &
230 "datafile" / datafile)
234 SUBROUTINE initdata(Mesh,Physics,Fluxes,Timedisc,Sources)
239 CLASS(mesh_base) ,
INTENT(IN) :: Mesh
240 CLASS(physics_base) ,
INTENT(INOUT) :: Physics
241 CLASS(fluxes_base) ,
INTENT(INOUT) :: Fluxes
242 CLASS(timedisc_base),
INTENT(INOUT):: Timedisc
243 CLASS(sources_list),
ALLOCATABLE,
INTENT(INOUT) :: Sources
248 REAL,
DIMENSION(Mesh%IGMIN:Mesh%IGMAX,Mesh%JGMIN:Mesh%JGMAX,Mesh%KGMIN:Mesh%KGMAX,2) :: dv
249 REAL :: s,z,tau,lambda,tau1,tau2,dPs,dPz,s1,s2,z1,z2,P0,rho0,cs_inf
253 REAL :: mdisk_local,am_local
256 CHARACTER(LEN=20) :: mdisk_str,am_str
259 IF (
ALLOCATED(sources)) &
260 sp => sources%GetSourcesPointer(gravity)
261 IF (.NOT.
ASSOCIATED(sp)) &
262 CALL physics%Error(
"ttauridisk::InitData",
"no gravity term initialized")
270 cs_inf = sqrt(gamma*p_inf/rho_inf)
272 DO k=mesh%KGMIN,mesh%KGMAX
273 DO j=mesh%JGMIN,mesh%JGMAX
274 DO i=mesh%IGMIN,mesh%IGMAX
275 s = abs(mesh%bccart(i,j,k,1))
276 z = mesh%bccart(i,j,k,3)
277if (s .eq. 0.0 .or. z .eq. 0.0) print *,s,z,i,j
281 timedisc%pvar%data4d(i,j,k,physics%XVELOCITY) = 0.0
282 timedisc%pvar%data4d(i,j,k,physics%ZVELOCITY) = 0.0
283 timedisc%pvar%data4d(i,j,k,physics%PRESSURE) =
pc(tau,rho0,cs_inf)
284 z1 = mesh%cart%faces(i,j,k,5,3)
285 z2 = mesh%cart%faces(i,j,k,6,3)
288 dpz = (
pc(tau2,rho0,cs_inf)-
pc(tau1,rho0,cs_inf))/mesh%dlz%data3d(i,j,k)
289 IF (abs(z).GT.0.0)
THEN
291 timedisc%pvar%data4d(i,j,k,physics%DENSITY) = dpz /
gz(s,z)
293 timedisc%pvar%data4d(i,j,k,physics%DENSITY) = rho0 * (s/s0)**b0
295 s1 = abs(mesh%cart%faces(i,j,k,1,1))
296 s2 = abs(mesh%cart%faces(i,j,k,2,1))
299 dps = (
pc(tau2,rho0,cs_inf)-
pc(tau1,rho0,cs_inf))/mesh%dlx%data3d(i,j,k)
302 timedisc%pvar%data4d(i,j,k,physics%YVELOCITY) = sqrt(max(0.0,-s*
gs(s,z) / lambda))
307 mdisk = sum(timedisc%pvar%data4d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,physics%DENSITY) &
308 * mesh%volume%data3d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
310 am = sum(mesh%hy%bcenter(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX) &
311 * timedisc%pvar%data4d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,physics%YVELOCITY) &
312 * timedisc%pvar%data4d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX,physics%DENSITY) &
313 * mesh%volume%data3d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
317 CALL mpi_allreduce(mdisk_local,mdisk,1,default_mpi_real,mpi_sum, &
318 mesh%comm_cart,ierror)
320 CALL mpi_allreduce(am_local,am,1,default_mpi_real,mpi_sum, &
321 mesh%comm_cart,ierror)
326 rho0 = m_disk / mdisk * rho0
342 SELECT TYPE (bbottom => timedisc%Boundary%Boundary(bottom)%p)
343 CLASS IS (boundary_farfield)
345 DO j=mesh%JMIN,mesh%JMAX
346 DO i=mesh%IMIN,mesh%IMAX
347 bbottom%data(i,j,k,:) = timedisc%pvar%data4d(i,j,mesh%KMIN-k,:)
353 SELECT TYPE (btop => timedisc%Boundary%Boundary(top)%p)
354 CLASS IS (boundary_farfield)
356 DO j=mesh%JMIN,mesh%JMAX
357 DO i=mesh%IMIN,mesh%IMAX
358 btop%data(i,j,k,:) = timedisc%pvar%data4d(i,j,mesh%KMAX+k,:)
364 SELECT TYPE (beast => timedisc%Boundary%Boundary(east)%p)
365 CLASS IS (boundary_farfield)
366 DO k=mesh%KMIN,mesh%KMAX
367 DO j=mesh%JMIN,mesh%JMAX
369 beast%data(i,j,k,:) = timedisc%pvar%data4d(mesh%IMAX+i,j,k,:)
376 SELECT TYPE (bwest => timedisc%Boundary%Boundary(west)%p)
377 CLASS IS(boundary_custom)
378 CALL bwest%SetCustomBoundaries(mesh,physics, &
379 (/custom_nograd,custom_outflow,custom_kepler,custom_nograd,custom_nograd/))
382 CALL physics%Convert2Conservative(timedisc%pvar,timedisc%cvar)
383 CALL timedisc%Boundary%CenterBoundary(mesh,physics,0.0,timedisc%pvar, &
387 WRITE (mdisk_str,
'(ES10.2)') mdisk/msun
388 WRITE (am_str,
'(ES10.2)') am
389 CALL mesh%Info(
" DATA-----> initial condition: non Keplerian flow")
390 CALL mesh%Info(
" disk mass: " // trim(mdisk_str) //
" M_sun")
391 CALL mesh%Info(
" angular momentum: " // trim(am_str) //
" kg/m^2/s")
397 REAL,
INTENT(IN) :: sc,zc
399 res = sqrt(gn*m_bh/sc) * (1.0d0+(zc/sc)**2)**(-0.75)
402 ELEMENTAL FUNCTION gs(sc,zc)
RESULT(res)
404 REAL,
INTENT(IN) :: sc,zc
406 res = -(gn*m_bh/sc**2) / sqrt(1.0d0+(zc/sc)**2)**3
409 ELEMENTAL FUNCTION gz(sc,zc)
RESULT(res)
411 REAL,
INTENT(IN) :: sc,zc
413 res = -(gn*m_bh/sc**2) * (zc/sc) / sqrt(1.0d0+(zc/sc)**2)**3
418 REAL,
INTENT(IN) :: zc
420 res = 1.0d0 + a0/(1.0d0+(zc/z0)**2)
425 REAL,
INTENT(IN) :: sc,zc
427 res = sc*sqrt(1.0d0 + (zc/sc)**2*(1.0d0 + (1.0d0+0.5d0*(zc/z0)**2)/a0))
430 ELEMENTAL FUNCTION pc(tau,rho_s0,cs_inf)
RESULT(res)
432 REAL,
INTENT(IN) :: tau,rho_s0,cs_inf
435 res = p_inf * (1.0 + a0/(1.0+a0) * 1.0/(1.0-b0) * 0.5 * gamma * &
436 (cc/cs_inf)**2 * rho_s0/rho_inf * (rs/s0) * (tau/s0)**(b0-1.0))
elemental real function func_tau(sc, zc)
elemental real function pc(tau, rho_s0, cs_inf, gamma)
elemental real function gz(sc, zc)
elemental real function func_lambda(zc)
elemental real function vkepler(sc, zc)
elemental real function gs(sc, zc)
subroutine initdata(Mesh, Physics, Fluxes, Timedisc)
subroutine makeconfig(Sim, config)
generic source terms module providing functionaly common to all source terms
generic gravity terms module providing functionaly common to all gravity terms
program ttauri
Program and data initialization for 3D rotating flow.