Ask Your Question
0

How to run a Static DC powerflow?

asked 2022-09-09 14:41:14 -0600

Alex_barajas gravatar image

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

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')
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

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

jconto gravatar image

replace:

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

with:

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

Comments

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 -0600 )edit
0

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

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

Comments

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

Alex_barajas gravatar imageAlex_barajas ( 2023-02-09 18:22:45 -0600 )edit

What do you mean with "internal values"?

perolofl gravatar imageperolofl ( 2023-02-10 02:08:29 -0600 )edit

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

Stats

Asked: 2022-09-09 14:41:14 -0600

Seen: 247 times

Last updated: Sep 21 '22