Ask Your Question
0

Dynamic simulation in a for loop using PSSE35

asked 2024-02-07 19:33:31 -0500

Ray gravatar image

updated 2024-02-08 20:50:04 -0500

With PSSEv35.3, if running the dynamic simulation in a for loop, it shows the same outputs even I made the change to generator parameters. The same code works well in PSSE EXPLORE 34.

Here is the code:

def myfunc(param)

## PSSE34
import os, sys, csv
sys_path_PSSE = 'C:\Program Files (x86)\PTI\PSSEXplore34\PSSPY27'  
sys.path.append(sys_path_PSSE)
os_path_PSSE = 'C:\Program Files (x86)\PTI\PSSEXplore34\PSSBIN'
os.environ['PATH'] = ';' + os_path_PSSE

## PSSE35
import PSSE35


## sharing code for both versions
import dyntools, psspy, redirect
_i = psspy.getdefaultint()
_f = psspy.getdefaultreal()
_s = psspy.getdefaultchar()
redirect.psse2py()
psspy.psseinit(150000)

psspy.progress_output(6, '', [])


Case = 'casefile.raw'
plbfile = 'pb.plb'
dyrfile ='case.dyr'
OutFile = 'plotcase.out'

psspy.read(0, Case)

f1 = open(plbfile)
reader = csv.reader(f1)
row1 = next(reader)
row2 = next(reader)
f1.close
t1 = float(row1[0])
t2 = float(row2[0])
Resolution = 0.033

psspy.bsys(sid=2, numbus=1, buses=1) # Assign SID=2 to Bus 1
psspy.dyre_new([1,1,1,1],dyrfile)


psspy.change_plmod_con(1, r"""01""", r"""IEEEST""", 12, float(param[0]))
psspy.change_plmod_con(1, r"""01""", r"""IEEEST""", 13, float(param[1]))

psspy.chsb(0,1,[-1,-1,-1,1,16,0])

psspy.cong(0)
psspy.conl(0, 1, 1, [0, 0], [100, 0, 0, 100])
psspy.conl(0, 1, 2, [0, 0], [100, 0, 0, 100])
psspy.conl(0, 1, 3, [0, 0], [100, 0, 0, 100])

psspy.dynamics_solution_param_2([_i, _i, _i, _i, _i, _i, _i, _i], [_f, _f, num_steps, _f, _f, _f, _f, _f])

psspy.strt(1, OutFile)
psspy.run(0, Trun_end, 80000, 1, 0)

ch = dyntools.CHNF(OutFile)
short_title, chanid_dict, chandata_dict = ch.get_data()

psspy.pssehalt_2() ## this line is commented out for PSSE35, otherwise, it will stop after 2nd initialization

In a for loop, this function is called with different parameters loaded.

for in range(100): # read parameters get param myfunc(param)

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2024-02-08 08:23:40 -0500

jconto gravatar image

updated 2024-02-09 09:47:16 -0500

If the same python version is used for both v.34 and v.35, there is no need to change the code (except the obvious, psse35 instead of psse34...). And the psspy API functions should works the same way. Check the log files for errors during running time.

If possible, post your code for other to comment on it (and learn from it). I recommend to update the code to python 3.9 for v.35

edit flag offensive delete link more

Comments

Thank you for the help. The code is updated.

Ray gravatar imageRay ( 2024-02-08 20:45:05 -0500 )edit

var sys_path_PSSE is set for v.34, so update such path for v.35 (same for os_path_PSSE). vars t1, t2 are defined but not used. var num_steps is not defined. vars param[0], param[1] would change on each iteration (?). The loop code is missing. Test if the passing vars are changing within the loop.

jconto gravatar imagejconto ( 2024-02-09 09:46:11 -0500 )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: 2024-02-07 19:33:31 -0500

Seen: 179 times

Last updated: Feb 09