CFPRIME SDEVIC                                                          SDEVIC      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  SDEVIC(TIMX)                                          SDEVIC      3
C---------------------------------------------------------------------  SDEVIC      4
C                                                                       SDEVIC      5
C               *****     SDEVIC  ROUTINE   *****                       SDEVIC      6
C                                                                       SDEVIC      7
C---------------------------------------------------------------------  SDEVIC      8
CD                                                                      SDEVIC      9
CD        PURPOSE:  Controls calculation of converter and breaker       SDEVIC     10
cD                  quantities.                                         SDEVIC     11
CD                                                                      SDEVIC     12
CD                                                                      SDEVIC     13
CD        DEFINITION OF LOCAL VARIABLES:                                SDEVIC     14
CD                  I      -  first bus.                                SDEVIC     15
CD                  J      -  second bus.                               SDEVIC     16
CD                  K      - 'do' loop index.                           SDEVIC     17
CD                  JPOSN   -  storage position for dc information.     SDEVIC     18
CD                  VCI    -  voltage for first bus.                    SDEVIC     19
CD                  VCJ    -  voltage for second bus.                   SDEVIC     20
CD                  VST    -  setpoint voltage value.                   SDEVIC     21
CD                                                                      SDEVIC     22
CD                                                                      SDEVIC     23
CD        SUBROUTINES REQUIRED:  SBVOLT, SCALPA, SCCURR, SCGAMA, SCVOLT SDEVIC     24
CD                                                                      SDEVIC     25
CD--------------------------------------------------------------------- SDEVIC     26
      INCLUDE 'PARX.INS'                                                SDEVIC     27
      INCLUDE 'CNPARX.INS'                                              SDEVIC     28
      INCLUDE 'GRDC01.INS'                                              SDEVIC     29
      INCLUDE 'GRDC03.INS'                                              SDEVIC     30
      INCLUDE 'UDCJ.INS'                                                SDEVIC     31
      INCLUDE 'CNMSG.INS'                                               SDEVIC     32
C                                                                       SDEVIC     33
      DOUBLE PRECISION  TIMX                                            SDEVIC     34
C                                                                       SDEVIC     35
C---------------------------------------------------------------------  SDEVIC     36
C                                                                       SDEVIC     37
      DO 20 K = 1, ICDC                                                 SDEVIC     38
         IF(IDCSRT(K) .NE. 0)THEN                                       SDEVIC     39
C                                                                       SDEVIC     40
            JPOSN = IDCSRT(K)                                           SDEVIC     41
C                                                                       SDEVIC     42
C           Calculate the voltage for this converter.                   SDEVIC     43
C                                                                       SDEVIC     44
            I = ICONRE(JPOSN,1)                                         SDEVIC     45
            J = ICONRE(JPOSN,2)                                         SDEVIC     46
C                                                                       SDEVIC     47
            IF(I.EQ.0)THEN                                              SDEVIC     48
               VCI = 0.0                                                SDEVIC     49
            ELSE                                                        SDEVIC     50
               VCI = VDCNOD(I)                                          SDEVIC     51
            END IF                                                      SDEVIC     52
C                                                                       SDEVIC     53
            IF(J.EQ.0)THEN                                              SDEVIC     54
               VCJ = 0.0                                                SDEVIC     55
            ELSE                                                        SDEVIC     56
               VCJ = VDCNOD(J)                                          SDEVIC     57
            END IF                                                      SDEVIC     58
C                                                                       SDEVIC     59
            VDCONV(JPOSN) = VCI - VCJ                                   SDEVIC     60
C                                                                       SDEVIC     61
C                                                                       SDEVIC     62
            IVC=0                                                       SDEVIC     63
            IF(UMODE(JPOSN).EQ.'ALPHA')THEN                             SDEVIC     64
               IF(UMOD2(JPOSN).EQ.'NONE') THEN                          SDEVIC     65
