Using multiple ChLinkMotorLinearForce() on element

53 views
Skip to first unread message

André Marinho

unread,
Dec 20, 2021, 9:09:01 AM12/20/21
to ProjectChrono
Hello,

I am bulding an example in Python for a fea.ChLoadXYZROTnodeXYZROTnodeBushingGeneric(), which has a stiffness matrix with non-zero terms only in its diagonal. I want to apply forces using a
ChLinkMotorLinearForce() for each direction (changing the respective axis). Althoug my example works with just one motor (in the x-direction with ramp function),
if I create another one (motor2, with frame in the y-direction) I can't get a proper result. Is there any correct way of setting up multiple ChLinkMotorLinearForce()? In the code bellow, the lines related to motor2 are commented.

import numpy as np 
from pychrono import fea, core, pardisomkl

print('Example')

# Creates system, mesh and adds mesh to system
system = core.ChSystemSMC()
system.Set_G_acc(m_acc=core.VNULL)
mesh = fea.ChMesh() system.Add(mesh)

# Creates nodes and adds them to mesh
nodeA = fea.ChNodeFEAxyzrot(core.ChFrameD(core.ChVectorD(0., 0., 0.), core.QUNIT))
nodeB = fea.ChNodeFEAxyzrot(core.ChFrameD(core.ChVectorD(0., 0., 0.), core.QUNIT))
mesh.AddNode(nodeA)
mesh.AddNode(nodeB)

# Fixing node A
truss = core.ChBody()
truss.SetBodyFixed(True)
system.Add(truss)
linkA = core.ChLinkMateGeneric()
linkA.Initialize(nodeA, truss, False, nodeA.Frame(), truss.GetAssetsFrame())
system.Add(linkA)

# Creating slider and motor for node B
slider = core.ChBody()
motor = core.ChLinkMotorLinearForce()
#motor2 = core.ChLinkMotorLinearForce()
system.Add(slider) system.Add(motor)
#system.Add(motor2)
linkB = core.ChLinkMateGeneric()
linkB.Initialize(nodeB, slider, False, nodeB.Frame(), slider.GetAssetsFrame())
linkB.SetConstrainedCoords(True, True, False, False, False, False)
system.Add(linkB)

#Initializing motors
guide_frame = core.ChFrameD(core.VNULL, core.QUNIT)
#guide_frame2 = core.ChFrameD(core.VNULL, core.Q_from_AngZ(np.pi / 2))
motor.Initialize(slider, truss, guide_frame)
#motor2.Initialize(slider, truss, guide_frame2)
ch_function = core.ChFunction_Ramp(0., 20.)
motor.SetForceFunction(ch_function)
#motor2.SetForceFunction(ch_function)

# Creates load container for bushing load and adds to system
load_container = core.ChLoadContainer()
system.Add(load_container)

# Stiffness and damping matrices
K_matrix = core.ChMatrixDynamicD(6, 6)
R_matrix = core.ChMatrixDynamicD(6, 6)
K_matrix[0, 0] = 10
K_matrix[1, 1] = 20
K_matrix[2, 2] = 30
K_matrix[3, 3] = 40
K_matrix[4, 4] = 50
K_matrix[5, 5] = 60

for
i in range(6):
for
j in range(6):
R_matrix[i, j] = 0

# Bushing load between two bodies attached to nodes
ch_bushing = fea.ChLoadXYZROTnodeXYZROTnodeBushingGeneric(nodeA, nodeB, nodeB.Frame() ,K_matrix, R_matrix)
load_container.Add(newload=ch_bushing)

# Perform a non-linear static analysis
solver = pardisomkl.ChSolverPardisoMKL()
system.SetSolver(newsolver=solver)
a_sys = core.ChStaticNonLinearAnalysis(system)
a_sys.SetIncrementalSteps(6)
a_sys.SetMaxIterations(30)
a_sys.SetVerbose(True)
a_sys.SetCorrectionTolerance(1e-10, 1e-14)
time_steps = [0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.]

# Output
for
time_val in time_steps:
system.DoFrameKinematics(end_time=time_val)
system.DoStaticAnalysis(a_sys)
print(time_val)
print(" node1->pos \n", nodeA.GetPos())
print(" node2->pos \n", nodeB.GetPos())

Results for last time step with just one motor:

Nonlinear statics
   max iterations:     30
   incremental steps:  6
   stopping test:      correction
      relative tol:    1e-10
      absolute tol:    1e-14

--- Nonlinear statics iteration 0 |Dx|_wrms = 9.49508e+07 --- Nonlinear statics iteration 1 |Dx|_wrms = 9.84864e+07 --- Nonlinear statics iteration 2 |Dx|_wrms = 7.3256e+07 --- Nonlinear statics iteration 3 |Dx|_wrms = 3.87515e+07 --- Nonlinear statics iteration 4 |Dx|_wrms = 1.32293e+07 --- Nonlinear statics iteration 5 |Dx|_wrms = 2.20331e+06 --- Nonlinear statics iteration 6 |Dx|_wrms = 0.0525289 +++ Newton procedure converged in 7 iterations. |R|_inf = 20 |Qc|_inf = 0 node1->pos [ 0, 0, 0 ] node2->pos [ 2, 0, 0 ]

Results for last time step with both motors

Nonlinear statics
   max iterations:     30
   incremental steps:  6
   stopping test:      correction
      relative tol:    1e-10
      absolute tol:    1e-14

--- Nonlinear statics iteration 0  |Dx|_wrms = 0
+++ Newton procedure converged in 1 iterations.
    |R|_inf = 5.71429  |Qc|_inf = 0

  node1->pos 
 [ 0, 0, 0 ]
  node2->pos 
 [ 0, 0, 0 ]

Thank you in advance.

André Marinho

Reply all
Reply to author
Forward
0 new messages