REALP2 Real Pole (First Order Lag) Function

Description

The structure of Real Pole or 1st Order Lag function REALP2 is as shown below:

 

 

Structure of the REALP2 Function

 

It is possible to model this function directly by using the integral function INTGL3 as follows:

 

 

Where,

 

Output function

Output function (previous time step)

e(t) at previous time step

Gain

Input function

Input function (previous time step)

Time step interval

 

As is clearly stated above, the input e(t) is derived from the current value of the input function x(t) and the output of the integrator from the previous time step y(t – Dt).  There is a disadvantage in using this method to evaluate a real pole function, as the input e(t) is derived using the historic y(t – Dt).   In EMTDC, the real pole REALP2 function is coded as follows in order to improve the solution:

 

 

Substituting into the expression given above:

 

 

Collecting like terms leads to:

 

 

REALP2 uses the above equation only if the time constant T > Dt/2.  For very small time constants where T < Dt/2, an exact solution is used instead:

 

NOTE:  For any time constant smaller than 1.0E–20 seconds, the input is directly passed to the output (T = 0.0 is valid).

 

 

Block Diagram of the REALP2 Function

 

At time t = 0.0, the output and the internal storage of this function is automatically initialized to its input value.

 

As seen below in the Argument Descriptions for the REALP2 function, there are no limits on the output.  If non-sticking limits are required then there are several possibilities:  The first is to write a new real pole function with limits added, or secondly, if a single time step delay in feedback can be tolerated, the function can be constructed using INTGL3.   A third way is to add statements following the REALP2 function call statement, which apply limits by addressing the appropriate location in the STOR array and limiting it accordingly.   This limiting is performed already in the Master Library component Real Pole and is shown below (as it appears in the component DSDYN section) for convenience:

 

 

#STORAGE STOR:2

#FUNCTION REAL REALP2 Real Pole

!  $COM

      $O = REALP2( $G , $T, $I)

#IF LIMIT

      IF ($O .GT. $Max) THEN

         $O = $Max

         STOR(NEXC-1) = 0.0

         STOR(NEXC)   = $O

      ELSE IF ($O .LT. $Min) THEN

         $O = $Min

         STOR(NEXC-1) = 0.0

         STOR(NEXC)   = $O

      ENDIF

#ENDIF

!

 

NOTE:  The above PSCAD Script statements will keep the output $O approximately within the limits of $Min and $Max.  The REALP2 function uses two storage locations, the first being the e(t - Dt) value, and the second the value y(t – Dt).  Since the STOR array is updated within the REALP2 function code by the statement NEXC = NEXC + 2, then y(t – Dt) can be reset following a function call by addressing the STOR(NEXC) storage location (as shown above).  The e(t - Dt) value is addressed one storage location back by STOR(NEXC-1), and is reset to 0.0.

 

Author(s):

 

 

 

Argument Descriptions

 

      REAL FUNCTION REALP2(G,T,X)

 

 

Argument

Type

Dimension

Description

 

 

 

 

G

REAL

1

Gain factor

T

REAL

1

Time constant [s]

X

REAL

1

Input signal

 

Storage

This function requires the following storage allocations per call (see #STORAGE Script Directive and STORx Arrays for more details):

 

#STORAGE STOR:2

 

Address

Description

 

 

NEXC + 1

NEXC + 2