CFPRIME DSTA10                                                          DSTA10      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 DSTA10(NXS)                                            DSTA10      3
CD                                                                      DSTA10      4
CD    TO CALCULATE THE DERIVATIVES OF THE STATES OF TYPES 10 AND 11     DSTA10      5
CD    STABILIZER, USED BY BOTH RUNGE-KUTTA AND TRAPEZOIDAL METHOD.      DSTA10      6
CD                                                                      DSTA10      7
CD    THE DATA STRUCTURES OF THESE TYPES OF STABILIZERS ARE GIVEN BELOW.DSTA10      8
CD                                                                      DSTA10      9
CD   4.9 Stabilizer type 10                                             DSTA10     10
CD                                                                      DSTA10     11
CD     Stabilizer data                                                  DSTA10     12
CD                                                                      DSTA10     13
CD     IDDAT(JS+ 1)   = BUSR         : sensing bus number               DSTA10     14
CD     IDDAT(JS +2)   = TYPE         : type of input signal:            DSTA10     15
CD                                     = 1 rotor speed                  DSTA10     16
CD                                     = 2 acceleration power           DSTA10     17
CD                                     = 3 bus frequency                DSTA10     18
CD                                     = 4 electrical power             DSTA10     19
CD                                     = 5 bus voltage magnitude        DSTA10     20
CD                                     = 6 voltage deviation from steadyDSTA10     21
CD                                        state value                   DSTA10     22
CD     DDAT(JS+ 3)    = KQS                                             DSTA10     23
CD     DDAT(JS+ 4)    = TQS                                             DSTA10     24
CD     DDAT(JS+ 5)    = KQV                                             DSTA10     25
CD     DDAT(JS+ 6)    = TQV                                             DSTA10     26
CD     DDAT(JS+ 7)    = TQ                                              DSTA10     27
CD     DDAT(JS+ 8)    = T'Q1                                            DSTA10     28
CD     DDAT(JS+ 9)    = TQ1                                             DSTA10     29
CD     DDAT(JS+10)    = T'Q2                                            DSTA10     30
CD     DDAT(JS+11)    = TQ2                                             DSTA10     31
CD     DDAT(JS+12)    = T'Q3                                            DSTA10     32
CD     DDAT(JS+13)    = TQ3                                             DSTA10     33
CD     DDAT(JS+14)    = VSMAX                                           DSTA10     34
CD     DDAT(JS+15)    = VSMIN                                           DSTA10     35
CD     DDAT(JS+16)    = VC                                              DSTA10     36
CD     DDAT(JS+17)    = TF                                              DSTA10     37
CD     DDAT(JS+18)    = RC                                              DSTA10     38
CD     DDAT(JS+19)    = XC                                              DSTA10     39
CD     DDAT(JS+20)    = PTHR                                            DSTA10     40
CD                                                                      DSTA10     41
CD     Stabilizer states                                                DSTA10     42
CD                                                                      DSTA10     43
CD     XSTATE(JSS+1)  = TF block if input is bus frequency              DSTA10     44
CD                                                  : optional          DSTA10     45
CD     XSTATE(JSS+2)  = TQS block                   : optional          DSTA10     46
CD     XSTATE(JSS+3)  = TQV block                   : optional          DSTA10     47
CD     XSTATE(JSS+4)  = TQ block                    : compulsory        DSTA10     48
CD     XSTATE(JSS+5)  = TQ1 block                   : optional          DSTA10     49
CD     XSTATE(JSS+6)  = TQ2 block                   : optional          DSTA10     50
CD     XSTATE(JSS+7)  = TQ3 block                   : optional          DSTA10     51
CD                                                                      DSTA10     52
CD     Stabilizer Y-variables                                           DSTA10     53
CD                                                                      DSTA10     54
CD     VSS(JYS+1)     = stabilizer output                               DSTA10     55
CD     VTOS(JYS+2)    = V0 (magnitude of initial bus voltage)           DSTA10     56
CD                                                                      DSTA10     57
CD   4.10 Stabilizer type 11                                            DSTA10     58
CD                                                                      DSTA10     59
CD     Stabilizer data                                                  DSTA10     60
CD                                                                      DSTA10     61
CD     IDDAT(JS+ 1)   = BUSR         : sensing bus number               DSTA10     62
CD     IDDAT(JS+ 2)   = TYPE         : type of input signal:            DSTA10     63
CD                                     = 1 rotor speed                  DSTA10     64
CD                                     = 2 acceleration power           DSTA10     65
CD                                     = 3 bus frequency                DSTA10     66
CD                                     = 4 electrical power             DSTA10     67
CD                                     = 5 bus voltage magnitude        DSTA10     68
CD                                     = 6 voltage deviation from steadyDSTA10     69
CD                                        state value                   DSTA10     70
CD     DDAT(JS+ 3)    = KQS                                             DSTA10     71
CD     DDAT(JS+ 4)    = TQS                                             DSTA10     72
CD     DDAT(JS+ 5)    = KQV                                             DSTA10     73
CD     DDAT(JS+ 6)    = TQV                                             DSTA10     74
CD     DDAT(JS+ 7)    = TQ                                              DSTA10     75
CD     DDAT(JS+ 8)    = T'Q1                                            DSTA10     76
CD     DDAT(JS+ 9)    = TQ1                                             DSTA10     77
CD     DDAT(JS+10)    = T'Q2                                            DSTA10     78
CD     DDAT(JS+11)    = TQ2                                             DSTA10     79
CD     DDAT(JS+12)    = T'Q3                                            DSTA10     80
CD     DDAT(JS+13)    = TQ3                                             DSTA10     81
CD     DDAT(JS+14)    = VSMAX                                           DSTA10     82
CD     DDAT(JS+15)    = VSMIN                                           DSTA10     83
CD     DDAT(JS+16)    = VC                                              DSTA10     84
CD     DDAT(JS+17)    = K'QS                                            DSTA10     85
CD     DDAT(JS+18)    = K                                               DSTA10     86
CD     DDAT(JS+19)    = T1                                              DSTA10     87
CD     DDAT(JS+20)    = T2                                              DSTA10     88
CD     DDAT(JS+21)    = T3                                              DSTA10     89
CD     DDAT(JS+22)    = T4                                              DSTA10     90
CD     DDAT(JS+23)    = DW1                                             DSTA10     91
CD     DDAT(JS+24)    = DW2                                             DSTA10     92
CD     DDAT(JS+25)    = WDOT                                            DSTA10     93
CD     DDAT(JS+26)    = TF                                              DSTA10     94
CD     DDAT(JS+27)    = RC                                              DSTA10     95
CD     DDAT(JS+28)    = XC                                              DSTA10     96
CD     DDAT(JS+29)    = TDELAY                                          DSTA10     97
CD     DDAT(JS+30)    = PTHR                                            DSTA10     98
CD     DDAT(JS+31)    = for internal use, refer to block diagram and    DSTA10     99
CD                      phase-plane diagram for meaning                 DSTA10    100
CD     DDAT(JS+32)    = for internal use                                DSTA10    101
CD                      status of switch S1 = 0 opened                  DSTA10    102
CD                                        = 1 closed                    DSTA10    103
CD     DDAT(JS+33)    = for internal use                                DSTA10    104
CD                      time counter : for signal U continuously greaterDSTA10    105
CD                                   than or equal to zero              DSTA10    106
CD                                                                      DSTA10    107
CD     Stabilizer states                                                DSTA10    108
CD                                                                      DSTA10    109
CD     XSTATE(JSS+1)  = TF block if input is bus frequency              DSTA10    110
CD                                                  : optional          DSTA10    111
CD     XSTATE(JSS+2)  = TQS block                   : optional          DSTA10    112
CD     XSTATE(JSS+3)  = TQV block                   : optional          DSTA10    113
CD     XSTATE(JSS+4)  = T1 block                    : optional          DSTA10    114
CD     XSTATE(JSS+5)  = T2 block                    : optional          DSTA10    115
CD     XSTATE(JSS+6)  = T3 block                    : optional          DSTA10    116
CD     XSTATE(JSS+7)  = T4 block                    : optional          DSTA10    117
CD     XSTATE(JSS+8)  = TQ block                    : compulsory        DSTA10    118
CD     XSTATE(JSS+9)  = TQ1 block                   : optional          DSTA10    119
CD     XSTATE(JSS+10) = TQ2 block                   : optional          DSTA10    120
CD     XSTATE(JSS+11) = TQ3 block                   : optional          DSTA10    121
CD                                                                      DSTA10    122
CD     Stabilizer Y-variables                                           DSTA10    123
CD                                                                      DSTA10    124
CD     VSS(JYS+1)     = stabilizer output                               DSTA10    125
CD                                                                      DSTA10    126
      INCLUDE 'PARX.INS'                                                DSTA10    127
      INCLUDE 'CNMDAT.INS'                                              DSTA10    128
      INCLUDE 'CNEXC.INS'                                               DSTA10    129
      INCLUDE 'CNXSTA.INS'                                              DSTA10    130
      INCLUDE 'CNYVAR.INS'                                              DSTA10    131
      INCLUDE 'CNFLAG.INS'                                              DSTA10    132
      INCLUDE 'CNPARX.INS'                                              DSTA10    133
      INCLUDE 'CNUNIT.INS'                                              DSTA10    134
      INCLUDE 'CNB9.INS'                                                DSTA10    135
