The Method of Characteristics - MOC
To get the full understanding, MOC should be explained in more detail. That's
for a later post. For the time being I just refer to Wylie and Streeter and
Wikipedia:
In mathematics, the method of characteristics is a technique for solving particular partial differential equations. Typically, it applies to first-order equations, though in general characteristic curves can also be found for hyperbolic and parabolic partial differential equation. The method is to reduce a partial differential equation (PDE) to a family of ordinary differential equations (ODEs) along which the solution can be integrated from some initial data given on a suitable hypersurface.
Explained below is the basic system algorithm for MOC in a system,
not MOC itself. It's how it is programmed in LVTrans, and how it will be
programmed in any eventual future versions.
System of hydraulic pipes
Each hydraulic pipe is modelled with MOC. A Pipe has a length and two
ends. Each of these ends must be connected to a "non pipe" element, called
NP. This NP element is typically a valve, a T-joint, a turbine, a
reservoir but can also simply be an open or closed end of the Pipe. Thus
for each Pipe, the NP represent the spatial boundary elements at each
end.
Each NP can have one or more boundaries. These boundaries are typically Pipes, but can also be other NP elements. An example is a PID for a turbine. Many of these NP elements also have natural boundaries. For instance, a reservoir can be connected to one or several pipes but also have a surface level that is relatively constant seen in relation to waterhammer transients. This surface level is a natural boundary condition. The surface level can also vary, and can be measured and given as input for a digital twin.
The figure above shows a simple system of Pipes and NPs. Each Pipe has an
arrow towards the NP elements. Why becomes apparent soon.
Basic element algorithm
Each pipe is divided into smaller sections. For each time step, the
H and Q
(head and flow) for each section is calculated based on the values for the
previous time step. The boundaries are yet unknown, but the
C+ and C- characteristics
can be calculated. This is how far each Pipe can be calculated alone. All the
internal values and the C+ and C+ characteristics at the boundaries.
What is missing is the H and Q at each end.
Each NP element do almost the same. They start with the values from previous
time step and the C+ and C- characteristics from the connecting pipes
that just were calculated. All the inner variables and the H and Q at the
boundaries can be fully resolved. These H and Q are then sent back to each
pipe and make their calculations complete. Now the time step is fully resolved
everywhere. The procedure is repeated for the next time step and so on.
Note that NP elements normally use
Runge-Kutta
or
Newton-Raphson methods.
NP elements also can have manual inputs. For instance the opening of a valve.
This is also updated for each time step.
MOC System algorithm
From the figure the full arrows are the C+ and C- characteristics at each end
of the pipe. The back propagation of H and Q at the boundaries are the dotted
lines. The PID does not send H, Q or C, but rather sends A and receives B,
where A and B typically but not necessarily, are guide vane opening
and turbine speed.
The MOC system algorithm therefore becomes:
- For all Pipes and (PID).
- Calculate the internal variables; H Q and predict the A in (PID) for T1 based on T0
- Send C+, C- and A to each connected NP element
- For all NP elements
- Calculate all internal variables and the boundary values for T1 based on T0 and values received from Pipe and (PID)
- Iterate each NP-PID pair once more to correct the predicted A if needed*.
- Send H, Q and B to each Pipe and (PID)
- Update the boundary H and Q for each pipe and B for the (PID)
- Start at 1 again for the next time step.
Programmatically there are many ways to to this depending on choice and the
programming language. In "native" LVTrans these connections happens almost
by itself. It's the way
LabVIEW
works by default. In a text based programming language this can be done by
lists or arrays of Pipes and NPs. A major point is that the inner workings
and transfer of values of each element is the same no matter how this is
done. An independent library of MOC can thus be made. Here independent means
independent from the actual implementation of the MOC system
algorithm.
*Note that the (PID) is not a Pipe with MOC inside. It does not have
analytically correct C+ and C- characteristics for T1. The initial A it
sends is a forward in time predicted value at T1 based on the
time step T0 for all variables in (PID) including B. The B which is sent
back from NP, is based on this predicted value of A. This B is used to
update all variables inside (PID) and can be used to correct the predicted
value of A at T1. This corrected value can be sent once more for a new
iteration in the connected NP. Default is a predictor method. One extra
iteration becomes a predictor-corrector method. An error analysis of this is
found in the LVTrans manual, and is a part of choosing the correct time
step.
In Wylie and Streeter the procedure is to gather all connected NP elements
together and iterate them as one single block with regard to connected Pipe
elements. In practice this is equivalent to an NP-NP pair iteration. It's a
matter of choice, but the method of Wylie and Streeter may be more practical
for blocks of NPs with more than two NPs. Such blocks never happens in
LVTrans. With the exception of PID elements, it's probably more practical to
create separate elements where larger collections of NP blocks are are
pre-made.
Conclusion
The MOC system algorithm is very simple. MOC is also superfast. Orders of
magnitude faster than anything else while being analytically correct and with
no numerical artifacts. With an
object oriented approach
for each elements, the same core library can be used in several different
applications. This is very useful when different use cases are needed.


No comments:
Post a Comment