Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/zh/examples/hpinns.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
```



| 预训练模型 | 指标 |
|:--| :--|
| [hpinns_pretrained.pdparams](https://paddle-org.bj.bcebos.com/paddlescience/models/hPINNs/hpinns_pretrained.pdparams) | loss(opt_sup): 0.05352<br>MSE.eval_metric(opt_sup): 0.00002<br>loss(val_sup): 0.02205<br>MSE.eval_metric(val_sup): 0.00001 |
Expand Down
17 changes: 12 additions & 5 deletions examples/hpinns/holography.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,19 @@ def inference(cfg: DictConfig):
for store_key, infer_key in zip(cfg.INFER.output_keys, output_dict.keys())
}

ppsci.visualize.save_vtu_from_dict(
"./hpinns_pred.vtu",
{**input_dict, **output_dict},
input_dict.keys(),
cfg.INFER.output_keys,
# plotting E and eps
N = ((func_module.l_BOX[1] - func_module.l_BOX[0]) / 0.05).astype(int)
input_eval = np.stack((input_dict["x"], input_dict["y"]), axis=-1).reshape(
N[0], N[1], 2
)
e_re = output_dict["e_re"].reshape(N[0], N[1])
e_im = output_dict["e_im"].reshape(N[0], N[1])
eps = output_dict["eps"].reshape(N[0], N[1])
v_visual = e_re**2 + e_im**2
field_visual = np.stack((v_visual, eps), axis=-1)
plot_module.field_name = ["Fig7_E", "Fig7_eps"]
plot_module.FIGNAME = "hpinns_pred"
plot_module.plot_field_holo(input_eval, field_visual)


@hydra.main(version_base=None, config_path="./conf", config_name="hpinns.yaml")
Expand Down
11 changes: 6 additions & 5 deletions examples/hpinns/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from typing import Callable
from typing import Dict
from typing import List
from typing import Optional

import functions as func_module
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -114,16 +115,16 @@ def prepare_data(solver: ppsci.solver.Solver, expr_dict: Dict[str, Callable]):
def plot_field_holo(
coord_visual: np.ndarray,
field_visual: np.ndarray,
coord_lambda: np.ndarray,
field_lambda: np.ndarray,
coord_lambda: Optional[np.ndarray] = None,
field_lambda: Optional[np.ndarray] = None,
):
"""Plot fields of of holography example.

Args:
coord_visual (np.ndarray): The coord of epsilon and |E|**2.
field_visual (np.ndarray): The filed of epsilon and |E|**2.
coord_lambda (np.ndarray): The coord of lambda.
field_lambda (np.ndarray): The filed of lambda.
coord_lambda (Optional[np.ndarray], optional): The coord of lambda. Defaults to None.
field_lambda (Optional[np.ndarray], optional): The filed of lambda. Defaults to None.
"""
fmin, fmax = np.array([0, 1.0]), np.array([0.6, 12])
cmin, cmax = coord_visual.min(axis=(0, 1)), coord_visual.max(axis=(0, 1))
Expand Down Expand Up @@ -168,7 +169,7 @@ def plot_field_holo(
cb = plt.colorbar()
plt.axis((emin[0], emax[0], emin[1], emax[1]))
plt.clim(vmin=fmin[fi], vmax=fmax[fi])
else:
elif coord_lambda is not None and field_lambda is not None:
# Fig_6C_lambda_
plt.figure(fi * 100 + 101, figsize=(8, 6))
plt.clf()
Expand Down