sblintheo3D.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 #
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 :: TSIM = 10.0/OMEGA ! simulation time !
88 REAL, PARAMETER :: gamma = 1.4 ! dep. on vert. struct. !
89 REAL, PARAMETER :: q = 1.5 ! shearing parameter !
90 ! set (initial) speed of sound using the Toomre criterion and
91 ! assuming marginal stabily; in non-isothermal simulations this is
92 ! used to set the initial pressure (see InitData) whereas in isothermal
93 ! simulations this is constant throughout the simulation
94 REAL, PARAMETER :: soundspeed = pi*gn*sigma0/omega ! det. by. Toomre !
95 REAL, PARAMETER :: height = soundspeed/omega ! (initial) scale height
96! INTEGER, PARAMETER :: PHYS = EULER
97 INTEGER, PARAMETER :: phys = euler_isotherm
98 ! mesh settings
99 INTEGER, PARAMETER :: mgeo = cartesian
100 INTEGER, PARAMETER :: xres = 64 ! amount of cells in x- !
101 INTEGER, PARAMETER :: yres = 64 ! y-direction (rho/phi) !
102 INTEGER, PARAMETER :: zres = 16 ! and z-direction !
103 ! extent of computational domain
104 REAL :: domainx = 40.0 ! domain size [GEOM] !
105 REAL :: domainy = 40.0 ! domain size [GEOM] !
106 REAL :: domainz = 10.0 ! domain size [GEOM] !
107 ! number of output time steps
108 INTEGER, PARAMETER :: onum = 10
109 ! output directory and output name
110 CHARACTER(LEN=256), PARAMETER :: odir = "./"
111 CHARACTER(LEN=256), PARAMETER :: ofname = "sblintheo3D"
112 !--------------------------------------------------------------------------!
113 CLASS(fosite), ALLOCATABLE :: sim
114 LOGICAL :: ok
115 !--------------------------------------------------------------------------!
116
117tap_plan(1)
118
119 ALLOCATE(sim)
120
121 CALL sim%InitFosite()
122 CALL makeconfig(sim, sim%config)
123 CALL sim%Setup()
124 CALL initdata(sim%Mesh, sim%Physics, sim%Timedisc%pvar, sim%Timedisc%cvar)
125 CALL sim%Run()
126 ok = .NOT.sim%aborted
127
128! search for the amplitude
129!maximum = MAXVAL(Sim%Timedisc%pvar(:,:,:,Sim%Physics%DENSITY)) - SIGMA0
130!TAP_CHECK_CLOSE(maximum, 0.0316463969505, 0.005, "Last max. < 0.005 deviation")
131
132 CALL sim%Finalize()
133 DEALLOCATE(sim)
134
135tap_check(ok,"stoptime reached")
136tap_done
137
138CONTAINS
139
141 SUBROUTINE makeconfig(Sim,config)
142 IMPLICIT NONE
143 !--------------------------------------------------------------------------!
144 CLASS(fosite) :: Sim
145 TYPE(dict_typ), POINTER :: config
146 !--------------------------------------------------------------------------!
147 TYPE(dict_typ), POINTER :: mesh,physics,fluxes,boundary,&
148 grav,sources,timedisc,datafile
149 REAL :: XMIN,XMAX,YMIN,YMAX,ZMIN,ZMAX
150 !--------------------------------------------------------------------------!
151 domainx = domainx*gn*sigma0/(omega*omega)
152 domainy = domainy*gn*sigma0/(omega*omega)
153 xmin = -0.5*domainx
154 xmax = +0.5*domainx
155 ymin = -0.5*domainy
156 ymax = +0.5*domainy
157 zmin = -0.5*domainz
158 zmax = +0.5*domainz
159
160 ! physics settings
161 SELECT CASE(phys)
162 CASE(euler_isotherm)
163 physics => dict("problem" / euler_isotherm, &
164 "cs" / soundspeed, & ! isothermal speed of sound
165 "units" / geometrical)
166 CASE(euler)
167 physics => dict("problem" / euler, &
168 "gamma" / gamma, & ! ratio of specific heats
169 "units" / geometrical)
170 CASE DEFAULT
171 CALL sim%Error("sblintheo3D::MakeConfig","unsupported physics")
172 END SELECT
173
174 ! mesh settings
175 mesh => dict(&
176 "meshtype" / midpoint, &
177 "geometry" / mgeo, &
178 "shearingbox" / shearsheet_direction, &
179 "inum" / xres, &
180 "jnum" / yres, &
181 "knum" / zres, &
182 "xmin" / xmin, &
183 "xmax" / xmax, &
184 "ymin" / ymin, &
185 "ymax" / ymax, &
186 "zmin" / zmin, &
187 "zmax" / zmax, &
188 "omega" / omega, &
189 "decomposition"/ (/ 1, -1, 1/), &
190 "output/rotation" / 0, &
191 "output/volume" / 0, &
192 "output/bh" / 0, &
193 "output/dl" / 0, &
194 "Qsher" / q &
195 )
196
197 ! boundary conditions (x-/y-boundaries are set automatically)
198 ! z-boundary should be reflecting, otherwise the disk mass
199 ! increases and the disk becomes unstable
200 boundary => dict(&
201 "bottomer" / reflecting,&
202 "topper" / reflecting)
203
204 ! fluxes settings
205 fluxes => dict(&
206 "order" / linear, &
207 "fluxtype" / kt, &
208 "variables" / primitive, &
209 "limiter" / vanleer &
210 )
211
212 ! gravity settings (source term)
213 grav => dict(&
214 "stype" / gravity, &
215 "self/gtype" / sboxspectral, &
216 "self/output/accel" / 0, &
217 "self/output/potential" / 0 &
218 )
219
220 ! sources settings (contains source terms)
221 sources => dict(&
222 "grav" / grav &
223 )
224
225 ! time discretization settings
226 timedisc => dict( &
227 "method" / dormand_prince, &
228 "cfl" / 0.4, &
229 "stoptime" / tsim, &
230 "dtlimit" / 1.0e-40, &
231 "tol_rel" / 0.1, &
232 "maxiter" / 100000000)
233
234 ! initialize data input/output
235 datafile => dict( &
236 "fileformat" / vtk, &
237 "filename" / (trim(odir) // trim(ofname)), &
238 "count" / onum)
239
240 ! overall config settings
241 config => dict(&
242 "mesh" / mesh, &
243 "physics" / physics, &
244 "fluxes" / fluxes, &
245 "boundary" / boundary, &
246 "sources" / sources, &
247 "timedisc" / timedisc, &
248 "datafile" / datafile &
249 )
250 END SUBROUTINE makeconfig
251
253 SUBROUTINE initdata(Mesh,Physics,pvar,cvar)
254 IMPLICIT NONE
255 !------------------------------------------------------------------------!
256 CLASS(mesh_base), INTENT(IN) :: Mesh
257 CLASS(physics_base), INTENT(IN) :: Physics
258 CLASS(marray_compound), POINTER, INTENT(INOUT) :: pvar,cvar
259 !------------------------------------------------------------------------!
260 ! local variable declaration
261 REAL :: kx, ky, kz
262 !------------------------------------------------------------------------!
263
264 !---------------------- linear theory test ------------------------------!
265 kx = -2*(2*pi/domainx)
266 ky = 2*pi/domainy
267 kz = 2*pi/domainz
268
269 ! initial condition
270 SELECT TYPE(p => pvar)
271 TYPE IS(statevector_eulerisotherm)
272 ! zero all velocity components
273 p%velocity%data1d(:) = 0.0
274 IF(mesh%shear_dir.EQ.2)THEN
275 p%density%data3d(:,:,:) = (sigma0 &
276 + delsigma*cos(kx*mesh%bcenter(:,:,:,1) &
277 + ky*mesh%bcenter(:,:,:,2)))/(sqrt(2*pi)*height) &
278 *exp(-0.5*(mesh%bcenter(:,:,:,3)/height)**2)
279 p%velocity%data4d(:,:,:,2) = -q*omega*mesh%bcenter(:,:,:,1)
280 ELSE IF(mesh%shear_dir.EQ.1)THEN
281 p%density%data3d(:,:,:) = (sigma0 &
282 + delsigma*cos(kx*mesh%bcenter(:,:,:,2) &
283 - ky*mesh%bcenter(:,:,:,1)))/(sqrt(2*pi)*height) &
284 *exp(-0.5*(mesh%bcenter(:,:,:,3)/height)**2)
285 p%velocity%data4d(:,:,:,1) = q*omega*mesh%bcenter(:,:,:,2)
286 END IF
287 p%density%data1d(:) = p%density%data1d(:) / mesh%dz
288 TYPE IS(statevector_euler) ! non-isothermal HD
289 IF(mesh%shear_dir.EQ.2)THEN
290 p%density%data3d(:,:,:) = (sigma0 &
291 + delsigma*cos(kx*mesh%bcenter(:,:,:,1) &
292 + ky*mesh%bcenter(:,:,:,2)))/(sqrt(2*pi)*height) &
293 *exp(-0.5*(mesh%bcenter(:,:,:,3)/height)**2)
294 p%velocity%data4d(:,:,:,2) = -q*omega*mesh%bcenter(:,:,:,1)
295 ELSE IF(mesh%shear_dir.EQ.1)THEN
296 p%density%data3d(:,:,:) = (sigma0 &
297 + delsigma*cos(kx*mesh%bcenter(:,:,:,2) &
298 - ky*mesh%bcenter(:,:,:,1)))/(sqrt(2*pi)*height) &
299 *exp(-0.5*(mesh%bcenter(:,:,:,3)/height)**2)
300 p%velocity%data4d(:,:,:,1) = q*omega*mesh%bcenter(:,:,:,2)
301 END IF
302 p%density%data1d(:) = p%density%data1d(:) / mesh%dz
303 p%pressure%data1d(:) = soundspeed**2 / gamma * p%density%data1d(:)
304 CLASS DEFAULT
305 CALL physics%Error("sblintheo3D::InitData","only (non-)isothermal HD supported")
306 END SELECT
307
308 CALL physics%Convert2Conservative(pvar,cvar)
309 CALL mesh%Info(" DATA-----> initial condition: " // &
310 "Linear Theory Test - 3D Shearingbox")
311 END SUBROUTINE initdata
312END 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