Skip to content

Commit a1ed7a3

Browse files
set create_graph=False before eval (#776)
1 parent 92f1b4d commit a1ed7a3

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

docs/zh/examples/bubble.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,9 @@ examples/bubble/bubble.py:189:206
301301

302302
最后在给定的可视化区域上进行预测并可视化,可视化数据是区域内的二维点集,每个时刻 $t$ 的坐标是 $(x^t_i, y^t_i)$,对应值是 $(u^t_i, v^t_i, p^t_i,\phi^t_i)$,在此我们对预测得到的 $(u^t_i, v^t_i, p^t_i,\phi^t_i)$ 进行反归一化,我们将反归一化后的数据按时刻保存成 126 个 **vtu格式** 文件,最后用可视化软件打开查看即可。代码如下:
303303

304-
``` py linenums="212"
304+
``` py linenums="222"
305305
--8<--
306-
examples/bubble/bubble.py:212:238
306+
examples/bubble/bubble.py:222:248
307307
--8<--
308308
```
309309

examples/bubble/bubble.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,16 @@ def transform_out(in_, out):
208208
visu_mat = geom["time_rect_visu"].sample_interior(
209209
NPOINT_PDE * NTIME_PDE, evenly=True
210210
)
211+
# transform
212+
def transform_out(in_, out):
213+
psi_y = out["psi"]
214+
y = in_["y"]
215+
x = in_["x"]
216+
u = jacobian(psi_y, y, create_graph=False)
217+
v = -jacobian(psi_y, x, create_graph=False)
218+
return {"u": u, "v": v}
219+
220+
model_psi.register_output_transform(transform_out)
211221

212222
pred_norm = solver.predict(visu_mat, None, 4096, no_grad=False, return_numpy=True)
213223
# inverse normalization

0 commit comments

Comments
 (0)