57 REAL,
PARAMETER :: GN = 6.6742d-8
58 REAL,
PARAMETER :: RG = 8.31447d+7
59 REAL,
PARAMETER :: MSUN = 1.989d+33
60 REAL,
PARAMETER :: AU = 1.49597870691e+13
61 REAL,
PARAMETER :: YEAR = 3.15576e+7
62 REAL,
PARAMETER :: MSCALE = msun
64 REAL,
PARAMETER :: TSIM = 6.0
65 REAL,
PARAMETER :: MU = 2.35d+0
66 REAL,
PARAMETER :: VALPHA = 0.05
68 REAL,
PARAMETER :: MBH = 1.0*mscale
69 REAL,
PARAMETER :: MDISK = 0.1*mscale
70 REAL,
PARAMETER :: T_INIT = 120.0
71 REAL,
PARAMETER :: T_MIN = 10.0
73 REAL,
PARAMETER :: BETA_C = 10.0
74 REAL,
PARAMETER :: GAMMA = 1.6
76 INTEGER,
PARAMETER :: MGEO = logcylindrical
77 REAL,
PARAMETER :: GPAR = au
78 REAL,
PARAMETER :: RMIN = 1.0*gpar
79 REAL,
PARAMETER :: RMAX = 25.0*gpar
80 INTEGER,
PARAMETER :: XRES = 256
81 INTEGER,
PARAMETER :: YRES = xres*3
82 INTEGER,
PARAMETER :: ZRES = 1
85 REAL,
PARAMETER :: NOISE = 0.3
87 INTEGER,
PARAMETER :: ONUM = 100
88 CHARACTER(LEN=256),
PARAMETER &
90 CHARACTER(LEN=256) :: OFNAME =
'sgdisk' 92 CLASS(fosite),
ALLOCATABLE :: Sim
93 REAL :: CSISO,OMEGA,ORP
99 CALL asl_library_initialize()
102 CALL sim%InitFosite()
105 CALL initdata(sim%Mesh, sim%Physics, sim%Timedisc, sim%Fluxes, sim%Sources, &
106 sim%Timedisc%pvar, sim%Timedisc%cvar)
111 CALL asl_library_finalize()
121 CLASS(fosite),
INTENT(INOUT) :: Sim
122 TYPE(Dict_TYP),
POINTER :: config
123 TYPE(Dict_TYP),
POINTER :: mesh, physics, fluxes, boundary, grav,&
124 sources, timedisc, datafile, cooling, &
125 rotframe, pmass, self, damping
128 csiso = sqrt(rg/mu*t_init)
130 orp = 2.*pi/(sqrt(gn*mbh/rmax**3.))
136 "meshtype" / midpoint, &
141 "xmin" / log(rmin/gpar), &
142 "xmax" / log(rmax/gpar), &
149 "decomposition" / (/ -1, 1, 1/), &
152 "output/position_vector" / 1, &
168 "southern" / periodic, &
169 "northern" / periodic, &
170 "bottomer" / reflecting, &
171 "topper" / reflecting)
178 "variables" / primitive, &
179 "passive_limiting" / .false., &
180 "limiter" / vanleer, &
186 "stype" / rotating_frame)
191 "gtype" / pointmass, &
193 "output/position" / 1)
197 "stype" / disk_cooling, &
198 "output/Qcool" / 1, &
199 "rhomin" / 1.0e-30, &
205 "gtype" / spectral, &
206 "output/potential" / 1, &
214 "output/potential" / 1, &
216 "output/height" / 1, &
221 "cooling" / cooling, &
226 CALL setattr(sources,
"damping",damping)
230 "method" / modified_euler, &
232 "dtlimit" / 1.0e-50, &
233 "tol_rel" / 1.0e-3, &
235 "tol_abs" / (/ 1.0e-16, 1.0, 1.0e-16, 1.0 /), &
236 "output/energy" / 1, &
238 "stoptime" / (orp*tsim), &
241 "checkdata" / ior(check_nothing,check_tmin), &
242 "maxiter" / 100000000)
246 "fileformat" / xdmf, &
247 "filename" / (trim(odir) // trim(ofname)), &
251 "physics" / physics, &
254 "boundary" / boundary, &
255 "sources" / sources, &
256 "timedisc" / timedisc, &
257 "datafile" / datafile)
262 SUBROUTINE initdata(Mesh,Physics,Timedisc,Fluxes,Sources,pvar,cvar)
266 CLASS(mesh_base),
INTENT(IN) :: Mesh
267 CLASS(physics_base),
INTENT(INOUT) :: Physics
268 CLASS(timedisc_base),
INTENT(INOUT) :: Timedisc
269 CLASS(fluxes_base),
INTENT(INOUT) :: Fluxes
270 CLASS(sources_base),
POINTER :: Sources
271 CLASS(marray_compound),
INTENT(INOUT):: pvar,cvar
274 CLASS(sources_base),
POINTER :: sp
275 CLASS(sources_gravity),
POINTER :: gp
281 REAL,
DIMENSION(:,:,:),
POINTER :: r, Sigma
282 REAL,
DIMENSION(:,:,:,:),
POINTER :: r_vec
283 CHARACTER(LEN=32) :: mdisk_str
284 REAL,
DIMENSION(Mesh%IGMIN:Mesh%IGMAX,Mesh%JGMIN:Mesh%JGMAX,Mesh%KGMIN:Mesh%KGMAX) &
292 r => mesh%RemapBounds(mesh%radius%bcenter(:,:,:))
293 r_vec => mesh%RemapBounds(mesh%posvec%bcenter(:,:,:,:))
295 sigma => mesh%RemapBounds(pvar%data4d(:,:,:,physics%DENSITY))
300 CALL random_number(rands)
302 CALL asl_random_create(rng, asl_randommethod_mt19937_64)
303 CALL asl_random_distribute_uniform(rng)
304 n = (mesh%IGMAX-mesh%IGMIN+1)*(mesh%JGMAX-mesh%JGMIN+1)*(mesh%KGMAX-mesh%KGMIN+1)
305 CALL asl_random_generate_d(rng, n, rands)
307 rands = rands * noise * 2.0 + (1.0 - noise)
308 sigma = rands*(rmin/r(:,:,:))
311 CALL asl_random_destroy(rng)
315 mass = sum(mesh%volume%data3d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX) * &
316 sigma(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
318 CALL mpi_allreduce(mpi_in_place,mass,1,default_mpi_real,mpi_sum, &
319 mesh%comm_cart,ierror)
322 sigma(:,:,:) = sigma(:,:,:) * mdisk / mass
325 SELECT TYPE(phys => physics)
327 pvar%data4d(:,:,:,physics%PRESSURE) = &
328 csiso*csiso*pvar%data4d(:,:,:,physics%DENSITY)/gamma
330 SELECT TYPE(pvarious => pvar)
332 CALL phys%UpdateSoundSpeed(pvarious)
338 IF (
ASSOCIATED(sp).EQV..false.)
RETURN 340 CLASS IS(sources_gravity)
347 CALL gp%UpdateGravity(mesh,physics,fluxes,pvar,0.0,0.0)
350 pvar%data2d(:,physics%XVELOCITY:physics%YVELOCITY) = 0.0
355 pvar%data4d(:,:,:,physics%XVELOCITY:physics%XVELOCITY+physics%VDIM-1) = &
356 timedisc%GetCentrifugalVelocity(mesh,physics,fluxes,sources,(/0.,0.,1./),gp%accel%data4d)
358 IF (mesh%FARGO.EQ.2) &
359 timedisc%w(:,:) = sqrt(physics%constants%GN*mbh/r(:,mesh%JMIN,:))-mesh%OMEGA*r(:,mesh%JMIN,:)
362 pvar%data4d(:,:,:,physics%YVELOCITY) = pvar%data4d(:,:,:,physics%YVELOCITY) &
363 - mesh%OMEGA*r(:,:,:)
366 CALL physics%Convert2Conservative(pvar,cvar)
369 SELECT TYPE(bwest => timedisc%Boundary%boundary(west)%p)
370 CLASS IS (boundary_custom)
371 CALL bwest%SetCustomBoundaries(mesh,physics, &
372 (/custom_nograd,custom_outflow,custom_kepler,custom_nograd/))
376 SELECT TYPE(beast => timedisc%Boundary%boundary(east)%p)
377 CLASS IS (boundary_custom)
378 CALL beast%SetCustomBoundaries(mesh,physics, &
379 (/custom_nograd,custom_outflow,custom_kepler,custom_nograd/))
382 CALL physics%Convert2Conservative(pvar,cvar)
384 WRITE (mdisk_str,
'(ES8.2)') mdisk
385 CALL mesh%Info(
" DATA-----> initial condition: Mestel's disk")
386 CALL mesh%Info(
" disk mass: " // trim(mdisk_str))
394 CLASS(timedisc_base),
INTENT(IN) :: Timedisc
395 INTEGER :: i, n, clock
396 INTEGER,
DIMENSION(:),
ALLOCATABLE :: seed
400 CALL random_seed(
size = n)
402 CALL system_clock(count=clock)
403 seed = clock + 37 * (/ (i - 1, i = 1, n) /)
405 seed = seed + timedisc%GetRank()
407 CALL random_seed(put = seed)