From 00b90237863cc1ee936442583c544a9af2121c50 Mon Sep 17 00:00:00 2001 From: Carlos-Alegre Date: Tue, 10 Dec 2024 16:32:18 +0100 Subject: [PATCH 1/4] Bugfix: Number of controlQ constraints now removes the controllable shunts --- .../Simulations/OPF/NumericalMethods/ac_opf_derivatives.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GridCalEngine/Simulations/OPF/NumericalMethods/ac_opf_derivatives.py b/src/GridCalEngine/Simulations/OPF/NumericalMethods/ac_opf_derivatives.py index d89497715..4616cd7f5 100644 --- a/src/GridCalEngine/Simulations/OPF/NumericalMethods/ac_opf_derivatives.py +++ b/src/GridCalEngine/Simulations/OPF/NumericalMethods/ac_opf_derivatives.py @@ -695,7 +695,7 @@ def jacobians_and_hessians(x: Vec, c1: Vec, c2: Vec, c_s: Vec, c_v: Vec, Cg: csc npq = len(pq) if ctQ: # if reactive power control... - nqct = Ng + nqct = Ng_nosh else: nqct = 0 From 85f15d49ccdeee23c822ef9135ec42432a40bf06 Mon Sep 17 00:00:00 2001 From: Carlos-Alegre Date: Tue, 10 Dec 2024 17:02:30 +0100 Subject: [PATCH 2/4] Bugfix: Number of controlQ constraints now removes the controllable shunts v2 --- .../OPF/NumericalMethods/ac_opf_derivatives.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/GridCalEngine/Simulations/OPF/NumericalMethods/ac_opf_derivatives.py b/src/GridCalEngine/Simulations/OPF/NumericalMethods/ac_opf_derivatives.py index 4616cd7f5..728a929d1 100644 --- a/src/GridCalEngine/Simulations/OPF/NumericalMethods/ac_opf_derivatives.py +++ b/src/GridCalEngine/Simulations/OPF/NumericalMethods/ac_opf_derivatives.py @@ -988,11 +988,11 @@ def jacobians_and_hessians(x: Vec, c1: Vec, c2: Vec, c_s: Vec, c_v: Vec, Cg: csc if ctQ: # if reactive power control... # tanmax curves (simplified capability curves of generators) - Hqmaxp = np.r_[2 * Pg[:Ng_nosh], np.zeros(nsh)] - Hqmaxq = np.r_[2 * Qg[:Ng_nosh], np.zeros(nsh)] + Hqmaxp = 2 * Pg[:Ng_nosh] + Hqmaxq = 2 * Qg[:Ng_nosh] Hqmaxv = - 2 * diags(np.power(Inom, 2.0)) * Cg[:, ig[:Ng_nosh]].T @ diags(vm) - Hqmax = sp.hstack([lil_matrix((nqct, N)), Hqmaxv, diags(Hqmaxp), diags(Hqmaxq), - lil_matrix((nqct, nsl + nslcap + ntapm + ntapt + ndc))]) + Hqmax = sp.hstack([lil_matrix((nqct, N)), Hqmaxv, diags(Hqmaxp), lil_matrix((nqct, nsh)), diags(Hqmaxq), + lil_matrix((nqct, nsh)), lil_matrix((nqct, nsl + nslcap + ntapm + ntapt + ndc))]) else: Hqmax = lil_matrix((nqct, NV)) Hqmaxv = lil_matrix((nqct, N)) From 3cf3eb51720a8df22782c2e68fd6e8ff6576d577 Mon Sep 17 00:00:00 2001 From: Carlos-Alegre Date: Tue, 10 Dec 2024 17:24:41 +0100 Subject: [PATCH 3/4] Added test_case for controlQ + controllable shunt interaction --- src/tests/test_ac_opf.py | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/tests/test_ac_opf.py b/src/tests/test_ac_opf.py index 0f6a7b9df..0f209d9d7 100644 --- a/src/tests/test_ac_opf.py +++ b/src/tests/test_ac_opf.py @@ -78,6 +78,34 @@ def case14() -> tuple[NonlinearOPFResults, NonlinearOPFResults, NonlinearOPFResu return base_sol, slack_sol, tap_sol, tap_slack_sol +def case14_ctrlQ_shunts() -> tuple[NonlinearOPFResults, NonlinearOPFResults, NonlinearOPFResults, NonlinearOPFResults]: + """ + Test case14 from matpower. Tests multiple situations + :return: + """ + cwd = os.getcwd() + print(cwd) + + # Go back two directories + file_path = os.path.join('data', 'grids', 'case14.m') + + grid = gce.FileOpen(file_path).open() + + for ll in range(len(grid.lines)): + grid.lines[ll].monitor_loading = True + + csh = gce.ControllableShunt(name="Cshunt", number_of_steps=2, b_per_step=15.0) + grid.add_controllable_shunt(bus=grid.buses[3], api_obj=csh) + grid.generators[2].Snom = 25.0 + + nc = gce.compile_numerical_circuit_at(grid) + pf_options = gce.PowerFlowOptions(control_q=False) + opf_options = gce.OptimalPowerFlowOptions(ips_method=gce.SolverType.NR, ips_tolerance=1e-8, ips_iterations=50, + acopf_mode=gce.AcOpfMode.ACOPFstd, ips_control_q_limits=True, verbose=0) + + base_sol = ac_optimal_power_flow(nc=nc, pf_options=pf_options, opf_options=opf_options) + + return base_sol def case_pegase89() -> NonlinearOPFResults: """ @@ -245,3 +273,21 @@ def test_pegase89(): assert np.allclose(res.Va, va_test, atol=1e-3) assert np.allclose(res.Pg, Pg_test, atol=1e-2) assert np.allclose(res.Qg, Qg_test, atol=1e-3) + + +def test_ieee14_controlQ_controllableshunts(): + + vm_test = [1.0600, 1.0398, 1.0044, 1.0195, 1.0194, 1.0600, 1.0488, + 1.0600, 1.0463, 1.0413, 1.0471, 1.0450, 1.0403, 1.0255] + va_test = [-0.0000, -0.0707, -0.1772, -0.1527, -0.1304, -0.2198, -0.1900, + -0.1683, -0.2233, -0.2277, -0.2260, -0.2343, -0.2351, -0.2462] + + Pg_test = [1.957688, 0.370331, 0.220336, 0.000012, 0.136859] + Qg_test = [0.000001, 0.217937, 0.120408, 0.095518, 0.068983, 0.178715] + + res = case14_ctrlQ_shunts() + + assert np.allclose(res.Vm, vm_test, atol=1e-2) + assert np.allclose(res.Va, va_test, atol=1e-2) + assert np.allclose(res.Pg, Pg_test, atol=1e-2) + assert np.allclose(np.r_[res.Qg, res.Qsh], Qg_test, atol=1e-2) \ No newline at end of file From f36bb18bde65a4b321ca653350b82d887685ad65 Mon Sep 17 00:00:00 2001 From: santi Date: Tue, 10 Dec 2024 16:33:33 +0000 Subject: [PATCH 4/4] 5.2.7 --- .idea/workspace.xml | 1386 +++++++++++++++++++----------- src/GridCal/Gui/Main/icons_rc.py | 404 ++++----- src/GridCal/__version__.py | 2 +- src/GridCalEngine/__version__.py | 2 +- src/GridCalServer/__version__.py | 2 +- 5 files changed, 1097 insertions(+), 699 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 56e5731de..6628db1d4 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,6 +1,8 @@ + @@ -26,8 +28,12 @@