Skip to main content
Version: 0.3.0

Run an analysis

Everything goes through one class, scirocco::Scirocco. Create it with a geometry, call SetOper, call Solve, and read the results.

#include <scirocco/scirocco.h>

scirocco::Scirocco foil("2412", 160); // NACA 2412, 160 panels
foil.SetOper(4.0, -1.0, 1.0e6, 0.0); // alpha, Cl target, Re, Mach
bool ok = foil.Solve();

Always check what Solve() returns. A failed solve leaves the results undefined.

Sweep angle of attack​

Reuse one object and call SetOper for each point:

scirocco::Scirocco foil("2412", 160);

std::printf(" alpha Cl Cd Cm\n");
for (double alpha = -2.0; alpha <= 10.0; alpha += 2.0) {
foil.SetOper(alpha, -1.0, 1.0e6, 0.0);
if (!foil.Solve()) {
std::printf("%6.1f did not converge\n", alpha);
continue;
}
std::printf("%6.1f %7.4f %7.5f %7.4f\n", alpha, foil.GetCl(),
foil.GetCd(), foil.GetCm());
}
alpha Cl Cd Cm
-2.0 0.0231 0.00657 -0.0542
0.0 0.2354 0.00563 -0.0516
2.0 0.4491 0.00577 -0.0480
4.0 0.7202 0.00693 -0.0585
6.0 0.9028 0.00902 -0.0507
8.0 1.0844 0.01224 -0.0438
10.0 1.2628 0.01547 -0.0370

The same sweep from −4° to 14° in 1° steps, with the inviscid lift for comparison:

  • Viscous
  • Inviscid
-0.500.511.5-404812α (deg)Cl
Show data
Viscous
α (deg)Cl
-4-0.1942
-3-0.0855
-20.0231
-10.1302
00.2354
10.3384
20.4491
30.5914
40.7202
50.8129
60.9028
70.9929
81.0844
91.1754
101.2628
111.3395
121.4025
131.4429
141.4834
Inviscid
α (deg)Cl
-4-0.2280
-3-0.1071
-20.0138
-10.1347
00.2556
10.3764
20.4971
30.6176
40.7379
50.8580
60.9779
71.0975
81.2167
91.3356
101.4540
111.5720
121.6896
131.8066
141.9231
-0.500.511.50.0050.0100.0150.0200.025CdCl
Show data
Viscous
CdCl
0.00766-0.1942
0.00705-0.0855
0.006570.0231
0.006070.1302
0.005630.2354
0.005470.3384
0.005770.4491
0.006340.5914
0.006930.7202
0.007750.8129
0.009020.9028
0.010620.9929
0.012241.0844
0.013821.1754
0.015471.2628
0.017531.3395
0.019641.4025
0.023261.4429
0.027401.4834

Inviscid or viscous​

Re picks the model:

  • Re > 0 couples the panel method to the boundary layer and wake. You get drag, skin friction, and boundary-layer thicknesses.
  • Re = 0 solves potential flow only. It's much faster, drag is zero, and there is no boundary layer or wake.

Solve for a lift coefficient​

Pass a non-negative cl and Scirocco finds the angle of attack:

scirocco::Scirocco foil("2412", 160);
foil.SetOper(0.0, 0.5, 1.0e6, 0.0); // find alpha for Cl = 0.5
if (foil.Solve()) {
std::printf("alpha = %.4f deg, Cl = %.4f, Cd = %.5f\n",
foil.GetAlpha(), foil.GetCl(), foil.GetCd());
}
alpha = 2.3754 deg, Cl = 0.5000, Cd = 0.00597

The alpha you pass is the starting guess. Pass cl = -1.0 to go back to fixed-angle mode.

Add Mach number​

The fourth argument turns on the Kármán–Tsien compressibility correction:

for (double mach : {0.0, 0.3, 0.5, 0.6}) {
foil.SetOper(2.0, -1.0, 3.0e6, mach);
if (foil.Solve()) {
std::printf("Ma = %.1f Cl = %.4f Cd = %.5f\n",
mach, foil.GetCl(), foil.GetCd());
}
}
Ma = 0.0 Cl = 0.4617 Cd = 0.00506
Ma = 0.3 Cl = 0.4872 Cd = 0.00522
Ma = 0.5 Cl = 0.5437 Cd = 0.00558
Ma = 0.6 Cl = 0.5945 Cd = 0.00591

The correction doesn't model shocks. Keep to subsonic flow without strong supersonic pockets; see Compressibility.

Read the distributions​

After a solve, surface and boundary-layer data are available as Eigen vectors:

const Eigen::MatrixXd& xz = foil.GetFoilCoords(); // 2 x N panel nodes
const Eigen::VectorXd& cp = foil.GetCp(); // N
const Eigen::VectorXd& cf = foil.GetCf(); // N + wake nodes
161 airfoil nodes, 27 wake nodes
cp: 161 values, cf: 188 values
AccessorSizeContents
GetCp()NPressure coefficient at each panel node
GetCf()N + NwSkin friction, airfoil nodes then wake nodes
GetTheta()N + NwMomentum thickness
GetDeltaStar()N + NwDisplacement thickness
GetFoilCoords()2 × NNode coordinates, lower trailing edge → leading edge → upper trailing edge
GetWakeCoords()2 × NwWake node coordinates

N is the number of panels plus one. In an inviscid solve the boundary-layer arrays and wake are empty. More quantities, such as the shape factor Hk and edge velocity ue, are in GetState().post; see FoilState.

See the solver working​

Set the verbosity before solving to print the residual each Newton step:

foil.GetState().param.verb = 1;

A healthy viscous solve converges in under ten steps. If it doesn't converge, see Troubleshooting.