Thermal engines are the most important component in underwater gliders (TUGs) for converting ocean thermal energy for propulsion. Although experimental achievements were made to establish diverse thermal engine, the insight thermal-to-work conversion process lacks detailed investigation. This paper unveils the fundamental principles of this thermal engine by establishing a numerical model describing the PCM expansion induced pressurized oil transfer process between two flexible oil bladders. The results of the numerical simulations well match the experimental test. Further, the effects of the outer wall temperature and the diameter of the thermal engine on the performance of the engine, as well as the velocities and streamlines evolution in the liquid phase PCM and pressurized oil are studied. This study finds that increasing the outer wall temperature of the thermal engine significantly reduces the melting duration of the PCM by changing the Stefan number (Ste) and Grashof number (Gr). Additionally, the velocity distribution in the liquid PCM resulted from natural convection affects the melting process and the performance of the thermal engine. In summary, this study provides important insights into the thermal-to-work conversion and is helpful in optimizing the performance of TUG.