C                                                                       DSTA10    136
*IF DEBUG                                                               DSTA10    137
         LDEB=(JDEB(51).NE.0)                                           DSTA10    138
*ENDIF                                                                  DSTA10    139
C                                                                       DSTA10    140
      NXS=KSTATE                                                        DSTA10    141
C                                                                       DSTA10    142
C   TYPE 10 STABILIZER (EPRI MODEL)                                     DSTA10    143
C                                                                       DSTA10    144
        IF (ISTABN.EQ.10) THEN                                          DSTA10    145
*IF DEBUG                                                               DSTA10    146
           IF(LDEB)WRITE(IUD6,1220)N,LSTATE,JSTATE,VSI1                 DSTA10    147
*ENDIF                                                                  DSTA10    148
        VSI1=VSI1*DDAT(JS+3)                                            DSTA10    149
C-  FIRST INPUT BLOCK                                                   DSTA10    150
        IF(IDDAT(JS+4).NE.0)THEN                                        DSTA10    151
           KSTATE=KSTATE+1                                              DSTA10    152
           DSTATE(LSTATE+KSTATE)=(VSI1-XSTATE(JSTATE+KSTATE))           DSTA10    153
     +     /DDAT(JS+4)                                                  DSTA10    154
           VSI1=XSTATE(JSTATE+KSTATE)                                   DSTA10    155
        ENDIF                                                           DSTA10    156
C-  SECOND INPUT BLOCK                                                  DSTA10    157
        DET=VTOS(JYS+2)-ET                                              DSTA10    158
        VSI2=DET*DDAT(JS+5)                                             DSTA10    159
        IF(IDDAT(JS+6).NE.0)THEN                                        DSTA10    160
           KSTATE=KSTATE+1                                              DSTA10    161
           DSTATE(LSTATE+KSTATE)=(VSI2-XSTATE(JSTATE+KSTATE))           DSTA10    162
     +     /DDAT(JS+6)                                                  DSTA10    163
           VSI2=XSTATE(JSTATE+KSTATE)                                   DSTA10    164
        ENDIF                                                           DSTA10    165
C-  SUMMING JUNCTION                                                    DSTA10    166
        VSX=VSI1-VSI2                                                   DSTA10    167
*IF DEBUG                                                               DSTA10    168
          IF(LDEB)WRITE(IUD6,1230)VSI1,VSI2,VSX                         DSTA10    169
*ENDIF                                                                  DSTA10    170
C-  TQ - TQ1 - TQ2 - TQ3 BRANCH                                         DSTA10    171
C   TQ BLOCK                                                            DSTA10    172
        IF(IDDAT(JS+7).NE.0)THEN                                        DSTA10    173
           KSTATE=KSTATE+1                                              DSTA10    174
           DSTATE(LSTATE+KSTATE)=(VSX-XSTATE(JSTATE+KSTATE))/DDAT(JS+7) DSTA10    175
           VSX=DDAT(JS+7)*DSTATE(LSTATE+KSTATE)                         DSTA10    176
