10: Draft task 1

This commit is contained in:
2022-03-15 09:41:58 +01:00
parent e0a729f84e
commit 74a4162fc0

View File

@ -39,7 +39,7 @@
"cell_type": "raw", "cell_type": "raw",
"metadata": {}, "metadata": {},
"source": [ "source": [
"team_members = \"\"" "team_members = \"Koen Vendrig, Kees van Kempen\""
] ]
}, },
{ {
@ -66,7 +66,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 1,
"metadata": { "metadata": {
"deletable": false, "deletable": false,
"nbgrader": { "nbgrader": {
@ -83,10 +83,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"# Import packages here ...\n", "import numpy as np"
"\n",
"# YOUR CODE HERE\n",
"raise NotImplementedError()"
] ]
}, },
{ {
@ -183,8 +180,31 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"def pdeHyperbolic(a, x, t, f, g):\n", "def pdeHyperbolic(a, x, t, f, g):\n",
" # YOUR CODE HERE\n", " # TODO: Docstring.\n",
" raise NotImplementedError()" " \n",
" n = len(t)\n",
" m = len(x)\n",
" \n",
" # TODO: The stepsize is defined by fixed h (k), but the input x (t)\n",
" # could allow variable step size. What should it be?\n",
" #h = x[1] - x[0]\n",
" l = x[-1]\n",
" h = l/(m - 1)\n",
" k = t[1] - t[0]\n",
" λ = a*k/h\n",
" \n",
" A = np.eye(m - 2)*2*(1 - λ**2) + ( np.eye(m - 2, m - 2, 1) + np.eye(m - 2, m - 2, -1) )*λ**2\n",
" \n",
" w = np.zeros((n, m))\n",
" \n",
" # Set initial values w[i, 0] = f[x[i]] and w[i, 1] = ...\n",
" # TODO: Fix previous comment.\n",
" w[:, 0] = f(x)\n",
" # TODO: What does the length of x[1:]?\n",
" w[:, 1] = (1 - λ**2)*f[x[1:m - 1]] + λ**2/2*f(x[2:m]) - λ**2/2*f(x[2:m]) + k*g(x[1:m - 1])\n",
" \n",
" for j in range(2, n):\n",
" w[:, j] = "
] ]
}, },
{ {
@ -441,7 +461,7 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 3 (ipykernel)", "display_name": "Python 3",
"language": "python", "language": "python",
"name": "python3" "name": "python3"
}, },