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.

Machined components in titanium
Machined validation part in titanium
Aluminum Power Breakdown graphs
Empirical and predicted power vs time for machining the validation part in aluminum separated by different operations in the toolpath
Titanium Power Breakdown graphs
Empirical and predicted power vs time for machining the validation part in titanium separated by different operations in the toolpath
Energy vs time graphs
Empirical and predicted energy vs time for aluminum (left) and titanium (right)

This program functions by first reconstructing the toolpath from the G-code.

toolpath generated

The simulation then runs a virtual endmill along the toolpath in a voxel mesh of the workpiece, replicating material removal.

before and after mesh

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.

power and sec relation

The full thesis with comparisons and sensitivity analyses can be found here.