CFPRIME DFLTER                                                          DFLTER      1
C***********************************************************************RIGHTE      1
C*                                                                     *RIGHTE      2
C*        Extended Transient-Midterm Stability Program (ETMSP)         *RIGHTE      3
C*        ====================================================         *RIGHTE      4
C*                                                                     *RIGHTE      5
C*       Copyright (C) (1993) Electric Power Research Institute        *RIGHTE      6
C*                                                                     *RIGHTE      7
C* EPRI reserves all rights in the software and associated             *RIGHTE      8
C* documentation as delivered. The software and its associated         *RIGHTE      9
C* documention or any portion thereof may not be reproduced in any form*RIGHTE     10
C* whatsoever without the consent of EPRI, except as explicity provided*RIGHTE     11
C* for by license. Licensee shall submit a detailed description to EPRI*RIGHTE     12
C* of any changes or modifications to the software within two (2)      *RIGHTE     13
C* months after such changes or modifications are made. At EPRI's sole *RIGHTE     14
C* discretion, the software, as changed or modified, shall be given a  *RIGHTE     15
C* new designation sufficiently different from its then current        *RIGHTE     16
C* designation as to prevent mistake,confusion, or deception as between*RIGHTE     17
C* the current software as changed or modified.                        *RIGHTE     18
C*                                                                     *RIGHTE     19
C* A license under EPRI's rights in the software can be obtained       *RIGHTE     20
C* directly from EPRI.                                                 *RIGHTE     21
C*                                                                     *RIGHTE     22
C* This program and supporting materials may be independently available*RIGHTE     23
C* from Electric Power Software centre (EPSC) for an appropriate       *RIGHTE     24
C* distribution fee. The EPSC is a service of                          *RIGHTE     25
C*                                                                     *RIGHTE     26
C*                    Power Computing Company                          *RIGHTE     27
C*                    1930 Hi Line                                     *RIGHTE     28
C*                    Dallas, Tx 75207                                 *RIGHTE     29
C*                                                                     *RIGHTE     30
C* NEITHER EPRI, ANY MEMBER OF EPRI, NOR ANY PERSON OR  ORGANIZATION   *RIGHTE     31
C* ACTING ON BEHAVE OF THEM:                                           *RIGHTE     32
C*                                                                     *RIGHTE     33
C* 1. MAKE ANY WARRANTY OR REPRESENTATION WHATSOEVER, EXPRESS OR       *RIGHTE     34
C*    IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR FITNESS OR *RIGHTE     35
C*    ANY PURPOSE WITH RESPECT TO THE SOFTWARE OR ITS ASSOCIATED       *RIGHTE     36
C*    DOCUMENTATION; OR                                                *RIGHTE     37
C*                                                                     *RIGHTE     38
C* 2. ASSUMES ANY LIABILITY WHATSOEVER WITH RESPECT TO ANY USE OF THE  *RIGHTE     39
C*    SOFTWARE OR ITS ASSOCIATED DOCUMENTATION OR ANY PORTION THEREOF  *RIGHTE     40
C*    OR WITH RESPECT TO ANY DAMAGES WHICH MAY RESULT FROM SUCH USE.   *RIGHTE     41
C*                                                                     *RIGHTE     42
C* THIS NOTICE MAY NOT BE REMOVED FROM THE SOFTWARE BY ANY USER        *RIGHTE     43
C* THEREOF.                                                            *RIGHTE     44
C*                                                                     *RIGHTE     45
C***********************************************************************RIGHTE     46
      SUBROUTINE DFLTER(NXS)                                            DFLTER      3
CD                                                                      DFLTER      4
CD    TO CALCULATE THE DERIVATIVES OF THE STATES OF STABILIZER TORSIONALDFLTER      5
CD    FILTER, USED BY BOTH RUNGE-KUTTA AND TRAPEZOIDAL METHOD.          DFLTER      6
CD                                                                      DFLTER      7
CD   5.1 Stabilizer torsional filter type 1                             DFLTER      8
CD                                                                      DFLTER      9
CD     Torsional filter data                                            DFLTER     10
CD                                                                      DFLTER     11
CD     DDAT(JF+ 1)    = T6                                              DFLTER     12
CD     DDAT(JF+ 2)    = A5                                              DFLTER     13
CD     DDAT(JF+ 3)    = A3                                              DFLTER     14
CD     DDAT(JF+ 4)    = A6                                              DFLTER     15
CD     DDAT(JF+ 5)    = A4                                              DFLTER     16
CD     DDAT(JF+ 6)    = A1                                              DFLTER     17
CD     DDAT(JF+ 7)    = A2                                              DFLTER     18
CD     DDAT(JF+ 8)    = A0                                              DFLTER     19
CD                                                                      DFLTER     20
CD     Torsional filter states                                          DFLTER     21
CD                                                                      DFLTER     22
CD     XSTATE(JSSL+1) = T6 block                    : optional          DFLTER     23
CD     XSTATE(JSSL+2) = first state in A3/A4 block  : optional          DFLTER     24
CD     XSTATE(JSSL+3) = second state in A3/A4 block : optional          DFLTER     25
CD     XSTATE(JSSL+4) = first state in A1/A2 block  : optional          DFLTER     26
CD     XSTATE(JSSL+5) = second state in A1/A2 block : optional          DFLTER     27
CD                                                                      DFLTER     28
CD     Where JSSL is the last state of the associated stabilizer        DFLTER     29
CD                                                                      DFLTER     30
CD     Torsional filter Y-variables                                     DFLTER     31
CD                                                                      DFLTER     32
CD     There are no Y-variables for stabilizer torsional filter         DFLTER     33
CD                                                                      DFLTER     34
      INCLUDE 'PARX.INS'                                                DFLTER     35
      INCLUDE 'CNMDAT.INS'                                              DFLTER     36
      INCLUDE 'CNEXC.INS'                                               DFLTER     37
      INCLUDE 'CNB8.INS'                                                DFLTER     38
      INCLUDE 'CNXSTA.INS'                                              DFLTER     39
      INCLUDE 'CNYVAR.INS'                                              DFLTER     40
