Replies: 3 comments 9 replies
-
I have no idea yet about the The code below works fine with loaded snapshots in different names. I would appreciate it if you poke around and let me know. import andes
from matplotlib import pyplot
%matplotlib inline
andes.config_logger()
ss = andes.system.example()
ss.PFlow.run()
ss.TDS.init();
# --- First save and load ---
from andes.utils.snapshot import save_ss, load_ss
save_ss("snapshot.pkl", ss)
ss_new = load_ss("snapshot.pkl")
ss_new.TDS.run()
ss_new.TDS.plt.plot(ss.GENROU.omega)
# --- Second save and load ---
save_ss("snapshot.pkl", ss_new)
ss_new2 = load_ss("snapshot.pkl")
ss_new2.TDS.config.tf = 30
ss_new2.TDS.run()
ss_new2.TDS.plt.plot(ss_new2.GENROU.omega) |
Beta Was this translation helpful? Give feedback.
-
Hello Hantao @cuihantao,
I might have more comments on this. It is correct that I think maybe I can improve this by creating a copied ANDES system using the file source and all the config in Also, I am thinking that we can include a chapter or subchapter in the documentation to further explain the Regards, |
Beta Was this translation helpful? Give feedback.
-
It seems, the discussion-feature / tab on the repository has been
deactivated currently. Hence, I'll reply via mail:
I really like the idea of the track_system function (if I understood it
correctly) and was starting work on that myself. Currently it's basically
trying to "update" the PP-system by always creating a new one via:
def create_pps(ssa: andes.system, verbose=False):
if verbose: inspect_andes_system(ssa)
ssa.Slack.u.v[:] = 1
ssa.PV.u.v[:] = 1
ssp = to_pandapower(ssa, verify=False) # Verfication useless as Post-TDS andes systems cant do Power Flow anymore
ssa.Slack.u.v[:] = 0
ssa.PV.u.v[:] = 0
ssp.load.loc[:, "p_mw"] = ssa.PQ.Ppf.v * 100
ssp.load.loc[:, "q_mvar"] = ssa.PQ.Qpf.v * 100
if verbose: inspect_pandapower_system(ssp)
return ssp
Second step is the OPF-execution, again based on Jinning Wangs ideas:
def run_pp_opf(ssa: andes.system,
ssp: pandapower.auxiliary.pandapowerNet,
gen_cost=gen_cost_default_IEEE14,
verbose=False):
add_gencost(ssp, gen_cost)
link_table = make_link_table(ssa)
# if verbose:
# print("Link-Table:")
# print(link_table)
# print()
ssa_opt = runopp_map(ssp, link_table)
if verbose:
print("Optimal Results:")
print(ssa_opt)
print()
return ssa_opt
And (at an optionally later point in time) I bring back in the
OPF-setpoints:
def inject_opf_setpoints(ssa: andes.system, ssa_opt, verbose=False):
ssa_gov_idx = list(ssa_opt['gov_idx'][~ssa_opt['gov_idx'].isna()])
if verbose:
print("Generator P setpoints BEFORE OPF")
print(ssa.TurbineGov.get(src='pref0', idx=ssa_gov_idx, attr='v'))
print()
ssa.TurbineGov.set(src='pref0', idx=ssa_gov_idx, attr='v', value=ssa_opt['p'][~ssa_opt['gov_idx'].isna()])
if verbose:
print("Generator P setpoints AFTER OPF")
print(ssa.TurbineGov.get(src='pref0', idx=ssa_gov_idx, attr='v'))
print()
ssa_exciter_idx = list(ssa_opt['exc_idx'][~ssa_opt['exc_idx'].isna()])
if verbose:
print("Generator V setpoints BEFORE OPF")
print(ssa.Exciter.get(src='vref0', idx=ssa_exciter_idx, attr='v'))
print()
ssa.Exciter.set(src='vref0', idx=ssa_exciter_idx, attr='v', value=ssa_opt['vm_pu'][~ssa_opt['exc_idx'].isna()])
if verbose:
print("Generator V setpoints AFTER OPF")
print(ssa.Exciter.get(src='vref0', idx=ssa_exciter_idx, attr='v'))
print()
Ultimately, this merely tries to create a PP-system based on a
POST-TDS-andes system by replacing the PQ-bus-values for active and
reactive power with the TDS-values "Ppf" and "Qpf" (assuming constant load
services. Anything else would defy the point of bringing-in OPF-results).
After OPF both active generator output (TurbineGovs --> pref0) and
voltage-setpoints for generators (Exciters --> vref0) are mapped back from
OPF to ANDES. I must admit that especially the voltage-mapping does not
seem to be correctly done, but it is doing SOMETHING ;)
At the beginning, both Slack-bus and PV-buses need to be re-activated,
otherwise the to_pandapower-function will not work. I DO re-disable both
them right after the creation of the PP-system again, just to recreate the
state of the ANDES system from where it stopped after the last TDS. I do
not yet fully understand why the TDS disables slack-nodes (or where it does
that, actually), but the TDS will work / continue with any combination of
enabled or disabled Slack and PV-busses.
This is my current state, thanks a lot for the inspirations and code so
far, both of you! :)
… Message ID: ***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
@MaKla89
Here's a fix for your use case. See my notes enclosed as well.
Beta Was this translation helpful? Give feedback.
All reactions