! Modified (Mod 2) version of IEEE 34-bus test case with buses added in the middle of line sections
! This gives a better match to the "distributed load" model used in the test case than Mod 1.
! The DSS Line model presently does not support the distributed load concept. Load objects may be attached
! only at buses.  Therefore, midpoint buses are created in this example.

Clear

New object=circuit.ieee34-2
~ basekv=69 pu=1.05 angle=30 mvasc3=200000  !stiffen up a bit over default

! Substation Transformer  -- Modification: Make source very stiff by using artificially low short circuit reactance
New Transformer.SubXF Phases=3 Windings=2 Xhl=0.001 ppm=0    ! Very low %Z and no shunt reactance added
~ wdg=1 bus=sourcebus conn=Delta kv=69    kva=25000   %r=0.0005  ! Set the %r very low
~ wdg=2 bus=800       conn=wye   kv=24.9  kva=25000   %r=0.0005

! import line codes with phase impedance matrices
Redirect        IEEELineCodes.dss   ! assumes original order is ABC rather than BAC

! Define Lines and mid-point buses
New Line.L1      Phases=3 Bus1=800.1.2.3     Bus2=802.1.2.3     LineCode=300  Length=2.58   units=kft
New Line.L2a     Phases=3 Bus1=802.1.2.3     Bus2=mid806.1.2.3  LineCode=300  Length=(1.73 2 /)    units=kft ! use in-line math to divide lenght by 2
New Line.L2b     Phases=3 Bus1=mid806.1.2.3  Bus2=806.1.2.3     LineCode=300  Length=(1.73 2 /)   units=kft
New Line.L3      Phases=3 Bus1=806.1.2.3     Bus2=808.1.2.3     LineCode=300  Length=32.23   units=kft
New Line.L4a     Phases=1 Bus1=808.2         Bus2=Mid810.2      LineCode=303  Length=(5.804 2 /)   units=kft
New Line.L4b     Phases=1 Bus1=Mid810.2      Bus2=810.2         LineCode=303  Length=(5.804 2 /)   units=kft
New Line.L5      Phases=3 Bus1=808.1.2.3     Bus2=812.1.2.3     LineCode=300  Length=37.5   units=kft
New Line.L6      Phases=3 Bus1=812.1.2.3     Bus2=814.1.2.3     LineCode=300  Length=29.73   units=kft
New Line.L7      Phases=3 Bus1=814r.1.2.3    Bus2=850.1.2.3     LineCode=301  Length=0.01   units=kft
New Line.L24     Phases=3 Bus1=850.1.2.3     Bus2=816.1.2.3     LineCode=301  Length=0.31   units=kft
New Line.L8      Phases=1 Bus1=816.1         Bus2=818.1         LineCode=302  Length=1.71   units=kft
New Line.L9a     Phases=3 Bus1=816.1.2.3     Bus2=mid824.1.2.3  LineCode=301  Length=(10.21 2 /)   units=kft
New Line.L9b     Phases=3 Bus1=mid824.1.2.3  Bus2=824.1.2.3     LineCode=301  Length=(10.21 2 /)   units=kft
New Line.L10a    Phases=1 Bus1=818.1         Bus2=mid820.1      LineCode=302  Length=(48.15 2 /)   units=kft
New Line.L10b    Phases=1 Bus1=mid820.1      Bus2=820.1         LineCode=302  Length=(48.15 2 /)   units=kft
New Line.L11a    Phases=1 Bus1=820.1         Bus2=mid822.1      LineCode=302  Length=(13.74 2 /)   units=kft
New Line.L11b    Phases=1 Bus1=mid822.1      Bus2=822.1         LineCode=302  Length=(13.74 2 /)   units=kft
New Line.L12a    Phases=1 Bus1=824.2         Bus2=mid826.2      LineCode=303  Length=(3.03 2 /)   units=kft
New Line.L12b    Phases=1 Bus1=mid826.2      Bus2=826.2         LineCode=303  Length=(3.03 2 /)   units=kft
New Line.L13a    Phases=3 Bus1=824.1.2.3     Bus2=mid828.1.2.3  LineCode=301  Length=(0.84 2 /)   units=kft
New Line.L13b    Phases=3 Bus1=mid828.1.2.3  Bus2=828.1.2.3     LineCode=301  Length=(0.84 2 /)   units=kft
New Line.L14a    Phases=3 Bus1=828.1.2.3     Bus2=mid830.1.2.3  LineCode=301  Length=(20.44 2 /)   units=kft
New Line.L14b    Phases=3 Bus1=mid830.1.2.3  Bus2=830.1.2.3     LineCode=301  Length=(20.44 2 /)   units=kft
New Line.L15     Phases=3 Bus1=830.1.2.3     Bus2=854.1.2.3     LineCode=301  Length=0.52   units=kft
New Line.L16a    Phases=3 Bus1=832.1.2.3     Bus2=mid858.1.2.3  LineCode=301  Length=(4.9 2 /)   units=kft
New Line.L16b    Phases=3 Bus1=mid858.1.2.3  Bus2=858.1.2.3     LineCode=301  Length=(4.9 2 /)   units=kft
New Line.L29a    Phases=3 Bus1=858.1.2.3     Bus2=mid834.1.2.3  LineCode=301  Length=(5.83 2 /)   units=kft
New Line.L29b    Phases=3 Bus1=mid834.1.2.3  Bus2=834.1.2.3     LineCode=301  Length=(5.83 2 /)   units=kft
New Line.L18     Phases=3 Bus1=834.1.2.3     Bus2=842.1.2.3     LineCode=301  Length=0.28   units=kft
New Line.L19a    Phases=3 Bus1=836.1.2.3     Bus2=mid840.1.2.3  LineCode=301  Length=(0.86 2 /)   units=kft
New Line.L19b    Phases=3 Bus1=mid840.1.2.3  Bus2=840.1.2.3     LineCode=301  Length=(0.86 2 /)   units=kft
New Line.L21a    Phases=3 Bus1=842.1.2.3     Bus2=mid844.1.2.3  LineCode=301  Length=(1.35 2 /)   units=kft
New Line.L21b    Phases=3 Bus1=mid844.1.2.3  Bus2=844.1.2.3     LineCode=301  Length=(1.35 2 /)   units=kft
New Line.L22a    Phases=3 Bus1=844.1.2.3     Bus2=mid846.1.2.3  LineCode=301  Length=(3.64 2 /)   units=kft
New Line.L22b    Phases=3 Bus1=mid846.1.2.3  Bus2=846.1.2.3     LineCode=301  Length=(3.64 2 /)   units=kft
New Line.L23a    Phases=3 Bus1=846.1.2.3     Bus2=mid848.1.2.3  LineCode=301  Length=(0.53 2 /)   units=kft
New Line.L23b    Phases=3 Bus1=mid848.1.2.3  Bus2=848.1.2.3     LineCode=301  Length=(0.53 2 /)   units=kft
New Line.L26a    Phases=1 Bus1=854.2         Bus2=mid856.2      LineCode=303  Length=(23.33 2 /)   units=kft
New Line.L26b    Phases=1 Bus1=mid856.2      Bus2=856.2         LineCode=303  Length=(23.33 2 /)   units=kft
New Line.L27     Phases=3 Bus1=854.1.2.3     Bus2=852.1.2.3     LineCode=301  Length=36.83   units=kft
! regulator in here
New Line.L25     Phases=3 Bus1=852r.1.2.3    Bus2=832.1.2.3     LineCode=301  Length=0.01   units=kft

