CFPRIME ASTA10                                                          ASTA10      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 ASTA10(ISTATE)                                         ASTA10      3
CD                                                                      ASTA10      4
CD    TO FORMULATE THE JACOBIAN MATRICES OF TYPE 10 STABILIZER.         ASTA10      5
CD                                                                      ASTA10      6
      INCLUDE 'PARX.INS'                                                ASTA10      7
      INCLUDE 'CNB8.INS'                                                ASTA10      8
      INCLUDE 'CNEXC.INS'                                               ASTA10      9
      INCLUDE 'CNSTAB.INS'                                              ASTA10     10
      INCLUDE 'CNPARX.INS'                                              ASTA10     11
      INCLUDE 'CNMDAT.INS'                                              ASTA10     12
      INCLUDE 'CNXSTA.INS'                                              ASTA10     13
      INCLUDE 'CNMSTA.INS'                                              ASTA10     14
      INCLUDE 'CNUDMB.INS'                                              ASTA10     15
C                                                                       ASTA10     16
      INCLUDE 'CNABAK.INS'                                              ASTA10     17
C                                                                       ASTA10     18
C     SUBSCRIPTS                                                        ASTA10     19
C                                                                       ASTA10     20
      ISUB1=IDDAT(JS+21)                                                ASTA10     21
      ISUB2=IDDAT(JS+22)                                                ASTA10     22
      ISUB3=IDDAT(JS+23)                                                ASTA10     23
      ISUB4=IDDAT(JS+24)                                                ASTA10     24
      ISUB5=IDDAT(JS+25)                                                ASTA10     25
      ISUB6=IDDAT(JS+26)                                                ASTA10     26
C                                                                       ASTA10     27
      IE=0                                                              ASTA10     28
      ICASE=IDDAT(JS+27)                                                ASTA10     29
C                                                                       ASTA10     30
      IF (ICASE.EQ.0) THEN                                              ASTA10     31
C                                                                       ASTA10     32
C     OUTPUT SWITCH AT "OFF" POSITION, EXIT                             ASTA10     33
C                                                                       ASTA10     34
         IF (ISUB1.NE.0) IE=IE+1                                        ASTA10     35
         IF (ISUB2.NE.0) IE=IE+1                                        ASTA10     36
         IF (ISUB3.NE.0) IE=IE+1                                        ASTA10     37
         IF (ISUB4.NE.0) IE=IE+1                                        ASTA10     38
         IF (ISUB5.NE.0) IE=IE+1                                        ASTA10     39
         IF (ISUB6.NE.0) IE=IE+1                                        ASTA10     40
         IF (IFLTRN.NE.0) CALL ASTF1(ISTATE)                            ASTA10     41
         INSTA(1,1)=0                                                   ASTA10     42
C                                                                       ASTA10     43
         GOTO 110                                                       ASTA10     44
C                                                                       ASTA10     45
      END IF                                                            ASTA10     46
C                                                                       ASTA10     47
      INTYP1=IDDAT(JS+2)                                                ASTA10     48
      INTYP2=5                                                          ASTA10     49
C                                                                       ASTA10     50
C     KQS, TQS BLOCK (OPTIONAL)                                         ASTA10     51
C                                                                       ASTA10     52
      CC1=DDAT(JS+3)                                                    ASTA10     53
      IF (ISUB1.EQ.0) THEN                                              ASTA10     54
         INPUT1=0                                                       ASTA10     55
      ELSE                                                              ASTA10     56
         IE=IE+1                                                        ASTA10     57
         INPUT1=1                                                       ASTA10     58
         TQSI=1.0/DDAT(JS+4)                                            ASTA10     59
         A(ISUB1,ISUB1)=-TQSI                                           ASTA10     60
         INSTA(IE,1)=ISUB1                                              ASTA10     61
         RINSTA(IE,1)=CC1*TQSI                                          ASTA10     62
         RINSTA(IE,2)=0.0                                               ASTA10     63
      END IF                                                            ASTA10     64
C                                                                       ASTA10     65
C     KQV, TQV BLOCK (OPTIONAL)                                         ASTA10     66
C                                                                       ASTA10     67
      CC2=DDAT(JS+5)                                                    ASTA10     68
      IF (ISUB2.EQ.0) THEN                                              ASTA10     69
         INPUT2=0                                                       ASTA10     70
      ELSE                                                              ASTA10     71
         IE=IE+1                                                        ASTA10     72
         INPUT2=1                                                       ASTA10     73
         TQVI=1.0/DDAT(JS+6)                                            ASTA10     74
         A(ISUB2,ISUB2)=-TQVI                                           ASTA10     75
         INSTA(IE,1)=ISUB2                                              ASTA10     76
         RINSTA(IE,1)=0.0                                               ASTA10     77
