Comments (5)
-
This is what we talked about on Friday, where I couldn't remember the reason as to why this was so complicated to begin with. The reason is that the Simulation class needs to reference itself, which is a bit tricky in python and can only be done after the class definition (that's why the
_fields_
variable is set at the very end). -
There is a performance difference between pointer(), POINTER() and byref(). It's too late right now to completely wrap my head around, but maybe this does explain the 5% performance difference that you see.
http://stackoverflow.com/a/12281481/115102
from rebound.
I have the same memory leak in reboundxf, so thanks for letting me know. I don’t know what to say about the structure vs class. The Structure implementation seems to make more sense logically to me, though I agree it’s kind of ugly to have internal variables subscripted with ‘_’. There’s no way to overload a field’s setter function? I’ll try to look into that, as well as the pointer vs byref issue you found. That sounds quite interesting/promising.
Thanks,
Dan
On Aug 10, 2015, at 4:11 PM, Hanno Rein [email protected] wrote:
There was minor memory leak in the reb_free_simulation() function that actually did not free the simulation but only pointer therein.
I also looked at the complexity of the python Simulation class. I think this was overly complicated. Now Simulation is just a subclass of ctypes.Structure and one can access field variable directly without a setter/getter.
This raises two other issues, however:
If we want a setter on a field, e.g. for simualtion.integrator, then we need to make the fields variable private, e.g. by calling it _integrator.
The documentation for the getter/setters is gone; naturally, as the getter/setters are gone.
Development branch is on https://github.com/hannorein/rebound/tree/simsim https://github.com/hannorein/rebound/tree/simsim. I'm not totally happy with it yet and there might be an example that does not work yet (although almost all changes should be internal and not be visible from the outside).—
Reply to this email directly or view it on GitHub #66.
from rebound.
After sleeping on in, I think the byref/pointer issue is straightforward:
- byref gives you just the address
- pointer() gives you the address as well, but is a full fledged pointer object in python (e.g. you can access the contents via sim.contents.G)
- POINTER() generates the type
from rebound.
I tried to look into the private field variables issue, and like you seem to have found that this is the best way to do things. A bit weird/frustrating, but I guess that’s OK...
Dan
On Aug 10, 2015, at 10:20 PM, Daniel Tamayo [email protected] wrote:
I have the same memory leak in reboundxf, so thanks for letting me know. I don’t know what to say about the structure vs class. The Structure implementation seems to make more sense logically to me, though I agree it’s kind of ugly to have internal variables subscripted with ‘_’. There’s no way to overload a field’s setter function? I’ll try to look into that, as well as the pointer vs byref issue you found. That sounds quite interesting/promising.
Thanks,
Dan
On Aug 10, 2015, at 4:11 PM, Hanno Rein <[email protected] mailto:[email protected]> wrote:
There was minor memory leak in the reb_free_simulation() function that actually did not free the simulation but only pointer therein.
I also looked at the complexity of the python Simulation class. I think this was overly complicated. Now Simulation is just a subclass of ctypes.Structure and one can access field variable directly without a setter/getter.
This raises two other issues, however:
If we want a setter on a field, e.g. for simualtion.integrator, then we need to make the fields variable private, e.g. by calling it _integrator.
The documentation for the getter/setters is gone; naturally, as the getter/setters are gone.
Development branch is on https://github.com/hannorein/rebound/tree/simsim https://github.com/hannorein/rebound/tree/simsim. I'm not totally happy with it yet and there might be an example that does not work yet (although almost all changes should be internal and not be visible from the outside).—
Reply to this email directly or view it on GitHub #66.
from rebound.
Thanks. I think the only thing we need to think about is documentation. Maybe we can just put everything in the docstring for the Simulation class.
from rebound.
Related Issues (20)
- How to plot multiple "alternative" orbit evolutions? HOT 2
- examples/solarsystem_with_testparticles needs fix HOT 1
- Impossible slow simulation switching from 10k to 100k particles using hardsphere. Is this normal? HOT 1
- Naming convention HOT 1
- Spikes in semi major axis when increasing output number in a simulation HOT 6
- Add unit tests for OPENMP
- How to find old documentation HOT 2
- Hello again, I'm trying to implement the variational equations. Based on the example provided in read the docs, I should set the Sun as primary when I do the integration. But I get an error when I try to follow the exmaple shown in the docs. Here's what I'm trying and getting the error with: sim.add(primary=sim.particles[0], "Mercury", date=date) or another: sim.add(primary="Sun", "Mercury") with solar_system_objects = ["Sun", "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"]. thank you for your help! HOT 2
- trying to use variational equations to get Jacobian but get an error... HOT 6
- Can't copy simulation in Python, wonder how to fix HOT 2
- rebound should have some --help ? HOT 3
- Segmentation fault with latest Rebound version when accessing orbit of a particle HOT 5
- Attempting to install previous version in order to access read simulation archives. HOT 1
- Question on removing particles in 'additional forces' function HOT 2
- 'Simulation' object has no attribute 'automateSimulationArchive' HOT 2
- backpropagation of the 2016 HO3 quasi stable (QS) orbit around Earth HOT 3
- Particles in system stop moving using Mercurius integrator HOT 8
- linker error when running make HOT 8
- The Aarseth (1985) timestep criterion is incorrectly implemented HOT 1
- Raise exception when two particles are further apart than a set amount HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rebound.