New question #688763 on Yade:
https://answers.launchpad.net/yade/+question/688763

hi all,

I want to achieve the oscillation movement, as I mentioned in a previous 
question.[1]  

generally speaking, making the shaft rotates 200 degrees in one direction and 
then reverse it back.  

Here is my code.

########################
from yade import ymport
from yade import pack,export,geom
import itertools
from numpy import *
import numpy as np
from yade import plot, export, utils
import math
target=0.12
young=4e8
finalcompFricDegree=19.5
rate = 20*(2*pi/60)
############################################# sphere particles material 
properties ########################
sphereMat=O.materials.append(CohFrictMat(young=young,poisson=0.3,frictionAngle=radians(finalcompFricDegree),isCohesive=False,alphaKr=0.2,alphaKtw=0,etaRoll=0.5,momentRotationLaw=True,density=2648))
#O.bodies.append(ymport.text("rotation.txt",material = sphereMat))
O.bodies.append([
        sphere((0.1,0.1,0.1),.03,color=(0,1,0)),
])
################################################ create the penetrator and 
shaft and the cylinder ##############################
facetMat=O.materials.append(FrictMat(young=young,poisson=0.3,frictionAngle=radians(finalcompFricDegree),density=0))
O.materials.append(FrictMat(young=young,poisson=0.3,frictionAngle=0,density=0,label='walls'))

facets =  
O.bodies.append(geom.facetCylinder((200e-3,200e-3,300e-3),200e-3,600e-3,wallMask=6,material='walls',segmentsNumber=100))

x0=0.2;y0=0.2;z0=0.39665
cylinderIDS= O.bodies.append(geom.facetCylinder((x0,y0,z0-0.02),
        radius=0.0125,height=0.15,orientation=Quaternion((0, 0, 1), 
0),wallMask=5,segmentsNumber=10, angleRange=None,material=facetMat))
coneIDS= O.bodies.append(geom.facetCone((x0,y0,z0-0.085825-0.02),
        
radiusTop=0.0125,radiusBottom=0.0,height=0.02165,orientation=Quaternion((0, 0, 
1), 0),wallMask=6,segmentsNumber=10, angleRange=None,material=facetMat))
conecheck=O.bodies[-1].id
################################################  set the global engine for the 
simulation##############################
O.engines=[
        ForceResetter(),
        InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
        InteractionLoop(
                        
[Ig2_Sphere_Sphere_ScGeom6D(),Ig2_Facet_Sphere_ScGeom()],
                        
[Ip2_FrictMat_FrictMat_FrictPhys(),Ip2_CohFrictMat_CohFrictMat_CohFrictPhys()],
                                        
[Law2_ScGeom_FrictPhys_CundallStrack(),Law2_ScGeom6D_CohFrictPhys_CohesionMoment(useIncrementalForm=True,always_use_moment_law=True,label='cohesiveLaw')]
        ),
        
GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=10,timestepSafetyCoefficient=0.8),
        NewtonIntegrator(gravity=(0,0,-9.81),damping=0.7),
        
HelixEngine(angularVelocity=rate,linearVelocity=-0.05,rotateAroundZero=True,zeroPoint=(x0,y0,z0),rotationAxis=(0,0,1),ids=cylinderIDS),
        
HelixEngine(angularVelocity=rate,linearVelocity=-0.05,rotateAroundZero=True,zeroPoint=(x0,y0,z0),rotationAxis=(0,0,1),ids=coneIDS),
        PyRunner(command='stop_loading()',iterPeriod=10000),
        PyRunner (command ="ossillation_rotation",iterPeriod = 1),
]

def ossillation_rotation():
        rotationAngle = O.bodies[cylinderIDS].state.rot().norm()
        if 0 < rotationAngle <= 200:
                angularVelocity = rate
                
O.bodies[cylinderIDS].state.refOri=O.bodies[cylinderIDS].state.ori
        if 0 < rotationAngle <= 200:
                angularVelocity = - rate   ### it seems code here is not 
working.
                
O.bodies[cylinderIDS].state.refOri=O.bodies[cylinderIDS].state.ori
########################## stop the simulation 
###################################################################
def stop_loading():
        if 
((O.bodies[conecheck].state.pos[2]-O.bodies[conecheck].state.refPos[2])*(-1))>target:
                O.pause()

###############################
i defined a function called ossillation_rotation and use pyrunner to check it 
every timestep. but it seems it doesn'e work. it rotates always in one 
direction. 


Thanks in advance.

Yong

[1] https://answers.launchpad.net/yade/+question/688324





-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp

Reply via email to