-
Notifications
You must be signed in to change notification settings - Fork 0
/
input.py
executable file
·174 lines (132 loc) · 5.92 KB
/
input.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/usr/bin/env python
import numpy as np
import main_resolvent as m
import wavepackets as wp
import dns_routine as dns
from datetime import datetime
import utils as ut
import time
import os
pwd=os.getcwd()
print(pwd)
startTimeLarge = datetime.now()
# Case Booleans_____________________________________________________________________________________
generateInitialFF = True
# Initial Condition
outputPhysASC = True
outputSpecASC = False
plotting = False
# Convert to Binary for DNS
convert2ff = False
# Write symmetry file
writeSymmFile = False
# Run DNS
DNS = False
if DNS:
convert2ff = False
# Check convergence
checkConvergence = False
runSeriesDist = False
if checkConvergence:
runSeriesDist = False
"""
====================================================================================================
Initialize Variables
====================================================================================================
"""
####################################################################################################
#### INITIALISE VARIABLES - Using existing flow field
####################################################################################################
mac = False
linux = False
approximate_soln = linux
if mac:
direct = '/Users/arslan/Documents/work/channelflow-related/database_solns/W03/equilibria/EQ1'
elif linux:
direct='/home/arslan/Documents/work/channelflow-related/set01/Re1200/KB/ampls-DNS-2015_10_25/wavepacket_017_4modes_(-0.0118649290443+0j)/data-skew/u200.00'
ampl_weights = np.array([1.0])
step = ''
else:
direct = ''
ampl_weights = np.logspace(1.0, -3.0, 5)
#ampl_weights = np.logspace(-0.26, -0.47, 5)
#ampl_weights = np.array([1e-1])
date = time.strftime("%Y_%m_%d")
step = '-DNS-' + str(date)
####################################################################################################
#### INITIALISE VARIABLES - Creating your own flow field
####################################################################################################
# Resolution in wall-normal direction________________________________
geom={}
geom['Nd']=3; geom['Nx']=36; geom['Ny']=37; geom['Nz']=36
# Reynolds number ___________________________________________________
# based on centreline/wall velocity for channel/coutte flow
Re = 3000
# Wave number triplet________________________________________________
# The mode combinations are taken from Sharma & McKeon (2013) paper
wavepacket = 'KB'
xlabel = wavepacket+'_x'
zlabel = wavepacket+'_z'
kx = wp.wavepackets[xlabel]
kz = wp.wavepackets[zlabel]
# Wave speed_________________________________________________________
c = 2.0 / 3.0
# Amplitudes_________________________________________________________
alabel = wavepacket+'_a'
a = wp.wavepackets[alabel]
# Plotting information for a slice___________________________________
fdary = [0 , 'all', 'all', 17] # XY
fdary = [0, 0, 'all', 'all'] # YZ
# Output directory___________________________________________________
main_direc = '/home/arslan/Documents/work/channelflow-related/set01/Re' + str(Re) + '/' + wavepacket + '/ampls' + step
# Geometry___________________________________________________________
geom['Lx'] = 2.0*np.pi / kx[0]
geom['Lz'] = 2.0*np.pi / kz[0]
# Stationary nodes along each axis___________________________________
# X axis
geom['Mx_full'] = np.arange((-geom['Nx']/2.0), (geom['Nx']/2.0)+1) # Full range of Fourier modes
geom['Mx'] = np.arange(-1.0, 2.0) # 1 harmonic
# Z axis_____________________________________________________________
geom['Mz_full'] = np.arange(0, 0.5*(geom['Nz']) + 1.0) # full range of Fourier modes
geom['Mz'] = np.arange(2.0) # 1 harmonic
# X & Z axes_________________________________________________________
geom['x'] = np.linspace(0.0, geom['Lx'], geom['Nx'])
geom['z'] = np.linspace(-geom['Lz']/2.0, geom['Lz']/2.0, geom['Nz'])
geom['t'] = 0
# Total number of modes____________________________________________________
geom['m'] = geom['Ny'] - 2
####################################################################################################
#### ROUTINE: Generate Initial Flow Field & Conver to BINARY
####################################################################################################
if generateInitialFF:
for i in range(0, len(ampl_weights)):
ampl = a*ampl_weights[i]
m.main(direct, fdary, geom, Re, kx, kz, c, ampl, i, main_direc, approximate_soln, outputPhysASC, outputSpecASC, plotting)
os.chdir(main_direc)
# Now we are going to loop through the directory and list directories
dirs = [d for d in os.listdir(main_direc) if os.path.isdir(d)]
dirs = sorted(dirs)
# now we loop thorugh all directories in main_direc and run the conver2ff method
for i in range(0, len(dirs)):
case_direc = dirs[i]
####################################################################################################
#### ROUTINE: Convert to Binary
####################################################################################################
if convert2ff:
ut.convert2ff(case_direc)
###################################################################################################
#### ROUTINE: Write symmetry file
####################################################################################################
symData = {}
symData['fileName'] = 'sigma.asc'
symData['writtenSymmsFile'] = writeSymmFile
if writeSymmFile:
# symmetry file: s sx sy sz ax az
ut.writeSymmsFile(case_direc, symmsFileName, 1, ['1 1 1 1 0.5 0.0'])
####################################################################################################
#### ROUTINE: DNS
####################################################################################################
if DNS:
dns.main(case_direc, Re, symData)
print('\n All donne!\n')
print(' ', datetime.now() - startTimeLarge, '\n')