瀏覽代碼

PINN SimNet Release

bharatk-parallel 3 年之前
父節點
當前提交
c2bdc78d1f
共有 96 個文件被更改,包括 117956 次插入0 次删除
  1. 45 0
      hpc_ai/PINN/English/python/Start_Here.ipynb
  2. 45 0
      hpc_ai/PINN/English/python/jupyter_notebook/Start_Here.ipynb
  3. 360 0
      hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/Challenge_1_template.ipynb
  4. 356 0
      hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/Challenge_2_template.ipynb
  5. 187 0
      hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/Challenge_3_template.ipynb
  6. 99 0
      hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/Challenge_CFD_Problem_Notebook.ipynb
  7. 二進制
      hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/challenge_results.png
  8. 二進制
      hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/challenge_results_param_updated.png
  9. 二進制
      hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/chip_2d_geom.png
  10. 二進制
      hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/chip_2d_parameterized.png
  11. 二進制
      hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/multi_GPU_1.png
  12. 二進制
      hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/multi_GPU_2.png
  13. 56943 0
      hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/openfoam/2D_chip_fluid0.csv
  14. 877 0
      hpc_ai/PINN/English/python/jupyter_notebook/diffusion_1d/Diffusion_Problem_Notebook.ipynb
  15. 二進制
      hpc_ai/PINN/English/python/jupyter_notebook/diffusion_1d/diffusion_bar_geometry.png
  16. 二進制
      hpc_ai/PINN/English/python/jupyter_notebook/diffusion_1d/image_diffusion_problem_bootcamp.png
  17. 二進制
      hpc_ai/PINN/English/python/jupyter_notebook/diffusion_1d/image_diffusion_problem_bootcamp_parameterized.png
  18. 二進制
      hpc_ai/PINN/English/python/jupyter_notebook/diffusion_1d/image_tensorboard.png
  19. 214 0
      hpc_ai/PINN/English/python/jupyter_notebook/introduction/Introductory_Notebook.ipynb
  20. 二進制
      hpc_ai/PINN/English/python/jupyter_notebook/introduction/SimNet_v21.06_User_Guide.pdf
  21. 二進制
      hpc_ai/PINN/English/python/jupyter_notebook/introduction/every_parabola.png
  22. 二進制
      hpc_ai/PINN/English/python/jupyter_notebook/introduction/image_data_driven_cons.png
  23. 二進制
      hpc_ai/PINN/English/python/jupyter_notebook/introduction/inverse_parabola.png
  24. 二進制
      hpc_ai/PINN/English/python/jupyter_notebook/introduction/inverse_parabola_2.png
  25. 二進制
      hpc_ai/PINN/English/python/jupyter_notebook/introduction/single_parabola.png
  26. 606 0
      hpc_ai/PINN/English/python/jupyter_notebook/spring_mass/Spring_Mass_Problem_Notebook.ipynb
  27. 二進制
      hpc_ai/PINN/English/python/jupyter_notebook/spring_mass/__pycache__/spring_mass_ode.cpython-38.pyc
  28. 二進制
      hpc_ai/PINN/English/python/jupyter_notebook/spring_mass/comparison.png
  29. 二進制
      hpc_ai/PINN/English/python/jupyter_notebook/spring_mass/comparison_spring_mass.png
  30. 二進制
      hpc_ai/PINN/English/python/jupyter_notebook/spring_mass/spring_mass_drawing.png
  31. 79 0
      hpc_ai/PINN/English/python/source_code/chip_2d/chip_2d_inverse_template.py
  32. 170 0
      hpc_ai/PINN/English/python/source_code/chip_2d/chip_2d_parameterized_template.py
  33. 143 0
      hpc_ai/PINN/English/python/source_code/chip_2d/chip_2d_template.py
  34. 56943 0
      hpc_ai/PINN/English/python/source_code/chip_2d/openfoam/2D_chip_fluid0.csv
  35. 27 0
      hpc_ai/PINN/English/python/source_code/chip_2d/sample_plotting_script.py
  36. 242 0
      hpc_ai/PINN/English/python/source_code/diffusion_1d/diffusion_bar.py
  37. 253 0
      hpc_ai/PINN/English/python/source_code/diffusion_1d/diffusion_bar_paramaterized.py
  38. 2 0
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/checkpoint
  39. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/events.out.tfevents.1614704654.2530984d8521
  40. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/model.ckpt-2000.data-00000-of-00001
  41. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/model.ckpt-2000.index
  42. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/model.ckpt-2000.meta
  43. 3 0
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/monitor_domain/results/FluxU1.csv
  44. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/monitor_domain/results/FluxU1.png
  45. 3 0
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/monitor_domain/results/FluxU2.csv
  46. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/monitor_domain/results/FluxU2.png
  47. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interface1n2_diff.npz
  48. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interface1n2_diff.vtu
  49. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interface1n2_pred.npz
  50. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interface1n2_pred.vtu
  51. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interface1n2_true.npz
  52. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interface1n2_true.vtu
  53. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior1_diff.npz
  54. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior1_diff.vtu
  55. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior1_pred.npz
  56. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior1_pred.vtu
  57. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior1_true.npz
  58. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior1_true.vtu
  59. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior2_diff.npz
  60. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior2_diff.vtu
  61. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior2_pred.npz
  62. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior2_pred.vtu
  63. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior2_true.npz
  64. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior2_true.vtu
  65. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/LeftHandSide_diff.npz
  66. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/LeftHandSide_diff.vtu
  67. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/LeftHandSide_pred.npz
  68. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/LeftHandSide_pred.vtu
  69. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/LeftHandSide_true.npz
  70. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/LeftHandSide_true.vtu
  71. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/RightHandSide_diff.npz
  72. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/RightHandSide_diff.vtu
  73. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/RightHandSide_pred.npz
  74. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/RightHandSide_pred.vtu
  75. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/RightHandSide_true.npz
  76. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/RightHandSide_true.vtu
  77. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val1_diff.npz
  78. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val1_diff.vtu
  79. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val1_pred.npz
  80. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val1_pred.vtu
  81. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val1_true.npz
  82. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val1_true.vtu
  83. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val2_diff.npz
  84. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val2_diff.vtu
  85. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val2_pred.npz
  86. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val2_pred.vtu
  87. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val2_true.npz
  88. 二進制
      hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val2_true.vtu
  89. 25 0
      hpc_ai/PINN/English/python/source_code/diffusion_1d/plot_results.py
  90. 25 0
      hpc_ai/PINN/English/python/source_code/diffusion_1d/plot_results_parameterized.py
  91. 二進制
      hpc_ai/PINN/English/python/source_code/spring_mass/__pycache__/spring_mass_ode.cpython-38.pyc
  92. 28 0
      hpc_ai/PINN/English/python/source_code/spring_mass/plot_results_spring.py
  93. 96 0
      hpc_ai/PINN/English/python/source_code/spring_mass/spring_mass_inverse.py
  94. 62 0
      hpc_ai/PINN/English/python/source_code/spring_mass/spring_mass_ode.py
  95. 85 0
      hpc_ai/PINN/English/python/source_code/spring_mass/spring_mass_solver.py
  96. 38 0
      hpc_ai/PINN/README.MD

+ 45 - 0
hpc_ai/PINN/English/python/Start_Here.ipynb

@@ -0,0 +1,45 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Welcome to AI for Science Bootcamp using SimNet\n",
+    "\n",
+    "The objective of this bootcamp is to provide fundamental difference between Data driven and Physics Driven approach  to using Artificial Intelligence (AI) algorithms in Science ( High Performance Computing(HPC) Simulations ). \n",
+    "\n",
+    "This bootcamp will introduce participants to Physics Informed Neural Network ( PINN ) with help of Nvidia toolkit SimNet.\n",
+    "\n",
+    "1. [Introduction](jupyter_notebook/introduction/Introductory_Notebook.ipynb) : In this notebook we will see the advantages of Physics Informed modeling over data-driven modeling and will also outline the brief theory about Physics Informed Neural Networks (PINNs).\n",
+    "\n",
+    "2. [Solving PDEs using PINNs](jupyter_notebook/diffusion_1d/Diffusion_Problem_Notebook.ipynb)  : This notebook give you a headstart in solving your own Partial Differential Equations (PDEs) using neural networks. You will also see how to solve parameterized PDEs. \n",
+    "\n",
+    "3. [Solving transient problems and inverse problems](jupyter_notebook/spring_mass/Spring_Mass_Problem_Notebook.ipynb) : In this tutorial we will see how to solve the transient problems over small time intervals easily by treating time as a continuous variable. We will also cover how to solve inverse problems. \n",
+    "\n",
+    "4. [Challenge](jupyter_notebook/chip_2d/Challenge_CFD_Problem_Notebook.ipynb) : A small exercise to solve  a fluid mechanics problem involving solution to the Navier Stokes equations.\n",
+    "\n"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 45 - 0
hpc_ai/PINN/English/python/jupyter_notebook/Start_Here.ipynb

@@ -0,0 +1,45 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Welcome to AI for Science Bootcamp using SimNet\n",
+    "\n",
+    "The objective of this bootcamp is to provide fundamental difference between Data driven and Physics Driven approach  to using Artificial Intelligence (AI) algorithms in Science ( High Performance Computing(HPC) Simulations ). \n",
+    "\n",
+    "This bootcamp will introduce participants to Physics Informed Neural Network ( PINN ) with help of Nvidia toolkit SimNet.\n",
+    "\n",
+    "1. [Introduction](introduction/Introductory_Notebook.ipynb) : In this notebook we will see the advantages of Physics Informed modeling over data-driven modeling and will also outline the brief theory about Physics Informed Neural Networks (PINNs).\n",
+    "\n",
+    "2. [Solving PDEs using PINNs](diffusion_1d/Diffusion_Problem_Notebook.ipynb)  : This notebook give you a headstart in solving your own Partial Differential Equations (PDEs) using neural networks. You will also see how to solve parameterized PDEs. \n",
+    "\n",
+    "3. [Solving transient problems and inverse problems](spring_mass/Spring_Mass_Problem_Notebook.ipynb) : In this tutorial we will see how to solve the transient problems over small time intervals easily by treating time as a continuous variable. We will also cover how to solve inverse problems. \n",
+    "\n",
+    "4. [Challenge](chip_2d/Challenge_CFD_Problem_Notebook.ipynb) : A small exercise to solve  a fluid mechanics problem involving solution to the Navier Stokes equations.\n",
+    "\n"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.6.2"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

