## Auto-pilot definition

@AUTO_PILOT_DEFINITION {
@AUTO_PILOT_NAME {AutoPltName} {
@CONTROLLER_NAME {ContrlrName}
@NUMBER_OF_STATES {Ni}
@TARGET_VALUES {y1*, y2*, ..., yNi*}
@GAIN_MATRIX {g1, g2, ..., gNi}
@PHASES_TIME_SPANS {Tref, Tper, Tsim}
@PERTURBATION_MAGNITUDE {Δ1, Δ2, ΔNi}
@TIME_CONSTANT {T}
@INVERSE_TRIM_MATRIX {J-1}
@MAXIMUM_RATE {Rmax}
@MINIMUM_ERROR {emin}
}
}

### Introduction

The quasi-steady trimmer is a control law designed to determine the outputs, u, that will drive the system to a configuration where the input match the specified target values y*T = {y1*, y2*, ..., yNi*}. The auto-pilot modifies the controls proportionally to the output error so as to drive the inputs to their target values. The following discrete equations are introduced to compute the control outputs at each time step uf = ui + Δt J-1 G (y* - yf), where the subscripts (.)i and (.)f denote quantities computed at the initial and final times of the time step, respectively, denoted ti and tf, respectively; Δt = tf - ti is the time step size, yf the present input value, J the Jacobian matrix and G the gain matrix. The gain matrix is assumed to be a diagonal matrix, G = diag(gα).

The Jacobian matrix is defined as a derivative of the inputs with respect to the outputs J = ∂y/∂u. This matrix is, in general, unknown, and hence, it is evaluated numerically using a finite difference process

1. First, a reference configuration is established by simulating the response of the system for period Tref with the outputs set to reference constant values u. At the end of the reference run, the input values are denoted y.
2. Next, a perturbed configuration is established for the first state by simulating the system for time Tper with the first output set to a value u1 = u1 ref + Δ1, where Δ1 is the perturbation magnitude. All other outputs are kept to their reference value. At the end of the first perturbation run, the input values are denoted y1.
3. Next, the procedure is repeated for each state of the system, to determine the sensor measurements yi, i = 2, 3, ..., Ni, corresponding to perturbations of the other outputs with magnitudes Δi.

At the end of this identification process, an approximation to the Jacobian matrix is obtained as follows J = [ (y1 - y)/Δ1, (y2 - y)/Δ2, ..., (yNi - y)/ΔNi ]. Once the Jacobian matrix has been identified, the autopilot switches to simulation mode for period Tsim. At each time step, the control law is applied to drive the input values to their targets.

### Notes

1. The auto-pilot is an embedded control law associated with the controller ContrlrName. The auto-pilot control law features a number of states, Ni, that must equal the number of inputs, Ni, and outputs, No, i.e., Ni = No = Ni.
2. A set of Ni target values, y1*, y2*, ..., yNi* and Ni gains, g1, g2, ..., gNi, must be defined.
3. The time span for each of the three phases of operation of the auto-pilot are defined as follows.
1. The system is simulated for period Tref to establish the reference configuration of the system for the reference output values u. At the end of the reference run, the input values are denoted y. It is important to simulate the response of the system for a period that is long enough to allow the dynamics of the system to settle, i.e., for y to settle to steady values.
2. For each of the Ni states of the system, the system will be simulated for period Tper to establish the response of the system due to perturbed outputs, ui = ui + Δi, i = 1, 2, ... Ni, where Δi are the perturbation magnitudes. To avoid applying the perturbations in a single time step, the following schedule is used to perturb the auto-pilot outputs: ui(t') = ui + Δi [ 1 - cos (π t'/T ) ]/2, if t' < T, and ui(t') = ui + Δi, if t' ≥ T, where t' is the time measured from the beginning of the perturbation phase, and T the time constant. Here again, it is important to simulate the system for a period that is long enough to allow the response to stabilize after the application of each perturbation. The following must hold: T < Tper.
3. Finally, the system is simulated for period Tsim in the simulation phase. At each time step, the control law is applied to drive the input values to their targets.
4. Application of the auto-pilot approach to periodic problems can be troublesome. The control law adjusts the control variables at every time step to track the target values. This leads to periodic excitation of the controlled variables, and, in turn, periodic excitation of the input values. To overcome this problem, the auto-pilot equation should be driven driven by averages of the input values over one period of the system. This is readily achieved by using the data conditioning feature of signals: all sensors measurements will then be running averages over the last period rather than instantaneous measurements.
5. If the trim matrix has already been identified in a previous run, it is effective to read this matrix, bypassing the need to construct it with the help of the procedure described above. At the end of the identification process, the inverse trim matrix is printed in the output file, to be used in a subsequent run. If the inverse trim matrix is read, the auto pilot will immediately start with the simulation phase for a period Tsim using the control law. Upon completion, the Jacobian matrix identification process will start again. The inverse trim matrix should be read column by column.
6. The behavior and convergence characteristics of the auto-pilot are strongly affected by the gain matrix G = diag(gi); the individual gains, gi, should be adjusted to obtain the best convergence characteristics. High gain values may render the closed-loop system unstable. Even moderate gain values can lead to instabilities because the auto-pilot does not account for system dynamics. To overcome this problem, if the minimum error parameters emin is defined, an adaptive gain selection strategy is introduced: when the difference between the input and its target value becomes small, the gain is gradually decreased to zero using the following schedule gs = tanh (4e/ emin), where e = || y - y ||/ || y ||, the relative difference between the actual and target input values. The gain matrix then becomes G = gs diag(gi).
7. The auto-pilot algorithm ignores system dynamics from both structural dynamics and aerodynamic standpoints. To avoid spurious dynamics and unsteady aerodynamic effects, it is sometimes necessary to limit the rate of change of the control variables. Hence, if Rmax is defined, the following condition is imposed || uf - ui || ≤ Δt Rmax.
8. It is possible to attach comments to the definition of the object; these comments have no effect on its definition.