sblintheo.f90
Go to the documentation of this file.
1!#############################################################################
2!# #
3!# fosite - 3D hydrodynamical simulation program #
4!# module: sblintheo.f90 #
5!# #
6!# Copyright (C) 2015-2018 #
7!# Jannes Klee <jklee@astrophysik.uni-kiel.de> #
8!# Tobias Illenseer <tillense@astrophysik.uni-kiel.de> #
9!# #
10!# This program is free software; you can redistribute it and/or modify #
11!# it under the terms of the GNU General Public License as published by #
12!# the Free Software Foundation; either version 2 of the License, or (at #
13!# your option) any later version. #
14!# #
15!# This program is distributed in the hope that it will be useful, but #
16!# WITHOUT ANY WARRANTY; without even the implied warranty of #
17!# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or #
18!# NON INFRINGEMENT. See the GNU General Public License for more #
19!# details. #
20!# #
21!# You should have received a copy of the GNU General Public License #
22!# along with this program; if not, write to the Free Software #
23!# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
24!# #
25!#############################################################################
26!----------------------------------------------------------------------------!
71!----------------------------------------------------------------------------!
72PROGRAM sblintheo
73 USE fosite_mod
74#include "tap.h"
75 IMPLICIT NONE
76 !--------------------------------------------------------------------------!
77 ! general constants
78 REAL, PARAMETER :: gn = 1.0 ! grav. constant [GEOM] !
79 ! make a shearingsheet simulation and denote the direction of shearing
80 ! (applies boundaries, ficitious forces and fargo automatically)
81 INTEGER, PARAMETER :: shearsheet_direction = 1
82 ! simulation parameter
83 REAL, PARAMETER :: omega = 1.0 ! rotation at fid. point !
84 REAL, PARAMETER :: sigma0 = 1.0 ! mean surf.dens. !
85 REAL, PARAMETER :: delsigma = sigma0*5.0e-4 ! disturbance !
86 REAL, PARAMETER :: tsim = 4.54845485/omega ! simulation time (first maximum) !
87 REAL, PARAMETER :: gamma = 2.0 ! dep. on vert. struct. !
88 REAL, PARAMETER :: q = 1.5 ! shearing parameter !
89 ! set (initial) speed of sound using the Toomre criterion and
90 ! assuming marginal stabily; in non-isothermal simulations this is
91 ! used to set the initial pressure (see InitData) whereas in isothermal
92 ! simulations this is constant throughout the simulation
93 REAL, PARAMETER :: soundspeed = pi*gn*sigma0/omega
94 ! mesh settings
95 INTEGER, PARAMETER :: mgeo = cartesian
96 INTEGER, PARAMETER :: xres = 128 ! amount of cells in x- !
97 INTEGER, PARAMETER :: yres = 128 ! y-direction (rho/phi) !
98 INTEGER, PARAMETER :: zres = 1
99 REAL, PARAMETER :: thickness = 0e-5 ! small value or zero for!
100 ! razor thin disks !
101 REAL :: domainx = 40.0 ! domain size [GEOM] !
102 REAL :: domainy = 40.0 ! domain size [GEOM] !
103 ! number of output time steps
104 INTEGER, PARAMETER :: onum = 10
105 ! output directory and output name
106 CHARACTER(LEN=256), PARAMETER :: odir = "./"
107 CHARACTER(LEN=256), PARAMETER :: ofname = "sblintheo"
108 !--------------------------------------------------------------------------!
109 CLASS(fosite), ALLOCATABLE :: sim
110 REAL :: maximum
111 !--------------------------------------------------------------------------!
112
113 tap_plan(1)
114
115 ALLOCATE(sim)
116
117 CALL sim%InitFosite()
118 CALL makeconfig(sim, sim%config)
119 CALL sim%Setup()
120 CALL initdata(sim%Mesh, sim%Physics, sim%Timedisc%pvar, sim%Timedisc%cvar)
121 CALL sim%Run()
122
123 ! check amplitude
124 IF (sim%Mesh%dz.GT.0.0) THEN
125 maximum = maxval(sim%Timedisc%pvar%data4d(:,:,:,sim%Physics%DENSITY))*sim%Mesh%dz - sigma0
126 ELSE
127 maximum = maxval(sim%Timedisc%pvar%data4d(:,:,:,sim%Physics%DENSITY)) - sigma0
128 END IF
129
130 CALL sim%Finalize()
131 DEALLOCATE(sim)
132
133 tap_check_close(maximum, 0.02395931, 0.0003, "First max. < 3e-4 deviation")
134 tap_done
135
136CONTAINS
137
139 SUBROUTINE makeconfig(Sim,config)
140 IMPLICIT NONE
141 !--------------------------------------------------------------------------!
142 CLASS(fosite) :: Sim
143 TYPE(dict_typ), POINTER :: config
144 !--------------------------------------------------------------------------!
145 TYPE(dict_typ), POINTER :: mesh,physics,fluxes,&
146 grav,sources,timedisc,datafile
147 REAL :: XMIN,XMAX,YMIN,YMAX,ZMIN,ZMAX
148 !--------------------------------------------------------------------------!
149 domainx = domainx*gn*sigma0/(omega*omega)
150 domainy = domainy*gn*sigma0/(omega*omega)
151 xmin = -0.5*domainx
152 xmax = +0.5*domainx
153 ymin = -0.5*domainy
154 ymax = +0.5*domainy
155 zmin = -0.5*thickness*domainx
156 zmax = +0.5*thickness*domainx
157
158 ! physics settings
159 physics => dict(&
160 "problem" / euler_isotherm, &
161 "cs" / soundspeed, &
162 "units" / geometrical &
163 )
164
165 ! mesh settings
166 mesh => dict(&
167 "meshtype" / midpoint, &
168 "geometry" / mgeo, &
169 "shearingbox" / shearsheet_direction, &
170 "inum" / xres, &
171 "jnum" / yres, &
172 "knum" / zres, &
173 "xmin" / xmin, &
174 "xmax" / xmax, &
175 "ymin" / ymin, &
176 "ymax" / ymax, &
177 "zmin" / zmin, &
178 "zmax" / zmax, &
179 "omega" / omega, &
180 "decomposition"/ (/ 1, -1, 1/), &
181 "output/rotation" / 0, &
182 "output/volume" / 0, &
183 "output/bh" / 0, &
184 "output/dl" / 0, &
185 "Qshear" / q &
186 )
187
188 ! fluxes settings
189 fluxes => dict(&
190 "order" / linear, &
191 "fluxtype" / kt, &
192 "variables" / primitive, &
193 "limiter" / vanleer &
194 )
195
196 ! gravity settings (source term)
197 grav => dict(&
198 "stype" / gravity, &
199 "self/gtype" / sboxspectral, &
200 "self/output/accel" / 1, &
201 "self/output/potential" / 1 &
202 )
203
204 ! add gravitational sources
205 sources => dict(&
206 "grav" / grav &
207 )
208
209 ! time discretization settings
210 timedisc => dict( &
211 "method" / dormand_prince, &
212 "cfl" / 0.4, &
213 "stoptime" / tsim, &
214 "dtlimit" / 1.0e-40, &
215 "tol_rel" / 0.1, &
216 "maxiter" / 100000000)
217
218 ! initialize data input/output
219 datafile => dict( &
220 "fileformat" / vtk, &
221 "filename" / (trim(odir) // trim(ofname)), &
222 "count" / onum)
223
224 ! overall config settings
225 config => dict(&
226 "mesh" / mesh, &
227 "physics" / physics, &
228 "fluxes" / fluxes, &
229 "sources" / sources, &
230 "timedisc" / timedisc, &
231 "datafile" / datafile &
232 )
233 END SUBROUTINE makeconfig
234
237 SUBROUTINE initdata(Mesh,Physics,pvar,cvar)
238 IMPLICIT NONE
239 !------------------------------------------------------------------------!
240 CLASS(mesh_base), INTENT(IN) :: Mesh
241 CLASS(physics_base), INTENT(IN) :: Physics
242 CLASS(marray_compound), POINTER, INTENT(INOUT) :: pvar,cvar
243 !------------------------------------------------------------------------!
244 ! local variable declaration
245 REAL :: kx, ky
246 !------------------------------------------------------------------------!
247
248 !---------------------- linear theory test ------------------------------!
249 kx = -2*(2*pi/domainx)
250 ky = 2*pi/domainy
251
252 ! initial condition
253 SELECT TYPE(p => pvar)
254 TYPE IS(statevector_eulerisotherm)
255 IF(mesh%shear_dir.EQ.2)THEN
256 p%density%data3d(:,:,:) = sigma0 &
257 + delsigma*cos(kx*mesh%bcenter(:,:,:,1) + ky*mesh%bcenter(:,:,:,2))
258 p%velocity%data2d(:,1) = 0.0
259 p%velocity%data4d(:,:,:,2) = -q*omega*mesh%bcenter(:,:,:,1)
260 ELSE IF(mesh%shear_dir.EQ.1)THEN
261 p%density%data3d(:,:,:) = sigma0 &
262 + delsigma*cos(kx*mesh%bcenter(:,:,:,2) - ky*mesh%bcenter(:,:,:,1))
263 p%velocity%data4d(:,:,:,1) = q*omega*mesh%bcenter(:,:,:,2)
264 p%velocity%data2d(:,2) = 0.0
265 END IF
266 ! compute volume density from surface density
267 ! for disks with vertical extent
268 IF (mesh%dz.GT.0.0) p%density%data1d(:) = p%density%data1d(:) / mesh%dz
269 TYPE IS(statevector_euler) ! non-isothermal HD
270 IF(mesh%shear_dir.EQ.2)THEN
271 p%density%data3d(:,:,:) = sigma0 &
272 + delsigma*cos(kx*mesh%bcenter(:,:,:,1) + ky*mesh%bcenter(:,:,:,2))
273 p%velocity%data2d(:,1) = 0.0
274 p%velocity%data4d(:,:,:,2) = -q*omega*mesh%bcenter(:,:,:,1)
275 ELSE IF(mesh%shear_dir.EQ.1)THEN
276 p%density%data3d(:,:,:) = sigma0 &
277 + delsigma*cos(kx*mesh%bcenter(:,:,:,2) - ky*mesh%bcenter(:,:,:,1))
278 p%velocity%data4d(:,:,:,1) = q*omega*mesh%bcenter(:,:,:,2)
279 p%velocity%data2d(:,2) = 0.0
280 END IF
281 p%pressure%data3d(:,:,:) = soundspeed**2 * sigma0 / gamma
282 ! compute volume density/pressure from surface density/pressure
283 ! for disks with vertical extent
284 IF (mesh%dz.GT.0.0) THEN
285 p%density%data1d(:) = p%density%data1d(:) / mesh%dz
286 p%pressure%data1d(:) = p%pressure%data1d(:) / mesh%dz
287 END IF
288 CLASS DEFAULT
289 CALL physics%Error("sblintheo::InitData","only (non-)isothermal HD supported")
290 END SELECT
291
292 CALL physics%Convert2Conservative(pvar,cvar)
293
294 !------------------------------------------------------------------------!
295
296 CALL mesh%Info(" DATA-----> initial condition: " // &
297 "Linear Theory Test - Shearingsheet")
298 END SUBROUTINE initdata
299END PROGRAM sblintheo
subroutine initdata(Mesh, Physics, Fluxes, Timedisc)
Definition: bondi2d.f90:274
subroutine makeconfig(Sim, config)
Definition: bondi2d.f90:165
program sblintheo
Definition: sblintheo.f90:72
pure real function, dimension(size(ephir%data2d, dim=1)) omega(ephir, velocity)
main fosite class
Definition: fosite.f90:71