*IF DEBUG                                                               DSTA10    177
           IF(LDEB)WRITE(IUD6,1240)VSX                                  DSTA10    178
*ENDIF                                                                  DSTA10    179
        ENDIF                                                           DSTA10    180
C   TQ1 BLOCK                                                           DSTA10    181
        IF(IDDAT(JS+9).NE.0)THEN                                        DSTA10    182
           KSTATE=KSTATE+1                                              DSTA10    183
           DSTATE(LSTATE+KSTATE)=(VSX-XSTATE(JSTATE+KSTATE))/DDAT(JS+9) DSTA10    184
           VSX=XSTATE(JSTATE+KSTATE)+DDAT(JS+8)*DSTATE(LSTATE+KSTATE)   DSTA10    185
*IF DEBUG                                                               DSTA10    186
           IF(LDEB)WRITE(IUD6,1250)VSX                                  DSTA10    187
*ENDIF                                                                  DSTA10    188
        ENDIF                                                           DSTA10    189
C   TQ2 BLOCK                                                           DSTA10    190
        IF(IDDAT(JS+11).NE.0)THEN                                       DSTA10    191
           KSTATE=KSTATE+1                                              DSTA10    192
           DSTATE(LSTATE+KSTATE)=(VSX-XSTATE(JSTATE+KSTATE))/DDAT(JS+11)DSTA10    193
           VSX=XSTATE(JSTATE+KSTATE)+DDAT(JS+10)*DSTATE(LSTATE+KSTATE)  DSTA10    194
*IF DEBUG                                                               DSTA10    195
           IF(LDEB)WRITE(IUD6,1260)VSX                                  DSTA10    196
*ENDIF                                                                  DSTA10    197
        ENDIF                                                           DSTA10    198
C   TQ3 BLOCK                                                           DSTA10    199
        IF(IDDAT(JS+13).NE.0)THEN                                       DSTA10    200
           KSTATE=KSTATE+1                                              DSTA10    201
           DSTATE(LSTATE+KSTATE)=(VSX-XSTATE(JSTATE+KSTATE))/DDAT(JS+13)DSTA10    202
           VSX=XSTATE(JSTATE+KSTATE)+DDAT(JS+12)*DSTATE(LSTATE+KSTATE)  DSTA10    203
*IF DEBUG                                                               DSTA10    204
           IF(LDEB)WRITE(IUD6,1270)VSX                                  DSTA10    205
*ENDIF                                                                  DSTA10    206
        ENDIF                                                           DSTA10    207
C-  LIMITER                                                             DSTA10    208
        IF(VSX.GT.DDAT(JS+14)) VSX=DDAT(JS+14)                          DSTA10    209
        IF(VSX.LT.DDAT(JS+15)) VSX=DDAT(JS+15)                          DSTA10    210
C-  OUTPUT CONTROL SWITCH                                               DSTA10    211
        IF (ABS(DET).GT.DDAT(JS+16).AND.IDDAT(JS+16).NE.0) THEN         DSTA10    212
           VSX=0.0                                                      DSTA10    213
           IDDAT(JS+27)=0                                               DSTA10    214
        ELSE                                                            DSTA10    215
           IDDAT(JS+27)=1                                               DSTA10    216
        END IF                                                          DSTA10    217
        VSS(JYS+1)=VSX                                                  DSTA10    218
        NXS=KSTATE                                                      DSTA10    219
