--- frameworks: - pytorch language: - en license: apache-2.0 tags: - OneScience - hp-VPINN - variational-physics-informed-neural-networks - partial-differential-equations - Poisson tasks: - pde-solving ---
hp-VPINN
# Model Overview hp-VPINN (Variational Physics-Informed Neural Network with h- and p-Refinement) trains a neural network using the variational weak form of a partial differential equation. Test functions impose integral constraints on the equation residual, while domain decomposition (h-refinement) and higher-order polynomial test functions (p-refinement) improve the representation and solution of complex fields. This model package provides one- and two-dimensional Poisson equation examples. Paper: hp-VPINNs: Variational physics-informed neural networks with domain decomposition https://doi.org/10.1016/j.cma.2020.113547 # Model Description hp-VPINN constructs its variational loss with Gauss–Lobatto–Jacobi quadrature and represents the equation solution with a fully connected network. The one-dimensional example supports piecewise integration domains, while the two-dimensional example supports non-square subdomain grids. The number of subdomains and the order of the test functions can be adjusted independently to study the effects of h- and p-refinement on solution quality. # Use Cases | Use Case | Description | | :---: | :--- | | One-dimensional Poisson equation | Constrain the weak-form residual using piecewise integration domains and higher-order test functions | | Two-dimensional Poisson equation | Perform tensor-product quadrature on a two-dimensional domain-decomposition grid | | h-refinement research | Vary the number of subdomains to compare spatial decomposition strategies | | p-refinement research | Vary the test-function order to compare weak-form constraint capacity | # Usage ## 1. OneCode Use the online OneCode environment for an intelligent, one-click AI for Science (AI4S) programming experience: [Launch OneCode for one-click AI4S programming](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home) ## 2. Manual Setup **Hardware Requirements** - A GPU or DCU is recommended for training. - A CPU can be used for inference and small-scale pipeline validation, but full training will be slow. - DCU users must install DTK and a PyTorch environment compatible with the target cluster. ### Download the Model Package ```bash modelscope download --model OneScience/VPINNs --local_dir ./VPINNs cd VPINNs ``` ### Set Up the Runtime Environment **DCU Environment** ```bash # Activate DTK and Conda first conda create -n onescience311 python=3.11 -y conda activate onescience311 pip install onescience[cfd-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai ``` **GPU Environment** ```bash # Activate Conda first conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12 conda activate onescience311 pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai ``` ### Training Data Both the one- and two-dimensional Poisson examples construct source terms, boundary values, and evaluation data from analytical solutions, with no dependency on external data files. The numbers of subdomains, test functions, and quadrature points can be configured in `conf/config.yaml`. ### Training The training example is controlled by `common.case` in `conf/config.yaml`, which supports `1d`, `2d`, and `all`: ```bash python scripts/train.py ``` Training weights are saved to the `weight/` directory by default. ### Model Weights This repository provides weights trained on the one- and two-dimensional Poisson datasets in the `weight/` directory. ### Inference, Evaluation, and Visualization The model package provides one-dimensional Poisson weights for validation. Run: ```bash python scripts/inference.py ``` For the two-dimensional example, first train the corresponding weights, then set `common.case` to `2d` or `all` before running inference. The script reports the relative L2 error and saves result plots to `result/`. Model, training, and inference parameters can all be modified in `conf/config.yaml`. # Official OneScience Resources | Platform | OneScience Repository | Skills Repository | | --- | --- | --- | | Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills | | GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills | # Citations and License - Kharazmi, E., Zhang, Z., and Karniadakis, G. E. hp-VPINNs: Variational physics-informed neural networks with domain decomposition. Computer Methods in Applied Mechanics and Engineering, 374, 113547, 2021. - This model package is released under the Apache-2.0 license and retains attribution to the original paper.