How to make a propeller spin?

Asked by William

Hi, everyone!
I’m building a blender and I meet a question. Please run my code and open the Primary view. We can see that the blender rotates on the central axis. However, I hope the four propellers can rotate on their own while spin with the blender. How could I achieve it ?

Next is my script

import random
import math
from yade import geom, pack, utils, plot, ymport, export
import numpy as np

#particle parameters
Density = 3000
FrictionAngle = 0
PoissonRatio = 0.5
Young = 300e6
Damp = 0.7
AvgRadius1 = 0.02
N_particles1 = 15000
AvgRadius2 = 0.024
N_particles2 = 10000

#Wall constants
WDensity = 3000
WFrictionAngle = 0.0
WPoissonRatio = 0.5
WYoung = 600e7

SphereMat = O.materials.append(FrictMat(young = Young, poisson = PoissonRatio, frictionAngle = radians(FrictionAngle), density = Density))
WallMat = O.materials.append(FrictMat(young = WYoung, poisson = WPoissonRatio, frictionAngle = radians(WFrictionAngle), density = WDensity))

### tank
center = (0, 0, 0.5)
diameter = 1
height = 1
cylinder = geom.facetCylinder(center=center, radius=diameter/2, height=height, segmentsNumber=80, wallMask=6,material=WallMat)
O.bodies.append(cylinder)

### blender
## bottom beam
totallist=[]
box = utils.box((0,0,0.05),(0.45,0.015,0.015))
box.mat=O.materials[WallMat]
boxid = O.bodies.append(box)
totallist.append(boxid)

## intermediate beam
box = utils.box((0,0,0.3),(0.015,0.45,0.015))
box.mat=O.materials[WallMat]
boxid = O.bodies.append(box)
totallist.append(boxid)

box = utils.box((0.1,0.25,0.3),(0.1,0.015,0.015))
box.mat=O.materials[WallMat]
boxid = O.bodies.append(box)
totallist.append(boxid)

box = utils.box((-0.1,-0.25,0.3),(0.1,0.015,0.015))
box.mat=O.materials[WallMat]
boxid = O.bodies.append(box)
totallist.append(boxid)

## top beam
box = utils.box((0,0,0.7),(0.45,0.015,0.015))
box.mat=O.materials[WallMat]
boxid = O.bodies.append(box)
totallist.append(boxid)

box = utils.box((0.25,-0.1,0.7),(0.015,0.1,0.015))
box.mat=O.materials[WallMat]
boxid = O.bodies.append(box)
totallist.append(boxid)

box = utils.box((-0.25,0.1,0.7),(0.015,0.1,0.015))
box.mat=O.materials[WallMat]
boxid = O.bodies.append(box)
totallist.append(boxid)

## pillar
box = utils.box((0,0,0.7),(0.02,0.02,0.65))
box.mat=O.materials[WallMat]
boxid = O.bodies.append(box)
totallist.append(boxid)

## propeller 1
box = utils.box((0.25,-0.1,0.6),(0.01,0.005,0.1))
box.mat=O.materials[WallMat]
boxid = O.bodies.append(box)
totallist.append(boxid)

box = utils.box((0.34,-0.1,0.75),(0.01,0.005,0.1))
box.mat=O.materials[WallMat]
axis = (0,1,0)
angle = pi/3
box.state.ori = axis,angle
boxid = O.bodies.append(box)
totallist.append(boxid)

box = utils.box((0.34,-0.1,0.75),(0.01,0.005,0.1))
box.mat=O.materials[WallMat]
axis = (0,1,0)
angle = -pi/3
box.state.ori = axis,angle
box.state.pos = (0.16,-0.1,0.75)
boxid = O.bodies.append(box)
totallist.append(boxid)

## propeller 2
box = utils.box((-0.25,0.1,0.8),(0.01,0.005,0.1))
box.mat=O.materials[WallMat]
boxid = O.bodies.append(box)
totallist.append(boxid)

box = utils.box((-0.34,0.1,0.65),(0.01,0.005,0.1))
box.mat=O.materials[WallMat]
axis = (0,1,0)
angle = pi/3
box.state.ori = axis,angle
boxid = O.bodies.append(box)
totallist.append(boxid)

