-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_images_2d.py
executable file
·38 lines (28 loc) · 962 Bytes
/
gen_images_2d.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
import os
import matplotlib.pyplot as plt
import numpy as np
from tqdm import tqdm
import pulsatile_flow
def main():
w = 1.
num_frames = 100
ts = np.linspace(-np.pi / w, np.pi / w, num_frames, endpoint=False)
r_fraction = np.linspace(-1., 1., 100, endpoint=True)
out_dir = 'img'
if not os.path.isdir(out_dir):
os.makedirs(out_dir)
alphas = [1, 2, 5, 10]
fig = plt.figure(frameon=False, figsize=(8,6))
ax = fig.add_axes([0, 0, 1, 1])
ax.axis('off')
for i, t in tqdm(enumerate(ts), total=num_frames,
desc='Rendering frames: ', ascii=True):
ax.cla()
for alpha in alphas:
u = pulsatile_flow.ux(r_fraction, t, w, alpha=alpha)
ax.plot(u, label=r'$\alpha={:.1f}$'.format(alpha))
plt.ylim(-1.5, 1.5)
ax.legend(loc='upper right')
plt.savefig(os.path.join(out_dir, f'{i}.png'), dpi=300)
if __name__ == '__main__':
main()