C         RINSTA(IE,2)=CC2*TQVI                                         ASTA10     78
         RINSTA(IE,2)=-CC2*TQVI                                         ASTA10     79
      END IF                                                            ASTA10     80
C                                                                       ASTA10     81
      GAIN1=1.0                                                         ASTA10     82
      GAIN2=0.0                                                         ASTA10     83
      GAIN3=0.0                                                         ASTA10     84
      GAIN4=0.0                                                         ASTA10     85
C                                                                       ASTA10     86
C     TQ BLOCK                                                          ASTA10     87
C                                                                       ASTA10     88
      IF (ISUB3.NE.0) THEN                                              ASTA10     89
         IE=IE+1                                                        ASTA10     90
         TQI=1.0/DDAT(JS+7)                                             ASTA10     91
         A(ISUB3,ISUB3)=-TQI                                            ASTA10     92
         INSTA(IE,1)=ISUB3                                              ASTA10     93
         RINSTA(IE,1)=0.0                                               ASTA10     94
         RINSTA(IE,2)=0.0                                               ASTA10     95
         IF (INPUT1.EQ.0) THEN                                          ASTA10     96
            RINSTA(IE,1)=CC1*TQI                                        ASTA10     97
         ELSE                                                           ASTA10     98
            A(ISUB3,ISUB1)=TQI                                          ASTA10     99
         END IF                                                         ASTA10    100
         IF (INPUT2.EQ.0) THEN                                          ASTA10    101
C            RINSTA(IE,2)=-CC2*TQI                                      ASTA10    102
            RINSTA(IE,2)=CC2*TQI                                        ASTA10    103
         ELSE                                                           ASTA10    104
            A(ISUB3,ISUB2)=-TQI                                         ASTA10    105
         END IF                                                         ASTA10    106
      END IF                                                            ASTA10    107
C                                                                       ASTA10    108
C     T'Q1, TQ1 BLOCK (OPTIONAL)                                        ASTA10    109
C                                                                       ASTA10    110
      IF (ISUB4.NE.0) THEN                                              ASTA10    111
         IE=IE+1                                                        ASTA10    112
         TQ1I=1.0/DDAT(JS+9)                                            ASTA10    113
         TPQ1=DDAT(JS+8)                                                ASTA10    114
         GAIN1=TQ1I                                                     ASTA10    115
         A(ISUB4,ISUB4)=-TQ1I                                           ASTA10    116
         IF (ISUB3.NE.0) A(ISUB4,ISUB3)=-GAIN1                          ASTA10    117
         INSTA(IE,1)=ISUB4                                              ASTA10    118
         RINSTA(IE,1)=0.0                                               ASTA10    119
         RINSTA(IE,2)=0.0                                               ASTA10    120
         IF (INPUT1.EQ.0) THEN                                          ASTA10    121
            RINSTA(IE,1)=CC1*GAIN1                                      ASTA10    122
         ELSE                                                           ASTA10    123
            A(ISUB4,ISUB1)=GAIN1                                        ASTA10    124
         END IF                                                         ASTA10    125
         IF (INPUT2.EQ.0) THEN                                          ASTA10    126
C            RINSTA(IE,2)=-CC2*GAIN1                                    ASTA10    127
            RINSTA(IE,2)=CC2*GAIN1                                      ASTA10    128
         ELSE                                                           ASTA10    129
            A(ISUB4,ISUB2)=-GAIN1                                       ASTA10    130
         END IF                                                         ASTA10    131
         GAIN2=1.0-TPQ1*TQ1I                                            ASTA10    132
         GAIN1=GAIN1*TPQ1                                               ASTA10    133
      END IF                                                            ASTA10    134
C                                                                       ASTA10    135
C     T'Q2, TQ2 BLOCK (OPTIONAL)                                        ASTA10    136
C                                                                       ASTA10    137
      IF (ISUB5.NE.0) THEN                                              ASTA10    138
         IE=IE+1                                                        ASTA10    139
         TQ2I=1.0/DDAT(JS+11)                                           ASTA10    140
         TPQ2=DDAT(JS+10)                                               ASTA10    141
         GAIN2=GAIN2*TQ2I                                               ASTA10    142
         GAIN1=GAIN1*TQ2I                                               ASTA10    143
         A(ISUB5,ISUB5)=-TQ2I                                           ASTA10    144
         IF (ISUB3.NE.0) A(ISUB5,ISUB3)=-GAIN1                          ASTA10    145
         IF (ISUB4.NE.0) A(ISUB5,ISUB4)=GAIN2                           ASTA10    146
         INSTA(IE,1)=ISUB5                                              ASTA10    147
         RINSTA(IE,1)=0.0                                               ASTA10    148
         RINSTA(IE,2)=0.0                                               ASTA10    149
         IF (INPUT1.EQ.0) THEN                                          ASTA10    150
            RINSTA(IE,1)=CC1*GAIN1                                      ASTA10    151
         ELSE                                                           ASTA10    152
            A(ISUB5,ISUB1)=GAIN1                                        ASTA10    153
         END IF                                                         ASTA10    154
         IF (INPUT2.EQ.0) THEN                                          ASTA10    155
