81 REAL,
POINTER :: accrate
82 REAL,
POINTER :: massloss
86 REAL,
DIMENSION(:,:),
POINTER :: pos
87 REAL,
DIMENSION(:),
POINTER :: r0
88 REAL,
DIMENSION(:,:,:),
POINTER :: r_prim
89 REAL,
DIMENSION(:,:,:,:),
POINTER :: fr_prim
90 REAL,
DIMENSION(:,:,:,:),
POINTER :: posvec_prim
91 REAL,
DIMENSION(:,:,:,:),
POINTER :: posvec_prim_tmp
92 REAL,
DIMENSION(:,:,:,:,:),
POINTER :: fposvec_prim
93 REAL,
DIMENSION(:,:,:,:),
POINTER :: pot_prim
94 REAL,
DIMENSION(:,:,:),
POINTER ::
omega 95 REAL,
DIMENSION(:,:,:,:),
POINTER :: omega2
138 CLASS(gravity_pointmass),
INTENT(INOUT) :: this
139 CLASS(mesh_base),
INTENT(IN) :: Mesh
140 CLASS(physics_base),
INTENT(IN) :: Physics
141 TYPE(Dict_TYP),
POINTER :: config,IO
143 INTEGER :: potential_number, valwrite, gtype
144 INTEGER :: err,i,j,k,l
145 REAL :: r_schwarzschild=0.0,eps
147 CALL this%InitGravity(mesh,physics,
"central point mass",config,io)
149 ALLOCATE(this%potential, &
150 this%pot(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX,4), &
151 this%omega(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX), &
152 this%omega2(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX,1), &
153 this%r_prim(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX),&
154 this%fr_prim(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX,3), &
155 this%posvec_prim(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX,3),&
156 this%posvec_prim_tmp(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX,3),&
157 this%fposvec_prim(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX,3,3),&
158 this%mass, this%accrate, this%massloss, this%pos(1,3), &
160 IF (err.NE.0)
CALL this%Error(
"InitGravity_pointmass",
"Unable allocate memory!")
163 CALL getattr(config,
"potential", potential_number,
newton)
164 CALL this%potential%InitLogging(potential_number,
potential_name(potential_number))
167 CALL getattr(config,
"mass", this%mass, 1.0)
168 CALL setattr(io,
"mass", ref(this%mass))
171 CALL getattr(config,
"x", this%pos(1,1), 0.0)
172 CALL getattr(config,
"y", this%pos(1,2), 0.0)
173 CALL getattr(config,
"z", this%pos(1,3), 0.0)
176 CALL getattr(config,
"softening", eps, 0.0)
179 CALL getattr(config,
"switchon", this%switchon, -1.0)
184 CALL getattr(config,
"acclimit", this%acclimit, -1.0)
186 CALL setattr(io,
"accrate", ref(this%accrate))
187 IF (this%acclimit.GT.0.0) &
188 CALL setattr(io,
"massloss", ref(this%massloss))
190 SELECT CASE(potential_number)
192 r_schwarzschild = 0.0
195 r_schwarzschild = 2.*physics%constants%GN * this%mass / physics%constants%C**2
197 CALL this%Error(
"InitGravity_pointmass",
"potential must be either NEWTON or WIITA")
201 CALL getattr(config,
"output/position", valwrite, 0)
202 IF (valwrite .EQ. 1) &
203 CALL setattr(io,
"position", this%pos)
213 IF (abs(this%pos(1,1)).LE.tiny(this%pos(1,1)).AND.abs(this%pos(1,2)).LE.tiny(this%pos(1,2)))
THEN 216 this%posvec_prim(:,:,:,:) = mesh%posvec%bcenter(:,:,:,:)
217 this%r_prim(:,:,:) = mesh%radius%bcenter(:,:,:)
218 this%fr_prim(:,:,:,1) = mesh%radius%faces(:,:,:,east)
219 this%fr_prim(:,:,:,2) = mesh%radius%faces(:,:,:,north)
220 this%fr_prim(:,:,:,3) = mesh%radius%faces(:,:,:,top)
227 this%posvec_prim_tmp(:,:,:,1) = this%pos(1,1)
228 this%posvec_prim_tmp(:,:,:,2) = this%pos(1,2)
229 this%posvec_prim_tmp(:,:,:,3) = this%pos(1,3)
231 CALL mesh%Geometry%Convert2Curvilinear(mesh%curv%faces(:,:,:,east,:),this%posvec_prim_tmp(:,:,:,:),this%fposvec_prim(:,:,:,1,:))
232 CALL mesh%Geometry%Convert2Curvilinear(mesh%curv%faces(:,:,:,north,:),this%posvec_prim_tmp(:,:,:,:),this%fposvec_prim(:,:,:,2,:))
233 CALL mesh%Geometry%Convert2Curvilinear(mesh%curv%faces(:,:,:,top,:),this%posvec_prim_tmp(:,:,:,:),this%fposvec_prim(:,:,:,3,:))
235 CALL mesh%Geometry%Convert2Curvilinear(mesh%bcenter,this%posvec_prim_tmp,this%posvec_prim)
240 this%posvec_prim(:,:,:,:) = mesh%posvec%bcenter(:,:,:,:) - this%posvec_prim(:,:,:,:)
241 this%fposvec_prim(:,:,:,1,:) = mesh%posvec%faces(:,:,:,east,:) - this%fposvec_prim(:,:,:,1,:)
242 this%fposvec_prim(:,:,:,2,:) = mesh%posvec%faces(:,:,:,north,:) - this%fposvec_prim(:,:,:,2,:)
243 this%fposvec_prim(:,:,:,3,:) = mesh%posvec%faces(:,:,:,top,:) - this%fposvec_prim(:,:,:,3,:)
245 this%r_prim(:,:,:) = sqrt(this%posvec_prim(:,:,:,1)**2+this%posvec_prim(:,:,:,2)**2+this%posvec_prim(:,:,:,3)**2)
246 this%fr_prim(:,:,:,1) = sqrt(this%fposvec_prim(:,:,:,1,1)**2+this%fposvec_prim(:,:,:,1,2)**2+this%fposvec_prim(:,:,:,1,3)**2)
247 this%fr_prim(:,:,:,2) = sqrt(this%fposvec_prim(:,:,:,2,1)**2+this%fposvec_prim(:,:,:,2,2)**2+this%fposvec_prim(:,:,:,2,3)**2)
248 this%fr_prim(:,:,:,3) = sqrt(this%fposvec_prim(:,:,:,3,1)**2+this%fposvec_prim(:,:,:,3,2)**2+this%fposvec_prim(:,:,:,3,3)**2)
256 DO k=mesh%KGMIN,mesh%KGMAX
257 DO j=mesh%JGMIN,mesh%JGMAX
259 DO i=mesh%IGMIN,mesh%IGMAX
264 this%omega2(i,j,k,1) = 1./ max(10*tiny(eps), &
265 (( this%r_prim(i,j,k) * (this%r_prim(i,j,k)-r_schwarzschild)**2) + eps**3) / (physics%Constants%GN*this%mass) )
266 this%omega(i,j,k) = sqrt(this%omega2(i,j,k,1))
270 this%accel%data4d(i,j,k,l) = -this%omega2(i,j,k,1) * this%posvec_prim(i,j,k,l)
277 CALL this%CalcPotential(mesh,physics,this%mass,this%r_prim,this%fr_prim,this%pot)
280 CALL this%SetOutput(mesh,physics,config,io)
284 SELECT TYPE(geo=>mesh%geometry)
286 CALL getattr(config,
"outbound", this%outbound, west)
288 CALL getattr(config,
"outbound", this%outbound, west)
290 CALL getattr(config,
"outbound", this%outbound, 0)
291 CALL this%WARNING(
"GravitySources_pointmass",
"geometry does not support accretion")
293 CALL this%InfoGravity()
296 SUBROUTINE calcpotential(this,Mesh,Physics,mass,dist,dist_faces,pot)
299 CLASS(gravity_pointmass) :: this
300 CLASS(mesh_base),
INTENT(IN) :: Mesh
301 CLASS(physics_base),
INTENT(IN) :: Physics
303 REAL,
DIMENSION(Mesh%IGMIN:Mesh%IGMAX,Mesh%JGMIN:Mesh%JGMAX,Mesh%KGMIN:Mesh%KGMAX), &
305 REAL,
DIMENSION(Mesh%IGMIN:Mesh%IGMAX,Mesh%JGMIN:Mesh%JGMAX,Mesh%KGMIN:Mesh%KGMAX,3), &
306 INTENT(IN) :: dist_faces
307 REAL,
DIMENSION(Mesh%IGMIN:Mesh%IGMAX,Mesh%JGMIN:Mesh%JGMAX,Mesh%KGMIN:Mesh%KGMAX,4), &
312 pot(:,:,:,1) = - physics%constants%GN * mass / dist(:,:,:)
313 pot(:,:,:,2) = - physics%constants%GN * mass / dist_faces(:,:,:,1)
314 pot(:,:,:,3) = - physics%constants%GN * mass / dist_faces(:,:,:,2)
315 pot(:,:,:,4) = - physics%constants%GN * mass / dist_faces(:,:,:,3)
321 CLASS(gravity_pointmass),
INTENT(IN) :: this
323 CHARACTER(LEN=32) :: param_str
325 WRITE (param_str,
'(ES8.2)') this%mass
326 CALL this%Info(
" potential: " // &
327 trim(this%potential%GetName()))
328 CALL this%Info(
" initial mass: " // trim(param_str))
329 IF (this%outbound.GT.0)
THEN 330 param_str =
"enabled" 332 param_str =
"disabled" 334 CALL this%Info(
" accretion: " // trim(param_str))
335 IF (this%outbound.GT.0.AND.this%acclimit.GT.0.0)
THEN 336 WRITE (param_str,
'(ES8.2)') this%acclimit
337 CALL this%Info(
" accretion limit: " // trim(param_str))
339 IF (this%switchon.GT.0.0)
THEN 340 WRITE (param_str,
'(ES8.2)') this%switchon
341 CALL this%Info(
" switchon time: " // trim(param_str))
354 CLASS(gravity_pointmass),
INTENT(INOUT) :: this
355 CLASS(mesh_base),
INTENT(IN) :: Mesh
356 CLASS(physics_base),
INTENT(IN) :: Physics
357 CLASS(fluxes_base),
INTENT(IN) :: Fluxes
358 CLASS(marray_compound),
INTENT(INOUT) :: pvar
359 REAL,
INTENT(IN) :: time,dt
362 REAL,
DIMENSION(Physics%VNUM) :: bflux
363 REAL :: scaling,oldmass,massfac,sqrmassfac,dmass,dmasslim
366 IF (this%outbound.NE.0)
THEN 369 bflux(:) = fluxes%GetBoundaryFlux(mesh,physics,this%outbound,mpi_comm_world)
371 bflux(:) = fluxes%GetBoundaryFlux(mesh,physics,this%outbound)
379 dmass = (bflux(physics%DENSITY) - this%mdot)
380 IF(this%acclimit.GE.0.)
THEN 381 dmasslim = min(dmass,this%acclimit*dt*this%mass)
382 this%massloss = this%massloss + dmass - dmasslim
386 this%mass = this%mass + dmass
387 IF (dt.GT.0.0) this%accrate = dmass/dt
390 massfac = this%mass/oldmass
391 sqrmassfac = sqrt(massfac)
392 this%accel%data4d(:,:,:,:) = this%accel%data4d(:,:,:,:) * massfac
393 this%pot(:,:,:,:) = this%pot(:,:,:,:) * massfac
394 this%omega(:,:,:) = this%omega(:,:,:) * sqrmassfac
395 this%mdot = bflux(physics%DENSITY)
399 IF (time.GE.0.0.AND.time.LE.this%switchon)
THEN 401 scaling = sin(0.5*pi*time/this%switchon)**2
406 this%accel%data4d(:,:,:,l) = -scaling * this%omega2(:,:,:,1) * this%posvec_prim(:,:,:,l)
423 TYPE(
marray_base),
INTENT(INOUT) :: bccsound,h_ext,height
432 CLASS(gravity_pointmass),
INTENT(INOUT) :: this
434 CHARACTER(LEN=128) :: buffer
436 IF (this%GetRank().EQ.0)
THEN 437 CALL this%Info(
"-------------------------------------------------------------------")
438 WRITE(buffer,
"(A,(ES11.3))")
" central mass: ", this%mass
439 CALL this%Info(buffer)
440 IF (this%acclimit.GT.0.0)
THEN 441 WRITE(buffer,
"(A,(ES11.3))")
" mass loss: ", this%massloss
442 CALL this%Info(buffer)
446 DEALLOCATE(this%pot,this%omega,this%omega2,this%r_prim,this%fr_prim, &
447 this%posvec_prim,this%posvec_prim_tmp,this%fposvec_prim,this%mass, &
448 this%accrate,this%massloss,this%pos)
450 DEALLOCATE(this%potential)
452 CALL this%Finalize_base()
467 REAL,
INTENT(IN) :: cs,
omega
subroutine finalize(this)
Destructor of common class.
character(len=16), dimension(2), parameter potential_name
subroutine infogravity(this)
integer, parameter, public newton
pure real function, dimension(size(ephir%data2d, dim=1)) omega(ephir, velocity)
type(logging_base), save this
derived class for compound of mesh arrays
base class for mesh arrays
pure subroutine calcdiskheight_single(this, Mesh, Physics, pvar, bccsound, h_ext, height)
computes pressure scale height of a geometrically thin Keplerian disk
subroutine updategravity_single(this, Mesh, Physics, Fluxes, pvar, time, dt)
updates the gravitational acceleration of the pointmass module
defines properties of a 3D logcylindrical mesh
defines properties of a 3D cylindrical mesh
defines properties of a 3D spherical mesh
source terms module for gravitational acceleration due to a point mass at the center of the coordinat...
generic gravity terms module providing functionaly common to all gravity terms
subroutine calcpotential(this, Mesh, Physics, mass, dist, dist_faces, pot)
named integer constants for flavour of state vectors
Dictionary for generic data types.
subroutine initgravity_pointmass(this, Mesh, Physics, config, IO)
constructor for point mass module
elemental real function, public getdiskheight(cs, omega)
return pressure scale height of a geometrically thin Keplerian disk
integer, parameter, public wiita
base module for numerical flux functions