Ask Your Question
0

Returning Dynamic simulation data.

asked 2018-05-19 18:36:41 -0500

Chris.R gravatar image

updated 2018-05-19 18:50:51 -0500

Hello,

I am trying to run a dynamic simulation and return the data from each time step rather than outputting it to the .out file so that it can be used in Matlab. Is there a function or way that I would be able to do that?

dryfile, Outfile, and subsystem 2 are all defined earlier in the code and are working fine.

#initiate DYR    
psspy.dyre_new([1,1,1,1],dyrfile)
psspy.chsb(2,1,[-1,-1,-1,1,13,0]) #voltage at bus

#convert loads and generators    
psspy.cong(0) 
psspy.conl(-1,1,1)
psspy.conl(-1,1,2,[0,0],[0,100,0,100])
psspy.conl(-1,1,3)

psspy.ordr()
psspy.fact()
psspy.tysl()

psspy.strt(0,OutFile)
psspy.run(0,5,1,1,0)
psspy.dist_bus_fault(5,3, 0.0, [.1,0]); #SET Fault at bus 5
psspy.run(0,5.1,1,1,0)
psspy.dist_clear_fault(1)

t = 5.1

for TS in range(600): #runs to roughly 10 seconds
    t=t+0.0087
    psspy.run(tpause=t)
    #output voltage (or other CHSB data) as a variable for matlab use at each pause point. 
    pausePoint = input('pause here for Matlab to be run')

I want to set it up so that bus voltage is returned at each time step in the loop after the fault occurs so that some math can be done on with it before initiating the next time step.

edit retag flag offensive close merge delete

3 answers

Sort by » oldest newest most voted
0

answered 2018-05-20 04:27:51 -0500

AlexYang gravatar image

updated 2018-05-20 04:34:27 -0500

You can use dyntool to export output file to excel file, then using matlab process excel file. Or catch dyntool objection, use matplotlib package in python to plot what you want.

You can refer to this script [search: Extract data with dyntools and plot with matplotlib]:

import dyntools
import matplotlib.pyplot as plt

outfile = r"""test.out"""
chnfobj = dyntools.CHNF(outfile)
short_title, chanid, chandata = chnfobj.get_data()

t = chandata['time']
v = chandata[1]              #based on the channel identifier set in the dynamic simulation

fig = plt.figure()
fig.patch.set_facecolor('0.8')
ax1.plot(t,v,linestyle='-', linewidth=1, color='green',label="Voltage")
plt.grid(linestyle='--', color='grey',linewidth=0.5)
plt.xlabel("Time")
plt.ylabel("Voltage")
plt.legend()
axes = plt.gca()
axes.set_facecolor('w')
axes.set_ylim([0.6,1.2])
axes.set_xlim([0,10])
plt.savefig(r"""figure.pdf""",dpi=fig.dpi,facecolor='0.8')
plt.show()
edit flag offensive delete link more

Comments

Completely off topic!

perolofl gravatar imageperolofl ( 2018-05-22 02:10:20 -0500 )edit
0

answered 2018-05-21 17:54:57 -0500

jconto gravatar image

AlexYang's code can run outside the PSSe GUI! I added code to export to XLS, change ax1.plot to plt.plot, and commented "axes.set_facecolor('w')" to make it work on my pc:

import dyntools
import matplotlib.pyplot as plt

outfile = r"""test.out"""
chnfobj = dyntools.CHNF(outfile)
short_title, chanid, chandata = chnfobj.get_data()

t = chandata['time']
v = chandata[1]              #based on the channel identifier set in the dynamic simulation
XLSfile = 'voltage.xls'
sheetname= 'V_chan1'
chnfobj.xlsout(channels=[1,],outfile=outfile,xlsfile=XLSfile,sheet=sheetname,show=False)

fig = plt.figure()
fig.patch.set_facecolor('0.8')
plt.plot(t,v,linestyle='-', linewidth=1, color='green',label="Voltage")
plt.grid(linestyle='--', color='grey',linewidth=0.5)
plt.xlabel("Time")
plt.ylabel("Voltage")
plt.legend()
axes = plt.gca()
#axes.set_facecolor('w')
axes.set_ylim([0.6,1.2])
axes.set_xlim([0,10])
plt.savefig(r"""figure.pdf""",dpi=fig.dpi,facecolor='0.8')
plt.show()
edit flag offensive delete link more
0

answered 2018-05-21 04:06:28 -0500

perolofl gravatar image

What kind of math are you going to apply to the bus voltage?

Do you want to manipulate PSSE during the simulation? If so, which parameter in PSSE will be updated based on the Matlab calculation?

edit flag offensive delete link more

Comments

The objective is to run a single time step in PSSE, take the output values of the dynamic simulation and use them in Matlab to run Kalman Filter. Then apply the result of KF in PSSE simulation and run the next PSSE time step. In short I want to run KF in every time step of PSSE dynamic simulation.

Chris.R gravatar imageChris.R ( 2018-05-21 16:36:27 -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

Stats

Asked: 2018-05-19 18:36:41 -0500

Seen: 524 times

Last updated: May 21