-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtunnel_primal.py
65 lines (52 loc) · 1.97 KB
/
tunnel_primal.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
################################################################################
# #
# tunnel_primal.py copyright 2015 Qiqi Wang ([email protected]) #
# #
################################################################################
import matplotlib
matplotlib.use('agg')
matplotlib.interactive(False)
import pdb
import sys
import time
import argparse
from pylab import *
from tunnel import *
# set parameters
s = 0.1 * np.ones(2)
parser = argparse.ArgumentParser()
parser.add_argument('--restart', type=str, default='')
args = parser.parse_args()
if len(args.restart) == 0:
w = grid.zeros([4]) + w0
w[:] *= 1 + 0.01 * (grid.random() - 0.5)
else:
print('restarting from ', args.restart)
w = load(args.restart)
assert w.shape == (Nx, Ny, 4)
fout = open('force_hist.txt','w')
figure(figsize=(28,10))
for iplot in range(200):
for iprint in range(nPrintsPerPlot):
for istep in range(nStepPerPrint):
w = step(w,s)
print('%f %f' % tuple(force(w,s)))
fout.write('%f %f\n' % tuple(force(w,s)))
sys.stdout.flush()
w.save('w{0:06d}.npy'.format(iplot))
r, ru, rv, p = w
rho, u, v = r * r, ru / r, rv / r
clf()
u_range = linspace(-u0, u0 * 2, 100)
subplot(2,1,1); contourf(x._data.T, y._data.T, u._data.T,
u_range, extend='both')
axis('scaled'); colorbar()
v_range = linspace(-u0, u0, 100)
subplot(2,1,2); contourf(x._data.T, y._data.T, v._data.T,
v_range, extend='both')
axis('scaled'); colorbar()
savefig('fig{0:06d}.png'.format(iplot))
fout.close()
################################################################################
################################################################################
################################################################################