Skip to content

Commit c91f80e

Browse files
Solving formatting issues
1 parent 97b81f8 commit c91f80e

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

chapter2/linear-elasticity-v1.ipynb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,17 @@
1313
"This leads to the following variational formulation:\n",
1414
"\n",
1515
"$$\n",
16-
"\n",
1716
"\\boxed{\n",
1817
"\\begin{aligned}\n",
1918
"&\\text{Find } u \\in V \\text{ such that:} \\\\\n",
2019
"&\\qquad a(u, v) = L(v) \\quad \\forall v \\in V\n",
2120
"\\end{aligned}\n",
2221
"}\n",
23-
"\n",
2422
"$$\n",
2523
"\n",
2624
"with\n",
2725
"\n",
2826
"$$\n",
29-
"\n",
3027
"\\begin{aligned}\n",
3128
"&a : \n",
3229
"\\begin{cases}\n",
@@ -39,7 +36,6 @@
3936
"v \\longmapsto \\int_\\Omega f \\cdot v \\, dx + \\int_{\\partial\\Omega_T} g_T \\cdot v \\, ds\n",
4037
"\\end{cases}\n",
4138
"\\end{aligned}\n",
42-
"\n",
4339
"$$\n",
4440
"\n",
4541
"\n",

chapter2/linear-elasticity-v2.ipynb

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,46 +13,39 @@
1313
"In the case of high values of the Lamé parameter $ \\lambda $, the pressure field $ p $ can be defined as:\n",
1414
"\n",
1515
"$$\n",
16-
"\n",
1716
"p := -\\lambda \\nabla \\cdot u \\hspace{1cm} \\text{ in } \\Omega\n",
18-
"\n",
1917
"$$\n",
2018
"\n",
2119
"As $u \\in H^1(\\Omega)$, the pressure field $p \\in L^2(\\Omega)$.\n",
2220
"\n",
2321
"## The strong formulation of the problem\n",
2422
"The strong formulation of the problem can be expressed as follows:\n",
25-
"Find $ (u, p) \\in V \\times L^2(\\Omega) $ such that\n",
23+
"Find $(u, p) \\in V \\times L^2(\\Omega)$ such that\n",
2624
"\n",
2725
"$$\n",
28-
"\n",
2926
"\\begin{align}\n",
3027
" -\\nabla \\cdot \\sigma(u,p) &= f & \\text{in } & \\Omega \\\\\n",
3128
" u &= 0 & \\text{on } & \\partial \\Omega_D \\\\\n",
3229
" \\sigma(u,p) \\cdot n &= g_T & \\text{on } & \\partial \\Omega_T \\\\\n",
3330
" \\nabla \\cdot u + \\frac{1}{\\lambda} p &= 0 & \\text{in } & \\Omega\n",
3431
"\\end{align}\n",
35-
"\n",
3632
"$$\n",
3733
"\n",
3834
"## The Variational Formulation (Pressure-Displacement Formulation)\n",
39-
"To derive the weak formulation of the problem, we multiply the first equation by a test function $ v \\in V $ and integrate by parts over the domain $ \\Omega $ and we add the fourth equation multiplied by a test function $ q \\in L^2(\\Omega) $ integrated over the domain $ \\Omega $:\n",
35+
"To derive the weak formulation of the problem, we multiply the first equation by a test function $v \\in V$ and integrate by parts over the domain $\\Omega$ and we add the fourth equation multiplied by a test function $q \\in L^2(\\Omega)$ integrated over the domain $\\Omega$:\n",
4036
"\n",
4137
"$$\n",
42-
"\n",
4338
"\\boxed{\n",
4439
"\\begin{aligned}\n",
4540
"&\\text{Find } (u, p) \\in V \\times L^2(\\Omega) \\text{ such that:} \\\\\n",
4641
"&\\qquad \\tilde{a}((u, p), (v, q)) = l(v, q) \\quad \\forall (v, q) \\in V \\times L^2(\\Omega)\n",
4742
"\\end{aligned}\n",
4843
"}\n",
49-
"\n",
5044
"$$\n",
5145
"\n",
5246
"with\n",
5347
"\n",
5448
"$$\n",
55-
"\n",
5649
"\\begin{aligned}\n",
5750
"&\\tilde{a} : \n",
5851
"\\begin{cases}\n",
@@ -65,7 +58,6 @@
6558
"v \\longmapsto \\int_\\Omega f \\cdot v \\, dx + \\int_{\\partial\\Omega_N} t_N \\cdot v \\, ds\n",
6659
"\\end{cases}\n",
6760
"\\end{aligned}\n",
68-
"\n",
6961
"$$"
7062
]
7163
},
@@ -469,24 +461,20 @@
469461
"metadata": {},
470462
"outputs": [],
471463
"source": [
472-
"p_simulated = -lambda_ * compute_divergence(u1, u2, u3, x_vals, y_vals, z_vals)\n",
473-
"exact_p = -lambda_ * np.pi * np.sin(np.pi * X) * np.sin(np.pi * Y) * np.cos(np.pi * Z)\n",
474-
"error_p = p_simulated - exact_p\n",
475-
"\n",
476464
"fig = plt.figure(figsize=(24, 6 * len(z_plane_list)))\n",
477465
"for i, z_plane in enumerate(z_plane_list):\n",
478466
" list_index = int(z_plane * (h - 1))\n",
479467
"\n",
480468
" # Simulated pressure\n",
481469
" ax1 = fig.add_subplot(len(z_plane_list), 3, 3 * i + 1, projection='3d')\n",
482-
" ax1.plot_surface(X[:, :, list_index], Y[:, :, list_index], p_simulated[:, :, list_index], cmap='viridis')\n",
470+
" ax1.plot_surface(X[:, :, list_index], Y[:, :, list_index], p_sim[:, :, list_index], cmap='viridis')\n",
483471
" ax1.set_title('Simulated Pressure on z={:.2f} plane'.format(z_plane))\n",
484472
" ax1.set_xlabel('X-axis')\n",
485473
" ax1.set_ylabel('Y-axis')\n",
486-
" ax1.set_zlabel('p_simulated')\n",
474+
" ax1.set_zlabel('p_sim')\n",
487475
" ax1.set_xlim(0, x_lim)\n",
488476
" ax1.set_ylim(0, y_lim)\n",
489-
" ax1.set_zlim(p_simulated[:, :, list_index].min(), p_simulated[:, :, list_index].max())\n",
477+
" ax1.set_zlim(p_sim[:, :, list_index].min(), p_sim[:, :, list_index].max())\n",
490478
"\n",
491479
" # Exact pressure\n",
492480
" ax2 = fig.add_subplot(len(z_plane_list), 3, 3 * i + 2, projection='3d')\n",
@@ -501,14 +489,14 @@
501489
"\n",
502490
" # Error in pressure\n",
503491
" ax3 = fig.add_subplot(len(z_plane_list), 3, 3 * i + 3, projection='3d')\n",
504-
" mappable = ax3.plot_surface(X[:, :, list_index], Y[:, :, list_index], error_p[:, :, list_index], cmap='viridis')\n",
492+
" mappable = ax3.plot_surface(X[:, :, list_index], Y[:, :, list_index], p_sim[:, :, list_index] - exact_p[:, :, list_index], cmap='viridis')\n",
505493
" ax3.set_title('Error in Pressure on z={:.2f} plane'.format(z_plane))\n",
506494
" ax3.set_xlabel('X-axis')\n",
507495
" ax3.set_ylabel('Y-axis')\n",
508496
" ax3.set_zlabel('Error in pressure')\n",
509497
" ax3.set_xlim(0, x_lim)\n",
510498
" ax3.set_ylim(0, y_lim)\n",
511-
" ax3.set_zlim(error_p[:, :, list_index].min(), error_p[:, :, list_index].max())\n",
499+
" ax3.set_zlim((p_sim[:, :, list_index] - exact_p[:, :, list_index]).min(), (p_sim[:, :, list_index] - exact_p[:, :, list_index]).max())\n",
512500
" fig.colorbar(mappable, ax=ax3, shrink=0.5, aspect=5)\n",
513501
"\n",
514502
"plt.tight_layout()\n",

0 commit comments

Comments
 (0)