You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Carlos Adir edited this page Nov 15, 2021
·
2 revisions
To start, please see in the page RBDyn problem what kind of problem we treat.
To define a simple pendulum, we have
frommatplotlibimportpyplotaspltfromcompmec.rbdynimport*a=1# Rope's lenght or radiustheta=Variable("theta") # The angleR0=FrameReference() # The Inertial Reference FrameR1=FrameReference(R0, rotation=(-pi/2+theta, "z"))
R2=FrameReference(R1, translation=(a, 0, 0))
ball=Object(R2, name="ball") # We put the ball connected to the frame R2ball.mass=1# Pendulum's massE=ball.KineticEnergy(R0) # We get the kinetic energytheta0=pi/3# Initial position at t = 0dtheta0=0# Initial velocity at t = 0Simulation.initialconditions= {theta: (theta0, dtheta0)}
Simulation.totaltime=10# We are going to simulate 10 secondsSimulation.totalenergy=Eresults=Simulation.run()
times=results["time"] # or the variable timethetas=results["theta"] # or the variable thetaplt.plot(times, thetas)
plt.show()