文件差異過大導致無法顯示
+ 360 - 0
hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/Challenge_1_template.ipynb


文件差異過大導致無法顯示
+ 356 - 0
hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/Challenge_2_template.ipynb


+ 187 - 0
hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/Challenge_3_template.ipynb

@@ -0,0 +1,187 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Problem Statement\n",
+    "\n",
+    "Use PINNs along with the OpenFOAM data to solve the inverse problem of finding the viscosity of the flow, given the flow field data\n",
+    "\n",
+    "## Challenge\n",
+    "\n",
+    "The main challenge in this problem is to correctly formulate the problem using PINNs. In order to achieve that, you will have to complete the following parts successfully:\n",
+    "1. Assimilate the OpenFOAM data\n",
+    "2. Set-up the correct equation residuals to miminize\n",
+    "3. Create the neural network and solve the inverse problem\n",
+    "\n",
+    "The viscosity in the OpenFOAM simulation was set to $0.02 \\text{ }m^2/s$. A successful completion of the problem should result in infering out the same viscosity within 10% error margin. The OpenFOAM data that was used for validation in the previous parts would now be used as a training input. "
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "Let us start by importing the required packages and modules\n",
+    "\n",
+    "**Note: You need to edit the `chip_2d_inverse_template.py` script that is placed in the ../source_code/chip_2d/ directory.**\n",
+    "\n",
+    "From the top menu, click on File, and Open `chip_2d_inverse_template.py` from the current directory at `../source_code/chip_2d` directory. Remember to SAVE your code after changes, before running below cells."
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "```python\n",
+    "from sympy import Symbol\n",
+    "import numpy as np\n",
+    "import tensorflow as tf\n",
+    "from simnet.solver import Solver\n",
+    "from simnet.dataset import TrainDomain, ValidationDomain, MonitorDomain\n",
+    "from simnet.data import Validation, Monitor, BC\n",
+    "from simnet.sympy_utils.geometry_2d import Rectangle, Line, Channel2D\n",
+    "from simnet.sympy_utils.functions import parabola\n",
+    "from simnet.csv_utils.csv_rw import csv_to_dict\n",
+    "from simnet.PDES.navier_stokes import IntegralContinuity, NavierStokes\n",
+    "from simnet.controller import SimNetController\n",
+    "from simnet.architecture import FourierNetArch\n",
+    "```"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "For this problem, since we are interested in only assimilating the OpenFOAM data and getting the inference out of it, you do not need create the geometry. Fill in the `Chip2DTrain` based on the data generated from OpenFOAM. Remember to add appropriate keys to the dataset to solve for the correct equations. "
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "```python\n",
+    "#TODO: Replace all the placeholders with appropriate values\n",
+    "\n",
+    "# define sympy variables to parametrize domain curves\n",
+    "x, y = Symbol('x'), Symbol('y')\n",
+    "\n",
+    "# OpenFOAM data\n",
+    "mapping = {'Points:0': 'x', 'Points:1': 'y',\n",
+    "           'U:0': 'u', 'U:1': 'v', 'p': 'p'}\n",
+    "openfoam_var = csv_to_dict('openfoam/2D_chip_fluid0.csv', mapping)\n",
+    "openfoam_var['x'] -= 2.5 # normalize pos\n",
+    "openfoam_var['y'] -= 0.5\n",
+    "openfoam_invar_numpy = {key: value for key, value in openfoam_var.items() if key in ['x', 'y']}\n",
+    "openfoam_outvar_numpy = {key: value for key, value in openfoam_var.items() if key in ['u', 'v', 'p']}\n",
+    "\n",
+    "#TODO: Add keys and appropriate values for continuity and momentum equations in x and y directions here:\n",
+    "openfoam_outvar_numpy['continuity'] = placeholder\n",
+    "openfoam_outvar_numpy['momentum_x'] = placeholder\n",
+    "openfoam_outvar_numpy['momentum_y'] = placeholder\n",
+    "\n",
+    "class Chip2DTrain(TrainDomain):\n",
+    "  def __init__(self, **config):\n",
+    "    super(Chip2DTrain, self).__init__()\n",
+    "    \n",
+    "    # fill in the appropriate parameters for the from_numpy function\n",
+    "    interior=BC.from_numpy(placeholder, placeholder, batch_size=placeholder)\n",
+    "    self.add(interior, name=\"Interior\")\n",
+    "```"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "Create a `MonitorDomain` to monitor the average viscosity predicted by the model "
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "```python\n",
+    "class Chip2DMonitor(MonitorDomain):\n",
+    "  def __init__(self, **config):\n",
+    "    super(Chip2DMonitor, self).__init__()\n",
+    "    \n",
+    "    global_monitor = Monitor(openfoam_invar_numpy, {'average_nu': lambda var: tf.reduce_mean(var['nu'])})\n",
+    "    self.add(global_monitor, 'GlobalMonitor')\n",
+    "```"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "Now complete the last part of the code by creating the `ChipSolver` to solve our problem. Don't forget to stop the gradients for appropriate variables while setting the equations. "
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "```python\n",
+    "#TODO: Replace all the placeholders with appropriate values\n",
+    "class ChipSolver(Solver):\n",
+    "  train_domain = placeholder\n",
+    "  monitor_domain = placeholder\n",
+    "\n",
+    "  def __init__(self, **config):\n",
+    "    super(ChipSolver, self).__init__(**config)\n",
+    "\n",
+    "    self.equations = (NavierStokes(nu=placeholder, rho=1, dim=2, time=False).make_node(stop_gradients=[placeholder]))\n",
+    "\n",
+    "    flow_net = self.arch.make_node(name='flow_net',\n",
+    "                                   inputs=['x', 'y'],\n",
+    "                                   outputs=['u', 'v', 'p'])\n",
+    "    invert_net = self.arch.make_node(name='invert_net',\n",
+    "                                     inputs=['x', 'y'],\n",
+    "                                     outputs=['nu'])\n",
+    "    self.nets = [flow_net, invert_net]\n",
+    "\n",
+    "  @classmethod\n",
+    "  def update_defaults(cls, defaults):\n",
+    "    defaults.update({\n",
+    "        'network_dir': './network_checkpoint_chip_2d_inverse',\n",
+    "        'rec_results': True,\n",
+    "        'rec_results_freq': 100,\n",
+    "        'start_lr': 3e-4,\n",
+    "        'max_steps': 40000,\n",
+    "        'decay_steps': 100,\n",
+    "        'xla': True\n",
+    "        })\n",
+    "if __name__ == '__main__':\n",
+    "  ctr = SimNetController(ChipSolver)\n",
+    "  ctr.run()\n",
+    "```\n",
+    "\n",
+    "\n",
+    "# Licensing\n",
+    "This material is released by NVIDIA Corporation under the Creative Commons Attribution 4.0 International (CC BY 4.0)"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.6.2"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 99 - 0
hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/Challenge_CFD_Problem_Notebook.ipynb

@@ -0,0 +1,99 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "     \n",
+    "     \n",
+    "     \n",
+    "     \n",
+    "   \n",
+    "[Home Page](../../Start_Here.ipynb)\n",
+    "\n",
+    "[Previous Notebook](../spring_mass/Spring_Mass_Problem_Notebook.ipynb)\n",
+    "     \n",
+    "     \n",
+    "     \n",
+    "     \n",
+    "   \n",
+    "[1](../introduction/Introductory_Notebook.ipynb)\n",
+    "[2](../diffusion_1d/Diffusion_Problem_Notebook.ipynb)\n",
+    "[3](../spring_mass/Spring_Mass_Problem_Notebook.ipynb)\n",
+    "[4]\n",
+    "   \n",
+    "\n",
+    "\n",
+    "# Steady State 2D Laminar Flow over a Chip"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "Now that you are familiar with the PINNs and the SimNet library, let's solve a fluid mechanics problem involving solution to the Navier Stokes equations. The problem is defined as follows:\n",
+    "\n",
+    "A 2D chip is placed inside a 2D channel. The flow enters inlet (a parabolic profile is used with $u_{max}=1.5\\text{ m/s}$) and exits through the outlet which is a $0 Pa$. All the other walls are treated as no-slip. The kinematic viscosity $(\\nu)$ for the flow is $0.02 \\text{ }m^2/s$ and the density $(\\rho)$ is $1 \\text{ }kg/m^3$. The problem is shown in the figure below.\n",
+    "\n",
+    "<img src=\"chip_2d_geom.png\" alt=\"Drawing\" style=\"width: 800px;\"/>"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "### Objectives \n",
+    "The objectives of this problem are following:\n",
+    "1. [Fluid Flow](Challenge_1_template.ipynb) Use PINNs to solve the fluid flow for the given geometry and flow parameters\n",
+    "2. [Parameterized](Challenge_2_template.ipynb)Use PINNs to solve the parameterized problem by varying the chip's geometry (width and height)\n",
+    "3. [Inverse Problem](Challenge_3_template.ipynb)Use PINNs along with the OpenFOAM data to solve the inverse problem of finding the viscosity of the flow, given the flow field data \n",
+    "\n",
+    "\n",
+    "\n",
+    "# Licensing\n",
+    "This material is released by NVIDIA Corporation under the Creative Commons Attribution 4.0 International (CC BY 4.0)\n",
+    "\n",
+    "\n",
+    "&emsp;&emsp;&emsp;&emsp;&emsp;\n",
+    "&emsp;&emsp;&emsp;&emsp;&emsp;\n",
+    "&emsp;&emsp;&emsp;&emsp;&emsp;\n",
+    "&emsp;&emsp;&emsp;&emsp;&emsp;\n",
+    "&emsp;&emsp;&ensp;\n",
+    "[Home Page](../../Start_Here.ipynb)\n",
+    "\n",
+    "[Previous Notebook](../spring_mass/Spring_Mass_Problem_Notebook.ipynb)\n",
+    "&emsp;&emsp;&emsp;&emsp;&emsp;\n",
+    "&emsp;&emsp;&emsp;&emsp;&emsp;\n",
+    "&emsp;&emsp;&emsp;&emsp;&emsp;\n",
+    "&emsp;&emsp;&emsp;&emsp;&emsp;\n",
+    "&emsp;&emsp;&ensp;\n",
+    "[1](../introduction/Introductory_Notebook.ipynb)\n",
+    "[2](../diffusion_1d/Diffusion_Problem_Notebook.ipynb)\n",
+    "[3](../spring_mass/Spring_Mass_Problem_Notebook.ipynb)\n",
+    "[4]\n",
+    "   "
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

