Skip to content

Commit

Permalink
Merge branch 'master' into addNetworksFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
jessLryan authored Dec 14, 2023
2 parents 354505f + 1d3d4c9 commit d22f713
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 16 deletions.
4 changes: 4 additions & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Upcoming Release

.. warning:: The features listed below are not released yet, but will be part of the next release! To use the features already you have to install the ``master`` branch, e.g. ``pip install git+https://github.com/pypsa/pypsa#egg=pypsa``.

* The output attribute ``n_mod`` introduced in the previous version was removed
since it contains duplicate information. Calculate the number of expanded
modules with ``p_nom_opt / p_nom_mod`` instead.

PyPSA 0.26.0 (4th December 2023)
================================

Expand Down
1 change: 0 additions & 1 deletion pypsa/component_attrs/generators.csv
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ weight,float,n/a,1,"Weighting of a generator. Only used for network clustering."
p,series,MW,0.,active power at bus (positive if net generation),Output
q,series,MVar,0.,reactive power (positive if net generation),Output
p_nom_opt,float,MW,0.,Optimised nominal power.,Output
n_mod,int,n/a,0,Optimised number of modular generators if ``p_nom_mod`` is non-zero.,Output
status,series,n/a,1,"Status (1 is on, 0 is off). Only outputted if committable is True.",Output
mu_upper,series,currency/MWh,0.,Shadow price of upper p_nom limit,Output
mu_lower,series,currency/MWh,0.,Shadow price of lower p_nom limit,Output
Expand Down
1 change: 0 additions & 1 deletion pypsa/component_attrs/lines.csv
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@ b_pu,float,per unit,0,Per unit shunt susceptance calculated by PyPSA from b and
x_pu_eff,float,per unit,0,"Effective per unit series reactance for linear power flow, calculated by PyPSA from x, tap_ratio for transformers and bus.v_nom.",Output
r_pu_eff,float,per unit,0,"Effective per unit series resistance for linear power flow, calculated by PyPSA from x, tap_ratio for transformers and bus.v_nom.",Output
s_nom_opt,float,MVA,0,Optimised capacity for apparent power.,Output
n_mod,int,n/a,0,Optimised number of modular lines if ``s_nom_mod`` is non-zero.,Output
mu_lower,series,currency/MVA,0.,Shadow price of lower s_nom limit -F \leq f. Always non-negative.,Output
mu_upper,series,currency/MVA,0.,Shadow price of upper s_nom limit f \leq F. Always non-negative.,Output
1 change: 0 additions & 1 deletion pypsa/component_attrs/links.csv
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ ramp_limit_shut_down,float,per unit,1,"Maximum decrease at shut down, per unit o
p0,series,MW,0.,Active power at bus0 (positive if branch is withdrawing power from bus0).,Output
p1,series,MW,0.,Active power at bus1 (positive if branch is withdrawing power from bus1).,Output
p_nom_opt,float,MW,0,Optimised capacity for active power.,Output
n_mod,int,n/a,0,Optimised number of modular links if ``p_nom_mod`` is non-zero.,Output
status,series,n/a,1.,"Status (1 is on, 0 is off). Only outputted if committable is True.",Output
mu_lower,series,currency/MW,0.,Shadow price of lower p_nom limit -F \leq f. Always non-negative.,Output
mu_upper,series,currency/MW,0.,Shadow price of upper p_nom limit f \leq F. Always non-negative.,Output
Expand Down
1 change: 0 additions & 1 deletion pypsa/component_attrs/storage_units.csv
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ q,series,MVar,0,reactive power (positive if net generation),Output
state_of_charge,series,MWh,NaN,State of charge as calculated by the OPF.,Output
spill,series,MW,0,Spillage for each snapshot.,Output
p_nom_opt,float,MW,0,Optimised nominal power.,Output
n_mod,int,n/a,0,Optimised number of moudaler storage units if ``p_nom_mod`` is non-zero.,Output
mu_upper,series,currency/MWh,0,Shadow price of upper p_nom limit,Output
mu_lower,series,currency/MWh,0,Shadow price of lower p_nom limit,Output
mu_state_of_charge_set,series,currency/MWh,0,Shadow price of fixed state of charge state_of_charge_set,Output
Expand Down
1 change: 0 additions & 1 deletion pypsa/component_attrs/stores.csv
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ p,series,MW,0,active power at bus (positive if net generation),Output
q,series,MVar,0,reactive power (positive if net generation),Output
e,series,MWh,0,Energy as calculated by the OPF.,Output
e_nom_opt,float,MWh,0,Optimised nominal energy capacity outputed by OPF.,Output
n_mod,int,n/a,0,Optimised number of modular stores if ``e_nom_mod`` is non-zero.,Output
mu_upper,series,currency/MWh,0,Shadow price of upper e_nom limit,Output
mu_lower,series,currency/MWh,0,Shadow price of lower e_nom limit,Output
mu_energy_balance,series,currency/MWh,0,Shadow price of storage consistency equations,Output
1 change: 0 additions & 1 deletion pypsa/component_attrs/transformers.csv
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,5 @@ b_pu,float,per unit,0,Per unit shunt susceptance calculated by PyPSA from b and
x_pu_eff,float,per unit,0,"Effective per unit series reactance for linear power flow, calculated by PyPSA from x, tap_ratio for transformers and bus.v_nom.",Output
r_pu_eff,float,per unit,0,"Effective per unit series resistance for linear power flow, calculated by PyPSA from x, tap_ratio for transformers and bus.v_nom.",Output
s_nom_opt,float,MVA,0,Optimised capacity for apparent power.,Output
n_mod,int,n/a,0,Optimised number of modular transformers if ``s_nom_mod`` is non-zero.,Output
mu_lower,series,currency/MVA,0,Shadow price of lower s_nom limit -F \leq f. Always non-negative.,Output
mu_upper,series,currency/MVA,0,Shadow price of upper s_nom limit f \leq F. Always non-negative.,Output
4 changes: 1 addition & 3 deletions pypsa/linopf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1393,9 +1393,7 @@ def map_solution(c, attr):
non_ext = n.df(c)[attr]
n.df(c)[attr + "_opt"] = sol.reindex(non_ext.index).fillna(non_ext)
else:
if attr.endswith("-n_mod"):
n.df(c)["n_mod"].update(sol)
else:
if not attr.endswith("-n_mod"):
n.sols[c].df[attr] = sol

n.sols = Dict()
Expand Down
4 changes: 1 addition & 3 deletions pypsa/optimization/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,7 @@ def assign_solution(n):

else:
set_from_frame(n, c, attr, df)
elif attr == "n_mod":
n.df(c)[attr].update(df)
else:
elif attr != "n_mod":
n.df(c)[attr + "_opt"].update(df)

# if nominal capacity was no variable set optimal value to nominal
Expand Down
8 changes: 4 additions & 4 deletions test/test_lopf_modularity.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def test_modular_components(api):

optimize(n, api)

expected_n_opt_gen = np.array([5], dtype=float).T
expected_n_opt_store = np.array([10], dtype=float).T
expected_p_nom_opt_gen = np.array([5000], dtype=float).T
expected_e_nom_opt_store = np.array([1000], dtype=float).T

equal(n.generators.n_mod, expected_n_opt_gen)
equal(n.stores.n_mod, expected_n_opt_store)
equal(n.generators.p_nom_opt, expected_p_nom_opt_gen)
equal(n.stores.e_nom_opt, expected_e_nom_opt_store)

0 comments on commit d22f713

Please sign in to comment.