Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
300fd526eThis file is pinned to the selected release. Download the original to open it in your design tool.
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# The Basics"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We learn the basic concepts to program in NGSolve, we start with an easy example and we explore the single steps to solve a PDE problem. Then we apply the same steps and concepts to a more complex problem."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"**basic topics**\n",
"- [easy problem]()\n",
"- [coefficient functions]()\n",
"- [modelling domains with occ]()\n",
"- [apply what we have learned]() Modelling a capacitor in 2D. \n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"\n",
"### Finite Element Method in a Nutshell\n",
"\n",
"\n",
"**Problem:** (Strong)\\\n",
"Let $\\Omega$ be a domain in $\\mathbb{R}^n$ .\n",
"\n",
"Find $u$ such that\n",
"\\begin{align*} -\\Delta u &= f \\quad \\text{in } \\Omega, \\\\ u &= u_D \\quad \\text{on } \\Gamma_D,\\\\ n\\cdot \\nabla u &= g \\quad \\text{on } \\Gamma_N, \\end{align*}\n",
"With $\\Gamma_D \\sqcup \\Gamma_N = \\partial \\Omega$ \n",
"\n",
"\n",
"Multiply the equation by a test function $v$ and integrate by parts we get the weak formulation:\n",
"\n",
"\n",
"**Problem:** (Weak) \\\n",
"Find $u \\in H^1(\\Omega)$ such that $u = u_D$ on $\\Gamma_D$ and\n",
"\\begin{align*} \\int_{\\Omega} \\nabla u \\cdot \\nabla v \\, dx &= \\int_{\\Omega} f v \\, dx - \\int_{\\Gamma_N} g v \\, ds \\quad \\forall v \\in H^1_{\\Gamma_D}(\\Omega), \\end{align*}\n",
"\n",
"Let $\\mathcal{T}$ ba a triangulation of the space $\\Omega$ the discrete weak formulation is given by:\n",
"\n",
"\n",
"**Problem:** (Discrete-Weak)\\\n",
"Find $u_h \\in V_{h}$ such that $u_h = u_D$ on $\\Gamma_D$ and\n",
"\\begin{align*} \\int_{\\Omega} \\nabla u_h \\cdot \\nabla v_h \\, dx &= \\int_{\\Omega} f v_h \\, dx - \\int_{\\Gamma_N} g v_h \\, ds\\quad \\forall v_h \\in V_{h,\\Gamma_D}(\\mathcal{T}), \\end{align*}\n",
"\n",
"Applying the Galerkin method:\n",
"Suppose that on the triangulation $\\mathcal{T}$ we the finite dimensional function space $V_{h}(\\mathcal{T})$ has a basis $\\{\\phi^i\\}_{i=1}^{N}$, and\n",
"let \n",
"\\begin{align*}\n",
"v_h = \\sum_{i=1}^{N} v^i \\phi_i\\quad \\text{and} \\quad\n",
"u_h = \\sum_{j=1}^{N} u^j \\phi_j\n",
"\\end{align*}\n",
"Then, by substituting $v_h$ and $u_h$ in the discrete weak formulation we obtain the following linear system:\n",
"\n",
"\\begin{align*} \n",
"\\sum_{i,j} v^i u^j \\overbrace{\\int_{\\Omega} \\nabla \\phi_j \\cdot \\nabla \\phi_i \\, dx }^{A_{ij}}&= \\sum_{i} v^i \\overbrace{ \\left(\\int_{\\Omega} f \\phi_i \\, dx - \\int_{\\Gamma_N} g \\phi_i \\, ds \\right)}^{f_i}\n",
"\\end{align*}\n",
"\n",
"\n",
"Then the problem reduces to solve the linear system $A u = f$.\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2
}