For my undergraduate thesis, I developed a G-code based program in MATLAB that simulates the material removal process and predicts the energy and power consumption required to CNC machine a part. The simulation was validated by comparing the simulated energy to that of a part in both aluminum and titanium, showing an energy prediction error of 2.11% and 3.48% respectively.
This program functions by first reconstructing the toolpath from the G-code.
The simulation then runs a virtual endmill along the toolpath in a voxel mesh of the workpiece, replicating material removal.
The model predicts the power and specific energy consumption for a timestep by relating it to the simulated material removal rate and spindle speed using existing analytical models and machine-dependant power data. An example relation is shown below.
The full thesis with comparisons and sensitivity analyses can be found here.