73 CHARACTER(LEN=32),
PARAMETER ::
source_name =
"viscosity of Newtonian fluid"
77 INTEGER,
PARAMETER ::
beta = 3
81 "constant viscosity ", &
82 "turbulent Shakura-Sunyaev ", &
83 "turbulent Duschl ", &
84 "power law viscosity ", &
85 "alternative Shakura-Sunyaev "/)
89 CLASS(
marray_base),
ALLOCATABLE :: ephir, & !< azimuthal unit vector */ distance to axis
91 dynvis, & !< dynamic viscosity
92 kinvis, & !< kinematic viscosity
94 REAL :: dynconst,bulkconst,power
95 REAL,
DIMENSION(:,:,:),
POINTER :: & !< comp. of stress tensor
96 btxx,btyy,btzz,btxy,btxz,btyz,tmp,tmp2,tmp3
97 REAL,
DIMENSION(:,:),
POINTER :: &
98 sxx,syy,szz,sxy,sxz,syz
129 TYPE(
dict_typ),
POINTER :: config, IO
132 INTEGER :: err, viscosity_number ,k,l
134 CALL getattr(config,
"stype", stype)
137 SELECT TYPE(phys => physics)
139 IF (phys%VDIM.EQ.1) &
140 CALL this%Error(
"InitSources_viscosity",
"viscosity is currently not supported in 1D physics")
142 CALL this%Error(
"InitSources_viscosity", &
143 "viscosity is currently only supported in eulerisotherm/euler physics")
147 CALL getattr(config,
"vismodel", viscosity_number)
149 CALL this%viscosity%InitLogging(viscosity_number,
viscosity_name(viscosity_number))
152 CALL getattr(config,
"dynconst", this%dynconst, 0.1)
158 CALL getattr(config,
"bulkconst", this%bulkconst, -2./3.*this%dynconst)
162 CALL getattr(config,
"exponent", this%power, 0.0)
165 CALL getattr(config,
"cvis", this%cvis, 0.5)
167 ALLOCATE(this%dynvis,this%kinvis,this%bulkvis, &
168 this%btxx(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX), &
169 this%btyy(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX), &
170 this%btzz(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX), &
171 this%btxy(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX), &
172 this%btxz(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX), &
173 this%btyz(mesh%IGMIN:mesh%IGMAX,mesh%JGMIN:mesh%JGMAX,mesh%KGMIN:mesh%KGMAX), &
176 CALL this%Error(
"InitSources_viscosity",
"Memory allocation failed.")
182 this%dynvis%data1d(:) = this%dynconst
183 this%kinvis%data1d(:) = 0.0
184 this%bulkvis%data1d(:) = this%bulkconst
187 SELECT CASE(this%viscosity%GetType())
193 SELECT TYPE(phys => physics)
195 ALLOCATE(this%ephir,this%ephir_tmp,stat=err)
197 CALL this%Error(
"InitSources_viscosity",
"Memory allocation failed.")
202 this%ephir%data4d(:,:,:,1) = -mesh%cart%bcenter(:,:,:,2) / mesh%radius%bcenter(:,:,:)**2
203 this%ephir%data4d(:,:,:,2) = mesh%cart%bcenter(:,:,:,1) / mesh%radius%bcenter(:,:,:)**2
204 this%ephir%data4d(:,:,:,3) = 0.0
206 CALL mesh%geometry%Convert2Curvilinear(mesh%curv%bcenter,this%ephir%data4d,this%ephir_tmp%data4d)
208 IF (phys%VDIM.LT.3)
THEN
209 DEALLOCATE(this%ephir,stat=err)
211 ALLOCATE(this%ephir,stat=err)
215 CALL this%Error(
"InitSources_viscosity",
"Memory reallocation failed.")
220 IF (btest(mesh%VECTOR_COMPONENTS,k-1))
THEN
221 this%ephir%data2d(:,l) = this%ephir_tmp%data2d(:,k)
226 DEALLOCATE(this%ephir_tmp)
228 CALL this%Error(
"InitSources_viscosity",&
229 "Physics not supported for alpha-/beta-viscosity")
233 CALL this%Error(
"InitSources_viscosity",&
234 "alternative alpha-viscosity currently not supported")
241 CALL this%Error(
"InitSources_viscosity",&
242 "Viscosity prescription not supported.")
248 this%btxx(:,:,:) = 0.0
249 this%btyy(:,:,:) = 0.0
250 this%btzz(:,:,:) = 0.0
251 this%btxy(:,:,:) = 0.0
252 this%btxz(:,:,:) = 0.0
253 this%btyz(:,:,:) = 0.0
255 CALL this%SetOutput(mesh,config,io)
257 CALL this%InfoSources()
271 CALL getattr(config,
"output/stress", valwrite, 0)
272 IF (valwrite .EQ. 1)
THEN
273 CALL setattr(io,
"stress:xx", this%btxx(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
274 CALL setattr(io,
"stress:xy", this%btxy(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
275 CALL setattr(io,
"stress:xz", this%btxz(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
276 CALL setattr(io,
"stress:yy", this%btyy(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
277 CALL setattr(io,
"stress:yz", this%btyz(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
278 CALL setattr(io,
"stress:zz", this%btzz(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
281 CALL getattr(config,
"output/dynvis", valwrite, 0)
282 IF (valwrite .EQ. 1) &
283 CALL setattr(io,
"dynvis", this%dynvis%data3d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
285 CALL getattr(config,
"output/kinvis", valwrite, 0)
286 IF (valwrite .EQ. 1) &
287 CALL setattr(io,
"kinvis", this%kinvis%data3d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
289 CALL getattr(config,
"output/bulkvis", valwrite, 0)
290 IF (valwrite .EQ. 1) &
291 CALL setattr(io,
"bulkvis", this%bulkvis%data3d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
301 CHARACTER(LEN=32) :: dynconst_str,bulkconst_str
303 WRITE (dynconst_str,
'(ES9.2)') this%dynconst
304 CALL this%Info(
" viscosity model: " // this%viscosity%GetName())
305 SELECT CASE(this%viscosity%GetType())
307 WRITE (bulkconst_str,
'(ES9.2)') this%bulkconst
308 CALL this%Info(
" dynamic viscosity: " // trim(dynconst_str))
309 CALL this%Info(
" bulk viscosity: " // trim(bulkconst_str))
311 CALL this%Info(
" alpha: " // trim(dynconst_str))
313 CALL this%Info(
" beta: " // trim(dynconst_str))
315 WRITE (bulkconst_str,
'(ES9.2)') this%power
316 CALL this%Info(
" coupling constant: " // trim(dynconst_str))
317 CALL this%Info(
" exponent: " // trim(bulkconst_str))
365 REAL,
INTENT(IN) :: time
371 IF ((time.NE.this%time) .OR. (time .EQ. 0.))
THEN
373 SELECT CASE(this%viscosity%GetType())
380 SELECT TYPE(p => pvar)
382 SELECT TYPE(phys => physics)
384 this%dynvis%data1d(:) =
etafkt_alpha(this%dynconst,p%density%data1d(:),&
385 phys%bccsound%data1d(:),
omega(this%ephir,p%velocity)+mesh%Omega)
391 SELECT TYPE(p => pvar)
393 this%dynvis%data1d(:) =
etafkt_beta(this%dynconst,mesh%radius%data2d(:,2), &
394 p%density%data1d(:),
omega(this%ephir,p%velocity)+mesh%Omega)
399 SELECT TYPE(p => pvar)
402 mesh%radius%data2d(:,2),p%density%data1d(:),
omega(this%ephir,p%velocity)+mesh%Omega)
414 SELECT CASE(this%viscosity%GetType())
421 this%bulkvis%data1d(:) = -2./3.*this%dynvis%data1d(:)
435 REAL,
DIMENSION(SIZE(ephir%data2d,DIM=1)) ::
omega
440 omega(:) = ephir%data2d(:,1) * velocity%data2d(:,1)
442 omega(:) =
omega(:) + ephir%data2d(:,l) * velocity%data2d(:,l)
472 REAL,
INTENT(IN) ::
beta,q,r,density,
omega
475 eta =
beta * density * (r**2 * abs(
omega))**q
491 REAL,
INTENT(IN) :: time, dt
494 CALL this%UpdateViscosity(mesh,physics,fluxes,time,pvar,cvar)
495 SELECT TYPE(phys => physics)
497 CALL phys%CalcStresses(mesh,pvar,this%dynvis,this%bulkvis, &
498 this%btxx,this%btxy,this%btxz,this%btyy,this%btyz,this%btzz)
499 CALL phys%ViscositySources(mesh,pvar,this%btxx,this%btxy,this%btxz, &
500 this%btyy,this%btyz,this%btzz,sterm)
511 SUBROUTINE calctimestep(this,Mesh,Physics,Fluxes,pvar,cvar,time,dt,dtcause)
521 REAL,
INTENT(IN) :: time
522 REAL,
INTENT(INOUT) :: dt
523 INTEGER,
INTENT(OUT) :: dtcause
528 CALL this%UpdateViscosity(mesh,physics,fluxes,time,pvar,cvar)
531 SELECT TYPE(p => pvar)
533 this%kinvis%data1d(:) = this%dynvis%data1d(:) / p%density%data1d(:)
537 IF ((mesh%JNUM.EQ.1).AND.(mesh%KNUM.EQ.1))
THEN
539 invdt = maxval((max(fluxes%maxwav%data2d(:,1),-fluxes%minwav%data2d(:,1)) &
540 + 2*this%kinvis%data1d(:) / mesh%dlx%data1d(:)) / mesh%dlx%data1d(:))
541 ELSE IF ((mesh%INUM.EQ.1).AND.(mesh%KNUM.EQ.1))
THEN
543 invdt = maxval((max(fluxes%maxwav%data2d(:,1),-fluxes%minwav%data2d(:,1)) &
544 + 2*this%kinvis%data1d(:) / mesh%dly%data1d(:)) / mesh%dly%data1d(:))
545 ELSE IF ((mesh%INUM.EQ.1).AND.(mesh%JNUM.EQ.1))
THEN
547 invdt = maxval((max(fluxes%maxwav%data2d(:,1),-fluxes%minwav%data2d(:,1)) &
548 + 2*this%kinvis%data1d(:) / mesh%dlz%data1d(:)) / mesh%dlz%data1d(:))
549 ELSE IF ((mesh%INUM.GT.1).AND.(mesh%JNUM.GT.1).AND.(mesh%KNUM.EQ.1))
THEN
551 invdt = maxval((max(fluxes%maxwav%data2d(:,1),-fluxes%minwav%data2d(:,1)) &
552 + 2*this%kinvis%data1d(:) / mesh%dlx%data1d(:)) / mesh%dlx%data1d(:) &
553 + (max(fluxes%maxwav%data2d(:,2),-fluxes%minwav%data2d(:,2)) &
554 + 2*this%kinvis%data1d(:) / mesh%dly%data1d(:)) / mesh%dly%data1d(:))
555 ELSE IF ((mesh%INUM.GT.1).AND.(mesh%KNUM.GT.1).AND.(mesh%JNUM.EQ.1))
THEN
557 invdt = maxval((max(fluxes%maxwav%data2d(:,1),-fluxes%minwav%data2d(:,1)) &
558 + 2*this%kinvis%data1d(:) / mesh%dlx%data1d(:)) / mesh%dlx%data1d(:) &
559 + (max(fluxes%maxwav%data2d(:,2),-fluxes%minwav%data2d(:,2)) &
560 + 2*this%kinvis%data1d(:) / mesh%dlz%data1d(:)) / mesh%dlz%data1d(:))
561 ELSE IF ((mesh%JNUM.GT.1).AND.(mesh%KNUM.GT.1).AND.(mesh%INUM.EQ.1))
THEN
563 invdt = maxval((max(fluxes%maxwav%data2d(:,1),-fluxes%minwav%data2d(:,1)) &
564 + 2*this%kinvis%data1d(:) / mesh%dly%data1d(:)) / mesh%dly%data1d(:) &
565 + (max(fluxes%maxwav%data2d(:,2),-fluxes%minwav%data2d(:,2)) &
566 + 2*this%kinvis%data1d(:) / mesh%dlz%data1d(:)) / mesh%dlz%data1d(:))
569 invdt = maxval((max(fluxes%maxwav%data2d(:,1),-fluxes%minwav%data2d(:,1)) &
570 + 2*this%kinvis%data1d(:) / mesh%dlx%data1d(:)) / mesh%dlx%data1d(:) &
571 + (max(fluxes%maxwav%data2d(:,2),-fluxes%minwav%data2d(:,2)) &
572 + 2*this%kinvis%data1d(:) / mesh%dly%data1d(:)) / mesh%dly%data1d(:) &
573 + (max(fluxes%maxwav%data2d(:,3),-fluxes%minwav%data2d(:,3)) &
574 + 2*this%kinvis%data1d(:) / mesh%dlz%data1d(:)) / mesh%dlz%data1d(:))
576 IF (invdt.GT.tiny(invdt))
THEN
577 dt = this%cvis / invdt
589 IF (
ALLOCATED(this%ephir))
DEALLOCATE(this%ephir)
590 DEALLOCATE(this%dynvis,this%kinvis,this%bulkvis, &
591 this%btxx,this%btyy,this%btzz,this%btxy,this%btxz,this%btyz)
Dictionary for generic data types.
base module for numerical flux functions
base class for geometrical properties
defines properties of a 3D cylindrical mesh
defines properties of a 3D logcylindrical mesh
subroutine finalize(this)
Destructor of logging_base class.
base class for mesh arrays
derived class for compound of mesh arrays
subroutine setoutput(this, config, IO)
Setup mesh fields for i/o.
physics module for 1D,2D and 3D non-isothermal Euler equations
physics module for 1D,2D and 3D isothermal Euler equations
generic source terms module providing functionaly common to all source terms
computes momentum and energy sources due to shear stresses
subroutine infosources(this)
integer, parameter, public alpha_alt
integer, parameter, public powerlaw
integer, parameter, public molecular
integer, parameter, public beta
character(len=32), parameter source_name
subroutine initsources(this, Mesh, Physics, Fluxes, config, IO)
subroutine calctimestep(this, Mesh, Physics, Fluxes, pvar, cvar, time, dt, dtcause)
compute time step limit for advection-diffusion problems
subroutine externalsources(this, Mesh, Physics, Fluxes, Sources, time, dt, pvar, cvar, sterm)
character(len=32), dimension(5), parameter, public viscosity_name
integer, parameter, public alpha
subroutine updateviscosity(this, Mesh, Physics, Fluxes, time, pvar, cvar)
updates dynamic and bulk viscosity
elemental real function etafkt_beta(beta, r, density, omega)
elemental real function etafkt_alpha(alpha, density, cs, omega)
pure real function, dimension(size(ephir%data2d, dim=1)) omega(ephir, velocity)
elemental real function etafkt_powerlaw(beta, q, r, density, omega)