How to export relative velocity of spheres to Paraview
Hi all,
I am simulating direct shear experiments and I would like to visualize the relative velocity of all interacted spheres.
I've tried to record the interaction of bodies using VTKRecorder but it seems there is no relative velocity in this recorder.
So I am wondering how do I export the relative velocity of all interactive spheres to Paraview to visualize it?
Thanks!
Chien-Cheng
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Yade Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Chien-Cheng Hung
- Solved:
- Last query:
- Last reply:
Revision history for this message
|
#1 |
Hello Chien-Cheng,
> the relative velocity of all interacted spheres.
relative velocity with respect to what? relative velocity of interacting bodies for all interactions?
you can use export.VTKExporter [1]
###
vtk = export.
vtk.exportSpher
vtk.exportInter
###
above, b.state.vel and i.phys.normalForce is only illustrative, needs to be replaced by actual formula for relative velocity
If you use older Yade version, the correct format might be list of tuples instead of dict: what=[(
cheers
Jan
[1] https:/
Revision history for this message
|
#2 |
Hi Jan,
Thanks for your quick reply!
> relative velocity with respect to what? relative velocity of interacting bodies for all interactions?
Sorry I didn't describe clearly. But, yes, the relative velocity of interacting bodies for all interactions.
The relative velocity of the spheres that I want to obtain is described in ScGeom [1].
> above, b.state.vel and i.phys.normalForce is only illustrative, needs to be replaced by actual formula for relative velocity.
Can I get the formula for relative velocity [1] somewhere in Yade? Or I have to define one by myself?
Cheers,
Chien-Cheng
[1] https:/
Revision history for this message
|
#3 |
> Can I get the formula for relative velocity [1] somewhere in Yade? Or I have to define one by myself?
AFAIK you have to write it yourself..
you can write a function to it and call the function in exportInteractions / exportContactPo
###
def relativeVelocit
i1,i2 = interaction.id1, interaction.id2
b1,b2 = [O.bodies[i] for i in (i1,i2)]
r1,r2 = [b.shape.radius for b in (b1,b2)]
v1,v2 = [b.state.vel for b in (b1,b2)]
... # actual code comes here
return relativeVelocity
import __builtin__ # or buitlins (2ithout underscores) in Python3
__builtin_
vtk.exportInter
###
cheers
Jan
Revision history for this message
|
#4 |
Hi Jan,
Thanks a lot!
> you can write a function to it and call the function in exportInteractions / exportContactPoints
Is it possible that instead of calling the function, I can make a list of data of relative velocity that is recognized in Paraview
Cheers,
Chien-Cheng
Revision history for this message
|
#5 |
> Is it possible that instead of calling the function, I can make a list of data of relative velocity that is recognized in Paraview
I am not sure i I got it correctly, but you can e.g. create a dict with (id1,id2) keys and read from it in exportInteractions, something like (not tested):
###
interactionsInfo = {}
for i in O.interactions:
... # some computations
interactions
...
vtk.exportInter
# probably interactionsInfo would need the same builtin trick
###
cheers
Jan
Revision history for this message
|
#6 |
Thanks Jan Stránský, that solved my question.
Revision history for this message
|
#8 |
Hi Jan,
I would like to export the function in vtk files as below. I adjust the body of function unlike the above you showed me.
But it shows me that "name i is not defined". How do I modify my code?
Thank you for your help again!
###
def weakeningTemp(
heatCapacity = 900 # [J/kg*K]
density = 2500 # [kg/m3]
totalHeat = 0
thermal_diff = 1.e-6
shear_modulus = 22e9
tau_c = 0.1*shear_modulus
initialTemp = 20
for i in O.interactions():
if O.bodies[
radius1 = i.geom.refR1
radius2 = i.geom.refR2
Da = 2 * contactRadius
return weakeningTemp
builtins.
vtk = export.
def vtkExport():
vtk.
###
Cheers,
Chien-Cheng
Revision history for this message
|
#9 |
> But it shows me that "name i is not defined".
please post the complete error message
thanks
Jan
Revision history for this message
|
#10 |
> what=dict(
weakeningTemp(i) means it is a function of **one interaction**. In your function, the interaction argument is never used and instead you do "for i in O.interactions" instead, which should not be like this..
Should be something like:
###
def weakeningTemp(
heatCapacity = 900 # [J/kg*K]
...
initialTemp = 20
penetration
...
weakeningTemp = ...
return weakeningTemp
###
> if O.bodies[
body does not have isReal member..
cheers
Jan
Revision history for this message
|
#11 |
Hi Jan,
Thanks for your reply.
I still get the same error message after following your instruction.
The complete error message:
###
NameError Traceback (most recent call last)
/home/hung/
/home/hung/
183 vtk = export.
184 def vtkExport():
--> 185 vtk.exportSpher
186
187 #######
/home/hung/
427 # write additional data from 'what' param
428 for name,command in what.items(): # for each name...
--> 429 test = eval(command) # ... eval one example to see what type (float, Vector3, Matrix3) the result is ...
430 # ... and write appropriate header line and loop over all bodies and write appropriate vtk line(s)
431 if isinstance(
/home/hung/
NameError: name 'i' is not defined
###
Part of my code looks like:
###
O.engines=[
ForceResetter()
,InsertionSort
,InteractionLoop(
[Ig2_
[Ip2_
[Law2_
)
,GlobalStiffne
,PeriTriaxCont
,NewtonIntegra
,PyRunner(
,PyRunner(
,PyRunner(
,PyRunner(
]
def weakeningTemp(
heatCapacity = 900 # [J/kg*K]
density = 2500 # [kg/m3]
totalHeat = 0
thermal_diff = 1.e-6
shear_modulus = 22e9
tau_c = 0.1*shear_modulus
initialTemp = 20
penetration
radius1 = i.geom.refR1
radius2 = i.geom.refR2
effectiveRadius = (i.geom.refR1 * i.geom.refR2 )/( i.geom.
contactRadius = math.sqrt( i.geom.
Da = 2 * contactRadius
contactArea = np.pi*(
relativeVel
weakeningTemp = math.sqrt(
return weakeningTemp
builtins.
vtk = export.
def vtkExport():
vtk.
###
Cheers,
Chien-Cheng
Revision history for this message
|
#12 |
Thanks for more info
> NameError: name 'i' is not defined
> vtk.exportSpher
vtk.exportSpheres expect "b" as the body.
vtk.exportInter
You have to choose :-)
cheers
Jan
Revision history for this message
|
#13 |
Thanks Jan Stránský, that solved my question.
Revision history for this message
|
#14 |
Hi Jan,
In my "vtk.exportInte
I tried as follow but it seems not to work.
I'd appreciate it if you could give some hints. Thank you!
###
def weakeningTemp(i):
heatCapacity = 900 # [J/kg*K]
density = 2500 # [kg/m3]
thermal_diff = 1.e-6
shear_modulus = 22e9
tau_c = 0.1*shear_modulus
initialTemp = 20
penetration
radius1 = i.geom.refR1
radius2 = i.geom.refR2
effectiveRadius = (i.geom.refR1 * i.geom.refR2 )/( i.geom.
contactRadius = math.sqrt( i.geom.
Da = 2 * contactRadius
contactArea = np.pi*(
relativeVel
weakeningTemp = (math.sqrt(
return weakeningTemp
builtins.
vtk = export.
def vtkExport():
for a in range(2,
b = O.bodies[a]
for i in b.intrs():
###
Cheers,
Chien-Cheng
Revision history for this message
|
#15 |
paremter 'ids' [1] is for this:
###
ids = [(i.id1,i.id2) for i in O.interactions] # all ids
ids = [(i,j) for i,j in ids if not i in (0,1) and not j in (0,1)] # filtered ids not containing 0 and 1
vtk.exportInter
###
cheers
Jan
[1] https:/
Revision history for this message
|
#16 |
Thanks, Jan. That's really helpful!