! Y-Y Stepdown transformer Transformer
New Transformer.XFM1  Phases=3 Windings=2 Xhl=4.08
~ wdg=1 bus=832  conn=wye kv=24.9  kva=500    %r=0.95
~ wdg=2 bus=888  conn=Wye kv=4.16  kva=500    %r=0.95

! 9-17-10 858-864 changed to phase A per error report
New Line.L28a    Phases=1 Bus1=858.1         Bus2=mid864.1      LineCode=303  Length=(1.62 2 /)   units=kft
New Line.L28b    Phases=1 Bus1=mid864.1      Bus2=864.1         LineCode=303  Length=(1.62 2 /)   units=kft
New Line.L17a    Phases=3 Bus1=834.1.2.3     Bus2=mid860.1.2.3  LineCode=301  Length=(2.02 2 /)   units=kft
New Line.L17b    Phases=3 Bus1=mid860.1.2.3  Bus2=860.1.2.3     LineCode=301  Length=(2.02 2 /)   units=kft
New Line.L30a    Phases=3 Bus1=860.1.2.3     Bus2=mid836.1.2.3  LineCode=301  Length=(2.68 2 /)   units=kft
New Line.L30b    Phases=3 Bus1=mid836.1.2.3  Bus2=836.1.2.3     LineCode=301  Length=(2.68 2 /)   units=kft
New Line.L20     Phases=3 Bus1=836.1.2.3     Bus2=862.1.2.3     LineCode=301  Length=0.28   units=kft
New Line.L31a    Phases=1 Bus1=862.2         Bus2=mid838.2      LineCode=304  Length=(4.86 2 /)   units=kft
New Line.L31b    Phases=1 Bus1=mid838.2      Bus2=838.2         LineCode=304  Length=(4.86 2 /)   units=kft
New Line.L32     Phases=3 Bus1=888.1.2.3     Bus2=890.1.2.3     LineCode=300  Length=10.56   units=kft