C                                                                       SDEVIC     66
C                 Converter is LC alpha controlled.                     SDEVIC     67
C                                                                       SDEVIC     68
                  VST = USETPT(JPOSN) * PII / 180.0                     SDEVIC     69
C                                                                       SDEVIC     70
                  CALL SCALPA (JPOSN, VST,TIMX)                         SDEVIC     71
C                                                                       SDEVIC     72
               ELSEIF(UMOD2(JPOSN).EQ.'ALPHA') THEN                     SDEVIC     73
                  WRITE(MSG(1),1000) DCCNAM(JPOSN)                      SDEVIC     74
     *                              ,UMODE(JPOSN),UMOD2(JPOSN)          SDEVIC     75
                  WRITE(MSG(2),1010) TIMX                               SDEVIC     76
                  CALL PRTMSG(2)                                        SDEVIC     77
                  MSG(1)='FAILURE IN HVDC...WRONG COMBINATION OF MODES' SDEVIC     78
                  CALL ASTOP(MSG(1),44)                                 SDEVIC     79
               ELSEIF(UMOD2(JPOSN).EQ.'GAMMA') THEN                     SDEVIC     80
                  VST1 = USETPT(JPOSN) * PII / 180.0                    SDEVIC     81
                  VST2 = USETP2(JPOSN)                                  SDEVIC     82
                  CALL SCALGA (JPOSN, VST1, VST2, TIMX)                 SDEVIC     83
               ELSEIF(UMOD2(JPOSN).EQ.'CURRENT') THEN                   SDEVIC     84
                  VST1 = USETPT(JPOSN) * PII / 180.0                    SDEVIC     85
                  VST2 = USETP2(JPOSN)                                  SDEVIC     86
                  CALL SCALID (JPOSN, VST1, VST2, TIMX, IVC)            SDEVIC     87
               ELSEIF(UMOD2(JPOSN).EQ.'BLOCK') THEN                     SDEVIC     88
                  VST1 = 0.0                                            SDEVIC     89
                  VST2 = 0.0                                            SDEVIC     90
                  CALL SCALID (JPOSN, VST1, VST2, TIMX, IVC)            SDEVIC     91
               ELSEIF(UMOD2(JPOSN).EQ.'VOLTAGE') THEN                   SDEVIC     92
                  VST1 = USETPT(JPOSN) * PII / 180.0                    SDEVIC     93
                  VST2 = USETP2(JPOSN)                                  SDEVIC     94
                  CALL SCAGVD (JPOSN, VST1, VST2, TIMX, IVC)            SDEVIC     95
               ELSEIF(UMOD2(JPOSN).EQ.'BYPASS'                          SDEVIC     96
     1            .OR.UMOD2(JPOSN).EQ.'COMFAIL') THEN                   SDEVIC     97
                  VST1 = 0.0                                            SDEVIC     98
                  VST2 = 0.0                                            SDEVIC     99
                  CALL SCAGVD (JPOSN, VST1, VST2, TIMX, IVC)            SDEVIC    100
               ENDIF                                                    SDEVIC    101
C                                                                       SDEVIC    102
            ELSEIF(UMODE(JPOSN).EQ.'GAMMA')THEN                         SDEVIC    103
               IF(UMOD2(JPOSN).EQ.'NONE') THEN                          SDEVIC    104
C                                                                       SDEVIC    105
C                 Converter is LC gamma controlled.                     SDEVIC    106
C                                                                       SDEVIC    107
                  VST = USETPT(JPOSN) * PII / 180.0                     SDEVIC    108
C                                                                       SDEVIC    109
                  CALL SCGAMA (JPOSN, VST,TIMX)                         SDEVIC    110
C                                                                       SDEVIC    111
               ELSEIF(UMOD2(JPOSN).EQ.'ALPHA') THEN                     SDEVIC    112
                  VST2 = USETPT(JPOSN)                                  SDEVIC    113
                  VST1 = USETP2(JPOSN) * PII / 180.0                    SDEVIC    114
                  CALL SCALGA (JPOSN, VST1, VST2, TIMX)                 SDEVIC    115
               ELSEIF(UMOD2(JPOSN).EQ.'GAMMA') THEN                     SDEVIC    116
                  WRITE(MSG(1),1000) DCCNAM(JPOSN)                      SDEVIC    117
     *                              ,UMODE(JPOSN),UMOD2(JPOSN)          SDEVIC    118
                  WRITE(MSG(2),1010) TIMX                               SDEVIC    119
                  CALL PRTMSG(2)                                        SDEVIC    120
                  MSG(1)='FAILURE IN HVDC...WRONG COMBINATION OF MODES' SDEVIC    121
                  CALL ASTOP(MSG(1),44)                                 SDEVIC    122
               ELSEIF(UMOD2(JPOSN).EQ.'CURRENT') THEN                   SDEVIC    123
                  VST1 = USETPT(JPOSN)                                  SDEVIC    124
                  VST2 = USETP2(JPOSN)                                  SDEVIC    125
                  CALL SCGAID (JPOSN, VST1, VST2, TIMX, IVC)            SDEVIC    126
               ELSEIF(UMOD2(JPOSN).EQ.'BLOCK') THEN                     SDEVIC    127
                  VST1 = 0.0                                            SDEVIC    128
                  VST2 = 0.0                                            SDEVIC    129
                  CALL SCALID (JPOSN, VST1, VST2, TIMX, IVC)            SDEVIC    130
               ELSEIF(UMOD2(JPOSN).EQ.'VOLTAGE') THEN                   SDEVIC    131
                  VST1 = USETPT(JPOSN)                                  SDEVIC    132
                  VST2 = USETP2(JPOSN)                                  SDEVIC    133
                  IVC=2                                                 SDEVIC    134
                  CALL SCAGVD (JPOSN, VST1, VST2, TIMX, IVC)            SDEVIC    135
               ELSEIF(UMOD2(JPOSN).EQ.'BYPASS'                          SDEVIC    136
     *            .OR.UMOD2(JPOSN).EQ.'COMFAIL') THEN                   SDEVIC    137
                  VST1 = 0.0                                            SDEVIC    138
                  VST2 = 0.0                                            SDEVIC    139
                  CALL SCAGVD (JPOSN, VST1, VST2, TIMX, IVC)            SDEVIC    140
               ENDIF                                                    SDEVIC    141
C                                                                       SDEVIC    142
C                                                                       SDEVIC    143
            ELSEIF(UMODE(JPOSN).EQ.'CURRENT') THEN                      SDEVIC    144
               IF(UMOD2(JPOSN).EQ.'NONE') THEN                          SDEVIC    145
C                                                                       SDEVIC    146
C                 Converter is LC current controlled.                   SDEVIC    147
C                                                                       SDEVIC    148
                  VST=USETPT(JPOSN)                                     SDEVIC    149
                  CALL SCCURR (JPOSN,VST,TIMX,IVC)                      SDEVIC    150
C                                                                       SDEVIC    151
               ELSEIF(UMOD2(JPOSN).EQ.'ALPHA') THEN                     SDEVIC    152
                  VST2 = USETPT(JPOSN)                                  SDEVIC    153
                  VST1 = USETP2(JPOSN) * PII / 180.0                    SDEVIC    154
                  CALL SCALID (JPOSN, VST1, VST2, TIMX, IVC)            SDEVIC    155
               ELSEIF(UMOD2(JPOSN).EQ.'GAMMA') THEN                     SDEVIC    156
                  VST2 = USETPT(JPOSN)                                  SDEVIC    157
                  VST1 = USETP2(JPOSN)                                  SDEVIC    158
                  CALL SCGAID (JPOSN, VST1, VST2, TIMX, IVC)            SDEVIC    159
               ELSEIF(UMOD2(JPOSN).EQ.'CURRENT'                         SDEVIC    160
     *            .OR.UMOD2(JPOSN).EQ.'VOLTAGE') THEN                   SDEVIC    161
                  WRITE(MSG(1),1000) DCCNAM(JPOSN)                      SDEVIC    162
     *                              ,UMODE(JPOSN),UMOD2(JPOSN)          SDEVIC    163
                  WRITE(MSG(2),1010) TIMX                               SDEVIC    164
                  CALL PRTMSG(2)                                        SDEVIC    165
                  MSG(1)='FAILURE IN HVDC...WRONG COMBINATION OF MODES' SDEVIC    166
                  CALL ASTOP(MSG(1),44)                                 SDEVIC    167
               ELSEIF(UMOD2(JPOSN).EQ.'BLOCK') THEN                     SDEVIC    168
                  VST1 = 0.0                                            SDEVIC    169
                  VST2 = 0.0                                            SDEVIC    170
                  CALL SCALID (JPOSN, VST1, VST2, TIMX, IVC)            SDEVIC    171
               ELSEIF(UMOD2(JPOSN).EQ.'BYPASS'                          SDEVIC    172
     *            .OR.UMOD2(JPOSN).EQ.'COMFAIL') THEN                   SDEVIC    173
                  VST1 = 0.0                                            SDEVIC    174
                  VST2 = 0.0                                            SDEVIC    175
                  CALL SCAGVD (JPOSN, VST1, VST2, TIMX, IVC)            SDEVIC    176
               ENDIF                                                    SDEVIC    177
C                                                                       SDEVIC    178
C                                                                       SDEVIC    179
            ELSEIF(UMODE(JPOSN).EQ.'BLOCK') THEN                        SDEVIC    180
               IF(UMOD2(JPOSN).EQ.'NONE') THEN                          SDEVIC    181
C                                                                       SDEVIC    182
C                 Converter is LC current controlled.                   SDEVIC    183
C                                                                       SDEVIC    184
                  VST = 0.0                                             SDEVIC    185
                  CALL SCCURR (JPOSN,VST,TIMX,IVC)                      SDEVIC    186
C                                                                       SDEVIC    187
               ELSE                                                     SDEVIC    188
                  VST1 = 0.0                                            SDEVIC    189
                  VST2 = 0.0                                            SDEVIC    190
                  CALL SCALID (JPOSN, VST1, VST2, TIMX, IVC)            SDEVIC    191
               ENDIF                                                    SDEVIC    192
C                                                                       SDEVIC    193
C                                                                       SDEVIC    194
            ELSEIF(UMODE(JPOSN).EQ.'VOLTAGE') THEN                      SDEVIC    195
               IF(UMOD2(JPOSN).EQ.'NONE') THEN                          SDEVIC    196
C                                                                       SDEVIC    197
C                 Converter is voltage controlled.                      SDEVIC    198
C                                                                       SDEVIC    199
                  VST=USETPT(JPOSN)                                     SDEVIC    200
                  CALL SCVOLT (JPOSN,VST,TIMX,IVC)                      SDEVIC    201
