Skip to content
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

Merged
merged 16 commits into from
Aug 16, 2023
Merged

Bubble net #478

merged 16 commits into from
Aug 16, 2023

Conversation

liaoxin2
Copy link
Contributor

@liaoxin2 liaoxin2 commented Aug 9, 2023

PR types

One of New features

PR changes

One of Docs

Describe

single bubble flow

@paddle-bot
Copy link

paddle-bot bot commented Aug 9, 2023

Thanks for your contribution!

examples/bubble/bubble.py Outdated Show resolved Hide resolved
examples/bubble/bubble.py Outdated Show resolved Hide resolved
v_out = -jacobian(psi_y, x)
return {"u": u_out, "v": v_out}

model_psi.register_input_transform(transform_in)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删掉55行

geom["time_rect"],
{
"dataset": "IterableNamedArrayDataset",
"batch_size": 228595,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用 IterableNamedArrayDataset 作为dataset,不需要指定batchsize

ppsci.loss.MSELoss("mean"),
name="EQ",
)
# set constraint
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

移动到93行

Comment on lines 143 to 151
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,
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删除eta_前缀,这个案例跟eta无关

eta_mse_validator.name: eta_mse_validator,
}

visu_mat = geom["time_rect_eval"].sample_interior(300 * 100 * 126, evenly=True)
Copy link
Collaborator

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代替

Comment on lines 155 to 164
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]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的8个量如果只是浮点数,不需要存放在.mat里面吧,或者具体说明一下是怎么计算得到的

"p": lambda d: d["p"] * (p_max - p_min) + p_min,
"phil": lambda d: d["phil"],
},
num_timestamps=126,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同理,不要写数字,用变量代替,否则其他代码更改后,这里需要同步进行更改

examples/bubble/bubble.py Show resolved Hide resolved
# 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
Copy link
Collaborator

@HydrogenSulfate HydrogenSulfate Aug 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删除末尾的_pinns_p

Comment on lines 38 to 40
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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

顺序全部改成 ("t", "x", "y")

"dataset": {
"name": "MatDataset",
"file_path": DATASET_PATH,
"input_keys": ("x", "t", "y"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

顺序改成 ("t", "x", "y")

Comment on lines 156 to 163
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]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8个浮点数直接写在代码里,不需要从外部文件读入进来

Comment on lines 46 to 48
u_out = jacobian(psi_y, y)
v_out = -jacobian(psi_y, x)
return {"u": u_out, "v": v_out}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删除变量末尾的_out

Comment on lines 49 to 74
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

变量命名用全小写字母

N = X_star.shape[0]
T = t_star.shape[0]

# Rearrange Data
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rearrange

train_data["p"] = p[idx, :]
train_data["phil"] = phil[idx, :]
scipy.io.savemat("bubble_train.mat", train_data)
# valid Data
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eval data

Comment on lines 88 to 99
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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

测试数据生成好后,在内存中可以直接用NamedArrayDataset读取,不需要保存到磁盘再通过MatDataset读取

Copy link
Collaborator

@HydrogenSulfate HydrogenSulfate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@HydrogenSulfate HydrogenSulfate merged commit 6c2b58a into PaddlePaddle:develop Aug 16, 2023
huohuohuohuohuo123 pushed a commit to huohuohuohuohuo123/PaddleScience that referenced this pull request Aug 12, 2024
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants