A diesel engine is a typical dynamic system. In this paper, a dynamics method is proposed to establish the Hamiltonian model of the diesel engine, which solves the main difficulty of constructing a Hamiltonian function under the multi-field coupling condition. Furthermore, the control method of Hamiltonian model structure modification is introduced to study the control of a diesel engine. By means of the principle of energy-shaping and Hamiltonian model structure modification theories, the modified energy function is constructed, which is proved to be a quasi-Lyapunov function of the closed-loop system. Finally, the control laws are derived, and the simulations are carried out. The study reveals the dynamic mechanism of diesel engine operation and control and provides a new way to research the modeling and control of a diesel engine system.