CFPRIME CONVOL                                                          CONVOL      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  CONVOL                                                CONVOL      3
CD -------------------------------------------------------------------  CONVOL      4
CD                                                                      CONVOL      5
CD              *****     CONVOL  ROUTINE   *****                       CONVOL      6
CD                                                                      CONVOL      7
CD -------------------------------------------------------------------  CONVOL      8
CD                                                                      CONVOL      9
CD       PURPOSE:  This subroutine provides the conversion from         CONVOL     10
CD                 the pu voltage of the loadflow to the stability      CONVOL     11
CD                 voltages (in Kv).                                    CONVOL     12
CD                                                                      CONVOL     13
CD                                                                      CONVOL     14
CD       DEFINITION OF LOCAL VARIABLES:                                 CONVOL     15
CD                 I      - 'do' loop index.                            CONVOL     16
CD                 N      -  converter ac bus position.                 CONVOL     17
CD                 N2     -  converter second ac bus position.          CONVOL     18
CD                 JPOSN  -  internal number for DC information.        CONVOL     19
CD                                                                      CONVOL     20
CD -------------------------------------------------------------------  CONVOL     21
      INCLUDE 'PARX.INS'                                                CONVOL     22
      INCLUDE 'GRDC01.INS'                                              CONVOL     23
      INCLUDE 'GRDC02.INS'                                              CONVOL     24
      INCLUDE 'UDCF.INS'                                                CONVOL     25
C                                                                       CONVOL     26
C---------------------------------------------------------------------  CONVOL     27
C                                                                       CONVOL     28
C     Fix up the converter voltages                                     CONVOL     29
C                                                                       CONVOL     30
      DO 20 I = 1, ICDC                                                 CONVOL     31
         IF(IDC(I) .NE. 0)THEN                                          CONVOL     32
            JPOSN = IDC(I)                                              CONVOL     33
            N = IDCBNU(JPOSN)                                           CONVOL     34
            N2 = IDCBN2(JPOSN)                                          CONVOL     35
            IF(N .EQ. 0) THEN                                           CONVOL     36
C                                                                       CONVOL     37
C              1.0 per unit ac infinite bus                             CONVOL     38
C                                                                       CONVOL     39
               VMCONV(JPOSN) = 1.0                                      CONVOL     40
               VACONV(JPOSN) = 0.0                                      CONVOL     41
            ELSE                                                        CONVOL     42
C                                                                       CONVOL     43
               IF(N2 .EQ. 0) THEN                                       CONVOL     44
C                                                                       CONVOL     45
C                 shunt converter                                       CONVOL     46
C                                                                       CONVOL     47
                  VMCONV(JPOSN) = SQRT( DCEA(N) * DCEA(N) +             CONVOL     48
     1                                  DCEB(N) * DCEB(N))              CONVOL     49
                  VACONV(JPOSN) = 0.0                                   CONVOL     50
               ELSE                                                     CONVOL     51
C                                                                       CONVOL     52
C                 series converter                                      CONVOL     53
C                                                                       CONVOL     54
                  VR1 = DCEA(N)                                         CONVOL     55
                  VI1 = DCEB(N)                                         CONVOL     56
                  VRD = VR1 - DCEA(N2)                                  CONVOL     57
                  VID = VI1 - DCEB(N2)                                  CONVOL     58
                  VM1 = SQRT(VR1**2 + VI1**2)                           CONVOL     59
                  VMD = SQRT(VRD**2 + VID**2)                           CONVOL     60
                  IF(VM1.LT.0.05) THEN                                  CONVOL     61
                     ANG1=0.0                                           CONVOL     62
                  ELSE                                                  CONVOL     63
                     ANG1=ATAN2 (VI1, VR1)                              CONVOL     64
                  ENDIF                                                 CONVOL     65
                  IF(VMD.LT.0.00001) THEN                               CONVOL     66
                     ANGD=0.0                                           CONVOL     67
                  ELSE                                                  CONVOL     68
                     ANGD=ATAN2 (VID, VRD)                              CONVOL     69
                  ENDIF                                                 CONVOL     70
                  VMCONV(JPOSN) = VMD                                   CONVOL     71
                  VACONV(JPOSN) = ANG1 - ANGD                           CONVOL     72
               ENDIF                                                    CONVOL     73
            ENDIF                                                       CONVOL     74
            VAHVDC(JPOSN) = VMCONV(JPOSN) * VACDC(JPOSN)                CONVOL     75
         END IF                                                         CONVOL     76
20    CONTINUE                                                          CONVOL     77
C                                                                       CONVOL     78
C---------------------------------------------------------------------  CONVOL     79
C                                                                       CONVOL     80
      RETURN                                                            CONVOL     81
C                                                                       CONVOL     82
C---------------------------------------------------------------------  CONVOL     83
C                                                                       CONVOL     84
      END                                                               CONVOL     85
