Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
901 views

PF With Python in Digsilent

This Python script imports the PowerFactory module to access a Nine Bus System project in Digsilent, sets up event-driven simulations by creating an event to change a generator's target power at 1 second, runs load flow and time-domain simulations, and exports selected results such as bus voltages and generator speeds to a text file.

Uploaded by

Yutee
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
901 views

PF With Python in Digsilent

This Python script imports the PowerFactory module to access a Nine Bus System project in Digsilent, sets up event-driven simulations by creating an event to change a generator's target power at 1 second, runs load flow and time-domain simulations, and exports selected results such as bus voltages and generator speeds to a text file.

Uploaded by

Yutee
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

PF With Python in Digsilent

import sys
sys.path.append(r"C:\DigSILENT15p1p7\python")
# import PowerFactory module
import powerfactory
# start PowerFactory in engine mode
app = powerfactory.GetApplication()
user = app.GetCurrentUser()
# activate project
project = app.ActivateProject("Nine Bus System")
prj = app.GetActiveProject()
ldf = app.GetFromStudyCase("ComLdf")
ini = app.GetFromStudyCase('ComInc')
sim = app.GetFromStudyCase('ComSim')
Shc_folder = app.GetFromStudyCase('IntEvt');
terminals = app.GetCalcRelevantObjects("*.ElmTerm")
lines = app.GetCalcRelevantObjects("*.ElmTerm")
syms = app.GetCalcRelevantObjects("*.ElmSym")

Shc_folder.CreateObject('EvtSwitch', 'evento de generacion');


EventSet = Shc_folder.GetContents();
evt = EventSet[0];
evt.time =1.0
evt.p_target = syms[1]
ldf.iopt_net = 0
ldf.Execute()
elmres = app.GetFromStudyCase('Results.ElmRes')
for terminal in terminals:
elmres.AddVars(terminal,'m:u','m:phiu','m:fehz')
for sym in syms:
elmres.AddVars(sym,'s:xspeed')

ini.Execute()
sim.Execute()
evt.Delete()
comres = app.GetFromStudyCase('ComRes');
comres.iopt_csel = 0

comres.iopt_tsel = 0
comres.iopt_locn = 2
comres.ciopt_head = 1
comres.pResult=elmres
comres.f_name = r'C:\Users\jmmauricio\hola.txt'
comres.iopt_exp=4
comres.Execute()

You might also like