C            RINSTA(IE,2)=-CC2*GAIN1                                    ASTA10    156
            RINSTA(IE,2)=CC2*GAIN1                                      ASTA10    157
         ELSE                                                           ASTA10    158
            A(ISUB5,ISUB2)=-GAIN1                                       ASTA10    159
         END IF                                                         ASTA10    160
         GAIN3=1.0-TPQ2*TQ2I                                            ASTA10    161
         GAIN2=GAIN2*TPQ2                                               ASTA10    162
         GAIN1=GAIN1*TPQ2                                               ASTA10    163
      END IF                                                            ASTA10    164
C                                                                       ASTA10    165
C     T'Q3, TQ3 BLOCK (OPTIONAL)                                        ASTA10    166
C                                                                       ASTA10    167
      IF (ISUB6.NE.0) THEN                                              ASTA10    168
         IE=IE+1                                                        ASTA10    169
         TQ3I=1.0/DDAT(JS+13)                                           ASTA10    170
         TPQ3=DDAT(JS+12)                                               ASTA10    171
         GAIN3=GAIN3*TQ3I                                               ASTA10    172
         GAIN2=GAIN2*TQ3I                                               ASTA10    173
         GAIN1=GAIN1*TQ3I                                               ASTA10    174
         A(ISUB6,ISUB6)=-TQ3I                                           ASTA10    175
         IF (ISUB3.NE.0) A(ISUB6,ISUB3)=-GAIN1                          ASTA10    176
         IF (ISUB4.NE.0) A(ISUB6,ISUB4)=GAIN2                           ASTA10    177
         IF (ISUB5.NE.0) A(ISUB6,ISUB5)=GAIN3                           ASTA10    178
         INSTA(IE,1)=ISUB6                                              ASTA10    179
         RINSTA(IE,1)=0.0                                               ASTA10    180
         RINSTA(IE,2)=0.0                                               ASTA10    181
         IF (INPUT1.EQ.0) THEN                                          ASTA10    182
            RINSTA(IE,1)=CC1*GAIN1                                      ASTA10    183
         ELSE                                                           ASTA10    184
            A(ISUB6,ISUB1)=GAIN1                                        ASTA10    185
         END IF                                                         ASTA10    186
         IF (INPUT2.EQ.0) THEN                                          ASTA10    187
C            RINSTA(IE,2)=-CC2*GAIN1                                    ASTA10    188
            RINSTA(IE,2)=CC2*GAIN1                                      ASTA10    189
         ELSE                                                           ASTA10    190
            A(ISUB6,ISUB2)=-GAIN1                                       ASTA10    191
         END IF                                                         ASTA10    192
         GAIN4=1.0-TPQ3*TQ3I                                            ASTA10    193
         GAIN3=GAIN3*TPQ3                                               ASTA10    194
         GAIN2=GAIN2*TPQ3                                               ASTA10    195
         GAIN1=GAIN1*TPQ3                                               ASTA10    196
      END IF                                                            ASTA10    197
C                                                                       ASTA10    198
C     OUTPUT EQUATION                                                   ASTA10    199
C                                                                       ASTA10    200
      IE1=0                                                             ASTA10    201
      DSTB1=0.0                                                         ASTA10    202
      DSTB2=0.0                                                         ASTA10    203
      IF (INPUT1.EQ.0) THEN                                             ASTA10    204
         DSTB1=CC1*GAIN1                                                ASTA10    205
      ELSE                                                              ASTA10    206
         IE1=IE1+1                                                      ASTA10    207
         IOUTS(IE1)=ISUB1                                               ASTA10    208
         ROUTS(IE1)=GAIN1                                               ASTA10    209
      END IF                                                            ASTA10    210
      IF (INPUT2.EQ.0) THEN                                             ASTA10    211
