Cyclic Control Optimization Algorithm for Stirling Engines

: The ideal Stirling cycle describes a speciﬁc way to operate an equilibrium Stirling engine. This cycle consists of two isothermal and two isochoric strokes. For non-equilibrium Stirling engines, which may feature various irreversibilities and whose dynamics is characterized by a set of coupled ordinary differential equations, a control strategy that is based on the ideal cycle will not necessarily yield the best performance—for example, it will not generally lead to maximum power. In this paper, we present a method to optimize the engine’s piston paths for different objectives; in particular, power and efﬁciency. Here, the focus is on an indirect iterative gradient algorithm that we use to solve the cyclic optimal control problem. The cyclic optimal control problem leads to a Hamiltonian system that features a symmetry between its state and costate subproblems. The symmetry manifests itself in the existence of mutually related attractive and repulsive limit cycles. Our algorithm exploits these limit cycles to solve the state and costate problems with periodic boundary conditions. A description of the algorithm is provided and it is explained how the control can be embedded in the system dynamics. Moreover, the optimization results obtained for an exemplary Stirling engine model are discussed. For this Stirling engine model, a comparison of the optimized piston paths against harmonic piston paths shows signiﬁcant gains in both power and efﬁciency. At the maximum power point, the relative power gain due to the power-optimal control is ca. 28%, whereas the relative efﬁciency gain due to the efﬁciency-optimal control at the maximum efﬁciency point is ca. 10%.


Introduction
Stirling engines are closed-cycle regenerative heat engines that harness a temperature difference between two external heat baths. At the cost of taking entropy from the hot heat bath and disposing it to the cold heat bath, they generate mechanical work. This means that Stirling engines are very flexible regarding the possible technical representations of those two heat baths. Therefore, they can be applied in various scenarios. Some current example applications are power generation from burnable industrial waste gases [1], domestic combined heat and power generation [2], electro-thermal energy storage systems for renewable energies as an alternative to lithium-ion batteries [3], and low-maintenance power generation in remote regions with harsh climatic conditions [4], among others. If properly designed, Stirling engines can achieve high efficiency, durability, low-maintenance, and low-noise operation. Hence, they are considered to be one good candidate technology for enhancing the sustainability of power systems.
One certain ideal representation of the thermodynamic cycle performed in Stirling engines is commonly referred to as the ideal Stirling cycle. It consists of four distinct strokes (processes) that an enclosed working gas cyclically performs:
Isothermal expansion at T ExH 4.
Isochoric regenerative cooling to T ExL where T ExH and T ExL are the temperatures of the hot and cold heat bath, respectively. If those four ideal processes are repeated in the prescribed order, the cycle represents an ideal heat engine, operating with Carnot efficiency η C = 1 − T ExL /T ExH . In the two regenerative processes 4 and 2, heat needs to be stored and provided at a range of temperatures. The combined process is called regeneration, and is accomplished with help of a multi-temperature heat storage, referred to as a regenerator.
In real Stirling engines, the working gas is typically contained in two working spaces. One of them, the hot working space, is in thermal contact with the hot heat bath. The other one, the cold working space, is in thermal contact with the cold heat bath. The two working spaces' volumes can be changed by moving pistons. As a result of those pistons' movements, the working spaces exchange working gas through the regenerator, which is often implemented as a porous metal structure.
In contrast to the ideal Stirling cycle, in real Stirling engines, the four above-described strokes can typically not be clearly distinguished. This is due to several reasons. First of all, the engine's piston movements (piston paths) usually do not exactly reproduce the two isochoric strokes. Moreover, the regenerator, as well as the hot and cold working spaces, have non-zero dead volumes. The most important reason, however, is connected to the fact that real engines are supposed to produce a finite amount of work in finite time, which is in contrast to the assumptions of equilibrium thermodynamics, and thus to the ideal Stirling cycle. Consequently, in real Stirling engines, various inevitable loss phenomena occur, for example, finite heat transfer between the working gas and the external heat baths or the regenerator matrix, pressure drop across the regenerator, and heat leaks through the engine's internal components.
Correspondingly, real Stirling engines are non-equilibrium devices. Hence, piston paths aiming to emulate the ideal Stirling cycle's four strokes would not necessarily yield best performance. The question of what piston paths yield best performance, for example, optimal net power, constitutes a cyclic optimal control problem.
In this paper we present an algorithm that can be used to solve such cyclic optimal control problems. It is an indirect iterative gradient algorithm and based on Optimal Control Theory. The algorithm starts with prescribing initial control functions determining the piston paths. These control functions are then gradually modified over the course of the iterations so as to gradually improve an objective and approach the optimal control. To determine the gradual shifts in every iteration, not only does the system of ordinary differential equations, describing the thermodynamics of the Stirling engine, need to be solved, but also a conjugate system of differential equations. For the efficient practical feasibility of this task, low numerical effort of the utilized thermodynamic model is crucial. In detailed models of Stirling engines, significant numerical effort is usually connected to the description of the regenerator. Therefore, here we will apply a Stirling engine model with a reduced-order endoreversible regenerator model that provides a proper tradeoff between accuracy and numerical effort for optimal control problems.
As indicated above, the core discrepancy between the ideal Stirling cycle and a real Stirling engine is that, in the former, all processes are quasi-static, and hence reversible, whereas the latter is required to produce a finite amount of work in finite time. Therefore, real Stirling engines are non-equilibrium devices that could by no means achieve the performance measures of the ideal cycle, such as Carnot efficiency. A non-equilibrium thermodynamics field that studies how constraints on time and rate influence the performance of such devices is Finite-Time Thermodynamics (FTT) [5,6]. FTT typically approaches this and related questions with variational principles and global-rather than local-descriptions of the irreversible systems considered [5].
Endoreversible Thermodynamics [7][8][9][10][11] can be regarded as a subfield of FTT that intends to provide a toolbox of model building blocks from which an FTT model can be constructed in a comprehensible way. The emphasis is placed on including the main loss phenomena, while keeping the model structure clear and minimizing mathematical complexity and numerical effort. The basic approach is to decompose the considered thermodynamic system into a network of reversible subsystems that are connected with each other through (ir)reversible interactions. That is, in its endoreversible representation, the original system's irreversibilities are captured by the interactions, whereas for the reversible subsystems the known relations from equilibrium thermodynamics hold.
The optimization approach used in the current study to optimize the Stirling engine differs from [21][22][23] in that a cyclic version of Optimal Control Theory is applied. Beyond Endoreversible Thermodynamics, this has been done by Craun and Bamieh [24] for an ideal beta-Stirling engine model with an actively controlled displacer. In [24], the heat transfer between the heat baths and the working gas was infinitely fast and regeneration was perfect. The pressure drop across the regenerator was thermodynamically neglected, but considered in terms of mechanical losses. As opposed to this, in the current study, an alpha-Stirling engine model with finite heat transfer between the heat baths and the working gas, an external heat leak, gas leakages and friction of the piston rings, and an irreversible regenerator is considered. Compared to the endoreversible regenerator models used in [22,23], the EEn-regenerator model [25] used in this study features a significantly higher degree of detail.

