Numerical viscosity is the artificial dissipation we add to stabilize shock-capturing schemes. Too little, and oscillations destroy the solution. Too much, and shocks are smeared beyond recognition. Finding the right balance has traditionally been more art than science โ until now.
The Problem with Fixed Viscosity
Classical schemes use fixed viscosity coefficients:
- First-order schemes (Godunov) use too much โ shocks are smeared.
- High-order schemes (WENO) use less โ but still uniformly across the domain.
- Adaptive schemes switch between first and high order โ but the switch is heuristic.
The fundamental issue is that optimal viscosity varies in space and time. Near shocks, we need more dissipation. In smooth regions, we need less. But how do we know where we are?
Enter Reinforcement Learning
We frame viscosity tuning as a reinforcement learning problem:
- State: Local flow features (gradients, curvature, Mach number, etc.)
- Action: Viscosity coefficient to apply at each cell interface
- Reward: Combination of accuracy (low error) and stability (no oscillations)
The RL agent learns a policy that maps local flow conditions to optimal viscosity coefficients. After training on a diverse set of problems, the agent generalizes to unseen configurations.
Results
Our preliminary results are promising:
- Sod shock tube: 40% reduction in L1 error compared to standard WENO-JS
- Double Mach reflection: Sharper shock resolution with fewer artifacts
- 2D Riemann problems: Better capture of contact discontinuities
"The RL agent discovers strategies that human experts might not consider โ for example, using negative viscosity in carefully controlled regions to sharpen contacts, something traditional limiters avoid."
Challenges
This approach is not without challenges:
- Training cost: Each episode requires a full CFD simulation.
- Generalization: Does the agent trained on 1D problems work for 3D?
- Interpretability: The learned policy is a black box โ can we extract insights?
Future Directions
We are exploring several extensions:
- Multi-agent RL for systems of equations (each equation gets its own viscosity)
- Transfer learning from 1D to 2D/3D problems
- Physics-informed reward functions that encode known conservation properties
Conclusion
Machine learning offers a powerful new paradigm for optimizing numerical methods. By framing viscosity tuning as an RL problem, we can leverage decades of progress in AI to enhance classical numerical schemes. The marriage of both fields is just beginning.