! Capacitors
New Capacitor.C844      Bus1=844        Phases=3        kVAR=300        kV=24.9
New Capacitor.C848      Bus1=848        Phases=3        kVAR=450        kV=24.9

! Regulators - three independent phases
! Regulator 1
new transformer.reg1a phases=1 windings=2 buses=(814.1 814r.1) conns='wye wye' kvs="14.376 14.376" kvas="2000 2000" XHL=.01
~ wdg=1 %r=.0001 wdg=2 %r=.0001 ppm=0
new regcontrol.creg1a transformer=reg1a winding=2 vreg=122 band=2 ptratio=120 ctprim=100 R=2.7 X=1.6
new transformer.reg1b phases=1 windings=2 buses=(814.2 814r.2) conns='wye wye' kvs="14.376 14.376" kvas="2000 2000" XHL=.01
~ wdg=1 %r=.0001 wdg=2 %r=.0001 ppm=0
new regcontrol.creg1b transformer=reg1b winding=2 vreg=122 band=2 ptratio=120 ctprim=100 R=2.7 X=1.6
new transformer.reg1c phases=1 windings=2 buses=(814.3 814r.3) conns='wye wye' kvs="14.376 14.376" kvas="2000 2000" XHL=.01
~ wdg=1 %r=.0001 wdg=2 %r=.0001 ppm=0
new regcontrol.creg1c transformer=reg1c winding=2 vreg=122 band=2 ptratio=120 ctprim=100 R=2.7 X=1.6

! Regulator 2
new transformer.reg2a phases=1 windings=2 buses=(852.1 852r.1) conns='wye wye' kvs="14.376 14.376" kvas="2000 2000" XHL=.01
~ wdg=1 %r=.0001 wdg=2 %r=.0001 ppm=0
new regcontrol.creg2a transformer=reg2a winding=2 vreg=124 band=2 ptratio=120 ctprim=100 R=2.5 X=1.5 delay=30
new transformer.reg2b phases=1 windings=2 buses=(852.2 852r.2) conns='wye wye' kvs="14.376 14.376" kvas="2000 2000" XHL=.01
~ wdg=1 %r=.0001 wdg=2 %r=.0001 ppm=0
new regcontrol.creg2b transformer=reg2b winding=2 vreg=124 band=2 ptratio=120 ctprim=100 R=2.5 X=1.5 delay=30
new transformer.reg2c phases=1 windings=2 buses=(852.3 852r.3) conns='wye wye' kvs="14.376 14.376" kvas="2000 2000" XHL=.01
~ wdg=1 %r=.0001 wdg=2 %r=.0001 ppm=0
new regcontrol.creg2c transformer=reg2c winding=2 vreg=124 band=2 ptratio=120 ctprim=100 R=2.5 X=1.5 delay=30