Stirling Engine Model
In this paper, our focus is on a cyclic control optimization algorithm that can be applied to various Stirling engine models, or models of other cyclically operating systems. Nevertheless, we here briefly introduce a Stirling engine model [25] that we will use to demonstrate the algorithm's usage. In particular, we will present optimization results for this model in Section 5.
We consider an alpha-type Stirling engine as schematized in Figure 1, where the heat transfer between the external heat baths and the working gas is realized through the cylinders.  [25] has ten degrees of freedom (state variables), being the working space's volumes V i , temperatures T i , and particle numbers n i , the energies E R.h and E R.l of the hot and cold halves of the regenerator matrix as well as the particle number n R.d and temperature T R.d of the gas inside the regenerator dead space.
For the sake of simplicity, we assume a constant finite heat transfer coefficient. Further irreversibilities result from an external heat leak between the heat baths, gas leakage of the piston rings, friction of the pistons, pressure drop across the regenerator, and thermal mixing at the interfaces of the regenerator and the working spaces.
The regenerator is described with the reduced-order endoreversible EEn-regenerator model, developed in [25]. Essentially, this is based on the assumptions that the spatial temperature distribution inside the regenerator is linear and that the temperature difference between the gas and matrix is small. Aside from external irreversibilities that automatically occur due to thermal mixing in the regenerator's interactions with the working spaces, internal irreversibilities can be included via entropy source terms in the EEn-regenerator model. In the current study, the irreversibility due to the pressure drop across the regenerator is accounted for by such an entropy source term.
The Stirling engine performance measures that are to be optimized in this study are power and efficiency. The power, or net power output, is defined as with the fixed cycle time τ and the net cycle work where V i and p i are the volume and pressure of the working spaces i ∈ {H, L} and γ is the friction coefficient of the pistons. Then, the efficiency is where I H,ExH is the instantaneous heat flux to the hot working space and K Ex (T ExH − T ExL ) corresponds to an external heat leak. We here use the same transfer laws and parameter values as in [25], for example, the heat bath temperatures are defined as T ExH = 500 K and T ExL = 300 K. Solely for the heat conductance of the external heat leak, we chose a different parameter value: K Ex = 5 W/K. This Stirling engine model has ten state variables, which are the working spaces' volumes V i , temperatures T i , and particle numbers n i with i ∈ { H,L }, the energies E R.h and E R.l of the hot and cold halves of the regenerator matrix as well as the particle number n R.d and temperature T R.d of the gas inside the regenerator dead space.
The state variables of this Stirling engine model can be arranged in a state vector x and the state dynamics can be expressed in terms ofẋ = f (x, u). Here, f (x, u) is a vectorvalued function that depends on the state vector x and a control vector u. In our Stirling engine model we define the control vector u in terms of an explicitly time-dependent, τ-periodic control function u(t), which has the entries u H (t) and u L (t). Each of those two sub-functions determines the dynamics of one working volume, as indicated in Figure 1. An essential requirement that we raise is that the state dynamicsẋ = f (x, u(t)) features a limit cycle with regard to all state variables, which will be necessary for the applicability of the optimization algorithm. Therefore, care must be taken regarding the embedding of the control in the system dynamics, which will be explained in Section 4.

Cyclic Optimal Control Problem
Optimal Control Theory provides a framework for the dynamic (or indirect) optimization of dynamical systems, such as the above-described Stirling engine model. The type of optimal control problem considered in this work can be formulated as: find an unconstrained, smooth, τ-periodic control function u(t) that maximizes the objective functional subject to the constraintẋ for a fixed period τ. Here, x is the state vector of the system. The dynamics of the system is determined by the ordinary differential Equation (5) and is influenced by the vector-valued, explicitly time-dependent, τ-periodic control function u(t).
For the formulation of necessary conditions of optimality, a Hamilton function H is defined as [26,27] with an adjoint vector λ, which varies over time and will henceforth also be called a costate vector. As we will see later, there exists an interesting symmetry between the dynamics of the state vector x and the costate vector λ. The first order necessary conditions for the control u with the optimal value are [26,27] combined with the respective transversality conditions that specify the boundary conditions for the state and costate dynamics from Equations (7) and (8), respectively. In the case of the optimal cyclic regime, as valid for the stationary operational state of a cyclically operating engine, these boundary conditions are [27] x| τ = x| 0 , The notation x| t refers to the value of x at time t, while it does not indicate explicit time dependence. These boundary conditions do not render the problem overdetermined, since the initial and final values are not quantified, but only required to be equal.
In this way, the global dynamic optimization problem from Equation (4) with the constraint Equation (5) is turned into the continuous set of local (static) optimization problems from Equation (9) with the constraints Equations (7) and (8). This means that H(x, u, λ) must be locally maximized for all t ∈ [0, τ) with respect to u. For the optimal solution x * , u * , λ * of the considered kind of cyclic optimization problem, without explicit time dependence of ζ(x, u), the temporal value of the Hamilton function H * will then be constant [26,27].

Maximum Power
In the case of the optimization being performed for the objective functional, which is the cycle-averaged net power output P, as defined in Equation (1), the definition of the path target function ζ(x, u) for Equations (4) and (6) is straightforward: which is simply the instantaneous power output. Since the optimization is performed for fixed cycle time τ, maximum power corresponds to maximum work. Hence, a prefactor of 1/τ can be disregarded here.

