Last active
February 28, 2023 10:22
-
-
Save jmmauricio/125dbd994726c586fa940b814c05aa84 to your computer and use it in GitHub Desktop.
Power Factory DigSILENT python short circuit at bus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| buses = app.GetCalcRelevantObjects("*.ElmTerm") | |
| events_folder = app.GetFromStudyCase('IntEvt'); # to get events folder | |
| evt1 = events_folder.CreateObject('EvtShc', 'short circuit'); # generator switch event is created here | |
| evt1[0].p_target = buses[1] # event target is the 1 bus | |
| evt1[0].time = 1.0 # short circuit starts at t=1 s | |
| evt1[0].i_shc = 0 | |
| evt2 = events_folder.CreateObject('EvtShc', 'clear short circuit'); # generator switch event is created here | |
| evt2[0].p_target = buses[1] # event target is the 1 bus | |
| evt2[0].time = 1.0 + 0.1 # short circuit is cleared at t=1.1 s | |
| evt2[0].i_shc = 4 |
Hello, you can solver this problem using the next code:
import os
os.environ["PATH"]=r"C:\Program Files (x86)\DIgSILENT\PowerFactory 15.1"+os.environ["PATH"]
import sys
sys.path.append(r"C:\Program Files (x86)\DIgSILENT\PowerFactory 15.1\python")
import powerfactory as pf
I have solved this problem. I found the version of Python and PowerFactory should keep the same. Then it works.
But when I want to generate an event in a generation, a code always shows error below:
evt1[0].p_target = gens[2]
The error is 'DataObject' object is not subscriptable.
How could I modify it? Thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, I meet a problem for Python in PowerFactory.
When I want to import powerfactory, there is always a problem, saying no module named 'powerfactory'.
How could I modify it? thank you!