Hamiltonian Modeling and Structure Modiﬁed Control of Diesel Engine

: 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 difﬁculty of constructing a Hamiltonian function under the multi-ﬁeld coupling condition. Furthermore, the control method of Hamiltonian model structure modiﬁcation is introduced to study the control of a diesel engine. By means of the principle of energy-shaping and Hamiltonian model structure modiﬁcation theories, the modiﬁed 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.


Introduction
In recent years, with large-scale development and the application of new energy resources, diesel generator sets (DGSs) have become more and more important in distributed power grids and micro-power grids [1]. Diesel engine properties have been paid more and more attention by researchers.
A DGS is complex power equipment. From a control point of view, the dynamic characteristics of the actuator and shafting are key. The internal dynamic process of a diesel engine can be ignored due to the short transient time. Although there are various types of diesel engine actuators, they can be described by the classical second-order vibration model after being abstracted as mathematical models. A simplified first-order transfer function model is also used in some applications. Research methods for the nonlinear characteristics of diesel engine actuators mainly include refined modeling with consideration of the nonlinear characteristics of components [9,10] and the physical characteristics and parameter identification with the introduction of new algorithms [11,12]. Combining the motion equations of the shaft system and the actuator equations, the equations of a diesel engine can be obtained.
Current control can be roughly divided into two categories. First, based on the traditional proportion integration differentiation (PID) control, the new control theory is used to optimize the PID parameters, e.g., using particle swarm optimization to optimize PID parameters [13] and using a radial-basis-function neural network for the real-time optimization of PID parameters [14]. The second aspect is to construct a new controller to replace the PID control unit, e.g., nonlinear H 2 /H ∞ control [15], explicit multi-input and multi-output predictive control [16], extended guaranteed cost control [17], generalized Hamiltonian control [18], and virtual generator technology [19]. The general trend is to break out of the PID mode constraints and introduce new control theories to design new controllers. The generalized Hamiltonian system in solving the control problems of a nonlinear system has significant features. Its structure and the damping matrix provide the relevant dynamic information of internal parameters [20,21], which provides a new way to research the Hamiltonian system. As a result, there have been a lot of achievements. Taking the port-controlled Hamiltonian (PCH) system as an example, the literature [22] has proposed a Hamiltonian control method of structure modification, which effectively avoids the difficulty of constructing the modified energy function, and the control laws are formed with a stabilizing control and an additional control at the given equilibrium point. The solution equation of stabilizing control and the displayed expression of additional control are derived. The control method of the PCH system has many applications. The PCH system combined with the energy-shaping method has been applied to control a permanent magnet synchronous motor [23,24]. The PCH model framework and the adaptive control method have been used to study the modeling problem of an uncertain system with parameters [25]. The energy-shaping control method has been used to study the control strategy of a quasi-Z-source inverter based on the PCH system to reach the purpose of improving the dynamic response and steady-state accuracy [26].
In this paper, the PCH model of a diesel engine is derived. Based on the PCH model, the quasi-Lyapunov function of the system is obtained by the energy-shaping method. Under the condition of guaranteeing the stability of the system at the equilibrium point, the control law of the diesel engine system is obtained by the structure and damping modified The feedback stabilization control is realized.
The key work of this paper includes two aspects. First, a dynamic method is proposed to establish the Hamiltonian model of the diesel engine, which solves the main difficulty of constructing the Hamiltonian function. This method provides a new way for the modeling of other devices based on dynamics theory. Second, based on the established Hamiltonian model, the control method of Hamiltonian model structure modification is introduced to study the control of the DGS, which shows the effectiveness of the structure modification method in the application of the Hamiltonian system.

Actuator Function of Diesel Engine
Consider the diesel engine actuator shown in Figure 1. The mechanical system shown in Figure 1 is a typical spring-mass system. Assuming that the mass of the moving parts containing the armature, linkage of actuator, and so on is m 1 (kg), the linkage displacement is x (m), and the velocity is v (m/s), then the kinetic energy of the moving parts of the actuator is m 1 v 2 /2 and the elastic potential energy is k 1 x 2 /2, where k 1 is the spring stiffness (N/m). The Lagrangian function of the system is equal to the kinetic energy minus the potential energy as follows: The input of the electromagnetic coil is u and the output is a linkage displacement, x. Obviously, the electromagnetic force, F, generated by the armature moving in the charged coil on the axis is related to u and x, i.e., F can be expressed as F(x, u). At the initial steady state, the electromagnetic force is F(x 0 ,u 0 ). If the input changes, ∆u, and the corresponding axis displacement changes, ∆x, then the electromagnetic force changes to F(x 0 + ∆x,u 0 + ∆ u ). Expanding the electromagnetic force into Taylor series and ignoring the higher-order terms, the electromagnetic force can be expressed as follows: where k x = ∂F/∂x and k u = ∂F/∂u. Further, assuming the damping acting on the axis is linear damping with a damping coefficient of c 1 (N·s/m), the external force, Q 1 , acting on the axis is the sum of the electromagnetic force and the damping force, Q 1 = F(x, u)-c 1 v.
As is known, the Lagrangian equation is Substituting L 1 and Q 1 into the above Lagrangian equation (Equation (3)), where at steady state, the differential terms of each order are zero, that is ∆u = 0 and ∆x = 0, then Equation (3) can be written as follows: where k x1 = k x −k 1 and v = .
x. By reducing the order of the nonlinear differential equation (Equation (4)) and setting x 1 , then Equation (4) can be replaced by two first-order equations, as shown in Equation (5):

Motion Equations of Diesel Engine
Taking the angular displacement of the rotating machinery, θ m (rad), as the generalized coordinate, the Lagrangian function L 2 is the rotational kinetic energy of the axis: Assuming that the output torque of the diesel engine is M 1, the electromagnetic torque of the diesel engine load is M 2 , and the damping torque is M d , then, the non-conservative generalized external force acting on the diesel engine shaft is The torque and speed characteristics of the diesel engine shaft is M 1 = kω + d 1 + a 1 x. Referring to [27], the damping torque is expressed as M d = M B D(ω−1), where ω is the angular velocity per unit and M B is the basic value of diesel engine torque. D is the equivalent damping coefficient of the diesel engine. By substituting Equation (6) into the Lagrangian equation (Equation (3)), the motion equation of the diesel engine shaft can be obtained as follows: The diesel engine actuator and body are combined together as a whole diesel engine system. The Lagrangian function L 3 of the entire diesel engine system is:

Hamiltonian Model of Diesel Engine
Setting V = [x 2 x 1 ω m ] T , according to the theory of analytical dynamics, defines the generalized momentum as follows: According to the theory of analytical dynamics, the Hamiltonian function is defined as Referring to [28], the rotational kinetic energy can be expressed as a function of ω 1 , where ω 1 = ω m /ω B −1 and ω B = 100π (rad/s) which represents the angular velocity base value, then the Hamiltonian function is as follows: where T J = Jω 2 B /S B . Using the Hamiltonian transformation relations ∂H/∂x 1 = k 1 x 1 ,∂H/∂x 2 = m 1 x 2 , and ∂H/∂ω 1 = T J ω B ω 1 , Equations (5) and (7) can be expressed in the form of the Hamiltonian function: Remark 1. Equation (11) is in the Hamiltonian form. This set of equations is derived from the original nonlinear differential equation model of the diesel engine, which is essentially consistent with the differential equations. (11) can be transformed into Equation (12) as follows: where

Basic Theory
A nonlinear system can be written in a PCH as where the state variable is x∈R n , the control variable is u∈R m , m < n, and J(x) = J T (x) is the anti-symmetric structure matrix, which reflects the internal correlation mechanism of the system variables. R(x) = R T (x) is the symmetric damping matrix, which reflects the damping characteristics of the system variables at the port. The input channel matrix, g(x), reflects the action of the external input. Theorem [20]: Given the equilibrium point x 0 , the desired modified structure matrix J α (x), and the damping matrix R a (x), Suppose that a control α(x) and a vector function K(x) can be found to satisfy: and makes i.
At the equilibrium point x 0 satisfied: At the equilibrium point x 0 satisfied: ∂K ∂x (x 0 ) > − ∂ 2 H ∂x 2 (x 0 ). Then, the closed-loop system by u(x) = α(x) can be changed as: where H d (x) = H(x) + H α (x) and ∂H α ∂x (x) = K(x). x 0 is the local stable equilibrium point of the closed-loop system and H d (x) is a quasi-Lyapunov function of the equilibrium.

Design of Modified Structure and Damping
The purpose of the design is to make the system (Equation (12)) stable at the given equilibrium point by finding the modified structural matrix, J α , and damping matrix, R a .
Step 1: Constructing the Hamiltonian function and modified matrixes of the closedloop system.
The Hamiltonian function, H d , is selected as follows: where x 0 = x 10 x 20 ω 10 T is the initial value of the state variables and If every element is modified in the matrixes J α (x) and R α (x), it would make the design very difficult. Therefore, considering the correlation of variables, the modified matrixes J α and R α are selected as Equations (17) and (18), respectively: and In Equation (17), J 13 represents the influence factor between the linkage displacement and the shaft speed, and J 23 represents the influence factor between the linkage speed and the shaft speed. In Equation (18), the elements r 1 , r 2 , and r 3 represent the damping factor of the state variable itself.
Step 2: Calculation of the vector function K(x).
Setting the feedback control, a, as Substituting Equations (15)- (20) into Equation (14), the following three equations can be obtained: From Equations (22) and (23), the expressions of the control variable,u α and the load moment, M 2 , can be obtained as follows: It is known from Equation (12) that u and M 2 are input control variables of the system. After the modified design, their expressions (Equations (24) and (25)) contain the damping and structure modified factors r 2 , J 13 , and J 23 . This means that the outputs of the diesel engine can be controlled by these modified factors. (24) can be expressed as u = u 0 + ∆u , where u 0 = k x1 x 10 /k u + c 1 x 20 /k u is the initial control. ∆u which is related to the modified factors r 2 and J 23 is the additional control item generated by the modified structure, namely

Remark 3. Equation (25) can be expressed as M
which is related to the modified factors J 13 , J 23 , and r 3 represents another item of the additional control generated by the modified structure.

Stability Analysis
According to the theorem in Section 3.1 of the theorem is satisfied, and the Hessian matrix is The above analysis shows that the closed-loop system is stable at the equilibrium point, and H d (x) is a quasi-Lyapunov function of the equilibrium point.

Remark 4:
The key to the realization of the Hamiltonian model structure modification method is whether an appropriate energy function H d can be found. In this study, H d chosen in function (16) is the same form as energy function H in (10). The purpose is to satisfy the condition of stability, but, in the application of this method for a general dynamic system, finding an appropriate energy function H d is not easy.

Remark 5:
The additional control output generated by the modification is reflected in Equations (24) and (25). In this paper, as these two equations do not contain factor r 1 , the parameter modification of r 1 fails, and this is the deficiency of this design method.

Simulation System
The purpose of studying the modeling and control of a DGS is to play the regulating role of the DGS in a micro-grid that includes wind power, solar power, batteries, and a DGS. Therefore, the simulation platform is constructed as in Figure 2 and contains three modules: renewable energy module, DGS, and load module in which the renewable energy module includes solar power, wind power, and batteries. The DGS adopts the Hamilton model proposed in this paper. The load module is used to simulate the load and the load disturbance is controlled by the switch QF.

Simulation parameters:
The rated power of the diesel engine is 1250 kW, the rated speed, n, is 1500 r/min, the mass, m 1 , is 0.8 kg, the mechanical damping coefficient, c 1 , is 10.0 N s/mm, the spring stiffness, k 1 , is 3.6, the maximum stroke of the linkage output is 10 mm, the moment of inertia, J, is 71.822 kg.m 2 , the number of generator poles, p, is 2, and the equivalent damping coefficient of the generator, D, is 2.1753. The output power of the renewable energy in Figure 2 remains unchanged during the simulation.

Stability Simulation Analysis of Diesel Engine Model
The stability of the diesel engine model is studied by simulation. The initial operating conditions are as follows: the initial load, p e , is 0.8 (pu), with a 0.1 (pu) step disturbance occurring at t = 1.0 s and ending at t = 5.0 s. In the transient process, the characteristics of the output torque, p m1 , of the diesel engine, the electromagnetic power, p e1 , of the generator connected to the diesel engine, and the diesel engine frequency are simulated. The simulation results are shown in Figures 3 and 4, respectively.  In Figure 3, the red dotted line is the diesel engine output torque, p m1 , and the black line is the electromagnetic power of the generator output, p e1 . It can be seen in the process of load disturbance that the response of the diesel engine and the generator output power is completely consistent.
The curve in Figure 4 is the changing of frequency. The oscillation characteristic of the frequency curve is consistent with the expected result of the theoretical analysis.
The above simulation results show that the model of the diesel engine is correct and stable under the disturbance of the load step.

Effects of Modified Factors on Output
The initial operating conditions are as follows: the active power of the generator, p e , is 0.8 (pu), the power factor of the generator is 0.8, with a 0.1 (pu) step disturbance occurring at t = 0.1 s and ending at t = 0.2 s. The effect of each modified factor on the output power of the diesel generator set is studied below.
(1) Effect of modified damping factor Given the structure factors J 13 = 3 and J 23 = 3, the response characteristics of the DGS in different values of the damping factor are shown in Figure 5. It can be seen from Figure 5 that the red curve with r 2 = 0, r 3 = 50 has better effects than that of the black curve without the additional control and the blue curve with r 2 = 50, r 3 = 0. The results indicate that the overshoot generated by the disturbance can be suppressed by selecting appropriate modified damping parameters, and meanwhile the oscillation time is shortened. That is, the oscillation damping of the system can be changed by modifying the damping parameters in Equation (18). Therefore, the modified damping factor design is effective. (2) Effects of modified structure factor Given the damping modified factor r 2 = 5, r 3 = 5, Figures 6 and 7 are the response curves of the active power in different modified structure factor values of J 13 and J 23 . Figures 6 and 7 show that the decay characteristics of the active power oscillation of the DGS change with varying the modified structure factor. By selecting the appropriate modified structure parameters, a better effect on disturbance suppression can be obtained.  (3) Relationship between the modified factors and the damping coefficient The above simulation results show that different values of the modified factors have different effects on the output of active power of the DGS, reflecting the different role of damping. The damping characteristic can be described by using the damping coefficient, which can be extracted from the oscillation curve of the active power. In this section, different modified factors are selected to further study the relationship between the modified factors and the damping coefficient.
Keeping the modified structure factors J 13 and J 23 unchanged, while r 2 and r 3 change within a certain range, the relationship between r 2 , r 3 , and the damping coefficient is simulated. In Figure 8, r 3 changes from 2 to 7 and the variation of r 2 and the damping coefficient is shown. It can be seen that the damping coefficient increases with the decrease of r 2 and increases with the increase of r 3 . These results assist with the design of the matrix R α expressed in Equation (18), which makes the damping coefficient higher and the control effect better. From the aspect of the structure factor, J, the effects of J 13 and J 23 on the damping coefficient are studied. Keeping the damping modified factors r 2 and r 3 unchanged, while J 23 and J 13 change within a certain range, the relationship between J 23 , J 13 , and the damping coefficient is simulated. In Figure 9, seven curves are obtained with J 13 changing from 0 to 7. The result in Figure 9 shows that the smaller J 13 is better in achieving the higher damping coefficient. The result can help us to design the matrix J α expressed in Equation Function (17) and get a satisfactory control effect.

Conclusions
In this paper, the modeling and control of a diesel engine are studied from the perspective of Hamiltonian dynamics. The dynamics mechanism of diesel engine operation and control are explored. Three conclusions are drawn: (1) The Hamiltonian function of a diesel engine is constructed based on the dynamics principle, and the port-controlled Hamiltonian model of a diesel engine is further established. This modeling method provides a new way for other equipment to establish the Hamiltonian model. (2) The modification of the structure and damping matrixes is essentially equivalent to an additional control, which can suppress the abrupt load disturbance. The modified matrixes J α and R α are the key components of this additional control, and the control effect is closely related to the modified factors in the J α and R α matrixes. Both structure and damping factors have a damping effect on the load oscillation. However, there exists an optimal match between the structure and the damping factors to obtain the desired control effect. The related optimization problems are worth further exploring in the future.
(3) The method presented in this paper can be extended to all operating cases of diesel engines. In order to obtain a good control effect, appropriate J α and R α need to be selected carefully according to various objects.