You are on page 1of 12

!

=======================================================================
! Generated by : PSCAD v4.6.3.0
!
! Warning: The content of this file is automatically generated.
! Do not modify, as any changes made here will be lost!
!-----------------------------------------------------------------------
! Component : Main
! Description :
!-----------------------------------------------------------------------

!=======================================================================

SUBROUTINE MainDyn()

!---------------------------------------
! Standard includes
!---------------------------------------

INCLUDE 'nd.h'
INCLUDE 'emtconst.h'
INCLUDE 'emtstor.h'
INCLUDE 's0.h'
INCLUDE 's1.h'
INCLUDE 's2.h'
INCLUDE 's4.h'
INCLUDE 'branches.h'
INCLUDE 'pscadv3.h'
INCLUDE 'fnames.h'
INCLUDE 'radiolinks.h'
INCLUDE 'matlab.h'
INCLUDE 'rtconfig.h'

!---------------------------------------
! Function/Subroutine Declarations
!---------------------------------------

!---------------------------------------
! Variable Declarations
!---------------------------------------

! Subroutine Arguments

! Electrical Node Indices

! Control Signals
REAL Vload, Iload, RT_1, RT_2, VCO
REAL RT_3, RT_4, Vsource

! Internal Variables
REAL RVD1_1, RVD1_2, RVD1_3, RVD1_4

! Indexing variables
INTEGER ICALL_NO ! Module call num
INTEGER ISTOF, IT_0 ! Storage Indices
INTEGER SS, INODE, IBRCH ! SS/Node/Branch/Xfmr

!---------------------------------------
! Local Indices
!---------------------------------------

! Dsdyn <-> Dsout transfer index storage

NTXFR = NTXFR + 1

TXFR(NTXFR,1) = NSTOL
TXFR(NTXFR,2) = NSTOI
TXFR(NTXFR,3) = NSTOF
TXFR(NTXFR,4) = NSTOC

! Define electric network subsystem number

SS = NODE(NNODE+1)

! Increment and assign runtime configuration call indices

ICALL_NO = NCALL_NO
NCALL_NO = NCALL_NO + 1

! Increment global storage indices

ISTOF = NSTOF
NSTOF = NSTOF + 8
NPGB = NPGB + 4
INODE = NNODE + 2
NNODE = NNODE + 8
IBRCH = NBRCH(SS)
NBRCH(SS) = NBRCH(SS) + 10
NCSCS = NCSCS + 0
NCSCR = NCSCR + 0

!---------------------------------------
! Transfers from storage arrays
!---------------------------------------

Vload = STOF(ISTOF + 1)
Iload = STOF(ISTOF + 2)
RT_1 = STOF(ISTOF + 3)
RT_2 = STOF(ISTOF + 4)
VCO = STOF(ISTOF + 5)
RT_3 = STOF(ISTOF + 6)
RT_4 = STOF(ISTOF + 7)
Vsource = STOF(ISTOF + 8)

!---------------------------------------
! Electrical Node Lookup
!---------------------------------------

!---------------------------------------
! Configuration of Models
!---------------------------------------

IF ( TIMEZERO ) THEN
FILENAME = 'Main.dta'
CALL EMTDC_OPENFILE
SECTION = 'DATADSD:'
CALL EMTDC_GOTOSECTION
ENDIF
!---------------------------------------
! Generated code from module definition
!---------------------------------------

! 70:[const] Real Constant

RT_1 = 60.0

! 80:[vco] Voltage-Controlled Oscillator


! Voltage Controlled Oscillator
VCO = STORF(NSTORF)
IF(VCO.GE. TWO_PI) VCO = VCO - TWO_PI
IF(VCO.LE.-TWO_PI) VCO = VCO + TWO_PI
RT_3 = SIN(VCO)
RT_2 = COS(VCO)
STORF(NSTORF) = VCO + DELT*RT_1*TWO_PI
VCO = VCO*BY180_PI
NSTORF = NSTORF + 1

! 1:[peswitch] Power electronic switch


! Power Electronic Switch Model: Diode
CALL COMPONENT_ID(ICALL_NO,400587730)
CALL PESWITCH1_EXE(SS, (IBRCH+1), 1, 0.0)

! 1:[peswitch] Power electronic switch


! Power Electronic Switch Model: Diode
CALL COMPONENT_ID(ICALL_NO,1355933753)
CALL PESWITCH1_EXE(SS, (IBRCH+5), 1, 0.0)

! 1:[peswitch] Power electronic switch


