-
Notifications
You must be signed in to change notification settings - Fork 13
/
gen_data.py
64 lines (53 loc) · 2.01 KB
/
gen_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
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
import deepxde as dde
import numpy as np
from utils import read_data
def gen_low():
bte = read_data("bte5x5_2iter_size10532", 10532)
input_branch = []
input_trunk = []
output = []
for i in range(10000):
pores = bte[i]["x"]
x = bte[i]["centroids"]
y = np.linalg.norm(bte[i]["intermediate"]["Flux BTE"], axis=1)
n = len(x)
input_branch.append(np.tile(pores, (n, 1)))
input_trunk.append(x)
output.append(y.reshape((n, 1)))
input_branch = np.array(input_branch, dtype=object)
input_trunk = np.array(input_trunk, dtype=object)
output = np.array(output, dtype=object)
np.savez_compressed("train.npz", X0=input_branch, X1=input_trunk, y=output)
def gen_mf():
bte = read_data("bte5x5_2iter_size10532", 10532)
input_branch = []
input_trunk = []
output = []
output_low = []
for i in range(1000):
pores = bte[i]["x"]
# pores = np.ravel(bte[i]["centers"])
x = bte[i]["centroids"]
# T = bte[i]["variables"]["Temperature BTE"]["data"]
# T_low = bte[i]["variables"]["Temperature Fourier"]["data"]
y = np.linalg.norm(bte[i]["variables"]["Flux BTE"]["data"], axis=1)
# y_low = np.linalg.norm(bte[i]["variables"]["Flux Fourier"]["data"], axis=1)
y_low = np.linalg.norm(bte[i]["intermediate"]["Flux BTE"], axis=1)
n = len(x)
input_branch.append(np.tile(pores, (n, 1)))
input_trunk.append(x)
output.append(y.reshape((n, 1)))
output_low.append(y_low.reshape((n, 1)))
input_branch = np.array(input_branch, dtype=object)
input_trunk = np.array(input_trunk, dtype=object)
output = np.array(output, dtype=object)
output_low = np.array(output_low, dtype=object)
print(dde.metrics.mean_squared_error(np.vstack(output), np.vstack(output_low)))
np.savez_compressed(
"train.npz", X0=input_branch, X1=input_trunk, y=output, y_low_x=output_low
)
def main():
# gen_low()
gen_mf()
if __name__ == "__main__":
main()