Ask Your Question

How to run a Static DC powerflow?

asked 2022-09-09 14:41:14 -0500

Alex_barajas gravatar image

updated 2022-09-20 21:09:25 -0500

Hi y'all, I'm attempting to run a DC power flow using just a Python script. From my understanding using psspy.fnsl() is running an AC powerflow. I feel like I'm missing an obvious function call. please help if you can :^)

here's my code for reference:

import os,sys

# Path stuff
sys.path.append(r"C:\Program Files\PTI\PSSE35\35.3\PSSPY37")
sys.path.append(r"C:\Program Files\PTI\PSSE35\35.3\PSSBIN")
sys.path.append(r"C:\Program Files\PTI\PSSE35\35.3\PSSLIB")
sys.path.append(r"C:\Program Files\PTI\PSSE35\35.3\EXAMPLE")
os.environ['PATH'] = (r"C:\Program Files\PTI\PSSE35\35.3\PSSPY37;" 
  + r"C:\Program Files\PTI\PSSE35\35.3\PSSBIN;" 
  + r"C:\Program Files\PTI\PSSE35\35.3\EXAMPLE;" + os.environ['PATH'])

# imports all the GOOOOOOD stuff we need for our program / automation stuff 
import glob
from pathlib import Path
import pandas as pd
import psse35
import math
import numpy as np

import psspy

case_file = '../input_files/case14.raw', case_file)

injection_file = ('../input_files/WECgen_data.csv')
injection = pd.read_csv(injection_file)

for i in range(len(injection)):
    print("Time: {}".format(injection.iloc[i].time))
    print("P setpoint: {}".format([i]))
    ierr = psspy.machine_chng_3(3, "1", [], [[i]])
    if ierr > 0:
        print("Failed | machine_chng_3 code = {}".format(ierr))
    psspy.fnsl() # needs to be DC solver not AC 

UPDATE: seems like PSSe isn't actually solving the DC powerflow, I feel like I'm missing something simple. using these function parameters

psspy.dclf(1, 1, [1,0,1,2,1,1],[0,0,0], '1')
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2022-09-12 16:52:04 -0500

jconto gravatar image


psspy.fnsl() # needs to be DC solver not AC


psspy.dclf() # DC LF solver
edit flag offensive delete link more


it seems not to be updating and just solving the AC. Any reason that would be happening?

Alex_barajas gravatar imageAlex_barajas ( 2022-09-20 20:53:15 -0500 )edit

answered 2022-09-21 04:31:14 -0500

perolofl gravatar image

You are using the old API (DCLF) with the arguments for the new API (DCLF_2). It should be:

psspy.dclf_2(1, 1, [1,0,1,2,1,1],[0,0,0], '1')
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

1 follower


Asked: 2022-09-09 14:41:14 -0500

Seen: 60 times

Last updated: Sep 21