Question #692420 on Yade changed:
https://answers.launchpad.net/yade/+question/692420

Description changed to:
Hello yade programmers and fellow users,
Hope all is well! I have been trying to mimic the uniax-post.py example to 
produce a velocity contour plot of a slice of particles in the simulation. 
Following Jan’s advice in post [1], I tried searching for ways to construct an 
extractor function to output “2-tuple velocity” for the bodies I want and 
“None” for the rest. I was only able to think of two ways to attack this being 
fairly new to python. Both of them did not work out so it would be greatly 
appreciated if you could offer me some hints!!

Below are the two methods I attempted:
1.      I tried defining a new extractor function vExtract() that could take 
the body instance outputs (b) looped by post2d.data() as its own argument. That 
way I would be able to use the following structure to accomplish my goal. 

def vExtract(b):        
if -0.15< b.state.pos[2] <= 0.15:return flattener.normal(b,b.state.vel)
else:return None                
        
# raw velocity (vector field) plot
pylab.figure(); post2d.plot(post2d.data(vExtract(),flattener))

However, this would yield an error due to the fact that vExtract is
expecting exactly one argument while I passed zero to post2d.data. If
there is a way to write the vExtract() function to use arguments (body
b) not specified in its own definitions, but in the higher level
post2d.data function it would work.

2.      I also looked for ways to modify the extractor extractVelocity()
used by the original uniax-post.py. I thought of adding the if-else
condition

if -0.15< b.state.pos[2] <= 0.15:return flattener.normal(b,b.state.vel)
else:return None

to the lambda expression “extractVelocity=lambda b: 
flattener.normal(b,b.state.vel)”,
but seems like lambda expressions cannot take conditional statements.

Thank you in advance! My Yade version is 2018.02b.


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

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

Reply via email to