Skip to content

Commit

Permalink
Azure CI commit ref 90f8482d22c486563af0218508fe82cf23d9820d
Browse files Browse the repository at this point in the history
  • Loading branch information
simpeg-bot committed Jan 28, 2023
1 parent 5ed4349 commit d5e68ae
Show file tree
Hide file tree
Showing 4,464 changed files with 2,427,721 additions and 10,792,994 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
"version": "3.10.8"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
Y = mesh.gridCC[:, 1]
Z = mesh.gridCC[:, 2]

U = -1 - X ** 2 + Y + Z
V = 1 + X - Y ** 2 + Z
W = 1 + X + Y - Z ** 2
U = -1 - X**2 + Y + Z
V = 1 + X - Y**2 + Z
W = 1 + X + Y - Z**2

###############################################################################
# Plot streamlines
Expand Down
Binary file modified en/main/_downloads/1738b50aa178e7b4230879ecd5b02d54/pde_python.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
"import discretize\nfrom pymatsolver import SolverLU\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n\ndef run(plotIt=True):\n\n # Step1: Generate Tensor and Curvilinear Mesh\n sz = [40, 40]\n tM = discretize.TensorMesh(sz)\n rM = discretize.CurvilinearMesh(discretize.utils.exampleLrmGrid(sz, \"rotate\"))\n\n # Step2: Direct Current (DC) operator\n def DCfun(mesh, pts):\n D = mesh.faceDiv\n sigma = 1e-2 * np.ones(mesh.nC)\n MsigI = mesh.getFaceInnerProduct(sigma, invProp=True, invMat=True)\n A = -D * MsigI * D.T\n A[-1, -1] /= mesh.vol[-1] # Remove null space\n rhs = np.zeros(mesh.nC)\n txind = discretize.utils.closestPoints(mesh, pts)\n rhs[txind] = np.r_[1, -1]\n return A, rhs\n\n pts = np.vstack((np.r_[0.25, 0.5], np.r_[0.75, 0.5]))\n\n # Step3: Solve DC problem (LU solver)\n AtM, rhstM = DCfun(tM, pts)\n AinvtM = SolverLU(AtM)\n phitM = AinvtM * rhstM\n\n ArM, rhsrM = DCfun(rM, pts)\n AinvrM = SolverLU(ArM)\n phirM = AinvrM * rhsrM\n\n if not plotIt:\n return\n\n # Step4: Making Figure\n fig, axes = plt.subplots(1, 2, figsize=(12 * 1.2, 4 * 1.2))\n vmin, vmax = phitM.min(), phitM.max()\n\n dat = tM.plotImage(phitM, ax=axes[0], clim=(vmin, vmax), grid=True)\n cb0 = plt.colorbar(dat[0], ax=axes[0])\n cb0.set_label(\"Voltage (V)\")\n axes[0].set_title(\"TensorMesh\")\n\n dat = rM.plotImage(phirM, ax=axes[1], clim=(vmin, vmax), grid=True)\n cb1 = plt.colorbar(dat[0], ax=axes[1])\n cb1.set_label(\"Voltage (V)\")\n axes[1].set_title(\"CurvilinearMesh\")\n\n\nif __name__ == \"__main__\":\n run()\n plt.show()"
"import discretize\nfrom pymatsolver import SolverLU\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n\ndef run(plotIt=True):\n # Step1: Generate Tensor and Curvilinear Mesh\n sz = [40, 40]\n tM = discretize.TensorMesh(sz)\n rM = discretize.CurvilinearMesh(discretize.utils.exampleLrmGrid(sz, \"rotate\"))\n\n # Step2: Direct Current (DC) operator\n def DCfun(mesh, pts):\n D = mesh.faceDiv\n sigma = 1e-2 * np.ones(mesh.nC)\n MsigI = mesh.getFaceInnerProduct(sigma, invProp=True, invMat=True)\n A = -D * MsigI * D.T\n A[-1, -1] /= mesh.vol[-1] # Remove null space\n rhs = np.zeros(mesh.nC)\n txind = discretize.utils.closestPoints(mesh, pts)\n rhs[txind] = np.r_[1, -1]\n return A, rhs\n\n pts = np.vstack((np.r_[0.25, 0.5], np.r_[0.75, 0.5]))\n\n # Step3: Solve DC problem (LU solver)\n AtM, rhstM = DCfun(tM, pts)\n AinvtM = SolverLU(AtM)\n phitM = AinvtM * rhstM\n\n ArM, rhsrM = DCfun(rM, pts)\n AinvrM = SolverLU(ArM)\n phirM = AinvrM * rhsrM\n\n if not plotIt:\n return\n\n # Step4: Making Figure\n fig, axes = plt.subplots(1, 2, figsize=(12 * 1.2, 4 * 1.2))\n vmin, vmax = phitM.min(), phitM.max()\n\n dat = tM.plotImage(phitM, ax=axes[0], clim=(vmin, vmax), grid=True)\n cb0 = plt.colorbar(dat[0], ax=axes[0])\n cb0.set_label(\"Voltage (V)\")\n axes[0].set_title(\"TensorMesh\")\n\n dat = rM.plotImage(phirM, ax=axes[1], clim=(vmin, vmax), grid=True)\n cb1 = plt.colorbar(dat[0], ax=axes[1])\n cb1.set_label(\"Voltage (V)\")\n axes[1].set_title(\"CurvilinearMesh\")\n\n\nif __name__ == \"__main__\":\n run()\n plt.show()"
]
}
],
Expand All @@ -46,7 +46,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
"version": "3.10.8"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Operators: Cahn Hilliard\n\nThis example is based on the example in the FiPy_ library.\nPlease see their documentation for more information about the\nCahn-Hilliard equation.\n\nThe \"Cahn-Hilliard\" equation separates a field \\\\( \\\\phi \\\\)\ninto 0 and 1 with smooth transitions.\n\n\\begin{align}\\frac{\\partial \\phi}{\\partial t} = \\nabla \\cdot D \\nabla \\left( \\frac{\\partial f}{\\partial \\phi} - \\epsilon^2 \\nabla^2 \\phi \\right)\\end{align}\n\nWhere \\\\( f \\\\) is the energy function \\\\( f = ( a^2 / 2 )\\\\phi^2(1 - \\\\phi)^2 \\\\)\nwhich drives \\\\( \\\\phi \\\\) towards either 0 or 1, this competes with the term\n\\\\(\\\\epsilon^2 \\\\nabla^2 \\\\phi \\\\) which is a diffusion term that creates smooth changes in \\\\( \\\\phi \\\\).\nThe equation can be factored:\n\n\\begin{align}\\frac{\\partial \\phi}{\\partial t} = \\nabla \\cdot D \\nabla \\psi \\\\\n \\psi = \\frac{\\partial^2 f}{\\partial \\phi^2} (\\phi - \\phi^{\\text{old}}) + \\frac{\\partial f}{\\partial \\phi} - \\epsilon^2 \\nabla^2 \\phi\\end{align}\n\nHere we will need the derivatives of \\\\( f \\\\):\n\n\\begin{align}\\frac{\\partial f}{\\partial \\phi} = (a^2/2)2\\phi(1-\\phi)(1-2\\phi)\n \\frac{\\partial^2 f}{\\partial \\phi^2} = (a^2/2)2[1-6\\phi(1-\\phi)]\\end{align}\n\nThe implementation below uses backwards Euler in time with an\nexponentially increasing time step. The initial \\\\( \\\\phi \\\\)\nis a normally distributed field with a standard deviation of 0.1 and\nmean of 0.5. The grid is 60x60 and takes a few seconds to solve ~130\ntimes. The results are seen below, and you can see the field separating\nas the time increases.\n\n\n.. http://www.ctcms.nist.gov/fipy/examples/cahnHilliard/generated/examples.cahnHilliard.mesh2DCoupled.html\n"
"\n# Operators: Cahn Hilliard\n\nThis example is based on the example in the FiPy_ library.\nPlease see their documentation for more information about the\nCahn-Hilliard equation.\n\nThe \"Cahn-Hilliard\" equation separates a field $\\phi$\ninto 0 and 1 with smooth transitions.\n\n\\begin{align}\\frac{\\partial \\phi}{\\partial t} = \\nabla \\cdot D \\nabla \\left( \\frac{\\partial f}{\\partial \\phi} - \\epsilon^2 \\nabla^2 \\phi \\right)\\end{align}\n\nWhere $f$ is the energy function $f = ( a^2 / 2 )\\phi^2(1 - \\phi)^2$\nwhich drives $\\phi$ towards either 0 or 1, this competes with the term\n$\\epsilon^2 \\nabla^2 \\phi$ which is a diffusion term that creates smooth changes in $\\phi$.\nThe equation can be factored:\n\n\\begin{align}\\frac{\\partial \\phi}{\\partial t} = \\nabla \\cdot D \\nabla \\psi \\\\\n \\psi = \\frac{\\partial^2 f}{\\partial \\phi^2} (\\phi - \\phi^{\\text{old}}) + \\frac{\\partial f}{\\partial \\phi} - \\epsilon^2 \\nabla^2 \\phi\\end{align}\n\nHere we will need the derivatives of $f$:\n\n\\begin{align}\\frac{\\partial f}{\\partial \\phi} = (a^2/2)2\\phi(1-\\phi)(1-2\\phi)\n \\frac{\\partial^2 f}{\\partial \\phi^2} = (a^2/2)2[1-6\\phi(1-\\phi)]\\end{align}\n\nThe implementation below uses backwards Euler in time with an\nexponentially increasing time step. The initial $\\phi$\nis a normally distributed field with a standard deviation of 0.1 and\nmean of 0.5. The grid is 60x60 and takes a few seconds to solve ~130\ntimes. The results are seen below, and you can see the field separating\nas the time increases.\n\n\n.. http://www.ctcms.nist.gov/fipy/examples/cahnHilliard/generated/examples.cahnHilliard.mesh2DCoupled.html\n"
]
},
{
Expand All @@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
"import discretize\nfrom pymatsolver import Solver\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n\ndef run(plotIt=True, n=60):\n\n np.random.seed(5)\n\n # Here we are going to rearrange the equations:\n\n # (phi_ - phi)/dt = A*(d2fdphi2*(phi_ - phi) + dfdphi - L*phi_)\n # (phi_ - phi)/dt = A*(d2fdphi2*phi_ - d2fdphi2*phi + dfdphi - L*phi_)\n # (phi_ - phi)/dt = A*d2fdphi2*phi_ + A*( - d2fdphi2*phi + dfdphi - L*phi_)\n # phi_ - phi = dt*A*d2fdphi2*phi_ + dt*A*(- d2fdphi2*phi + dfdphi - L*phi_)\n # phi_ - dt*A*d2fdphi2 * phi_ = dt*A*(- d2fdphi2*phi + dfdphi - L*phi_) + phi\n # (I - dt*A*d2fdphi2) * phi_ = dt*A*(- d2fdphi2*phi + dfdphi - L*phi_) + phi\n # (I - dt*A*d2fdphi2) * phi_ = dt*A*dfdphi - dt*A*d2fdphi2*phi - dt*A*L*phi_ + phi\n # (dt*A*d2fdphi2 - I) * phi_ = dt*A*d2fdphi2*phi + dt*A*L*phi_ - phi - dt*A*dfdphi\n # (dt*A*d2fdphi2 - I - dt*A*L) * phi_ = (dt*A*d2fdphi2 - I)*phi - dt*A*dfdphi\n\n h = [(0.25, n)]\n M = discretize.TensorMesh([h, h])\n\n # Constants\n D = a = epsilon = 1.0\n I = discretize.utils.speye(M.nC)\n\n # Operators\n A = D * M.faceDiv * M.cellGrad\n L = epsilon ** 2 * M.faceDiv * M.cellGrad\n\n duration = 75\n elapsed = 0.0\n dexp = -5\n phi = np.random.normal(loc=0.5, scale=0.01, size=M.nC)\n ii, jj = 0, 0\n PHIS = []\n capture = np.logspace(-1, np.log10(duration), 8)\n while elapsed < duration:\n dt = min(100, np.exp(dexp))\n elapsed += dt\n dexp += 0.05\n\n dfdphi = a ** 2 * 2 * phi * (1 - phi) * (1 - 2 * phi)\n d2fdphi2 = discretize.utils.sdiag(a ** 2 * 2 * (1 - 6 * phi * (1 - phi)))\n\n MAT = dt * A * d2fdphi2 - I - dt * A * L\n rhs = (dt * A * d2fdphi2 - I) * phi - dt * A * dfdphi\n phi = Solver(MAT) * rhs\n\n if elapsed > capture[jj]:\n PHIS += [(elapsed, phi.copy())]\n jj += 1\n if ii % 10 == 0:\n print(ii, elapsed)\n ii += 1\n\n if plotIt:\n fig, axes = plt.subplots(2, 4, figsize=(14, 6))\n axes = np.array(axes).flatten().tolist()\n for ii, ax in zip(np.linspace(0, len(PHIS) - 1, len(axes)), axes):\n ii = int(ii)\n M.plotImage(PHIS[ii][1], ax=ax)\n ax.axis(\"off\")\n ax.set_title(\"Elapsed Time: {0:4.1f}\".format(PHIS[ii][0]))\n\n\nif __name__ == \"__main__\":\n run()\n plt.show()"
"import discretize\nfrom pymatsolver import Solver\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n\ndef run(plotIt=True, n=60):\n np.random.seed(5)\n\n # Here we are going to rearrange the equations:\n\n # (phi_ - phi)/dt = A*(d2fdphi2*(phi_ - phi) + dfdphi - L*phi_)\n # (phi_ - phi)/dt = A*(d2fdphi2*phi_ - d2fdphi2*phi + dfdphi - L*phi_)\n # (phi_ - phi)/dt = A*d2fdphi2*phi_ + A*( - d2fdphi2*phi + dfdphi - L*phi_)\n # phi_ - phi = dt*A*d2fdphi2*phi_ + dt*A*(- d2fdphi2*phi + dfdphi - L*phi_)\n # phi_ - dt*A*d2fdphi2 * phi_ = dt*A*(- d2fdphi2*phi + dfdphi - L*phi_) + phi\n # (I - dt*A*d2fdphi2) * phi_ = dt*A*(- d2fdphi2*phi + dfdphi - L*phi_) + phi\n # (I - dt*A*d2fdphi2) * phi_ = dt*A*dfdphi - dt*A*d2fdphi2*phi - dt*A*L*phi_ + phi\n # (dt*A*d2fdphi2 - I) * phi_ = dt*A*d2fdphi2*phi + dt*A*L*phi_ - phi - dt*A*dfdphi\n # (dt*A*d2fdphi2 - I - dt*A*L) * phi_ = (dt*A*d2fdphi2 - I)*phi - dt*A*dfdphi\n\n h = [(0.25, n)]\n M = discretize.TensorMesh([h, h])\n\n # Constants\n D = a = epsilon = 1.0\n I = discretize.utils.speye(M.nC)\n\n # Operators\n A = D * M.faceDiv * M.cellGrad\n L = epsilon**2 * M.faceDiv * M.cellGrad\n\n duration = 75\n elapsed = 0.0\n dexp = -5\n phi = np.random.normal(loc=0.5, scale=0.01, size=M.nC)\n ii, jj = 0, 0\n PHIS = []\n capture = np.logspace(-1, np.log10(duration), 8)\n while elapsed < duration:\n dt = min(100, np.exp(dexp))\n elapsed += dt\n dexp += 0.05\n\n dfdphi = a**2 * 2 * phi * (1 - phi) * (1 - 2 * phi)\n d2fdphi2 = discretize.utils.sdiag(a**2 * 2 * (1 - 6 * phi * (1 - phi)))\n\n MAT = dt * A * d2fdphi2 - I - dt * A * L\n rhs = (dt * A * d2fdphi2 - I) * phi - dt * A * dfdphi\n phi = Solver(MAT) * rhs\n\n if elapsed > capture[jj]:\n PHIS += [(elapsed, phi.copy())]\n jj += 1\n if ii % 10 == 0:\n print(ii, elapsed)\n ii += 1\n\n if plotIt:\n fig, axes = plt.subplots(2, 4, figsize=(14, 6))\n axes = np.array(axes).flatten().tolist()\n for ii, ax in zip(np.linspace(0, len(PHIS) - 1, len(axes)), axes):\n ii = int(ii)\n M.plotImage(PHIS[ii][1], ax=ax)\n ax.axis(\"off\")\n ax.set_title(\"Elapsed Time: {0:4.1f}\".format(PHIS[ii][0]))\n\n\nif __name__ == \"__main__\":\n run()\n plt.show()"
]
}
],
Expand All @@ -46,7 +46,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
"version": "3.10.8"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
"version": "3.10.8"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
},
"outputs": [],
"source": [
"X = mesh.gridCC[:, 0]\nY = mesh.gridCC[:, 1]\nZ = mesh.gridCC[:, 2]\n\nU = -1 - X ** 2 + Y + Z\nV = 1 + X - Y ** 2 + Z\nW = 1 + X + Y - Z ** 2"
"X = mesh.gridCC[:, 0]\nY = mesh.gridCC[:, 1]\nZ = mesh.gridCC[:, 2]\n\nU = -1 - X**2 + Y + Z\nV = 1 + X - Y**2 + Z\nW = 1 + X + Y - Z**2"
]
},
{
Expand Down Expand Up @@ -107,7 +107,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
"version": "3.10.8"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit d5e68ae

Please sign in to comment.