Closed jobovy closed 9 months ago
Apologies for the delayed response. In addition to the 'ulimit -s unlimited' as mentioned in my previous email, another way to trace the code causing the crash is to switch on debug mode via configure:
configure --with-debug=g
Then, use gdb to run the petar commander in sample.sh:
OMP_NUM_THREADS=8 OMP_STACKSIZE=128M gdb --arg petar -u 1 -b 500 -t 100.0 -o 5.0 input
In gdb, use run
and when the code crashes, use where
to show the place where the abort occurred.
Thanks for the pointer! I ran with gdb
and got the following:
Looks like there's an issue with the input data, but I got that by just running the sample_galpy.sh code exactly?
Wait, I think one issue might be that I didn't compile with --with-interrupt=bse
, but if I try adding that, I get the following compilation error:
For what I want to do, I don't really need stellar evolution, is there a way to turn it off entirely in the sample_galpy.sh
script? I tried removing various options, but keep getting the Ptcl data reading fails
error.
Without bse, the input data has different number of columns. You can remove '-s bse' option for petar.init commander. Then, it will generate the input file with correct number of columns for petar:
petar.init -v kms2pcmyr -f input test.dat.10
OMP_NUM_THREADS=8 OMP_STACKSIZE=128M petar -u 1 -b 500 -t 100.0 -o 5.0 input &>output
Thanks! I managed to get the code to compile and run I think! First, I fixed the error in my previous comment by adding -no-pie
to my CXXFLAGS
. Then I was getting weird FORTRAN compilation errors that I correctly assumed were caused by my gfortran
version being very old, so I upgraded that (I ended up using GCC/G++/gfortran version 11.4.0 installed using conda). Then I got weird linker errors when linking the FORTRAN code to C++, so I fixed that by adding -lgfortran
to my CXXFLAGS
(using LIBS
or LDFLAGS
didn't work). And then things compiled!
I managed to run the sample_galpy.sh
code successfully. However, it looks like it doesn't conserve energy very well, is that expected? I assume that's because the time step is too large (I don't think it's explicitly set in the sample_galpy.sh
example and I don't think the actual tree time step is printed in the output? The only thing I can find is Tree step number: 2048
, which I think means that there are 2048 basic time steps, so then that would be 1/512 Myr; I tried running with a smaller timestep, but energy is still not conserved and the amount of energy drift seems to be about the same regardless of the step size).
Another question that wasn't entirely clear from the README or help functions: are the -t
and -o
times in Myr (when Myr is the time unit)? And the statement that this has to be 0.5^[integer power] really means that it has to be some integer times 0.5^[integer power] such that it corresponds to an integer number of basic tree time steps?
I think this is expected. When stellar evolution is activated, energy conservation is not very well. Furthermore, the sample_galpy.sh runs a model with 100% binary fraction. The SDAR algorithm may not conserve the energy of perturbed binaries or multiple systems, but the orbital result is reasonable. You can run a model without primordial binaries and without stellar evolution, the energy conservation should be better .
Okay, indeed, I ran a similar simulation with no stellar evolution and no binaries and energy is indeed conserved at the 1e-7 level, so it looks like all is well. Thanks!
I also checked that the latest master
branch compiles under gcc 13.2.0, so I'll close this issue now.
I'm getting a compilation error (
invalid preprocessing directive #double
) because of this line:https://github.com/lwang-astro/PeTar/blob/ab1eec771872600091c3520a68493038f558eaea/galpy-interface/galpy_interface.h#L1642
I'm using gcc version 13.2.0 (conda-forge gcc 13.2.0-2). Just commenting that line out allows the compilation to proceed fully.
By the way, the reason that in
galpy
the potential in C does not depend on phi is that it is only ever used in situations where the potential has to be assumed to be axisymmetric (the potential in C is only used to calculate action-angle coordinates for axisymmetric potentials). But for PeTar it might be useful to have a version of the potential evaluation that does depend on phi? In principle that's not a very difficult change ingalpy
, although it's hard to test ingalpy
so might be difficult to implement correctly.I'm trying to compile PeTar to run an N-body simulation of a globular cluster in the Milky Way's tidal field, but even though the code compiles correctly (when fixing this issue), I get
Aborted (core dumped)
when I run either thetest/sample.sh
ortest/sample_galpy.sh
codes. I'm running these examples exactly as in those files (so settingOMP_STACKSIZE
). Do you have any idea why this might be or how I could go about debugging this? Maybe I should use an older version of gcc?