C                                                                       SDEVIC    202
               ELSEIF(UMOD2(JPOSN).EQ.'ALPHA') THEN                     SDEVIC    203
                  VST2 = USETPT(JPOSN)                                  SDEVIC    204
                  VST1 = USETP2(JPOSN) * PII / 180.0                    SDEVIC    205
                  CALL SCAGVD (JPOSN, VST1, VST2, TIMX, IVC)            SDEVIC    206
               ELSEIF(UMOD2(JPOSN).EQ.'GAMMA') THEN                     SDEVIC    207
                  VST2 = USETPT(JPOSN)                                  SDEVIC    208
                  VST1 = USETP2(JPOSN)                                  SDEVIC    209
                  IVC=2                                                 SDEVIC    210
                  CALL SCAGVD (JPOSN, VST1, VST2, TIMX, IVC)            SDEVIC    211
               ELSEIF(UMOD2(JPOSN).EQ.'CURRENT'                         SDEVIC    212
     *            .OR.UMOD2(JPOSN).EQ.'VOLTAGE') THEN                   SDEVIC    213
                  WRITE(MSG(1),1000) DCCNAM(JPOSN)                      SDEVIC    214
     *                              ,UMODE(JPOSN),UMOD2(JPOSN)          SDEVIC    215
                  WRITE(MSG(2),1010) TIMX                               SDEVIC    216
                  CALL PRTMSG(2)                                        SDEVIC    217
                  MSG(1)='FAILURE IN HVDC...WRONG COMBINATION OF MODES' SDEVIC    218
                  CALL ASTOP(MSG(1),44)                                 SDEVIC    219
               ELSEIF(UMOD2(JPOSN).EQ.'BLOCK') THEN                     SDEVIC    220
                  VST1 = 0.0                                            SDEVIC    221
                  VST2 = 0.0                                            SDEVIC    222
                  CALL SCALID (JPOSN, VST1, VST2, TIMX, IVC)            SDEVIC    223
               ELSEIF(UMOD2(JPOSN).EQ.'BYPASS'                          SDEVIC    224
     *            .OR.UMOD2(JPOSN).EQ.'COMFAIL') THEN                   SDEVIC    225
                  VST1 = 0.0                                            SDEVIC    226
                  VST2 = 0.0                                            SDEVIC    227
                  CALL SCAGVD (JPOSN, VST1, VST2, TIMX, IVC)            SDEVIC    228
               ENDIF                                                    SDEVIC    229
C                                                                       SDEVIC    230
            ELSEIF(UMODE(JPOSN).EQ.'BYPASS'                             SDEVIC    231
     *         .OR.UMODE(JPOSN).EQ.'COMFAIL') THEN                      SDEVIC    232
               IF(UMOD2(JPOSN).EQ.'NONE') THEN                          SDEVIC    233
C                                                                       SDEVIC    234
C                 Converter is voltage controlled.                      SDEVIC    235
C                                                                       SDEVIC    236
                  VST = 0.0                                             SDEVIC    237
                  CALL SCVOLT (JPOSN,VST,TIMX,IVC)                      SDEVIC    238
               ELSE                                                     SDEVIC    239
                  VST2 = 0.0                                            SDEVIC    240
                  VST1 = 0.0                                            SDEVIC    241
                  CALL SCAGVD (JPOSN, VST1, VST2, TIMX, IVC)            SDEVIC    242
               ENDIF                                                    SDEVIC    243
C                                                                       SDEVIC    244
            END IF                                                      SDEVIC    245
C                                                                       SDEVIC    246
         END IF                                                         SDEVIC    247
20    CONTINUE                                                          SDEVIC    248
C                                                                       SDEVIC    249
C     Determine the current for voltage controlled breakers.            SDEVIC    250
C                                                                       SDEVIC    251
      DO 40 K = 1, IBDC                                                 SDEVIC    252
         IF(IDBSRT(K).NE.0) THEN                                        SDEVIC    253
            JPOSN = IDBSRT(K)                                           SDEVIC    254
            IF(IBSTAT(JPOSN).NE.IOPEND) THEN                            SDEVIC    255
C                                                                       SDEVIC    256
C     Breaker is voltage controlled.                                    SDEVIC    257
C                                                                       SDEVIC    258
               CALL SBVOLT(JPOSN)                                       SDEVIC    259
            END IF                                                      SDEVIC    260
         END IF                                                         SDEVIC    261
40    CONTINUE                                                          SDEVIC    262
C                                                                       SDEVIC    263
C---------------------------------------------------------------------  SDEVIC    264
C                                                                       SDEVIC    265
      RETURN                                                            SDEVIC    266
C                                                                       SDEVIC    267
C---------------------------------------------------------------------  SDEVIC    268
C                                                                       SDEVIC    269
 1000 FORMAT(' *** CONVERTER "', A,'"  MODES "', A,'" & "', A)          SDEVIC    270
 1010 FORMAT('     HAS NON-ALLOWED COMBINATION OF MODES AT TIME =',     SDEVIC    271
     *F10.4,' SECONDS.')                                                SDEVIC    272
      END                                                               SDEVIC    273
