From 8c7dfc9f0bfad378dafdb69335188eb79aca9415 Mon Sep 17 00:00:00 2001 From: looooo Date: Sat, 4 Jan 2025 23:31:30 +0100 Subject: [PATCH] worm-notebook update min_ground --- .../cutting_tool_worm_assembly.ipynb | 2 +- examples/worm_cutting_tool/worm_1.ipynb | 35 +++++++++++++------ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/examples/worm_cutting_tool/cutting_tool_worm_assembly.ipynb b/examples/worm_cutting_tool/cutting_tool_worm_assembly.ipynb index c67ffb8..91e815a 100644 --- a/examples/worm_cutting_tool/cutting_tool_worm_assembly.ipynb +++ b/examples/worm_cutting_tool/cutting_tool_worm_assembly.ipynb @@ -786,7 +786,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.8" + "version": "3.13.1" } }, "nbformat": 4, diff --git a/examples/worm_cutting_tool/worm_1.ipynb b/examples/worm_cutting_tool/worm_1.ipynb index a687cba..54aeb15 100644 --- a/examples/worm_cutting_tool/worm_1.ipynb +++ b/examples/worm_cutting_tool/worm_1.ipynb @@ -315,10 +315,20 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 9, "id": "08796217-5c32-4970-9c2e-486855bfe01a", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "-2.7328221219692046 3.4258549033764787 3.111447653720825\n", + "-2.7297767569965177 2.6754565048922134 3.111447653720825\n", + "-2.703747361749271 3.750915476594737 3.111447653720825\n" + ] + } + ], "source": [ "import scipy as sp\n", "import numpy as np\n", @@ -357,6 +367,11 @@ " r0 = xw + module * (1 + clearence)\n", " x0 = np.sqrt(r0**2 - y**2)\n", " return d_distance_pw_dx(x0, y, t)\n", + "\n", + " def min_ground(y, t):\n", + " r1 = xw + rw / 2\n", + " xt = sp.optimize.root(lambda xt: xt + np.sqrt(rw**2 / 4 - z(xt, y, t) ** 2) - r1, xw).x[0]\n", + " return d_distance_pw_dx(xt, y, t)\n", " \n", " def min_head(y, t):\n", " r1 = xw - module * (1 + head)\n", @@ -367,18 +382,18 @@ " r1 = xw - module * (1 + head)\n", " x1 = np.sqrt(r1**2 - y**2)\n", " r2 = xw + rw - x1\n", - " # x2 = np.sqrt(r2**2 - z(x2, y, t)) # x2 is function of x2!!!\n", - " x2 = sp.optimize.root(lambda x2: x2 - np.sqrt(r2**2 - z(x2, y, t)), x1).x[0]\n", - " xt = rw + xw - x2\n", + " # rw + xw - xt = np.sqrt(r2**2 - z(xt, y, t)) # x2 is function of x2!!!\n", + " xt = sp.optimize.root(lambda xt: xt - rw - xw + np.sqrt(r2**2 - z(xt, y, t)), x1).x[0]\n", " return d_distance_pw_dx(xt, y, t)\n", "\n", " def create_points(): \n", " xyz = []\n", - " t_start_0 = module * (1 + head) * (np.tan(alpha) + 1. / np.tan(alpha))\n", - " t_start_1 = - module * (1 + clearence) * (np.tan(alpha) + 1. / np.tan(alpha))\n", - " for y in np.linspace(- height / 2, height / 2, 5):\n", - " t0 = sp.optimize.root(lambda t: min_head_1(y, t)**2, t_start_0).x[0]\n", - " t1 = sp.optimize.root(lambda t: min_root(y, t)**2, t_start_1).x[0]\n", + " t_start_0 = -rw * np.tan(alpha)\n", + " t_start_1 = module * (1 + head) * (np.tan(alpha) + 1. / np.tan(alpha))\n", + " for y in np.linspace(- height / 2, height / 2, 3):\n", + " t0 = sp.optimize.root(lambda t: min_ground(y, t)**2, t_start_0).x[0]\n", + " t1 = sp.optimize.root(lambda t: min_head_1(y, t)**2, t_start_1).x[0]\n", + " print(t0, t1, t_start_1)\n", " xyz_section = []\n", " for t in np.linspace(t0, t1, 10):\n", " # phi = np.pi / 2\n",