Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Dynamic simulation in a for loop using PSSE35

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.

Dynamic simulation in a for loop using PSSE35

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)