Skip to content

Commit

Permalink
Added option to set nCrit (#29)
Browse files Browse the repository at this point in the history
* added option to change ncrit

* use the actual Reynolds number instead of Reynolds per length

* revert Reynolds change, update comments

* added nCrit test

* bumped minor version
  • Loading branch information
sseraj authored Aug 7, 2024
1 parent 581dcfd commit 3ea3b9b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
14 changes: 10 additions & 4 deletions cmplxfoil/CMPLXFOIL.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,18 @@ def __call__(self, aeroProblem, useComplex=False, deriv=False):
self.setAeroProblem(aeroProblem)

# Set flight condition and options
xfoil.cr15.reinf1 = aeroProblem.re # Reynolds number
xfoil.cr09.minf1 = aeroProblem.mach # Mach Number set
xfoil.cr09.adeg = aeroProblem.alpha
xfoil.ci04.itmax = self.getOption("maxIters") # Iterations Limit Set
xfoil.cr15.reinf1 = aeroProblem.re # Reynolds number per unit length
xfoil.cr09.minf1 = aeroProblem.mach # Mach number
xfoil.cr09.adeg = aeroProblem.alpha # Angle of attack
xfoil.ci04.itmax = self.getOption("maxIters") # Iterations limit
if not np.any(np.isnan(self.getOption("xTrip"))): # NaN is default to not set, otherwise set it
xfoil.cr15.xstrip = self.getOption("xTrip")

# Set nCrit (The Fortran variable is acrit)
# lvconv needs to be set to False to update internal variables
xfoil.cr15.acrit = self.getOption("nCrit")
xfoil.cl01.lvconv = False

# Call XFOIL
xfoil.oper()

Expand Down Expand Up @@ -1073,6 +1078,7 @@ def _getDefaultOptions():
np.ndarray,
np.full(2, np.NaN),
], # boundary layer trip x coordinate of upper and lower surface, respectively (two-element array)
"nCrit": [float, 9.0],
}

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion cmplxfoil/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "2.0.4"
__version__ = "2.1.0"

from .CMPLXFOIL import CMPLXFOIL

Expand Down
5 changes: 5 additions & 0 deletions doc/options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ xTrip:
desc: >
The boundary layer trip location specified as a two-element numpy array where the first element is the chordwise location at which to trip the upper surface and the second is the chordwise location at which to trip the lower surface.
By default will not trip the boundary layer and instead use XFOIL's transition model.
nCrit:
desc: >
The critical amplification exponent for boundary layer transition.
This parameter represents the background turbulence level.
Lower values will result in earlier turbulent transition.
24 changes: 23 additions & 1 deletion tests/test_solver_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_function_values(self):
self.assertAlmostEqual(true_val, funcs[key])


class TestTrip(unittest.TestCase):
class TestTransition(unittest.TestCase):
def test_trip(self):
"""
Test that setting the trip changes the result.
Expand All @@ -116,6 +116,28 @@ def test_trip(self):
for func in evalFuncs:
self.assertNotEqual(funcs["fc_" + func], funcsTripped["fc_" + func])

def test_nCrit(self):
"""
Test that setting nCrit changes the result.
"""
evalFuncs = ["cl", "cd", "cm"]
self.ap = AeroProblem(
name="fc", alpha=3, mach=0.2, altitude=1e3, areaRef=1.0, chordRef=1.0, evalFuncs=evalFuncs
)
self.CFDSolver = CMPLXFOIL(os.path.join(baseDir, "naca0012.dat"))
self.CFDSolverNCrit = CMPLXFOIL(os.path.join(baseDir, "naca0012.dat"), options={"nCrit": 5.0})

funcs = {}
self.CFDSolver(self.ap)
self.CFDSolver.evalFunctions(self.ap, funcs)

funcsNCrit = {}
self.CFDSolverNCrit(self.ap)
self.CFDSolverNCrit.evalFunctions(self.ap, funcsNCrit)

for func in evalFuncs:
self.assertNotEqual(funcs["fc_" + func], funcsNCrit["fc_" + func])


class TestDerivativesFFD(unittest.TestCase):
def setUp(self):
Expand Down

0 comments on commit 3ea3b9b

Please sign in to comment.