melasticity.SetGwithPoissonRatio(0.3)
melasticity.SetIyy((CH_C_PI / 4.0) * (pow(beam_ro, 4) - pow(beam_ri, 4)))
melasticity.SetIzz((CH_C_PI / 4.0) * (pow(beam_ro, 4) - pow(beam_ri, 4)))
melasticity.SetJ((CH_C_PI / 2.0) * (pow(beam_ro, 4) - pow(beam_ri, 4)))

msection = fea.ChBeamSectionCosserat(melasticity)
msection.SetDensity(7800)
msection.SetCircular(True)
msection.SetDrawCircularRadius(
    beam_ro)  # SetAsCircularSection(..) would overwrite Ixx Iyy J etc.
msection.SetArea(CH_C_PI * (pow(beam_ro, 2) - pow(beam_ri, 2)))

# Use the ChBuilderBeamIGA tool for creating a straight rod
# divided in Nel elements:

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
# a ChElasticityCosserat and ChInertiaCosserat models, and optional ChDampingCosserat and ChPlasticityCosserat.
minertia = fea.ChInertiaCosseratSimple()
minertia.SetAsRectangularSection(
    beam_wy, beam_wz,
    2700)  # automatically sets A etc., from width, height, density

melasticity = fea.ChElasticityCosseratSimple()
melasticity.SetYoungModulus(73.0e9)
melasticity.SetGwithPoissonRatio(0.3)
melasticity.SetAsRectangularSection(beam_wy, beam_wz)

msection1 = fea.ChBeamSectionCosserat(minertia, melasticity)

msection1.SetDrawThickness(beam_wy, beam_wz)

builder_iga = fea.ChBuilderBeamIGA()
builder_iga.BuildBeam(
    my_mesh,  # the mesh to put the elements in
    msection1,  # section of the beam
    32,  # number of sections (spans)
    vA,  # start point
    vC,  # end point
    chrono.VECT_Y,  # suggested Y direction of section
    3)  # order (3 = cubic, etc)
builder_iga.GetLastBeamNodes().front().SetFixed(True)
node_tip = builder_iga.GetLastBeamNodes()[-1]
node_mid = builder_iga.GetLastBeamNodes()[17]

# Create the vertical beam (Here use Euler beams, for example).
msection2 = fea.ChBeamSectionEulerAdvanced()