First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
1 | initial version |
Hello, I am trying to make a script in python that reads from CSV files the load and generation values and updates the values in the PSS/E sav case for one timestamp. csv file structure for load looks like this:
columns node number, load MW, load Mvar
The status of the script is as follows:
import os import sys
PSSELOCATION = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN" sys.path.append(PSSELOCATION) os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION
import psspy _i = psspy.getdefaultint() _f = psspy.getdefaultreal() _s = psspy.getdefaultchar() psspy.psseinit(100000) psspy.throwPsseExceptions = True
STUDYCASE = 'C:\path\202203010030_FO1.sav'
psspy.case(STUDY_CASE)
psspy.loaddata4(10004, '1', 1, [5, 5, 0, 0, 0, 0]) psspy.loaddata4(10006, '1', 1, [5, 5, 0, 0, 0, 0]) psspy.loaddata4(10007, '1', 1, [5, 4, 0, 0, 0, 0]) psspy.loaddata4(10008, '1', 1, [5, 5, 0, 0, 0, 0]) psspy.machinechng2(10001, r"""1""", [1, i, _i, _i, _i, _i], [4.0, 1.0, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) psspy.branchchng(10004, 10005, '1', [0, i, _i, _i, _i, _i], [f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f])
psspy.fnsl([0, 0, 0, 0, 0, 0, 99, 0]) psspy.area2(0, 1, 1) psspy.save(STUDYCASE) psspy.rawd2(0, 1, [1, 1, 1, 0, 0, 0, 0], 0, r"""202203010030_FO1.raw""")
The part I am struggling with is defining some way of importing the CSV list in python and applying the load (MW/Mvar) in each load node.
Thank you.
2 | No.2 Revision |
Hello, I am trying to make a script in python that reads from CSV files the load and generation values and updates the values in the PSS/E sav case for one timestamp. csv file structure for load looks like this:
columns node number, load MW, load Mvar
The status of the script is as follows:
import os import sys
PSSELOCATION = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN" sys.path.append(PSSELOCATION) os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION
import psspy _i = psspy.getdefaultint() _f = psspy.getdefaultreal() _s = psspy.getdefaultchar() psspy.psseinit(100000) psspy.throwPsseExceptions = True
STUDYCASE = 'C:\path\202203010030_FO1.sav'
psspy.case(STUDY_CASE)
psspy.loaddata4(10004, '1', 1,
[5,[5, 5, 0, 0, 0, 0]) psspy.loaddata4(10006, '1', 1,[5,[5, 5, 0, 0, 0, 0]) psspy.loaddata4(10007, '1', 1,[5,[5, 4, 0, 0, 0, 0]) psspy.loaddata4(10008, '1', 1,[5,[5, 5, 0, 0, 0, 0]) psspy.machinechng2(10001,r"""1""",r"""1""", [1, i, _i, _i, _i,_i],_i], [4.0, 1.0, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) psspy.branchchng(10004, 10005,'1','1', [0, i, _i, _i, _i, _i], [f,_f, _f, _f,f, _f,f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f])psspy.fnsl([0, 0, 0, 0, 0, 0, 99, 0]) psspy.area2(0, 1, 1) psspy.save(STUDYCASE) psspy.rawd
2(0,2(0, 1, [1, 1, 1, 0, 0, 0, 0],0,0, r"""202203010030_FO1.raw""")
The part I am struggling with is defining some way of importing the CSV list in python and applying the load (MW/Mvar) in each load node.
Thank you.
3 | No.3 Revision |
Hello, I am trying to make a script in python that reads from CSV files the load and generation values and updates the values in the PSS/E sav case for one timestamp. csv file structure for load looks like this:
columns node number, load MW, load Mvar
The status of the script is as follows:
import os import sys
PSSELOCATION = r"C:\Program Files
(x86)\PTI\PSSE33\PSSBIN"
Files (x86)\PTI\PSSE33\PSSBIN" sys.path.append(PSSELOCATION)
LOCATION) os.environ['PATH'] =
= os.environ['PATH'] + ';' +
+ PSSE_LOCATION
import psspy
_i = psspy.getdefaultint()
_f = psspy.getdefaultreal()
_s = psspy.getdefaultchar() psspy.psseinit(100000)
psspy.psseinit(100000) psspy.throwPsseExceptions = True
STUDYCASE =
= 'C:\path\202203010030_FO1.sav'
psspy.case(STUDY_CASE)
psspy.loaddata4(10004, '1', 1, [5, 5, 0, 0, 0, 0])
0]) psspy.loaddata4(10006, '1', 1, [5, 5, 0, 0, 0, 0])
0]) psspy.loaddata4(10007, '1', 1, [5, 4, 0, 0, 0, 0])
0]) psspy.loaddata4(10008, '1', 1, [5, 5, 0, 0, 0, 0])
0]) psspy.machinechng2(10001, r"""1""", [1, i, _i, _i, _i, _i], [4.0, 1.0, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) psspy.branchchng(10004, 10005, '1', [0, i, _i, _i, _i, _i], [f, f, _f,f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f])
The part I am struggling with is defining some way of importing the CSV list in python and applying the load (MW/Mvar) in each load node.
Thank you.
4 | No.4 Revision |
Hello, I am trying to make a script in python that reads from CSV files the load and generation values and updates the values in the PSS/E sav case for one timestamp. csv file structure for load looks like this:
columns node number, load MW, load Mvar
The status of the script is as follows:
import PSSELOCATION
STUDYCASE = 'C:\path\202203010030_FO1.sav'
psspy.case(STUDY_CASE)
psspy.loaddata4(10004,
The part I am struggling with is defining some way of importing the CSV list in python and applying the load (MW/Mvar) in each load node.
Thank you.
5 | No.5 Revision |
Hello, I am trying to make a script in python that reads from CSV files the load and generation values and updates the values in the PSS/E sav case for one timestamp. csv file structure for load looks like this:
columns
node number, load MW, load MvarMvar
10004, 5, 5
10006, 5, 5
.
.
.
The status of the script is as follows:
import os
import sys
PSSE_LOCATION = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN"
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION
import psspy
_i = psspy.getdefaultint()
_f = psspy.getdefaultreal()
_s = psspy.getdefaultchar()
psspy.psseinit(100000)
psspy.throwPsseExceptions = True
STUDY_CASE = 'C:\\path\\20220301_0030_FO1.sav'
psspy.case(STUDY_CASE)
psspy.load_data_4(10004, '1', 1, [5, 5, 0, 0, 0, 0])
psspy.load_data_4(10006, '1', 1, [5, 5, 0, 0, 0, 0])
psspy.load_data_4(10007, '1', 1, [5, 4, 0, 0, 0, 0])
psspy.load_data_4(10008, '1', 1, [5, 5, 0, 0, 0, 0])
psspy.machine_chng_2(10001, r"""1""", [1, _i, _i, _i, _i, _i], [4.0, 1.0, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f])
psspy.branch_chng(10004, 10005, '1', [0, _i, _i, _i, _i, _i], [_f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f])
psspy.fnsl([0, 0, 0, 0, 0, 0, 99, 0])
psspy.area_2(0, 1, 1)
psspy.save(STUDY_CASE)
psspy.rawd_2(0, 1, [1, 1, 1, 0, 0, 0, 0], 0, r"""20220301_0030_FO1.raw""")
The part I am struggling with is defining some way of importing the CSV list in python and applying the load (MW/Mvar) in each load node.
Thank you.
6 | No.6 Revision |
Hello, I am trying to make a script in python that reads from CSV files the load and generation values and updates the values in the PSS/E sav case for one timestamp. csv file structure for load looks like this:
node number, load MW, load Mvar 10004, 5, 5 10006, 5, 5 . . .
The status of the script is as follows:
import os
import sys
PSSE_LOCATION = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN"
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION
import psspy
_i = psspy.getdefaultint()
_f = psspy.getdefaultreal()
_s = psspy.getdefaultchar()
psspy.psseinit(100000)
psspy.throwPsseExceptions = True
STUDY_CASE = 'C:\\path\\20220301_0030_FO1.sav'
psspy.case(STUDY_CASE)
psspy.load_data_4(10004, '1', 1, [5, 5, 0, 0, 0, 0])
psspy.load_data_4(10006, '1', 1, [5, 5, 0, 0, 0, 0])
psspy.load_data_4(10007, '1', 1, [5, 4, 0, 0, 0, 0])
psspy.load_data_4(10008, '1', 1, [5, 5, 0, 0, 0, 0])
psspy.machine_chng_2(10001, r"""1""", [1, #My updated code is below, changed identation
with open("1.csv", 'r') as file:
reader = csv.reader(file)
for row in reader:
loaddatalst = row.split(",")
loadbus = int(loaddatalst[0])
loadid = '1' # or loaddatalst [x], x is position of load id in row
loadp = float(loaddatalst[1])
loadq = float(loaddatalst[2])
psspy.load_data_4(loadbus, loadid, [_i, _i, _i, _i, _i, _i], [4.0, 1.0, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f])
psspy.branch_chng(10004, 10005, '1', [0, _i, _i, _i, _i, _i], [_f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f])
[loadp, loadq, 0, 0, 0, 0])
psspy.fnsl([0, 0, 0, 0, 0, 0, 99, 0])
psspy.area_2(0, 1, 1)
psspy.save(STUDY_CASE)
psspy.rawd_2(0, 1, [1, 1, 1, 0, 0, 0, 0], 0, r"""20220301_0030_FO1.raw""")
The part I am struggling with is defining some way of importing the CSV list in python and applying the load (MW/Mvar) in each load node.
Thank you.
7 | No.7 Revision |
Hello, I am trying to make a script in python that reads from CSV files the load and generation values and updates the values in the PSS/E sav case for one timestamp. csv file structure for load looks like this:
node number, load MW, load Mvar 10004, 5, 5 10006, 5, 5 . . .
The status of the script is as follows:
import os
import sys
PSSE_LOCATION = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN"
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION
import psspy
_i = psspy.getdefaultint()
_f = psspy.getdefaultreal()
_s = psspy.getdefaultchar()
psspy.psseinit(100000)
psspy.throwPsseExceptions = True
STUDY_CASE = 'C:\\path\\20220301_0030_FO1.sav'
psspy.case(STUDY_CASE)
#My updated code is below, changed identation
with open("1.csv", 'r') as file:
reader = csv.reader(file)
for row in reader:
loaddatalst = row.split(",")
loadbus = int(loaddatalst[0])
int(row[0])
loadid = '1' # or loaddatalst [x], x is position of load id in row
loadp = float(loaddatalst[1])
float(row[1])
loadq = float(loaddatalst[2])
float(row[2])
psspy.load_data_4(loadbus, loadid, [_i, _i, _i, _i, _i, _i], [loadp, loadq, 0, 0, 0, 0])
psspy.fnsl([0, 0, 0, 0, 0, 0, 99, 0])
psspy.area_2(0, 1, 1)
psspy.save(STUDY_CASE)
psspy.rawd_2(0, 1, [1, 1, 1, 0, 0, 0, 0], 0, r"""20220301_0030_FO1.raw""")
The part I am struggling with is defining some way of importing the CSV list in python and applying the load (MW/Mvar) in each load node.
Thank you.
8 | No.8 Revision |
Hello, I am trying to make a script in python that reads from CSV files the load and generation values and updates the values in the PSS/E sav case for one timestamp. csv file structure for load looks like this:
node number, load MW, load Mvar 10004, 5, 5 10006, 5, 5 . . .
The status of the script is as follows:
import os
import sys
PSSE_LOCATION = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN"
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION
import psspy
_i = psspy.getdefaultint()
_f = psspy.getdefaultreal()
_s = psspy.getdefaultchar()
psspy.psseinit(100000)
psspy.throwPsseExceptions = True
STUDY_CASE = 'C:\\path\\20220301_0030_FO1.sav'
psspy.case(STUDY_CASE)
#My updated code is below, changed identation
with open("1.csv", 'r') as file:
reader = csv.reader(file)
for row in reader:
loadbus = int(row[0])
loadid = '1' # or loaddatalst [x], x is position of load id in row
loadp = float(row[1])
loadq = float(row[2])
psspy.load_data_4(loadbus, loadid, [_i, _i, _i, _i, _i, _i], [loadp, loadq, 0, 0, 0, 0])
psspy.fnsl([0, 0, 0, 0, 0, 0, 99, 0])
psspy.area_2(0, 1, 1)
psspy.save(STUDY_CASE)
psspy.rawd_2(0, 1, [1, 1, 1, 0, 0, 0, 0], 0, r"""20220301_0030_FO1.raw""")
The part I am struggling with is defining some way of importing the CSV list in python and applying the load (MW/Mvar) in each load node.
Thank you.
to follow up after JConto answer, my code for updating load and generation in PSSE case looks like this:
#read load p and q
with open('load.csv', 'r') as file:
reader = csv.reader(file)
for row in reader:
loadbus = int(row[0])
loadid = '1' # or loaddatalst [x], x is position of load id in row
loadp = float(row[1])
loadq = float(row[2])
psspy.load_data_4(loadbus, loadid, [_i, _i, _i, _i, _i, _i], [loadp, loadq, 0, 0, 0, 0])
#read generators
with open('gen.csv', 'r') as file:
reader = csv.reader(file)
for row in reader:
genbus = int(row[0])
genid = str(row[1]) # or loaddatalst [x], x is position of load id in row
status = int(row[2])
genp = float(row[3])
genq = float(row[4])
psspy.machine_chng_2(genbus, genid, [status, _i, _i, _i, _i, _i],[genp, genq, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f])