二進制
hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/challenge_results.png


二進制
hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/challenge_results_param_updated.png


二進制
hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/chip_2d_geom.png


二進制
hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/chip_2d_parameterized.png


二進制
hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/multi_GPU_1.png


二進制
hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/multi_GPU_2.png


文件差異過大導致無法顯示
+ 56943 - 0
hpc_ai/PINN/English/python/jupyter_notebook/chip_2d/openfoam/2D_chip_fluid0.csv


文件差異過大導致無法顯示
+ 877 - 0
hpc_ai/PINN/English/python/jupyter_notebook/diffusion_1d/Diffusion_Problem_Notebook.ipynb


二進制
hpc_ai/PINN/English/python/jupyter_notebook/diffusion_1d/diffusion_bar_geometry.png


二進制
hpc_ai/PINN/English/python/jupyter_notebook/diffusion_1d/image_diffusion_problem_bootcamp.png


二進制
hpc_ai/PINN/English/python/jupyter_notebook/diffusion_1d/image_diffusion_problem_bootcamp_parameterized.png


二進制
hpc_ai/PINN/English/python/jupyter_notebook/diffusion_1d/image_tensorboard.png


文件差異過大導致無法顯示
+ 214 - 0
hpc_ai/PINN/English/python/jupyter_notebook/introduction/Introductory_Notebook.ipynb


二進制
hpc_ai/PINN/English/python/jupyter_notebook/introduction/SimNet_v21.06_User_Guide.pdf


二進制
hpc_ai/PINN/English/python/jupyter_notebook/introduction/every_parabola.png


二進制
hpc_ai/PINN/English/python/jupyter_notebook/introduction/image_data_driven_cons.png


二進制
hpc_ai/PINN/English/python/jupyter_notebook/introduction/inverse_parabola.png


二進制
hpc_ai/PINN/English/python/jupyter_notebook/introduction/inverse_parabola_2.png


二進制
hpc_ai/PINN/English/python/jupyter_notebook/introduction/single_parabola.png


文件差異過大導致無法顯示
+ 606 - 0
hpc_ai/PINN/English/python/jupyter_notebook/spring_mass/Spring_Mass_Problem_Notebook.ipynb


二進制
hpc_ai/PINN/English/python/jupyter_notebook/spring_mass/__pycache__/spring_mass_ode.cpython-38.pyc


二進制
hpc_ai/PINN/English/python/jupyter_notebook/spring_mass/comparison.png


二進制
hpc_ai/PINN/English/python/jupyter_notebook/spring_mass/comparison_spring_mass.png


二進制
hpc_ai/PINN/English/python/jupyter_notebook/spring_mass/spring_mass_drawing.png


+ 79 - 0
hpc_ai/PINN/English/python/source_code/chip_2d/chip_2d_inverse_template.py

@@ -0,0 +1,79 @@
+from sympy import Symbol
+import numpy as np
+import tensorflow as tf
+from simnet.solver import Solver
+from simnet.dataset import TrainDomain, ValidationDomain, MonitorDomain
+from simnet.data import Validation, Monitor, BC
+from simnet.sympy_utils.geometry_2d import Rectangle, Line, Channel2D
+from simnet.sympy_utils.functions import parabola
+from simnet.csv_utils.csv_rw import csv_to_dict
+from simnet.PDES.navier_stokes import IntegralContinuity, NavierStokes
+from simnet.controller import SimNetController
+from simnet.architecture import FourierNetArch
+
+#TODO: Replace all the placeholders with appropriate values
+
+# define sympy variables to parametrize domain curves
+x, y = Symbol('x'), Symbol('y')
+
+# OpenFOAM data
+mapping = {'Points:0': 'x', 'Points:1': 'y',
+           'U:0': 'u', 'U:1': 'v', 'p': 'p'}
+openfoam_var = csv_to_dict('openfoam/2D_chip_fluid0.csv', mapping)
+openfoam_var['x'] -= 2.5 # normalize pos
+openfoam_var['y'] -= 0.5
+openfoam_invar_numpy = {key: value for key, value in openfoam_var.items() if key in ['x', 'y']}
+openfoam_outvar_numpy = {key: value for key, value in openfoam_var.items() if key in ['u', 'v', 'p']}
+
+#TODO: Add keys and appropriate values for continuity and momentum equations in x and y directions here:
+openfoam_outvar_numpy['continuity'] = placeholder
+openfoam_outvar_numpy['momentum_x'] = placeholder
+openfoam_outvar_numpy['momentum_y'] = placeholder
+
+class Chip2DTrain(TrainDomain):
+  def __init__(self, **config):
+    super(Chip2DTrain, self).__init__()
+
+    # fill in the appropriate parameters for the from_numpy function
+    interior=BC.from_numpy(placeholder, placeholder, batch_size=placeholder)
+    self.add(interior, name="Interior")
+
+class Chip2DMonitor(MonitorDomain):
+  def __init__(self, **config):
+    super(Chip2DMonitor, self).__init__()
+
+    global_monitor = Monitor(openfoam_invar_numpy, {'average_nu': lambda var: tf.reduce_mean(var['nu'])})
+    self.add(global_monitor, 'GlobalMonitor')
+
+#TODO: Replace all the placeholders with appropriate values
+class ChipSolver(Solver):
+  train_domain = placeholder
+  monitor_domain = placeholder
+
+  def __init__(self, **config):
+    super(ChipSolver, self).__init__(**config)
+
+    self.equations = (NavierStokes(nu=placeholder, rho=1, dim=2, time=False).make_node(stop_gradients=[placeholder]))
+
+    flow_net = self.arch.make_node(name='flow_net',
+                                   inputs=['x', 'y'],
+                                   outputs=['u', 'v', 'p'])
+    invert_net = self.arch.make_node(name='invert_net',
+                                     inputs=['x', 'y'],
+                                     outputs=['nu'])
+    self.nets = [flow_net, invert_net]
+
+  @classmethod
+  def update_defaults(cls, defaults):
+    defaults.update({
+        'network_dir': './network_checkpoint_chip_2d_inverse',
+        'rec_results': True,
+        'rec_results_freq': 100,
+        'start_lr': 3e-4,
+        'max_steps': 40000,
+        'decay_steps': 100,
+        'xla': True
+        })
+if __name__ == '__main__':
+  ctr = SimNetController(ChipSolver)
+  ctr.run()

+ 170 - 0
hpc_ai/PINN/English/python/source_code/chip_2d/chip_2d_parameterized_template.py

