Skip to content

Commit bb0a461

Browse files
Update softening.h
1 parent ef8505c commit bb0a461

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

src/dt/softening.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,45 +14,45 @@
1414
#include "gravity/octree.h"
1515
#include "struct/particle.h"
1616

17+
/* Softening for BarnesHut */
1718
inline real nextSoftening(real nodeSize,
1819
real nodeMass,
1920
real dist)
2021
{
21-
// Base softening from node size (dominant term)
22+
// Base softening from node size
2223
real eps_size = nodeSize * real(0.015);
2324

24-
// Mass-based softening (heavier nodes get slightly more smoothing)
25+
// Mass-based softening (physical radius proxy)
2526
real eps_mass = std::cbrt(nodeMass) * real(0.002);
2627

27-
// Distance-based tapering:
28-
// - strong softening at r → 0
29-
// - fades out smoothly as r grows
28+
// Distance taper: strong at r→0, fades smoothly
3029
real eps_taper = real(1.0) / (real(1.0) + dist * real(10.0));
3130

32-
// Combine components
31+
// Combine
3332
real eps = (eps_size + eps_mass) * eps_taper;
3433

35-
// Minimum floor to avoid zero-softening singularities
34+
// Minimum floor
3635
const real eps_min = real(1e-4);
3736
if (eps < eps_min)
3837
eps = eps_min;
3938

4039
return eps;
4140
}
4241

42+
/* Softening for Gravity kernel */
4343
inline real pairSoftening(real ma, real mb)
4444
{
45-
// Mass-based softening (cubic root gives physical size scale)
45+
// Physical radius proxy
4646
real ea = std::cbrt(ma) * real(0.002);
4747
real eb = std::cbrt(mb) * real(0.002);
4848

49-
// Symmetric combination
50-
real eps2 = ea*ea + eb*eb;
49+
// Symmetric combination (quadrature)
50+
real eps = std::sqrt(ea*ea + eb*eb);
5151

5252
// Minimum floor
53-
const real eps_min = real(1e-6);
54-
if (eps2 < eps_min)
55-
eps2 = eps_min;
53+
const real eps_min = real(1e-4);
54+
if (eps < eps_min)
55+
eps = eps_min;
5656

57-
return eps2;
57+
return eps; // return epsilon
5858
}

0 commit comments

Comments
 (0)