danieljprice / phantom

Phantom Smoothed Particle Hydrodynamics and Magnetohydrodynamics code
https://phantomsph.github.io
Other
110 stars 246 forks source link

(set-binary) update npartoftype array when particle types are set according to a specific star in a binary #596

Closed themikelau closed 1 month ago

themikelau commented 1 month ago

Type of PR: Bug fix (found by @msha0023)

Description: When setting up two gas-particle stars in a binary using SETUP=binary with relax_star, the second star is not relaxed because of an error raised by checksetup called in `relax_star:

rstar =    1.0000000000000000       mstar =   0.99935806369259794       tdyn =    1.1110774122591152     
 n(via iphase)=         100           0           0         100           0           0           0           0
 npartoftype  =         200           0           0           0           0           0           0           0
 ERROR: sum of types in iphase is not equal to npartoftype

 ERROR! relax_star: cannot relax star because particle setup contains errors

The cause of this is that the npartoftype array was not updated when particles from star 1 were set to the type itype+ioffset, causing a mismatch with iphase. I have now ensured npartoftype is updated whenever particle types are changed.

danieljprice commented 1 month ago

thanks both