box = utils.box((-0.34,0.1,0.65),(0.01,0.005,0.1))
box.mat=O.materials[WallMat]
axis = (0,1,0)
angle = -pi/3
box.state.ori = axis,angle
box.state.pos = (-0.16,0.1,0.65)
boxid = O.bodies.append(box)
totallist.append(boxid)

## propeller 3
box = utils.box((0.1,0.25,0.2),(0.005,0.01,0.1))
box.mat=O.materials[WallMat]
boxid = O.bodies.append(box)
totallist.append(boxid)

box = utils.box((0.1,0.34,0.35),(0.005,0.01,0.1))
box.mat=O.materials[WallMat]
axis = (1,0,0)
angle = -pi/3
box.state.ori = axis,angle
boxid = O.bodies.append(box)
totallist.append(boxid)

box = utils.box((0.1,0.34,0.35),(0.005,0.01,0.1))
box.mat=O.materials[WallMat]
axis = (1,0,0)
angle = pi/3
box.state.ori = axis,angle
box.state.pos = (0.1,0.16,0.35)
boxid = O.bodies.append(box)
totallist.append(boxid)

## propeller 4
box = utils.box((-0.1,-0.25,0.4),(0.005,0.01,0.1))
box.mat=O.materials[WallMat]
boxid = O.bodies.append(box)
totallist.append(boxid)

box = utils.box((-0.1,-0.34,0.25),(0.005,0.01,0.1))
box.mat=O.materials[WallMat]
axis = (1,0,0)
angle = -pi/3
box.state.ori = axis,angle
boxid = O.bodies.append(box)
totallist.append(boxid)

box = utils.box((-0.1,-0.34,0.35),(0.005,0.01,0.1))
box.mat=O.materials[WallMat]
axis = (1,0,0)
angle = pi/3
box.state.ori = axis,angle
box.state.pos = (-0.1,-0.16,0.25)
boxid = O.bodies.append(box)
totallist.append(boxid)

totalclump = O.bodies.clump(totallist)
s1=O.bodies[-1]
s1.state.blockedDOFs='xyzXYZ'

O.engines=[
   ForceResetter(),
    InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb(),Bo1_Facet_Aabb()]),
    InteractionLoop(
     [Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],
     [Ip2_FrictMat_FrictMat_FrictPhys()],
     [Law2_ScGeom_FrictPhys_CundallStrack()]
   ),
   NewtonIntegrator(gravity=(0,0,-9.8),damping=0.7),
   CombinedKinematicEngine(ids=[s1.id],comb=[RotationEngine(angularVelocity=-0.0001,rotateAroundZero=1,rotationAxis=(0,0,1),zeroPoint=(0,0,0))]),
]
O.dt=0.8*PWaveTimeStep()

Question information

Language:
English Edit question
Status:
Expired
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Yade Guide (yade-guide) said :
#1

Hey qfxx-123, check out some related threads. This is an automated reply.

Title: "about rotate"
Question by jpeng22 on 01 Nov 2016:
 The user is encountering an issue with a Yade ODE simulation where a rigid body is rotating on the rotation axis (0,1,0) and translating along the z-axis, but only rotates in a fixed situation. The user has tried setting the zeroPoint for the RotationEngine to O.bodies[0].state.pos without success. Thanks to Jan Stránský's help, the problem was solved.
https://answers.launchpad.net/yade/+question/403708

Title: "How to rotate the box"
Question by qfxx-123 on 19 Apr 2022:
 The user is seeking guidance on rotating a box in their code using a specific command. They want the box to be rotated 45 degrees around a line that passes through its centroid and is parallel to the z-axis. The suggested solution involves creating the box with the `utils.box()` function, appending it to the list of objects, and then setting its orientation using the `state.ori` attribute with the axis and angle values.
https://answers.launchpad.net/yade/+question/701413

Title: "Rotate cylinder"
Question by mithushan93 on 25 Mar 2021:
 Jim sought advice on simulating gravity in YADE, with Joe recommending using g=-9.8. To ensure accuracy and efficiency, it's often beneficial to adjust velocities or angular velocities rather than directly updating position or orientation, as per best practices in YADE. Jan Stránský's suggestion resolved Jim's query.
https://answers.launchpad.net/yade/+question/696243

Revision history for this message
Launchpad Janitor (janitor) said :
#2

This question was expired because it remained in the 'Open' state without activity for the last 15 days.