*IF DEBUG                                                               DSTA10    220
        IF(LDEB)THEN                                                    DSTA10    221
            WRITE(IUD6,1130)N,(DSTATE(LSTATE+KKK),KKK=1,KSTATE)         DSTA10    222
            WRITE(IUD6,1140)N,JYS,VSX,(XSTATE(JSTATE+KKK),KKK=1,KSTATE) DSTA10    223
        ENDIF                                                           DSTA10    224
*ENDIF                                                                  DSTA10    225
C                                                                       DSTA10    226
C   TYPE 11 STABILIZER (WSCC MODEL)                                     DSTA10    227
C                                                                       DSTA10    228
        ELSE IF (ISTABN.EQ.11) THEN                                     DSTA10    229
        VSI1=VSI1*DDAT(JS+3)                                            DSTA10    230
C-  FIRST INPUT BLOCK                                                   DSTA10    231
        IF(IDDAT(JS+4).NE.0)THEN                                        DSTA10    232
           KSTATE=KSTATE+1                                              DSTA10    233
           DSTATE(LSTATE+KSTATE)=(VSI1-XSTATE(JSTATE+KSTATE))           DSTA10    234
     +     /DDAT(JS+4)                                                  DSTA10    235
           VSI1=XSTATE(JSTATE+KSTATE)                                   DSTA10    236
        ENDIF                                                           DSTA10    237
C-  SECOND INPUT BLOCK                                                  DSTA10    238
        DET=VTOS(JYS+2)-ET                                              DSTA10    239
        VSI2=DET*DDAT(JS+5)                                             DSTA10    240
        IF(IDDAT(JS+6).NE.0)THEN                                        DSTA10    241
           KSTATE=KSTATE+1                                              DSTA10    242
           DSTATE(LSTATE+KSTATE)=(VSI2-XSTATE(JSTATE+KSTATE))           DSTA10    243
     +     /DDAT(JS+6)                                                  DSTA10    244
           VSI2=XSTATE(JSTATE+KSTATE)                                   DSTA10    245
        ENDIF                                                           DSTA10    246
C                                                                       DSTA10    247
C   K-S1-T1-T2-T3-T4 BRANCH                                             DSTA10    248
C                                                                       DSTA10    249
C   IF K=0.0                                                            DSTA10    250
        IF(IDDAT(JS+18).EQ.0)THEN                                       DSTA10    251
           VSK=0.0                                                      DSTA10    252
C                                                                       DSTA10    253
C   IF K>0.0                                                            DSTA10    254
C                                                                       DSTA10    255
        ELSE                                                            DSTA10    256
C                                                                       DSTA10    257
C-  IF S1 IS OPENED                                                     DSTA10    258
C                                                                       DSTA10    259
        IF(IDDAT(JS+32).EQ.0)THEN                                       DSTA10    260
           IF(IDDAT(JS+19).NE.0)THEN                                    DSTA10    261
              KSTATE=KSTATE+1                                           DSTA10    262
              DSTATE(LSTATE+KSTATE)=0.0                                 DSTA10    263
           ENDIF                                                        DSTA10    264
           IF(IDDAT(JS+20).NE.0)THEN                                    DSTA10    265
              KSTATE=KSTATE+1                                           DSTA10    266
              DSTATE(LSTATE+KSTATE)=0.0                                 DSTA10    267
           ENDIF                                                        DSTA10    268
           VSK=0.0                                                      DSTA10    269
           IF(IDDAT(JS+21).NE.0)THEN                                    DSTA10    270
              KSTATE=KSTATE+1                                           DSTA10    271
              DSTATE(LSTATE+KSTATE)=(VSI1-XSTATE(JSTATE+KSTATE))        DSTA10    272
     +        /DDAT(JS+21)                                              DSTA10    273
              DELOMG=DDAT(JS+21)*DSTATE(LSTATE+KSTATE)                  DSTA10    274
           ELSE                                                         DSTA10    275
              DELOMG=VSI1                                               DSTA10    276
           ENDIF                                                        DSTA10    277
           IF(IDDAT(JS+22).NE.0)THEN                                    DSTA10    278
              KSTATE=KSTATE+1                                           DSTA10    279
              DSTATE(LSTATE+KSTATE)=(DELOMG-XSTATE(JSTATE+KSTATE))      DSTA10    280
     +        /DDAT(JS+22)                                              DSTA10    281
              DOMG=DSTATE(LSTATE+KSTATE)                                DSTA10    282
           ELSE                                                         DSTA10    283
              DOMG=DELOMG                                               DSTA10    284
           ENDIF                                                        DSTA10    285
