vault backup: 2025-03-21 14:31:32
This commit is contained in:
parent
41f1550a4f
commit
c30f521289
File diff suppressed because it is too large
Load Diff
95
补课/多体动力学/16_generalized_forces.ipynb
Normal file
95
补课/多体动力学/16_generalized_forces.ipynb
Normal file
@ -0,0 +1,95 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\displaystyle l \\dot{q}_{1}\\mathbf{\\hat{a}_x} + l \\dot{q}_{2}\\mathbf{\\hat{b}_x}$"
|
||||
],
|
||||
"text/plain": [
|
||||
"l⋅q₁̇ a_x + l⋅q₂̇ b_x"
|
||||
]
|
||||
},
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import sympy as sm\n",
|
||||
"import sympy.physics.mechanics as me\n",
|
||||
"me.init_vprinting(use_latex='mathjax')\n",
|
||||
"\n",
|
||||
"l = sm.symbols('l')\n",
|
||||
"q1, q2, u1, u2 = me.dynamicsymbols('q1, q2, u1, u2')\n",
|
||||
"\n",
|
||||
"N = me.ReferenceFrame('N')\n",
|
||||
"A = me.ReferenceFrame('A')\n",
|
||||
"B = me.ReferenceFrame('B')\n",
|
||||
"\n",
|
||||
"A.orient_axis(N, q1, N.z)\n",
|
||||
"B.orient_axis(N, q2, N.z)\n",
|
||||
"\n",
|
||||
"O = me.Point('O')\n",
|
||||
"P1 = me.Point('P1')\n",
|
||||
"P2 = me.Point('P2')\n",
|
||||
"\n",
|
||||
"O.set_vel(N, 0)\n",
|
||||
"\n",
|
||||
"P1.set_pos(O, -l*A.y)\n",
|
||||
"P2.set_pos(P1, -l*B.y)\n",
|
||||
"\n",
|
||||
"P1.v2pt_theory(O, N, A)\n",
|
||||
"P2.v2pt_theory(P1, N, B)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\displaystyle l \\cos{\\left(q_{1} \\right)} \\dot{q}_{1}\\mathbf{\\hat{n}_x} + l \\sin{\\left(q_{1} \\right)} \\dot{q}_{1}\\mathbf{\\hat{n}_y}$"
|
||||
],
|
||||
"text/plain": [
|
||||
"l⋅cos(q₁)⋅q₁̇ n_x + l⋅sin(q₁)⋅q₁̇ n_y"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"P1.vel(N).express(N)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "TagUIFocus5",
|
||||
"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.12.4"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
27
补课/多体动力学/16_generalized_forces.py
Normal file
27
补课/多体动力学/16_generalized_forces.py
Normal file
@ -0,0 +1,27 @@
|
||||
import sympy as sm
|
||||
import sympy.physics.mechanics as me
|
||||
me.init_vprinting(use_latex='mathjax')
|
||||
|
||||
l = sm.symbols('l')
|
||||
q1, q2, u1, u2 = me.dynamicsymbols('q1, q2, u1, u2')
|
||||
|
||||
N = me.ReferenceFrame('N')
|
||||
A = me.ReferenceFrame('A')
|
||||
B = me.ReferenceFrame('B')
|
||||
|
||||
A.orient_axis(N, q1, N.z)
|
||||
B.orient_axis(N, q2, N.z)
|
||||
|
||||
O = me.Point('O')
|
||||
P1 = me.Point('P1')
|
||||
P2 = me.Point('P2')
|
||||
|
||||
O.set_vel(N, 0)
|
||||
|
||||
P1.set_pos(O, -l*A.y)
|
||||
P2.set_pos(P1, -l*B.y)
|
||||
|
||||
P1.v2pt_theory(O, N, A)
|
||||
P2.v2pt_theory(P1, N, B)
|
||||
|
||||
print(P1.vel(N).express(N))
|
Loading…
x
Reference in New Issue
Block a user