Menu

Getting zeros for voltage values when used through COM interface in Python

Beginners
Dilan
2019-09-09
2019-09-09
  • Dilan

    Dilan - 2019-09-09

    Hi,

    I recently started to use the COM interface with Python and I’m simulating a 10 bus network as the initial step. I’m obtaining 0 values for all node voltages in this simulation.
    I used the “CalcVoltageBases" and “set defaultbasefreq=50” commands as mentioned in another post and still getting the same results.
    Also I get non zero voltage values when a similar code is used in Matlab .

    Please find the code below. Highly appreciate if you can point out the problem in the attached code.

    Thanks.

    import numpy as np
    import win32com.client
    v=0.4
    busnumber=10
    
    loaddata=np.matrix([  [1,0,0] ,                                
                         [2,1000,100],
                         [3,1000,100],
                         [4,1000,100],
                         [5,5000,100],
                         [6,1000,100],
                         [7,1000,100],
                         [8,1000,100],
                         [9,1000,100],
                         [10,1000,100]])
    
    linedata=np.matrix([[1,1,2,1,1],    
                [2,2,3,1,1],
                [3,3,4,1,1],
                [4,4,5,1,1],
                [5,5,6,1,1],
                [6,6,7,1,1],
                [7,5,8,1,1],
                [8,8,9,1,1],
                [9,9, 10,1,1]])
    
    DSSObj = win32com.client.Dispatch("OpenDSSEngine.DSS")
    Start=DSSObj.Start(0) 
    DSSText = DSSObj.Text
    DSSText.Command = "clear"
    DSSText.Command ="New Circuit.Simple"  
    DSSText.Command = "set defaultbasefreq=50 "
    DSSText.Command ="Edit Vsource.Source BasekV="+str(v)+" pu=1.00 ISC3=3000 ISC1=2500"    
    DSSText.Command ="New Line.1 Bus1=SourceBus Bus2=2 R1=1 X1=1 R0=1 X0=1 C1=0 C0=0  Length=1"  
    
    for i in range(1,busnumber-1):
    
        DSSText.Command ="New Line."+str(int(linedata[i,0]))+ " Bus1="+str(int(linedata[i,1]))+ " Bus2="+str(int(linedata[i,2])) +" R1="+str((linedata[i,3]))+ " X1="+str((linedata[i,4]))+ " R0="+str((linedata[i,3]))+" X0="+str((linedata[i,4]))+ " C1=0 C0=0 Length=1"
    
    for i in range(1,busnumber):
    
        DSSText.Command ="New Load."+ str(int(loaddata[i,0]))+ " Bus1="+ str(int(loaddata[i,0])) +" kV=0.4"+ " kW="+ str(loaddata[i,1]/1000)+ " kVar=" +str(loaddata[i,2]/1000)
    
    DSSText.Command ="CalcVoltageBases"
    DSSCircuit = DSSObj.ActiveCircuit
    DSSSolution = DSSCircuit.Solution
    
    DSSSolution.Solve
    DSSLines = DSSCircuit.Lines
    DSSBus= DSSCircuit.ActiveBus
    VMSi=DSSCircuit.AllNodeVmagPUByPhase(2)
    
    MyLineLosses = DSSCircuit.LineLosses
    print(DSSCircuit.AllNodeVmagByPhase(3))
    DSSObj.ClearAll()
    
     

    Last edit: Dilan 2019-09-09
  • Roger Dugan

    Roger Dugan - 2019-09-09

    Try

    DSSText.Command ="Show Isolated"

    To make sure you have everything connected

     
  • Dilan

    Dilan - 2019-09-09

    Hi Roger,

    Thank you very much for the quick response.

    It looks like every thing is connected from the following ISOLATED CIRCUIT ELEMENT REPORT.

    Please let me know if you notice a problem in the code.

    ISOLATED CIRCUIT ELEMENT REPORT
    
    
    ***  THE FOLLOWING BUSES HAVE NO CONNECTION TO THE SOURCE ***
    
    
    ***********  THE FOLLOWING SUB NETWORKS ARE ISOLATED ************
    
    
    ***********  THE FOLLOWING ENABLED ELEMENTS ARE ISOLATED ************
    
    
    ***  THE FOLLOWING BUSES ARE NOT CONNECTED TO ANY POWER DELIVERY ELEMENT ***
    
    
    ***********  CONNECTED CIRCUIT ELEMENT TREE ************
    
    (Lexical Level) Element name
    
    (0) Vsource.source
    (1) Line.1
    [SHUNT], Load.2
    (2) Line.2
    [SHUNT], Load.3
    (3) Line.3
    [SHUNT], Load.4
    (4) Line.4
    [SHUNT], Load.5
    (5) Line.7
    [SHUNT], Load.8
    (6) Line.8
    [SHUNT], Load.9
    (7) Line.9
    [SHUNT], Load.10
    (5) Line.5
    [SHUNT], Load.6
    (6) Line.6
    [SHUNT], Load.7
    
     
  • Dilan

    Dilan - 2019-09-09

    Hi Roger,

    Thank you very much for the quick response.

    It looks like every thing is connected from the following ISOLATED CIRCUIT ELEMENT REPORT.

    Please let me know if you notice a problem in the code.

    ISOLATED CIRCUIT ELEMENT REPORT
    
    
    ***  THE FOLLOWING BUSES HAVE NO CONNECTION TO THE SOURCE ***
    
    
    ***********  THE FOLLOWING SUB NETWORKS ARE ISOLATED ************
    
    
    ***********  THE FOLLOWING ENABLED ELEMENTS ARE ISOLATED ************
    
    
    ***  THE FOLLOWING BUSES ARE NOT CONNECTED TO ANY POWER DELIVERY ELEMENT ***
    
    
    ***********  CONNECTED CIRCUIT ELEMENT TREE ************
    
    (Lexical Level) Element name
    
    (0) Vsource.source
    (1) Line.1
    [SHUNT], Load.2
    (2) Line.2
    [SHUNT], Load.3
    (3) Line.3
    [SHUNT], Load.4
    (4) Line.4
    [SHUNT], Load.5
    (5) Line.7
    [SHUNT], Load.8
    (6) Line.8
    [SHUNT], Load.9
    (7) Line.9
    [SHUNT], Load.10
    (5) Line.5
    [SHUNT], Load.6
    (6) Line.6
    [SHUNT], Load.7
    
     
  • Roger Dugan

    Roger Dugan - 2019-09-09

    Try moving

    Set DefaultBaseFrequency=50
    

    to right after the Clear command. I suspect the circuit got defined with a source for 60 Hz.

     
  • Dilan

    Dilan - 2019-09-09

    That solved the problem.

    Thank you very much for the support.

     

Log in to post a comment.

MongoDB Logo MongoDB