Hello

I am trying to model a 2D double pendulum problem with the following 
geometry and initial conditions. However, the solution does not match the 
analytical results. I would like to verify whether my inputs are correct.

Also, if I plan to make one of the links flexible, what would be an 
efficient way to implement it?

The code is included below.

....................................................................................................................................................

import pychrono as chrono
import pychrono.irrlicht as chronoirr

# Create system

sys = chrono.ChSystemNSC()
sys.SetGravitationalAcceleration(chrono.ChVector3d(0, -9.81, 0))

# 1. Ground body (fixed)
ground = chrono.ChBody()
ground.SetFixed(True)
ground.SetPos(chrono.ChVector3d(0, 0, 0))
sys.Add(ground)

# 2. First pendulum body
pend1 = chrono.ChBody()
pend1.SetMass(0.79)
pend1.SetInertiaXX(chrono.ChVector3d(0.01, 0.01, 0.0658))
pend1.SetPos(chrono.ChVector3d(0, -0.5, 0))  # CG in center of bar
pend1.SetAngVelParent(chrono.ChVector3d(0, 0, 10))
sys.Add(pend1)

# Visual: 1m tall, half-dim = 0.5, shift visual down by 0.5
shape1 = chrono.ChVisualShapeBox(chrono.ChVector3d(0.01,1, 0.01))
shape1.SetColor(chrono.ChColor(0.5, 0.5, 0.8))
pend1.AddVisualShape(shape1)

# 3. Second pendulum body
pend2 = chrono.ChBody()
pend2.SetMass(0.3)
pend2.SetInertiaXX(chrono.ChVector3d(0.01, 0.01, 0.0250))
pend2.SetPos(chrono.ChVector3d(0, -1.5, 0))  # CG in center of second bar
pend2.SetAngVelParent(chrono.ChVector3d(0, 0, 5))
sys.Add(pend2)

# Visual for pend2
shape2 = chrono.ChVisualShapeBox(chrono.ChVector3d(0.01, 1, 0.01))
shape2.SetColor(chrono.ChColor(0.8, 0.5, 0.5))
pend2.AddVisualShape(shape2)

# 4. Revolute joint between ground and pend1 at origin
joint1 = chrono.ChLinkRevolute()
frame1 = chrono.ChFramed(chrono.ChVector3d(0, 0, 0))
joint1.Initialize(ground, pend1, frame1)
sys.Add(joint1)

# 5. Revolute joint between pend1 and pend2 at (0, -1, 0)
joint2 = chrono.ChLinkRevolute()
frame2 = chrono.ChFramed(chrono.ChVector3d(0, -1, 0))
joint2.Initialize(pend1, pend2, frame2)
sys.Add(joint2)

# 6. Visualization setup
vis = chronoirr.ChVisualSystemIrrlicht()
vis.AttachSystem(sys)
vis.SetWindowSize(1024, 768)
vis.SetWindowTitle("Double Pendulum")
vis.Initialize()
vis.AddSkyBox()
vis.AddCamera(chrono.ChVector3d(0.5, 1.5, 1.0))  # Camera looking in 3D
vis.AddTypicalLights()

# Simulation loop
while vis.Run():
    vis.BeginScene()
    vis.Render()
    vis.EndScene()
    sys.DoStepDynamics(0.005)

-- 
You received this message because you are subscribed to the Google Groups 
"ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to projectchrono+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/projectchrono/00ec8823-0972-493c-aeb1-fdc60d0b6e4en%40googlegroups.com.

Reply via email to