-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgenerate_data.py
34 lines (25 loc) · 1.12 KB
/
generate_data.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
import os
import numpy as np
from data_generation.generate_mesh import generate_mesh
from data_generation.generate_flow import generate_flow
from data_generation.generate_reaction import generate_reaction
from utils import DATA_DIR
if __name__ == '__main__':
# Generate the mesh
generate_mesh()
# Simulate the flow in the channel
w = generate_flow()
# Simulate the reaction system to generate training, validation and test data
np.random.seed(42)
print('Generating training data')
c0_train, u_train, c_train, y_train = generate_reaction()
print('Generating validation data')
c0_val, u_val, c_val, y_val = generate_reaction()
print('Generating test data')
c0_test, u_test, c_test, y_test = generate_reaction()
with open(os.path.join(DATA_DIR, 'training.npz'), 'wb') as f:
np.savez(f, c0=c0_train, u=u_train, c=c_train, y=y_train)
with open(os.path.join(DATA_DIR, 'validation.npz'), 'wb') as f:
np.savez(f, c0=c0_val, u=u_val, c=c_val, y=y_val)
with open(os.path.join(DATA_DIR, 'test.npz'), 'wb') as f:
np.savez(f, c0=c0_test, u=u_test, c=c_test, y=y_test)