Skip to content

Commit

Permalink
worm-notebook update min_ground
Browse files Browse the repository at this point in the history
  • Loading branch information
looooo committed Jan 4, 2025
1 parent e65f2e8 commit 8c7dfc9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.8"
"version": "3.13.1"
}
},
"nbformat": 4,
Expand Down
35 changes: 25 additions & 10 deletions examples/worm_cutting_tool/worm_1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 8c7dfc9

Please sign in to comment.