-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexamples.py
135 lines (105 loc) · 4.95 KB
/
examples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import sys
import numpy as np
import math as m
import os.path
import subprocess
from os import path
sys.path.append('python-utils')
from writexmf import writexmf
from CompNavierStokes import CompNavierStokes
# Parameters that can be specified are:
# Grid Parameters (defaults are shown here)
# mx, my, mz = 128, 128, 128 = total grid size in the x-, y- and z- direction
# Lx, Ly, Lz = 1, 1, 1 = total domain length in the x-, y- and z- direction
# perX = True = boolean (true=periodic BC in X, false=wall BC in X)
# nUnifX = False = boolean (true=hyperbolic tangent in X, false=uniform grid in X)
# Numerical Parameters
# cfl = 0.5 = CFL number
# stenA = 4 = half of order for advective terms (minimum 1 maximum 4)
# stenV = 4 = half of order for viscous terms (minimum 1 maximum 4 <= stenA)
# Physical Parameters (defaults are shown here)
# Re = 1600 = Reynolds number
# Ma = 0.1 = Mach number
# Pr = 1 = Prandtl number
# visc = 1 = exponent for viscosity as a function of temperature
# forcing = False = boolean (true=uniform forcing in z- direction, false=no forcing)
# if restart=-1, then the initialization will be taylor green vortices
# for forcing false and rollers for forcing true
# Simulation Parameters (defaults are shown)
# nsteps = 200 = iterations between saving files
# nfiles = 1 = number of files to save (total simulation nsteps*nfiles)
# restart = -1 = if negative start from scratch, otherwise number of restart file
# pRow, pCol = 1, 1 = number of GPU used in y- and z- direction (divide my and mz)
# stream = False = boolean (true=use streams for RHS, false=serial RHS calculation)
# checkCFL = 10 = number of iteration at which the CFL condition is checked and Dt is changed accordingly
# checkBulk = 10 = number of iteration at which Bulk values are calculated
# as a first example we do a decaying turbulence simulation.
# all defaults are set up to have a decaying turbulence simulation
# we just have to set up the amount of required files (100 will do)
# and make sure the domain is 2\pi*2\pi*2\pi
Nfiles=10 # we want to save down 10 fields
CompNavierStokes(nsteps=101,nfiles=Nfiles,Lx=2*m.pi,Ly=2*m.pi,Lz=2*m.pi)
# when the solution is finished let's save the results in a different folder and create a visualization xmf file
directory='./fields/decaying-turbulence/'
if not(path.exists(directory)):
subprocess.call(["mkdir",directory])
subprocess.call('mv ./fields/*.bin ' + directory, shell=True)
x = np.fromfile(directory + 'x.bin', dtype='double')
y = np.fromfile(directory + 'y.bin', dtype='double')
z = np.fromfile(directory + 'z.bin', dtype='double')
writexmf(directory + 'decaying-turbulence.xmf','double', \
x, y, z, \
np.arange(1,Nfiles+1,1), 1.0, \
['r',\
'u',\
'v',\
'w',\
'e'])
# Now let's run a supersonic channel with Mach equal to 1.5 and reynolds (bulk) equal to 3000
# this time we need a slighlty bigger grid and to fix also the domain.
# we need to increase the reynolds number and make the grid not uniform as well as include forcing.
# we can also increase the number of steps in between the saving of the files
CompNavierStokes(mx=160, my=192, mz=192, \
Lx=2, Ly=2*m.pi, Lz=4*m.pi, \
perX=False, nUnifX=True, forcing=True, \
Re=3000, Ma=1.5, visc=0.7, \
nsteps=1000, nfiles=Nfiles)
# Let's again save the results in a different folder and create a visualization xmf file
directory='./fields/supersonic-channel/'
if not(path.exists(directory)):
subprocess.call(["mkdir",directory])
subprocess.call('mv ./fields/*.bin ' + directory, shell=True)
x = np.fromfile(directory + 'x.bin', dtype='double')
y = np.fromfile(directory + 'y.bin', dtype='double')
z = np.fromfile(directory + 'z.bin', dtype='double')
writexmf(directory + 'supersonic-channel.xmf','double', \
x, y, z, \
np.arange(1,Nfiles+1,1), 1.0, \
['r',\
'u',\
'v',\
'w',\
'e'])
# Now let's run a supersonic laminar boundary layer channel with Mach equal to 0.8 and reynolds (bulk) equal to 300
CompNavierStokes(mx=320, my=4, mz=320, \
Lx=20, Ly=2, Lz=100, \
perX=False, nUnifX=True, forcing=False, boundaryLayer=True, \
Re=300, Ma=0.8, visc=0.75, Pr=0.71, \
checkCFL=10,checkBulk=10, \
nsteps=1000, nfiles=Nfiles)
# Let's again save the results in a different folder and create a visualization xmf file
directory='./fields/laminar-BL/'
if not(path.exists(directory)):
subprocess.call(["mkdir",directory])
subprocess.call('mv ./fields/*.bin ' + directory, shell=True)
x = np.fromfile(directory + 'x.bin', dtype='double')
y = np.fromfile(directory + 'y.bin', dtype='double')
z = np.fromfile(directory + 'z.bin', dtype='double')
writexmf(directory + 'supersonic-channel.xmf','double', \
x, y, z, \
np.arange(1,Nfiles+1,1), 1.0, \
['r',\
'u',\
'v',\
'w',\
'e'])