Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring #143

Merged
merged 5 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 151 additions & 0 deletions examples/timing_gear_t.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "dbef2e6b-b521-40d8-af63-b187bc646d92",
"metadata": {},
"outputs": [],
"source": [
"import sympy as sp\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "ceb86e9b-4bed-4c74-b4f7-e687ddd839e7",
"metadata": {},
"outputs": [],
"source": [
"p, t, h, u, alpha, s = sp.symbols(\"p, t, h, u, alpha, s\")"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "f8f6467e-fec5-4052-a09b-ace996831ce9",
"metadata": {},
"outputs": [],
"source": [
"r_p = p * t / 2 / sp.pi\n",
"gamma_0 = p / r_p\n",
"gamma_1 = gamma_0 / 4"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "f4c7cab6-aa4b-4d12-b456-933088efc677",
"metadata": {},
"outputs": [],
"source": [
"p_A = sp.Matrix([sp.cos(-gamma_1), sp.sin(-gamma_1)]) * (r_p - u - h / 2)"
]
},
{
"cell_type": "code",
"execution_count": 33,
"id": "b0bb717c-786c-4c27-9486-e597fa2e5f53",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}\\frac{- \\pi s \\cos{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} + \\frac{\\left(p t - \\pi \\left(h + 2 u\\right)\\right) \\cos{\\left(\\frac{\\pi}{2 t} \\right)}}{2}}{\\pi}\\\\\\frac{- \\pi s \\sin{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} + \\frac{\\left(- p t + \\pi \\left(h + 2 u\\right)\\right) \\sin{\\left(\\frac{\\pi}{2 t} \\right)}}{2}}{\\pi}\\end{matrix}\\right]$"
],
"text/plain": [
"Matrix([\n",
"[ (-pi*s*cos(alpha - pi/(2*t)) + (p*t - pi*(h + 2*u))*cos(pi/(2*t))/2)/pi],\n",
"[(-pi*s*sin(alpha - pi/(2*t)) + (-p*t + pi*(h + 2*u))*sin(pi/(2*t))/2)/pi]])"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"p_1 = sp.simplify(p_A - sp.Matrix([sp.cos(alpha-gamma_1), sp.sin(alpha-gamma_1)]) * s)\n",
"p_1"
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "65bfc74b-995b-4ce4-85ec-f9c4e32086a4",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\frac{h^{2}}{4} - \\frac{h p t}{2 \\pi} + h s \\cos{\\left(\\alpha \\right)} + h u + \\frac{p^{2} t^{2}}{4 \\pi^{2}} - \\frac{p s t \\cos{\\left(\\alpha \\right)}}{\\pi} - \\frac{p t u}{\\pi} + s^{2} + 2 s u \\cos{\\left(\\alpha \\right)} + u^{2}$"
],
"text/plain": [
"h**2/4 - h*p*t/(2*pi) + h*s*cos(alpha) + h*u + p**2*t**2/(4*pi**2) - p*s*t*cos(alpha)/pi - p*t*u/pi + s**2 + 2*s*u*cos(alpha) + u**2"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sp.simplify(p_1.dot(p_1))"
]
},
{
"cell_type": "code",
"execution_count": 39,
"id": "7a25ddba-d433-492b-83ee-7b48ec13918f",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\frac{- \\frac{\\pi h \\cos{\\left(\\alpha \\right)}}{2} + \\frac{p t \\cos{\\left(\\alpha \\right)}}{2} - \\pi u \\cos{\\left(\\alpha \\right)} - \\frac{\\sqrt{- 4 \\pi^{2} h^{2} \\sin^{2}{\\left(\\frac{\\pi}{2 t} \\right)} \\cos^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} - 4 \\pi^{2} h^{2} \\sin^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} \\cos^{2}{\\left(\\frac{\\pi}{2 t} \\right)} + 16 \\pi^{2} h^{2} \\sin^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} + \\pi^{2} h^{2} \\cos{\\left(2 \\alpha \\right)} + 16 \\pi^{2} h^{2} \\cos^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} - \\pi^{2} h^{2} \\cos{\\left(2 \\alpha - \\frac{2 \\pi}{t} \\right)} + 8 \\pi h p t \\sin^{2}{\\left(\\frac{\\pi}{2 t} \\right)} \\cos^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} + 8 \\pi h p t \\sin^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} \\cos^{2}{\\left(\\frac{\\pi}{2 t} \\right)} - 16 \\pi h p t \\sin^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} - 2 \\pi h p t \\cos{\\left(2 \\alpha \\right)} - 16 \\pi h p t \\cos^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} + 2 \\pi h p t \\cos{\\left(2 \\alpha - \\frac{2 \\pi}{t} \\right)} - 16 \\pi^{2} h u \\sin^{2}{\\left(\\frac{\\pi}{2 t} \\right)} \\cos^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} - 16 \\pi^{2} h u \\sin^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} \\cos^{2}{\\left(\\frac{\\pi}{2 t} \\right)} + 32 \\pi^{2} h u \\sin^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} + 4 \\pi^{2} h u \\cos{\\left(2 \\alpha \\right)} + 32 \\pi^{2} h u \\cos^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} - 4 \\pi^{2} h u \\cos{\\left(2 \\alpha - \\frac{2 \\pi}{t} \\right)} - 4 p^{2} t^{2} \\sin^{2}{\\left(\\frac{\\pi}{2 t} \\right)} \\cos^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} - 4 p^{2} t^{2} \\sin^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} \\cos^{2}{\\left(\\frac{\\pi}{2 t} \\right)} + 4 p^{2} t^{2} \\sin^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} + p^{2} t^{2} \\cos{\\left(2 \\alpha \\right)} + 4 p^{2} t^{2} \\cos^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} - p^{2} t^{2} \\cos{\\left(2 \\alpha - \\frac{2 \\pi}{t} \\right)} + 16 \\pi p t u \\sin^{2}{\\left(\\frac{\\pi}{2 t} \\right)} \\cos^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} + 16 \\pi p t u \\sin^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} \\cos^{2}{\\left(\\frac{\\pi}{2 t} \\right)} - 16 \\pi p t u \\sin^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} - 4 \\pi p t u \\cos{\\left(2 \\alpha \\right)} - 16 \\pi p t u \\cos^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} + 4 \\pi p t u \\cos{\\left(2 \\alpha - \\frac{2 \\pi}{t} \\right)} - 16 \\pi^{2} u^{2} \\sin^{2}{\\left(\\frac{\\pi}{2 t} \\right)} \\cos^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} - 16 \\pi^{2} u^{2} \\sin^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} \\cos^{2}{\\left(\\frac{\\pi}{2 t} \\right)} + 16 \\pi^{2} u^{2} \\sin^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} + 4 \\pi^{2} u^{2} \\cos{\\left(2 \\alpha \\right)} + 16 \\pi^{2} u^{2} \\cos^{2}{\\left(\\alpha - \\frac{\\pi}{2 t} \\right)} - 4 \\pi^{2} u^{2} \\cos{\\left(2 \\alpha - \\frac{2 \\pi}{t} \\right)}}}{4}}{\\pi}$"
],
"text/plain": [
"(-pi*h*cos(alpha)/2 + p*t*cos(alpha)/2 - pi*u*cos(alpha) - sqrt(-4*pi**2*h**2*sin(pi/(2*t))**2*cos(alpha - pi/(2*t))**2 - 4*pi**2*h**2*sin(alpha - pi/(2*t))**2*cos(pi/(2*t))**2 + 16*pi**2*h**2*sin(alpha - pi/(2*t))**2 + pi**2*h**2*cos(2*alpha) + 16*pi**2*h**2*cos(alpha - pi/(2*t))**2 - pi**2*h**2*cos(2*alpha - 2*pi/t) + 8*pi*h*p*t*sin(pi/(2*t))**2*cos(alpha - pi/(2*t))**2 + 8*pi*h*p*t*sin(alpha - pi/(2*t))**2*cos(pi/(2*t))**2 - 16*pi*h*p*t*sin(alpha - pi/(2*t))**2 - 2*pi*h*p*t*cos(2*alpha) - 16*pi*h*p*t*cos(alpha - pi/(2*t))**2 + 2*pi*h*p*t*cos(2*alpha - 2*pi/t) - 16*pi**2*h*u*sin(pi/(2*t))**2*cos(alpha - pi/(2*t))**2 - 16*pi**2*h*u*sin(alpha - pi/(2*t))**2*cos(pi/(2*t))**2 + 32*pi**2*h*u*sin(alpha - pi/(2*t))**2 + 4*pi**2*h*u*cos(2*alpha) + 32*pi**2*h*u*cos(alpha - pi/(2*t))**2 - 4*pi**2*h*u*cos(2*alpha - 2*pi/t) - 4*p**2*t**2*sin(pi/(2*t))**2*cos(alpha - pi/(2*t))**2 - 4*p**2*t**2*sin(alpha - pi/(2*t))**2*cos(pi/(2*t))**2 + 4*p**2*t**2*sin(alpha - pi/(2*t))**2 + p**2*t**2*cos(2*alpha) + 4*p**2*t**2*cos(alpha - pi/(2*t))**2 - p**2*t**2*cos(2*alpha - 2*pi/t) + 16*pi*p*t*u*sin(pi/(2*t))**2*cos(alpha - pi/(2*t))**2 + 16*pi*p*t*u*sin(alpha - pi/(2*t))**2*cos(pi/(2*t))**2 - 16*pi*p*t*u*sin(alpha - pi/(2*t))**2 - 4*pi*p*t*u*cos(2*alpha) - 16*pi*p*t*u*cos(alpha - pi/(2*t))**2 + 4*pi*p*t*u*cos(2*alpha - 2*pi/t) - 16*pi**2*u**2*sin(pi/(2*t))**2*cos(alpha - pi/(2*t))**2 - 16*pi**2*u**2*sin(alpha - pi/(2*t))**2*cos(pi/(2*t))**2 + 16*pi**2*u**2*sin(alpha - pi/(2*t))**2 + 4*pi**2*u**2*cos(2*alpha) + 16*pi**2*u**2*cos(alpha - pi/(2*t))**2 - 4*pi**2*u**2*cos(2*alpha - 2*pi/t))/4)/pi"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sp.simplify(sp.solve(p_1.dot(p_1)- (r_p - u - h)**2, s)[0])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c98e5e55-2a8e-4e35-a5ff-d9b1f0379c81",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading
Loading