-
-
Save jmmauricio/1198491fa8223572881a to your computer and use it in GitHub Desktop.
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() |
the easiest one will be the column header has the same name with load name in PowerFactory. And then you can map it like this:
loads_data = app.GetRelevantObjects('*.ElmLod')
for load in loads_data:
try:
load_curve = df[load.GetAttribute('loc_name']
except:
print(f'load curve for {load.GetAttribute('loc_name']} not found') #catching error because load name is not in data
Is there a way to extract multiple parameters of all synchronous machines at a time and write to a csv file?
@midhunagarapati , what parameter do you want to extract? If it's just static parameter like inertia, time constant or etc, the easiest one is directly use GUI of powerfactory through Network Model Manager. Chose Generator, and then go through flexible tab.
You can define the parameter in there.
@rizky-r-lab I want to extract simulation RMS parameters like transient reactances and change them according to the size of the machine
i searched for a long time now to find all attributes a element can have. Is there a list i didnt know about?
the easiest one will be the column header has the same name with load name in PowerFactory. And then you can map it like this:
loads_data = app.GetRelevantObjects('*.ElmLod')
for load in loads_data:
try:
load_curve = df[load.GetAttribute('loc_name']
except:
print(f'load curve for {load.GetAttribute('loc_name']} not found') #catching error because load name is not in data
Hi. I want to know if someone can help me in a issue that I´m having on Digsilent 2023... I want to know if it is posible to modify a setpoint value of a controller of a STATCOM during a RMS simulation; specifically when one specific line trips off (Meaning that the system would be running in N-1 condittions), for instance, at that moment when N-1 scenario occurs, instead of a setpoint value of 1 pu voltage at certain busbar, the statcom change that setpoint to look up for 0.98 pu. voltage.... Please if you can help me I´ll appreciate it.
Hi Everyone, did anybody know how can i create static generator objects in my project and then need to read date from csv file in order to give every photovoltic (static generator) their power and other properties??
Hello, . I'm trying to implement rms simulation via python code and I ran into a problem. I want to extract the value of a variable at a specific moment in time, but I don't know how to do it. can someone help me please? Regards!
Hi
I want to add a shunt element to a bus. How can I do it?
Thanks.
When I close powerfactory, I run the following python script:
import sys sys.path.append( r"C:\Program Files\DIgSILENT\PowerFactory 2022\Python\3.10") if __name__ == "__main__": import powerfactory app = powerfactory.GetApplication() if app is None: raise Exception('getting Powerfactory application failed')
Error reported:
Process finished with exit code -1073741819 (0xC0000005)
Tried many methods to no avail, if you have a similar situation and successfully solved it, or if you have other suggestions, please let me know, thank you for your help, it is greatly appreciated
import os
os.environ["PATH"]=r"C:\DIgSILENT\PF 2023_SP5"+os.environ["PATH"]
import sys
sys.path.append(r"C:\DIgSILENT\PF 2023_SP5\Python\3.8")
#IMPORTAR LA APLICACION
try:
import powerfactory as pf
app = pf.GetApplication()
app.Show()
outputWindow = app.GetOutputWindow()
outputWindow.Print(pf.OutputWindow.MessageType.Plain, "Hello World!")
except Exception as e:
print("Error corregir",e)
Only close powerfactory, If powerfactory is run, Engine mode with Digrcom.
i would like to read data from excel using the module “pandas”, i found that i can use
import pandas as pd
pandas.read_excel('File_name','sheet name')
The data will then be returned into a DataFrame. The DataFrame has the advantage of providing easy access to columns and rows. But, i'm not able to map the header in the Excel file with a load object in PowerFactory, can someone help me here ?