lwang-astro / PeTar

PeTar is a high-performance N-body code for modelling the evolution of star clusters and tidal streams, including the effect of galactic potential, dynamics of binary and hierarchical system, single and binary stellar evolution.
MIT License
72 stars 21 forks source link

```Lagrangian``` with shell mode #45

Closed HerculeWu closed 1 year ago

HerculeWu commented 1 year ago

Dear Long Wang,

When I use the python data analysis tool, I found one issue about lagrangian.

In the class Lagrangian (defined in PeTar/analysis/lagrangian.py), when use calcOneSnapshot with shell mode, the variabe nlagr (line 393, 394) denotes number of particles between two neighbor Lagrangian radii. Then n_offset (line 435) works not properly. Maybe this issue can be fixed by changing line 435 to

if shell_mode:
    n_offset = np.append(np.zeros(1), rindex+1).astype(int)
else:
    n_offset = np.append(np.zeros(1),nlagr).astype(int)

Thanks and with best wishes, Wu

lwang-astro commented 1 year ago

Thank you for pointing out this bug. Indeed the usage of nlagr to determing n_offset is not correct. It should be rindex+1. I have modified the line 435 to n_offset = np.append(np.zeros(1), rindex+1).astype(int).