! spot loads
New Load.S860       Bus1=860     Phases=3 Conn=Wye   Model=1 kV= 24.900 kW=  60.0 kVAR=  48.0
New Load.S840       Bus1=840     Phases=3 Conn=Wye   Model=5 kV= 24.900 kW=  27.0 kVAR=  21.0
New Load.S844       Bus1=844     Phases=3 Conn=Wye   Model=2 kV= 24.900 kW= 405.0 kVAR= 315.0
New Load.S848       Bus1=848     Phases=3 Conn=Delta Model=1 kV= 24.900 kW=  60.0 kVAR=  48.0
New Load.S830a      Bus1=830.1.2 Phases=1 Conn=Delta Model=2 kV= 24.900 kW=  10.0 kVAR=   5.0
New Load.S830b      Bus1=830.2.3 Phases=1 Conn=Delta Model=2 kV= 24.900 kW=  10.0 kVAR=   5.0
New Load.S830c      Bus1=830.3.1 Phases=1 Conn=Delta Model=2 kV= 24.900 kW=  25.0 kVAR=  10.0
New Load.S890       Bus1=890     Phases=3 Conn=Delta Model=5 kV=  4.160 kW= 450.0 kVAR= 225.0

! distributed loads connected to line mid points
New Load.D802_806b Bus1=Mid806.2   Phases=1 Conn=Wye   Model=1 kV= 14.376 kW=  30   kVAR=  15
New Load.D802_806c Bus1=Mid806.3   Phases=1 Conn=Wye   Model=1 kV= 14.376 kW=  25   kVAR=  14
New Load.D808_810b Bus1=Mid810.2   Phases=1 Conn=Wye   Model=5 kV= 14.376 kW=  16   kVAR=   8
New Load.D818_820a Bus1=mid820.1   Phases=1 Conn=Wye   Model=2 kV= 14.376 kW=  34   kVAR=  17
New Load.D820_822a Bus1=mid822.1   Phases=1 Conn=Wye   Model=1 kV= 14.376 kW= 135   kVAR=  70
New Load.D816_824b Bus1=mid824.2.3 Phases=1 Conn=Delta Model=5 kV= 24.900 kW=   5   kVAR=   2
New Load.D824_826b Bus1=mid826.2   Phases=1 Conn=Wye   Model=5 kV= 14.376 kW=  40.0 kVAR=  20.0
New Load.D824_828c Bus1=mid828.3   Phases=1 Conn=Wye   Model=1 kV= 14.376 kW=   4.0 kVAR=   2.0
New Load.D828_830a Bus1=mid830.1   Phases=1 Conn=Wye   Model=1 kV= 14.376 kW=   7   kVAR=   3
New Load.D854_856b Bus1=mid856.2   Phases=1 Conn=Wye   Model=1 kV= 14.376 kW=   4   kVAR=   2
New Load.D832_858a Bus1=mid858.1.2 Phases=1 Conn=Delta Model=2 kV= 24.900 kW=   7   kVAR=   3
New Load.D832_858b Bus1=mid858.2.3 Phases=1 Conn=Delta Model=2 kV= 24.900 kW=   2   kVAR=   1
New Load.D832_858c Bus1=mid858.3.1 Phases=1 Conn=Delta Model=2 kV= 24.900 kW=   6   kVAR=   3
New Load.D858_864a Bus1=mid864.1   Phases=1 Conn=Wye   Model=1 kV= 14.376 kW=   2   kVAR=   1
New Load.D858_834a Bus1=mid834.1.2 Phases=1 Conn=Delta Model=1 kV= 24.900 kW=   4.0 kVAR=   2.0
New Load.D858_834b Bus1=mid834.2.3 Phases=1 Conn=Delta Model=1 kV= 24.900 kW=  15   kVAR=   8
New Load.D858_834c Bus1=mid834.3.1 Phases=1 Conn=Delta Model=1 kV= 24.900 kW=  13   kVAR=   7
New Load.D834_860a Bus1=mid860.1.2 Phases=1 Conn=Delta Model=2 kV= 24.900 kW=  16   kVAR=   8
New Load.D834_860b Bus1=mid860.2.3 Phases=1 Conn=Delta Model=2 kV= 24.900 kW=  20.0 kVAR=  10
New Load.D834_860c Bus1=mid860.3.1 Phases=1 Conn=Delta Model=2 kV= 24.900 kW= 110   kVAR=  55
New Load.D860_836a Bus1=mid836.1.2 Phases=1 Conn=Delta Model=1 kV= 24.900 kW=  30   kVAR=  15
New Load.D860_836b Bus1=mid836.2.3 Phases=1 Conn=Delta Model=1 kV= 24.900 kW=  10   kVAR=   6
New Load.D860_836c Bus1=mid836.3.1 Phases=1 Conn=Delta Model=1 kV= 24.900 kW=  42   kVAR=  22
New Load.D836_840a Bus1=mid840.1.2 Phases=1 Conn=Delta Model=5 kV= 24.900 kW=  18   kVAR=   9
New Load.D836_840b Bus1=mid840.2.3 Phases=1 Conn=Delta Model=5 kV= 24.900 kW=  22   kVAR=  11
New Load.D862_838b Bus1=mid838.2   Phases=1 Conn=Wye   Model=1 kV= 14.376 kW=  28.0 kVAR=  14
New Load.D842_844a Bus1=mid844.1   Phases=1 Conn=Wye   Model=1 kV= 14.376 kW=   9   kVAR=   5
New Load.D844_846b Bus1=mid846.2   Phases=1 Conn=Wye   Model=1 kV= 14.376 kW=  25   kVAR=  12
New Load.D844_846c Bus1=mid846.3   Phases=1 Conn=Wye   Model=1 kV= 14.376 kW=  20   kVAR=  11
New Load.D846_848b Bus1=mid848.2   Phases=1 Conn=Wye   Model=1 kV= 14.376 kW=  23   kVAR=  11

