CFPRIME VDEVIC                                                          VDEVIC      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  VDEVIC                                                VDEVIC      3
C---------------------------------------------------------------------  VDEVIC      4
C                                                                       VDEVIC      5
C               *****     VDEVIC  ROUTINE   *****                       VDEVIC      6
C                                                                       VDEVIC      7
CD--------------------------------------------------------------------- VDEVIC      8
CD                                                                      VDEVIC      9
CD        PURPOSE:  To control building of converter contributions to   VDEVIC     10
CD                  G matrix.                                           VDEVIC     11
CD                                                                      VDEVIC     12
CD                                                                      VDEVIC     13
CD        DEFINITION OF LOCAL VARIABLES:                                VDEVIC     14
CD                  I      - 'do' loop index.                           VDEVIC     15
CD                  N      - 'do' loop index.                           VDEVIC     16
CD                  JPOSN   -  storage position for dc information.     VDEVIC     17
CD                  VST    -  temporary storage of set point.           VDEVIC     18
CD                                                                      VDEVIC     19
CD                                                                      VDEVIC     20
CD        SUBROUTINES REQUIRED:  VBCURR, VBVOLT, VCALPA,                VDEVIC     21
CD                               VCCURR, VCGAMA, VCVOLT                 VDEVIC     22
CD                                                                      VDEVIC     23
CD--------------------------------------------------------------------- VDEVIC     24
      INCLUDE 'PARX.INS'                                                VDEVIC     25
      INCLUDE 'CNPARX.INS'                                              VDEVIC     26
      INCLUDE 'GRDC01.INS'                                              VDEVIC     27
      INCLUDE 'UDCA.INS'                                                VDEVIC     28
      INCLUDE 'UDCJ.INS'                                                VDEVIC     29
C                                                                       VDEVIC     30
C---------------------------------------------------------------------  VDEVIC     31
C                                                                       VDEVIC     32
      DO 20 I = 1, IDCPTR                                               VDEVIC     33
         IF(IDCSRT(I) .NE. 0) THEN                                      VDEVIC     34
            JPOSN = IDCSRT(I)                                           VDEVIC     35
C                                                                       VDEVIC     36
            IF(UMODE(JPOSN).EQ.'ALPHA')THEN                             VDEVIC     37
               IF(UMOD2(JPOSN).EQ.'NONE') THEN                          VDEVIC     38
C                                                                       VDEVIC     39
C                 Converter is line commutated alpha controlled.        VDEVIC     40
C                                                                       VDEVIC     41
                  VST = USETPT(JPOSN) * PII / 180.0                     VDEVIC     42
                  CALL VCALPA (JPOSN, VST)                              VDEVIC     43
               ELSEIF(UMOD2(JPOSN).EQ.'GAMMA') THEN                     VDEVIC     44
                  VST1 = USETPT(JPOSN) * PII / 180.0                    VDEVIC     45
                  VST2 = USETP2(JPOSN)                                  VDEVIC     46
                  CALL VCALGA (JPOSN, VST1, VST2)                       VDEVIC     47
               ELSEIF(UMOD2(JPOSN).EQ.'CURRENT') THEN                   VDEVIC     48
                  VST=USETP2(JPOSN)                                     VDEVIC     49
                  CALL VCCURR (JPOSN, VST)                              VDEVIC     50
               ELSEIF(UMOD2(JPOSN).EQ.'BLOCK') THEN                     VDEVIC     51
                  VST = 0.0                                             VDEVIC     52
                  CALL VCCURR (JPOSN, VST)                              VDEVIC     53
               ENDIF                                                    VDEVIC     54
C                                                                       VDEVIC     55
C                                                                       VDEVIC     56
C                                                                       VDEVIC     57
            ELSEIF(UMODE(JPOSN).EQ.'GAMMA')THEN                         VDEVIC     58
               IF(UMOD2(JPOSN).EQ.'NONE') THEN                          VDEVIC     59
C                                                                       VDEVIC     60
C              Converter is line commutated gamma controlled.           VDEVIC     61
C                                                                       VDEVIC     62
                  VST = USETPT(JPOSN) * PII / 180.0                     VDEVIC     63
                  CALL VCGAMA (JPOSN, VST)                              VDEVIC     64
               ELSEIF(UMOD2(JPOSN).EQ.'ALPHA') THEN                     VDEVIC     65
                  VST1 = USETP2(JPOSN) * PII / 180.0                    VDEVIC     66
                  VST2 = USETPT(JPOSN)                                  VDEVIC     67
                  CALL VCALGA (JPOSN, VST1, VST2)                       VDEVIC     68
               ELSEIF(UMOD2(JPOSN).EQ.'CURRENT') THEN                   VDEVIC     69
                  VST = USETP2(JPOSN)                                   VDEVIC     70
                  CALL VCCURR (JPOSN, VST)                              VDEVIC     71
               ELSEIF(UMOD2(JPOSN).EQ.'BLOCK') THEN                     VDEVIC     72
                  VST = 0.0                                             VDEVIC     73
                  CALL VCCURR (JPOSN, VST)                              VDEVIC     74
               ENDIF                                                    VDEVIC     75
C                                                                       VDEVIC     76
            ELSEIF(UMODE(JPOSN).EQ.'CURRENT') THEN                      VDEVIC     77
C                                                                       VDEVIC     78
C              Converter is current controlled.                         VDEVIC     79
C                                                                       VDEVIC     80
               VST = USETPT(JPOSN)                                      VDEVIC     81
               CALL VCCURR (JPOSN, VST)                                 VDEVIC     82
C                                                                       VDEVIC     83
            ELSEIF(UMODE(JPOSN).EQ.'BLOCK')THEN                         VDEVIC     84
C                                                                       VDEVIC     85
C              Converter is blocked (current controlled)                VDEVIC     86
C                                                                       VDEVIC     87
               VST = 0.0                                                VDEVIC     88
               CALL VCCURR (JPOSN, VST)                                 VDEVIC     89
C                                                                       VDEVIC     90
            ELSEIF(UMODE(JPOSN).EQ.'VOLTAGE') THEN                      VDEVIC     91
               IF(UMOD2(JPOSN).EQ.'BLOCK')THEN                          VDEVIC     92
C                                                                       VDEVIC     93
C                 converter is self commutated blocked                  VDEVIC     94
C                                                                       VDEVIC     95
                  VST = 0.0                                             VDEVIC     96
                  CALL VCCURR (JPOSN, VST)                              VDEVIC     97
               ENDIF                                                    VDEVIC     98
C                                                                       VDEVIC     99
C                                                                       VDEVIC    100
C                                                                       VDEVIC    101
            END IF                                                      VDEVIC    102
C                                                                       VDEVIC    103
         END IF                                                         VDEVIC    104
20    CONTINUE                                                          VDEVIC    105
C                                                                       VDEVIC    106
C     Process current controlled breakers.                              VDEVIC    107
C                                                                       VDEVIC    108
      VST=0.0                                                           VDEVIC    109
      DO 40 I = 1, IDBPTR                                               VDEVIC    110
         IF(IDBSRT(I) .NE. 0) THEN                                      VDEVIC    111
            JPOSN = IDBSRT(I)                                           VDEVIC    112
            CALL VBCURR (JPOSN,VST)                                     VDEVIC    113
            UBCURR(JPOSN) = 0.0                                         VDEVIC    114
         END IF                                                         VDEVIC    115
40    CONTINUE                                                          VDEVIC    116
C                                                                       VDEVIC    117
C     Save injections before voltage control                            VDEVIC    118
C                                                                       VDEVIC    119
      DO 100 I = 1, ISIZEV                                              VDEVIC    120
            XINJSA(I) = XINJVE(I)                                       VDEVIC    121
100   CONTINUE                                                          VDEVIC    122
C                                                                       VDEVIC    123
C                                                                       VDEVIC    124
      DO 120 I = IDCPTR+1, ICDC                                         VDEVIC    125
         IF(IDCSRT(I) .NE. 0)THEN                                       VDEVIC    126
            JPOSN = IDCSRT(I)                                           VDEVIC    127
C                                                                       VDEVIC    128
            IF(UMODE(JPOSN).EQ.'VOLTAGE' .OR.                           VDEVIC    129
     1         UMODE(JPOSN).EQ.'BYPASS' .OR.                            VDEVIC    130
     2         UMODE(JPOSN).EQ.'COMFAIL') THEN                          VDEVIC    131
               IF(UMODE(JPOSN).NE.'VOLTAGE'                             VDEVIC    132
     1            .OR. UMOD2(JPOSN).NE.'BLOCK') THEN                    VDEVIC    133
C                                                                       VDEVIC    134
C              Converter is voltage controlled.                         VDEVIC    135
C                                                                       VDEVIC    136
                  IF(UMODE(JPOSN).EQ.'BYPASS' .OR.                      VDEVIC    137
     2               UMODE(JPOSN).EQ.'COMFAIL') THEN                    VDEVIC    138
                     VST = 0.0                                          VDEVIC    139
                  ELSE                                                  VDEVIC    140
                     VST = USETPT(JPOSN)                                VDEVIC    141
                  ENDIF                                                 VDEVIC    142
                  CALL VCVOLT (JPOSN, VST)                              VDEVIC    143
               ENDIF                                                    VDEVIC    144
C                                                                       VDEVIC    145
C                                                                       VDEVIC    146
C                                                                       VDEVIC    147
            END IF                                                      VDEVIC    148
C                                                                       VDEVIC    149
         END IF                                                         VDEVIC    150
120   CONTINUE                                                          VDEVIC    151
c                                                                       VDEVIC    152
      DO 140 I = IDBPTR+1, IBDC                                         VDEVIC    153
C                                                                       VDEVIC    154
C     Breakers are voltage controlled.                                  VDEVIC    155
C                                                                       VDEVIC    156
         IF(IDBSRT(I) .NE. 0)THEN                                       VDEVIC    157
            JPOSN = IDBSRT(I)                                           VDEVIC    158
C                                                                       VDEVIC    159
C     Obtain the breaker voltage form the associated UDC block.         VDEVIC    160
C                                                                       VDEVIC    161
            VST = UDVAL(IUBBRE(JPOSN))                                  VDEVIC    162
            CALL VBVOLT (JPOSN, VST)                                    VDEVIC    163
         END IF                                                         VDEVIC    164
140   CONTINUE                                                          VDEVIC    165
C                                                                       VDEVIC    166
C---------------------------------------------------------------------  VDEVIC    167
C                                                                       VDEVIC    168
      RETURN                                                            VDEVIC    169
C                                                                       VDEVIC    170
C---------------------------------------------------------------------  VDEVIC    171
C                                                                       VDEVIC    172
      END                                                               VDEVIC    173
