Re: [Yade-users] [Question #661262]: How to record the rotation angle of polyhedra?

2017-12-04 Thread De zhang
Question #661262 on Yade changed:
https://answers.launchpad.net/yade/+question/661262

De zhang confirmed that the question is solved:
Thanks Jan Stránský, that solved my question.

-- 
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 : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #661262]: How to record the rotation angle of polyhedra?

2017-12-04 Thread De zhang
Question #661262 on Yade changed:
https://answers.launchpad.net/yade/+question/661262

Status: Answered => Solved

De zhang confirmed that the question is solved:
Dear Jan~
The code worked! Moreover, the results showed that the rate of rotation 
(state.angVel) could reveal the relationship between  roll  and cyclic loading 
for one polyhedra, which was better than the accumulated angle (state.ori).
   Thanks again~ It's great help for me!! : )

-- 
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 : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #661262]: How to record the rotation angle of polyhedra?

2017-12-02 Thread Jan Stránský
Question #661262 on Yade changed:
https://answers.launchpad.net/yade/+question/661262

Status: Open => Answered

Jan Stránský proposed the following answer:
I think (not tested) that rate of rotation angle around x axis should be
dotAx = state.angVel.dot(Vector3.UnitX)
and the increment per time step
deltaAx = dotAx * O.dt

try it and let us know
cheers
Jan

-- 
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 : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #661262]: How to record the rotation angle of polyhedra?

2017-11-30 Thread De zhang
Question #661262 on Yade changed:
https://answers.launchpad.net/yade/+question/661262

Status: Solved => Open

De zhang is still having a problem:
Hello, Jan~
I have one more question about the rotation angle of polyhedra that if I want 
to know the rotation angle rate of that. Can I calculate it by 
deltaV/(iter*time-pave) ? or using other command ? like angular velocity?
thanks~

-- 
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 : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #661262]: How to record the rotation angle of polyhedra?

2017-11-30 Thread De zhang
Question #661262 on Yade changed:
https://answers.launchpad.net/yade/+question/661262

De zhang posted a new comment:
Hello, Jan~
I have one more question about the rotation angle of polyhedra that if I want 
to know the rotation angle rate of that. Can I calculate it by 
deltaV/(iter*time-pave) ? or using other command ? like angular velocity?
thanks~

-- 
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 : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #661262]: How to record the rotation angle of polyhedra?

2017-11-30 Thread De zhang
Question #661262 on Yade changed:
https://answers.launchpad.net/yade/+question/661262

De zhang posted a new comment:
Thanks Jan and Bruno~
I will have try~

-- 
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 : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #661262]: How to record the rotation angle of polyhedra?

2017-11-30 Thread De zhang
Question #661262 on Yade changed:
https://answers.launchpad.net/yade/+question/661262

Status: Answered => Solved

De zhang confirmed that the question is solved:
Thanks Jan Stránský, that solved my question.

-- 
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 : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #661262]: How to record the rotation angle of polyhedra?

2017-11-30 Thread Jan Stránský
Question #661262 on Yade changed:
https://answers.launchpad.net/yade/+question/661262

Jan Stránský proposed the following answer:
> I want to record the rotation angle of one or more polyhedra around x
axis.

thanks, it makes it much more clear :-)

o = b.state.ori
v = o.toRotationVector()
ax = v.dot(Vector3.UnitX)

according to your needs, you can record it incrementally
deltaV = ori.toRotationVector() - oriPrev.toRotationVector() # oriPrev is 
stored externally
deltaAx = deltaV.dot(Vector3.UnitX)

not tested for "large" angles, e.g. if it rotates around x axis 2
rounds..

cheers
Jan

-- 
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 : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #661262]: How to record the rotation angle of polyhedra?

2017-11-30 Thread Bruno Chareyre
Question #661262 on Yade changed:
https://answers.launchpad.net/yade/+question/661262

Status: Open => Answered

Bruno Chareyre proposed the following answer:
Yade [3]: q=O.bodies[200].state.ori
Yade [4]: q. +TAB
q.conjugate  q.norm   q.Rotate q.toAxisAngle

q.Identity   q.normalize  q.setFromTwoVectors  
q.toRotationMatrix   
q.inverseq.normalized q.toAngleAxis
q.toRotationVector
Yade [4]: q.toRotationVector()
 ->  [4]: Vector3(0.026689449551319206,0.593081956355,-0.325048371862)

Note that you will never be able to get the rotation angle (unless 1/
you define mathematicaly what "rotation angle" is in 3D then 2/ you
implement an algorithm to calculate it). What you get from state.ori is
orientation, a rather different thing.

Note2: Euler angles are probably not a good way to go.

Bruno

-- 
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 : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #661262]: How to record the rotation angle of polyhedra?