C         DSTB2=-CC2*GAIN1                                              ASTA10    212
         DSTB2=CC2*GAIN1                                                ASTA10    213
      ELSE                                                              ASTA10    214
         IE1=IE1+1                                                      ASTA10    215
         IOUTS(IE1)=ISUB2                                               ASTA10    216
         ROUTS(IE1)=-GAIN1                                              ASTA10    217
      END IF                                                            ASTA10    218
      IF (ISUB3.NE.0) THEN                                              ASTA10    219
         IE1=IE1+1                                                      ASTA10    220
         IOUTS(IE1)=ISUB3                                               ASTA10    221
         ROUTS(IE1)=-GAIN1                                              ASTA10    222
      END IF                                                            ASTA10    223
      IF (ISUB4.NE.0) THEN                                              ASTA10    224
         IE1=IE1+1                                                      ASTA10    225
         IOUTS(IE1)=ISUB4                                               ASTA10    226
         ROUTS(IE1)=GAIN2                                               ASTA10    227
      END IF                                                            ASTA10    228
      IF (ISUB5.NE.0) THEN                                              ASTA10    229
         IE1=IE1+1                                                      ASTA10    230
         IOUTS(IE1)=ISUB5                                               ASTA10    231
         ROUTS(IE1)=GAIN3                                               ASTA10    232
      END IF                                                            ASTA10    233
      IF (ISUB6.NE.0) THEN                                              ASTA10    234
         IE1=IE1+1                                                      ASTA10    235
         IOUTS(IE1)=ISUB6                                               ASTA10    236
         ROUTS(IE1)=GAIN4                                               ASTA10    237
      END IF                                                            ASTA10    238
C                                                                       ASTA10    239
C     TORSIONAL FILTER                                                  ASTA10    240
C                                                                       ASTA10    241
      IF (IFLTRN.NE.0) CALL ASTF1(ISTATE)                               ASTA10    242
C                                                                       ASTA10    243
C     INTERCONNECTION WITH EXCITER                                      ASTA10    244
C                                                                       ASTA10    245
      IE1=IE                                                            ASTA10    246
      IF (IEXN.NE.50) THEN                                              ASTA10    247
C                                                                       ASTA10    248
      DO 10 I=1,4                                                       ASTA10    249
         IF (IUST(I).EQ.0) GOTO 100                                     ASTA10    250
         IWS1=IUST(I)                                                   ASTA10    251
         WS1=GUST(I)                                                    ASTA10    252
         DO 20 J=1,IE                                                   ASTA10    253
            IWS2=IOUTS(J)                                               ASTA10    254
            A(IWS1,IWS2)=ROUTS(J)*WS1                                   ASTA10    255
  20     CONTINUE                                                       ASTA10    256
         IE1=IE1+1                                                      ASTA10    257
         INSTA(IE1,1)=IWS1                                              ASTA10    258
         RINSTA(IE1,1)=DSTB1*WS1                                        ASTA10    259
         RINSTA(IE1,2)=DSTB2*WS1                                        ASTA10    260
  10  CONTINUE                                                          ASTA10    261
C                                                                       ASTA10    262
      ELSE                                                              ASTA10    263
C                                                                       ASTA10    264
C     CONNECTION WITH A USER DEFIEND EXCITER                            ASTA10    265
C                                                                       ASTA10    266
      MSEXC=MSUDM(1,1)                                                  ASTA10    267
      IWS1=ISTATE-MSEXC                                                 ASTA10    268
      DO 30 I=1,MSEXC+1                                                 ASTA10    269
         IWS2=IWS1+I                                                    ASTA10    270
         IF (I.GT.MSEXC) IWS2=3                                         ASTA10    271
         DO 40 J=1,IE                                                   ASTA10    272
            IWS3=IOUTS(J)                                               ASTA10    273
            A(IWS2,IWS3)=ROUTS(J)*BXVS(I)                               ASTA10    274
  40     CONTINUE                                                       ASTA10    275
         IE1=IE1+1                                                      ASTA10    276
         INSTA(IE1,1)=IWS2                                              ASTA10    277
         RINSTA(IE1,1)=DSTB1*BXVS(I)                                    ASTA10    278
         RINSTA(IE1,2)=DSTB2*BXVS(I)                                    ASTA10    279
  30  CONTINUE                                                          ASTA10    280
C                                                                       ASTA10    281
      END IF                                                            ASTA10    282
C                                                                       ASTA10    283
 100  CONTINUE                                                          ASTA10    284
      INSTA(IE1+1,1)=0                                                  ASTA10    285
C                                                                       ASTA10    286
C     INCOPORATE WITH INPUT SIGNALS                                     ASTA10    287
C                                                                       ASTA10    288
      CALL ASGNAL(ISTATE,INTYP1,INTYP2)                                 ASTA10    289
C                                                                       ASTA10    290
 110  CONTINUE                                                          ASTA10    291
C                                                                       ASTA10    292
      ISTATE=ISTATE+IE                                                  ASTA10    293
C                                                                       ASTA10    294
      RETURN                                                            ASTA10    295
      END                                                               ASTA10    296
