Python based Simulation - Particle Calculation Time

Discussion about scripting with Python
User avatar
stascrash
Posts: 65
Joined: Tue Sep 18, 2012 8:21 pm
Location: World Wide Web
Contact:

Python based Simulation - Particle Calculation Time

Post by stascrash » Tue Sep 18, 2012 8:27 pm

Hey guys,
i am working for a client, simulating the dishwasher cycle, i am using python to control the direction and flow of particle when they are colliding with dishes, and walls of the dishwasher, as well as checking for number of other things to filter for, like
remove based on age and collision status (isColliding), transferring from emitter to emitter, etc.

everything works really nice, but when i set my machine (xeon 12 core) to calculate, it takes around 20 hours for 30 frames ( i have to make about 300 frames for final)

i know that scripting puts you only on one core, and i was wondering, if my render times here look reasonable, or is there a problem with my script that can cause such a long rendering process.

Thanks a lot!
-stas

User avatar
bolek
Posts: 121
Joined: Thu Nov 27, 2008 10:24 am
Contact:

Re: Python based Simulation - Particle Calculation Time

Post by bolek » Tue Sep 18, 2012 9:55 pm

Hi stascrash .

Turn off script for a while and you will see if it is the problem.
Anyhow ... Which version of RF you are using? If it is 5 or higher, instead of python 'isColliding' you can use Filter daemon.
____________________________________________
http://vimeo.com/bolekcg
http://bolekcg.blogspot.com/

User avatar
stascrash
Posts: 65
Joined: Tue Sep 18, 2012 8:21 pm
Location: World Wide Web
Contact:

Re: Python based Simulation - Particle Calculation Time

Post by stascrash » Tue Sep 18, 2012 10:06 pm

hey bolek,
i am running 2012 version.
turning off the script is a good idea, that way i wont get any effects tho, since everything is depending on the script, but i will give that a shot.
could you elaborate a little about using the filter?

i know how it works, but i am not sure how would i integrate that with python, i would say that i am pretty new to the scripting within RF and python in general, more MEL (maya)

thanks,

fkfx
Posts: 309
Joined: Wed Apr 11, 2012 11:11 am
Location: Cologne, Germany
Contact:

Re: Python based Simulation - Particle Calculation Time

Post by fkfx » Wed Sep 19, 2012 3:07 pm

Filter was introduced in order to replace most of the time consuming Python scripts that were used to filter particles from one emitter to another on certain conditions. You should try using Filter instead of scripting if possible, because filter is capable of multithreading. Filter is something like an if- then control structure.

User avatar
stascrash
Posts: 65
Joined: Tue Sep 18, 2012 8:21 pm
Location: World Wide Web
Contact:

Re: Python based Simulation - Particle Calculation Time

Post by stascrash » Wed Sep 19, 2012 5:22 pm

Ok, that makes sense. guys!

Now, is it possible to call for a Daemon from python?

here is a basic scenario for my script:

1. Emit particles from Circle01
2. IF particle is colliding with an object
2a. Create particle in Secondary Emitter
2b. Set new particles velocity/position from existing (particle.getVelocity, getPosition)
2c. Remove original particle from Circle01
(Basically a simple FOAM script approach)
3. If NEW particles age is within set threshold and particle is not colliding with any object - Remove that particle
4. If Age is reached, but particle is colliding - keep that particle.
5. if particle is in collision with Specified object - (use basic foam structure) and freeze that new particle.

p.s. i tried using filter for a few projects, and it does that trick, however i feel that i dont have as much control as with scripting.
Any advice to make this more efficient?

Thanks
-stas

User avatar
stascrash
Posts: 65
Joined: Tue Sep 18, 2012 8:21 pm
Location: World Wide Web
Contact:

Re: Python based Simulation - Particle Calculation Time

Post by stascrash » Wed Sep 19, 2012 6:46 pm

i think i am slowly getting what you guys were suggesting, using Filter, i can define my own expressions....

If i am running an expression there, should i be addressing it a a formal python? like
"for Something in Range:" - ?

if i do something that requires more than a single check-parameter, is it still going to be processed via all cpu-threads? or single?

User avatar
stascrash
Posts: 65
Joined: Tue Sep 18, 2012 8:21 pm
Location: World Wide Web
Contact:

Re: Python based Simulation - Particle Calculation Time

Post by stascrash » Wed Sep 19, 2012 7:26 pm

Yeah, so i am able to get partial results, however not everything.
1. i get really decent way of particle split on collision, a lot faster, and same results
2. i cannot remove particles when they meet the age limitation and are not colliding.

i am using this:
(particle.colliding == 0) & (particle.age>0.5)
it does not seem to work, i can see how particles drop count if i only check by age, but when i combine both expressions it does not do so, however i also get no error...

Would it be possible to write script for just that portion? or may be a scripted daemon?

Code: Select all

#check for age and collision and delete matching particles
		if (ageSprayMid >= ageThreshold + randMid and sprayMParticle.isColliding() == False):	
			deletePartId = sprayMParticle.getId()
			sprayMid.removeParticle(deletePartId)
			#scene.message("Particle ID: " + str(deletePartId) + " was removed.")

User avatar
bolek
Posts: 121
Joined: Thu Nov 27, 2008 10:24 am
Contact:

Re: Python based Simulation - Particle Calculation Time

Post by bolek » Fri Sep 21, 2012 9:17 am

If it doesn't work with single filter (I didn't try) use another one for checking age.
____________________________________________
http://vimeo.com/bolekcg
http://bolekcg.blogspot.com/

User avatar
stascrash
Posts: 65
Joined: Tue Sep 18, 2012 8:21 pm
Location: World Wide Web
Contact:

Re: Python based Simulation - Particle Calculation Time

Post by stascrash » Fri Sep 21, 2012 3:06 pm

yeah, but how would i combine the action? if you look at the code in my last post, i am checking against collision and only if there is no collision i am telling it to remove the particle. any thoughts?

User avatar
bolek
Posts: 121
Joined: Thu Nov 27, 2008 10:24 am
Contact:

Re: Python based Simulation - Particle Calculation Time

Post by bolek » Fri Sep 21, 2012 6:34 pm

So all you need is kAge daemon... I think..
____________________________________________
http://vimeo.com/bolekcg
http://bolekcg.blogspot.com/

Post Reply

Return to “Python-Scripting”