Maximum Efficiency
In the case of the optimization being performed for the objective of efficiency η, as defined in Equation (3), the definition of ζ(x, u) is slightly more involved. This is because the definition of the efficiency corresponds to a ratio of two functionals (inte-grals) which need to be separately evaluated before calculating their ratio. This can be seen in Equation (3) and is in contrast to the structure of Equation (4). In order to resolve this discrepancy, we investigate how variations in the cycle work W and the heat Q H := τ 0 I H,ExH + K Ex (T ExH − T ExL ) dt translate to the first variation of the efficiency: This means that the problem of optimizing the efficiency can be morphed into an equivalent optimization problem of the weighted sum λ W W + λ QH Q H with the weights being defined according to the partial derivatives: Within these weights, W and Q H are the results obtained for a specific prescribed τ-periodic control function u † (t) for which, at a given time t, the values of the control and state vectors are u ≈ u † (t) and x ≈ x † (t).
Here, x † (t) is the periodic solution of the state dynamics for u † (t). Based on this, we can now define the path target function for maximizing the efficiency: Here, W and Q H are again the results obtained for a τ-periodic control function u † (t) with the above-described closeness requirements for the instantaneous values of x and u. In a strict sense, the path target function ζ η (x, u) is therefore also a functional of . If the closeness requirement of x and u, regarding u † (t) is valid for all t, the second and third terms in Equation (15) will (approximately) cancel upon integration from 0 to τ. Therefore, the first term was added here to ensure that τ 0 ζ η (x, u) dt does actually represent η. This first term does, in fact, not influence the optimization problem from Equation (7) to Equation (11), since it does not depend on the instantaneous values of x and u.

Penalty Function
The cyclic optimal control problem introduced so far does not contain inequality constraints for the state x or the control u. However, we can introduce inequality constraints for x and u by means of a penalty function. In particular, we will use such a penalty function to introduce lower and upper bounds for the Stirling engine's working volumes: where the working volumes V i are contained in x, v 0 = 1 W and v 1 = 500 are penalty factors, V i,sw = V i,max − V i,min refers to the admissible swept volumes and V i,max and V i,min are the maximum and minimum admissible working volumes with i ∈ {H, L}. Accordingly, in the case of optimizing the Stirling engine's piston paths for maximum power, the overall path target function is defined as whereas in case of the optimization for maximum efficiency, it is defined as

Optimization Algorithm
The indirect iterative gradient method described in the following was inspired by a contribution of Craun and Bamieh [24,28], who solved an optimal control problem of a modified beta-Stirling engine using an ideal thermodynamic model, namely the Schmidt model. Similar methods have earlier been used, for example, by Horn and Lin [29], Kowler and Kadlec [30], as well as Noorden et al. [31] for other applications. The method presented in this paper differs from the aforementioned ones in the means by which the periodic solutions of the state and costate equations are obtained. A pseudocode representation of the cyclic control optimization algorithm is shown in Algorithm 1.
Algorithm 1 Cyclic optimal control algorithm. declare ε = small number; 13: declareê m = unit vector of m th state component; 14: return u, λ,ā) )/ ε; 15  In the first section, between lines 1 and 20, the basic function definitions are made. First, the right-hand side (RHS) of the state dynamics is defined as a vector function f (x, u). Afterwards, the path cost function ζ(x, u,ā) that is to be maximized in terms of the objective functional from Equation (4) is defined. Here, the argumentā may, for example, contain the cycle work W and heat Q H , as required in Equation (15). Then, based on the definition of the Hamilton function H(x, u, λ,ā) from lines 8 to 10, the right-hand side of the costate dynamics −∇ app x H(x, u, λ,ā) is defined in terms of an approximation: where x m is the mth state component,ê m is the corresponding unit vector and ε is a sufficiently small difference. For simple systems, it is reasonable to derive this right-hand side in terms of algebraic expressions. However, for involved systems it can be much more practical to do this by numerical partial differentiation as, for example, according to Equation (19). Note that for systems with discontinuous dynamics additional care must be taken here in order to make sure that the derivatives are properly approximated in the vicinity of the discontinuity. Similarly to −∇ app x H(x, u, λ,ā), the vector ∇ app u H(x, u, λ,ā) of partial derivatives of the Hamilton function with respect to the control is defined from lines 16 to 20. Here, the following approximation is used: where u m is the mth control component,ê m is the corresponding unit vector and ε is, again, a sufficiently small difference.
In the second section between lines 21 and 28, the most relevant variables are declared and initialized. These are the control vector function u(t), the state vector function x(t), and the costate vector function λ(t). They are defined in the time domain [0, τ) and may be implemented as vectors of arrays, where the array lengths correspond to the number of time steps per period. That means that the values of u, x, and λ are saved at every time step in the periodic domain. The control vector function u(t) is initialized with a smooth τ-periodic guess of the optimal control. Moreover, x(0) is set to arbitrary but physically admissible values, whereas λ(0) is set to 0.
The iterative control optimization itself is described in the third section between lines 29 and 48. This starts at iteration n = 0 with the initial guess of the smooth τ-periodic control function u (0) (t), and the previously defined state and costate initial values x (0) (0) and λ (0) (0), respectively. Here, the bracketed superscript identifies the iteration n of the forloop from lines 30 to 48. Since the control is predefined, the state and costate problem can be solved separately. The steps to obtain the subsequent iteration u (n+1) (t), according to Algorithm 1, can be summarized in simplified terms:

1.
For given u (n) (t): Solveẋ by temporal forward integration in the periodic domain until the cyclic equilibrium is reached. Save auxiliary quantities, such as the cycle work W and the heat Q H inā (n) . (Algorithm 1, lines 31 to 37: example with Euler method.) 2.

4.
Calculate the next control vector function with a sufficiently small positive step-size factor Λ. (Algorithm 1, line 46.) These five steps are repeated for increasing n until u (n) (t) has converged to the optimal control. This can, for example, be checked with the below indicators which should both approach a numerical zero:

Exploiting Limit Cycles
The dynamic systems considered here are required to posses a limit cycle. This means that, given a proper periodic control function, the systems feature a closed state trajectory x ∞ (t) in the state space, which is attractive. Here, the subscript ∞ refers to this limit cycle. If the state dynamics is integrated forward in time starting from t = 0 with a proper initial value x| 0 in the vicinity of x ∞ (0), then x| t → x ∞ (t) for t → ∞. This is a property of many dissipative systems, and it is directly made use of in the first step (Algorithm 1, lines 31 to 35) for finding the periodic solution of the state vector.
Numerical studies of optimal control problems carried out in the context of this work show an interesting type of symmetry in that the costate dynamics then features a limit cycle, too, for prescribed u(t) and x| t := x ∞ (t). However, the respective closed trajectory λ ∞ (t) is repulsive when the costate dynamics is considered forward in time, and becomes attractive in the reversed time direction: λ| t → λ ∞ (t) for t → ∞. Such a relation is not surprising, as the overall Hamiltonian system is conservative and the expansive costate dynamics compensates for the contractive state dynamics. Therefore, in the second step (Algorithm 1, line 38 to 42), the temporal direction of integration is reversed to obtain the periodic solution of the costate vector.
The correspondingly enhanced stability of the costate problem under temporal backward integration can also be exploited without directly making use of the limit-cycle property for obtaining the periodic solution, but for solving boundary value problems, for example, see [26,31].

Proper Embedding of the Control
Note that the way in which the control is embedded in the system's state dynamics, can influence the existence of these limit cycles in the state and costate problems. In the Stirling engine optimization problem, considered in this paper, our goal is to optimize the piston paths. Hence, we chose to structure the system dynamics in such a way that the control function determines the temporal evolution of the working space volumes V i with i ∈ {H, L}. A rather obvious choice for embedding the control u i (t) would be: For an explicitly time-dependent, τ-periodic control u i (t) that has an average value τ 0 u i (t) dt = 0, the resulting volumes V i will be τ-periodic. However, this dynamics does not feature a limit cycle: The solution of V i | t will even for t being large integer multiples of τ remain equal to the initial value V i | 0 from which integration was started. This will translate to the costate problem, so that the solution algorithm from above will, in general, not converge without further manipulation of the optimization problem.
A proper choice for embedding the control in the system's state dynamics that leads to the existence of a limit cycle for a continuous τ-periodic u i (t) is: with a sufficiently large number ν. This dynamics is similar to that of an overdamped mass-spring-damper system, where the spring support moves according to That is, for ν → ∞, the control vector function u(t) represents the limit cycle V ∞ (t) of the volumes.

