j2 Developer Process Flow

When a building a developer item, there are several assemblies added to the existing code.  These include Developer Interface and Developer Description.  The Developer Description is responsible for creating and initialising the input and output variables, whereas the Developer Interface is responsible for calling the appropriate methods.

There are then two stages to using the external code.

The first stage is responsible for the creation of the Developer Item and defining the I/O data structures.

Once the item has been created/loaded so the calculation stages can take place.

Convergence Loop

Once the Developer Item is loaded the software can perform the calculation steps.  With the way models are built in j2 Universal, it is not possible to know the full sequence of dependencies between components on a model.

E.g. if we were to consider the downwash on the Horizontal Tail, this is a function of the downwash gradient and the Wing angle of attack.  The Wing angle of attack is dependent upon the Wing lift and the lift gradient of the Wing and the Wing lift is a function of the angle of attack.  If we were to write this in code, we would write the calculations such that the Wing lift is calculated first, then the Wing angle of attack and then the Horizontal Tail downwash.

Wing.CLifta=f(alpha)
Wing.AoA = Wing.CLifta/(Wing.dCLift/dAlpha)
Horizontal Tail.downwash = Horizontal Tail.de_da*Wing.AoA

However, within the j2 Universal Tool-Kit, there is no guarantee that items will be calculated in this order. Depending upon how the model is constructed, so the Horizontal Tail could be calculated first and then the Wing.

This would be like the code being written thus:

HorizontalTail.downwash = HorizontalTail.de_da*Wing.AoA
Wing.AoA = Wing.CLifta/(Wing.dCLift/dAlpha)
Wing.CLifta=f(alpha)

In this situation it may be necessary to go through the calculations several times to ensure that the values converge. The j2 Universal Tool-Kit thus has a convergence loop built in that automatically goes through the whole model calculating all the values until such time as the results have converged.

Note. A stateless system like the one above does not rely on parameters or states from the previous iteration remaining

Stateless and Stateful Systems

In a stateless system such as the example above, the convergence doesn’t cause any problems.  However, if we have a stateful system where some parameters stay resident in memory and the calculations may be dependent upon the previous values, this can cause the solutions to not converge

e.g. If the position of a Motor is dependent upon the Motor Speed the code may be:

Motor.Position=Motor.Position+Motor.Speed*dt

Every time this calculation is called as part of the convergence loop so the motor position will increase/decrease and as such the solution will not converge. Thus, we need to break this down into 2 stages.
In the convergence loop we use

Motor.Position=PreviousMotor.Position+Motor.Speed*dt

and once the solution has converged, we can set the previous value ready for the next time step.

PreviousMotor.Position=Motor.Position

For this reason, the j2 Developer interface has 3 functions that are called during calculations.

  • Pre-Convergence
    This is called before the convergence loop starts. It can be used to set any convergence counters or reset values that need to be performed before the calculations start. This is called during trimming (static) and responses/re-prediction (dynamic) analysis.
  • Calculate
    This is called as part of the convergence loop. Until the inputs and outputs have settled, the Calculate method is called. Each time it is called it passes the current inputs (these may change as part of the convergence process but should settle when all inputs have been calculated) and the outputs from the calculation are returned. If the outputs are different from the previous call, within a convergence loop, so the results are classed to have not converged and the calculation process will be gone through again.
  • Post Dynamic Update Calculation
    This performs any functions that are required once per time step and are to be performed after the main Calculation has converged. This can be used to set any “previous” values to the current value. This is only called during responses/re-prediction (dynamic) analysis.