@@ -0,0 +1,170 @@
+from sympy import Symbol
+import numpy as np
+import tensorflow as tf
+from simnet.solver import Solver
+from simnet.dataset import TrainDomain, ValidationDomain, InferenceDomain
+from simnet.data import Validation, Inference
+from simnet.sympy_utils.geometry_2d import Rectangle, Line, Channel2D
+from simnet.sympy_utils.functions import parabola
+from simnet.csv_utils.csv_rw import csv_to_dict
+from simnet.PDES.navier_stokes import IntegralContinuity, NavierStokes
+from simnet.controller import SimNetController
+from simnet.architecture import FourierNetArch
+from simnet.learning_rate import ExponentialDecayLRWithWarmup
+
+# simulation params
+channel_length = (-2.5, 2.5)
+channel_width = (-0.5, 0.5)
+chip_pos = -1.0
+#chip_height = 0.6         # Not fixed anymore
+#chip_width = 1.0          # Not fixed anymore
+inlet_vel = 1.5
+
+# paramteric variables
+chip_height = Symbol('chip_height')
+chip_width = Symbol('chip_width')
+
+chip_height_range = (0.4, 0.8)
+chip_width_range  = (0.6, 1.4)
+
+param_ranges = {chip_height: chip_height_range,
+                chip_width: chip_width_range}
+
+#TODO: Replace all the placeholders with appropriate geometry constructions
+# define geometry here
+# you may use the geometry generated in the previous challenge problem as a reference
+
+channel = placeholder
+# define inlet and outlet
+inlet = placeholder
+outlet = placeholder
+# define the chip
+rec = placeholder
+# create a geometry for higher sampling of point cloud near the fin
+flow_rec = placeholder
+
+# fluid area
+geo = placeholder
+geo_hr = placeholder
+geo_lr = placeholder
+
+x_pos = Symbol('x_pos')
+integral_line = placeholder
+x_pos_range = {x_pos: lambda batch_size: np.full((batch_size, 1), np.random.uniform(channel_length[0], channel_length[1]))}
+
+#TODO: Replace all the placeholders with appropriate values
+
+# define sympy variables to parametrize domain curves
+x, y = Symbol('x'), Symbol('y')
+
+class Chip2DTrain(TrainDomain):
+  def __init__(self, **config):
+    super(Chip2DTrain, self).__init__()
+
+    # inlet
+    inlet_parabola = parabola(y, channel_width[0], channel_width[1], inlet_vel)
+    inlet_bc = inlet.boundary_bc(outvar_sympy={'u': inlet_parabola, 'v': 0},
+                                 batch_size_per_area=64,
+                                 param_ranges=param_ranges)
+    self.add(inlet_bc, name="Inlet")
+
+    # outlet
+    outlet_bc = outlet.boundary_bc(outvar_sympy={placeholder},
+                                   batch_size_per_area=placeholder,
+                                   param_ranges=placeholder)
+    self.add(outlet_bc, name="Outlet")
+
+    # noslip
+    noslip = geo.boundary_bc(outvar_sympy={placeholder},
+                             batch_size_per_area=placeholder,
+                             param_ranges=placeholder)
+    self.add(noslip, name="ChipNS")
+
+    # interior lr
+    interior_lr = geo_lr.interior_bc(outvar_sympy={placeholder},
+                                     bounds={placeholder},
+                                     lambda_sympy={placeholder},
+                                     batch_size_per_area=placeholder,
+                                     param_ranges=placeholder)
+    self.add(interior_lr, name="InteriorLR")
+
+    # interior hr
+    interior_hr = geo_hr.interior_bc(outvar_sympy={placeholder},
+                                     bounds={placeholder},
+                                     lambda_sympy={placeholder},
+                                     batch_size_per_area=placeholder,
+                                     param_ranges=placeholder)
+    self.add(interior_hr, name="InteriorHR")
+
+
+    # integral continuity
+    for i in range(4):
+      IC = integral_line.boundary_bc(outvar_sympy={placeholder},
+                                     batch_size_per_area=placeholder,
+                                     lambda_sympy={placeholder},
+                                     criteria=placeholder,
+                                     param_ranges={placeholder},
+                                     fixed_var=placeholder)
+      self.add(IC, name="IntegralContinuity_"+str(i))
+
+# validation data
+mapping = {'Points:0': 'x', 'Points:1': 'y',
+           'U:0': 'u', 'U:1': 'v', 'p': 'p'}
+openfoam_var = csv_to_dict('openfoam/2D_chip_fluid0.csv', mapping)
+openfoam_var['x'] -= 2.5 # normalize pos
+openfoam_var['y'] -= 0.5
+
+#TODO: Add the arrays for 'chip_height' and 'chip_width'
+
+openfoam_invar_numpy = {key: value for key, value in openfoam_var.items() if key in ['x', 'y', 'chip_height', 'chip_width']}
+openfoam_outvar_numpy = {key: value for key, value in openfoam_var.items() if key in ['u', 'v', 'p']}
+
+class Chip2DVal(ValidationDomain):
+  def __init__(self, **config):
+    super(Chip2DVal, self).__init__()
+    val = Validation.from_numpy(openfoam_invar_numpy, openfoam_outvar_numpy)
+    self.add(val, name='Val')
+
+class Chip2DInf(InferenceDomain):
+  def __init__(self, **config):
+    super(Chip2DInf, self).__init__()
+    inf = Inference(geo.sample_interior(2048, bounds={x: channel_length, y: channel_width}, 
+                                        param_ranges={chip_height: 0.4, chip_width: 1.4}),
+                    ['u', 'v', 'p'])
+    self.add(inf, name='Inference')
+
+#TODO: Replace all the placeholders with appropriate values
+class ChipSolver(Solver):
+  train_domain = placeholder
+  val_domain = placeholder
+  arch = FourierNetArch
+  lr = ExponentialDecayLRWithWarmup
+  inference_domain = placeholder
+
+  def __init__(self, **config):
+    super(ChipSolver, self).__init__(**config)
+
+    self.frequencies = ('axis,diagonal', [i/5. for i in range(25)]) 
+
+    self.equations = (placeholder)
+    flow_net = self.arch.make_node(name='flow_net',
+                                   inputs=[placeholder],
+                                   outputs=[placeholder])
+    self.nets = [flow_net]
+
+  @classmethod
+  def update_defaults(cls, defaults):
+    defaults.update({
+        'network_dir': './network_checkpoint_chip_2d_parameterized',
+        'rec_results': True,
+        'rec_results_freq': 5000,
+        'max_steps': 20000,
+        'decay_steps': 400,
+        'warmup_type': 'gradual',
+        'warmup_steps': 2000,
+        'xla': True
+        })
+if __name__ == '__main__':
+  ctr = SimNetController(ChipSolver)
+  ctr.run()
+

+ 143 - 0
hpc_ai/PINN/English/python/source_code/chip_2d/chip_2d_template.py

@@ -0,0 +1,143 @@
+from sympy import Symbol
+import numpy as np
+import tensorflow as tf
+from simnet.solver import Solver
+from simnet.dataset import TrainDomain, ValidationDomain
+from simnet.data import Validation
+from simnet.sympy_utils.geometry_2d import Rectangle, Line, Channel2D
+from simnet.sympy_utils.functions import parabola
+from simnet.csv_utils.csv_rw import csv_to_dict
+from simnet.PDES.navier_stokes import IntegralContinuity, NavierStokes
+from simnet.controller import SimNetController
+from simnet.architecture import FourierNetArch
+
+# simulation params
+channel_length = (-2.5, 2.5)
+channel_width = (-0.5, 0.5)
+chip_pos = -1.0
+chip_height = 0.6
+chip_width = 1.0
+inlet_vel = 1.5
+#TODO: Replace x1, y1, x2, y2, and X's with appropriate values
+
+# define geometry
+# define channel
+channel = Channel2D((x1, y1), (x2, y2))
+# define inlet and outlet
+inlet = Line((x1, y1), (x1, y2), normal= X)
+outlet = Line((x1, y1), (x1, y2), normal= X)
+# define the chip
+rec = Rectangle((x1, y1), (x2, y2))
+# create a geometry for higher sampling of point cloud near the fin
+flow_rec = Rectangle((chip_pos-0.25, channel_width[0]),
+                     (chip_pos+chip_width+0.25, channel_width[1]))
+# fluid area
+geo = channel - rec
+geo_hr = geo & flow_rec
+geo_lr = geo - flow_rec
+
+# Optional integral continuity planes to speed up convergence
+x_pos = Symbol('x_pos')
+integral_line = Line((x_pos, channel_width[0]),
+                     (x_pos, channel_width[1]),
+                     1)
+x_pos_range = {x_pos: lambda batch_size: np.full((batch_size, 1), np.random.uniform(channel_length[0], channel_length[1]))}
+
+# TODO: Replace all the placeholders with appropriate values
+
+# define sympy variables to parametrize domain curves
+x, y = Symbol('x'), Symbol('y')
+
+class Chip2DTrain(TrainDomain):
+  def __init__(self, **config):
+    super(Chip2DTrain, self).__init__()
+
+    # inlet
+    inlet_parabola = parabola(y, channel_width[0], channel_width[1], inlet_vel)
+    inlet_bc = inlet.boundary_bc(outvar_sympy={'u': inlet_parabola, 'v': 0},
+                                 batch_size_per_area=64)
+    self.add(inlet_bc, name="Inlet")
+
+    # outlet
+    outlet_bc = outlet.boundary_bc(outvar_sympy={placeholder},
+                                   batch_size_per_area=placeholder)
+    self.add(outlet_bc, name="Outlet")
+
+    # noslip
+    noslip = geo.boundary_bc(outvar_sympy={placeholder},
+                             batch_size_per_area=placeholder)
+    self.add(noslip, name="ChipNS")
+
+    # interior lr
+    interior_lr = geo_lr.interior_bc(outvar_sympy={placeholder},
+                                     bounds={placeholder},
+                                     lambda_sympy={placeholder},
+                                     batch_size_per_area=placeholder)
+    self.add(interior_lr, name="InteriorLR")
+
+    # interior hr
+    interior_hr = geo_hr.interior_bc(outvar_sympy=placeholder,
+                                     bounds=placeholder,
+                                     lambda_sympy=placeholder,
+                                     batch_size_per_area=placeholder)
+    self.add(interior_hr, name="InteriorHR")
+
+
+    # integral continuity
+    for i in range(4):
+      IC = integral_line.boundary_bc(outvar_sympy={'integral_continuity': 1.0},
+                                     batch_size_per_area=512,
+                                     lambda_sympy={'lambda_integral_continuity': 1.0},
+                                     criteria=geo.sdf>0,
+                                     param_ranges=x_pos_range,
+                                     fixed_var=False)
+      self.add(IC, name="IntegralContinuity_"+str(i))
+
+# TODO: Set the appropriate normalization for the validation data
+# The validation data has domain extents of (0,0) to (5,1). Normalize this based on your definition of the domain
+
+# validation data
+mapping = {'Points:0': 'x', 'Points:1': 'y',
+           'U:0': 'u', 'U:1': 'v', 'p': 'p'}
+openfoam_var = csv_to_dict('openfoam/2D_chip_fluid0.csv', mapping)
+openfoam_var['x'] -= 2.5 #TODO Samle normalization of position. Edit based on your geometry definition
+openfoam_var['y'] -= 0.5
+openfoam_invar_numpy = {key: value for key, value in openfoam_var.items() if key in ['x', 'y']}
+openfoam_outvar_numpy = {key: value for key, value in openfoam_var.items() if key in ['u', 'v', 'p']}
+
+class Chip2DVal(ValidationDomain):
+  def __init__(self, **config):
+    super(Chip2DVal, self).__init__()
+    val = Validation.from_numpy(placeholder)
+    self.add(val, name='Val')
+
+#TODO: Replace all the placeholders with appropriate values
+class ChipSolver(Solver):
+  train_domain = placeholder
+  val_domain = placeholder
+  arch = FourierNetArch
+
+  def __init__(self, **config):
+    super(ChipSolver, self).__init__(**config)
+
+    self.frequencies = ('axis,diagonal', [i/5. for i in range(25)]) 
+
+    self.equations = (placeholder)
+    flow_net = self.arch.make_node(name='flow_net',
+                                   inputs=[placeholder],
+                                   outputs=[placeholder])
+    self.nets = [flow_net]
+
+  @classmethod
+  def update_defaults(cls, defaults):
+    defaults.update({
+        'network_dir': './network_checkpoint_chip_2d',
+        'rec_results': True,
+        'rec_results_freq': 5000,
+        'max_steps': 10000,
+        'decay_steps': 100,
+        'xla': True
+        })
+if __name__ == '__main__':
+  ctr = SimNetController(ChipSolver)
+  ctr.run()

文件差異過大導致無法顯示
+ 56943 - 0
hpc_ai/PINN/English/python/source_code/chip_2d/openfoam/2D_chip_fluid0.csv


+ 27 - 0
hpc_ai/PINN/English/python/source_code/chip_2d/sample_plotting_script.py

