First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!

Ask Your Question
0

How to run a Static DC powerflow?

asked Sep 9 '2

Alex_barajas gravatar image

updated Sep 21 '2

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
psse35.set_minor(3)
import math
import numpy as np

import psspy
psspy.psseinit(50)


case_file = '../input_files/case14.raw'
psspy.read(1, case_file)
psspy.fnsl()


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(injection.pg.iloc[i]))
    ierr = psspy.machine_chng_3(3, "1", [], [injection.pg.iloc[i]])
    if ierr > 0:
        print("Failed | machine_chng_3 code = {}".format(ierr))
    psspy.fnsl() # needs to be DC solver not AC 
    print("========================")

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')

2 answers

Sort by » oldest newest most voted
1

answered Sep 12 '2

jconto gravatar image

replace:

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

with:

psspy.dclf() # DC LF solver
link

Comments

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

Alex_barajas gravatar imageAlex_barajas (Sep 21 '2)
0

answered Sep 21 '2

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')
link

Comments

it's running the power flwo but the internal values are not updating. any clue as to why?

Alex_barajas gravatar imageAlex_barajas (Feb 10 '3)

What do you mean with "internal values"?

perolofl gravatar imageperolofl (Feb 10 '3)

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.
Want to format code in your answer? Here is a one minute demo on Youtube

Add Answer

[hide preview]

Question Tools

1 follower

Stats

Asked: Sep 9 '2

Seen: 281 times

Last updated: Sep 21 '22