C-   IF S1 IS CLOSED                                                    DSTA10    286
        ELSE                                                            DSTA10    287
           IF(IDDAT(JS+19).NE.0)THEN                                    DSTA10    288
              KSTATE=KSTATE+1                                           DSTA10    289
              DSTATE(LSTATE+KSTATE)=(DDAT(JS+18)-XSTATE(JSTATE+KSTATE)) DSTA10    290
     +        /DDAT(JS+19)                                              DSTA10    291
              VSK=XSTATE(JSTATE+KSTATE)                                 DSTA10    292
           ELSE                                                         DSTA10    293
              VSK=DDAT(JS+18)                                           DSTA10    294
           ENDIF                                                        DSTA10    295
           IF(IDDAT(JS+20).NE.0)THEN                                    DSTA10    296
              KSTATE=KSTATE+1                                           DSTA10    297
              DSTATE(LSTATE+KSTATE)=(VSK-XSTATE(JSTATE+KSTATE))         DSTA10    298
     +        /DDAT(JS+20)                                              DSTA10    299
              VSK=DDAT(JS+20)*DSTATE(LSTATE+KSTATE)                     DSTA10    300
           ENDIF                                                        DSTA10    301
           IF(IDDAT(JS+21).NE.0)THEN                                    DSTA10    302
              KSTATE=KSTATE+1                                           DSTA10    303
              DSTATE(LSTATE+KSTATE)=0.0                                 DSTA10    304
           ENDIF                                                        DSTA10    305
           IF(IDDAT(JS+22).NE.0)THEN                                    DSTA10    306
              KSTATE=KSTATE+1                                           DSTA10    307
              DSTATE(LSTATE+KSTATE)=0.0                                 DSTA10    308
           ENDIF                                                        DSTA10    309
C-  END OF "IF(IDDAT(JS+32).EQ.0)"                                      DSTA10    310
        ENDIF                                                           DSTA10    311
C                                                                       DSTA10    312
C   END IF K=0                                                          DSTA10    313
C                                                                       DSTA10    314
        ENDIF                                                           DSTA10    315
C                                                                       DSTA10    316
C   SUMMING JUNCTIONS                                                   DSTA10    317
C                                                                       DSTA10    318
        VSX=(VSI1-VSK)*DDAT(JS+17)-VSI2                                 DSTA10    319
C-  TQ - TQ1 - TQ2 - TQ3 BRANCH                                         DSTA10    320
C   TQ BLOCK                                                            DSTA10    321
        IF(IDDAT(JS+7).NE.0)THEN                                        DSTA10    322
           KSTATE=KSTATE+1                                              DSTA10    323
           DSTATE(LSTATE+KSTATE)=(VSX-XSTATE(JSTATE+KSTATE))/DDAT(JS+7) DSTA10    324
           VSX=DDAT(JS+7)*DSTATE(LSTATE+KSTATE)                         DSTA10    325
        ENDIF                                                           DSTA10    326
C   TQ1 BLOCK                                                           DSTA10    327
        IF(IDDAT(JS+9).NE.0)THEN                                        DSTA10    328
           KSTATE=KSTATE+1                                              DSTA10    329
           DSTATE(LSTATE+KSTATE)=(VSX-XSTATE(JSTATE+KSTATE))/DDAT(JS+9) DSTA10    330
           VSX=XSTATE(JSTATE+KSTATE)+DDAT(JS+8)*DSTATE(LSTATE+KSTATE)   DSTA10    331
        ENDIF                                                           DSTA10    332
