March 2024: CFD Direct is pleased to announce that OpenFOAM can simulate internal combustion (IC) engines including piston and valve motion. The capability was produced in collaboration with Wärtsilä, Finland and partner organisations, starting in October 2021. It is publicly available from The OpenFOAM Foundation in the development line of OpenFOAM (OpenFOAM-dev
, packaged here), with example cases in the ICengines
repository.
CFD simulation of IC engines
An IC engine has one or more cylinders cut into an engine block. A piston moves rapidly in and out of each cylinder, forming a combustion chamber in the space between the piston head and cylinder walls. The cylinder head includes air intake and exhaust ports with valves which open and close to regulate the flow of gases in and out of the combustion chamber.
Computational fluid dynamics (CFD) can simulate the fluid flow, heat, thermodynamics and combustion within the combustion chamber. Flow and heat are simulated using a moderate speed, compressible solver with models for fluid properties that vary with temperature. Combustion can be simulated with empirical models based on flame speed or by calculations of the combustion chemistry. Piston and valve motion present a difficult challenge for simulation of IC engines. The piston motion causes the combustion chamber to decrease to 10% or less of its maximum volume. The closure of valves is particularly difficult due to contact at the port openings.
Piston and valve motion
In OpenFOAM, the piston and valve motion uses a sequence of pre-generated meshes corresponding to different positions of the boundary of the piston head and valves during an engine cycle. During a simulation, the piston and valve boundaries move, which moves and deforms the mesh using athe dedicated multiValveEngine mesh mover, created by Wärtsilä and refactored, generalised, optimised and merged into OpenFOAM by CFD Direct.
When the piston and values reach the positions in next pre-generated mesh, the field data (pressure, velocity, etc) is mapped from the deformed mesh onto the pre-generated mesh. The mesh motion then continues from the new mesh until it reaches the next pre-generated mesh, when the mapping process is repeated. The process is encoded within a general mesh-to-mesh topology changer created by CFD Direct, which is fully parallelised, compatible with non-conformal coupling and works with discrete particles.
Non-conformal coupling (NCC) and mesh stitching
Robust and accurate CFD calculations require meshes of sufficient quality, i.e. falling within reasonable thresholds of non-orthogonality, skewness and aspect ratio. Mesh quality deteriorates with mesh motion, so mesh-to-mesh mapping needs to occur frequently enough to avoid poor quality meshes. Fewer pre-generated meshes are required if mesh quality is preserved for longer during mesh motion.
IC engine simulations use boundaries with non-conformal coupling (NCC) as an effective way to preserve mesh quality longer. For the valves, motion occurs in a region of the mesh surrounding the valve, whose boundary slides along the boundary of adjacent, stationary regions of mesh. NCC connects the regions at their common boundary. NCC was created by CFD Direct as a robust replacement to arbitrary mesh interface functionality in OpenFOAM. For engine simulations, its interoperability with run-time mesh changes was improved (also commit 2f4ef2ab) so that it could be used in conjunction with mesh-to-mesh mapping. It was also extended to provide connections between different regions of a multi-region simulation.
NCC enables a modular approach to meshing in which individual domains and regions within them can be meshed separately and then connected, as shown below. Stationary domains can be connected using NCC itself, or more persistently using the stitchMesh utility, recently rewritten by CFD Direct using the patch intersection algorithm developed for NCC.
Case-based, collaborative development
In July 2021, CFD Direct released OpenFOAM v9 via the OpenFOAM Foundation. Hightlights of v9 included the replacement of fvOptions with fvModels and fvConstraints and redesign of thermophysical transport modelling. There was no plan to include specific capabilities to simulate IC engines within OpenFOAM at that time. A few months later, however, Wärtsilä put forward a plan to develop the capability, which has now been released only two and a half years later.
What factors have contributed to the success? First, Wärtsilä and their funding partners invested in this capability at a realistic level. They paid CFD Direct for development and support and became a Gold Level sponsor of OpenFOAM. The funding covered everything from the development of new functionality like mesh-to-mesh mapping, to refactoring of poorly designed or defective code and removal of redundant code.
Wärtsilä have staff allocated to this project full-time, who work in parallel with CFD Direct. They keep their work up to date with the latest code in OpenFOAM-dev
, testing new developments and reporting any issues that arise. With everything continuously maintained and updated, it is possible to adopt important new developments funded from other sources. For example, CFD Direct’s development of NCC was funded from 2017 by the Process Engineering Consortium and released in OpenFOAM v10 in 2022, reaching maturity in OpenFOAM v11.
There are clear advantages of developing CFD software towards a specific simulation case — here, IC engines. With case-based development, functionality is developed as required and fit for purpose, rather than by conjecture. Testing on real cases exposes shortcomings of new developments, in particular relating to robustness and efficiency. Scientific computing needs agile development (i.e. an iterative and flexible approach), as opposed to roadmap development.
The ICengines repository
The public ICengines
repository was created on March 5th 2024 at the OpenFOAM Foundation GitHub site. Wärtsilä released an initial beta version of an Advanced Analysis Tool for Engines (AATE) in the repository. They plan to release new features in AATE in August each year, following each new version release of OpenFOAM in July. New developments in OpenFOAM, funded by Wärtsilä or otherwise, create new opportunities to improve the tool. One possibility is the addition of conjugate heat transfer, enabled by modular solvers, released in OpenFOAM v11, in combination with NCC. At the current rate of progress, we can expect exciting developments over the coming years.