-
-
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() |
thank u so much for the replies.
now I am wondering why my calculations are differ from the simulation result. I calculate Ploss using I^2 R, which R replaced by Z (R+XL for <80km line), Z calculation are similar than in simulation "resulting values" in line data (6.8 vs 6.78 ohm), Current are similar (both 85A) since Power are similar (both 21-22 MW), using I^2 Z, simulation differ up to 2x-4x value of calculation.
I don't know how the procedure that you are using to calculate Ploss. However, If you only calculate Ploss(active power losses), you should using I^2 R, not I^2 Z.
Problem description (PowerFactory Python / IntForm / Line labels):
I am trying to automatically change the line (ElmLne) labels in the network diagram (Netzmodell) using Python by modifying the corresponding IntForm (e.g. ElmLne_basic_sym.IntForm).
I can successfully access the object:
...\ElmLne_basic_sym.IntForm
Question:
Where are the line label templates actually stored in PowerFactory (Symbol, IntForm, hidden child objects, or annotation layer), and what is the correct Python way to modify them so the diagram updates?
You can use m:P:bus1 and m:P:bus2 for balance load flow or m:P1:bus1 and M:P2:bus2 for unbalanced.
For reference, you can search the variable in here, depends on what analysis you are doing.

To go there, you go into flexible data tab, in network model manager for each class.