Skip to content

Commit 55ffbfa

Browse files
Update softening.h
1 parent 92c7845 commit 55ffbfa

1 file changed

Lines changed: 25 additions & 30 deletions

File tree

src/dt/softening.h

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,47 +11,42 @@
1111

1212
#pragma once
1313
#include <cmath>
14-
#include "floatdef.h"
1514

1615
/* Softening for BarnesHut */
17-
inline real nextSoftening(real nodeSize,
18-
real nodeMass,
19-
real dist)
20-
{
21-
// Base softening from node size
22-
real eps_size = nodeSize * real(0.015);
16+
inline real nextSoftening(real nodeSize, real nodeMass, real dist) {
17+
// Base softening from node size
18+
real eps_size = nodeSize * real(0.015);
2319

24-
// Mass-based softening (physical radius proxy)
25-
real eps_mass = std::cbrt(nodeMass) * real(0.002);
20+
// Mass-based softening (physical radius proxy)
21+
real eps_mass = std::cbrt(nodeMass) * real(0.002);
2622

27-
// Distance taper: strong at r→0, fades smoothly
28-
real eps_taper = real(1.0) / (real(1.0) + dist * real(10.0));
23+
// Distance taper: strong at r→0, fades smoothly
24+
real eps_taper = real(1.0) / (real(1.0) + dist * real(10.0));
2925

30-
// Combine
31-
real eps = (eps_size + eps_mass) * eps_taper;
26+
// Combine
27+
real eps = (eps_size + eps_mass) * eps_taper;
3228

33-
// Minimum floor
34-
const real eps_min = real(1e-4);
35-
if (eps < eps_min)
36-
eps = eps_min;
29+
// Minimum floor
30+
const real eps_min = real(1e-4);
31+
if (eps < eps_min)
32+
eps = eps_min;
3733

38-
return eps;
34+
return eps;
3935
}
4036

4137
/* Softening for Gravity kernel */
42-
inline real pairSoftening(real ma, real mb)
43-
{
44-
// Physical radius proxy
45-
real ea = std::cbrt(ma) * real(0.002);
46-
real eb = std::cbrt(mb) * real(0.002);
38+
inline real pairSoftening(real ma, real mb) {
39+
// Physical radius proxy
40+
real ea = std::cbrt(ma) * real(0.002);
41+
real eb = std::cbrt(mb) * real(0.002);
4742

48-
// Symmetric combination (quadrature)
49-
real eps = std::sqrt(ea*ea + eb*eb);
43+
// Symmetric combination (quadrature)
44+
real eps = std::sqrt(ea * ea + eb * eb);
5045

51-
// Minimum floor
52-
const real eps_min = real(1e-4);
53-
if (eps < eps_min)
54-
eps = eps_min;
46+
// Minimum floor
47+
const real eps_min = real(1e-4);
48+
if (eps < eps_min)
49+
eps = eps_min;
5550

56-
return eps; // return epsilon
51+
return eps; // return epsilon
5752
}

0 commit comments

Comments
 (0)