particles exiting the bounding box
Good evening,
I recently started playing around with the tutorial. I noticed that if a particle exits the bounding box through its movement
i get this error
File "bingle.py", line 45, in <module>
p2 = particles[
IndexError: list index out of range
is there a way substract the particle from the simulation instead of throwing this error?
Thank you very much for your help, i realise this might be a beginners question
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Dion Weatherley
- Solved:
- 2017-10-27
- Last query:
- 2017-10-27
- Last reply:
- 2017-10-27
|
#1 |
Hi John,
As it happens, this error is thrown *because* the particle has already been subtracted from the simulation.
Let me explain:
Initially the bingle.py simulation contains two particles, both entirely within the simulation domain. Thus a call to sim.getParticle
When one/other particle leaves the simulation domain (defined by the bounding box), ESyS-Particle internally subtracts/deletes that particle. A subsequent call to sim.getParticle
The error thrown above is because you are attempting to access an element with index=1, from a list of length=1. In this case (as the error message indicates) the "list index is out of range". To prevent this error messaage occurring, you will need to explicitly check the length of the list returned by sim.getParticle
I hope this helps and have fun!
Cheers,
Dion
JOHN (washingmachine) said : | #2 |
Thanks Dion Weatherley, that solved my question.