C   TQ2 BLOCK                                                           DSTA10    333
        IF(IDDAT(JS+11).NE.0)THEN                                       DSTA10    334
           KSTATE=KSTATE+1                                              DSTA10    335
           DSTATE(LSTATE+KSTATE)=(VSX-XSTATE(JSTATE+KSTATE))/DDAT(JS+11)DSTA10    336
           VSX=XSTATE(JSTATE+KSTATE)+DDAT(JS+10)*DSTATE(LSTATE+KSTATE)  DSTA10    337
        ENDIF                                                           DSTA10    338
C   TQ3 BLOCK                                                           DSTA10    339
        IF(IDDAT(JS+13).NE.0)THEN                                       DSTA10    340
           KSTATE=KSTATE+1                                              DSTA10    341
           DSTATE(LSTATE+KSTATE)=(VSX-XSTATE(JSTATE+KSTATE))/DDAT(JS+13)DSTA10    342
           VSX=XSTATE(JSTATE+KSTATE)+DDAT(JS+12)*DSTATE(LSTATE+KSTATE)  DSTA10    343
        ENDIF                                                           DSTA10    344
C-  LIMITER                                                             DSTA10    345
        IF(VSX.GT.DDAT(JS+14)) VSX=DDAT(JS+14)                          DSTA10    346
        IF(VSX.LT.DDAT(JS+15)) VSX=DDAT(JS+15)                          DSTA10    347
C-  OUTPUT CONTROL SWITCH                                               DSTA10    348
        IF (ABS(DET).GT.DDAT(JS+16).AND.IDDAT(JS+16).NE.0) THEN         DSTA10    349
           VSX=0.0                                                      DSTA10    350
           IDDAT(JS+34)=0                                               DSTA10    351
        ELSE                                                            DSTA10    352
           IDDAT(JS+34)=1                                               DSTA10    353
        END IF                                                          DSTA10    354
        VSS(JYS+1)=VSX                                                  DSTA10    355
        NXS=KSTATE                                                      DSTA10    356
C                                                                       DSTA10    357
      ENDIF                                                             DSTA10    358
C                                                                       DSTA10    359
      LSTATE=LSTATE+NXS                                                 DSTA10    360
      JSTATE=JSTATE+NXS                                                 DSTA10    361
C                                                                       DSTA10    362
*IF DEBUG                                                               DSTA10    363
      IF(LDEB)WRITE(IUD6,1100) JS,LSTATE,(IDDAT(JS+LK),LK=1,2)          DSTA10    364
     &,(DDAT(JS+LK),LK=3,17)                                            DSTA10    365
*ENDIF                                                                  DSTA10    366
C                                                                       DSTA10    367
      RETURN                                                            DSTA10    368
C                                                                       DSTA10    369
 1100 FORMAT(1X,'DB-DSTAB:JS,LSTATE,DDAT(1:17) ',2I5,2X,2I5,/,          DSTA10    370
     & (8X,10G12.5))                                                    DSTA10    371
 1130 FORMAT(' DSTATE ',I10,6F15.9)                                     DSTA10    372
 1140 FORMAT(' XSTATE ',2I10,6F15.9)                                    DSTA10    373
 1220 FORMAT(' N,LSTATE,JSTATE AND INPUT TO THE STABILIZER ',           DSTA10    374
     &3I10,F15.9)                                                       DSTA10    375
 1230 FORMAT(' SUMMING JUNCTION SIGNALS VSI1,VSI2,VSX ',3F15.9)         DSTA10    376
 1240 FORMAT(' OUTPUT SIGNAL FOR THE TQ BLOCK ',F15.9)                  DSTA10    377
 1250 FORMAT(' OUTPUT SIGNAL FOR THE TQ1 BLOCK ',F15.9)                 DSTA10    378
 1260 FORMAT(' OUTPUT SIGNAL FOR THE TQ2 BLOCK ',F15.9)                 DSTA10    379
 1270 FORMAT(' OUTPUT SIGNAL FOR THE TQ3 BLOCK ',F15.9)                 DSTA10    380
C                                                                       DSTA10    381
      END                                                               DSTA10    382