! Power Electronic Switch Model: Diode
CALL COMPONENT_ID(ICALL_NO,976340957)
CALL PESWITCH1_EXE(SS, (IBRCH+7), 1, 0.0)

! 1:[peswitch] Power electronic switch


! Power Electronic Switch Model: Diode
CALL COMPONENT_ID(ICALL_NO,1513256542)
CALL PESWITCH1_EXE(SS, (IBRCH+2), 1, 0.0)

! 1:[peswitch] Power electronic switch


! Power Electronic Switch Model: Diode
CALL COMPONENT_ID(ICALL_NO,1322216231)
CALL PESWITCH1_EXE(SS, (IBRCH+4), 1, 0.0)

! 1:[peswitch] Power electronic switch


! Power Electronic Switch Model: Diode
CALL COMPONENT_ID(ICALL_NO,1120014030)
CALL PESWITCH1_EXE(SS, (IBRCH+6), 1, 0.0)

! 1:[source_1] Single Phase Voltage Source Model 2 'AC Source'


! Single Phase AC source: Type: Ideal
RVD1_1 = RTCF(NRTCF)
RVD1_2 = RTCF(NRTCF+1)
RVD1_3 = RTCF(NRTCF+2)
RVD1_4 = RTCF(NRTCF+3)
NRTCF = NRTCF + 4
CALL EMTDC_1PVSRC(SS, (IBRCH+3),RVD1_4,1,RVD1_1,RVD1_2,RVD1_3)

! 1:[source_1] Single Phase Voltage Source Model 2 'AC Source'


! Single Phase AC source: Type: Ideal
RVD1_1 = RTCF(NRTCF)
RVD1_2 = RTCF(NRTCF+1)
RVD1_3 = RTCF(NRTCF+2)
RVD1_4 = RTCF(NRTCF+3)
NRTCF = NRTCF + 4
CALL EMTDC_1PVSRC(SS, (IBRCH+8),RVD1_4,1,RVD1_1,RVD1_2,RVD1_3)

! 1:[source_1] Single Phase Voltage Source Model 2 'AC Source'


! Single Phase AC source: Type: Ideal
RVD1_1 = RTCF(NRTCF)
RVD1_2 = RTCF(NRTCF+1)
RVD1_3 = RTCF(NRTCF+2)
RVD1_4 = RTCF(NRTCF+3)
NRTCF = NRTCF + 4
CALL EMTDC_1PVSRC(SS, (IBRCH+9),RVD1_4,1,RVD1_1,RVD1_2,RVD1_3)

!---------------------------------------
! Feedbacks and transfers to storage
!---------------------------------------

STOF(ISTOF + 1) = Vload
STOF(ISTOF + 2) = Iload
STOF(ISTOF + 3) = RT_1
STOF(ISTOF + 4) = RT_2
STOF(ISTOF + 5) = VCO
STOF(ISTOF + 6) = RT_3
STOF(ISTOF + 7) = RT_4
STOF(ISTOF + 8) = Vsource

!---------------------------------------
! Transfer to Exports
!---------------------------------------

!---------------------------------------
! Close Model Data read
!---------------------------------------

IF ( TIMEZERO ) CALL EMTDC_CLOSEFILE


RETURN
END

!=======================================================================

SUBROUTINE MainOut()

!---------------------------------------
! Standard includes
!---------------------------------------

INCLUDE 'nd.h'
INCLUDE 'emtconst.h'
INCLUDE 'emtstor.h'
INCLUDE 's0.h'
INCLUDE 's1.h'
INCLUDE 's2.h'
INCLUDE 's4.h'
INCLUDE 'branches.h'
INCLUDE 'pscadv3.h'
INCLUDE 'fnames.h'
INCLUDE 'radiolinks.h'
INCLUDE 'matlab.h'
INCLUDE 'rtconfig.h'

!---------------------------------------
! Function/Subroutine Declarations
!---------------------------------------

REAL EMTDC_VVDC !
REAL RMS3 ! 'Instantaneous RMS Measurement'
REAL VBRANCH ! Voltage across the branch

!---------------------------------------
! Variable Declarations
!---------------------------------------

! Electrical Node Indices


INTEGER NT_1, NT_4

! Control Signals
REAL Vload, Iload, RT_1, RT_4, Vsource

! Internal Variables

! Indexing variables
INTEGER ICALL_NO ! Module call num
INTEGER ISTOL, ISTOI, ISTOF, ISTOC, IT_0 ! Storage Indices
INTEGER IPGB ! Control/Monitoring
INTEGER SS, INODE, IBRCH ! SS/Node/Branch/Xfmr
!---------------------------------------
! Local Indices
!---------------------------------------

! Dsdyn <-> Dsout transfer index storage

NTXFR = NTXFR + 1

ISTOL = TXFR(NTXFR,1)
ISTOI = TXFR(NTXFR,2)
ISTOF = TXFR(NTXFR,3)
ISTOC = TXFR(NTXFR,4)

! Define electric network subsystem number

SS = NODE(NNODE+1)

! Increment and assign runtime configuration call indices

ICALL_NO = NCALL_NO
NCALL_NO = NCALL_NO + 1

! Increment global storage indices

IPGB = NPGB
NPGB = NPGB + 4
INODE = NNODE + 2
NNODE = NNODE + 8
IBRCH = NBRCH(SS)
NBRCH(SS) = NBRCH(SS) + 10
NCSCS = NCSCS + 0
NCSCR = NCSCR + 0

!---------------------------------------
! Transfers from storage arrays
!---------------------------------------

Vload = STOF(ISTOF + 1)
Iload = STOF(ISTOF + 2)
RT_1 = STOF(ISTOF + 3)
RT_4 = STOF(ISTOF + 7)
Vsource = STOF(ISTOF + 8)

!---------------------------------------
! Electrical Node Lookup
!---------------------------------------

NT_1 = NODE(INODE + 1)
NT_4 = NODE(INODE + 4)

!---------------------------------------
! Configuration of Models
!---------------------------------------
IF ( TIMEZERO ) THEN
FILENAME = 'Main.dta'
CALL EMTDC_OPENFILE
SECTION = 'DATADSO:'
CALL EMTDC_GOTOSECTION
ENDIF
!---------------------------------------
! Generated code from module definition
!---------------------------------------

! 10:[ammeter] Current Meter 'Iload'


Iload = ( CBR((IBRCH+10), SS))

! 20:[voltmetergnd] Voltmeter (Line - Ground) 'Vload'


Vload = EMTDC_VVDC(SS, NT_1, 0)

! 30:[voltmetergnd] Voltmeter (Line - Ground) 'Vsource'


Vsource = EMTDC_VVDC(SS, NT_4, 0)

! 40:[pgb] Output Channel 'Vload'

PGB(IPGB+1) = 1000.0 * Vload

! 50:[pgb] Output Channel 'Vsource'

PGB(IPGB+2) = 1000.0 * Vsource

! 60:[pgb] Output Channel 'Iload'

PGB(IPGB+3) = 1000.0 * Iload

! 70:[const] Real Constant

RT_1 = 60.0

! 90:[rms-inst] Single Phase RMS Meter


RT_4 = RMS3( Vsource , 0.02 )

! 100:[pgb] Output Channel 'Vsrc_rms'

PGB(IPGB+4) = 1000.0 * RT_4

!---------------------------------------
! Feedbacks and transfers to storage
!---------------------------------------

STOF(ISTOF + 1) = Vload
STOF(ISTOF + 2) = Iload
STOF(ISTOF + 3) = RT_1
STOF(ISTOF + 7) = RT_4
STOF(ISTOF + 8) = Vsource
!---------------------------------------
! Close Model Data read
!---------------------------------------

IF ( TIMEZERO ) CALL EMTDC_CLOSEFILE


RETURN
END

!=======================================================================

SUBROUTINE MainDyn_Begin()

!---------------------------------------
! Standard includes
!---------------------------------------

INCLUDE 'nd.h'
INCLUDE 'emtconst.h'
INCLUDE 's0.h'
INCLUDE 's1.h'
INCLUDE 's4.h'
INCLUDE 'branches.h'
INCLUDE 'pscadv3.h'
INCLUDE 'radiolinks.h'
INCLUDE 'rtconfig.h'

!---------------------------------------
! Function/Subroutine Declarations
!---------------------------------------

!---------------------------------------
! Variable Declarations
!---------------------------------------

! Subroutine Arguments

! Electrical Node Indices

! Control Signals
REAL RT_1

! Internal Variables

! Indexing variables
INTEGER ICALL_NO ! Module call num
INTEGER IT_0 ! Storage Indices
INTEGER SS, INODE, IBRCH ! SS/Node/Branch/Xfmr

!---------------------------------------
! Local Indices
!---------------------------------------
! Define electric network subsystem number

SS = NODE(NNODE+1)

! Increment and assign runtime configuration call indices

ICALL_NO = NCALL_NO
NCALL_NO = NCALL_NO + 1

