Skip to content

ashfordeOU/aero-agent-skills / skills/aerodynamics/cfd/cfd-turbulence-modeling

cfd-turbulence-modeling

Verified

Use when you must estimate the wall-normal first cell height for a CFD mesh: compute the y plus value from the friction velocity and kinematic viscosity, derive the friction velocity from the wall shear stress or the skin friction coefficient, and recommend the turbulence model and wall treatment for the boundary layer. Produces the y plus value, the friction velocity, and the turbulence model recommendation that size the near-wall mesh. Trigger: turbulence model, y plus, friction velocity, boundary layer, wall treatment, cfd.

FileKindSize
SKILL.mdskill md3.3 KB
scripts/cfd_turbulence_logic.pyscript3.0 KB
scripts/test_cfd_turbulence.pyscript4.5 KB

scripts/test_cfd_turbulence.py

View on GitHub
#!/usr/bin/env python3
"""Gate 3 contract test: CFD turbulence modeling (y+, friction velocity).

Exercises scripts/cfd_turbulence_logic.py (stdlib unittest, offline).
Contract: docs/harness-contract.md gate 3 - y plus for the first
cell height, friction velocity from wall shear stress or skin
friction coefficient, and turbulence model recommendation for the
target y+; invalid inputs raise ValueError.
"""

import os
import sys
import unittest

sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))

import cfd_turbulence_logic as ctl  # noqa: E402


class YPlusTest(unittest.TestCase):
    def test_first_cell_anchor(self):
        # y = 1e-5 m, u_tau = 1.5 m/s, nu = 1.46e-5 m^2/s
        self.assertAlmostEqual(ctl.y_plus(1e-5, 1.5, 1.46e-5), 1.0274, delta=1e-3)

    def test_scales_linearly_with_y(self):
        yp = ctl.y_plus(1e-5, 1.5, 1.46e-5)
        self.assertAlmostEqual(ctl.y_plus(2e-5, 1.5, 1.46e-5), 2 * yp, delta=1e-3)

    def test_invalid_inputs_raise(self):
        with self.assertRaises(ValueError):
            ctl.y_plus(0.0, 1.5, 1.46e-5)
        with self.assertRaises(ValueError):
            ctl.y_plus(-1e-5, 1.5, 1.46e-5)
        with self.assertRaises(ValueError):
            ctl.y_plus(1e-5, 0.0, 1.46e-5)
        with self.assertRaises(ValueError):
            ctl.y_plus(1e-5, -1.5, 1.46e-5)
        with self.assertRaises(ValueError):
            ctl.y_plus(1e-5, 1.5, 0.0)
        with self.assertRaises(ValueError):
            ctl.y_plus(1e-5, 1.5, -1.46e-5)


class FrictionVelocityTest(unittest.TestCase):
    def test_wall_shear_anchor(self):
        # tau_w = 2.0 Pa, rho = 1.225 kg/m^3
        self.assertAlmostEqual(ctl.friction_velocity(2.0, 1.225), 1.2778, delta=1e-3)

    def test_invalid_inputs_raise(self):
        with self.assertRaises(ValueError):
            ctl.friction_velocity(0.0, 1.225)
        with self.assertRaises(ValueError):
            ctl.friction_velocity(-2.0, 1.225)
        with self.assertRaises(ValueError):
            ctl.friction_velocity(2.0, 0.0)
        with self.assertRaises(ValueError):
            ctl.friction_velocity(2.0, -1.225)


class FrictionVelocityFromCfTest(unittest.TestCase):
    def test_cf_anchor(self):
        # cf = 0.002, v_inf = 100 m/s
        self.assertAlmostEqual(
            ctl.friction_velocity_from_cf(0.002, 100), 3.1623, delta=1e-3
        )

    def test_invalid_inputs_raise(self):
        with self.assertRaises(ValueError):
            ctl.friction_velocity_from_cf(0.0, 100)
        with self.assertRaises(ValueError):
            ctl.friction_velocity_from_cf(-0.002, 100)
        with self.assertRaises(ValueError):
            ctl.friction_velocity_from_cf(0.002, 0.0)
        with self.assertRaises(ValueError):
            ctl.friction_velocity_from_cf(0.002, -100)


class TurbulenceModelRecommendationTest(unittest.TestCase):
    def test_yplus_one_sst(self):
        self.assertEqual(ctl.turbulence_model_recommendation(1, False), "k-omega-sst")

    def test_yplus_ten_realizable(self):
        self.assertEqual(
            ctl.turbulence_model_recommendation(10, True), "k-epsilon-realizable"
        )

    def test_yplus_hundred_wall_function(self):
        self.assertEqual(
            ctl.turbulence_model_recommendation(100, False), "sa-wall-function"
        )

    def test_yplus_four_hundred_wall_model_check(self):
        self.assertEqual(
            ctl.turbulence_model_recommendation(400, False), "wall-model-check"
        )

    def test_boundaries(self):
        # <= 1 is sst; 30 sits in the realizable band; 300 in the
        # wall-function band; above 300 is wall-model-check.
        self.assertEqual(
            ctl.turbulence_model_recommendation(1.0, False), "k-omega-sst"
        )
        self.assertEqual(
            ctl.turbulence_model_recommendation(30.0, False), "k-epsilon-realizable"
        )
        self.assertEqual(
            ctl.turbulence_model_recommendation(300.0, False), "sa-wall-function"
        )
        self.assertEqual(
            ctl.turbulence_model_recommendation(300.1, False), "wall-model-check"
        )

    def test_invalid_inputs_raise(self):
        with self.assertRaises(ValueError):
            ctl.turbulence_model_recommendation(0, False)
        with self.assertRaises(ValueError):
            ctl.turbulence_model_recommendation(-10, False)
        with self.assertRaises(ValueError):
            ctl.turbulence_model_recommendation(30, "yes")
        with self.assertRaises(ValueError):
            ctl.turbulence_model_recommendation(30, None)


if __name__ == "__main__":
    unittest.main(verbosity=2)
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall