Optimization of PID control parameters for marine dual-fuel engine using improved particle swarm algorithm

This study presents a comprehensive investigation into the optimization of PID control parameters for marine dual-fuel engines using an improved particle swarm algorithm. Through the development of a Matlab/Simulink simulation model, the thermodynamic behavior of the engine and the functionality of its control system are analyzed. The PID control parameters for air–fuel ratio control and mode switching control systems are fine-tuned utilizing the improved particle swarm algorithm (PSO). Simulation results demonstrate that the proposed improved PID-PSO approach outperforms traditional PID and traditional PSO-PID control methods in terms of reduced overshoot, minimized steady-state error, faster response times, and improved stability across various operating conditions and response modes. In comparison to traditional PID and PSO-PID controllers, the improved PSO-PID controller reduces the response time by 0.47 s and 0.21 s, the maximum overshoot by 98.43% and 96.05%, and decreases the absolute errors by 87.42% and 90.55%, respectively, in air–fuel ratio control using the step response method. The study's findings offer valuable insights into enhancing the performance and efficiency of marine dual-fuel engines through advanced control strategies.

1. Proposal and modeling of a sophisticated large-scale dual-fuel engine model based on the Matlab/Simulink environment.2. Introduction of an improved PSO algorithm to optimize the parameters of the traditional PID controller.3. Designing an effective similarity inertia weight function to ensure fast system response speed, low overshoot, and small steady-state errors.4. Air-fuel ratio and mode switching of the dual-fuel engine, solving issues of low optimization control precision, slow speed, and local optimal solutions.5. Insights for controling the dual-fuel engine for actual response modes in marine application.

Model of dual-fuel engine
Natural gas engines can be classified into two basic types based on the combustion method: single-fuel engines using spark plug ignition and dual-fuel engines that primarily use natural gas as the main fuel with high-reactivity fuels such as diesel as pilot fuel.The inclusion of pilot fuel in the latter addresses the challenge of ignition difficulty, especially under high fuel replacement rates, ensuring smoother and more reliable engine operation.In dual-fuel engines for vehicles, two main natural gas injection technologies are employed: intake manifold premixed injection and in-cylinder direct injection.There are three popular types of dual-fuel engines for marine applications: two-stroke high-pressure injection, two-stroke low-pressure injection, and four-stroke intake manifold injection 25 .Figure 1 illustrates the main structure of the marine dual fuel engine.The model comprises key components such as the intake and exhaust modules, fuel supply module, cylinder module, supercharger module, and air cooler module for dual-fuel engines.Table 1 presents the main technical specifications of the MAN 8L51/60DF dual-fuel engine 26 .

Basic equation for thermodynamics
The operation of dual fuel engine involves a series of complex chemical combustion, physical transmission, gas/ liquid flow and heat transfer processes, which can be simplified by the following equations.

Cylinder mathematical model
The cylinder module stands out as the most intricate and pivotal component within the entire engine modeling framework.The modeling of cylinder module comprises three aspects: the cylinder working volume, combustion, and cylinder perimeter wall heat transfer.This module plays a crucial role in capturing and simulating the complex dynamics occurring within the engine cylinder 27 .The cylinder working volume and volume change rate can be presented as follows: (1) dU = dW + dQ i + j h j • dm j (2) dm dϕ = dm s dϕ + dm e dϕ + dm B dϕ  where V s is cylinder working volume, L; λ is connecting rod to crank ratio; φ is crankshaft angle; S is fuel injection penetration; D is the diameter of the jet hole; ε is compression ratio.
In the context of non-predictive combustion models, the combustion rate is solely influenced by the crankshaft rotation angle, irrespective of whether the cylinder's operating conditions meet the combustion demand.Given the substantial impact of air-fuel ratio and fuel substitution rate on the combustion rate, coupled with the direct influence of injection parameter settings on the combustion process within the cylinder, the MAN 8L51/60DF dual-fuel engine employed in this study integrates the predictive combustion model DI-Pluse from Matlab/Simulink.This choice facilitates an exploration of the effects of these variables on power output, fuel consumption, and exhaust emissions in a dual-fuel engine.Distinct thermodynamic state parameters, compositions, and concentrations characterize the discrete thermodynamic partitions, and their independence from one another is a notable feature.The primary unburned zone, or first partition, comprises gases remaining in the cylinder after closure.The second and third partitions consist of the injected unburned zone-composed of inhaled fuel and gases-and the injected burned zone, representing combustion products.The mathematical model used to simulate this process is as follows.
Divided length: where L is the length of the jet hole; v i is the jet velocity; ρ l is the density of the injected fuel; and ρ g is the density of the surrounding gas.Angle of the spray cone: Fuel injection penetration: where t b is the oil beam splitting time; p is the jet pressure difference; D 0 is initial diameter of spray hole.

Fire delay duration:
where a is the ignition delay factor; b is the pressure delay exponent; c is the empirical constant; d is the delayed activation temperature; Z is the ignition delay period; φ is the equivalence ratio.
Rates of combustion and volumetric absorption can be defined as: where x j is the coordinate of the jth cell along the spray axis; R j is the radius of the jth cell; v j is the velocity of the local jet; v a, j is the velocity of the air; C x is the empirical constant; S L is the laminar flame velocity.Diffusion combustion models for computing volumetric absorption and burning rates: where l I is the integrated length scale, C u is 0.09, and C e is the pre-combustion coefficient before the ignition point of each partition, k is insulation index.Heat exchange occurs throughout the entire operation of the engine, such as between the external environment and the cylinder body, as well as between the cylinder body and the cylinder mixture.Heat losses are calculated through a heat transfer model, which transforms the complex heat transfer processes into a heat transfer coefficient model.The Woschni, Eichelberg, Annand, and Sitkei formulas can all be used to calculate the instantaneous heat transfer coefficient.In this paper, the Woschni heat transfer model is employed to calculate the heat transfer coefficient.This model is widely used in the field of internal combustion engine simulation modeling due to its simplicity and accuracy.The calculation formula is as follows 28 : where P z is the instantaneous cylinder pressure, MPa; T z is the instantaneous cylinder temperature, K; P 1 , T 1 , V 1 is the pressure, temperature, and volume at the starting point of compression; c m is the average piston velocity, m/s; c 1 is the gas velocity coefficient; c 2 is combustion chamber shape coefficient.

Intake and exhaust mathematical model
Due to the influence of exhaust gas pressure fluctuations on the efficiency of the turbocharger and the residual gas quantity in the cylinder, and the direct impact of intake manifold pressure fluctuations on the intake volume within the cylinder, it is necessary to perform detailed calculations of the gas flow in the dual fuel engine's intake and exhaust pipes.
In the simulation and modeling calculations, it is common to simplify the three-dimensional non-isotropic flow simulation of the dual fuel engine's intake and exhaust processes into an unsteady one-dimensional flow.During the engine's operation, the relevant parameters of the intake and exhaust systems are constantly changing.The pipe diameter is much smaller than the pipe length, resulting in radial flow dominating the entire flow process.Therefore, the intake and exhaust processes are treated as one-dimensional, and the simulation calculation method adopts the one-dimensional finite volume method.
Firstly, it is necessary to establish the differential equations relating the state parameters such as velocity, temperature, and pressure of the pipe segment to the corresponding crankshaft rotation angle and axial direction.The solution of the continuity equation, energy equation, and momentum equation are crucial for the mathematical model of the intake and exhaust systems.
The continuous equation is presented as: where m in is the inlet mass flow rate, kg/s; m is the mass of the work fluid in the boundary, kg; ρ is the density of the fluid in the pipe, kg/m 3 .A is the corresponding cross-sectional area of the pipe, m 2 ; u is the velocity of the control body boundary, m/s.The energy equation is expressed: where A s is the heat transfer surface area of the inner wall of the tube, m 2 ; p is the pressure, MPa; H is the total enthalpy corresponding to the fluid, J/kg; h is the heat transfer coefficient, W/(m 2. K); T fluid is the fluid temperature, K; T wall is the wall temperature of the tube wall, K.

Turbocharger mathematical model
In a waste gas turbocharged engine, the waste gas turbine converts the energy from the engine's exhaust gases into mechanical work through a turbine.This mechanical work is then transferred to the compressor, which compresses the air to increase the volume of air entering the engine and raise the intake pressure.Throughout this process, the turbine and compressor must achieve power balance, speed balance, and flow balance 29 .The power balance is expressed as: where W K is the work consumed by the compressor, kW; W T is the turbine work, kW; and η TKm is the supercharger efficiency.
( The rotational speeds of the compressor, turbine and supercharger are the same: where n K is the speed of the compressor; n T is the speed of the turbine; and n TK the shaft speed of the supercharger.The exhaust gas flow rate is the sum of the air and fuel flow rate: where ṁT is the exhaust gas flow rate; ṁK is the air flow rate; and ṁf is the fuel mass flow rate.The exhaust gas turbine plays a crucial role in powering the supercharger, and its model should encompass key features such as air flow, boost ratio, speed, and efficiency.The supercharger model, in turn, is characterized by two input parameters: air flow rate and supercharger speed, while the output parameters include temperature (T o ) and outlet pressure (P o ).
The pressurization ratio and the turbine's rotor speed can be calculated using the principles of thermodynamics and Newton's laws.Specific flow rate and efficiency data for the compressor can be acquired by referring to relevant tables.Subsequently, the compressor's efficiency can be determined using the one-dimensional isentropic adiabatic flow theory.Finally, the outlet temperature (T o ) and outlet pressure (P o ) can be calculated using the one-dimensional isentropic adiabatic compression process, with the arithmetic formula provided as follows.
where P i is the atmospheric pressure, Pa; T e is the environmental temperature, K.
The pressurization ratio and isentropic efficiency of the compressor are contingent upon both the air flow rate and the rotational speed of the compressor.These functional dependencies can be expressed through a mathematical relationship: The above functional relationships are typically determined based on characteristic curves of a specific model of a turbocharged gas engine.Due to the absence of characteristic curves for the turbocharger, a modeling approach is adopted using the characteristic curves of a diesel engine.Specifically, the pressurization ratio and efficiency of the turbocharger are formulated as a one-dimensional table that varies with the load of the dualfuel engine, represented using the one-dimensional lookup table module in Simulink.The modeling process of the turbocharger involves the utilization of additional structural or performance parameters, with specific numerical values as detailed in Table 2.

Intercooler model
The intercooler serves to cool the fresh air entering the cylinder, thereby improving the turbocharging efficiency of the engine.The input parameters for the intercooler model include the air temperature, air pressure, and air mass flow rate at the outlet of the turbocharger.As air flows through the intercooler, there is a pressure loss and temperature decrease.By introducing the intercooler effectiveness coefficient (i.e., the temperature at the outlet of the intercooler), the outlet temperature of the intercooler is calculated using a simplified method.By introducing the intercooler effectiveness coefficient (β) and combining it with experimental data, the outlet temperature of the intercooler is calculated using a simplified method, with β set to 0.88, resulting in the intercooler outlet temperature.
where T w is cooling water inlet temperature, K; β is cooling coefficient is generally taken as 0.7-0.9.
Intercooler pressure loss P s is defined as: where q m is actual flow rate of the intercooler, kg/s; P s0 is pressure loss of the intercooler at design operating conditions, Pa; q m0 is intercooler design flow rate, kg/s.Then the air pressure at the outlet is: The values of the intercooler parameters are shown in Table 3.

Cylinder intake model
The cylinder charging coefficient is a parameter that quantifies the amount of fresh air remaining in the cylinder at the end of the intake stroke relative to the volume of the intake manifold.Research results indicate that there is a functional relationship between the cylinder charging coefficient and the engine speed.Therefore, this article uses the least squares method to fit the engine speed and boost coefficient data to obtain the boost coefficient curve: where a 0 , a 1 , a 2 are the fitted constants.
Since the model established is an average model for studying air-fuel ratio control methods, it overlooks the residual exhaust gases in the cylinder after each engine cycle.According to the ideal gas equation, the intake air flow can be calculated as:

Fuel sub-model
For the MAN 8L51/60DF LNG/diesel dual-fuel engine, a fuel sub-model is established based on the propulsion characteristics.Under propulsion characteristics, the relationship between power and speed is given by: where P is engine power, kW; F is scale factor.
The corresponding values of propulsion characteristic speed and load are shown in Table 4.
To accurately establish the fuel supply sub-model for marine liquefied natural gas/diesel dual-fuel engines, it is necessary to explore the fuel injection quantity under propulsion characteristics 30 .In dual-fuel engines, both diesel and natural gas are introduced into the engine cylinder for combustion.The calculation necessitates the incorporation of the substitution ratio, which denotes the reduction in the amount of diesel consumed by the engine in dual-fuel operating mode compared to the consumption in pure diesel operating mode 31 .This ratio is expressed as a percentage of the diesel consumption in pure diesel operating mode 32 .
where T m is diesel replacement rate, %; B is diesel consumption in diesel-only mode, kg/h; B o is diesel consumption in dual-fuel mode, kg/h.The natural gas entering the cylinder precisely substitutes the reduced diesel fuel in the combustion process, and the substitution rate equals the doping rate.The calculation of the substitution rate is as follows 33 .Under specific operating conditions and at a specific substitution rate, the cylinder injection volume per cycle and the natural gas injection volume are determined based on theoretical considerations.
(31) P s = P s0 q m q m0 (32) P r = P o − P s (33)   where B l is natural gas consumption in dual fuel mode, g/cycle; H ul is low calorific value of natural gas, MJ/kg; H uo is low calorific value of diesel, MJ/kg.Based on the propulsion characteristics, the circulating injection volume and natural gas injection volume are calculated under various working conditions and different fuel substitution rates, following the aforementioned calculation process.Some of the calculation results are presented in Table 5.

Emissions calculation
The calculation of NO X and HC emissions is as follows: where NO X W represents the wet volume concentration of nitrogen oxides in parts per million (ppm), HCW denotes the wet volume concentration of hydrocarbons in parts per million (ppm), MNO X signifies the mass flow rate of nitrogen oxides in grams per kilowatt-hour (g/kWh), and MHC denotes the mass flow rate of hydrocarbons in grams per kilowatt-hour (g/kWh).The detailed calculation and derivation of these parameters can be found in literature 34 .Table 6 provides information on the main components of the fuel along with their respective proportions.

PID control based on improved particle swarm algorithm PID controller principle
The PID controller, being a second-order linear controller, is influenced by its proportional, integral, and differential parameters, allowing for direct modification of its control impact by adjusting these parameters 35 .The most commonly used PID controllers operate based on the following principles 36 : Expressed by transfer function as: where K p is the proportional gain; K i is the integral gain; K d is the differential gain.e(h) is the control error; T i is integral time constant; T d is differential time constant.
e(h) is as follows: (37)  40) is given by: where T u is time.
The integral absolute value of error (IAE) is used to calculate the error:

Standard particle swarm algorithm
To optimize the performance of the entire control system and achieve the ideal value for the controller's objectives, coordinate the parameters accordingly.Apply a particle swarm algorithm (PSO) to optimize these three parameters, seeking the most appropriate values within the specified range 37 .
Standard particle swarm algorithm is a mature swarm intelligence algorithm inspired by foraging scenarios observed in bird flocks and bee colonies 38 .It treats individual organisms as particles, searching in a D-dimensional space, iteratively seeking the optimal solution 39 .The algorithm evaluates results based on fitness and ultimately searches for the global optimum based on the best solution found during the current search 40 .Throughout the iteration process, a particle's motion consists of velocity and position, where the particle's velocity is determined by inertia, self-cognition, and social experience 41 .The optimization equations for the particle swarm are expressed in Eqs. ( 45) and ( 46).where j indicates the particle's jth dimension; i stands for particle i; t indicates the number of iterations; c 3 , c 4 is the acceleration factor; r 1 and r 2 are mutually independent stochastic functions (with values between 0 and 1); w is the inertia weight parameter (with values between 0 and 2).Among them, the initial velocity and position of particles are randomly generated, and then iterated continuously according to the formula.
The velocity update of a particle consists of three parts in above equation: the first part, known as the inertia factor, reflects the influence of the particle's current velocity on its direction and speed, playing a role in both local search and balancing global exploration capability; the second part represents the particle's self-awareness, allowing it to explore various points within the search space based on its own memory; and the third part involves interactions among particles, thereby enables the PSO population to collaboratively search for the optimal solution.This highlights the particle swarm optimization algorithm's strong global search capabilities.

Improved particle swarm algorithm
When standard particle swarm algorithm operates for a certain period, particles lose diversity among themselves and tend to hover around local optima.This susceptibility to converging to local optima can lead to stagnation in the overall iteration of the population.The particles cease exploring other regions, ultimately hindering the discovery of the global optimum 42 .
To tackle the inherent characteristics of PSO, two primary directions for algorithm improvement are identified.One approach involves enhancing algorithmic parameters, with a particular focus on the inertia weight parameter (w).The value of w plays a crucial role in balancing global and local searches.Some researchers have suggested modifications to the inertia weight parameter 43 .In this context, particles engage in global exploration during the initial stages and transition to local refinement post-convergence to attain precise values.The second direction revolves around augmenting the diversity of the population.By integrating genetic algorithms and introducing velocity mutation, position mutation, and other techniques, the diversity of particles can be increased, thereby enhancing global search capability 44 .These proposed solutions effectively address the challenges associated with global search difficulty.However, it remains crucial to strike a balance between global exploration and convergence speed for optimal algorithmic performance.Moreover, Research in particle swarm optimization suggests that the optimal particle (p g ), which is identified based on the performance of the particle swarm in the search space, is typically located near the global optimum.This optimal particle may vary during each iteration of the algorithm.Equation (45) reveals that the velocity update formula simplifies to only the first term.When the inertia weight is excessively large, the current p g may overshoot its neighborhood, potentially missing the true global optimum.Therefore, an effective search strategy involves particles closer to p g having smaller velocities, facilitating a fine-grained search within the neighborhood of the optimal particle.
This study introduces a similarity-based approach to dynamically adjust the inertia weight during iterations, relying on the similarity between each particle and the optimal particle.This ensures that each particle possesses a different w value at each iteration.As PSO iterations progress, particles gradually converge toward the optimal point, resulting in increased similarity among particles and a higher likelihood of falling into local optima.The similarity between two particles i and j is defined as follows: Vol:.( 1234567890 www.nature.com/scientificreports/s (i, j) = 0 when d (i, j) → ∞; 0 ≤ s (i, j) ≤ 1 for any particle.
The following equation is defined to calculate the similarity of i and j: where d (i, j) is expressed in terms of their Euclidean distance, and d max and d min are determined based on the search region of the particle.
From the iterative equation, it's evident that as the optimization process nears the optimal point, the impact of w on the flight velocity becomes more pronounced.To enable a fine-grained search within the vicinity of the optimal solution, particles near the optimum should be assigned smaller w values.This implies that particles bearing higher similarity to the current optimal particle should be assigned smaller w values.
The formula for calculating of w is as follows: The particle's w decreases both linearly with the number of iterations and as the particle's resemblance to the ideal particle rises, as indicated by Eqs. ( 48) and ( 49).This algorithm is beneficial for global search because it initiates the iteration with a large weight value that progressively decreases toward the end, demonstrating good convergence ability.Moreover, the inertia weights of different particles vary; those close to the optimal particle (p g ) have reduced inertia weights.This implies that particles near p g focus more on fine search than global search, increasing the probability of discovering the true global optimal solution.
Figure 2 illustrates the structure of the improved PSO-PID control system.The fundamental concept behind PSO-PID parameter optimization involves creating a model for optimizing PID controller parameters using an improved particle swarm algorithm.In this model, the three parameters of PID (proportional, integral, and differential) are amalgamated as particles within the particle swarm.During the optimization process, each particle iteratively adjusts its speed and position based on its individual experiences and collective group experiences, gradually converging towards the optimal objective and ultimately achieving the desired outcome.The flowchart of the improved PSO-PID control system is presented in Fig. 3.

Dual-fuel engine model validation
The simulation model of the dual-fuel engine is constructed using Matlab/Simulink, incorporating the mathematical relationships described above as shown in Fig. 4.
Figures 5 and 6 present a comparison of the main parameters in the diesel mode and gas mode of the dualfuel engine between simulation and experiment.Notably, key performance indicators reflecting the engine's performance exhibit a close fit between simulation and experiment, the maximum error was 2.51% for the diesel mode and 2.83% for the gas mode, with an error of less than 3%.This suggests that the established dual-fuel engine model is precisely calibrated.

Steady-state and dynamic characteristics of dual-fuel engine
The air-fuel ratio in a dual-fuel engine significantly impacts its overall performance.Based on the theoretical calculations discussed earlier, the target air-fuel ratio for the liquefied natural gas/diesel dual-fuel engine studied in this paper needs to be configured according to different operating conditions.Under low-load conditions, where the compressor intake is limited, and combustion is insufficient, the air-fuel ratio is kept small but not less than 15.This helps reduce the engine's equivalent fuel consumption rate and emissions of pollutants such as NO X and HC.In the middle load region, the optimal air-fuel ratio falls between 15 and 16, contributing to better overall engine performance, in the high-load condition, the air-fuel ratio should not be a larger value, (47) www.nature.com/scientificreports/but it should not be less than 16. Figure 7 illustrates the comparison between the target air-fuel ratio and the theoretical air-fuel ratio for the four operating conditions.Figures 8 and 9 illustrate the variations in NO X and HC under different loads and fuel substitution rates.Notably, a decrease in the fuel substitution rate correlates with a continuous rise in the specific emissions of NO X .This trend is primarily attributed to the reduced natural gas injection quantity, causing an overall decrease in the specific heat capacity of the cylinder due to the larger specific heat capacity of natural gas.Additionally, a higher proportion of diesel in the mixture with natural gas/air expands the ignition area of diesel, promoting complete combustion and elevating the combustion temperature within the cylinder, thus facilitating NO X formation.Furthermore, the reduction in natural gas injection increases the fresh air volume entering the cylinder, expanding the oxygen-rich area and favoring NO X synthesis.
Conversely, at higher fuel substitution rates, where diesel/natural gas/air premixed combustion occurs within the cylinder, the high equivalence ratio of natural gas and a smaller diesel injection mass result in a lower release of heat during the diesel diffusion combustion stage.Consequently, the cylinder temperature does not rise rapidly, leading to a reduction in nitrogen oxide emissions.www.nature.com/scientificreports/However, reducing the fuel substitution rate significantly decreases HC emissions.This is because a larger quantity of natural gas enters the cylinder, increasing the concentration area of gases within the cylinder, worsening the combustion conditions and causing incomplete combustion.Simultaneously, the low temperature and pressure within the cylinder result in poor diesel atomization, uneven mixing of diesel/natural gas/air, and suppression of complete combustion of natural gas.When the injection volume of natural gas decreases, the equivalence ratio of natural gas decreases.The temperature and pressure within the cylinder continually rise, and the increased diesel injection mass raises the heat release, promoting the complete combustion of natural gas and leading to a decrease in HC emissions.
According to the engine operation manual, dual-fuel engines possess the capability to transiently switch from diesel mode to gas mode when the engine load is below 80%, ensuring the safe operation of the engine.Moreover, they can seamlessly switch from gas mode to diesel mode under any load condition.This study specifically focuses on the transition from diesel mode to gas mode at an 80% load.Figure 10 illustrates the transient process of the engine performance parameters' response curve.As can be seen, in the transition from diesel mode to gas mode, the entire fuel conversion process is completed within 2 min.Throughout this transition, the air-fuel ratio and fuel consumption exhibit minimal deviation from the desired values.However, the engine's power and speed display more noticeable fluctuations.The power fluctuates within the range of 5000-8000 kW, while the speed fluctuates in the range of 445-455 rpm.Despite these fluctuations, the developed control system described in this paper proves effective in realizing the control of engine operating conditions.

Control performance under different response patterns
The control performance of air-fuel ratios under various response patterns is depicted in Fig. 11 for traditional PID control, PSO-PID control, and improved PSO-PID control.These patterns include step response, which simulates a sudden change in load; continuous change to node change response, which simulates a gradual and continuous increase or decrease in engine load; and periodic change response, which mimics the periodic load changes experienced by a marine dual-fuel engine on a fixed route.In the improved PSO algorithm, parameters c 3 and c 4 are set to 1.495.The maximum inertia weight is 1.5, and the minimum inertia weight is 0.4.The number of iteration steps is 60.
The response control simulation is conducted under the scenarios include 25% load with 10% fuel substitution, 50% load with 30% fuel substitution, 75% load with 50% fuel substitution, and 100% load with 70% fuel substitution.As can be seen, the improved PSO-PID control exhibits superior performance in terms of convergence speed and stability compared to traditional PID and PSO-PID across various response modes, ensuring the system's responsiveness.Notably, it excels in controlling step and nodal variations in the air-fuel ratio, displaying greater accuracy and stability in smooth cyclic variations compared to traditional PID and PSO-PID controls.Using the step response of air-fuel ratio as an illustration, the improved PSO-PID controller exhibits notable improvements over both the traditional PID and PSO-PID controllers.Specifically, compared to the traditional PID controller, the improved PSO-PID controller reduces the response time by 0.47 s and the maximum overshoot by 98.43%, while decreasing the absolute errors by 87.42%.Similarly, compared to the PSO-PID controller, the improved PSO-PID controller reduces the response time by 0.21 s, the maximum overshoot by 96.05%, and the absolute errors by 90.55%.Table 7 shows the comparison of PID setting parameters and performance indicators under different control methods and response modes.
Figures 12 and 13 provide a comprehensive view of the impact of traditional PID control, PSO-PID control, and improved PSO-PID control on NO X and HC emissions across various operational conditions and response modes.Notably, traditional PID control exhibits a larger overshoot and requires a longer time to stabilize, as seen in both NO X and HC emissions.Conversely, the improved PSO-PID control demonstrates superior tracking     performance, showcasing its effectiveness in promptly and accurately responding to dynamic changes in operating conditions.For example, considering the step response of NO X emissions, compared to the traditional PID and PSO-PID controllers, the improved PSO-PID reduces the response time by 1.15 s and 0.83 s, respectively.Moreover, the maximum overshoot decreases by 98.91% and 97.68%, while the absolute errors reduce by 89.31% and 91.75%, respectively.
Figure 14 presents a comparison of the effects of natural gas and diesel injection volumes under various operating situations.Notably, improved PSO-PID control demonstrates significant enhancements in reducing overshoot and improving stability compared to traditional PID control and PSO-PID control.Particularly depicted in Fig. 14a, compared to the traditional PID and PSO-PID methods, the improved PSO-PID control demonstrates a significant reduction in maximum overshoot by 97.21% and 95.79%, respectively.Additionally, www.nature.com/scientificreports/ it achieves a shortened response time of 0.68 s and 0.22 s, respectively.Furthermore, the absolute errors were reduced by 90.02% and 89.39%, respectively.

Control performance under mode switching
In addition to load changes, mode switching is also a common operation for dual-fuel engines, which can achieve different emissions, different power requirements.Table 8 shows the comparison of set parameters and performance indexes of the air-fuel ratio under different controls during the mode switching of the dual fuel engine.The stability and response time of the mode switching have an important effect on the operation of the system.Figure 15 provides a comparative analysis of control effects during the engine's transition from diesel mode to gas mode at an 80% load.The illustration clearly indicates that, while the three control methods exhibit similar effects on engine speed control, the improved PSO-PID control method surpasses both PID and PSO-PID controls in terms of air-fuel ratio and specific fuel consumption control, showcasing a superior control effect.Taking air-fuel ratio control as an example, the improved PSO-PID control method demonstrates superior performance compared to traditional PID and PSO-PID methods.The response time is reduced by 5.95 s and 5.17 s, respectively; the maximum overshoot is decreased by 96.36% and 95.29%, respectively; and the absolute errors are reduced by 88.22% and 90.09%, respectively.

Conclusion
A comprehensive thermodynamic model and functional model of a large marine dual-fuel engine were developed in the Matlab/Simulink environment.An improved particle swarm optimization (PSO) algorithm was applied to this simulation model to evaluate its control effectiveness and compared with traditional PID and PSO-PID control methods.Through the analysis of the results, the following conclusions are drawn: 1.The developed model was validated against experimental data, and the results showed good agreement, with an average deviation of less than 3%.The simulations demonstrated that the model can accurately predict fuel consumption, power output, and pollutant emissions.2. Dual-fuel engines possess the capability to transiently switch from diesel mode to gas mode, completing the entire fuel conversion process within 2 min when the engine load is below 80%.They can also seamlessly switch from gas mode to diesel mode under any load condition.3. Three different response modes are used to simplify the specific working conditions of dual fuel engine.The improved PSO-PID controller reduces the response time by 0.47 s and 0.21 s, the maximum overshoot by 98.43% and 96.05%, and decreases the absolute errors by 87.42% and 90.55%, respectively, in air-fuel ratio control using the step response method compared with traditional PID and PSO-PID controllers.

Figure 1 .
Figure 1.Structure and working principle of marine dual-fuel engine.

Figure 2 .
Figure 2. Structure of the improved PSO-PID control.

Figure 3 .
Figure 3. Flowchart of the improved PSO-PID control.

Figure 5 .
Figure 5. Model validation in diesel mode.

Figure 6 .
Figure 6.Model validation in gas mode.

Figure 7 .
Figure 7.Comparison of simulated and theoretical air-fuel ratios.

Figure 8 .
Figure 8. Variation of NO X at different loads and fuel substitution rates.

Figure 9 .
Figure 9. Variation of HC under different loads and fuel substitution rates.

Figure 10 .
Figure 10.The response curve of engine performance parameters.

Figure 11 .
Figure 11.Comparison of different controls in response modes with different air-fuel ratios.(a) Comparison of step change response.(b) Comparison of continuous change to node change response.(c) Comparison of periodic change response.

Figure 13 .
Figure 13.Comparison of HC emissions control performance in various response modes.(a) Comparison of step change response.(b) Comparison of continuous change to node change response.(c) Comparison of periodic change response.

Table 1 .
Main technical parameters of marine dual-fuel engine.

Table 2 .
Parameters related to superchargers.

Table 3 .
Values of intercooler related parameters.

Table 4 .
Characteristic speed and load corresponding values during propulsion.

Table 5 .
Partial cyclic injection volume and natural gas injection volume.

Table 7 .
Comparison of setting parameters and performance indicators.