Results
The previously described optimization algorithm was applied to the exemplary alpha-Stirling engine model presented in Section 2 to optimize the control (piston paths) regarding both power and efficiency. The optimizations were performed for varying cycle time τ, or correspondingly varying engine speed 1/τ. With help of the penalty function from Equation (16), the working volumes were restricted to an approximate range from 100 cm 3 to 1100 cm 3 . The initial control, from which the optimizations were started, corresponds to harmonic piston paths exploiting the complete admissible working volume range and featuring a phase shift of 90 • . This harmonic control will, in the following, also be used as a benchmark.
In Figure 2, the Stirling engine's power-optimal working volume trajectories are shown for different engine speeds.
It can be seen that the power-optimal volume trajectories significantly deviate from harmonic shapes. At low engine speeds, it is favorable to let the pistons rest in their extreme positions for about half the cycle time. This feature is less pronounced at higher engine speeds. Above ca. 1100 rpm and ca. 1300 rpm the power-optimal working volume trajectories detach from the maximum volume bounds, as can be seen in Figure 2 at t/τ ≈ 1/4 and t/τ ≈ 1, respectively. At the highest considered engine speed of 2000 rpm, the swept volumes are considerably reduced. The power-optimal engine speed is ca. 920 rpm, which is highlighted in Figure 2 by thick black lines. It is interesting that the power-optimal piston motions found in [22] by direct optimization are similar to the trajectories from Figure 2 for low and medium engine speeds. This is the case even though, in the current study, a Stirling engine with different parameters, and a much more detailed regenerator model, are considered. Nevertheless, compared to the parametric AS class of piston motions used in [22] for direct optimization, the trajectories from Figure 2 feature more details.
In Figure 3, the Stirling engine's efficiency-optimal working volume trajectories are shown, again for different engine speeds.  Obviously, the efficiency-optimal volume trajectories are different from the poweroptimal ones. The tendency to let the pistons rest in their extreme positions at low engine speeds can also be observed here. However, especially for the cold working volume, this feature is less distinctive than with the power-optimal trajectories. The efficiencyoptimal volume trajectories tend to involve smaller piston velocities and reduced swept volumes, when compared to the power-optimal trajectories for the same engine speed. The efficiency-optimal engine speed is ca. 430 rpm, which is highlighted in Figure 3 by thick black lines.
In Figure 4 the Stirling engine's power and efficiency are plotted against the engine speed for both the power-optimal control (solid, blue) and the efficiency-optimal control (dashed, green). Moreover, the values obtained with the harmonic control (dotted, grey) from which the optimizations were started is shown as a benchmark.  At the maximum power point, the relative power gain due to the power-optimal control is ca. 28%. The relative efficiency gain at the maximum efficiency point, which is achieved with the efficiency-optimal control, is ca. 10%.
Obviously, for a given engine speed, the power-optimal and efficiency-optimal controls each lead to maximum power and maximum efficiency, respectively. However, the optimization for one performance measure may come at the cost of the other. This can, in particular, be seen in the left-hand subfigure for the efficiency-optimal control: For medium engine speeds, the optimization for maximum efficiency leads to remarkable reductions in the output power. There, the power even drops below that obtained with the harmonic control. As opposed to that, the power-optimal control also leads to higher efficiency than the harmonic control over the complete considered range of engine speeds. Note, however, that this may be different for a different set of model parameters.
In the left-hand subfigure of Figure 4, it can be seen that the efficiency-optimal control (green, dashed) leads to a sharp bend at the maximum power point. This occurs at an engine speed of ca. 670 rpm, where the hot working volume trajectory (solid gray line in Figure 3) starts to detach from the maximum volume bound at t/τ ≈ 1.
Note that optimal controls obtained with the optimization algorithm introduced above generally constitute local optima. This becomes obvious in Figure 4 when, for example, comparing the powers resulting from the power-optimal controls at τ = 0.06 s (1000 rpm) and τ = 0.12 s (500 rpm). At τ = 0.06 s the power is close to the maximum value, whereas at τ = 0.12 s the power is much lower. However, it is clear that the power-optimal control obtained for τ = 0.06 s is an admissible periodic control for τ = 0.12 s as well, since two oscillations could be performed in one cycle. Hence, the power obtained for τ = 0.06 s (1000 rpm) constitutes a lower bound for the global optimum at τ = 0.12 s (500 rpm). It can be concluded that the optimal control found for τ = 0.12 s (500 rpm) is a local optimum and not the global one. Similar arguments are applicable for the efficiency-optimal control, for example, with the efficiency values obtained at 400 rpm and 200 rpm.