! Override Vminpu property to allow convergence at a lower per unit voltage.
! Define the daily load shape to the DSS default
Load.s860.vminpu=0.85 daily=default
Load.s840.vminpu=0.85 daily=default
Load.s844.vminpu=0.85 daily=default
Load.s848.vminpu=0.85 daily=default
Load.s830a.vminpu=0.85 daily=default
Load.s830b.vminpu=0.85 daily=default
Load.s830c.vminpu=0.85 daily=default
Load.s890.vminpu=0.85 daily=default
Load.d802_806b.vminpu=0.85 daily=default
Load.d802_806c.vminpu=0.85 daily=default
Load.d808_810b.vminpu=0.85 daily=default
Load.d818_820a.vminpu=0.85 daily=default
Load.d820_822a.vminpu=0.85 daily=default
Load.d816_824b.vminpu=0.85 daily=default
Load.d824_826b.vminpu=0.85 daily=default
Load.d824_828c.vminpu=0.85 daily=default
Load.d828_830a.vminpu=0.85 daily=default
Load.d854_856b.vminpu=0.85 daily=default
Load.d832_858a.vminpu=0.85 daily=default
Load.d832_858b.vminpu=0.85 daily=default
Load.d832_858c.vminpu=0.85 daily=default
Load.d858_864a.vminpu=0.85 daily=default
Load.d858_834a.vminpu=0.85 daily=default
Load.d858_834b.vminpu=0.85 daily=default
Load.d858_834c.vminpu=0.85 daily=default
Load.d834_860a.vminpu=0.85 daily=default
Load.d834_860b.vminpu=0.85 daily=default
Load.d834_860c.vminpu=0.85 daily=default
Load.d860_836a.vminpu=0.85 daily=default
Load.d860_836b.vminpu=0.85 daily=default
Load.d860_836c.vminpu=0.85 daily=default
Load.d836_840a.vminpu=0.85 daily=default
Load.d836_840b.vminpu=0.85 daily=default
Load.d862_838b.vminpu=0.85 daily=default
Load.d842_844a.vminpu=0.85 daily=default
Load.d844_846b.vminpu=0.85 daily=default
Load.d844_846c.vminpu=0.85 daily=default
Load.d846_848b.vminpu=0.85 daily=default

! Allow the DSS to estimate the voltage bases from this list
Set VoltageBases = [69, 24.9, 4.16, 0.48]
CalcVoltageBases