C                                                                       DFLTER     41
      NXS=0                                                             DFLTER     42
      JF=JCONTA(5,N)                                                    DFLTER     43
      VSX=VSS(JYS+1)                                                    DFLTER     44
C                                                                       DFLTER     45
      IF (IDDAT(JF+1).NE.0) THEN                                        DFLTER     46
         NXS=NXS+1                                                      DFLTER     47
         DSTATE(LSTATE+NXS)=(VSX-XSTATE(JSTATE+NXS))/DDAT(JF+1)         DFLTER     48
         VSX=XSTATE(JSTATE+NXS)                                         DFLTER     49
      END IF                                                            DFLTER     50
C                                                                       DFLTER     51
      IF (IDDAT(JF+3).EQ.0.AND.IDDAT(JF+5).EQ.0) GOTO 100               DFLTER     52
      IF (IDDAT(JF+5).NE.0) THEN                                        DFLTER     53
         NF1=NXS+1                                                      DFLTER     54
         NXS=NXS+2                                                      DFLTER     55
         DSTATE(LSTATE+NF1)=XSTATE(JSTATE+NXS)                          DFLTER     56
         DSTATE(LSTATE+NXS)=VSX-(DDAT(JF+3)*XSTATE(JSTATE+NXS)+         DFLTER     57
     +    XSTATE(JSTATE+NF1))/DDAT(JF+5)                                DFLTER     58
         TFR=DDAT(JF+4)/DDAT(JF+5)                                      DFLTER     59
         XF1=(XSTATE(JSTATE+NF1)*(1.-TFR)+XSTATE(JSTATE+NXS)*           DFLTER     60
     +   (DDAT(JF+2)-DDAT(JF+3)*TFR))/DDAT(JF+5)                        DFLTER     61
         VSX=XF1+(VSX*TFR)                                              DFLTER     62
      ELSE                                                              DFLTER     63
         NXS=NXS+1                                                      DFLTER     64
         DSTATE(LSTATE+NXS)=(VSX-XSTATE(JSTATE+NXS))/DDAT(JF+3)         DFLTER     65
         VSX=XSTATE(JSTATE+NXS)+DSTATE(LSTATE+NXS)*DDAT(JF+2)           DFLTER     66
      END IF                                                            DFLTER     67
  100 CONTINUE                                                          DFLTER     68
C                                                                       DFLTER     69
      IF (IDDAT(JF+6).EQ.0.AND.IDDAT(JF+7).EQ.0) GOTO 200               DFLTER     70
      IF (IDDAT(JF+7).NE.0) THEN                                        DFLTER     71
         NF3=NXS+1                                                      DFLTER     72
         NXS=NXS+2                                                      DFLTER     73
         DSTATE(LSTATE+NF3)=XSTATE(JSTATE+NXS)                          DFLTER     74
         DSTATE(LSTATE+NXS)=VSX-(DDAT(JF+6)*XSTATE(JSTATE+NXS)+         DFLTER     75
     +    XSTATE(JSTATE+NF3))/DDAT(JF+7)                                DFLTER     76
         TFR=DDAT(JF+8)/DDAT(JF+7)                                      DFLTER     77
         XF3=(XSTATE(JSTATE+NF3)*(1.-TFR)+XSTATE(JSTATE+NXS)*           DFLTER     78
     +   (DDAT(JF+11)-DDAT(JF+6)*TFR))/DDAT(JF+7)                       DFLTER     79
         VSX=XF3+(VSX*TFR)                                              DFLTER     80
C                                                                       DFLTER     81
      ELSE                                                              DFLTER     82
         NXS=NXS+1                                                      DFLTER     83
         DSTATE(LSTATE+NXS)=(VSX-XSTATE(JSTATE+NXS))/DDAT(JF+6)         DFLTER     84
         VSX=XSTATE(JSTATE+NXS)+DSTATE(LSTATE+NXS)*DDAT(JF+11)          DFLTER     85
      END IF                                                            DFLTER     86
  200 CONTINUE                                                          DFLTER     87
C                                                                       DFLTER     88
      IF (VSX.GT.DDAT(JF+9)) VSX=DDAT(JF+9)                             DFLTER     89
      IF (VSX.LT.DDAT(JF+10)) VSX=DDAT(JF+10)                           DFLTER     90
      VSS(JYS+1)=VSX                                                    DFLTER     91
C                                                                       DFLTER     92
      LSTATE=LSTATE+NXS                                                 DFLTER     93
C                                                                       DFLTER     94
      RETURN                                                            DFLTER     95
      END                                                               DFLTER     96