Summary
In this paper, we presented an iterative gradient method for optimizing the piston paths of Stirling engines, which is based on Cyclic Optimal Control Theory. After a brief introduction to Stirling engines, we outlined an exemplary irreversible alpha-Stirling engine model. This model served for illustrative purposes and is structured in such a way that its state dynamics can be expressed as a set of coupled ordinary differential equations. The Stirling engine's state dynamics is influenced by an explicitly time-dependent, vectorvalued control function. In particular, this control function determines the temporal paths of the engine's two working pistons.
The question of which realization of those piston paths-or correspondingly what control function-leads to optimal engine performance regarding a specific objective for a fixed cycle time, constitutes a cyclic optimal control problem. We introduced the necessary conditions of optimality for this problem, involving the definition of a Hamilton function, a path target function, and a set of adjoint ordinary differential equations (costate dynamics). For the optimization of Stirling engines, we presented proper definitions of path target functions to maximize either power or efficiency. Maximum and minimum volume constraints were accounted for here via an additional penalty term in the respective path target function.
Then, we gave a detailed description of an iterative optimization algorithm that starts with a predefined periodic control function, which is gradually shifted over the course of the iterations, so as to gradually enlarge the objective and approach the optimal control. To determine those gradual shifts of the control in every iteration, not only the engine's state dynamics needs to be solved, but also the costate dynamics. The cyclic optimal control problem features a symmetry that manifests itself in attractive and repulsive limit cycles in the state and costate dynamics, respectively. The algorithm exploits these limit cycles to solve the state and costate dynamics for periodic boundary conditions. This optimization algorithm was applied to both, power-optimize and efficiencyoptimize the control (piston paths) of the above-mentioned exemplary alpha-Stirling engine model for a range of cycle times. The optimization results were compared to piston paths that correspond to a harmonic control with 90 • phase shift, which had been used as an initial control for the optimizations. At the maximum power point, the relative power gain due to the power-optimal control is ca. 28%, whereas the relative efficiency gain due to the efficiency-optimal control at the maximum efficiency point is ca. 10%.
The developed optimization algorithm can easily be applied to other Stirling engine models that involve additional irreversibilities or transfer laws that are adapted to describe a specific experimental engine setup. Design limitations such as maximum pressure or maximum piston acceleration can be included in the optimal control problem in terms of additional constraints. Moreover, other types of machines, such as beta-type or free-piston Stirling engines, Stirling cryocoolers, or Vuilleumier refrigerators can be optimized analogously.

Conclusions
For the cyclic optimal control problems of a Stirling engine investigated here, we observed that the existence of an attractive limit cycle in the state dynamics translates to a repulsive limit cycle in the costate dynamics. We conclude that a very stable and numerically efficient way to solve such problems is through using indirect iterative gradient algorithms that exploit these limit cycles to solve the state and costate dynamics by temporal forward and backward integration, respectively.
In the case of the considered exemplary Stirling engine, the conducted piston path optimizations lead to significant performance gains of ca. 28% in maximum power and ca. 10% in maximum efficiency. This generally confirms earlier results [22][23][24] and we conclude that it can be very worthwhile to perform such optimizations during the design process of new engines or to improve the control strategy of existing ones. Numerous types of energy conversion systems operate cyclically. We expect that cyclic optimal control theory and, in particular, the developed algorithm can be applied to a wide class of these systems, in order to identify potential performance improvements and enhance their sustainability.

Conflicts of Interest:
The authors declare no conflict of interest.