@@ -0,0 +1,27 @@
+# template script to create some easy plots for the chip problem
+import numpy as np
+import matplotlib.pyplot as plt
+
+import simnet as sn
+
+# set the path for the .npz files
+base_dir = 'network_checkpoint_chip_2d/val_domain/results/'
+
+# load the .npz files
+pred_data = np.load(base_dir + 'Val_pred.npz', allow_pickle=True)
+true_data = np.load(base_dir + 'Val_true.npz', allow_pickle=True)
+
+pred_data = np.atleast_1d(pred_data.f.arr_0)[0]
+true_data = np.atleast_1d(true_data.f.arr_0)[0]
+
+# remove the variables created for parameterization (uncomment when visualizing parameteric results)
+#pred_data.pop('chip_width')
+#pred_data.pop('chip_height')
+#true_data.pop('chip_width')
+#true_data.pop('chip_height')
+
+# plot only one set of variables
+sn.plot_utils.field.plot_field(pred_data, 'chip_predicted', coordinates=['x', 'y'], resolution=256)
+
+# plot the comparison between a set of variables
+sn.plot_utils.field.plot_field_compare(true_data, pred_data, 'chip_comparison', coordinates=['x', 'y'], resolution=256)

+ 242 - 0
hpc_ai/PINN/English/python/source_code/diffusion_1d/diffusion_bar.py

@@ -0,0 +1,242 @@
+# import SimNet library
+from sympy import Symbol, sin, Eq, Abs, exp
+import numpy as np
+import sys
+sys.path.append('../../')
+from simnet.solver import Solver
+from simnet.dataset import TrainDomain, ValidationDomain, MonitorDomain
+from simnet.data import Validation, BC, Monitor
+from simnet.sympy_utils.geometry_1d import Line1D
+#from simnet.PDES.diffusion import Diffusion
+from simnet.controller import SimNetController
+from simnet.node import Node
+from simnet.pdes import PDES
+import tensorflow as tf
+from sympy import Symbol, Function, Number
+
+from simnet.pdes import PDES
+from simnet.node import Node
+from simnet.variables import Variables
+
+
+# params for domain
+L1 = Line1D(0,1)
+L2 = Line1D(1,2)
+
+D1 = 1e1
+D2 = 1e-1
+
+Tc = 100
+Ta = 0
+Tb = (Tc + (D1/D2)*Ta)/(1 + (D1/D2))
+
+#Tb = Tc - u_1__x*D1/D2 
+#Ta = Tb - u_1__x
+print(Ta)
+print(Tb)
+print(Tc)
+#exit()
+
+class Diffusion(PDES):
+  name = 'Diffusion'
+ 
+  def __init__(self, T='T', D='D', Q=0, dim=3, time=True):
+    # set params
+    self.T = T
+    self.dim = dim
+    self.time = time
+
+    # coordinates
+    x, y, z = Symbol('x'), Symbol('y'), Symbol('z')
+
+    # time
+    t = Symbol('t')
+
+    # make input variables 
+    input_variables = {'x':x,'y':y,'z':z,'t':t}
+    if self.dim == 1:
+      input_variables.pop('y')
+      input_variables.pop('z')
+    elif self.dim == 2:
+      input_variables.pop('z')
+    if not self.time: 
+      input_variables.pop('t')
+
+    # Temperature
+    assert type(T) == str, "T needs to be string"
+    T = Function(T)(*input_variables)
+
+    # Diffusivity
+    if type(D) is str:
+      D = Function(D)(*input_variables)
+    elif type(D) in [float, int]:
+      D = Number(D)
+
+    # Source
+    if type(Q) is str:
+      Q = Function(Q)(*input_variables)
+    elif type(Q) in [float, int]:
+      Q = Number(Q)
+
+    # set equations
+    self.equations = Variables()
+    self.equations['diffusion_'+self.T] = (T.diff(t)
+                                            - (D*T.diff(x)).diff(x)
+                                            - (D*T.diff(y)).diff(y)
+                                            - (D*T.diff(z)).diff(z)
+                                            - Q)
+
+class DiffusionInterface(PDES):
+  name = 'DiffusionInterface'
+
+  def __init__(self, T_1, T_2, D_1, D_2, dim=3, time=True):
+    # set params
+    self.T_1 = T_1
+    self.T_2 = T_2
+    self.D_1 = D_1
+    self.D_2 = D_2
+    self.dim = dim
+    self.time = time
+ 
+    # coordinates
+    x, y, z = Symbol('x'), Symbol('y'), Symbol('z')
+    normal_x, normal_y, normal_z = Symbol('normal_x'), Symbol('normal_y'), Symbol('normal_z')
+
+    # time
+    t = Symbol('t')
+
+    # make input variables 
+    input_variables = {'x':x,'y':y,'z':z,'t':t}
+    if self.dim == 1:
+      input_variables.pop('y')
+      input_variables.pop('z')
+    elif self.dim == 2:
+      input_variables.pop('z')
+    if not self.time: 
+      input_variables.pop('t')
+
+    # variables to match the boundary conditions (example Temperature)
+    T_1 = Function(T_1)(*input_variables)
+    T_2 = Function(T_2)(*input_variables)
+
+    # set equations
+    self.equations = Variables()
+    self.equations['diffusion_interface_dirichlet_'+self.T_1+'_'+self.T_2] = T_1 - T_2
+    flux_1 = self.D_1 * (normal_x * T_1.diff(x) + normal_y * T_1.diff(y) + normal_z * T_1.diff(z))
+    flux_2 = self.D_2 * (normal_x * T_2.diff(x) + normal_y * T_2.diff(y) + normal_z * T_2.diff(z))
+    self.equations['diffusion_interface_neumann_'+self.T_1+'_'+self.T_2] = flux_1 - flux_2
+
+class DiffusionTrain(TrainDomain):
+  def __init__(self, **config):
+    super(DiffusionTrain, self).__init__()
+    # sympy variables
+    x = Symbol('x')
+    c = Symbol('c')
+    
+    # right hand side (x = 2) Pt c
+    IC = L2.boundary_bc(outvar_sympy={'u_2': Tc},
+                        batch_size_per_area=1,
+                        criteria=Eq(x, 2))
+    self.add(IC, name="RightHandSide")
+    
+    # left hand side (x = 0) Pt a
+    IC = L1.boundary_bc(outvar_sympy={'u_1': Ta},
+                        batch_size_per_area=1,
+                        criteria=Eq(x, 0))
+    self.add(IC, name="LeftHandSide")
+    
+    # interface 1-2
+    IC = L1.boundary_bc(outvar_sympy={'diffusion_interface_dirichlet_u_1_u_2': 0,
+                                      'diffusion_interface_neumann_u_1_u_2': 0},
+                        lambda_sympy={'lambda_diffusion_interface_dirichlet_u_1_u_2': 1,
+                                      'lambda_diffusion_interface_neumann_u_1_u_2': 1},
+                        batch_size_per_area=1,
+                        criteria=Eq(x, 1))
+    self.add(IC, name="Interface1n2")
+    
+    # interior 1
+    interior = L1.interior_bc(outvar_sympy={'diffusion_u_1': 0},
+                              lambda_sympy={'lambda_diffusion_u_1': 1},
+                              bounds={x: (0, 1)},
+                              batch_size_per_area=200)
+    self.add(interior, name="Interior1")
+    
+    # interior 2
+    interior = L2.interior_bc(outvar_sympy={'diffusion_u_2': 0},
+                              lambda_sympy={'lambda_diffusion_u_2': 1},
+                              bounds={x: (1, 2)},
+                              batch_size_per_area=200)
+    self.add(interior, name="Interior2")
+
+class DiffusionVal(ValidationDomain):
+  def __init__(self, **config):
+    super(DiffusionVal, self).__init__()
+    # make validation data line 1
+    #Tc = u_2__2
+    #Tb = Tc - u_1__x*D1/D2 
+    #Ta = Tb - u_1__x
+
+    x = np.expand_dims(np.linspace(0, 1, 100), axis=-1)
+    u_1 = x*Tb + (1-x)*Ta
+    invar_numpy = {'x': x}
+    outvar_numpy = {'u_1': u_1}
+    val = Validation.from_numpy(invar_numpy, outvar_numpy)
+    self.add(val, name='Val1')
+    
+    # make validation data line 2
+    x = np.expand_dims(np.linspace(1, 2, 100), axis=-1)
+    u_2 = (x-1)*Tc + (2-x)*Tb
+    invar_numpy = {'x': x}
+    outvar_numpy = {'u_2': u_2}
+    val = Validation.from_numpy(invar_numpy, outvar_numpy)
+    self.add(val, name='Val2')
+
+class DiffusionMonitor(MonitorDomain):
+  def __init__(self, **config):
+    super(DiffusionMonitor, self).__init__()
+    x = Symbol('x')
+
+    # flux in U1 at x = 1 
+    fluxU1 = Monitor(L1.sample_boundary(10, criteria=Eq(x, 1)),
+                    {'flux_U1': lambda var: tf.reduce_mean(D1*var['u_1__x'])})
+    self.add(fluxU1, 'FluxU1')
+
+    # flux in U2 at x = 1 
+    fluxU2 = Monitor(L2.sample_boundary(10, criteria=Eq(x, 1)),
+                    {'flux_U2': lambda var: tf.reduce_mean(D2*var['u_2__x'])})
+    self.add(fluxU2, 'FluxU2')
+
+# Define neural network
+class DiffusionSolver(Solver):
+  train_domain = DiffusionTrain
+  val_domain = DiffusionVal
+  monitor_domain = DiffusionMonitor
+
+  def __init__(self, **config):
+    super(DiffusionSolver, self).__init__(**config)
+
+    self.equations = (Diffusion(T='u_1', D=D1, dim=1, time=False).make_node()
+                      + Diffusion(T='u_2', D=D2, dim=1, time=False).make_node()
+                      + DiffusionInterface('u_1', 'u_2', D1, D2, dim=1, time=False).make_node())
+    diff_net_u_1 = self.arch.make_node(name='diff_net_u_1',
+                                   inputs=['x'],
+                                   outputs=['u_1'])
+    diff_net_u_2 = self.arch.make_node(name='diff_net_u_2',
+                                   inputs=['x'],
+                                   outputs=['u_2'])
+    self.nets = [diff_net_u_1, diff_net_u_2]
+
+  @classmethod # Explain This
+  def update_defaults(cls, defaults):
+    defaults.update({
+        'network_dir': './network_checkpoint_diff',
+        'max_steps': 5000,
+        'decay_steps': 100,
+        'start_lr': 1e-4,
+        'xla': True,
+        #'end_lr': 1e-6,
+        })
+
+if __name__ == '__main__':
+  ctr = SimNetController(DiffusionSolver)
+  ctr.run()