2017-11-30 Thread De zhang
Question #661262 on Yade changed:
https://answers.launchpad.net/yade/+question/661262

De zhang gave more information on the question:
Jan~
I got the 
bodies[200].state.ori=Quaternion((0.5658292752452952,0.037320394020097174,0.823677375836904),2.187809578030986)
  ##quaternion(x,y,z,w)
how to change the Euler angle? around the x axis?

-- 
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 : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #661262]: How to record the rotation angle of polyhedra?

2017-11-30 Thread De zhang
Question #661262 on Yade changed:
https://answers.launchpad.net/yade/+question/661262

De zhang gave more information on the question:
Jan~
I checked the model and found that the bodies[45] was facet!!! Oh! it's .^^
But I still want to know how to record the rotation angle of polyhedra? as the 
ori record the quaternion, how to change to Euler Angle? Using the norm()?

-- 
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 : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #661262]: How to record the rotation angle of polyhedra?

2017-11-30 Thread De zhang
Question #661262 on Yade changed:
https://answers.launchpad.net/yade/+question/661262

Status: Needs information => Open

De zhang gave more information on the question:
Thanks Jan~
Actually I want to record the rotation angle of one or more polyhedra around x 
axis. 
I tried  state.ori, O.bodies[45].state.ori, but it showed zero with the 
iterations.
I also find class yade.wrapper.Polyhedra.GetOri(), but I dont know how to use 
this command.
Could you show me the example of recording one polyhedra rotate angle around x 
axis?

-- 
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 : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #661262]: How to record the rotation angle of polyhedra?

2017-11-30 Thread Jan Stránský
Question #661262 on Yade changed:
https://answers.launchpad.net/yade/+question/661262

Status: Open => Needs information

Jan Stránský requested more information:
Hello,

see my comment in [1]. The problem here is the definition of "the
rotation angle". I think in 3D you can deal with it in many different
ways depending on your purpose..

please be more specific on what you want to achieve. E.g. what should be
the result if the particle rotates 90 deg around x axis and then 90 deg
around y axis? 90+90=180 deg? or 120 deg as it would rotate around
(1,1,1) axis?

cheers
Jan

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

-- 
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 : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #661262]: How to record the rotation angle of polyhedra?

2017-11-29 Thread De zhang
Question #661262 on Yade changed:
https://answers.launchpad.net/yade/+question/661262

Description changed to:
I made a simulation of polyhedra compaction model and I want to record the 
rotation angle of polyhedra,
I tried :
> def addPlotData():
>   Fz=100+50*sin((15/pi)*O.time)
>   w=-plate.state.pos[2]+plate.state.refPos[2]
>   s=O.bodies[45].state.angVel
>   plot.addData(Fz=Fz,w=w,s=s)

I also tried 'state.rot' and 'state.ori' , but can't get any information of 
rotate angle of polyhedra? How to deal with this? 
The whole process is fllowing:

from yade import qt,plot,utils,polyhedra_utils,ymport,export,pack,timing
from yade import *
import numpy

## materials ##
global gravel
global steel
global rubber
gravel = PolyhedraMat()
gravel.density = 2600 #kg/m^3 
gravel.young = 1E7 #Pa
gravel.poisson = 2/1E7
gravel.frictionAngle = 0.5 #rad
gravel.strength = 1E9 # Pa crushable 1000MPa

steel = PolyhedraMat()
steel.density = 7850 #kg/m^3 
steel.young = 10*gravel.young #inital steel was 10*gravel.young
steel.poisson = gravel.poisson
steel.frictionAngle = 0.4 #rad

rubber = PolyhedraMat()
rubber.density = 1000 #kg/m^3 
rubber.young = gravel.young/10
rubber.poisson = gravel.poisson
rubber.frictionAngle = 0.7 #rad

## objects ##
# loading plate name 'laplt'
global ldplt
global ldpltheight
#thickness of plate is 20mm
ldpltheight=0.95
ldplt=polyhedra_utils.polyhedra(steel,v=((-0.15,0,ldpltheight),(-0.075*sqrt(3),-0.075,ldpltheight),(-0.075,-0.075*sqrt(3),ldpltheight),(0,-0.15,ldpltheight),(0.075,-0.075*sqrt(3),ldpltheight),(0.075*sqrt(3),-0.075,ldpltheight),(0.15,0,ldpltheight),(0.075*sqrt(3),0.075,ldpltheight),(0.075,0.075*sqrt(3),ldpltheight),(0,0.15,ldpltheight),(-0.075,0.075*sqrt(3),ldpltheight),(-0.075*sqrt(3),0.075,ldpltheight),(-0.15,0,ldpltheight+0.02),(-0.075*sqrt(3),-0.075,ldpltheight+0.02),(-0.075,-0.075*sqrt(3),ldpltheight+0.02),(0,-0.15,ldpltheight+0.02),(0.075,-0.075*sqrt(3),ldpltheight+0.02),(0.075*sqrt(3),-0.075,ldpltheight+0.02),(0.15,0,ldpltheight+0.02),(0.075*sqrt(3),0.075,ldpltheight+0.02),(0.075,0.075*sqrt(3),ldpltheight+0.02),(0,0.15,ldpltheight+0.02),(-0.075,0.075*sqrt(3),ldpltheight+0.022),(-0.075*sqrt(3),0.075,ldpltheight+0.02)),fixed=False,
 color=(0.75,0.65,0.65))
