Re: [Yade-users] [Question #704551]: How to make VTK file of relative particle rotation angle from state1 to state2

2023-01-27 Thread Jan Stránský
Question #704551 on Yade changed:
https://answers.launchpad.net/yade/+question/704551

Jan Stránský proposed the following answer:
a MWE for a case where you have the computed values
###
from yade import export
import builtins # to store "data" and access them from a string command

spheres = [
sphere((0,0,0),1),
sphere((3,0,0),1),
sphere((6,0,0),1),
]
O.bodies.append(spheres)

data = [ # e.g. angle
1,
2,
3,
]
builtins.data = data # make data "global", visible in export module

vtk = export.VTKExporter("test-angle")
vtk.exportSpheres(what=dict(angle="data[b.id]"))
###

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 #704551]: How to make VTK file of relative particle rotation angle from state1 to state2

2023-01-27 Thread Karol Brzezinski
Question #704551 on Yade changed:
https://answers.launchpad.net/yade/+question/704551

Status: Open => Answered

Karol Brzezinski proposed the following answer:
Hi Leonard,

I think that you can use 'rot()' method of body state or Jan's proposal
in VTKExporter.

 MVE
from yade import export
exporter = export.VTKExporter('tmp-')
s = O.bodies.append(sphere((0,0,0),1))

#set current state as reference
setRefSe3()
# set angular velocity
O.bodies[s].state.angVel = (0,0,1)

# rotate
O.run(1000,wait = True)

# export
exporter.exportSpheres(ids='all',what=dict(rotation_method_1 = 
'b.state.rot()',rotation_method_2 = 
'(b.state.refOri.conjugate()*b.state.ori).toRotationVector() '))
##

Cheers,
Karol

-- 
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 #704551]: How to make VTK file of relative particle rotation angle from state1 to state2

2023-01-27 Thread Leonard
Question #704551 on Yade changed:
https://answers.launchpad.net/yade/+question/704551

Status: Answered => Open

Leonard is still having a problem:
Hi Jan,

Thanks for your reply.

I got the solution for each individual question. But I am not clear how
to combine the two.

If I understood correctly, for using VTKExporter, it is something like:

vtkExporter.exportSpheres(ids='all',what=[('id',"b.id"),('ori','b.state.ori'),('radius',"b.shape.radius")])

It seems that the above code can only save the variables at one state.
i.e. not some value calculated from two states, such as the relative
rotation angle between state1 and state2.

What I have in my mind is: storing the rotation angle (calculated by
axis,angle = relOri.toAxisAngle()) into a VTK file. Something like:

step1: from the sample at state1 --> output a txt file (lets name it txt1) 
which has b.ori for each particle.
step2: from the sample at state2 --> output a txt file (txt2) which has b.ori 
for each particle.
step3: calculating relOri = state1.ori.conjugate()*state2.ori and axis,angle = 
relOri.toAxisAngle() by using txt1 and txt2, then I have the angle for each 
particle.
step4: store that angle into a VTK file which can be visualised in paraview

Do you have any ideas?

Thanks!

Leonard

-- 
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