Exemplo n.º 1
0
def build_external_cylinder(cyl_radius, shape_length, density, contact_method,
                            offset):
    """
    Build a left and right cylinder next to the shape_lenght that must be centered
    on 0,0,0 coord system.
    :param cyl_radius: radius of the two external cylinders
    :param shape_length: lenght of the shape
    :param density: Density of the cylinders
    :param contact_method: SMC or NSC
    :param offset: distance between disk and shape
    :return: two ChEasyCylinder
    """
    height = 0.01 * shape_length
    qCylinder = chrono.Q_from_AngX(90 * chrono.CH_C_DEG_TO_RAD)
    left_cyl = chrono.ChBodyEasyCylinder(cyl_radius, height, density, True,
                                         False, contact_method)
    right_cyl = chrono.ChBodyEasyCylinder(cyl_radius, height, density, True,
                                          False, contact_method)
    left_cyl.SetRot(qCylinder)
    right_cyl.SetRot(qCylinder)
    left_cyl.SetPos(chrono.ChVectorD(0, 0, -(shape_length / 2. + offset)))
    right_cyl.SetPos(chrono.ChVectorD(0, 0, shape_length / 2. + offset))
    left_cyl.SetBodyFixed(True)
    right_cyl.SetBodyFixed(True)
    return left_cyl, right_cyl
def AddFixedObstacles(system):
    # Create contact material, of appropriate type. Use default properties
    material = None
    if (NSC_SMC == chrono.ChContactMethod_NSC):
        matNSC = chrono.ChMaterialSurfaceNSC()
        #Change NSC material properties as desired
        material = matNSC
    elif (NSC_SMC == chrono.ChContactMethod_SMC):
        matSMC = chrono.ChMaterialSurfaceSMC()
        # Change SMC material properties as desired
        material = matSMC
    else:
        raise ("Unvalid Contact Method")
    radius = 3
    length = 10
    obstacle = chrono.ChBodyEasyCylinder(radius, length, 2000, True, True,
                                         material)

    obstacle.SetPos(chrono.ChVectorD(-20, 0, -2.7))
    obstacle.SetBodyFixed(True)

    system.AddBody(obstacle)

    for i in range(8):
        stoneslab = chrono.ChBodyEasyBox(0.5, 2.5, 0.25, 2000, True, True,
                                         material)
        stoneslab.SetPos(chrono.ChVectorD(-1.2 * i + 22, -1.5, -0.05))

        stoneslab.SetRot(
            chrono.Q_from_AngAxis(15 * chrono.CH_C_DEG_TO_RAD, chrono.VECT_Y))
        stoneslab.SetBodyFixed(True)
        system.AddBody(stoneslab)
    def build(self) -> None:
        """

        :param self:
        :return:
        """
        "Set friction, value = 0.42"
        "Set young modulus, value = 2.7 GPa"
        self._body = chrono.ChBodyEasyCylinder(self._diameter, self._height,
                                               self._density, False, True,
                                               self._contact_material)
        self._body.SetPos(chrono.ChVectorD(*self._position))
        self._body.SetMass(self._mass)
Exemplo n.º 4
0
builder = fea.ChBuilderBeamIGA()
builder.BuildBeam(
    my_mesh,  # the mesh to put the elements in
    msection,  # section of the beam
    20,  # number of sections (spans)
    chrono.ChVectorD(0, 0, 0),  # start point
    chrono.ChVectorD(beam_L, 0, 0),  # end point
    chrono.VECT_Y,  # suggested Y direction of section
    1)  # order (3 = cubic, etc)

node_mid = builder.GetLastBeamNodes()[m.floor(
    builder.GetLastBeamNodes().size() / 2.0)]

# Create the flywheel and attach it to the center of the beam

mbodyflywheel = chrono.ChBodyEasyCylinder(0.24, 0.05, 7800)  # R, h, density
mbodyflywheel.SetCoord(
    chrono.ChCoordsysD(
        node_mid.GetPos() + chrono.ChVectorD(
            0, 0.05, 0),  # flywheel initial center (plus Y offset)
        chrono.Q_from_AngAxis(CH_C_PI / 2.0, chrono.VECT_Z)
    )  # flywheel initial alignment (rotate 90° so cylinder axis is on X)
)
my_system.Add(mbodyflywheel)

myjoint = chrono.ChLinkMateFix()
myjoint.Initialize(node_mid, mbodyflywheel)
my_system.Add(myjoint)

# Create the truss
truss = chrono.ChBody()
Exemplo n.º 5
0
    chrono.GetChronoDataFile("textures/pinkwhite.png"))

# ...the rotating bar support for the two epicycloidal wheels
mbody_train = chrono.ChBodyEasyBox(8, 1.5, 1.0, 1000, True, False, mat)
mphysicalSystem.Add(mbody_train)
mbody_train.SetPos(chrono.ChVectorD(3, 0, 0))

# ...which must rotate respect to truss along Z axis, in 0,0,0
link_revoluteTT = chrono.ChLinkLockRevolute()
link_revoluteTT.Initialize(
    mbody_truss, mbody_train,
    chrono.ChCoordsysD(chrono.ChVectorD(0, 0, 0), chrono.QUNIT))
mphysicalSystem.AddLink(link_revoluteTT)

# ...the first gear
mbody_gearA = chrono.ChBodyEasyCylinder(radA, 0.5, 1000, True, False, mat)
mphysicalSystem.Add(mbody_gearA)
mbody_gearA.SetPos(chrono.ChVectorD(0, 0, -1))
mbody_gearA.SetRot(chrono.Q_from_AngX(m.pi / 2))
mbody_gearA.AddAsset(cylinder_texture)

# for aesthetic reasons, also add a thin cylinder only as a visualization
mshaft_shape = chrono.ChCylinderShape()
mshaft_shape.GetCylinderGeometry().p1 = chrono.ChVectorD(0, -3, 0)
mshaft_shape.GetCylinderGeometry().p2 = chrono.ChVectorD(0, 10, 0)
mshaft_shape.GetCylinderGeometry().rad = radA * 0.4
mbody_gearA.AddAsset(mshaft_shape)

# ...impose rotation speed between the first gear and the fixed truss
link_motor = chrono.ChLinkMotorRotationSpeed()
link_motor.Initialize(mbody_gearA, mbody_truss,
system.Add(constraint_pos)

## -------------------------------------------------------------------------
## EXERCISE 1a
##
## Add a cylinder.
## Suggested size: 0.02 radius, 0.1 height, density:1000.
## Hint: use the ChBodyEasyCylinder to make the cylinder, pass size as
## parameters in construction.
##
## -------------------------------------------------------------------------

# create the cylinder
cylinder = chrono.ChBodyEasyCylinder(
    0.02,  # radius
    0.1,  # height
    1000,  # density (used to auto-set inertia, mass)
    True,  # do collide 
    True)  # do visualize

# move cylinder to end of beam
cylinder.SetPos(beam_nodes[-1].GetPos() + chrono.ChVectorD(0, -0.05, 0))

# add it to the system
system.Add(cylinder)

## -------------------------------------------------------------------------
## EXERCISE 1b
##
## Attach the cylinder to the free end of the cable.
## Hint: use the ChLinkPointFrame to connect the cylinder and the end node.
##
    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)