diff --git a/Tests/Data/Mechanics/Linear/DiscWithHole/Disc with a hole_Convergence Analysis.ipynb b/Tests/Data/Mechanics/Linear/DiscWithHole/Disc with a hole_Convergence Analysis.ipynb index 57781f368a9df268941140a463929dc996a8a4b9..4677ecbae1cf647a0acf4150240ddcf510b2cd1f 100644 --- a/Tests/Data/Mechanics/Linear/DiscWithHole/Disc with a hole_Convergence Analysis.ipynb +++ b/Tests/Data/Mechanics/Linear/DiscWithHole/Disc with a hole_Convergence Analysis.ipynb @@ -111,9 +111,6 @@ "# different meshes we create\n", "STUDY_indices = [ 8, 16, 24, 40, 60, 80, 240 ]\n", "\n", - "# NOTE: I'll prefix all global variables that are of interest in\n", - "# the entire notebook with \"STUDY_\"\n", - "\n", "# With this parameter the length of one axis of the square plate is defined\n", "STUDY_mesh_size = 20" ] @@ -127,13 +124,10 @@ }, "outputs": [], "source": [ - "# NOTE: Good function names are very important!\n", "def read_last_timestep_mesh(study_idx):\n", " reader = pv.PVDReader(f\"out/disc_with_hole_idx_is_{study_idx}.pvd\")\n", " reader.set_active_time_point(-1) # go to last timestep\n", " \n", - " # NOTE: \"mesh\" is a local variable. Inside the function body we\n", - " # we don't have to worry to overwrite global variables\n", " mesh = reader.read()[0]\n", " \n", " return mesh\n", @@ -142,8 +136,6 @@ " line = pv.Line(start_point, end_point, resolution = 2)\n", " return mesh.slice_along_line(line)\n", "\n", - "# NOTE: This function now in principle works with the line meshes\n", - "# we extract from the whole mesh, and also with the whole mesh.\n", "def get_sigma_polar_components(mesh):\n", " sig = mesh.point_data[\"sigma\"]\n", " \n", @@ -166,8 +158,6 @@ " \n", " return indices_sorted, dist_sorted\n", "\n", - "# NOTE: I've split the error computation into parts for each component\n", - "# for better readability\n", "def compute_abs_and_rel_stress_error_rr(sigmas_rr_num, rs, theta_degree):\n", " num_points = sigmas_rr_num.shape[0]\n", " f_abs_rr = np.zeros(num_points)\n", @@ -176,12 +166,8 @@ " for pt_idx in range(num_points):\n", " r = rs[pt_idx]\n", " \n", - " # NOTE: It's usually a good idea to save intermediate results\n", - " # in a local variable, even \"small\" results\n", " sigma_rr_ana = kirsch_sig_rr(10, r, theta_degree, 2)\n", " \n", - " # NOTE: Such unit conversions \" * 1000\" are should better be avoided\n", - " # or at least not scattered throughout the code/notebook\n", " sigma_rr_num = sigmas_rr_num[pt_idx] * 1000\n", " \n", " f_abs_rr[pt_idx] = sigma_rr_num - sigma_rr_ana\n", @@ -928,12 +914,8 @@ } ], "source": [ - "# NOTE: This function just encapsulates everything such that we\n", - "# don't use so many global variables\n", "def plot_stress_distribution_along_xaxis():\n", " ### Step 1: Compute data ##########################################\n", - " # NOTE: Separating data computation and visualization is usually a good\n", - " # idea\n", " \n", " # These variables will hold the error data for all STUDY_indices\n", " f_abs_rr = {}\n", @@ -951,9 +933,6 @@ " ax[i][1].set_ylabel('$\\Delta\\\\sigma$ / kPa')\n", " ax[i][2].set_ylabel('$\\Delta\\\\sigma$ / $\\sigma_{\\mathrm{analytical}}$')\n", " \n", - " # NOTE: Iterating over the global STUDY_indices list ensures that\n", - " # we always use the same set of indices and don't accidentally\n", - " # forget to change them in one place during our work\n", " for idx in STUDY_indices:\n", " # we use the line mesh we extracted before\n", " line_mesh = STUDY_num_result_xaxis_meshes_by_index[idx]\n", @@ -991,9 +970,6 @@ " # numerical results\n", " cell_size = compute_cell_size(idx, STUDY_num_result_meshes_by_index[idx])\n", "\n", - " # NOTE: Using hard coded indices (8, 16, 24) here makes the code a bit harder to change.\n", - " # I know, it's currently necessary for assigning colors, but in a clean up step at the very end,\n", - " # we maybe can avoid it (or we are just happy that everything runs and looks nice and leave it as it is)\n", " if idx == 8:\n", " # TODO Maybe plotting the analytical results again is not necessary\n", " ax[0][0].plot(dist_sorted, sig_rr_sorted*1000, color = \"lightskyblue\", label = f\"h = {cell_size:.3f} cm\")\n",