-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bubble net #478
Bubble net #478
Conversation
Thanks for your contribution! |
examples/bubble/bubble.py
Outdated
v_out = -jacobian(psi_y, x) | ||
return {"u": u_out, "v": v_out} | ||
|
||
model_psi.register_input_transform(transform_in) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删掉55行
examples/bubble/bubble.py
Outdated
geom["time_rect"], | ||
{ | ||
"dataset": "IterableNamedArrayDataset", | ||
"batch_size": 228595, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使用 IterableNamedArrayDataset 作为dataset,不需要指定batchsize
examples/bubble/bubble.py
Outdated
ppsci.loss.MSELoss("mean"), | ||
name="EQ", | ||
) | ||
# set constraint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
移动到93行
examples/bubble/bubble.py
Outdated
eta_mse_validator = ppsci.validate.SupervisedValidator( | ||
valida_dataloader_cfg, | ||
ppsci.loss.MSELoss("mean"), | ||
metric={"MSE": ppsci.metric.MSE()}, | ||
name="eta_mse", | ||
) | ||
validator = { | ||
eta_mse_validator.name: eta_mse_validator, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删除eta_
前缀,这个案例跟eta无关
examples/bubble/bubble.py
Outdated
eta_mse_validator.name: eta_mse_validator, | ||
} | ||
|
||
visu_mat = geom["time_rect_eval"].sample_interior(300 * 100 * 126, evenly=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
300、100、126用变量代替,否则用不知道这些数字是什么意思,如126可以用len(timestamps) - 1代替
examples/bubble/bubble.py
Outdated
datafile = "maxmin.mat" | ||
data = scipy.io.loadmat(datafile) | ||
u_max = data["u_max"][0][0] | ||
u_min = data["u_min"][0][0] | ||
v_max = data["v_max"][0][0] | ||
v_min = data["v_min"][0][0] | ||
p_max = data["p_max"][0][0] | ||
p_min = data["p_min"][0][0] | ||
phil_max = data["phil_max"][0][0] | ||
phil_min = data["phil_min"][0][0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的8个量如果只是浮点数,不需要存放在.mat里面吧,或者具体说明一下是怎么计算得到的
examples/bubble/bubble.py
Outdated
"p": lambda d: d["p"] * (p_max - p_min) + p_min, | ||
"phil": lambda d: d["phil"], | ||
}, | ||
num_timestamps=126, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同理,不要写数字,用变量代替,否则其他代码更改后,这里需要同步进行更改
examples/bubble/bubble.py
Outdated
# set random seed for reproducibility | ||
ppsci.utils.misc.set_random_seed(42) | ||
# set output directory | ||
OUTPUT_DIR = "./output_bubble_pinns_p" if not args.output_dir else args.output_dir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删除末尾的_pinns_p
examples/bubble/bubble.py
Outdated
model_psi = ppsci.arch.MLP(("x", "y", "t"), ("psi",), 9, 30, "tanh") | ||
model_p = ppsci.arch.MLP(("x", "y", "t"), ("p",), 9, 30, "tanh") | ||
model_phil = ppsci.arch.MLP(("x", "y", "t"), ("phil",), 9, 30, "tanh") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
顺序全部改成 ("t", "x", "y")
examples/bubble/bubble.py
Outdated
"dataset": { | ||
"name": "MatDataset", | ||
"file_path": DATASET_PATH, | ||
"input_keys": ("x", "t", "y"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
顺序改成 ("t", "x", "y")
examples/bubble/bubble.py
Outdated
u_max = data["u_max"][0][0] | ||
u_min = data["u_min"][0][0] | ||
v_max = data["v_max"][0][0] | ||
v_min = data["v_min"][0][0] | ||
p_max = data["p_max"][0][0] | ||
p_min = data["p_min"][0][0] | ||
phil_max = data["phil_max"][0][0] | ||
phil_min = data["phil_min"][0][0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8个浮点数直接写在代码里,不需要从外部文件读入进来
examples/bubble/bubble.py
Outdated
u_out = jacobian(psi_y, y) | ||
v_out = -jacobian(psi_y, x) | ||
return {"u": u_out, "v": v_out} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删除变量末尾的_out
examples/bubble/bubble.py
Outdated
P_star = p_norm # N x T | ||
Phil_star = data["phil"] # N x T | ||
t_star = data["t"] # T x 1 | ||
X_star = data["X"] # N x 2 | ||
|
||
N = X_star.shape[0] | ||
T = t_star.shape[0] | ||
|
||
# Rearrange Data | ||
XX = np.tile(X_star[:, 0:1], (1, T)) # N x T | ||
YY = np.tile(X_star[:, 1:2], (1, T)) # N x T | ||
TT = np.tile(t_star, (1, N)).T # N x T | ||
|
||
UU = u_star # U_star[:,0,:] # N x T | ||
VV = v_star # U_star[:,1,:] # N x T | ||
PP = P_star # N x T | ||
Phil = Phil_star # N x T | ||
|
||
x = XX.flatten()[:, None] # NT x 1 | ||
y = YY.flatten()[:, None] # NT x 1 | ||
t = TT.flatten()[:, None] # NT x 1 | ||
|
||
u = UU.flatten()[:, None] # NT x 1 | ||
v = VV.flatten()[:, None] # NT x 1 | ||
p = PP.flatten()[:, None] # NT x 1 | ||
phil = Phil.flatten()[:, None] # NT x 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
变量命名用全小写字母
examples/bubble/bubble.py
Outdated
N = X_star.shape[0] | ||
T = t_star.shape[0] | ||
|
||
# Rearrange Data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rearrange
examples/bubble/bubble.py
Outdated
train_data["p"] = p[idx, :] | ||
train_data["phil"] = phil[idx, :] | ||
scipy.io.savemat("bubble_train.mat", train_data) | ||
# valid Data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eval data
examples/bubble/bubble.py
Outdated
test_data = dict() | ||
test_data["x"] = x | ||
test_data["y"] = y | ||
test_data["t"] = t | ||
test_data["u"] = u | ||
test_data["v"] = v | ||
test_data["p"] = p | ||
test_data["phil"] = phil | ||
scipy.io.savemat("bubble_valid.mat", test_data) | ||
|
||
DATASET_PATH = "bubble_train.mat" | ||
DATASET_PATH_VALID = "bubble_test.mat" | ||
DATASET_PATH_VALID = "bubble_valid.mat" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
测试数据生成好后,在内存中可以直接用NamedArrayDataset
读取,不需要保存到磁盘再通过MatDataset
读取
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* add bubble datafile test=develop * add bubble code test=develop * add bubble code test=develop * add bubble code test=develop * add bubble code * add bubble data * add bubble code * delete mat file * delete mat file * bubble code * delete mat file * add some modify * add some modifications * add some modifications * add some modifications * add some modifications
PR types
One of New features
PR changes
One of Docs
Describe
single bubble flow