+ 253 - 0
hpc_ai/PINN/English/python/source_code/diffusion_1d/diffusion_bar_paramaterized.py

@@ -0,0 +1,253 @@
+# import SimNet library
+from sympy import Symbol, sin, Eq, Abs, exp
+import numpy as np
+import sys
+sys.path.append('../../')
+from simnet.solver import Solver
+from simnet.dataset import TrainDomain, ValidationDomain, MonitorDomain
+from simnet.data import Validation, BC, Monitor
+from simnet.sympy_utils.geometry_1d import Line1D
+from simnet.controller import SimNetController
+from simnet.node import Node
+from simnet.pdes import PDES
+import tensorflow as tf
+from sympy import Symbol, Function, Number
+
+from simnet.pdes import PDES
+from simnet.node import Node
+from simnet.variables import Variables
+
+
+# params for domain
+L1 = Line1D(0,1)
+L2 = Line1D(1,2)
+
+D1 = Symbol('D1')
+D1_range = {D1: (5, 25)}
+D1_validation = 1e1
+
+D2 = 1e-1
+
+Tc = 100
+Ta = 0
+Tb = (Tc + (D1/D2)*Ta)/(1 + (D1/D2))
+
+Tb_validation = float(Tb.evalf(subs={D1: 1e1}))
+
+class Diffusion(PDES):
+  name = 'Diffusion'
+ 
+  def __init__(self, T='T', D='D', Q=0, dim=3, time=True):
+    # set params
+    self.T = T
+    self.dim = dim
+    self.time = time
+
+    # coordinates
+    x, y, z = Symbol('x'), Symbol('y'), Symbol('z')
+
+    # time
+    t = Symbol('t')
+
+    # make input variables 
+    input_variables = {'x':x,'y':y,'z':z,'t':t}
+    if self.dim == 1:
+      input_variables.pop('y')
+      input_variables.pop('z')
+    elif self.dim == 2:
+      input_variables.pop('z')
+    if not self.time: 
+      input_variables.pop('t')
+
+    # Temperature
+    assert type(T) == str, "T needs to be string"
+    T = Function(T)(*input_variables)
+
+    # Diffusivity
+    if type(D) is str:
+      D = Function(D)(*input_variables)
+    elif type(D) in [float, int]:
+      D = Number(D)
+
+    # Source
+    if type(Q) is str:
+      Q = Function(Q)(*input_variables)
+    elif type(Q) in [float, int]:
+      Q = Number(Q)
+
+    # set equations
+    self.equations = Variables()                  
+    self.equations['diffusion_'+self.T] = (T.diff(t)
+                                            - (D*T.diff(x)).diff(x)
+                                            - (D*T.diff(y)).diff(y)
+                                            - (D*T.diff(z)).diff(z)
+                                            - Q)
+
+class DiffusionInterface(PDES):
+  name = 'DiffusionInterface'
+
+  def __init__(self, T_1='T_1', T_2='T_2', D_1='D_1', D_2='D_2', dim=3, time=True):
+    # set params
+    self.T_1 = T_1
+    self.T_2 = T_2
+    self.dim = dim
+    self.time = time
+ 
+    # coordinates
+    x, y, z = Symbol('x'), Symbol('y'), Symbol('z')
+    normal_x, normal_y, normal_z = Symbol('normal_x'), Symbol('normal_y'), Symbol('normal_z')
+
+    # time
+    t = Symbol('t')
+
+    # make input variables 
+    input_variables = {'x':x,'y':y,'z':z,'t':t}
+    if self.dim == 1:
+      input_variables.pop('y')
+      input_variables.pop('z')
+    elif self.dim == 2:
+      input_variables.pop('z')
+    if not self.time: 
+      input_variables.pop('t')
+
+    # variables to match the boundary conditions (example Temperature)
+    T_1 = Function(T_1)(*input_variables)
+    T_2 = Function(T_2)(*input_variables)
+    
+    # Diffusivity D_1
+    if type(D_1) is str:
+      D_1 = Function(D_1)(*input_variables)
+    elif type(D_1) in [float, int]:
+      D_1 = Number(D_1)
+
+    # Diffusivity D_2
+    if type(D_2) is str:
+      D_2 = Function(D_2)(*input_variables)
+    elif type(D_2) in [float, int]:
+      D_2 = Number(D_2)
+
+    # set equations
+    self.equations = Variables()
+    self.equations['diffusion_interface_dirichlet_'+self.T_1+'_'+self.T_2] = T_1 - T_2
+    flux_1 = D_1 * (normal_x * T_1.diff(x) + normal_y * T_1.diff(y) + normal_z * T_1.diff(z))
+    flux_2 = D_2 * (normal_x * T_2.diff(x) + normal_y * T_2.diff(y) + normal_z * T_2.diff(z))
+    self.equations['diffusion_interface_neumann_'+self.T_1+'_'+self.T_2] = flux_1 - flux_2
+
+class DiffusionTrain(TrainDomain):
+  def __init__(self, **config):
+    super(DiffusionTrain, self).__init__()
+    # sympy variables
+    x = Symbol('x')
+    c = Symbol('c')
+    
+    # right hand side (x = 2) Pt c
+    IC = L2.boundary_bc(outvar_sympy={'u_2': Tc},
+                        batch_size_per_area=10,
+                        criteria=Eq(x, 2),
+                        param_ranges=D1_range)
+    self.add(IC, name="RightHandSide")
+    
+    # left hand side (x = 0) Pt a
+    IC = L1.boundary_bc(outvar_sympy={'u_1': Ta},
+                        batch_size_per_area=10,
+                        criteria=Eq(x, 0),
+                        param_ranges=D1_range)
+    self.add(IC, name="LeftHandSide")
+    
+    # interface 1-2
+    IC = L1.boundary_bc(outvar_sympy={'diffusion_interface_dirichlet_u_1_u_2': 0,
+                                      'diffusion_interface_neumann_u_1_u_2': 0},
+                        lambda_sympy={'lambda_diffusion_interface_dirichlet_u_1_u_2': 1,
+                                      'lambda_diffusion_interface_neumann_u_1_u_2': 1},
+                        batch_size_per_area=10,
+                        criteria=Eq(x, 1),
+                        param_ranges=D1_range)
+    self.add(IC, name="Interface1n2")
+    
+    # interior 1
+    interior = L1.interior_bc(outvar_sympy={'diffusion_u_1': 0},
+                              lambda_sympy={'lambda_diffusion_u_1': 1},
+                              bounds={x: (0, 1)},
+                              batch_size_per_area=400,
+                              param_ranges=D1_range)
+    self.add(interior, name="Interior1")
+    
+    # interior 2
+    interior = L2.interior_bc(outvar_sympy={'diffusion_u_2': 0},
+                              lambda_sympy={'lambda_diffusion_u_2': 1},
+                              bounds={x: (1, 2)},
+                              batch_size_per_area=400,
+                              param_ranges=D1_range)
+    self.add(interior, name="Interior2")
+
+class DiffusionVal(ValidationDomain):
+  def __init__(self, **config):
+    super(DiffusionVal, self).__init__()
+    # make validation data line 1
+    x = np.expand_dims(np.linspace(0, 1, 100), axis=-1)
+    D1 = np.zeros_like(x) + D1_validation                      # For creating D1 input array
+    u_1 = x*Tb_validation + (1-x)*Ta
+    invar_numpy = {'x': x}                                    # Set the invars for the required D1 
+    invar_numpy.update({'D1': np.full_like(invar_numpy['x'], D1_validation)})
+    outvar_numpy = {'u_1': u_1}
+    val = Validation.from_numpy(invar_numpy, outvar_numpy)
+    self.add(val, name='Val1')
+    
+    # make validation data line 2
+    x = np.expand_dims(np.linspace(1, 2, 100), axis=-1)
+    u_2 = (x-1)*Tc + (2-x)*Tb_validation
+    invar_numpy = {'x': x}                           # Set the invars for the required D1 
+    invar_numpy.update({'D1': np.full_like(invar_numpy['x'], D1_validation)})
+    outvar_numpy = {'u_2': u_2}
+    val = Validation.from_numpy(invar_numpy, outvar_numpy)
+    self.add(val, name='Val2')
+
+class DiffusionMonitor(MonitorDomain):
+  def __init__(self, **config):
+    super(DiffusionMonitor, self).__init__()
+    x = Symbol('x')
+
+    # flux in U1 at x = 1 
+    fluxU1 = Monitor(L1.sample_boundary(10, criteria=Eq(x, 1), param_ranges={D1: D1_validation}),   # Set the parameter range for the required D1 
+                    {'flux_U1': lambda var: tf.reduce_mean(D1_validation*var['u_1__x'])})
+    self.add(fluxU1, 'FluxU1')
+
+    # flux in U2 at x = 1 
+    fluxU2 = Monitor(L2.sample_boundary(10, criteria=Eq(x, 1), param_ranges={D1: D1_validation}),   # Set the parameter range for the required D1 
+                    {'flux_U2': lambda var: tf.reduce_mean(D2*var['u_2__x'])})
+    self.add(fluxU2, 'FluxU2')
+
+# Define neural network
+class DiffusionSolver(Solver):
+  train_domain = DiffusionTrain
+  val_domain = DiffusionVal
+  monitor_domain = DiffusionMonitor
+
+  def __init__(self, **config):
+    super(DiffusionSolver, self).__init__(**config)
+
+    self.equations = (Diffusion(T='u_1', D='D1', dim=1, time=False).make_node()         # Symbolic input to the equation
+                      + Diffusion(T='u_2', D=D2, dim=1, time=False).make_node()
+                      + DiffusionInterface('u_1', 'u_2', 'D1', D2, dim=1, time=False).make_node())
+    diff_net_u_1 = self.arch.make_node(name='diff_net_u_1',
+                                   inputs=['x', 'D1'],                                  # Add the parameters to the network
+                                   outputs=['u_1'])
+    diff_net_u_2 = self.arch.make_node(name='diff_net_u_2',
+                                   inputs=['x', 'D1'],
+                                   outputs=['u_2'])
+    self.nets = [diff_net_u_1, diff_net_u_2]
+
+  @classmethod # Explain This
+  def update_defaults(cls, defaults):
+    defaults.update({
+        'network_dir': './network_checkpoint_diff_parameterized',
+        'max_steps': 10000,
+        'decay_steps': 200,
+        'start_lr': 1e-4,
+        'layer_size': 256,
+        'xla': True,
+        })
+
+if __name__ == '__main__':
+  ctr = SimNetController(DiffusionSolver)
+  ctr.run()