O.bodies.append(ldplt) # area is 0.082 m^2 & weight is 7850*0.082*0.02=12.874kg

O.bodies.append(utils.wall(0,axis=2,sense=1, material = steel)) #bottom
of samples, wall objects are 'fixed' by default, i.e. not subject to
forces

O.bodies.append(geom.facetCylinder(center=(0.0,0.0,0.15),radius=0.152,height=0.3,orientation=Quaternion((0,0,1),0),segmentsNumber=12,wallMask=4,angleRange=(0.0,2*pi),closeGap=False,radiusTopInner=0.0,radiusBottomInner=0.0,material=steel))
#membrane of samples, radius=0.152>radius of loading plate 0.15 for 2mm

O.bodies.append(geom.facetBunker((0,0,0.3),0.40,0.304,hBunker=0.3,hOutput=0.05,hPipe=0.05,orientation=Quaternion((0,0,1),0),segmentsNumber=12,wallMask=4,angleRange=(0,2*pi),closeGap=False,material=steel))
#bunker for generate samples

#global ballast_up
ballast_up=polyhedra_utils.fillBox((-0.15,-0.15,0.4), 
(0.15,0.15,0.7),gravel,sizemin=[0.025,0.025,0.025],sizemax=[0.05,0.05,0.05],ratio=[1,1,1],seed=4,mask=1)
#global ballast_low
ballast_low=polyhedra_utils.fillBox((-0.11,-0.11,0.0), 
(0.11,0.11,0.4),gravel,sizemin=[0.025,0.025,0.025],sizemax=[0.05,0.05,0.05],ratio=[1,1,1],seed=4,mask=1)


## engines ##
O.engines=[
ForceResetter(),

InsertionSortCollider([Bo1_Polyhedra_Aabb(),Bo1_Wall_Aabb(),Bo1_Facet_Aabb()]),
InteractionLoop(
[Ig2_Wall_Polyhedra_PolyhedraGeom(), 
Ig2_Polyhedra_Polyhedra_PolyhedraGeom(), Ig2_Facet_Polyhedra_PolyhedraGeom()],
[Ip2_PolyhedraMat_PolyhedraMat_PolyhedraPhys(), 
Ip2_FrictMat_PolyhedraMat_FrictPhys()],
[Law2_PolyhedraGeom_PolyhedraPhys_Volumetric()],   # contact 
law -- apply forces #Bo1_Cylinder_Aabb()
),
NewtonIntegrator(damping=0.3,gravity=(0,0,-9.81)),
PolyhedraSplitter(iterPeriod=1,label='Splitter'), # allow splittering 
ballast

PyRunner(command="vtkExporter.exportPolyhedra(what=[('n','b.state.ori[1]')])",realPeriod=10),
PyRunner(command='checkUnbalancedI()',realPeriod=1,label='checker')

#PyRunner(command='VTKExporter.exportFacet(what=[('n','b.id'),,('n','b.state.pos')])',realPeriod=50)
]

vtkExporter = export.VTKExporter('postfalling/Jan-')

O.dt=0.1*polyhedra_utils.PWaveTimeStep()

## selfdefine pyrunner attention the format of the language
def checkUnbalancedI():
print "iter %d, time elapsed %f,  time step %.5e, unbalanced forces = 
%.5f"%(O.iter, O.realtime, O.dt, utils.unbalancedForce())
if O.iter<6000: return 
if unbalancedForce()>0.05: return

O.engines=O.engines+[PyRunner(command='addPlotData()',iterPeriod=50)]+[PyRunner(command='checkersieve()',iterPeriod=500)]
# next time, do not call this function anymore, but the next one 
(unloadPlate) instead
checker.command='cyclicloadingI()'



Re: [Yade-users] [Question #661262]: How to record the rotation angle of polyhedra?

2017-11-29 Thread De zhang
Question #661262 on Yade changed:
https://answers.launchpad.net/yade/+question/661262

Summary changed to:
How to record the rotation angle of polyhedra?

-- 
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 : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp