Skip to content

Commit c072520

Browse files
Added pairwise softening
Add pairwise softening for better simulation stability to use in src/struct/particle.h
1 parent 20529c3 commit c072520

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

src/dt/softening.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
// it under the terms of the GNU General Public License as published by
33
// the Free Software Foundation, either version 3 of the License, or
44
// (at your option) any later version.
5-
65
// This program is distributed in the hope that it will be useful,
76
// but WITHOUT ANY WARRANTY; without even the implied warranty of
87
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
98
// GNU General Public License for more details.
10-
119
// You should have received a copy of the GNU General Public License
1210
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1311

@@ -40,4 +38,21 @@ inline real nextSoftening(real nodeSize,
4038
eps = eps_min;
4139

4240
return eps;
41+
}
42+
43+
inline real pairSoftening(real ma, real mb)
44+
{
45+
// Mass-based softening (cubic root gives physical size scale)
46+
real ea = std::cbrt(ma) * real(0.002);
47+
real eb = std::cbrt(mb) * real(0.002);
48+
49+
// Symmetric combination
50+
real eps2 = ea*ea + eb*eb;
51+
52+
// Minimum floor
53+
const real eps_min = real(1e-6);
54+
if (eps2 < eps_min)
55+
eps2 = eps_min;
56+
57+
return eps2;
4358
}

0 commit comments

Comments
 (0)