def fix_extremity(self, fea_nodes, body, system): """ Fix the extremities of the sleeve to the left and right side of the body :param body: a ChBody where the nodes of the sleeve will be fixed :param system: :return: """ for fn in fea_nodes: constr = chrono.ChLinkMateGeneric() constr.Initialize(fn, body, False, fn.Frame(), fn.Frame()) system.Add(constr) constr.SetConstrainedCoords(True, True, True, True, True, True)
my_mesh.AddElement(belement2); # Apply a force or a torque to a node: hnode2.SetForce(chrono.ChVectorD(4, 2, 0)) hnode3.SetTorque(chrono.ChVectorD(0, -0.04, 0)) # Fix a node to ground: # hnode1.SetFixed(True) # otherwise fix it using constraints: mtruss = chrono.ChBody() mtruss.SetBodyFixed(True) my_system.Add(mtruss) constr_bc = chrono.ChLinkMateGeneric() constr_bc.Initialize(hnode3, mtruss, False, hnode3.Frame(), hnode3.Frame()) my_system.Add(constr_bc) constr_bc.SetConstrainedCoords(True, True, True, # x, y, z True, True, True) # Rx, Ry, Rz constr_d = chrono.ChLinkMateGeneric() constr_d.Initialize(hnode1, mtruss, False, hnode1.Frame(), hnode1.Frame()) my_system.Add(constr_d) constr_d.SetConstrainedCoords(False, True, True, # x, y, z False, False,False) # Rx, Ry, Rz # Add some EULER-BERNOULLI BEAMS (the fast way!) # Shortcut!
msection.SetBeamRaleyghDamping(0.200) msection.SetDensity(1500) # Create a beam of Eulero-Bernoulli type: melementA = fea.ChElementBeamEuler() melementA.SetNodes(mnodeA, mnodeB) melementA.SetSection(msection) my_mesh.AddElement(melementA) # Create also a truss truss = chrono.ChBody() truss.SetBodyFixed(True) my_system.Add(truss) # Create a constraat the end of the beam constr_a = chrono.ChLinkMateGeneric() constr_a.Initialize(mnodeA, truss, False, mnodeA.Frame(), mnodeA.Frame()) my_system.Add(constr_a) constr_a.SetConstrainedCoords(True, True, True, # x, y, z True, True, True) # Rx, Ry, Rz # APPLY SOME LOADS! # First: loads must be added to "load containers", # and load containers must be added to your system mloadcontainer = chrono.ChLoadContainer() my_system.Add(mloadcontainer) # Example 1: # Add a vertical load to the end of the beam element:
# melement.AddLayer(plate_thickness/3, 0 * CH_C_DEG_TO_RAD, mat_ortho) elarray[(iu - 1) * (nels_W) + (iw - 1)] = melement nodesLoad.append(nodes_end[int(len(nodes_end) / 2)]) nodePlotA = nodes_end[int(len(nodes_end) / 2)] nodePlotB = nodes_end[int(len(nodes_end) / 2)] for mstartnode in nodes_start : mstartnode.SetFixed(True) mtruss = chrono.ChBody() mtruss.SetBodyFixed(True) my_system.Add(mtruss) for mendnode in nodes_left : mlink = chrono.ChLinkMateGeneric(False, True, False, True, False, True) mlink.Initialize(mendnode, mtruss, False, mendnode.Frame(), mendnode.Frame()) my_system.Add(mlink) for mendnode in nodes_right : mlink = chrono.ChLinkMateGeneric(False, True, False, True, False, True) mlink.Initialize(mendnode, mtruss, False, mendnode.Frame(), mendnode.Frame()) my_system.Add(mlink) load_force = chrono.ChVectorD(0, -2000, 0) load_torque = chrono.VNULL # reference solution to plot ref_X.AddPoint(0.10, 1 - 0.16) ref_X.AddPoint(0.20, 1 - 0.37) ref_X.AddPoint(0.30, 1 - 0.66)
def __init__(self, sys, gravity, material, width, height, position_base, position_tip, damping, elements, torque=10, origin=True, stator_constraint=None): self.mesh = fea.ChMesh() self.mesh.SetAutomaticGravity(gravity) self.section = fea.ChBeamSectionAdvanced() self.section.SetAsRectangularSection(width, height) self.section.SetYoungModulus(material.modulus) self.section.SetGshearModulus(material.shear) self.section.SetDensity(material.density) self.section.SetBeamRaleyghDamping(damping) self.position_base = chrono.ChVectorD(*position_base) self.position_tip = chrono.ChVectorD(*position_tip) self.builder = fea.ChBuilderBeamEuler( ) #Use the beam builder assembly method to assembly each beam self.builder.BuildBeam( self.mesh, self.section, elements, self.position_base, self.position_tip, chrono.ChVectorD(0, 1, 0), ) self.stator = chrono.ChBodyEasyCylinder(0.01, 0.01, 1000) self.stator.SetPos(self.position_base) self.stator.SetBodyFixed(origin) self.frame = chrono.ChFrameD(self.stator) sys.Add(self.stator) if (origin == False) and ( stator_constraint is not None ): #If the beam is not located at the origin, it must need to be constrained to another beam self.constraint = chrono.ChLinkMateGeneric() self.constraint.Initialize(self.stator, stator_constraint, False, chrono.ChFrameD(self.stator), chrono.ChFrameD(stator_constraint)) self.constraint.SetConstrainedCoords(True, True, True, True, True, True) sys.Add(self.constraint) self.frame = chrono.ChFrameD(self.stator) self.rotor = chrono.ChBodyEasyCylinder(0.011, 0.011, 1000) self.rotor.SetPos(self.position_base) sys.Add(self.rotor) self.frame.SetRot( chrono.Q_from_AngAxis(chrono.CH_C_PI_2, chrono.VECT_X) ) #Rotate the direction of rotation to be planar (x-z plane) self.motor = chrono.ChLinkMotorRotationTorque() self.motor.Initialize(self.rotor, self.stator, self.frame) sys.Add(self.motor) self.motor.SetTorqueFunction(chrono.ChFunction_Const(torque)) self.arm_base = (self.builder.GetLastBeamNodes().front()) self.arm_tip = (self.builder.GetLastBeamNodes().back()) self.mate = chrono.ChLinkMateGeneric() self.mate.Initialize(self.builder.GetLastBeamNodes().front(), self.rotor, chrono.ChFrameD(self.builder.GetLastBeamNodes( ).front().GetPos())) #constrain beam to rotor self.mate.SetConstrainedCoords( True, True, True, True, True, True ) #constraints must be in format: (True,True,True,True,True,True) to constrain x,y,z,rotx,roty,rotz coordinates sys.Add(self.mate) self.visual = fea.ChVisualizationFEAmesh(self.mesh) self.visual.SetFEMdataType( fea.ChVisualizationFEAmesh.E_PLOT_ELEM_BEAM_MZ) self.visual.SetColorscaleMinMax(-1.4, 1.4) self.visual.SetSmoothFaces(True) self.visual.SetWireframe(False) self.mesh.AddAsset(self.visual) sys.Add(self.mesh)