K i?:dZddlmZddlmcmZ ddZddZ y)zOThis module contains some sample symbolic models used for testing and examples.)backendNctjdj|}tjdj|}tjdj|}tjd}tjdj|}tjdj|}tjdj|} tj d} tj d } | j| d | g} g} g}g}t|D]W}| d jd j|||| jz}|j| | d j| ||| jzz| j|tjd j||||}| j||||jz || ||z||||zz } |||dz||dzz||dz||dzzzz }|r ||||zz }|r|| |z }|j||| jzf|j|Ztj | ||| }|j#|||S#t$rYwxYw)asReturns a system containing the symbolic equations of motion and associated variables for a simple multi-degree of freedom point mass, spring, damper system with optional gravitational and external specified forces. For example, a two mass system under the influence of gravity and external forces looks like: :: ---------------- | | | | g \ | | | V k0 / --- c0 | | | | x0, v0 --------- V | m0 | ----- --------- | | | | | \ v | | | k1 / f0 --- c1 | | | | x1, v1 --------- V | m1 | ----- --------- | f1 V Parameters ========== n : integer The number of masses in the serial chain. apply_gravity : boolean If true, gravity will be applied to each mass. apply_external_forces : boolean If true, a time varying external force will be applied to each mass. Returns ======= kane : sympy.physics.mechanics.kane.KanesMethod A KanesMethod object. m:{}zk:{}zc:{}gzx:{}zv:{}zf:{}Noriginrzcenter{}zblock{}q_indu_indkd_eqs)smsymbolsformatmedynamicsymbolsReferenceFramePointset_velrange locatenewxvelappendParticlediff IndexError KanesMethodkanes_equations)n apply_gravityapply_external_forcesmass stiffnessdampingacceleration_due_to_gravity coordinatesspeeds specifiedsceilingrpointskinematic_equations particlesforcesicenterblock total_forcekanes d/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/physics/mechanics/models.pymulti_mass_spring_damperr6 s\ ::fmmA& 'D 6==+,Ijjq)*G"$**S/##FMM!$45K   v}}Q/ 0F""6==#34J$G XXh F NN7AXFI F 1X %%j&7&7&:&1!nwyy&@Bwr w 7ay799,!- . f I,,Q/aA""6!9{1~/B/B/D#DE!! }{1~5qzF1I-.   Ia!e,{1q5/AA#AENVAE]:; >'F!4 6DF+ K#   s(&K KKc|dkr tdtjdj|dz}tjdj|dz}|dur'tjdj|dz}t j dj|dz}t j d j|}t j d \}} tj d } tjd } | j| dtjd } | j| |d| jz| j| |d| jztjd| |d} | g}| g}| g}| |d |z| jzfg}|dj| |dz g}|dus|durg}nd}t|D]}| jdj|d||dz| j g}|j#| ||dz| j z|j%||dj'dj|dz|||jz}|j)|d| ||j%|tjdt+|dzz|||dz}|j%||j%|||dz |z| jzf|dur|j%||dk(r$|j%| || | j zf||dz k(r$|j%|||| j zfn9|j%|||| j z||dz| j zz f|j%||dzj| ||dzz  |durFtjd}|j%| || jzf|j%|tj,| |||}|j/|||S)a-Returns the system containing the symbolic first order equations of motion for a 2D n-link pendulum on a sliding cart under the influence of gravity. :: | o y v \ 0 ^ g \ | --\-|---- | \| | F-> | o --|---> x | | --------- o o Parameters ========== n : integer The number of links in the pendulum. cart_force : boolean, default=True If true an external specified lateral force is applied to the cart. joint_torques : boolean, default=False If true joint torques will be added as specified inputs at each joint. Returns ======= kane : sympy.physics.mechanics.kane.KanesMethod A KanesMethod object. Notes ===== The degrees of freedom of the system are n + 1, i.e. one for each pendulum link and one for the lateral motion of the cart. M x' = F, where x = [u0, ..., un+1, q0, ..., qn+1] The joint angles are all defined relative to the ground where the x axis defines the ground line and the y axis points up. The joint torques are applied between each adjacent link and the between the cart and the lower link where a positive torque corresponds to positive angle. rz/The number of links must be a positive integer.zq:{}r zu:{}TzT1:{}rzl:{}zg tIOP0Pa0NzB{}Axisr zP{}PaFr ) ValueErrorrrrrrrrrset_posrryrr orientnewz set_ang_velrr v2pt_theorystrrr )r! cart_force joint_torquesquTmlrtr8r9r:r;framesr,r.r/kindiffs specifiedr0BiPiPair>r4s r5n_link_pendulum_on_cartrUpsb AvJKK &--A./A &--A./A   gnnQU3 4 6==Q'(A 6==#$A ::e DAq #A  AIIaO $BJJq!A$*JJq!A$* ++eR1 &CSFTFIAaD519qss?# $F! ! qt#$HT]d2  1X5 [[a&1QU8QSS/ B q!AE(QSS.) b BZ ! !%,,q1u"5qtbdd{ C vbz1b) bkk$QU+R1q5: rAa!eH9q=133./0 D   QqT "Av q1Q4%!##+./AEz r1Q4!##:./ r1Q4!##:!a%133#>?@!a% a(1QU834558T   c " r1qss7m$ >>!1Ah ?DF+ K)r FF)r TF) __doc__ sympy.corerrsympy.physics.mechanicsphysics mechanicsrr6rUrVr5r]s* %$$1638cLvrV