+ 2 - 0
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/checkpoint

@@ -0,0 +1,2 @@
+model_checkpoint_path: "model.ckpt-2000"
+all_model_checkpoint_paths: "model.ckpt-2000"

二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/events.out.tfevents.1614704654.2530984d8521


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/model.ckpt-2000.data-00000-of-00001


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/model.ckpt-2000.index


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/model.ckpt-2000.meta


+ 3 - 0
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/monitor_domain/results/FluxU1.csv

@@ -0,0 +1,3 @@
+"flux_U1","step"
+1000.0,9.875020980834961
+9.908063888549805,2000.0

二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/monitor_domain/results/FluxU1.png


+ 3 - 0
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/monitor_domain/results/FluxU2.csv

@@ -0,0 +1,3 @@
+"flux_U2","step"
+1000.0,9.880534172058105
+9.898728370666504,2000.0

二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/monitor_domain/results/FluxU2.png


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interface1n2_diff.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interface1n2_diff.vtu


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interface1n2_pred.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interface1n2_pred.vtu


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interface1n2_true.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interface1n2_true.vtu


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior1_diff.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior1_diff.vtu


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior1_pred.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior1_pred.vtu


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior1_true.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior1_true.vtu


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior2_diff.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior2_diff.vtu


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior2_pred.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior2_pred.vtu


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior2_true.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/Interior2_true.vtu


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/LeftHandSide_diff.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/LeftHandSide_diff.vtu


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/LeftHandSide_pred.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/LeftHandSide_pred.vtu


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/LeftHandSide_true.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/LeftHandSide_true.vtu


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/RightHandSide_diff.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/RightHandSide_diff.vtu


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/RightHandSide_pred.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/RightHandSide_pred.vtu


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/RightHandSide_true.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/train_domain/results/RightHandSide_true.vtu


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val1_diff.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val1_diff.vtu


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val1_pred.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val1_pred.vtu


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val1_true.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val1_true.vtu


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val2_diff.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val2_diff.vtu


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val2_pred.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val2_pred.vtu


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val2_true.npz


二進制
hpc_ai/PINN/English/python/source_code/diffusion_1d/network_checkpoint_diff/val_domain/results/Val2_true.vtu


+ 25 - 0
hpc_ai/PINN/English/python/source_code/diffusion_1d/plot_results.py

@@ -0,0 +1,25 @@
+
+import numpy as np
+import matplotlib.pyplot as plt
+
+network_dir = './network_checkpoint_diff/val_domain/results/'
+
+u_1_pred = np.load(network_dir + 'Val1_pred.npz', allow_pickle=True)
+u_2_pred = np.load(network_dir + 'Val2_pred.npz', allow_pickle=True)
+u_1_pred = np.atleast_1d(u_1_pred.f.arr_0)[0]
+u_2_pred = np.atleast_1d(u_2_pred.f.arr_0)[0]
+
+plt.plot(u_1_pred['x'][:,0], u_1_pred['u_1'][:,0], '--', label='u_1_pred')
+plt.plot(u_2_pred['x'][:,0], u_2_pred['u_2'][:,0], '--', label='u_2_pred')
+
+u_1_true = np.load(network_dir + 'Val1_true.npz', allow_pickle=True)
+u_2_true = np.load(network_dir + 'Val2_true.npz', allow_pickle=True)
+u_1_true = np.atleast_1d(u_1_true.f.arr_0)[0]
+u_2_true = np.atleast_1d(u_2_true.f.arr_0)[0]
+
+plt.plot(u_1_true['x'][:,0], u_1_true['u_1'][:,0], label='u_1_true')
+plt.plot(u_2_true['x'][:,0], u_2_true['u_2'][:,0], label='u_2_true')
+
+plt.legend()
+plt.savefig('image_diffusion_problem_bootcamp')
+

+ 25 - 0
hpc_ai/PINN/English/python/source_code/diffusion_1d/plot_results_parameterized.py

@@ -0,0 +1,25 @@
+
+import numpy as np
+import matplotlib.pyplot as plt
+
+network_dir = './network_checkpoint_diff_parameterized/val_domain/results/'
+
+u_1_pred = np.load(network_dir + 'Val1_pred.npz', allow_pickle=True)
+u_2_pred = np.load(network_dir + 'Val2_pred.npz', allow_pickle=True)
+u_1_pred = np.atleast_1d(u_1_pred.f.arr_0)[0]
+u_2_pred = np.atleast_1d(u_2_pred.f.arr_0)[0]
+
+plt.plot(u_1_pred['x'][:,0], u_1_pred['u_1'][:,0], '--', label='u_1_pred')
+plt.plot(u_2_pred['x'][:,0], u_2_pred['u_2'][:,0], '--', label='u_2_pred')
+
+u_1_true = np.load(network_dir + 'Val1_true.npz', allow_pickle=True)
+u_2_true = np.load(network_dir + 'Val2_true.npz', allow_pickle=True)
+u_1_true = np.atleast_1d(u_1_true.f.arr_0)[0]
+u_2_true = np.atleast_1d(u_2_true.f.arr_0)[0]
+
+plt.plot(u_1_true['x'][:,0], u_1_true['u_1'][:,0], label='u_1_true')
+plt.plot(u_2_true['x'][:,0], u_2_true['u_2'][:,0], label='u_2_true')
+
+plt.legend()
+plt.savefig('image_diffusion_problem_bootcamp_parameterized')
+

二進制
hpc_ai/PINN/English/python/source_code/spring_mass/__pycache__/spring_mass_ode.cpython-38.pyc


+ 28 - 0
hpc_ai/PINN/English/python/source_code/spring_mass/plot_results_spring.py

@@ -0,0 +1,28 @@
+
+import numpy as np
+import matplotlib.pyplot as plt
+
+import simnet as sn
+
+base_dir = './network_checkpoint_spring_mass_pointMass_2/val_domain/results/'
+
+# plot in 1d
+predicted_data = np.load(base_dir + 'Val_pred.npz', allow_pickle=True)
+true_data = np.load(base_dir + 'Val_true.npz', allow_pickle=True)
+true_data = np.atleast_1d(true_data.f.arr_0)[0]
+predicted_data = np.atleast_1d(predicted_data.f.arr_0)[0]
+
+print(predicted_data)
+print(true_data)
+
+plt.plot(true_data['t'], true_data['x1'], label='True x1')
+plt.plot(true_data['t'], true_data['x2'], label='True x2')
+plt.plot(true_data['t'], true_data['x3'], label='True x3')
+plt.plot(predicted_data['t'], predicted_data['x1'], label='Pred x1')
+plt.plot(predicted_data['t'], predicted_data['x2'], label='Pred x2')
+plt.plot(predicted_data['t'], predicted_data['x3'], label='Pred x3')
+plt.xlabel("Time")
+plt.ylabel("Displacement")
+plt.legend()
+plt.savefig("comparison_new.png")
+

+ 96 - 0
hpc_ai/PINN/English/python/source_code/spring_mass/spring_mass_inverse.py

@@ -0,0 +1,96 @@
+from sympy import Symbol, Eq
+import numpy as np
+import tensorflow as tf
+
+from simnet.solver import Solver
+from simnet.dataset import TrainDomain, ValidationDomain, MonitorDomain
+from simnet.data import Validation, BC, Monitor
+from simnet.sympy_utils.geometry_1d import Point1D
+from simnet.controller import SimNetController
+from simnet.plot_utils.vtk import var_to_vtk
+
+from spring_mass_ode import SpringMass
+
+# define time variable and range
+t_max = 10.0
+t_symbol = Symbol('t')
+x = Symbol('x')
+time_range = {t_symbol: (0, t_max)}
+
+geo = Point1D(0)
+
+deltaT = 0.01
+t = np.arange(0, t_max, deltaT)
+t = np.expand_dims(t, axis=-1) 
+
+invar_numpy = {'t': t}
+outvar_numpy = {'x1': (1/6)*np.cos(t) + (1/2)*np.cos(np.sqrt(3)*t) + (1/3)*np.cos(2*t),
+                'x2': (2/6)*np.cos(t) + (0/2)*np.cos(np.sqrt(3)*t) - (1/3)*np.cos(2*t),
+                'x3': (1/6)*np.cos(t) - (1/2)*np.cos(np.sqrt(3)*t) + (1/3)*np.cos(2*t)} 
+outvar_numpy.update({'ode_x1': np.full_like(invar_numpy['t'], 0)})
+outvar_numpy.update({'ode_x2': np.full_like(invar_numpy['t'], 0)})
+outvar_numpy.update({'ode_x3': np.full_like(invar_numpy['t'], 0)})
+
+class SpringMassTrain(TrainDomain):
+  def __init__(self, **config):
+    super(SpringMassTrain, self).__init__()
+
+    # initial conditions
+    IC = geo.boundary_bc(outvar_sympy={'x1': 1.,
+                                       'x2': 0,
+                                       'x3': 0,
+                                       'x1__t': 0,
+                                       'x2__t': 0,
+                                       'x3__t': 0},
+                         param_ranges={t_symbol: 0},
+                         batch_size_per_area=1)
+    self.add(IC, name="IC")
+
+    # data
+    data =  BC.from_numpy(invar_numpy, outvar_numpy)
+
+    self.add(data, name="Data")
+
+class SpringMassMonitor(MonitorDomain):
+  def __init__(self, **config):
+    super(SpringMassMonitor, self).__init__()
+    
+    global_monitor = Monitor(invar_numpy, {'average_m1': lambda var: tf.reduce_mean(var['m1']),
+                                           'average_k4': lambda var: tf.reduce_mean(var['k4'])})
+    self.add(global_monitor, 'GlobalMonitor')
+
+class SpringMassSolver(Solver):
+  train_domain = SpringMassTrain
+  monitor_domain = SpringMassMonitor
+
+  def __init__(self, **config):
+    super(SpringMassSolver, self).__init__(**config)
+
+    self.equations = SpringMass(k=(2, 1, 1, 'k4'), m=('m1', 1, 1)).make_node(stop_gradients=['x1', 'x1__t', 'x1__t__t',
+                                                                                             'x2', 'x2__t', 'x2__t__t',
+                                                                                             'x3', 'x3__t', 'x3__t__t'])
+
+    spring_net = self.arch.make_node(name='spring_net',
+                                   inputs=['t'],
+                                   outputs=['x1','x2','x3'])
+    invert_net = self.arch.make_node(name='invert_net',
+                                   inputs=['t'],
+                                   outputs=['m1','k4'])
+
+    self.nets = [spring_net, invert_net]
+
+  @classmethod # Explain This
+  def update_defaults(cls, defaults):
+    defaults.update({
+        'network_dir': './network_checkpoint_spring_mass_inverse',
+        'max_steps': 10000,
+        'decay_steps': 100,
+        'nr_layers': 6,
+        'layer_size': 256,
+        'xla': True,
+        })
+
+
+if __name__ == '__main__':
+  ctr = SimNetController(SpringMassSolver)
+  ctr.run()

