A MATLAB implementation for steady-state simulation of a novel 6-stroke internal combustion engine architecture. This codebase provides a complete simulation framework, from geometric analysis to thermodynamic modeling and dynamic visualization.
This repository contains a simulation framework for analyzing a 6-stroke engine cycle inspired by US Patent US20240301817A1. The engine employs a planetary gear mechanism to enable variable stroke lengths, resulting in a unique 1080° crank-angle cycle comprising six distinct strokes (two long, two short, and two long strokes in alternating pattern).
The simulation employs a single-zone thermodynamics model with three state variables per cylinder:
- Cylinder pressure (p)
- Trapped gas mass (m)
- Oxygen mass (mO₂)
The thermodynamic modeling combines:
- Wiebe-based heat release functions for two separate combustion events
- Woschni correlation for convective heat transfer
- Compressible nozzle flow models for intake, exhaust, and scavenge ports
The thermodynamics are coupled to an 8-DOF multibody dynamics model representing a flat-six boxer engine configuration:
- 6 rotational DOFs for individual planet gears
- 1 DOF for the carrier/crankshaft
- 1 DOF for the output shaft
A dual-mass flywheel (DMF) model dampens torque fluctuations between the engine and gearbox. The coupled system's equations of motion are integrated in the crank-angle domain (0-1080°), with a cycle-to-cycle fixed-point iteration used to find periodic steady-state solutions.
The codebase is organized into three main directories:
Functions for parameter loading, geometric analysis, and initialization:
parameters.m- Engine parameters and operating conditionsderived_parameters.m- Computed geometric and kinematic parametersextrema_6stroke.m- TDC/BDC computation for all six strokesmanifold_geometry.m- Intake/exhaust/scavenge port geometry setupinitialize_particles.m- Particle initialization for visualization
Core simulation engine including thermodynamics and dynamics:
engine_cycle_steady_6stroke.m- Single-cylinder cycle simulation with fixed-point iterationfull_engine_simulation_6stroke.m- 8-DOF flat-six engine dynamicspiston_kinematics.m- Kinematic relationships for planetary mechanismgeneralized_gas_force.m- Gas pressure → generalized force conversiongeneralized_mesh_force.m- Gear mesh stiffness modelinggeneralized_DMF_force.m- Dual-mass flywheel model
Visualization and post-processing:
plot_results_6stroke.m- Comprehensive plotting of simulation resultsanimate_results_6stroke.m- Animated visualization of engine cycleplot_engine.m- 2D cross-section engine visualizationparticle_simulation.m- Particle-based flow visualization- Various
Draw*.mfunctions for rendering engine components
- MATLAB R2016b or later
- Optimization Toolbox (for
fzeroand ODE solvers)
-
Clone or download this repository
-
Open MATLAB and navigate to the repository directory
-
Run the main script:
Main_engine
The script automatically adds the required subdirectories to MATLAB's path and executes the complete simulation workflow:
- Parameter loading and geometric preprocessing
- Periodic steady-state calculation (single cylinder)
- Full 6-cylinder engine simulation with dynamics
- Result visualization and animation
Engine parameters can be modified in parameters.m, including:
- Operating conditions (RPM, number of cylinders)
- Geometric parameters (bore, stroke lengths, gear ratios)
- Combustion timing and fuel split
- Valve and port timing
- Heat transfer coefficients
This codebase represents a streamlined version intended for public release. While it captures the essential physics and dynamics of the 6-stroke cycle, certain advanced features and refinements present in more detailed implementations may not be included. The modeling approach prioritizes computational efficiency while maintaining physical accuracy for steady-state analysis.
Users seeking to extend or modify the code may find that some simplifying assumptions have been made to keep the codebase accessible and maintainable. The core algorithms remain intact and can serve as a solid foundation for further development.
While this codebase is written in MATLAB, the algorithms and mathematical formulations are language-agnostic. Users comfortable with Python, C++, Julia, or other programming languages may find it straightforward to port this codebase. Modern AI-assisted coding tools can significantly streamline the translation process, particularly for the vectorized numerical operations and ODE integration routines that form the core of this simulation.
The modular structure of the codebase—with clear separation between preprocessing, simulation, and visualization—also facilitates translation into object-oriented frameworks where appropriate.
Bart Blockmans
Email: bart@blockmans.net
Note: This code is provided as-is for educational and research purposes. Users should verify model assumptions and results against experimental data or more detailed simulations before making engineering decisions based on these simulations.
