feedbackDesired

feedbackDesired

feedbackDesired: Works with VSimPD and VSimMD licenses.

FeedbackDesired history objects are used to adjust parameters (currents and fields for example) based on measured time dependent quantities. An example would be automatically adjusting the current in a simulation to generate a desired voltage. The feedback desired is calculated based on the computation of the measured voltage compared to the desired voltage or any measured quantity verses a desired quantity. This factor is then used to adjust the current (or other value that can be defined in a STFunc block) so that the measured voltage approaches the desired voltage.

The update equation for the feedback factor (calculated in feedback) is given by:

\(F[n+1] = F[N] + (2*dt/{\tau})*max(-1,min(1,\frac{D[n]-M[n]}{|D[n]|+|M[n]|})) * \frac{\alpha*F[N] + \beta*(|Dn|+|Mn|)} { \gamma*F[N] + \delta}\)

where:

  • \(F[n+1]\): feedback factor at time level n+1
  • \(dt\): the simulation time step
  • \({\tau}\): relaxation time constant (timeConstant)
  • \(D[n]\): desired value at time level n
  • \(M[n]\): measured value at time level n
  • \(\alpha\): Exponential coefficient in feedback calculation (alpha)
  • \(\beta\): A constant determines linear feedback for small feedback (beta)
  • \(\gamma\): A constant determines linear feedback for large feedback (gamma)
  • \(\delta\): A constant determines minimum denominator for small feedback (delta)

Using the default values for \(\alpha\) =1.0, \(\beta\) =0.0, \(\gamma\) =0.0, \(\delta\) =1.0 gives:

\(F[n+1]= F[N]*(1.0+2.0*dt/{\tau}*max(-1,min(1,\frac{D[n]-M[n]}{|D[n]|+|M[n]|})))\)

An STFunc of kind feedbackSTFunc must be defined to make use of a feedbackDesired history. The sumRhoJ source contains STFunc blocks defining the current source and we would like this current to depend on a feedback parameter.

Note

Details of feedbackSTFunc and its parameters can be found in feedbackSTFunc.

Required feedbackDesired Parameters

scalar

A scalar which defines the measured value \(M[n]\). Previously, only a history could be used to define the measured value, through feedbackHist.

feedbackHist

Points to another history, in this case a history called potential. Scalars should be used, to be removed in version 10.

timeConstant

Defines how quickly the feedback responds to differences in measured and desired values. If timeConstant is too small the solution may oscillate about the correct answer quite a bit (or even diverge). If the value is too large it may take a long time for the feedback factor to reach the desired value. Experimenting with the timeConstant as in the example feedback code is a simple way to learn to understand this.

numberOfStepsForErrorAverage (integer, optional)

Number of time steps to use in moving average. This is used when the feedbackHist is oscillating.

desiredHistory (STFunc block)

Defines the desired value of the feedbackHist (i.e. the desired value of the potential in the example case).

alpha (optional, default = 1.0)

Exponential coefficient in feedback calculation. \(\alpha\) in the above equation.

beta (optional, default = 0.0)

A constant determines linear feedback for small feedback. \(\beta\) in the above equation.

gamma (optional, default = 0.0)

A constant determines linear feedback for large feedback. \(\gamma\) in the above equation.

delta (optional, default = 1.0)

A constant determines minimum denominator for small feedback. \(\delta\) in the above equation.

feedbackDesired History Example

<History feedbackDesiredHistory>
  kind=feedbackDesired
  feedbackHist=potential
  timeConstant=$75.0*DT$
  <STFunc desiredHistory>
    kind=expression
    expression = 1.0e5
  </STFunc>
</History>

Finally, a history must be defined which computes the measured value and which is compared to the desired value in the feedback equation. In the example below, a pseudo potential is used that defines the potential by integration of the electric field along a line.

<History potential>
  kind = pseudoPotential
  field = varEmField.ElecMultiField
  referencePoint = [$NX/2$ 0 $NZ/2$]
  measurePoint  = [$NX/2$ NY $NZ/2$]
</History>

Note

SumRhoJ sources are actually STFunc blocks, so the feedbackSTFunc can be used to adjust currents in simulations. Finally, restarts using feedback history require history data to be dumped at every time step.