teuben / nemo

a Stellar Dynamics Toolbox (Not Everybody Must Observe)
https://astronemo.readthedocs.io
GNU General Public License v2.0
56 stars 40 forks source link

Use falcON as a library - for vectors #103

Closed krobsp closed 1 year ago

krobsp commented 1 year ago

Hi all I plan to use NEMO and falcON as a library, especially for estimating gravitational potentials with Dehnen algorithm. But my particles are not in NEMO snapshot format: they are rather stored in a N-vector of 6-vectors. Is there a way to use falcON tools directly on this array or should I have to convert it to a NEMO snapshot file then call falcON tools on it (which would be extremely exhausting:-)) Thanks

teuben commented 1 year ago

It's going to depend what you need to do, do you just need the potentials and want to do other things in your own code? How many particles are we talking about? Here's an example using the unix command line to get the potentials of all particles, i'm using a NEMO plummer sphere as input, but you can also use tabtos to convert your ascii format so that gyrfalcON can read it:

      mkplummer - 1000 | gyrfalcON - p1k.out tstop=0 eps=0.05 kmax=8 give=mxvpa
      snapprint p1k.out  phi   > p1k.potentials.tab

sadly gyrfalcON cannot pipe the info into snapprint

teuben commented 1 year ago

I do believe some people have been able to use falcON as a library, your main() will be in C++.

krobsp commented 1 year ago

Thank you for your answer Yes, I need the potentials (with falcON) and then I am computing stuff with them, in cpp. There is about one million halos of 1e3-1e4 particles

teuben commented 1 year ago

Just a million is still "small enough", you could quite possibly use the ascii route to avoid having to build your potential getter.

tabtos took me 0.4sec to convert 1M partiles to snapshot format for gyrfalcON gyrfalcON took 1.4sec to compute the potentials snapprint took 0.2sec to dump 1M potentials to a table for you to read again.

krobsp commented 1 year ago

OK, I will try that. Thank you for the help ! If, in the future, there is a way to interface falcON (and NEMO) with usual std structures, it would be very useful I think

teuben commented 1 year ago

Your note is a great way to catalog this idea. If I know a better example, I'll let you know. I know of one or two projects that use falcOn via python i believe.

jcldc commented 1 year ago

You can use also falcON from python program (python 3.9 max so far ) : see https://pypi.org/project/python-unsiotools/