! Increment global storage indices

INODE = NNODE + 2
NNODE = NNODE + 8
IBRCH = NBRCH(SS)
NBRCH(SS) = NBRCH(SS) + 10
NCSCS = NCSCS + 0
NCSCR = NCSCR + 0

!---------------------------------------
! Electrical Node Lookup
!---------------------------------------

!---------------------------------------
! Generated code from module definition
!---------------------------------------

! 70:[const] Real Constant


RT_1 = 60.0

! 80:[vco] Voltage-Controlled Oscillator

! 1:[peswitch] Power electronic switch


CALL PESWITCH1_CFG(0, 0,0.01, 1000000.0, 100000.0, 100000.0, 0.001&
&, 0.0)

! 1:[peswitch] Power electronic switch


CALL PESWITCH1_CFG(0, 0,0.01, 1000000.0, 100000.0, 100000.0, 0.001&
&, 0.0)

! 1:[peswitch] Power electronic switch


CALL PESWITCH1_CFG(0, 0,0.01, 1000000.0, 100000.0, 100000.0, 0.001&
&, 0.0)

! 1:[peswitch] Power electronic switch


CALL PESWITCH1_CFG(0, 0,0.01, 1000000.0, 100000.0, 100000.0, 0.001&
&, 0.0)

! 1:[peswitch] Power electronic switch


CALL PESWITCH1_CFG(0, 0,0.01, 1000000.0, 100000.0, 100000.0, 0.001&
&, 0.0)

! 1:[peswitch] Power electronic switch


CALL PESWITCH1_CFG(0, 0,0.01, 1000000.0, 100000.0, 100000.0, 0.001&
&, 0.0)

! 1:[source_1] Single Phase Voltage Source Model 2 'AC Source'


CALL E_1PVSRC_CFG(1,0,6,0.24,60.0,0.0,0.0,0.0,0.0,0.0,0.0,0.01)

! 1:[source_1] Single Phase Voltage Source Model 2 'AC Source'


CALL E_1PVSRC_CFG(1,0,6,0.24,60.0,120.0,0.0,0.0,0.0,0.0,0.0,0.01)

! 1:[source_1] Single Phase Voltage Source Model 2 'AC Source'


CALL E_1PVSRC_CFG(1,0,6,0.24,60.0,240.0,0.0,0.0,0.0,0.0,0.0,0.01)

RETURN
END

!=======================================================================

SUBROUTINE MainOut_Begin()

!---------------------------------------
! Standard includes
!---------------------------------------

INCLUDE 'nd.h'
INCLUDE 'emtconst.h'
INCLUDE 's0.h'
INCLUDE 's1.h'
INCLUDE 's4.h'
INCLUDE 'branches.h'
INCLUDE 'pscadv3.h'
INCLUDE 'radiolinks.h'
INCLUDE 'rtconfig.h'

!---------------------------------------
! Function/Subroutine Declarations
!---------------------------------------

!---------------------------------------
! Variable Declarations
!---------------------------------------

! Subroutine Arguments

! Electrical Node Indices


INTEGER NT_1, NT_4

! Control Signals
REAL RT_1

! Internal Variables

! Indexing variables
INTEGER ICALL_NO ! Module call num
INTEGER IT_0 ! Storage Indices
INTEGER SS, INODE, IBRCH ! SS/Node/Branch/Xfmr

!---------------------------------------
! Local Indices
!---------------------------------------

! Define electric network subsystem number

SS = NODE(NNODE+1)

! Increment and assign runtime configuration call indices

ICALL_NO = NCALL_NO
NCALL_NO = NCALL_NO + 1

! Increment global storage indices

INODE = NNODE + 2
NNODE = NNODE + 8
IBRCH = NBRCH(SS)
NBRCH(SS) = NBRCH(SS) + 10
NCSCS = NCSCS + 0
NCSCR = NCSCR + 0

!---------------------------------------
! Electrical Node Lookup
!---------------------------------------

NT_1 = NODE(INODE + 1)
NT_4 = NODE(INODE + 4)

!---------------------------------------
! Generated code from module definition
!---------------------------------------

! 40:[pgb] Output Channel 'Vload'

! 50:[pgb] Output Channel 'Vsource'

! 60:[pgb] Output Channel 'Iload'

! 70:[const] Real Constant


RT_1 = 60.0

! 90:[rms-inst] Single Phase RMS Meter

! 100:[pgb] Output Channel 'Vsrc_rms'

RETURN
END

You might also like