From f8efb8ae00e5bb05f7f87d4b45052892c793e9c3 Mon Sep 17 00:00:00 2001 From: jinningwang Date: Wed, 24 Jan 2024 08:26:59 -0500 Subject: [PATCH 01/13] Remove routine base config adding --- ams/routines/routine.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/ams/routines/routine.py b/ams/routines/routine.py index fd464936..c403beb5 100644 --- a/ams/routines/routine.py +++ b/ams/routines/routine.py @@ -73,19 +73,6 @@ def __init__(self, system=None, config=None): if config is not None: self.config.load(config) - # TODO: these default configs might to be revised - self.config.add( - OrderedDict(( - ("sparselib", "klu"), - ) - ) - ) - self.config.add_extra( - "_help", sparselib="linear sparse solver name", - ) - self.config.add_extra( - "_alt", sparselib=("klu", "umfpack", "spsolve", "cupy"), - ) self.exec_time = 0.0 # recorded time to execute the routine in seconds # TODO: check exit_code of gurobipy or any other similiar solvers From 2b81d5f6bf31d82bea096ee0aed3ff7623e8cd72 Mon Sep 17 00:00:00 2001 From: jinningwang Date: Wed, 24 Jan 2024 08:27:16 -0500 Subject: [PATCH 02/13] Fix RTED formualtion regarding time interval --- ams/routines/rted.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ams/routines/rted.py b/ams/routines/rted.py index 7c741521..093f102e 100644 --- a/ams/routines/rted.py +++ b/ams/routines/rted.py @@ -49,6 +49,10 @@ def __init__(self): name='R10', tex_name=r'R_{10}', model='StaticGen', src='R10', unit='p.u./h',) + # NOTE: need to change args in dispatch routine using config.t + self.R10e = NumOp(info='Adjusted 10-min ramp rate', + name='R10e', tex_name=r'R_{10,e}', + u=self.R10, fun=np.dot,) class SFRBase: @@ -167,14 +171,15 @@ def __init__(self, system, config): self.rru.e_str = 'mul(ug, pg + pru) - mul(ug, pmax)' self.rrd.e_str = 'mul(ug, -pg + prd) + mul(ug, pmin)' # Gen ramping up/down - self.rgu.e_str = 'mul(ug, pg-pg0-R10)' - self.rgd.e_str = 'mul(ug, -pg+pg0-R10)' + self.R10e.args = dict(b=360*self.config.t) + self.rgu.e_str = 'mul(ug, pg-pg0-R10e)' + self.rgd.e_str = 'mul(ug, -pg+pg0-R10e)' # --- objective --- self.obj.info = 'total generation and reserve cost' # NOTE: the product of dt and pg is processed using ``dot``, # because dt is a numnber - cost = 'sum(mul(c2, power(pg, 2)))' + cost = 'sum(mul(c2, power(t dot pg, 2)))' cost += '+ sum(c1 @ (t dot pg))' cost += '+ ug * c0' # constant cost cost += '+ sum(cru * pru + crd * prd)' # reserve cost @@ -545,7 +550,7 @@ def __init__(self, system, config): gcost = 'sum(mul(c2, power(pg, 2)))' gcost += '+ sum(c1 @ (t dot pg))' gcost += '+ ug * c0 ' # constant cost - rcost = '+ sum(cru * pru + crd * prd) ' # reserve cost + rcost = '+ sum(cru * (t dot pru) + crd * (t dot prd)) ' # reserve cost vsgcost = '+ sum(cm * M + cd * D)' self.obj.e_str = gcost + rcost + vsgcost From 7e1589fe74321ff499aff21a77be18c4422c584c Mon Sep 17 00:00:00 2001 From: jinningwang Date: Wed, 24 Jan 2024 09:25:46 -0500 Subject: [PATCH 03/13] Fix mpc conversion units of gen ramp --- ams/io/matpower.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ams/io/matpower.py b/ams/io/matpower.py index 81c49f95..f47a9467 100644 --- a/ams/io/matpower.py +++ b/ams/io/matpower.py @@ -92,8 +92,8 @@ def mpc2system(mpc: dict, system) -> bool: mpc_gen[:, :10] = mpc['gen'] mbase = base_mva mpc_gen[:, 16] = system.PV.Ragc.default * mbase / 60 - mpc_gen[:, 17] = system.PV.R10.default * mbase / 6 - mpc_gen[:, 18] = system.PV.R30.default * mbase / 2 + mpc_gen[:, 17] = system.PV.R10.default * mbase + mpc_gen[:, 18] = system.PV.R30.default * mbase mpc_gen[:, 19] = system.PV.Rq.default * mbase / 60 else: mpc_gen = mpc['gen'] @@ -123,8 +123,8 @@ def mpc2system(mpc: dict, system) -> bool: qc2min = data[14] / mbase qc2max = data[15] / mbase ramp_agc = 60 * data[16] / mbase # from MW/min to MW/h - ramp_10 = 6 * data[17] / mbase # from MW/10min to MW/h - ramp_30 = 2 * data[18] / mbase # from MW/30min to MW/h + ramp_10 = data[17] / mbase # from MW to MW/h + ramp_30 = data[18] / mbase # from MW to MW/h ramp_q = 60 * data[19] / mbase # from MVAr/min to MVAr/h apf = data[20] @@ -341,6 +341,10 @@ def system2mpc(system) -> dict: gen[system.Slack.n:, 7] = PV.u.v gen[system.Slack.n:, 8] = (PV.ctrl.v * PV.pmax.v + (1 - PV.ctrl.v) * PV.pmax.v) * base_mva gen[system.Slack.n:, 9] = (PV.ctrl.v * PV.pmin.v + (1 - PV.ctrl.v) * PV.pmin.v) * base_mva + gen[system.Slack.n:, 16] = PV.Ragc.v * base_mva * 60 # from MW/h to MW/min + gen[system.Slack.n:, 17] = PV.R10.v * base_mva + gen[system.Slack.n:, 18] = PV.R30.v * base_mva + gen[system.Slack.n:, 19] = PV.Rq.v * base_mva * 60 # from MVAr/h to MVAr/min # --- Slack --- if system.Slack.n > 0: @@ -358,6 +362,10 @@ def system2mpc(system) -> dict: gen[:system.Slack.n, 7] = system.Slack.u.v gen[:system.Slack.n, 8] = system.Slack.pmax.v * base_mva gen[:system.Slack.n, 9] = system.Slack.pmin.v * base_mva + gen[:system.Slack.n, 16] = system.Slack.Ragc.v * base_mva * 60 # from MW/h to MW/min + gen[:system.Slack.n, 17] = system.Slack.R10.v * base_mva + gen[:system.Slack.n, 18] = system.Slack.R30.v * base_mva + gen[:system.Slack.n, 19] = system.Slack.Rq.v * base_mva * 60 # from MVAr/h to MVAr/min if system.Line.n > 0: branch = mpc['branch'] From 633202a9edcb28c8a0dabd42c6e0bf946473270f Mon Sep 17 00:00:00 2001 From: jinningwang Date: Wed, 24 Jan 2024 09:28:02 -0500 Subject: [PATCH 04/13] FIX RTED interval settings --- ams/routines/rted.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ams/routines/rted.py b/ams/routines/rted.py index 093f102e..d18f86c4 100644 --- a/ams/routines/rted.py +++ b/ams/routines/rted.py @@ -49,10 +49,6 @@ def __init__(self): name='R10', tex_name=r'R_{10}', model='StaticGen', src='R10', unit='p.u./h',) - # NOTE: need to change args in dispatch routine using config.t - self.R10e = NumOp(info='Adjusted 10-min ramp rate', - name='R10e', tex_name=r'R_{10,e}', - u=self.R10, fun=np.dot,) class SFRBase: @@ -171,9 +167,8 @@ def __init__(self, system, config): self.rru.e_str = 'mul(ug, pg + pru) - mul(ug, pmax)' self.rrd.e_str = 'mul(ug, -pg + prd) + mul(ug, pmin)' # Gen ramping up/down - self.R10e.args = dict(b=360*self.config.t) - self.rgu.e_str = 'mul(ug, pg-pg0-R10e)' - self.rgd.e_str = 'mul(ug, -pg+pg0-R10e)' + self.rgu.e_str = 'mul(ug, pg-pg0-R10)' + self.rgd.e_str = 'mul(ug, -pg+pg0-R10)' # --- objective --- self.obj.info = 'total generation and reserve cost' From e752692d3571362e3a23a19915d6d6feb3b8a34d Mon Sep 17 00:00:00 2001 From: jinningwang Date: Wed, 24 Jan 2024 09:28:21 -0500 Subject: [PATCH 05/13] FIX ED interval settings --- ams/routines/ed.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ams/routines/ed.py b/ams/routines/ed.py index 625e2e57..d11d8693 100644 --- a/ams/routines/ed.py +++ b/ams/routines/ed.py @@ -83,7 +83,7 @@ def __init__(self) -> None: self.R30 = RParam(info='30-min ramp rate', name='R30', tex_name=r'R_{30}', - src='R30', unit='p.u./min', + src='R30', unit='p.u./h', model='StaticGen', no_parse=True,) self.Mr = RampSub(u=self.pg, name='Mr', tex_name=r'M_{r}', info='Subtraction matrix for ramping', @@ -210,7 +210,7 @@ def __init__(self, system, config): # constant cost cost += '+ sum(mul(ugt, mul(c0, tlv)))' # spinning reserve cost - cost += ' + sum(csr@prs)' + cost += ' + sum(csr@(t dot prs))' self.obj.e_str = cost def _post_solve(self): From 841f4068841e504bd274ebb5625775be45f4adef Mon Sep 17 00:00:00 2001 From: jinningwang Date: Wed, 24 Jan 2024 09:39:39 -0500 Subject: [PATCH 06/13] Rerun examples and demo --- .../{1. ESD1.ipynb => demo_ESD1.ipynb} | 107 +++-- examples/ex1.ipynb | 144 +++---- examples/ex2.ipynb | 379 +++++++++++++++++- examples/ex3.ipynb | 39 +- examples/ex4.ipynb | 20 +- examples/ex5.ipynb | 38 +- examples/ex6.ipynb | 26 +- 7 files changed, 559 insertions(+), 194 deletions(-) rename examples/demonstration/{1. ESD1.ipynb => demo_ESD1.ipynb} (86%) diff --git a/examples/demonstration/1. ESD1.ipynb b/examples/demonstration/demo_ESD1.ipynb similarity index 86% rename from examples/demonstration/1. ESD1.ipynb rename to examples/demonstration/demo_ESD1.ipynb index 7e86af06..4fcb0b0c 100644 --- a/examples/demonstration/1. ESD1.ipynb +++ b/examples/demonstration/demo_ESD1.ipynb @@ -40,8 +40,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "Last run time: 2023-11-28 22:03:14\n", - "ams:0.7.3.post74.dev0+g47c1ae3\n" + "Last run time: 2024-01-24 09:39:21\n", + "ams:0.8.1.post5.dev0+ge752692\n" ] } ], @@ -77,8 +77,10 @@ "output_type": "stream", "text": [ "Parsing input file \"/Users/jinningwang/Documents/work/ams/ams/cases/5bus/pjm5bus_uced_esd1.xlsx\"...\n", - "Input file parsed in 0.1205 seconds.\n", - "System set up in 0.0031 seconds.\n" + "Input file parsed in 0.1276 seconds.\n", + "Zero line rates detacted in rate_a, rate_b, rate_c, adjusted to 999.\n", + "If expect a line outage, please set 'u' to 0.\n", + "System set up in 0.0021 seconds.\n" ] } ], @@ -159,8 +161,8 @@ " ESD1_1\n", " 1.0\n", " ESD1_1\n", - " 0\n", - " PV_1\n", + " 1\n", + " PV_2\n", " 100.0\n", " 1.0\n", " 1.0\n", @@ -178,7 +180,7 @@ "text/plain": [ " idx u name bus gen Sn gammap gammaq SOCmin SOCmax \\\n", "uid \n", - "0 ESD1_1 1.0 ESD1_1 0 PV_1 100.0 1.0 1.0 0.0 1.0 \n", + "0 ESD1_1 1.0 ESD1_1 1 PV_2 100.0 1.0 1.0 0.0 1.0 \n", "\n", " SOCinit En EtaC EtaD \n", "uid \n", @@ -198,12 +200,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "`RTEDES` is the RTED model extended to include energy storage.\n", + "`RTEDES` extends RTED to include energy storage.\n", "\n", "Note that mixed integer linear programming (MILP) requires\n", "capable solvers such as Gurobi or CPLEX.\n", - "They might require license and installation.\n", + "They might require extra installation and have their own license.\n", "\n", + "The example here only aims to show the usage of RTEDES.\n", "More details can be found at [CVXPY - Choosing a solver](https://www.cvxpy.org/tutorial/advanced/index.html#choosing-a-solver)." ] }, @@ -216,7 +219,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "Routine initialized in 0.0140 seconds.\n" + "Routine initialized in 0.0312 seconds.\n" ] }, { @@ -224,14 +227,14 @@ "output_type": "stream", "text": [ "Set parameter Username\n", - "Academic license - for non-commercial use only - expires 2024-05-21\n" + "Academic license - for non-commercial use only - expires 2024-12-17\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "RTEDES solved as optimal in 0.0341 seconds, converged after 0 iteration using solver GUROBI.\n" + "RTEDES solved as optimal in 0.0599 seconds, converged after 3 iterations using solver GUROBI.\n" ] }, { @@ -310,13 +313,13 @@ " \n", " 3\n", " pde\n", - " [2.1]\n", + " [8.5]\n", " ESD1 discharging power\n", " \n", " \n", " 4\n", " SOC\n", - " [0.1982]\n", + " [0.1929]\n", " ESD1 State of Charge\n", " \n", " \n", @@ -334,8 +337,8 @@ "0 uce [0.0] ESD1 charging decision\n", "1 ude [1.0] ESD1 discharging decision\n", "2 pce [0.0] ESD1 charging power\n", - "3 pde [2.1] ESD1 discharging power\n", - "4 SOC [0.1982] ESD1 State of Charge\n", + "3 pde [8.5] ESD1 discharging power\n", + "4 SOC [0.1929] ESD1 State of Charge\n", "5 SOCinit [0.2] Initial SOC" ] }, @@ -370,13 +373,33 @@ "cell_type": "code", "execution_count": 8, "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sp.EDES.config.t" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Routine initialized in 0.0238 seconds.\n", - "EDES solved as optimal in 0.0349 seconds, converged after 0 iteration using solver GUROBI.\n" + "Routine initialized in 0.0292 seconds.\n", + "EDES solved as optimal in 0.0468 seconds, converged after 22 iterations using solver GUROBI.\n" ] }, { @@ -385,7 +408,7 @@ "True" ] }, - "execution_count": 8, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -396,7 +419,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -447,13 +470,13 @@ " \n", " 3\n", " pde\n", - " [[2.1, 2.1, 2.1, 2.1]]\n", + " [[0.0, 0.0, 0.0, 0.0]]\n", " ESD1 discharging power\n", " \n", " \n", " 4\n", " SOC\n", - " [[0.179, 0.179, 0.179, 0.179]]\n", + " [[0.2, 0.2, 0.2, 0.2]]\n", " ESD1 State of Charge\n", " \n", " \n", @@ -467,37 +490,37 @@ "" ], "text/plain": [ - " Var Value info\n", - "0 uce [[0.0, 0.0, 0.0, 0.0]] ESD1 charging decision\n", - "1 ude [[1.0, 1.0, 1.0, 1.0]] ESD1 discharging decision\n", - "2 pce [[0.0, 0.0, 0.0, 0.0]] ESD1 charging power\n", - "3 pde [[2.1, 2.1, 2.1, 2.1]] ESD1 discharging power\n", - "4 SOC [[0.179, 0.179, 0.179, 0.179]] ESD1 State of Charge\n", - "5 SOCinit [0.2] Initial SOC" + " Var Value info\n", + "0 uce [[0.0, 0.0, 0.0, 0.0]] ESD1 charging decision\n", + "1 ude [[1.0, 1.0, 1.0, 1.0]] ESD1 discharging decision\n", + "2 pce [[0.0, 0.0, 0.0, 0.0]] ESD1 charging power\n", + "3 pde [[0.0, 0.0, 0.0, 0.0]] ESD1 discharging power\n", + "4 SOC [[0.2, 0.2, 0.2, 0.2]] ESD1 State of Charge\n", + "5 SOCinit [0.2] Initial SOC" ] }, - "execution_count": 9, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "ESESres = pd.DataFrame()\n", + "EDESres = pd.DataFrame()\n", "\n", "items = [sp.EDES.uce, sp.EDES.ude,\n", " sp.EDES.pce, sp.EDES.pde,\n", " sp.EDES.SOC, sp.EDES.SOCinit]\n", "\n", - "ESESres['Var'] = [item.name for item in items]\n", - "ESESres['Value'] = [item.v.round(4) for item in items]\n", - "ESESres['info'] = [item.info for item in items]\n", + "EDESres['Var'] = [item.name for item in items]\n", + "EDESres['Value'] = [item.v.round(4) for item in items]\n", + "EDESres['info'] = [item.info for item in items]\n", "\n", - "ESESres" + "EDESres" ] }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -505,9 +528,9 @@ "output_type": "stream", "text": [ "All generators are online at initial, make initial guess for commitment.\n", - "Turn off StaticGen PV_1 as initial commitment guess.\n", - "Routine initialized in 0.0272 seconds.\n", - "UCES solved as optimal in 0.0369 seconds, converged after 0 iteration using solver GUROBI.\n" + "Turn off StaticGen ['PV_1'] as initial commitment guess.\n", + "Routine initialized in 0.0289 seconds.\n", + "UCES solved as optimal in 0.0341 seconds, converged after 1 iteration using solver GUROBI.\n" ] }, { @@ -516,7 +539,7 @@ "True" ] }, - "execution_count": 10, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -527,7 +550,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -607,7 +630,7 @@ "5 SOCinit [0.2] Initial SOC" ] }, - "execution_count": 11, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } diff --git a/examples/ex1.ipynb b/examples/ex1.ipynb index fea75935..de4dd2fd 100644 --- a/examples/ex1.ipynb +++ b/examples/ex1.ipynb @@ -51,8 +51,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "Last run time: 2024-01-16 16:51:04\n", - "ams:0.8.0.post7.dev0+g2da39e4\n" + "Last run time: 2024-01-24 09:37:17\n", + "ams:0.8.1.post5+ge752692\n" ] } ], @@ -127,10 +127,10 @@ "output_type": "stream", "text": [ "Parsing input file \"/Users/jinningwang/Documents/work/ams/ams/cases/5bus/pjm5bus_uced.xlsx\"...\n", - "Input file parsed in 0.1150 seconds.\n", + "Input file parsed in 0.1218 seconds.\n", "Zero line rates detacted in rate_a, rate_b, rate_c, adjusted to 999.\n", "If expect a line outage, please set 'u' to 0.\n", - "System set up in 0.0020 seconds.\n" + "System set up in 0.0021 seconds.\n" ] } ], @@ -164,33 +164,33 @@ { "data": { "text/plain": [ - "OrderedDict([('Summary', Summary (3 devices) at 0x1122ab550),\n", - " ('Bus', Bus (5 devices) at 0x15ca01160),\n", - " ('PQ', PQ (3 devices) at 0x15ca019d0),\n", - " ('PV', PV (3 devices) at 0x15ca01f40),\n", - " ('Slack', Slack (1 device) at 0x15ca139d0),\n", - " ('Shunt', Shunt (0 devices) at 0x15ca1f490),\n", - " ('Line', Line (7 devices) at 0x15ca1f940),\n", - " ('PVD1', PVD1 (0 devices) at 0x15ca3b070),\n", - " ('ESD1', ESD1 (0 devices) at 0x15ca3b670),\n", - " ('REGCA1', REGCA1 (0 devices) at 0x15ca3bbe0),\n", - " ('REGCV1', REGCV1 (0 devices) at 0x15ca48220),\n", - " ('REGCV2', REGCV2 (0 devices) at 0x15ca48a00),\n", - " ('Area', Area (3 devices) at 0x15ca48f40),\n", - " ('Region', Region (2 devices) at 0x15ca55700),\n", - " ('SFR', SFR (2 devices) at 0x15ca55eb0),\n", - " ('SR', SR (2 devices) at 0x15ca61550),\n", - " ('NSR', NSR (2 devices) at 0x15ca61970),\n", - " ('VSGR', VSGR (0 devices) at 0x15ca61d90),\n", - " ('GCost', GCost (4 devices) at 0x16807a220),\n", - " ('SFRCost', SFRCost (4 devices) at 0x16807a8b0),\n", - " ('SRCost', SRCost (4 devices) at 0x16807ae50),\n", - " ('NSRCost', NSRCost (4 devices) at 0x1680882b0),\n", - " ('VSGCost', VSGCost (0 devices) at 0x1680886d0),\n", - " ('DCost', DCost (3 devices) at 0x1680889d0),\n", - " ('TimeSlot', TimeSlot (0 devices) at 0x168088f40),\n", - " ('EDTSlot', EDTSlot (24 devices) at 0x168090a00),\n", - " ('UCTSlot', UCTSlot (24 devices) at 0x168090e20)])" + "OrderedDict([('Summary', Summary (3 devices) at 0x105584d30),\n", + " ('Bus', Bus (5 devices) at 0x1056110d0),\n", + " ('PQ', PQ (3 devices) at 0x12f9b8df0),\n", + " ('PV', PV (3 devices) at 0x12f9caa60),\n", + " ('Slack', Slack (1 device) at 0x12f9e0910),\n", + " ('Shunt', Shunt (0 devices) at 0x12f9eb3d0),\n", + " ('Line', Line (7 devices) at 0x12f9eb880),\n", + " ('PVD1', PVD1 (0 devices) at 0x12f9f4f70),\n", + " ('ESD1', ESD1 (0 devices) at 0x12fa065b0),\n", + " ('REGCA1', REGCA1 (0 devices) at 0x12fa06b20),\n", + " ('REGCV1', REGCV1 (0 devices) at 0x12fa11160),\n", + " ('REGCV2', REGCV2 (0 devices) at 0x12fa11940),\n", + " ('Area', Area (3 devices) at 0x12fa11e80),\n", + " ('Region', Region (2 devices) at 0x12fa1e640),\n", + " ('SFR', SFR (2 devices) at 0x12fa1edf0),\n", + " ('SR', SR (2 devices) at 0x12fa2e490),\n", + " ('NSR', NSR (2 devices) at 0x12fa2e8b0),\n", + " ('VSGR', VSGR (0 devices) at 0x12fa2ecd0),\n", + " ('GCost', GCost (4 devices) at 0x12fa3a160),\n", + " ('SFRCost', SFRCost (4 devices) at 0x12fa3a7f0),\n", + " ('SRCost', SRCost (4 devices) at 0x12fa3ad90),\n", + " ('NSRCost', NSRCost (4 devices) at 0x12fa471f0),\n", + " ('VSGCost', VSGCost (0 devices) at 0x12fa47610),\n", + " ('DCost', DCost (3 devices) at 0x12fa47910),\n", + " ('TimeSlot', TimeSlot (0 devices) at 0x12fa47e80),\n", + " ('EDTSlot', EDTSlot (24 devices) at 0x12fa50940),\n", + " ('UCTSlot', UCTSlot (24 devices) at 0x12fa50d60)])" ] }, "execution_count": 5, @@ -343,23 +343,23 @@ { "data": { "text/plain": [ - "OrderedDict([('DCPF', DCPF at 0x15c991e80),\n", - " ('PFlow', PFlow at 0x16809fa90),\n", - " ('CPF', CPF at 0x1680b2100),\n", - " ('ACOPF', ACOPF at 0x1680b2730),\n", - " ('DCOPF', DCOPF at 0x1680c9040),\n", - " ('ED', ED at 0x1680c9d30),\n", - " ('EDDG', EDDG at 0x168201eb0),\n", - " ('EDES', EDES at 0x168225850),\n", - " ('RTED', RTED at 0x168424ca0),\n", - " ('RTEDDG', RTEDDG at 0x168436eb0),\n", - " ('RTEDES', RTEDES at 0x16845a2b0),\n", - " ('RTEDVIS', RTEDVIS at 0x16846ef40),\n", - " ('UC', UC at 0x17de58670),\n", - " ('UCDG', UCDG at 0x17e396cd0),\n", - " ('UCES', UCES at 0x17e3b8b80),\n", - " ('DOPF', DOPF at 0x17e5014f0),\n", - " ('DOPFVIS', DOPFVIS at 0x17e516730)])" + "OrderedDict([('DCPF', DCPF at 0x12f9b8490),\n", + " ('PFlow', PFlow at 0x12fa5fa00),\n", + " ('CPF', CPF at 0x12fa73070),\n", + " ('ACOPF', ACOPF at 0x12fa736a0),\n", + " ('DCOPF', DCOPF at 0x12fa73fa0),\n", + " ('ED', ED at 0x12fca9100),\n", + " ('EDDG', EDDG at 0x12fcb40a0),\n", + " ('EDES', EDES at 0x12fcc7ac0),\n", + " ('RTED', RTED at 0x12fe09fd0),\n", + " ('RTEDDG', RTEDDG at 0x12fe1c0d0),\n", + " ('RTEDES', RTEDES at 0x12fe42760),\n", + " ('RTEDVIS', RTEDVIS at 0x12fe684f0),\n", + " ('UC', UC at 0x12fe7ac40),\n", + " ('UCDG', UCDG at 0x160845430),\n", + " ('UCES', UCES at 0x160866370),\n", + " ('DOPF', DOPF at 0x16088dd60),\n", + " ('DOPFVIS', DOPFVIS at 0x1608b0070)])" ] }, "execution_count": 7, @@ -389,14 +389,14 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Routine initialized in 0.0123 seconds.\n" + "Routine initialized in 0.0130 seconds.\n" ] }, { @@ -405,7 +405,7 @@ "True" ] }, - "execution_count": 9, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -427,7 +427,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -448,7 +448,7 @@ " 'SCS']" ] }, - "execution_count": 10, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -459,14 +459,14 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "RTED solved as optimal in 0.0156 seconds, converged after 11 iterations using solver ECOS.\n" + "RTED solved as optimal in 0.0173 seconds, converged after 9 iterations using solver ECOS.\n" ] }, { @@ -475,7 +475,7 @@ "True" ] }, - "execution_count": 11, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -495,7 +495,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -504,7 +504,7 @@ "array([2.1, 5.2, 0.7, 2. ])" ] }, - "execution_count": 12, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -522,7 +522,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -531,7 +531,7 @@ "['PV_1', 'PV_3', 'PV_5', 'Slack_4']" ] }, - "execution_count": 13, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -549,7 +549,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -558,7 +558,7 @@ "array([2.1, 5.2])" ] }, - "execution_count": 14, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -576,7 +576,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -589,7 +589,7 @@ " ('prd', Var: StaticGen.prd)])" ] }, - "execution_count": 15, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -607,16 +607,16 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "0.19537500009190154" + "0.19537500005072062" ] }, - "execution_count": 16, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -635,7 +635,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -646,6 +646,8 @@ " ('pb', Constraint: pb [ON]),\n", " ('plflb', Constraint: plflb [ON]),\n", " ('plfub', Constraint: plfub [ON]),\n", + " ('alflb', Constraint: alflb [ON]),\n", + " ('alfub', Constraint: alfub [ON]),\n", " ('rbu', Constraint: rbu [ON]),\n", " ('rbd', Constraint: rbd [ON]),\n", " ('rru', Constraint: rru [ON]),\n", @@ -654,7 +656,7 @@ " ('rgd', Constraint: rgd [ON])])" ] }, - "execution_count": 17, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -672,7 +674,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -681,7 +683,7 @@ "array([-996.9, -993.8, -998.3, -997. ])" ] }, - "execution_count": 18, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } diff --git a/examples/ex2.ipynb b/examples/ex2.ipynb index 73fff278..75d32665 100644 --- a/examples/ex2.ipynb +++ b/examples/ex2.ipynb @@ -36,8 +36,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "Last run time: 2024-01-16 21:45:37\n", - "ams:0.8.0.post7.dev0+g2da39e4\n" + "Last run time: 2024-01-24 09:37:24\n", + "ams:0.8.1.post5+ge752692\n" ] } ], @@ -82,10 +82,10 @@ "output_type": "stream", "text": [ "Parsing input file \"/Users/jinningwang/Documents/work/ams/ams/cases/5bus/pjm5bus_uced.xlsx\"...\n", - "Input file parsed in 0.1210 seconds.\n", + "Input file parsed in 0.1140 seconds.\n", "Zero line rates detacted in rate_a, rate_b, rate_c, adjusted to 999.\n", "If expect a line outage, please set 'u' to 0.\n", - "System set up in 0.0020 seconds.\n" + "System set up in 0.0018 seconds.\n" ] } ], @@ -270,8 +270,8 @@ "name": "stderr", "output_type": "stream", "text": [ - "Routine initialized in 0.0117 seconds.\n", - "RTED solved as optimal in 0.0146 seconds, converged after 11 iterations using solver ECOS.\n" + "Routine initialized in 0.0114 seconds.\n", + "RTED solved as optimal in 0.0147 seconds, converged after 9 iterations using solver ECOS.\n" ] }, { @@ -416,7 +416,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "RTED solved as optimal in 0.0017 seconds, converged after 11 iterations using solver ECOS.\n" + "RTED solved as optimal in 0.0016 seconds, converged after 9 iterations using solver ECOS.\n" ] }, { @@ -471,7 +471,7 @@ { "data": { "text/plain": [ - "StaticLoad (3 devices) at 0x145144d90" + "StaticLoad (3 devices) at 0x15ad1e340" ] }, "execution_count": 14, @@ -690,7 +690,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "RTED solved as optimal in 0.0023 seconds, converged after 11 iterations using solver ECOS.\n" + "RTED solved as optimal in 0.0018 seconds, converged after 9 iterations using solver ECOS.\n" ] }, { @@ -723,7 +723,7 @@ { "data": { "text/plain": [ - "array([2.1 , 5.19999999, 2.30000002, 2. ])" + "array([2.1, 5.2, 2.3, 2. ])" ] }, "execution_count": 20, @@ -1007,7 +1007,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "RTED solved as optimal in 0.0138 seconds, converged after 10 iterations using solver ECOS.\n" + "RTED solved as optimal in 0.0154 seconds, converged after 8 iterations using solver ECOS.\n" ] }, { @@ -1040,7 +1040,7 @@ { "data": { "text/plain": [ - "array([0. , 5.2, 4.4, 2. ])" + "array([-0. , 5.2, 4.4, 2. ])" ] }, "execution_count": 25, @@ -1421,7 +1421,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "RTED solved as optimal in 0.0145 seconds, converged after 10 iterations using solver ECOS.\n" + "RTED solved as optimal in 0.0152 seconds, converged after 8 iterations using solver ECOS.\n" ] }, { @@ -1470,7 +1470,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Manipulate the Constraints" + "## Disable the Constraints" ] }, { @@ -1492,10 +1492,10 @@ "output_type": "stream", "text": [ "Parsing input file \"/Users/jinningwang/Documents/work/ams/ams/cases/5bus/pjm5bus_uced.xlsx\"...\n", - "Input file parsed in 0.0389 seconds.\n", + "Input file parsed in 0.0368 seconds.\n", "Zero line rates detacted in rate_a, rate_b, rate_c, adjusted to 999.\n", "If expect a line outage, please set 'u' to 0.\n", - "System set up in 0.0049 seconds.\n" + "System set up in 0.0020 seconds.\n" ] } ], @@ -1514,7 +1514,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "Routine initialized in 0.0095 seconds.\n" + "Routine initialized in 0.0100 seconds.\n" ] }, { @@ -1593,6 +1593,8 @@ " ('pb', Constraint: pb [ON]),\n", " ('plflb', Constraint: plflb [ON]),\n", " ('plfub', Constraint: plfub [ON]),\n", + " ('alflb', Constraint: alflb [ON]),\n", + " ('alfub', Constraint: alfub [ON]),\n", " ('rbu', Constraint: rbu [ON]),\n", " ('rbd', Constraint: rbd [ON]),\n", " ('rru', Constraint: rru [ON]),\n", @@ -1626,7 +1628,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "RTED solved as optimal in 0.0156 seconds, converged after 10 iterations using solver ECOS.\n" + "RTED solved as optimal in 0.0158 seconds, converged after 9 iterations using solver ECOS.\n" ] }, { @@ -1718,6 +1720,8 @@ " ('pb', Constraint: pb [ON]),\n", " ('plflb', Constraint: plflb [OFF]),\n", " ('plfub', Constraint: plfub [OFF]),\n", + " ('alflb', Constraint: alflb [ON]),\n", + " ('alfub', Constraint: alfub [ON]),\n", " ('rbu', Constraint: rbu [ON]),\n", " ('rbd', Constraint: rbd [ON]),\n", " ('rru', Constraint: rru [ON]),\n", @@ -1746,7 +1750,7 @@ "text": [ "Disabled constraints: plflb, plfub\n", "Routine initialized in 0.0080 seconds.\n", - "RTED solved as optimal in 0.0120 seconds, converged after 11 iterations using solver ECOS.\n" + "RTED solved as optimal in 0.0128 seconds, converged after 9 iterations using solver ECOS.\n" ] }, { @@ -1838,6 +1842,8 @@ " ('pb', Constraint: pb [ON]),\n", " ('plflb', Constraint: plflb [ON]),\n", " ('plfub', Constraint: plfub [ON]),\n", + " ('alflb', Constraint: alflb [ON]),\n", + " ('alfub', Constraint: alfub [ON]),\n", " ('rbu', Constraint: rbu [ON]),\n", " ('rbd', Constraint: rbd [ON]),\n", " ('rru', Constraint: rru [ON]),\n", @@ -1864,8 +1870,8 @@ "name": "stderr", "output_type": "stream", "text": [ - "Routine initialized in 0.0132 seconds.\n", - "RTED solved as optimal in 0.0131 seconds, converged after 10 iterations using solver ECOS.\n" + "Routine initialized in 0.0086 seconds.\n", + "RTED solved as optimal in 0.0150 seconds, converged after 9 iterations using solver ECOS.\n" ] }, { @@ -1946,7 +1952,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "Routine initialized in 0.0091 seconds.\n" + "Routine initialized in 0.0093 seconds.\n" ] }, { @@ -1977,6 +1983,8 @@ " ('pb', Constraint: pb [ON]),\n", " ('plflb', Constraint: plflb [ON]),\n", " ('plfub', Constraint: plfub [ON]),\n", + " ('alflb', Constraint: alflb [ON]),\n", + " ('alfub', Constraint: alfub [ON]),\n", " ('rbu', Constraint: rbu [ON]),\n", " ('rbd', Constraint: rbd [ON]),\n", " ('rru', Constraint: rru [ON]),\n", @@ -1993,6 +2001,333 @@ "source": [ "spc.RTED.constrs" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Alter the Config" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In AMS, routines have an ``config`` object as configuration settings." + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Parsing input file \"/Users/jinningwang/Documents/work/ams/ams/cases/5bus/pjm5bus_uced.xlsx\"...\n", + "Input file parsed in 0.0961 seconds.\n", + "Zero line rates detacted in rate_a, rate_b, rate_c, adjusted to 999.\n", + "If expect a line outage, please set 'u' to 0.\n", + "System set up in 0.0021 seconds.\n" + ] + } + ], + "source": [ + "spf = ams.load(ams.get_case('5bus/pjm5bus_uced.xlsx'),\n", + " setup=True,\n", + " no_output=True,)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In RTED, the default interval is 5/60 [hour], and the formulations has been adjusted to fit the interval." + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "OrderedDict([('t', 0.08333333333333333)])" + ] + }, + "execution_count": 50, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "spf.RTED.config" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Routine initialized in 0.0100 seconds.\n", + "RTED solved as optimal in 0.0145 seconds, converged after 9 iterations using solver ECOS.\n" + ] + }, + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "spf.RTED.run(solver='ECOS')" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.19537500005072062" + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "spf.RTED.obj.v" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can update the interval to 1 [hour] and re-solve the dispatch.\n", + "\n", + "Note that in this senario, compared to DCOPF, RTED has extra costs for ``pru`` and ``prd``." + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "metadata": {}, + "outputs": [], + "source": [ + "spf.RTED.config.t = 60/60" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Remember to update the parameters after the change." + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Re-init RTED OModel due to non-parametric change.\n" + ] + }, + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 54, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "spf.RTED.update()" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "RTED solved as optimal in 0.0164 seconds, converged after 325 iterations using solver SCS.\n" + ] + }, + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 55, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "spf.RTED.run(solver='SCS')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can then get the objective value." + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2.3444999986498134" + ] + }, + "execution_count": 56, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "spf.RTED.obj.v" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Note that in this build-in case, the ``cru`` and ``crd`` are defined as zero." + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([0., 0., 0., 0.])" + ] + }, + "execution_count": 57, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "spf.RTED.cru.v" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([0., 0., 0., 0.])" + ] + }, + "execution_count": 58, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "spf.RTED.crd.v" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "As benchmark, we can solve the DCOPF." + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Routine initialized in 0.0050 seconds.\n", + "DCOPF solved as optimal in 0.0103 seconds, converged after 225 iterations using solver SCS.\n" + ] + }, + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "spf.DCOPF.run(solver='SCS')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "As expected, the DCOPF has a similar objective value." + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2.3445094955490013" + ] + }, + "execution_count": 60, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "spf.DCOPF.obj.v" + ] } ], "metadata": { diff --git a/examples/ex3.ipynb b/examples/ex3.ipynb index 503c9a37..a2a17557 100644 --- a/examples/ex3.ipynb +++ b/examples/ex3.ipynb @@ -36,8 +36,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "Last run time: 2024-01-20 06:52:52\n", - "ams:0.8.0.post21+gdce75d5\n" + "Last run time: 2024-01-24 09:37:33\n", + "ams:0.8.1.post5+ge752692\n" ] } ], @@ -73,10 +73,10 @@ "output_type": "stream", "text": [ "Parsing input file \"/Users/jinningwang/Documents/work/ams/ams/cases/5bus/pjm5bus_uced.xlsx\"...\n", - "Input file parsed in 0.1544 seconds.\n", + "Input file parsed in 0.1172 seconds.\n", "Zero line rates detacted in rate_a, rate_b, rate_c, adjusted to 999.\n", "If expect a line outage, please set 'u' to 0.\n", - "System set up in 0.0037 seconds.\n" + "System set up in 0.0018 seconds.\n" ] } ], @@ -217,19 +217,21 @@ "\n", "Constraints\n", "\n", - " Name | Description \n", - "-------+----------------------\n", - " pglb | pg min \n", - " pgub | pg max \n", - " pb | power balance \n", - " plflb | line flow lower bound\n", - " plfub | line flow upper bound\n", - " rbu | RegUp reserve balance\n", - " rbd | RegDn reserve balance\n", - " rru | RegUp reserve source \n", - " rrd | RegDn reserve source \n", - " rgu | Gen ramping up \n", - " rgd | Gen ramping down \n", + " Name | Description \n", + "-------+----------------------------------\n", + " pglb | pg min \n", + " pgub | pg max \n", + " pb | power balance \n", + " plflb | line flow lower bound \n", + " plfub | line flow upper bound \n", + " alflb | line angle difference lower bound\n", + " alfub | line angle difference upper bound\n", + " rbu | RegUp reserve balance \n", + " rbd | RegDn reserve balance \n", + " rru | RegUp reserve source \n", + " rrd | RegDn reserve source \n", + " rgu | Gen ramping up \n", + " rgd | Gen ramping down \n", "\n", "Vars\n", "\n", @@ -248,6 +250,7 @@ " ctrle | Effective Gen controllability | NumOpDual\n", " nctrl | Effective Gen uncontrollability | NumOp \n", " nctrle | Effective Gen uncontrollability | NumOpDual\n", + " amax | max line angle difference | NumOp \n", " gs | Sum Gen vars vector in shape of zone | ZonalSum \n", " ds | Sum pd vector in shape of zone | ZonalSum \n", " pdz | zonal total load | NumOpDual\n", @@ -271,7 +274,7 @@ " gsh | shunt conductance | \n", " Cg | Gen connection matrix | \n", " Cl | Load connection matrix | \n", - " Cft | Line connection matrix | \n", + " CftT | Transpose of line connection matrix | \n", " Csh | Shunt connection matrix | \n", " Bbus | Bus admittance matrix | \n", " Bf | Bf matrix | \n", diff --git a/examples/ex4.ipynb b/examples/ex4.ipynb index 27d62771..f77afd13 100644 --- a/examples/ex4.ipynb +++ b/examples/ex4.ipynb @@ -45,8 +45,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "Last run time: 2024-01-20 07:07:12\n", - "ams:0.8.0.post21+gdce75d5\n" + "Last run time: 2024-01-24 09:37:40\n", + "ams:0.8.1.post5+ge752692\n" ] } ], @@ -89,10 +89,10 @@ "output_type": "stream", "text": [ "Parsing input file \"/Users/jinningwang/Documents/work/ams/ams/cases/ieee14/ieee14_uced.xlsx\"...\n", - "Input file parsed in 0.1516 seconds.\n", + "Input file parsed in 0.1265 seconds.\n", "Zero line rates detacted in rate_a, rate_b, rate_c, adjusted to 999.\n", "If expect a line outage, please set 'u' to 0.\n", - "System set up in 0.0034 seconds.\n", + "System set up in 0.0019 seconds.\n", "-> Systen size:\n", "Base: 100 MVA; Frequency: 60 Hz\n", "14 Buses; 20 Lines; 5 Static Generators\n", @@ -131,10 +131,10 @@ "output_type": "stream", "text": [ "Parsing input file \"/Users/jinningwang/Documents/work/ams/ams/cases/ieee14/ieee14.json\"...\n", - "Input file parsed in 0.0035 seconds.\n", + "Input file parsed in 0.0082 seconds.\n", "Zero line rates detacted in rate_a, rate_b, rate_c, adjusted to 999.\n", "If expect a line outage, please set 'u' to 0.\n", - "System set up in 0.0052 seconds.\n", + "System set up in 0.0068 seconds.\n", "-> Systen size:\n", "Base: 100 MVA; Frequency: 60 Hz\n", "14 Buses; 20 Lines; 5 Static Generators\n", @@ -169,10 +169,10 @@ "output_type": "stream", "text": [ "Parsing input file \"/Users/jinningwang/Documents/work/ams/ams/cases/matpower/case14.m\"...\n", - "Input file parsed in 0.0218 seconds.\n", + "Input file parsed in 0.0056 seconds.\n", "Zero line rates detacted in rate_a, rate_b, rate_c, adjusted to 999.\n", "If expect a line outage, please set 'u' to 0.\n", - "System set up in 0.0075 seconds.\n", + "System set up in 0.0023 seconds.\n", "-> Systen size:\n", "Base: 100.0 MVA; Frequency: 60 Hz\n", "14 Buses; 20 Lines; 5 Static Generators\n", @@ -224,10 +224,10 @@ "output_type": "stream", "text": [ "Parsing input file \"/Users/jinningwang/Documents/work/ams/ams/cases/ieee14/ieee14.raw\"...\n", - "Input file parsed in 0.0123 seconds.\n", + "Input file parsed in 0.0088 seconds.\n", "Zero line rates detacted in rate_a, rate_b, rate_c, adjusted to 999.\n", "If expect a line outage, please set 'u' to 0.\n", - "System set up in 0.0031 seconds.\n", + "System set up in 0.0020 seconds.\n", "-> Systen size:\n", "Base: 100.0 MVA; Frequency: 60.0 Hz\n", "14 Buses; 20 Lines; 5 Static Generators\n", diff --git a/examples/ex5.ipynb b/examples/ex5.ipynb index 72bed4db..9e929e1f 100644 --- a/examples/ex5.ipynb +++ b/examples/ex5.ipynb @@ -40,9 +40,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "Last run time: 2024-01-20 08:17:48\n", + "Last run time: 2024-01-24 09:37:49\n", "andes:1.8.10.post29+g97528c67\n", - "ams:0.8.0.post23+g92563fe\n" + "ams:0.8.1.post5+ge752692\n" ] } ], @@ -80,7 +80,7 @@ "output_type": "stream", "text": [ "Parsing input file \"/Users/jinningwang/Documents/work/ams/ams/cases/ieee14/ieee14_uced.xlsx\"...\n", - "Input file parsed in 0.1010 seconds.\n", + "Input file parsed in 0.1420 seconds.\n", "Zero line rates detacted in rate_a, rate_b, rate_c, adjusted to 999.\n", "If expect a line outage, please set 'u' to 0.\n", "System set up in 0.0020 seconds.\n" @@ -102,7 +102,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "Routine initialized in 0.0111 seconds.\n" + "Routine initialized in 0.0119 seconds.\n" ] }, { @@ -129,7 +129,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "RTED solved as optimal in 0.0173 seconds, converged after 10 iterations using solver ECOS.\n" + "RTED solved as optimal in 0.0178 seconds, converged after 11 iterations using solver ECOS.\n" ] }, { @@ -174,9 +174,9 @@ "text": [ "Parsing additional file \"/Users/jinningwang/Documents/work/andes/andes/cases/ieee14/ieee14_full.xlsx\"...\n", "Following PFlow models in addfile will be overwritten: , , , , , , \n", - "Addfile parsed in 0.0492 seconds.\n", - "System converted to ANDES in 0.1516 seconds.\n", - "AMS system 0x138bc5130 is linked to the ANDES system 0x2860ef850.\n" + "Addfile parsed in 0.0575 seconds.\n", + "System converted to ANDES in 0.1627 seconds.\n", + "AMS system 0x103585370 is linked to the ANDES system 0x28a1b55b0.\n" ] } ], @@ -406,8 +406,8 @@ "name": "stderr", "output_type": "stream", "text": [ - "Routine initialized in 0.0027 seconds.\n", - "ACOPF solved in 0.2243 seconds, converged after 12 iterations using solver PYPOWER-PIPS.\n", + "Routine initialized in 0.0031 seconds.\n", + "ACOPF solved in 0.2450 seconds, converged after 12 iterations using solver PYPOWER-PIPS.\n", "Attribute already exists in .\n", " is converted to AC.\n" ] @@ -465,7 +465,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "Send results to ANDES <0x2860ef850>...\n", + "Send results to ANDES <0x28a1b55b0>...\n", "Send to Bus.v0\n", "Send to StaticGen.u\n", "Send to StaticGen.p0\n" @@ -581,7 +581,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "22069e4d5fed48edbd304d39453fdadc", + "model_id": "08bf80e1b9e24b078738cfc1a9b4598e", "version_major": 2, "version_minor": 0 }, @@ -616,7 +616,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -625,7 +625,7 @@ "OrderedDict([('ug', ('StaticGen', 'u')), ('pg0', ('StaticGen', 'p'))])" ] }, - "execution_count": 18, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -636,7 +636,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 18, "metadata": {}, "outputs": [ { @@ -653,7 +653,7 @@ "True" ] }, - "execution_count": 19, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -671,16 +671,16 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([0.32261762, 0.01 , 0.02 , 0.01 , 1.97392234])" + "array([0.32260084, 0.01 , 0.02 , 0.01 , 1.97393997])" ] }, - "execution_count": 20, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } diff --git a/examples/ex6.ipynb b/examples/ex6.ipynb index 3003b274..dabccd1b 100644 --- a/examples/ex6.ipynb +++ b/examples/ex6.ipynb @@ -12,7 +12,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Multi-period dispatch economic dispatch (ED) and unit commitment (UC) is also available." + "Multi-period dispatch economic dispatch (ED) and unit commitment (UC) is also available.\n", + "\n", + "In this case, we will show a 24-hour ED simulation." ] }, { @@ -35,8 +37,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "Last run time: 2024-01-20 19:44:03\n", - "ams:0.8.0.post35+gdfb44b2\n" + "Last run time: 2024-01-24 09:37:57\n", + "ams:0.8.1.post5+ge752692\n" ] } ], @@ -73,10 +75,10 @@ "output_type": "stream", "text": [ "Parsing input file \"/Users/jinningwang/Documents/work/ams/ams/cases/5bus/pjm5bus_uced.xlsx\"...\n", - "Input file parsed in 0.1114 seconds.\n", + "Input file parsed in 0.0957 seconds.\n", "Zero line rates detacted in rate_a, rate_b, rate_c, adjusted to 999.\n", "If expect a line outage, please set 'u' to 0.\n", - "System set up in 0.0020 seconds.\n" + "System set up in 0.0019 seconds.\n" ] } ], @@ -370,9 +372,9 @@ { "data": { "text/plain": [ - "OrderedDict([('TimeSlot', TimeSlot (0 devices) at 0x179569fa0),\n", - " ('EDTSlot', EDTSlot (24 devices) at 0x179573a60),\n", - " ('UCTSlot', UCTSlot (24 devices) at 0x179573e80)])" + "OrderedDict([('TimeSlot', TimeSlot (0 devices) at 0x14b828e50),\n", + " ('EDTSlot', EDTSlot (24 devices) at 0x14b830910),\n", + " ('UCTSlot', UCTSlot (24 devices) at 0x14b830d30)])" ] }, "execution_count": 7, @@ -714,7 +716,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "Routine initialized in 0.0188 seconds.\n" + "Routine initialized in 0.0172 seconds.\n" ] }, { @@ -741,7 +743,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "ED solved as optimal in 0.0306 seconds, converged after 11 iterations using solver ECOS.\n" + "ED solved as optimal in 0.0298 seconds, converged after 11 iterations using solver ECOS.\n" ] }, { @@ -853,7 +855,7 @@ { "data": { "text/plain": [ - "array([[2.09999999, 2.09999999]])" + "array([2.09999999])" ] }, "execution_count": 14, @@ -862,7 +864,7 @@ } ], "source": [ - "sp.ED.get(src='pg', attr='v', idx='PV_1', horizon=['EDT1', 'EDT2'])" + "sp.ED.get(src='pg', attr='v', idx='PV_1', horizon=['EDT1'])" ] }, { From a82c60e6f744db348ffd4d10c0605bd9f17672d7 Mon Sep 17 00:00:00 2001 From: jinningwang Date: Wed, 24 Jan 2024 09:40:23 -0500 Subject: [PATCH 07/13] Update release notes --- docs/source/release-notes.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/source/release-notes.rst b/docs/source/release-notes.rst index 8a30e1c8..c7920443 100644 --- a/docs/source/release-notes.rst +++ b/docs/source/release-notes.rst @@ -9,6 +9,11 @@ The APIs before v3.0.0 are in beta and may change without prior notice. Pre-v1.0.0 ========== +v0.8.2 (2024-01-xx) +------------------- + +- Improve examples + v0.8.1 (2024-01-20) ------------------- From a88ce2dc40065a59cbc760dd2aeaf5520eca0511 Mon Sep 17 00:00:00 2001 From: jinningwang Date: Wed, 24 Jan 2024 09:49:28 -0500 Subject: [PATCH 08/13] Update github workflow --- .github/workflows/pythonapp.yml | 37 +++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 5bdfdae9..85c1139b 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -4,7 +4,7 @@ on: [push, pull_request] jobs: build: - + name: AMS Tests strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] @@ -13,29 +13,34 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - name: Set up Python 3.9 - uses: actions/setup-python@v1 + - uses: actions/checkout@v4 + - uses: conda-incubator/setup-miniconda@v3 with: - python-version: 3.9 - - name: Install dependencies + python-version: 3.11 + mamba-version: "*" + miniforge-version: "latest" + channels: conda-forge,defaults + channel-priority: true + activate-environment: anaconda-client-env + - shell: bash -el {0} + name: Install dependencies run: | - # work around a pip issue with extras_require: https://github.com/pypa/pip/issues/8323 - python -m pip install -U "pip @ git+https://github.com/pypa/pip.git" - python -m pip install --upgrade pip - python -m pip install .[all] - python -m pip install nbmake==0.10 pytest-xdist line_profiler # add'l packages for notebook tests. + mamba install -y nbmake pytest-xdist line_profiler # add'l packages for notebook tests. + mamba install --file requirements.txt --file requirements-extra.txt + python -m pip install -e . # - name: Lint with flake8 for pull requests # if: github.event_name == 'pull_request' # run: | # # stop the build if there are Python syntax errors or undefined names # flake8 . - - name: Test with pytest + - shell: bash -el {0} + name: Test with pytest run: | - pytest --log-cli-level=10 - # - name: Test notebooks. - # run: | - # pytest --log-cli-level=10 --nbmake examples --ignore=examples/verification + pytest + - shell: bash -el {0} + name: Test notebooks. + run: | + pytest --nbmake examples --ignore "examples/verification examples/demonstration" # - name: Build a distribution if tagged # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') # run: | From 5b32b0daf946eb6cadacf765896d16400510a0a8 Mon Sep 17 00:00:00 2001 From: jinningwang Date: Wed, 24 Jan 2024 10:06:19 -0500 Subject: [PATCH 09/13] Update requirements to fix dependency issue --- requirements-extra.txt | 7 ++++--- requirements.txt | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/requirements-extra.txt b/requirements-extra.txt index f2f071fb..d35fccba 100644 --- a/requirements-extra.txt +++ b/requirements-extra.txt @@ -7,14 +7,15 @@ # # Only one `#` is allowed per line. Lines starting with `#` are ignored. -pytest==7.0.1 # dev +pytest==7.4 # dev flake8 # dev +ipython # dev igraph # dev -sphinx>=5.0 # dev, doc +sphinx>=5.0 # dev, doc pydata-sphinx-theme # dev, doc numpydoc # dev, doc sphinx-copybutton # dev, doc sphinx-panels # dev, doc pydata-sphinx-theme # dev, doc -myst-parser # dev, doc +myst-parser # dev, doc myst-nb # dev, doc \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index fad7a13c..8402c9bd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,7 @@ +kvxopt>=1.3 numpy scipy +sympy>=1.6,!=1.10.0 pandas matplotlib psutil From 316bc918b75be9d4380e999a99ab8935bf4f87e7 Mon Sep 17 00:00:00 2001 From: jinningwang Date: Wed, 24 Jan 2024 10:08:47 -0500 Subject: [PATCH 10/13] Relax sphinx verion --- requirements-extra.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-extra.txt b/requirements-extra.txt index d35fccba..99ba28d6 100644 --- a/requirements-extra.txt +++ b/requirements-extra.txt @@ -11,7 +11,7 @@ pytest==7.4 # dev flake8 # dev ipython # dev igraph # dev -sphinx>=5.0 # dev, doc +sphinx # dev, doc pydata-sphinx-theme # dev, doc numpydoc # dev, doc sphinx-copybutton # dev, doc From 1b803c9789235526590e8131b3962bee026d4d77 Mon Sep 17 00:00:00 2001 From: jinningwang Date: Wed, 24 Jan 2024 10:13:38 -0500 Subject: [PATCH 11/13] Remove dependency of CVXOPT --- requirements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 8402c9bd..b13e1d70 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,5 +7,4 @@ matplotlib psutil openpyxl andes -cvxpy -cvxopt \ No newline at end of file +cvxpy \ No newline at end of file From f046210c8b8cd5f808c2e62724b691976943ac8d Mon Sep 17 00:00:00 2001 From: jinningwang Date: Wed, 24 Jan 2024 10:43:27 -0500 Subject: [PATCH 12/13] Disable progress bar in ex5 --- examples/ex5.ipynb | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/ex5.ipynb b/examples/ex5.ipynb index 9e929e1f..f0c25a34 100644 --- a/examples/ex5.ipynb +++ b/examples/ex5.ipynb @@ -604,6 +604,7 @@ } ], "source": [ + "sa.TDS.config.no_tqdm = True # disable progress bar\n", "sa.TDS.run()" ] }, From b6db8c05aa402189ac2e3f2cc082d4b8ffcc86ac Mon Sep 17 00:00:00 2001 From: jinningwang Date: Wed, 24 Jan 2024 10:43:45 -0500 Subject: [PATCH 13/13] Fix notebook examples test --- .github/workflows/pythonapp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 85c1139b..85a0a7c2 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -40,7 +40,7 @@ jobs: - shell: bash -el {0} name: Test notebooks. run: | - pytest --nbmake examples --ignore "examples/verification examples/demonstration" + pytest --nbmake examples --ignore=examples/demonstration # - name: Build a distribution if tagged # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') # run: |