+ 62 - 0
hpc_ai/PINN/English/python/source_code/spring_mass/spring_mass_ode.py

@@ -0,0 +1,62 @@
+from sympy import Symbol, Function, Number
+from simnet.pdes import PDES
+from simnet.variables import Variables
+
+class SpringMass(PDES):
+  name= 'SpringMass'
+
+  def __init__(self, k=(2, 1, 1, 2), m=(1, 1, 1)):
+    
+    self.k  = k
+    self.m  = m
+
+    k1 = k[0]
+    k2 = k[1]
+    k3 = k[2]
+    k4 = k[3]
+    m1 = m[0]
+    m2 = m[1]
+    m3 = m[2]
+
+    t=Symbol('t')
+    input_variables = {'t':t}
+    
+    x1 = Function('x1')(*input_variables)
+    x2 = Function('x2')(*input_variables)
+    x3 = Function('x3')(*input_variables)
+
+    if type(k1) is str:
+        k1 = Function(k1)(*input_variables)
+    elif type(k1) in [float, int]:
+        k1 = Number(k1)
+    if type(k2) is str:
+        k2 = Function(k2)(*input_variables)
+    elif type(k2) in [float, int]:
+        k2 = Number(k2)
+    if type(k3) is str:
+        k3 = Function(k3)(*input_variables)
+    elif type(k3) in [float, int]:
+        k3 = Number(k3)
+    if type(k4) is str:
+        k4 = Function(k4)(*input_variables)
+    elif type(k4) in [float, int]:
+        k4 = Number(k4)
+
+    if type(m1) is str:
+        m1 = Function(m1)(*input_variables)
+    elif type(m1) in [float, int]:
+        m1 = Number(m1)
+    if type(m2) is str:
+        m2 = Function(m2)(*input_variables)
+    elif type(m2) in [float, int]:
+        m2 = Number(m2)
+    if type(m3) is str:
+        m3 = Function(m3)(*input_variables)
+    elif type(m3) in [float, int]:
+        m3 = Number(m3)
+
+    self.equations = Variables()
+    self.equations['ode_x1'] = m1*(x1.diff(t)).diff(t) + k1*x1 - k2*(x2 - x1)
+    self.equations['ode_x2'] = m2*(x2.diff(t)).diff(t) + k2*(x2 - x1) - k3*(x3 - x2)
+    self.equations['ode_x3'] = m3*(x3.diff(t)).diff(t) + k3*(x3 - x2) + k4*x3
+

+ 85 - 0
hpc_ai/PINN/English/python/source_code/spring_mass/spring_mass_solver.py

@@ -0,0 +1,85 @@
+from sympy import Symbol, Eq
+import numpy as np
+
+from simnet.solver import Solver
+from simnet.dataset import TrainDomain, ValidationDomain
+from simnet.data import Validation
+from simnet.sympy_utils.geometry_1d import Point1D
+from simnet.controller import SimNetController
+from simnet.plot_utils.vtk import var_to_vtk
+
+from spring_mass_ode import SpringMass
+
+# define time variable and range
+t_max = 10.0
+t_symbol = Symbol('t')
+x = Symbol('x')
+time_range = {t_symbol: (0, t_max)}
+
+geo = Point1D(0)
+
+class SpringMassTrain(TrainDomain):
+  def __init__(self, **config):
+    super(SpringMassTrain, self).__init__()
+
+    # initial conditions
+    IC = geo.boundary_bc(outvar_sympy={'x1': 1.,
+                                       'x2': 0,
+                                       'x3': 0,
+                                       'x1__t': 0,
+                                       'x2__t': 0,
+                                       'x3__t': 0},
+                         param_ranges={t_symbol: 0},
+                         batch_size_per_area=1)
+    self.add(IC, name="IC")
+
+    # solve over given time period
+    interior = geo.boundary_bc(outvar_sympy={'ode_x1': 0.0,
+                                             'ode_x2': 0.0,
+                                             'ode_x3': 0.0}, 
+                               param_ranges=time_range,
+                               batch_size_per_area=500)
+    self.add(interior, name="Interior")
+
+class SpringMassVal(ValidationDomain):
+   def __init__(self, **config):
+     super(SpringMassVal, self).__init__()
+     deltaT = 0.001
+     t = np.arange(0, t_max, deltaT)
+     t = np.expand_dims(t, axis=-1) 
+     invar_numpy = {'t': t}
+     outvar_numpy = {'x1': (1/6)*np.cos(t) + (1/2)*np.cos(np.sqrt(3)*t) + (1/3)*np.cos(2*t),
+                     'x2': (2/6)*np.cos(t) + (0/2)*np.cos(np.sqrt(3)*t) - (1/3)*np.cos(2*t),
+                     'x3': (1/6)*np.cos(t) - (1/2)*np.cos(np.sqrt(3)*t) + (1/3)*np.cos(2*t)} 
+     val = Validation.from_numpy(invar_numpy, outvar_numpy)
+     self.add(val, name="Val")
+
+class SpringMassSolver(Solver):
+  train_domain = SpringMassTrain
+  val_domain = SpringMassVal
+
+  def __init__(self, **config):
+    super(SpringMassSolver, self).__init__(**config)
+
+    self.equations = SpringMass(k=(2, 1, 1, 2), m=(1, 1, 1)).make_node()
+
+    spring_net = self.arch.make_node(name='spring_net',
+                                   inputs=['t'],
+                                   outputs=['x1','x2','x3'])
+    self.nets = [spring_net]
+
+  @classmethod # Explain This
+  def update_defaults(cls, defaults):
+    defaults.update({
+        'network_dir': './network_checkpoint_spring_mass',
+        'max_steps': 10000,
+        'decay_steps': 100,
+        'nr_layers': 6,
+        'layer_size': 256,
+        'xla': True,
+        })
+
+
+if __name__ == '__main__':
+  ctr = SimNetController(SpringMassSolver)
+  ctr.run()

+ 38 - 0
hpc_ai/PINN/README.MD

@@ -0,0 +1,38 @@
+# openacc-training-materials
+Training materials provided by OpenACC.org. The objective of this lab is to give an introduction to application of Artificial Intelligence (AI) algorithms in Science ( High Performance Computing (HPC) Simulations ). This Bootcamp will provide introduction to fundamentals of using Physics Informed Neural Network and how they can be applied to real world scientific domains using NVIDIA SimNet. 
+
+## Prerequisites
+To run this tutorial you will need a machine with NVIDIA GPU.
+
+- Install the latest [Docker](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker) or [Singularity](https://sylabs.io/docs/).
+
+- The base containers required for the lab needs to be downloaded from SimNet product page and requires users to create a Nvidia Developer account (https://developer.nvidia.com/nvidia-simnet-downloads)
+
+## Creating containers
+To start with, we need to download the Docker file (`simnet_image_<version>.tar.gz`)as mentioned in the Prerequisites section. (Please note this lab is tested with SimNet release version 21.06). 
+
+### Docker Container
+Load the docker tar image: 
+`docker load -i simnet_image_v21.06.tar.gz`
+
+and to run the container, run:
+`docker run --shm-size=1g --ulimit memlock=-1 --ulimit stack=67108864 --gpus all -v ${PWD}/English/python:/examples -it simnet:21.06 jupyter notebook --no-browser --allow-root --ip=0.0.0.0 --port=8888 --NotebookApp.token="" --notebook-dir=/examples`
+
+The container launches jupyter notebook and runs on port 8888
+`jupyter notebook --ip 0.0.0.0 --port 8888 --no-browser --allow-root`
+
+Then, open the jupyter notebook in browser: http://localhost:8888
+Start working on the lab by clicking on the `Start_Here.ipynb` notebook.
+
+### Singularity Container
+
+To build the singularity container, run: 
+`sudo singularity build <image_name>.simg simnet_image_v21.06.tar.gz`
+
+
+Then, run the container:
+`singularity run --nv <image_name>.simg i--bind ${PWD}/English/python:/examples jupyter notebook --no-browser --allow-root --ip=0.0.0.0 --port=8888 --NotebookApp.token="" --notebook-dir=/examples`
+
+Then, open the jupyter notebook in browser: http://localhost:8888
+Start working on the lab by clicking on the `Start_Here.ipynb` notebook.
+