├── AUTHORS ├── CHANGES.md ├── Cases ├── case2.m ├── case9_new.m ├── connect_pg_case118.m ├── connect_pg_case2.m ├── connect_pg_case9.m ├── ng_case48.m └── ng_case8.m ├── Examples ├── Example1.m ├── Example2.m ├── Example3.m └── Example4.m ├── Functions ├── compressor2gen.m ├── define_constants_gas.m ├── idx_comp.m ├── idx_connect.m ├── idx_node.m ├── idx_pipe.m ├── idx_sto.m ├── idx_well.m ├── mgc_PU.m ├── mgc_REAL.m ├── mpc2gas_prep.m ├── mpng.m ├── multi_period.m ├── nsd2gen.m └── wey_approx.m ├── LICENSE ├── MPNG_User's_Manual ├── Chapters │ ├── Acknowledgements.tex │ ├── Appendixes.tex │ ├── Examples.tex │ ├── Formulation.tex │ ├── Front_matter.tex │ ├── Getting_started.tex │ ├── Introduction.tex │ ├── Natural_Gas_Flow.tex │ └── desktop.ini ├── Figures │ ├── Compressor.pdf │ ├── Example1.pdf │ ├── Gas_flow_problem.pdf │ ├── MPNG_logo.pdf │ ├── MPNG_logo_md.PNG │ ├── NG48.pdf │ ├── Node.pdf │ ├── Pipeline.pdf │ ├── Storage_unit.pdf │ ├── Time_resolution.pdf │ ├── Well.pdf │ ├── desktop.ini │ ├── ex2_fgc.pdf │ ├── ex2_fgo.pdf │ ├── ex2_inj.pdf │ ├── ex2_pressure-eps-converted-to.pdf │ └── ex2_pressure.pdf ├── MPNG_Manual_V0.99a.pdf └── MPNG_Manual_V0.99a.tex ├── README.md └── install_mpng.m /AUTHORS: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019, individual contributors. All rights reserved. 2 | 3 | MPNG:MATPOWER-Natural Gas was developed by: 4 | 5 | Sergio García-Marín, Universidad Nacional de Colombia - sede Manizales 6 | Wilson González-Vanegas, Universidad Tecnológica de Pereira 7 | Carlos E. Murillo-Sánchez, Universidad Nacional de Colombia - sede Manizales 8 | -------------------------------------------------------------------------------- /CHANGES.md: -------------------------------------------------------------------------------- 1 | Change history for MATPOWER-Natural Gas (MPNG) 2 | ============================================== 3 | 4 | #### 28/04/2022 (Changes included in released version 0.99beta) 5 | 6 | - Addition of unit commitment as an input parameter. Extra field `connect.power.UC` 7 | 8 | - Addition of inter-temporal power ramp constraints. Extra field `connect.power.ramp_time` for setting generation ramp-times. 9 | 10 | - Improved nargout checking in `wey_approx.m` for passing only needed data based on Jacobian and Hessian evaluation calls from `mpng.m` 11 | 12 | - Redefinition of the default region of approximation of Weymouth's equation (Pi*), according to a percentage of the pipeline's maximum flow. 13 | 14 | - Addition of a new optional field `mgc.wey_percent` for allowing the user to specify a different approximation region for Weymouth's equation (Pi*). 15 | 16 | - Temporal workaround for allowing compressor ratios to be lower or equal to 1.0 in order to model turboexpanders (i.e compressors with negative power consumption, that is, positive generation). *Thanks to a question from Roman Korab*. 17 | 18 | - Minor fix to ensure that actual nodal gas demand in `mgc.node.dem` matches total gas demand in `mgc.node.info(:,GD)`. 19 | 20 | - Fixes in per unit conversion of some quantities. 21 | 22 | - Release of `Example3.m`. It shows MPNG's performance taking turboexpanders into account. 23 | 24 | - Release of `Example4.m` and `connection_pg_case118.m`. This example simulates the 118-bus & 48-node power&gas system over a 24-hour horizon and tests the new MPNG's features regarding the assessment of given unit commitment schedules and start-up/shut-down generation ramps. 25 | 26 | - A new option has been enabled in all `Examples` for allowing passing the initial point contained in power&gas cases to the solver. 27 | -------------------------------------------------------------------------------- /Cases/case2.m: -------------------------------------------------------------------------------- 1 | function mpc = case2 2 | %CASE2 Power flow data for 2 bus, 1 generator case. 3 | % This case is used to run an independent Optimal Natural Gas Flow in MPNG 4 | 5 | % MPNG 6 | %% MATPOWER Case Format : Version 2 7 | mpc.version = '2'; 8 | 9 | %%----- Power Flow Data -----%% 10 | %% system MVA base 11 | mpc.baseMVA = 100; 12 | 13 | %% bus data 14 | % bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 15 | mpc.bus = [ 16 | 1 3 0 0 0 0 1 1 0 345 1 1.1 0.9; 17 | 2 1 5 1 0 0 1 1 0 345 1 1.1 0.9; 18 | ]; 19 | 20 | %% generator data 21 | % bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 22 | mpc.gen = [ 23 | 1 5 0 300 -300 1.0 100 1 15 0 0 0 0 0 0 0 0 0 0 0 0; 24 | ]; 25 | 26 | %% branch data 27 | % fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 28 | mpc.branch = [ 29 | 1 2 0 0.05 0 250 250 250 0 0 1 -360 360 30 | ]; 31 | 32 | %%----- OPF Data -----%% 33 | %% generator cost data 34 | 35 | mpc.gencost = [ 36 | 2 1500 0 3 0 5 0; 37 | ]; 38 | 39 | %% gen fuel 40 | mpc.genfuel = {'hydro'}; -------------------------------------------------------------------------------- /Cases/case9_new.m: -------------------------------------------------------------------------------- 1 | function mpc = case9_new 2 | %CASE9 Power flow data for 9 bus, 3 generator case. 3 | % Please see CASEFORMAT for details on the case file format. 4 | % 5 | % Based on data from p. 70 of: 6 | % 7 | % Chow, J. H., editor. Time-Scale Modeling of Dynamic Networks with 8 | % Applications to Power Systems. Springer-Verlag, 1982. 9 | % Part of the Lecture Notes in Control and Information Sciences book 10 | % series (LNCIS, volume 46) 11 | % 12 | % which in turn appears to come from: 13 | % 14 | % R.P. Schulz, A.E. Turner and D.N. Ewart, "Long Term Power System 15 | % Dynamics," EPRI Report 90-7-0, Palo Alto, California, 1974. 16 | 17 | % MATPOWER 18 | 19 | %% MATPOWER Case Format : Version 2 20 | mpc.version = '2'; 21 | 22 | %%----- Power Flow Data -----%% 23 | %% system MVA base 24 | mpc.baseMVA = 100; 25 | 26 | %% bus data 27 | % bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin 28 | mpc.bus = [ 29 | 1 3 0 0 0 0 1 1 1 345 1 1.1 0.9; 30 | 2 2 0 0 0 0 2 1 2 345 1 1.1 0.9; 31 | 3 2 0 0 0 0 1 1 3 345 1 1.1 0.9; 32 | 4 1 0 0 0 0 2 1 1 345 1 1.1 0.9; 33 | 5 1 90 -30 0 0 1 1 2 345 1 1.1 0.9; 34 | 6 1 0 0 0 0 2 1 3 345 1 1.1 0.9; 35 | 7 1 100 35 0 0 1 1 1 345 1 1.1 0.9; 36 | 8 1 0 0 0 0 2 1 2 345 1 1.1 0.9; 37 | 9 1 125 -50 0 0 1 1 3 345 1 1.1 0.9; 38 | ]; 39 | 40 | %% generator data 41 | % bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf 42 | mpc.gen = [ 43 | 1 72.3 27.03 300 -300 1.04 100 1 200 20 0 0 0 0 0 0 0 0 16 0 0; 44 | 2 163 6.54 300 -300 1.025 100 1 200 10 0 0 0 0 0 0 0 0 32 0 0; 45 | 3 85 -10.95 300 -300 1.025 100 1 200 10 0 0 0 0 0 0 0 0 8 0 0; 46 | ]; 47 | 48 | %% branch data 49 | % fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax 50 | mpc.branch = [ 51 | 1 4 0 0.0576 0 250 250 250 0 0 1 -360 360; 52 | 4 5 0.017 0.092 0.158 250 250 250 0 0 1 -360 360; 53 | 5 6 0.039 0.17 0.358 250 150 150 0 0 1 -360 360; 54 | 3 6 0 0.0586 0 250 300 300 0 0 1 -360 360; 55 | 6 7 0.0119 0.1008 0.209 250 150 150 0 0 1 -360 360; 56 | 7 8 0.0085 0.072 0.149 250 250 250 0 0 1 -360 360; 57 | 8 2 0 0.0625 0 250 250 250 0 0 1 -360 360; 58 | 8 9 0.032 0.161 0.306 250 250 250 0 0 1 -360 360; 59 | 9 4 0.01 0.085 0.176 250 250 250 0 0 1 -360 360; 60 | ]; 61 | 62 | %%----- OPF Data -----%% 63 | %% generator cost data 64 | % 1 startup shutdown n x1 y1 ... xn yn 65 | % 2 startup shutdown n c(n-1) ... c0 66 | % mpc.gencost = [ 67 | % 2 1500 0 3 0.11 5 150; 68 | % 2 2000 0 3 0.085 1.2 600; 69 | % 2 3000 0 3 0.1225 1 335; 70 | % ]; 71 | 72 | mpc.gencost = [ 73 | 2 1500 0 3 0 95 0; 74 | 2 2000 0 3 0 95 0; 75 | 2 3000 0 3 0 95 0; 76 | ]; 77 | 78 | %% gen fuel 79 | % mpc.genfuel = {'hydro'; 'hydro'; 'term'}; 80 | 81 | -------------------------------------------------------------------------------- /Cases/connect_pg_case118.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Cases/connect_pg_case118.m -------------------------------------------------------------------------------- /Cases/connect_pg_case2.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Cases/connect_pg_case2.m -------------------------------------------------------------------------------- /Cases/connect_pg_case9.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Cases/connect_pg_case9.m -------------------------------------------------------------------------------- /Cases/ng_case48.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Cases/ng_case48.m -------------------------------------------------------------------------------- /Cases/ng_case8.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Cases/ng_case8.m -------------------------------------------------------------------------------- /Examples/Example1.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Examples/Example1.m -------------------------------------------------------------------------------- /Examples/Example2.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Examples/Example2.m -------------------------------------------------------------------------------- /Examples/Example3.m: -------------------------------------------------------------------------------- 1 | % MPNG - Example 3. Optimal power and natural gas flow in the 8-node/9-bus 2 | % interconnected system adding features to model 3 | % turboexpanders. Four equal periods during 4 | % a day. Experimental setup is: 5 | % 6 | % i) Base case: same conditions as Example1.m 7 | % ii) Turbo case 1: power-driven compresor is set to 8 | % model a turboexpander (ratio<1) 9 | % iii) Turbo case 2: Bc parameter of turboexpander is 10 | % tripled to see the effect on the 11 | % injected power. 12 | % 13 | 14 | 15 | %% -------------------------- Base case -------------------------- 16 | clc; clear all; 17 | %% Define useful constants 18 | define_constants % power system constants 19 | define_constants_gas % natural gas system and connect struct constants 20 | %% defining option vector 21 | mpopt = mpoption; % initialize option struct 22 | mpopt.opf.ac.solver = 'IPOPT'; % current stable sover 23 | mpopt.ipopt.opts.max_iter = 1e5; % max iterations 24 | mpopt.opf.start = 2; % Pass the initial point from cases to IPOPT 25 | %% Load cases 26 | mpc = loadcase('case9_new'); % 9 bus power system with a little modifications 27 | mgc = ng_case8; % 8 node natural gas system 28 | connect = connect_pg_case9; % interconnection case, it mainly has to fit with the power case 29 | %% make some modifications 30 | % time 31 | connect.power.time = [6 6 6 6]; % four periods of time, all the same length 32 | % power system demands 33 | factors = [1 1.1 1.2 0.9]; % factors (external aid of MPNG) 34 | connect.power.demands.pd = factors.*mpc.bus(:,PD); % PD matrix 35 | connect.power.demands.qd = factors.*mpc.bus(:,QD); % QD matrix 36 | % energy available in gen 2 37 | connect.power.energy = zeros(1,2); % initialize (one gen with max energy) 38 | connect.power.energy(1,GEN_ID) = 2; % id for max energy in gen 2 39 | connect.power.energy(1,MAX_ENER) = 5000; % max energy is 1000 MWh/d 40 | % spinning reserve 41 | connect.power.sr = []; % no spinning reserves 42 | % interconnection through compressors 43 | connect.interc.comp = zeros(1,2); % initialize (one compressor working with power) 44 | connect.interc.comp(1,COMP_ID) = 2; % second compressor 45 | connect.interc.comp(1,BUS_ID) = 5; % connected to bus # 5 46 | mgc.comp(2,TYPE_C) = COMP_P; % create concordance with gas case 47 | % interconnection through gas-fired power plants 48 | connect.interc.term = zeros(1,3); % initialize (one gas-fired plant) 49 | connect.interc.term(1,GEN_ID) = 3; % third power plant 50 | connect.interc.term(1,NODE_ID) = 7; % connected to node # 7 51 | connect.interc.term(1,EFF) = 10e-3; % power plant efficiency (MMSCFD/MWh) 52 | %% putting all together 53 | mpgc = mpc; % initialize MPNG case 54 | mpgc.mgc = mgc; % adding gas case 55 | mpgc.connect = connect; % adding connection struct 56 | %% running Base case 57 | fprintf('\n\n$$$$$$$$$$$$$$$$$$$$$$$$- Base case -$$$$$$$$$$$$$$$$$$$$$$$$\n\n\n') 58 | res_base = mpng(mpgc,mpopt); % running MPNG 59 | 60 | 61 | %% -------------------------- Turbo case 1 -------------------------- 62 | fprintf('\n\n$$$$$$$$$$$$$$$$$$$$$$$$- Turbo case 1 -$$$$$$$$$$$$$$$$$$$$$$$$\n\n\n') 63 | mgc.comp(1,RATIO_C) = 1.5; % Uncomment to see the efect of allowing higher ratio for the gas-driven compressor 64 | mgc.comp(2,RATIO_C) = 0.7; % ratio < 1 to indicate operation as turboexpander 65 | 66 | mpgc.mgc = mgc; % update the gas case 67 | res_tur1 = mpng(mpgc,mpopt); % running Turbo case 1 68 | 69 | 70 | %% -------------------------- Turbo case 2 -------------------------- 71 | fprintf('\n\n$$$$$$$$$$$$$$$$$$$$$$$$- Turbo case 2 -$$$$$$$$$$$$$$$$$$$$$$$$\n\n\n') 72 | mgc.comp(2,B_C) = 3*mgc.comp(2,B_C); % Bc is tripled to see the effect on injected power 73 | 74 | mpgc.mgc = mgc; % update the gas case 75 | res_tur2 = mpng(mpgc,mpopt); % running Turbo case 1 76 | -------------------------------------------------------------------------------- /Examples/Example4.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Examples/Example4.m -------------------------------------------------------------------------------- /Functions/compressor2gen.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Functions/compressor2gen.m -------------------------------------------------------------------------------- /Functions/define_constants_gas.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Functions/define_constants_gas.m -------------------------------------------------------------------------------- /Functions/idx_comp.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Functions/idx_comp.m -------------------------------------------------------------------------------- /Functions/idx_connect.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Functions/idx_connect.m -------------------------------------------------------------------------------- /Functions/idx_node.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Functions/idx_node.m -------------------------------------------------------------------------------- /Functions/idx_pipe.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Functions/idx_pipe.m -------------------------------------------------------------------------------- /Functions/idx_sto.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Functions/idx_sto.m -------------------------------------------------------------------------------- /Functions/idx_well.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Functions/idx_well.m -------------------------------------------------------------------------------- /Functions/mgc_PU.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Functions/mgc_PU.m -------------------------------------------------------------------------------- /Functions/mgc_REAL.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Functions/mgc_REAL.m -------------------------------------------------------------------------------- /Functions/mpc2gas_prep.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Functions/mpc2gas_prep.m -------------------------------------------------------------------------------- /Functions/mpng.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Functions/mpng.m -------------------------------------------------------------------------------- /Functions/multi_period.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Functions/multi_period.m -------------------------------------------------------------------------------- /Functions/nsd2gen.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Functions/nsd2gen.m -------------------------------------------------------------------------------- /Functions/wey_approx.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/Functions/wey_approx.m -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2019, individual contributors (see AUTHORS file for details) 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /MPNG_User's_Manual/Chapters/Acknowledgements.tex: -------------------------------------------------------------------------------- 1 | \chapter{Acknowledgements} 2 | \label{chap:ack} 3 | 4 | \mpng{}: \matpower{}-Natural Gas was created as one of the main research products of the Colombian project:\\ 5 | 6 | \begin{center} 7 | ``\textit{Desarrollo de una plataforma para el cálculo de confiabilidad en la operación interdependiente de los sistemas de gas natural y sector eléctrico de Colombia que permita evaluar alternativas de inversión y regulación para optimizar los costos de operación}''\\ 8 | 9 | \vspace{1cm} 10 | developed by:\\ 11 | 12 | \vspace{1cm} 13 | Universidad Nacional de Colombia - sede Manizales,\\ 14 | Universidad Tecnológica de Pereira. 15 | \end{center} 16 | 17 | \vspace{1cm} 18 | \noindent This research was funded by the Department of Science, Technology and Innovation, Colciencias, Colombia, under the contract 1110-745-58696. 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /MPNG_User's_Manual/Chapters/Appendixes.tex: -------------------------------------------------------------------------------- 1 | \begin{appendix} 2 | 3 | \chapter{Appendix A: Gas Case Data File Format} 4 | \label{app:gas_format} 5 | 6 | All details about the gas case (\code{mgc}) format are provided in the tables below. For the sake of convenience and code portability, \code{idx\_node} defines a set of constants (positive integers) to be used as named indices into the columns of the \code{node.info} matrix. Similarly, \code{idx\_well}, \code{idx\_pipe}, \code{idx\_comp}, and \code{idx\_sto} defines names for the columns in \code{well}, \code{pipe}, \code{comp}, and \code{sto}, respectively. On the other hand, \code{mgc\_PU} converts from real to per-unit (P.U) quantities, while \code{mgc\_REAL} converts from P.U to real values. Moreover, the \code{pbase}, \code{fbase}, and \code{wbase} fields are simple scalar values to define the gas system pressure, flow and power bases, respectively. 7 | 8 | 9 | \begin{table}[!ht] 10 | \centering 11 | \begin{threeparttable} 12 | \caption{Node Information Data (\code{mgc.node.info})} 13 | \label{tab:nodedata} 14 | \footnotesize 15 | \begin{tabular}{lcl} 16 | \toprule 17 | name & column & description \\ 18 | \midrule 19 | \code{NODE\_I} & 1 & node number (positive integer)\\ 20 | \code{NODE\_TYPE} & 2 & node type (1 = demand node, 2 = extraction node)\\ 21 | \code{PR} & 3 & pressure [psia]\\ 22 | \code{PRMAX} & 4 & maximum pressure [psia]\\ 23 | \code{PRMIN} & 5 & minimum pressure [psia]\\ 24 | \code{OVP} & 6 & over-pressure [psia]\\ 25 | \code{UNP} & 7 & under-pressure [psia]\\ 26 | \code{COST\_OVP} & 8 & over-pressure cost [\$/psia$^2$]\\ 27 | \code{COST\_UNP} & 9 & under-pressure cost [\$/psia$^2$]\\ 28 | \code{GD} & 10 & full nodal demand [MMSCFD]\tnote{\dag}\\ 29 | \code{NGD} & 11 & number of different nodal users (positive integer)\\ 30 | \bottomrule 31 | \end{tabular} 32 | \begin{tablenotes} 33 | \scriptsize 34 | \item [\dag] {MMSCFD: Million Standard Cubic Feet Per Day.} 35 | \end{tablenotes} 36 | \end{threeparttable} 37 | \end{table} 38 | 39 | \begin{table}[!ht] 40 | \centering 41 | \begin{threeparttable} 42 | \caption{Well Information Data (\code{mgc.well})} 43 | \label{tab:welldata} 44 | \footnotesize 45 | \begin{tabular}{lcl} 46 | \toprule 47 | name & column & description \\ 48 | \midrule 49 | \code{WELL\_NODE} & 1 & well number (positive integer)\\ 50 | \code{G} & 2 & well gas production [MMSCFD]\\ 51 | \code{PW} & 3 & known well pressure [psia]\\ 52 | \code{GMAX} & 4 & maximum gas injection [MMSCFD]\\ 53 | \code{GMIN} & 5 & minimum gas injection [MMSCFD]\\ 54 | \code{WELL\_STATUS} & 6 & well status (0 = disable, 1 = enable)\\ 55 | \code{COST\_G} & 7 & well production cost [\$/MMSCFD]\\ 56 | \bottomrule 57 | \end{tabular} 58 | \end{threeparttable} 59 | \end{table} 60 | 61 | \begin{table}[!ht] 62 | \centering 63 | \begin{threeparttable} 64 | \caption{Pipeline Information Data (\code{mgc.pipe})} 65 | \label{tab:pipedata} 66 | \footnotesize 67 | \begin{tabular}{lcl} 68 | \toprule 69 | name & column & description \\ 70 | \midrule 71 | \code{F\_NODE} & 1 & from node number (positive integer)\\ 72 | \code{T\_NODE} & 2 & to node number (positive integer)\\ 73 | \code{FG\_O} & 3 & known gas pipeline flow [MMSCFD]\\ 74 | \code{K\_O} & 4 & Weymouth constant [MMSCFD/psia]\\ 75 | \code{DIAM} & 5 & diameter [inches]\\ 76 | \code{LNG} & 6 & longitude [km]\\ 77 | \code{FMAX\_O} & 7 & maximum flow [MMSCFD]\\ 78 | \code{FMIN\_O} & 8 & minimum flow [MMSCFD]\\ 79 | \code{COST\_O} & 9 & pipeline transportation cost [\$/MMSCFD]\\ 80 | \bottomrule 81 | \end{tabular} 82 | \end{threeparttable} 83 | \end{table} 84 | 85 | \begin{table}[!ht] 86 | \centering 87 | \begin{threeparttable} 88 | \caption{Compressor Information Data (\code{mgc.comp})} 89 | \label{tab:compdata} 90 | \footnotesize 91 | \begin{tabular}{lcl} 92 | \toprule 93 | name & column & description \\ 94 | \midrule 95 | \code{F\_NODE} & 1 & from node number (positive integer)\\ 96 | \code{T\_NODE} & 2 & to node number (positive integer)\\ 97 | \code{TYPE\_C} & 3 & compressor type (1 = power-driven, 2 = gas-driven)\\ 98 | \code{FG\_C} & 4 & gas flow through compressor [MMSCFD]\\ 99 | \code{PC\_C} & 5 & consumed compressor power [MVA]\\ 100 | \code{GC\_C} & 6 & gas consumed by the compressor [MMSCFD]\tnote{\dag}\\ 101 | \code{RATIO\_C} & 7 & maximum compressor ratio\\ 102 | \code{B\_C} & 8 & compressor-dependent constant [MVA/MMSCFD]\\ 103 | \code{Z\_C} & 9 & compresibility factor\\ 104 | \code{X} & 10 & independent approximation coefficient [MMSCFD]\\ 105 | \code{Y} & 11 & linear approximation coefficient [MMSCFD/MVA]\\ 106 | \code{Z} & 12 & quadratic approximation coefficient [MMSCFD/MVA$^2$]\\ 107 | \code{FMAX\_C} & 13 & maximum flow through compressor [MMSCFD]\\ 108 | \code{COST\_C} & 14 & compressor cost [\$/MMSCFD]\\ 109 | \bottomrule 110 | \end{tabular} 111 | \begin{tablenotes} 112 | \scriptsize 113 | \item [\dag] {Only relevant for a gas-driven compressor.} 114 | \end{tablenotes} 115 | \end{threeparttable} 116 | \end{table} 117 | 118 | \begin{table}[!ht] 119 | \centering 120 | \begin{threeparttable} 121 | \caption{Storage Information Data (\code{mgc.sto})} 122 | \label{tab:storedata} 123 | \footnotesize 124 | \begin{tabular}{lcl} 125 | \toprule 126 | name & column & description \\ 127 | \midrule 128 | \code{STO\_NODE} & 1 & node number (positive integer)\\ 129 | \code{STO} & 2 & end of day storage level [MSCF]\tnote{\dag}\\ 130 | \code{STO\_0} & 3 & initial storage level [MSCF]\\ 131 | \code{STOMAX} & 4 & maximum storage [MSCF]\\ 132 | \code{STOMIN} & 5 & minimum storage [MSCF]\\ 133 | \code{FSTO} & 6 & storage outflow difference [MMSCFD]\tnote{\ddag}\\ 134 | \code{FSTO\_OUT} & 7 & storage outflow [MMSCFD]\\ 135 | \code{FSTO\_IN} & 8 & storage inflow [MMSCFD]\\ 136 | \code{FSTOMAX} & 9 & maximum storage outflow difference [MMSCFD]\\ 137 | \code{FSTOMIN} & 10 & minimum storage outflow difference [MMSCFD]\\ 138 | \code{S\_STATUS} & 11 & storage status \\ 139 | \code{COST\_STO} & 12 & storage cost [\$/MSCF]\\ 140 | \code{COST\_OUT} & 13 & storage outflow cost [\$/MMSCFD]\\ 141 | \code{COST\_IN} & 14 & storage inflow cost [\$/MMSCFD]\\ 142 | \bottomrule 143 | \end{tabular} 144 | \begin{tablenotes} 145 | \scriptsize 146 | \item [\dag] {Volume in Million Standard Cubic Feet (MSCF).} 147 | \item[\ddag] {Storage outflow minus storage inflow. See Section \ref{chap:formulation} for more details.} 148 | \end{tablenotes} 149 | \end{threeparttable} 150 | \end{table} 151 | 152 | 153 | 154 | \chapter{Appendix B: Interconnection Case Data File Format} 155 | \label{app:connect_format} 156 | 157 | A detailed description about the interconnection case (\code{connect}) is provided in Table \ref{tab:connectcase}. As seen, some additional information is required for the power system besides the input data given in the \matpower{}-case. For the sake of clarity and readability, we decided to include such an additional information in the interconnection case rather than the \matpower{}-case. In short, different periods that are modeled using an island-based approach are allowed for the power system, where each island defines the network conditions at each period. On the other hand, the power-driven compressors and the gas-fired generator units set the coupling features between the power and natural gas systems. The user could define any of these two coupling options as empty arrays when they are not to be considered for a specific analysis. See Section \ref{chap:examples} for details. 158 | 159 | 160 | \begin{table}[!ht] 161 | \centering 162 | \begin{threeparttable} 163 | \caption{Connection Data (\code{mpgc.connect})} 164 | \label{tab:connectcase} 165 | \footnotesize 166 | \begin{tabular}{lcp{0.6\textwidth}} 167 | \toprule 168 | name & domain & description \\ 169 | \midrule 170 | \code{.power.time} & $\Real^{n_t}$ & vector to define the number of $n_t$ periods to be considered in the power system. Each component in the vector represents the number of hours for each period such that \code{sum(power.time)=24}\tnote{\dag}.\\ 171 | \code{.power.demands} & & \\ 172 | \hspace{2.5cm} \code{.pd} & $\Real^{n_b\times n_t}$ & matrix to define the active power demand for $n_b$ buses over $n_t$ periods of time.\\ 173 | \hspace{2.5cm} \code{.qd} & $\Real^{n_b\times n_t}$ & matrix to define the reactive power demand for $n_b$ buses over $n_t$ periods of time.\\ 174 | \code{.power.cost} & $\Real^+$ & non-supplied power demand cost.\\ 175 | \code{.power.sr} & $\Real^{n_a\times n_t}$ & matrix to define the spinning reserve of $n_a$ areas over $n_t$ periods.\\ 176 | \code{.power.energy} & $\Real^{n_{g_h}\times 2}$ & matrix to define the maximum energy available for the $n_{g_h}\subseteq n_g$ hydroelectric power generators, holding columns as follows:\tnote{\ddag} 177 | \begin{tabular}{c @{ -- } p{0.4\textwidth}} 178 | column 1 & generator number (positive integer)\\ 179 | column 2 & maximum energy for hydroelectric unit [MW$\cdot$h]\\ 180 | \end{tabular}\\ 181 | \code{.interc.comp} & $\Real^{n_{c_p}\times 2}$ & index matrix to locate the $n_{c_p}\subseteq n_c$ power-driven compressors at some specific buses, holding columns as below\tnote{\S}: 182 | \begin{tabular}{c @{ -- } p{0.4\textwidth}} 183 | column 1 & compressor number (positive integer)\\ 184 | column 2 & bus number to locate the power-driven compressor (positive integer)\\ 185 | \end{tabular}\\ 186 | \code{.interc.term} & $\Real^{n_{g_g}\times 3}$ & matrix to locate the $n_{g_g} \subseteq n_g$ gas-fired generators at some specific nodes and buses, holding the following columns:\tnote{\ddag} 187 | \begin{tabular}{c @{ -- } p{0.4\textwidth}} 188 | column 1 & bus number to locate the gas-fired unit as generator (positive integer)\\ 189 | column 2 & node number to locate the gas-fired unit as demand (positive integer)\\ 190 | column 3 & thermal efficiency of the gas-fired unit (positive real)\\ 191 | \end{tabular}\\ 192 | \bottomrule 193 | \end{tabular} 194 | \begin{tablenotes} 195 | \scriptsize 196 | \item [\dag] {The gas temporal resolution is one \textit{day}, while the electrical resolution is in terms of \textit{hours}. See Section \ref{chap:formulation} for more details.} 197 | \item [\ddag] {$n_g$ is the number of all power generator units installed in the power system.} 198 | \item[\S] {$n_c$ is the number of all compressors installed in the gas system.} 199 | \end{tablenotes} 200 | \end{threeparttable} 201 | \end{table} 202 | 203 | \end{appendix} -------------------------------------------------------------------------------- /MPNG_User's_Manual/Chapters/Examples.tex: -------------------------------------------------------------------------------- 1 | \chapter{Examples} 2 | \label{chap:examples} 3 | In this section, we provide some examples to show the main capabilities of \mpng{} for simulating the operation of power and natural gas networks. We have included the folder \mpngcasepath{} in the distribution, which contains the gas and interconnection cases used for testing. Moreover, the folder \mpngexamplepath{} contains the files used in the examples. In particular, we explore two examples: (1) the integrated operation of a nine-bus power system and an eight-node natural gas grid; and (2) the single operation of a 48-node looped natural gas network. 4 | 5 | \section{9-bus 8-node Power\&Gas System} 6 | \label{sec:8-9_gas_power} 7 | 8 | We analyze an interconnected system formed by a power system of nine buses and a natural gas network of eight nodes. As shown in Figure \ref{fig:example1}, they are coupled through a gas-fired power plant and a power-driven compressor working with energy coming from the power system. This example aims aimed at showing the primary functionalities of \mpng{} as well as how to properly run a simulation. 9 | 10 | The power system consists of the classic \matpower{} nine-bus case, with some modifications in order to meet the requirements of the interconnected network. Some of these changes are related to bus areas, line capability constraints, maximum power generation, and generation costs. For the gas system, we created an eight-node looped case with two compressors connected in series and a loop formed by three pipelines. Tables \ref{tab:ex1_power} and \ref{tab:ex1_gas} summarize the system information. 11 | 12 | \begin{figure}[!ht] 13 | \centering 14 | \includegraphics[scale=0.8]{Figures/Example1} 15 | \caption{Power and gas integrated network considered in Example 1.} 16 | \label{fig:example1} 17 | \end{figure} 18 | 19 | 20 | \begin{table}[!ht] 21 | \centering 22 | \begin{threeparttable} 23 | \caption{Example 1 - Power System Summary} 24 | \label{tab:ex1_power} 25 | \footnotesize 26 | \begin{tabular}{ll} 27 | \toprule 28 | \bf{topology} & 9-bus network \\ 29 | \midrule 30 | & 3 gens at buses 1, 2, and 3\\ 31 | \bf{generators} & 200 MW Max $P_{g}$ for all generators\\ 32 | & all 3 have identical quadratic generation costs \tnote{*}\\ 33 | \midrule 34 | \bf{load} & 90 MW at bus 5, 100 MW at bus 7, 125 MW at bus 9 \\ 35 | & curtailable at \$5000/MWh \\ 36 | \midrule 37 | \bf{branches} & 250 MW limit for all lines \\ 38 | \bottomrule 39 | \end{tabular} 40 | \begin{tablenotes} 41 | \scriptsize 42 | \item [*] {Linear costs of \$95/WMh are used for the example.} 43 | \end{tablenotes} 44 | \end{threeparttable} 45 | \end{table} 46 | 47 | 48 | \begin{table}[!ht] 49 | %\renewcommand{\arraystretch}{1.2} 50 | \centering 51 | \begin{threeparttable} 52 | \caption{Example 1 - Gas System Summary} 53 | \label{tab:ex1_gas} 54 | \footnotesize 55 | \begin{tabular}{ll} 56 | \toprule 57 | \bf{topology} & 8-node looped network \\ 58 | \midrule 59 | & 1 well at node 1\\ 60 | \bf{well} & 80 MMSCF Max $g^{w}$ for well\\ 61 | & linear cost extraction cost (\$5000 / MMSCFD )\\ 62 | \midrule 63 | & gas demands at nodes 7 and 8\\ 64 | \bf{load} & 2 types of gas load \\ 65 | & high cost of non-supplied demand\\ 66 | \midrule 67 | \bf{pipelines} & no active limits for all lines \\ 68 | & transport cost at (\$5 / MMSCFD) for all pipelines \\ 69 | \midrule 70 | \bf{compressors} & no active limits for all compressors \\ 71 | & transport cost at (\$5 / MMSCFD) for all compressors \\ 72 | \midrule 73 | \bf{storage} & no storage considered \\ 74 | \bottomrule 75 | \end{tabular} 76 | \begin{tablenotes} 77 | \scriptsize 78 | \item [] {} 79 | \end{tablenotes} 80 | \end{threeparttable} 81 | \end{table} 82 | 83 | Initially, for the sake of convenience and code portability, we define the column pointers (constants) for the power system\footnote{The default \matpower{} function \code{define\_constants} allows an straightforward indexing of all information via integer variables. See \cite{matpower_manual} for details.}. Similarly, we define column pointers to easily access the natural gas and interconnection cases, as follows: 84 | 85 | \begin{Code} 86 | >> define_constants % power system constants 87 | >> define_constants_gas % natural gas system and connect struct constants 88 | \end{Code} 89 | 90 | We can load the \matpower{} options struct to chose the desired solver and some additional features. The current stable solver for \mpng{} is `IPOPT'. Besides, based on the experience, we set the maximum number of iterations to 100000, as shown below: 91 | 92 | \begin{Code} 93 | >> mpopt = mpoption; % initialize option struct 94 | >> mpopt.opf.ac.solver = `IPOPT'; % current stable solver 95 | >> mpopt.ipopt.opts.max_iter = 1e5; % max iterations 96 | \end{Code} 97 | 98 | Afterwards, we load the power and gas cases and the connection struct\footnote{All cases and connection struct are included in the folder \mpngcasepath{}. Since the data of the interconnection case mainly comprises additional information of the \matpower{}-case, we refer to the connect struct using a similar name as that used for the power system case.}. For the sake of simplicity, we name the power case as \code{mpc}, the natural gas case as \code{mgc}, and the connection struct as \code{connect}, as follows: 99 | 100 | \begin{Code} 101 | >> mpc = loadcase(`case9_new'); % 9 bus power system 102 | >> mgc = ng_case8; % 8 node natural gas system 103 | >> connect = connect_pg_case9; % interconnection case 104 | \end{Code} 105 | 106 | As the window of analysis consist in an entire day for the gas network, we just need to define the number of periods and their corresponding length for analyzing the power system. We consider four periods of time, each of them of the same length, that is: 107 | 108 | \begin{Code} 109 | >> connect.power.time = [6 6 6 6]; % four periods of time 110 | \end{Code} 111 | 112 | The connection struct also requires the active and reactive demands in all buses for each period. Then, we take the original system's demand to produce such a temporal behavior via a factor vector as follows: 113 | 114 | \begin{Code} 115 | >> factors = [1 1.1 1.2 0.9]; % factors (external aid of MPNG) 116 | >> connect.power.demands.pd = factors.*mpc.bus(:,PD); % PD matrix 117 | >> connect.power.demands.qd = factors.*mpc.bus(:,QD); % QD matrix 118 | \end{Code} 119 | 120 | Moreover, we set the generator number two to have a maximum daily energy of 5000 MWh/d: 121 | 122 | \begin{Code} 123 | >> connect.power.energy = zeros(1,2); % initialize (one gen with max energy) 124 | >> connect.power.energy(1,GEN_ID) = 2; % id for max energy in gen 2 125 | >> connect.power.energy(1,MAX_ENER) = 5000; % max energy is 1000 MWh/d 126 | \end{Code} 127 | 128 | For this particular example, we do not consider spinning reserve because of the small number of generators. As a consequence, the spinning reserve matrix is set to be an empty array: 129 | 130 | \begin{Code} 131 | >> connect.power.sr = []; % no spinning reserves 132 | \end{Code} 133 | 134 | As shown in Figure \ref{fig:example1}, both classes of compressors where included in this example. Their corresponding information, specified in the connection struct, must be consistent with the gas and power cases: 135 | 136 | \begin{Code} 137 | >> connect.interc.comp = zeros(1,2); % initialize (a power-driven compressor) 138 | >> connect.interc.comp(1,COMP_ID) = 2; % second compressor 139 | >> connect.interc.comp(1,BUS_ID) = 5; % connected to bus # 5 140 | >> mgc.comp(2,TYPE_C) = COMP_P; % concordance with gas case 141 | \end{Code} 142 | 143 | Additionally, a gas-fired power plant was considered, and its information must be included in the connection struct in a manner consistent with the gas and power cases: 144 | 145 | \begin{Code} 146 | >> connect.interc.term = zeros(1,3); % initialize (one gas-fired plant) 147 | >> connect.interc.term(1,GEN_ID) = 3; % third power plant 148 | >> connect.interc.term(1,NODE_ID) = 7; % connected to node # 7 149 | >> connect.interc.term(1,EFF) = 10e-3; % power plant eff. (MMSCFD/MWh) 150 | \end{Code} 151 | 152 | At this point, we have set all the inputs required to model the different aspects that we intended for the interconnected power and natural gas system. Now, we need to put all together in a single struct. We call this struct \code{mpgc}, which represents the combination between \code{mpc}, \code{mgc}, and \code{connect}, as shown below: 153 | 154 | \begin{Code} 155 | >> mpgc = mpc; % initialize MPNG case 156 | >> mpgc.mgc = mgc; % adding gas case 157 | >> mpgc.connect = connect; % adding connection struct 158 | \end{Code} 159 | 160 | Finally, we can run the simulation by calling \mpng{} using the \code{mpgc} case and the \matpower{} options struct: 161 | 162 | \begin{Code} 163 | >> results = mpng(mpgc,mpopt); % running simulation 164 | \end{Code} 165 | 166 | The optimal solution values are saved as the \code{results} struct. See Section \ref{subsec:view_results} for more details about the simulation \code{results}. By default, the \code{results} are pretty-printed. The information related to the natural gas network after running the simulation looks like:\\ 167 | 168 | \vspace{-0.3cm} 169 | 170 | %\begin{tiny} 171 | %\begin{Code} 172 | % >> ================================================================================ 173 | % | Gas system summary | 174 | % ================================================================================ 175 | % 176 | % How many? How much? 177 | % --------------------- -------------------------------- 178 | % Nodes 8 Total Well Capacity 80.00 179 | % Wells 1 On-line Capacity 80.00 180 | % Pipelines 6 Gas Production 45.83 181 | % Compressors 2 Total Demand 38.63 182 | % Gas Comp. 1 Supplied Demand 38.63 183 | % Power Comp. 1 Non-Supplied Demand -0.00 184 | % Storage Units 1 Gas Stored 0.00 185 | % 186 | % Gas total extration cost = 229169.12 187 | % ================================================================================ 188 | % | Nodes Data | 189 | % ================================================================================ 190 | % Node Pressure Over Under Demand Non-S Gas Nodal 191 | % # (psi) Pressure Pressure (MMSCFD) Demand Extraction Lambda 192 | % ---- -------- -------- -------- -------- -------- ----------- --------- 193 | % 1 650.000 0.00 --- --- --- 45.83 5000.00 194 | % 2 563.146 --- --- --- --- --- 5911.35 195 | % 3 577.053 --- --- --- --- --- 5916.39 196 | % 4 612.558 --- --- --- --- --- 6083.14 197 | % 5 586.604 --- --- --- --- --- 6389.94 198 | % 6 592.410 --- --- --- --- --- 6212.97 199 | % 7 530.413 --- --- 12.22 -0.00 --- 6217.97 200 | % 8 464.000 --- --- 26.41 0.00 --- 8019.82 201 | % 202 | % ================================================================================ 203 | % | Pipeline Data | 204 | % ================================================================================ 205 | % Pipeline From To Weymouth Max Gas Gas Transport 206 | % # Node Node Constant Flow Flow Cost 207 | % -------- ----- ----- -------- -------- -------- --------- 208 | % 1 1 2 0.141 80.00 45.83 229.17 209 | % 2 4 5 0.121 40.00 21.42 107.09 210 | % 3 4 6 0.157 40.00 24.42 122.08 211 | % 4 5 6 0.060 40.00 -5.00 24.99 212 | % 5 6 7 0.074 40.00 19.42 97.09 213 | % 6 5 8 0.074 40.00 26.41 132.07 214 | % 215 | % ================================================================================ 216 | % | Compressor Data | 217 | % ================================================================================ 218 | % Comp. Comp. From To Comp. Power Gas Comp. Comp. 219 | % # Type Node Node Flow Consumed Consumed Ratio Cost 220 | % ----- ----- ---- ---- -------- -------- -------- ----- -------- 221 | % 1 G 2 3 45.834 1.29 0.0003 1.025 229.17 222 | % 2 P 3 4 45.834 3.17 --- 1.062 229.17 223 | % 224 | % ================================================================================ 225 | % | Gas-fired Generators Data | 226 | % ================================================================================ 227 | % Unit. Node Plant Daily Gas 228 | % # # Eff. Energy Consumed 229 | % ----- ---- --------- -------- -------- 230 | % 3 7 1.00e-02 720.00 7.20 231 | % ----- ---- --------- -------- -------- 232 | % Total 720.00 7.20 233 | %\end{Code} 234 | %\end{tiny} 235 | 236 | 237 | \begin{small} 238 | \begin{Code} 239 | >> ================================================================================ 240 | | Gas system summary | 241 | ================================================================================ 242 | 243 | How many? How much? 244 | --------------------- -------------------------------- 245 | Nodes 8 Total Well Capacity 80.00 246 | Wells 1 On-line Capacity 80.00 247 | Pipelines 6 Gas Production 45.83 248 | Compressors 2 Total Demand 38.63 249 | Gas Comp. 1 Supplied Demand 38.63 250 | Power Comp. 1 Non-Supplied Demand -0.00 251 | Storage Units 1 Gas Stored 0.00 252 | 253 | Gas total extraction cost = 229169.12 254 | ================================================================================ 255 | | Nodes Data | 256 | ================================================================================ 257 | Node Pressure Over Under Demand Non-S Gas Nodal 258 | # (psi) Pressure Pressure (MMSCFD) Demand Extraction Lambda 259 | ---- -------- -------- -------- -------- -------- ----------- --------- 260 | 1 650.000 0.00 --- --- --- 45.83 5000.00 261 | 2 563.146 --- --- --- --- --- 5911.35 262 | 3 577.053 --- --- --- --- --- 5916.39 263 | 4 612.558 --- --- --- --- --- 6083.14 264 | 5 586.604 --- --- --- --- --- 6389.94 265 | 6 592.410 --- --- --- --- --- 6212.97 266 | 7 530.413 --- --- 12.22 -0.00 --- 6217.97 267 | 8 464.000 --- --- 26.41 0.00 --- 8019.82 268 | ================================================================================ 269 | | Pipeline Data | 270 | ================================================================================ 271 | Pipeline From To Weymouth Max Gas Gas Transport 272 | # Node Node Constant Flow Flow Cost 273 | -------- ----- ----- -------- -------- -------- --------- 274 | 1 1 2 0.141 80.00 45.83 229.17 275 | 2 4 5 0.121 40.00 21.42 107.09 276 | 3 4 6 0.157 40.00 24.42 122.08 277 | 4 5 6 0.060 40.00 -5.00 24.99 278 | 5 6 7 0.074 40.00 19.42 97.09 279 | 6 5 8 0.074 40.00 26.41 132.07 280 | \end{Code} 281 | \end{small} 282 | 283 | 284 | \begin{small} 285 | \begin{Code} 286 | ================================================================================ 287 | | Compressor Data | 288 | ================================================================================ 289 | Comp. Comp. From To Comp. Power Gas Comp. Comp. 290 | # Type Node Node Flow Consumed Consumed Ratio Cost 291 | ----- ----- ---- ---- -------- -------- -------- ----- -------- 292 | 1 G 2 3 45.834 1.29 0.0003 1.025 229.17 293 | 2 P 3 4 45.834 3.17 --- 1.062 229.17 294 | 295 | ================================================================================ 296 | | Gas-fired Generators Data | 297 | ================================================================================ 298 | Unit. Node Plant Daily Gas 299 | # # Eff. Energy Consumed 300 | ----- ---- --------- -------- -------- 301 | 3 7 1.00e-02 720.00 7.20 302 | ----- ---- --------- -------- -------- 303 | Total 720.00 7.20 304 | \end{Code} 305 | \end{small} 306 | 307 | \section{48-node Looped Natural Gas Network} 308 | \label{sec:48_gas} 309 | 310 | In this example, we show the capability of \mpng{} for solving looped natural gas systems. We highlight that \mpng{} is also a tool for analyzing independent natural gas networks. In particular, we can use a virtual two-bus power system as the power case just to allow \matpower{} to work properly. The information for the 48-node gas network considered in this example was provided by Cheng et al.~\cite{Chen2017}, whose topology is shown in Figure \ref{fig:ng48}.\\ 311 | 312 | \begin{figure}[H] 313 | \centering 314 | \includegraphics[scale=1.6]{Figures/NG48} 315 | \caption{Natural gas network for Example 2. Source:~\cite{Chen2017}.} 316 | \label{fig:ng48} 317 | \end{figure} 318 | 319 | In terms of computational and mathematical tractability, looped natural gas systems are the most complex to solve because they require nodal pressures that guarantee the gas flow in more than one pipeline~\cite{Woldeyohannes2011}. This states an interesting scenario to assess the performance of \mpng{}. In this example, we consider two case studies over the 48-node gas network: a \textit{base case} study, where elements interact properly in a normal operation with no perturbations; and a \textit{contingency case} study, where failures lead to complex decisions for the simulator. 320 | 321 | Following Example \ref{sec:8-9_gas_power}, we start by defining all the power, gas, and connect constants. Then, we load the corresponding cases for this example: the gas case (\code{ng\_case48}), and the straightforward 2-bus power system (\code{case2}) that allows the virtual connection to the natural gas system (\code{connect\_pg\_case2}) with minimal implications in topological and computational terms. Lastly, we package the cases and the connect struct together and run \mpng{}: 322 | 323 | \begin{Code} 324 | mpc = loadcase(`case2'); % 2 bus power system 325 | mgc = ng_case48; % 48 node looped natural gas system 326 | connect = connect_pg_case2; % interconnection case 327 | 328 | %% put cases together 329 | mpgc = mpc; % initialize MPNG case 330 | mpgc.mgc = mgc; % adding gas case 331 | mpgc.connect = connect; % adding connection struct 332 | 333 | %% run mpng 334 | res_base = mpng(mpgc,mpopt); % running MPNG 335 | \end{Code} 336 | 337 | Now, we modify the base case to obtain the \textit{contingency case}. Specifically, we reduce the maximum injection capability of one of the wells located at the network center (node 20), forcing the system to extract natural gas from somewhere else to fulfill the gas demand. Moreover, we set pipeline number 38 (the one that connects nodes 43 and 44) to be out of service, eliminating one of the gas network loops located downstream. This contingency forces the system to supply the demands of nodes 30 to 33 through only two paths, which might cause over-pressures and pipeline congestion. 338 | 339 | To simulate these contingencies, we start again by loading the 48-node gas case. Then, we set the reduced maximum injection for well 9. For eliminating the mentioned pipeline, we remove its whole corresponding row in the field \code{mgc.pipe}. Once the contingencies are properly modeled, we put the entire system together and finally rerun the program: 340 | 341 | \begin{Code} 342 | %% changes due to contingencies 343 | mgc_cont = mgc; 344 | mgc_cont.well(9,GMAX) = 200; % set max injection of well 9 345 | cont_pipe = 39; % id for out-of-service pipeline 346 | mgc_cont.pipe(cont_pipe,:) = []; % take pipeline out of service 347 | 348 | %% putting all together 349 | mpgc_cont = mpc; % initialize MPNG case 350 | mpgc_cont.mgc = mgc_cont; % adding gas case 351 | mpgc_cont.connect = connect; % adding connection struct 352 | 353 | %% running program 354 | res_cont = mpng(mpgc_cont,mpopt); % running MPNG 355 | \end{Code} 356 | 357 | Figures \ref{fig:ex2_pressure} to \ref{fig:ex2_inj} show the results comparison between the base case and the contingency case. We mainly analyze pressures, gas flows, and well injections, since they are the most representative variables in the gas network. As seen, reducing the injection capacity in node 22 leads not only to the maximum injection in node one but also to the activation of the wells located at nodes 2 and 6 to balance the global production. As a consequence, new gas flows appear through pipelines 4-7 and 6-7 as a result of higher pressures in nodes 2 to 7; moreover, the gas flow through pipe 1-8 increases at the expense of lower pressure of node 8. Besides, compressors 1, 2, and 3 are forced to transport larger flows by increasing the difference between suction and discharge pressures, that is, their compressor ratios. On the other hand, the outage of pipeline 43-44 leads to higher pressures in the surrounding nodes because of the new radial connections of some pipes. Notice how pipelines 36-43 and 43-42 end up with gas flows in the opposite direction in the contingency case. 358 | 359 | \begin{figure}[H] 360 | \centering 361 | \includegraphics[scale=0.8]{Figures/ex2_pressure} 362 | \caption{Results Example 2 - Nodal Pressure.} 363 | \label{fig:ex2_pressure} 364 | \end{figure} 365 | 366 | \begin{figure}[H] 367 | \includegraphics[scale=0.75]{Figures/ex2_fgo} 368 | \caption{Results Example 2 - Gas Flow Through Pipelines.} 369 | \label{fig:ex2_fgo} 370 | \end{figure} 371 | 372 | \begin{figure}[H] 373 | \centering 374 | \includegraphics[scale=0.8]{Figures/ex2_fgc} 375 | \caption{Results Example 2 - Gas Flow Through Compressors.} 376 | \label{fig:ex2_fgc} 377 | \end{figure} 378 | 379 | \begin{figure}[H] 380 | \centering 381 | \includegraphics[scale=0.8]{Figures/ex2_inj} 382 | \caption{Results Example 2 - Gas Injection in Wells.} 383 | \label{fig:ex2_inj} 384 | \end{figure} 385 | 386 | -------------------------------------------------------------------------------- /MPNG_User's_Manual/Chapters/Formulation.tex: -------------------------------------------------------------------------------- 1 | \chapter{Optimal Power and Natural Gas Flow} 2 | \label{chap:formulation} 3 | 4 | In this chapter, we explain in detail the optimization model behind \mpng{}. We introduce the problem as an interdependent steady-state optimal power and natural flow, where a linear objective function models the overall operational cost, subject to several linear and non-linear constraints coming from both technical and operational conditions. 5 | 6 | In practice, the state-variables of a natural gas network change quite slowly in comparison to a power system~\cite{Cui2016}. Then, we consider a window of analysis of one entire day for the gas network. On the other hand, as it is found in most of the simulation tools, the power system is modeled using standard windows of one hour. However, a 24-hour time resolution would introduce too much complexity in terms of computational and mathematical tractability. Therefore, we propose a multi-period window of analysis defined by the user. Figure \ref{fig:periods} shows how the optimization model allows $n$ periods for the power system, whose individual duration is such that $\{t_i\in \mathbb{N}, \; i=1,2,...,n : \sum_i t_i = 24\}$, and one entire day for the natural gas system. The interconnection between systems is always consistent. Namely, each individual period of the power system is precisely linked to the single period of the natural gas network. 7 | 8 | \begin{figure}[!ht] 9 | \centering 10 | \includegraphics[scale=1.0]{Figures/Time_resolution} 11 | \caption{Periods considered in \mpng{}.} 12 | \label{fig:periods} 13 | \end{figure} 14 | 15 | \section*{Nomenclature} 16 | \subsection*{Indexes} 17 | \begin{labeling}{Longer label\quad} 18 | \item [$i$, $j$] Gas nodes. 19 | \item [$m$, $n$] Electric nodes (buses). 20 | \item [$o$] Gas pipeline. 21 | \item [$c$] Compressor. 22 | \item [$l$] Transmission line. 23 | \item [$w$] Gas well. 24 | \item [$e$] Power generator. 25 | \item [$ref$] Reference bus. 26 | \item [$r$] Spinning reserve. 27 | \item [$\sigma$] Type of gas load. 28 | \end{labeling} 29 | 30 | \subsection*{Parameters} 31 | 32 | \begin{labeling}{Longer label\quad} 33 | \item [$\alpha^{i}_{\pi_+}, \alpha^{i}_{\pi _-}$] Penalties for over-pressure and under-pressure at node $i$. 34 | \item [$\alpha_{\gamma}$] Penalties for non-supplied gas. 35 | \item [$\alpha_{\epsilon}$] Penalties for non-supplied electricity. 36 | \item [$C^{w}_{G}$] Gas cost at the well $w$. 37 | \item [$C^{oij}_{O}$] Transport cost of pipeline $o$, from node $i$ to node $j$. 38 | \item [$C^{cij}_{C}$] Compression cost of compressor $c$, from node $i$ to node $j$. 39 | \item [$C^{i}_{S}$] Storage cost at node $i$. 40 | \item [$C^{i}_{S_+}$] Storage outflow price at node $i$. 41 | \item [$C^{i}_{S_-}$] Storage inflow price at node $i$. 42 | \item [$C^{e}_{E}$] Power cost generation (excluding gas cost). 43 | \item [$\eta^{q}_{e}$] Thermal efficiency at generator $e$. 44 | \item [$D_{g}^{i \sigma}$] Gas demand of type $\sigma$ at node $i$. 45 | \item [$D_{e}^{tm}$] Electricity demand in the bus $m$ at time $t$. 46 | \item [$\bar{g}^{w}$, $\underline{g}^{w}$] Gas production limits. 47 | \item [$\overline{\pi}^{i}$, $\underline{\pi}^{i}$] Quadratic pressure limits at node $i$. 48 | \item [$S^{i}_{0}$] Initial stored gas at node $i$. 49 | \item [$\overline{S}^{i}$, $\underline{S}^{i}$] Storage limits at node $i$. 50 | \item [$\kappa^{oij}$] Weymouth constant of pipeline $o$. 51 | \item [$\delta^{oij}$] Threshold for gas flow capacities. 52 | \item [$\beta^{cij}$] Compression ratio of compressor $c$. 53 | \item [$Z^{c}$] Ratio parameter of compressor $c$. 54 | \item [$B^{c}$] Compressor design parameter of compressor $c$. 55 | \item [$x$, $y$, $z$] Gas consumption parameters of gas-driven compressors. 56 | \item [$\overline{f}^{oij}_{g}$] Gas transport capacity of pipeline $o$, from node $i$ to node $j$. 57 | \item [$\overline{f}^{cij}_{g}$] Gas flow capacity of compressor $c$, from node $i$ to node $j$. 58 | \item [$\overline{f}^{i}_{s}$,$\underline{f}^{i}_{s}$] Storage outflow capacities at node $i$. 59 | \item [$\overline{p}_{g}^{e}$, $\underline{p}_{g}^{e}$] Active power generation limits of generator $e$. 60 | \item [$\overline{q}_{g}^{e}$, $\underline{q}_{g}^{e}$] Reactive power generation limits of generator $e$. 61 | \item [$\overline{V}^{tm} \underline{V}^{tm}$] Voltage limits for bus $m$ at time $t$. 62 | \item [$\mathbb{S}^{l}$] Transmission capacity of power line $l$. 63 | %\item [$x^{mn}_{l}$] Reactance of line $l$, from bus $m$ to bus $n$. 64 | \item [$R^{tr}$] Spinning reserve in the $r$-th spinning reserve zone at time $t$. 65 | %\item [$M$] Generators assignment matrix. 66 | %\item [$L$] Compressors assignment matrix. 67 | \item [$u^{te}$] Unit commitment state for generator $e$ at time $t$. 68 | \item [$\tau^{t}$] Energy weight related to period of time $t$. 69 | \item [$E^{e}$] Available energy for hydroelectric generator $e$, \break during the total analysis window. 70 | \end{labeling} 71 | 72 | \subsection*{Sets} 73 | 74 | \begin{labeling}{Longer label\quad} 75 | \item [$\cal{N}$] Gas nodes, $\left| \cal{N} \right|= n_{\cal{N}}$. 76 | \item [$\cal{N}_{S}$] Gas nodes with storage, $\cal{N}_{S} \subset \cal{N} $, $\left| \cal{N}_{S} \right|= n_{\cal{S}}$. 77 | \item [${\cal{O}}$] Gas pipelines, $\left| \cal{O} \right| = n_{\cal{O}}$ 78 | \item [${\cal{C}}$] Compressors, ${\cal{C}}_{G} \cup {\cal{C}}_{E}$, $\left| \cal{C} \right| = n_{\cal{C}}$ 79 | \item [${\cal{C}}_{G}$] Compressors controlled by natural gas, ${\cal{C}}_{G} \subseteq {\cal{C}}$, $\left| {\cal{C}}_{G} \right| = n_{{\cal{C}}_{G}}$ 80 | \item [${\cal{C}}_{E}$] Compressors controlled by electric power, ${\cal{C}}_{E} \subseteq {\cal{C}}$, $\left| {\cal{C}}_{E} \right| = n_{{\cal{C}}_{P}}$ 81 | \item [${\cal{W}}$] Gas wells, $\left| \cal{W} \right|= n_{\cal{W}}$. 82 | %\item [${\cal{W}}^{i}$] Gas wells at node $i$, ${\cal{W}}^{i} \subset \cal{W} $, $\left| {\cal{W}}^{i} \right|= n_{{\cal{W}}^{i}}$. 83 | \item [$\cal{B}$] Power buses, $\left| \cal{B} \right|= n_{\cal{B}}$. 84 | \item [$\cal{L}$] Power lines, $\left| \cal{L} \right|= n_{\cal{L}}$. 85 | \item [$\cal{E}$] Power unit generators, ${\cal{E}}_{H} \cup {\cal{E}}_{G}^{i} =\cal{E}$, $\left| \cal{E} \right|= n_{\cal{E}}$. 86 | \item [${\cal{E}}_{H}$] Hydroelectric power units, ${\cal{E}}_{H} \subseteq \cal{E} $, $\left| {\cal{E}}_{H} \right|= n_{{\cal{E}}_{H}}$. 87 | \item [${\cal{E}}^{i}_{G}$] Gas-fired power units connected to gas node $i$, \break ${\cal{E}}^{i}_{G} \subseteq \cal{E}$, $\left| {\cal{E}}^{i}_{G} \right|= n_{{\cal{E}}_{G}}$. 88 | \item [${\cal{Z}}_{r}$] Spinning reserve zones. 89 | \item [${\cal{F}}^{i}_{G}$, ${\cal{T}}^{i}_{G}$] Connected pipelines to node $i$ at side \textit{From} or \textit{To}. 90 | \item [${\cal{F}}^{i}_{C}$, ${\cal{T}}^{i}_{C}$] Connected compressors to node $i$ at side \textit{From} or \textit{To}. 91 | \item [${\cal{F}}^{m}_{E}$, ${\cal{T}}^{m}_{E}$] Connected power lines to bus $m$ at side \textit{From} or \textit{To}. 92 | \item [$\cal{T}$] Periods of analysis. 93 | \item [$\Sigma$] Different types of gas demands. 94 | \end{labeling} 95 | 96 | \subsection*{Variables} 97 | 98 | \begin{labeling}{Longer label\quad} 99 | \item [${f}_{g}^{oij}$] Gas flow in pipeline $o$, from node $i$ to node $j$. 100 | \item [${f}_{g_+}^{oij}$ ${f}_{g_-}^{oij}$] Positive and negative gas flow in pipeline $o$. 101 | \item [${f}_{g}^{cij}$] Gas flow in compressor $c$, from node $i$ to node $j$. 102 | \item [$\psi^{c}$] Power consumed by compressor $c$. 103 | \item [$\phi^{c}$] Gas consumed by compressor $c$, connected to node $i$ at side \textit{from}. 104 | \item [$\gamma^{i \sigma}$] Non-served gas of type $\sigma$ at node $i$. 105 | \item [$\pi^{i}$] Quadratic pressure at node $i$. 106 | \item [${\pi}^{i}_{+}$, ${\pi}^{i}_{-}$] Quadratic over/under pressures at node $i$. 107 | \item [$g^{w}$] Gas production at well $w$. 108 | \item [$f_{s}^{i}$] Storage outflow difference. 109 | \item [$f_{s_+}^{i}$, $f_{s_-}^{i}$] Storage outflow and inflow. 110 | \item [$p_{g}^{te}$] Active power production of generator $e$ at time $t$. 111 | \item [$q_{g}^{te}$] Reactive power production of generator $e$ at time $t$. 112 | \item [$V^{tm}$] Voltage magnitude of bus $m$ at time $t$. 113 | \item [$\theta^{tm}$] Voltage angle of bus $m$ at time $t$. 114 | \item [$\epsilon^{tm}$] Non-served active power of bus $m$ at time $t$. 115 | \end{labeling} 116 | %\section{~} 117 | \section{Objective function} 118 | 119 | The cost function presented in Equation \ref{eq:obj_func} consists of several linear components, both from the power and the gas networks. It comprises the sum of the operation cost of the interdependent system. In the case of the natural gas network, it includes the natural gas extraction cost, the transportation cost, the storage cost, the penalties associates with quadratic over/sub pressures, and non-supplied natural gas. In the case of the power network, it includes the generation cost and the penalties associates with non-supplied power demand. 120 | 121 | %The cost function is represented by the equation \ref{obj_func} and is composed by several linear components. The first component is the gas production cost at each of the wells. As well as the first component, the second one is the power generation cost for every power plant, for the complete period. \color{red}The third component is the cost of the storage flow at every node with storage availability. \color{black}The fourth expression is the storage cost, having into account the previous storage level and the outing flow. The fifth component is the gas transport cost for each pipeline. Finally, the last three component are the penalties cost for over/under pressure, non-supply gas and non-supply power, respectively. Related to the non-gas supply, is important to clarify that the non-supply cost depends on the type of user. 122 | 123 | \begin{equation} 124 | \begin{aligned} 125 | C \left( x \right) = & \sum_{w \in \cal{W}}{C^{w}_{G} g^{w}} + \sum_{t \in \cal{T}} {\tau}^{t} \sum_{e \in \cal{E}} {C^{e}_{E} p_{g}^{te}}\\ 126 | & + \sum_{i \in {\cal{N}}_{S}}{\left({C^{i}_{S_+} f^{i}_{s_+}} - {C^{i}_{S_-} f^{i}_{s_-}} \right)}\\ 127 | & + \sum_{i \in {\cal{N}}_{S}}{C^{i}_{S} \left( S^{i}_{0} - f^{i}_{s} \right)} \\ 128 | & + \sum_{o \in \cal{O}}{C^{oij}_{O} f^{oij}_{g_+}} - \sum_{o \in \cal{O}}{C^{oij}_{O} f^{oij}_{g_-}} \\ 129 | & + \sum_{c \in \cal{C}}{C^{cij}_{C} f^{cij}_{g}} \\ 130 | & + \sum_{i \in \cal{N}}{\alpha^{i}_{\pi_+} \pi^{i}_{+}} + \sum_{i \in \cal{N}}{ \alpha^{i}_{\pi_-} \pi^{i}_{-}} \\ 131 | & + \sum_{i \in \cal{N}}\sum_{\sigma \in \Sigma} {\alpha_{\gamma}^{i \sigma}\gamma^{i \sigma}} + \alpha_{\epsilon} \sum_{t \in \cal{T}} {\tau}^{t} \sum_{m \in \cal{B}} {\epsilon^{tm}} 132 | \end{aligned} 133 | \label{eq:obj_func} 134 | \vspace{0.3cm} 135 | \end{equation} 136 | 137 | The aim of the Optimal Power and Natural Gas Flow is to minimize the linear objective $C(x)$ subject to the constraints explained below. 138 | 139 | \section{Constraints} 140 | 141 | %The model of the optimal power and natural gas flow consists in maintain the balance in both networks. For the natural gas network the nodal balance must be has linear and non-linear constraints, which model the 142 | 143 | \subsection{Gas network} 144 | 145 | Equation \ref{eq:node_gas_balance} shows the gas balance for a specific node $k$ during a day. This gas balance is composed by the incoming and outgoing flows associated with pipelines and compressors at the node $k$, the outgoing stored flow in the available storage, the generation related to that node, and the total gas demand. In detail, the gas demand is composed by the required flow in the gas-fired power plants and compressors, and the total gas demand of the rest of the consumers, excluding the non-supplied natural gas. 146 | 147 | \begin{equation} 148 | \begin{array}{l}\displaystyle 149 | \sum_{o \in {\cal{T}}^{k}_{G}}{{f}_{g}^{oij}} - \sum_{o \in {\cal{F}}^{k}_{G}}{{f}_{g}^{oij}} + \sum_{c \in {\cal{T}}^{k}_{C}}{{f}_{g}^{cij}} - \sum_{c \in {\cal{F}}^{k}_{C}}{ \left({f}_{g}^{cij} + \phi^{c}\right)} + {f}^{k}_{s}\\ [0.8cm] \displaystyle 150 | + \sum_{w \in {\cal{W}}^{k}}{g^{w}} - \sum_{t \in \cal{T}} {\tau}^{t} \sum_{e \in {\cal{E}}^{k}_{G}}\left({\eta^{q}_{e}}\cdot {p_{g}^{te}}\right) = {\sum_{\sigma \in \Sigma}\left( D^{\sigma k}_{g} - \gamma^{\sigma k}\right)} \\ 151 | \end{array} 152 | ,\;\; \forall k \in \cal{N}. 153 | \label{eq:node_gas_balance} 154 | \end{equation} 155 | 156 | \newpage 157 | \noindent \textbf{Nodes}\\ 158 | 159 | Constraints related to node $k$ are those that involve variables of non-supplied gas demands and quadratic pressures. The non-supplied gas at node $k$ for a specific user $\sigma$ can not exceed the total demand of that user. This constraint is presented in Equation \ref{eq:nsg_limits}. 160 | 161 | \begin{equation} 162 | {0 \le \gamma^{\sigma k} \le D^{\sigma k}_{g}, \quad \forall \sigma \in \Sigma, \quad \forall k \in \cal{N}}. 163 | \label{eq:nsg_limits} 164 | \vspace{0.3cm} 165 | \end{equation} 166 | 167 | Moreover, Equations \ref{overp} and \ref{underp} are the constraints that characterize the quadratic over-pressure and under-pressure at each node of the system, respectively. 168 | 169 | \begin{equation} 170 | \begin{array}{l} 171 | \pi^{k} \le \overline{\pi}^{k} + \pi^{k}_{+}\\ 172 | 0 \le \pi^{k}_{+}\\ 173 | \end{array} 174 | ,\quad \forall k \in {\cal{N}}\\ 175 | \label{overp} 176 | \end{equation} 177 | 178 | \begin{equation} 179 | \begin{array}{l} 180 | \underline{\pi}^{k} - \pi^{k}_{-} \le \pi^{k}\\ 181 | 0 \le \pi^{k}_{-}\\ 182 | \end{array} 183 | ,\quad \forall k \in {\cal{N}}.\\ 184 | \label{underp} 185 | \vspace{0.3cm} 186 | \end{equation} 187 | 188 | \noindent \textbf{Wells}\\ 189 | 190 | The constraints related to the gas wells injection depends on each well characteristics. The injection limits are represented as follows: 191 | 192 | \begin{equation} 193 | \underline{g}^{w} \le g^{w} \le \overline{g}^{w}, \quad \forall w \in \cal{W}. 194 | \label{eq:g_limits} 195 | \end{equation} 196 | %\vspace{5cm} 197 | 198 | \noindent \textbf{Pipelines} \\ 199 | 200 | The gas flow in pipeline $o$, connecting nodes $i$ and $j$, depends on the quadratic pressures of such nodes. This behavior is given by the Weymouth Equation \ref{eq:wey}. In particular, the gas flow is allowed to be bidirectional within a physical limit for a maximum daily transportation according to Equation \ref{fgo_limits}. On the other hand, as the transport cost is always a positive quantity no matter the direction, variables $f^{oij}_{g+}$ and $f^{oij}_{g-}$ support a positive contribution to the objective function. Equation \ref{eq:fgo} shows the sum of both directional flows to determine the actual flow in the direction $from$ node $i$ - $to$ node $j$. These flow variables are constrained by Equations \ref{eq:fgopos_limits} and \ref{eq:fgoneg_limits}. As seen, the positive gas flow must be greater than or equal to zero but lower than or equal to the maximum transport capacity multiplied by a threshold factor, $\delta^{oij}$, which states an extra flow margin. Analogously, the negative gas flow has similar bounds in the negative side. 201 | 202 | 203 | \begin{equation} 204 | {f}^{oij}_{g} = {{\kappa}^{oij}} sgn \left(\pi^{i}-\pi^{j}\right) {\sqrt{\left|\pi^{i}-\pi^{j}\right|}}, \quad \forall o \in {\cal{O}} 205 | \label{eq:wey} 206 | \end{equation} 207 | \begin{equation} 208 | - \overline{f}^{oij}_{g} \le f^{oij}_{g} \le \overline{f}^{oij}_{g}, \quad \forall o \in {\cal{O}} 209 | \label{fgo_limits} 210 | \end{equation} 211 | \begin{equation} 212 | {f}^{oij}_{g} = f^{oij}_{g_+} + {f}^{oij}_{g_-}, \quad \forall o \in {\cal{O}} 213 | \label{eq:fgo} 214 | \end{equation} 215 | \begin{equation} 216 | 0 \le f^{oij}_{g_+} \le \delta^{oij} \cdot \overline{f}^{oij}_{g}, \quad \forall o \in {\cal{O}} 217 | \label{eq:fgopos_limits} 218 | \end{equation} 219 | \begin{equation} 220 | - \delta^{oij} \cdot \overline{f}^{oij}_{g} \le f^{oij}_{g_-} \le 0, \quad \forall o \in {\cal{O}}. 221 | \label{eq:fgoneg_limits} 222 | \end{equation} 223 | 224 | \noindent \textbf{Compressors}\\ 225 | 226 | Compressors allow recovering from pressure losses through the gas network. This process demands energy. The power consumption of compressor $c$ between the suction node $i$ and the discharge node $j$ is given by Equation \ref{eq:hp_fc}. It depends on the quadratic pressure ratio of nodes $i$ and $j$, and the gas flow through the compressor. Moreover, the additional gas required by a gas-driven compressor relies on its consumed power as shown in Equation \ref{eq:g_fc}. As the gas flow through compressors is restricted to flow in one direction, the flow limits of compressor $c$ are fixed according to Equation \ref{eq:gfa_limits}. Finally, the quadratic pressure at suction and discharge nodes must fall within acceptable margins, as presented in Equation \ref{eq:presa_rel}, where $\beta^{cij}$ is the maximum compressor ratio.\\ 227 | 228 | \begin{equation} 229 | \psi^{c} = {B^{c}}{f}^{cij}_{g} \cdot \left[ {\left( \frac{\pi^{j}}{\pi^{i}} \right)}^{\frac{Z^{c}}{2}} - 1 \right], \quad \forall c \in {\cal{C}} 230 | \label{eq:hp_fc} 231 | \end{equation} 232 | \begin{equation} 233 | {\phi}^{c} = x + y \psi^{c} + z {\psi^{c}}^{2}, \quad \forall c \in {\cal{C}}_{G} 234 | \label{eq:g_fc} 235 | \end{equation} 236 | \begin{equation} 237 | 0 \le {f}^{cij}_{g} \le \overline{f}^{cij}_{g}, \quad \forall c \in {\cal{C}} 238 | \label{eq:gfa_limits} 239 | \end{equation} 240 | \begin{equation} 241 | \begin{aligned} 242 | &\pi^{i} \le \pi^{j} \le \beta^{cij} \pi^{i}\\ 243 | &\beta^{cij} \ge 1 \\ 244 | \end{aligned} 245 | ,\quad\forall i,j \in {\cal{N}}, \quad \forall c \in {\cal{C}}. 246 | \label{eq:presa_rel} 247 | \end{equation} 248 | 249 | \noindent \textbf{Storage}\\ 250 | 251 | The storage outflow difference is the subtraction between the storage outflow and the storage inflow at the storage nodes; this relationship is represented by Equation \ref{eq:fs}. Additionally, Equation \ref{eq:fs_limits} shows that the outflow storage difference is restricted by the maximum and minimum amount of gas that is allowed to be injected to or demanded from the network in every storage node. Furthermore, as the storage unit can operate either as an injection or a demand for the network, Equations \ref{eq:fs+} and \ref{eq:fs-} represent the possible storage unit behavior. In particular, the maximum gas amount that can be injected is the difference between the currently available stored gas and the minimum possible volume of the unit. Similarly, the maximum inflow is the difference between the maximum volume of the unit and the currently available stored gas. 252 | 253 | \begin{equation} 254 | f_{s}^{k} = f_{s_+}^{k} - f_{s_-}^{k}, \quad \forall k \in \cal{N} 255 | \label{eq:fs} 256 | \end{equation} 257 | \begin{equation} 258 | \underline{f}^{k}_{s} \le f^{k}_{s} \le \overline{f}^{k}_{s}, \quad \forall k \in \cal{N} 259 | \label{eq:fs_limits} 260 | \end{equation} 261 | \begin{equation} 262 | 0 \le f_{s_+}^{i} \le S^{k}_{0} - \underline{S}^{k}, \quad \forall k \in \cal{N} 263 | \label{eq:fs+} 264 | \end{equation} 265 | \begin{equation} 266 | 0 \le f_{s_-}^{i} \le \overline{S}^{k} - S^{k}_{0}, \quad \forall k \in \cal{N}. 267 | \label{eq:fs-} 268 | \end{equation} 269 | 270 | \subsection{Power network} 271 | 272 | The power network balance equations of active and reactive power are given by Equation \ref{eq:power_balance}. The model also takes into consideration the non-supplied power demand and the power consumed by compressors connected to the power system. 273 | 274 | \begin{equation} 275 | \begin{array}{l} 276 | g_{p_m}\left(\theta^{tm}, V^{tm}, p_{g}^{te}, \epsilon^{te}, \psi^{c}\right) = 0\\ 277 | g_{q_m}\left(\theta^{tm}, V^{tm}, q_{g}^{te}\right) = 0\\ 278 | \\ 279 | \quad \forall m \in {\cal{B}} \quad \forall t \in {\cal{T}} \quad \forall c \in {\cal{C}}_{E}. 280 | \end{array} 281 | \label{eq:power_balance} 282 | \vspace{0.3cm} 283 | \end{equation} 284 | 285 | The main variables of the power system are the voltage angles $\theta^{tm}$ and the voltage magnitudes $V^{tm}$ at each bus $m$ for every period of time $t$, as well as the active generation $p^{te}_{g}$ and reactive generation $g^{te}_{g}$ at each generator $e$ for each time period. The voltage limits are represented by Equation \ref{eq:v_lims}, and the generation limits are shown in Equation \ref{eq:pq_lims}. 286 | 287 | \begin{equation} 288 | \begin{aligned} 289 | &\theta^{t_\text{ref}} = 0\\ 290 | &\underline{V}^{tm} \le V^{tm} \le \overline{V}^{tm}\\ 291 | \end{aligned} 292 | \;,\quad \forall m \in {\cal{B}} \quad \forall t \in {\cal{T}} 293 | \label{eq:v_lims} 294 | \end{equation} 295 | 296 | \begin{equation} 297 | \begin{aligned} 298 | &\underline{p}_{g}^{e} \le p_{g}^{te} \le \overline{p}_{g}^{e}\\ 299 | &\underline{q}_{g}^{e} \le q_{g}^{te} \le \overline{q}_{g}^{e}\\ 300 | \end{aligned} 301 | \;,\quad \forall e \in {\cal{E}}, \quad \forall t \in {\cal{T}}. 302 | \label{eq:pq_lims} 303 | \vspace{0.3cm} 304 | \end{equation} 305 | 306 | The power flow limits are bidirectional and are presented in Equation \ref{eq:sft_lims}, where $\mathbb{S}_{fl}$ and $\mathbb{S}_{tl}$ are the complex power injections at side $from$ and $to$ of line $l$, respectively. 307 | 308 | \begin{equation} 309 | \begin{aligned} 310 | &|\mathbb{S}_{fl}\left(\theta,V\right)| \le \overline{\mathbb{S}}_{fl}\\ 311 | &|\mathbb{S}_{tl}\left(\theta,V\right)| \le \overline{\mathbb{S}}_{tl}\\ 312 | \end{aligned} 313 | \;,\quad \forall l \in {\cal{L}}. 314 | \label{eq:sft_lims} 315 | \vspace{0.3cm} 316 | \end{equation} 317 | 318 | The non-supplied active power demand at bus $m$ can not exceed the total bus demand, according to Equation \ref{nsd_limits}. 319 | 320 | \begin{equation} 321 | 0 \le \epsilon^{tm} \le D^{tm}_{e}, \quad \forall m \in {\cal{B}}, \quad \forall t \in {\cal{T}}. 322 | \label{nsd_limits} 323 | \vspace{0.3cm} 324 | \end{equation} 325 | 326 | The model also considers the required spinning reserve for each zone $r$ at every time $t$. This constraint is given by Equation \ref{eq:reserve}. 327 | 328 | \begin{equation} 329 | %\begin{array}{l} 330 | \sum_{e \in {\cal{Z}}_{r}}{u^{te} \left( \overline{p}_{g}^{e} - p_{g}^{te} \right)} \ge R^{tr} ,\quad \forall r \in {\cal{Z}}_{r}, \quad \forall t \in {\cal{T}}. 331 | %\end{array} 332 | \label{eq:reserve} 333 | \vspace{0.3cm} 334 | \end{equation} 335 | 336 | Finally, the model takes into consideration the maximum available energy during a day for certain generators, especially the energy stored in the dams for hydro-power plants. Equation \ref{eq:hydro_e} represents such a constraint. 337 | 338 | \begin{equation} 339 | \sum_{t \in {\cal{T}}}{{\tau}^{t} p_{g}^{te}} \le E^{e}, \quad \forall e \in {\cal{E}}_{H} 340 | \label{eq:hydro_e}. 341 | \vspace{0.3cm} 342 | \end{equation} 343 | 344 | \newpage -------------------------------------------------------------------------------- /MPNG_User's_Manual/Chapters/Front_matter.tex: -------------------------------------------------------------------------------- 1 | \thispagestyle{empty} 2 | 3 | \makeatletter 4 | \begin{titlepage} 5 | \begin{center} 6 | \includegraphics[width=0.75\textwidth]{./Figures/MPNG_logo} 7 | \vskip 10.5ex 8 | {\huge \bfseries{User's Manual} \par}%\\[2ex] 9 | \vskip 2em% 10 | {\LARGE Version \mpngversion{} \par}%\\[2ex] 11 | \vskip 3em% 12 | {\large 13 | \lineskip .75em% 14 | \begin{table}[H] 15 | \nonumber 16 | \centering 17 | \begin{tabular}{ccc} 18 | Sergio García-Marín & Wilson González-Vanegas & Carlos E. Murillo-Sánchez\\ 19 | \end{tabular} 20 | \end{table}} 21 | \vskip 1.5em% 22 | {\large \today \par}% 23 | \vfill 24 | {\scriptsize 25 | \copyright $\;$ 2019 individual contributors (see AUTHORS file for details)\\ 26 | All Rights Reserved} 27 | \end{center} 28 | \end{titlepage} 29 | \makeatother 30 | 31 | \newpage -------------------------------------------------------------------------------- /MPNG_User's_Manual/Chapters/Getting_started.tex: -------------------------------------------------------------------------------- 1 | \chapter{Getting started} 2 | \label{chap:get_started} 3 | 4 | \section{System Requirements} 5 | \label{sec:requirements} 6 | 7 | \mpng{} has the following software requirements: 8 | 9 | \begin{itemize} 10 | \item[\checkmark] \matlab{}\textsuperscript{\tiny \textregistered} version 7.3 (R2016b) or later.\footnote{\matlab{} is available from The MathWorks, Inc. (\url{https://www.mathworks.com/}). An R2016b or later \matlab{} version is required as the \mpng{} code uses \matlab{}-files with multiple function declarations.} 11 | 12 | \item[\checkmark] \matpower{} version 7.0 or later.\footnote{\matpower{} is available thanks to the Power Systems Engineering Research Center (\pserc) (\url{https://matpower.org}). \mpng{} requires \matpower{} version 7.0 or later to be properly installed.} 13 | \end{itemize} 14 | 15 | \section{Getting \mpng{}} 16 | \label{sec:get_mpng} 17 | 18 | You can obtain the \emph{current development version} from the \matpower{} Github repository: \url{https://github.com/MATPOWER/mpng.git}. 19 | 20 | \section{Installation} 21 | \label{sec:install} 22 | 23 | Installation and use of \mpng{} requires familiarity with basic operations of \matlab{} and \matpower{}. In short, installing \mpng{} is as simple as adding all the distribution files to the \matlab{} path. The user could either proceed manually with such an addition, or run the quick installer released with the package by opening \matlab{} at the \mpngpath{} directory and typing:\\ 24 | 25 | \code{~~~~~~~~~~~~~~~~~~~~~~~~~~~~install\_mpng}\\ 26 | 27 | \noindent A successful installation of a distribution located at the directory \mpnggitpath{} looks like: 28 | 29 | \begin{Notice} 30 | >> install_mpng 31 | 32 | ---------- MPNG installation routine ---------- 33 | 34 | Adding to the path: E:\GITHUB\MPNG\Functions 35 | Adding to the path: E:\GITHUB\MPNG\Cases 36 | Adding to the path: E:\GITHUB\MPNG\Examples 37 | 38 | MPNG has been successfully installed! 39 | \end{Notice} 40 | 41 | \section{Running a Simulation} 42 | \label{sec:simulate} 43 | 44 | The primary functionality of \mpng{} is to solve optimal power and natural gas flow problems. Running a simulation using \mpng{} requires (1) preparing the natural gas input data, (2) specifying the interconnection input data to couple the gas network to the power system, (3) invoking the function to run the integrated simulation and (4) accessing and viewing the results. 45 | 46 | The classical \matpower{} input data is a ``\matpower{}-case'' struct denoted by the variable \code{mpc}\cite{matpower_manual}. To integrate the power and natural gas systems we use the extended Optimal Power Flow (OPF) capability of \matpower{}. Namely, we model the natural gas system and its connection to the power system via general user nonlinear constraints. Then, \mpng{} uses an extended ``\matpower{}-gas case'' struct denoted by the variable \code{mpgc}. In particular, \code{mpgc} is a traditional \matpower{}-case struct with two additional fields, \code{mpgc.mgc} and \code{mpgc.connect} standing for the natural gas case and interconnection case, respectively. 47 | 48 | \subsection{Preparing the Natural Gas Case} 49 | \label{subsec:gas_case} 50 | 51 | The input data of the natural gas system are specified in a set of matrices arranged in a \matlab{} struct that we refer to as the ``gas case'' (\code{mpgc.mgc}). The structure of such a case is formatted in a similar way to the \matpower{}-case but holding the natural gas information that comprises nodes (including gas demand), wells, pipelines, compressors, and storage units. See Appendix~\ref{app:gas_format} for more details about the gas case structure. 52 | 53 | \subsection{Connecting the Gas Case to the \matpower{} Case} 54 | \label{subsec:connect_case} 55 | 56 | The input data regarding the connection between the power and natural gas systems are declared in a set of matrices packaged as a \matlab{} struct which we call ``interconnection case'' (\code{mpgc.connect}). The structure of this case contains specific information about coupling elements like gas-fired power generators and power-and-gas-driven compressors, according to the optimization model described in section~\ref{chap:formulation}. See Appendix~\ref{app:connect_format} for more details about the interconnection case structure. 57 | 58 | \subsection{Solving the Optimal Power\&Gas Flow} 59 | \label{subsec:solve_OPGF} 60 | 61 | Once the \matpower{}-gas case is properly formatted, the solver can be invoked using the (mandatory) \code{mpgc} struct and the traditional (optional) \matpower{} options struct \code{mpopt}. The calling syntax at the \matlab{} prompt could be one of the following: 62 | 63 | \begin{Code} 64 | >> mpng(mpgc); 65 | >> mpng(mpgc,mopt); 66 | >> results = mpng(mpgc); 67 | >> results = mpng(mpgc,mpopt); 68 | \end{Code} 69 | 70 | We have included a description for all of \mpng{}'s functions to work properly with the built-in \code{help} command. For instance, to get the help for \code{mpng}, type: 71 | 72 | \begin{Code} 73 | >> help mpng 74 | \end{Code} 75 | 76 | \subsection{Accessing the Results} 77 | \label{subsec:view_results} 78 | 79 | By default, the results of the optimization run are pretty-printed on the screen, displaying the traditional \matpower{} results for the power system\footnote{Including the non-supplied power demand as described in the formulation introduced in section \ref{chap:formulation}.} along with a gas system summary, node data, pipeline data, compressor data, storage data, and the interconnection results concerning gas-fired generators data. 80 | 81 | The optimal results are also stored in a \code{results} struct packaged as the default \matpower{} superset of the input case struct \code{mpgc}. Table \ref{tab:results_struct} shows the solution values included in the \code{results}. 82 | 83 | \begin{table}[!ht] 84 | %\renewcommand{\arraystretch}{1.2} 85 | \centering 86 | \begin{threeparttable} 87 | \caption{Power and Gas Flow Results} 88 | \label{tab:results_struct} 89 | \footnotesize 90 | \begin{tabular}{ll} 91 | \toprule 92 | name & description \\ 93 | \midrule 94 | \code{results.success} & success flag, 1 = succeeded, 0 = failed \\ 95 | \code{results.et} & computation time required for solution \\ 96 | \code{results.iterations} & number of iterations required for solution \\ 97 | \code{results.order} & see \code{ext2int} help for details on this field \\ 98 | \code{results.bus(:, VM)}\tnote{\S} & bus voltage magnitudes \\ 99 | \code{results.bus(:, VA)} & bus voltage angles \\ 100 | \code{results.gen(:, PG)} & generator real power injections \\ 101 | \code{results.gen(:, QG)}\tnote{\S} & generator reactive power injections \\ 102 | \code{results.branch(:, PF)} & real power injected into ``from'' end of branch \\ 103 | \code{results.branch(:, PT)} & real power injected into ``to'' end of branch \\ 104 | \code{results.branch(:, QF)}\tnote{\S} & reactive power injected into ``from'' end of branch \\ 105 | \code{results.branch(:, QT)}\tnote{\S} & reactive power injected into ``to'' end of branch \\ 106 | \code{results.f} & final objective function value \\ 107 | \code{results.x} & final value of optimization variables (internal order) \\ 108 | \code{results.om} & OPF model object\tnote{\dag} \\ 109 | \code{results.bus(:, LAM\_P)} & Lagrange multiplier on real power mismatch \\ 110 | \code{results.bus(:, LAM\_Q)} & Lagrange multiplier on reactive power mismatch \\ 111 | \code{results.bus(:, MU\_VMAX)} & Kuhn-Tucker multiplier on upper voltage limit \\ 112 | \code{results.bus(:, MU\_VMIN)} & Kuhn-Tucker multiplier on lower voltage limit \\ 113 | \code{results.gen(:, MU\_PMAX)} & Kuhn-Tucker multiplier on upper $P_g$ limit \\ 114 | \code{results.gen(:, MU\_PMIN)} & Kuhn-Tucker multiplier on lower $P_g$ limit \\ 115 | \code{results.gen(:, MU\_QMAX)} & Kuhn-Tucker multiplier on upper $Q_g$ limit \\ 116 | \code{results.gen(:, MU\_QMIN)} & Kuhn-Tucker multiplier on lower $Q_g$ limit \\ 117 | \code{results.branch(:, MU\_SF)} & Kuhn-Tucker multiplier on flow limit at ``from'' bus \\ 118 | \code{results.branch(:, MU\_ST)} & Kuhn-Tucker multiplier on flow limit at ``to'' bus \\ 119 | \code{results.mu} & shadow prices of constraints\tnote{\ddag} \\ 120 | \code{results.g} & (optional) constraint values \\ 121 | \code{results.dg} & (optional) constraint 1st derivatives \\ 122 | \code{results.raw} & raw solver output in form returned by MINOS, and more\tnote{\ddag} \\ 123 | \code{results.var.val} & final value of optimization variables, by named subset\tnote{\ddag} \\ 124 | \code{results.var.mu} & shadow prices on variable bounds, by named subset\tnote{\ddag} \\ 125 | \code{results.nle} & shadow prices on nonlinear equality constraints, by named subset\tnote{\ddag} \\ 126 | \code{results.nli} & shadow prices on nonlinear inequality constraints, by named subset\tnote{\ddag} \\ 127 | \code{results.lin} & shadow prices on linear constraints, by named subset\tnote{\ddag} \\ 128 | \code{results.cost} & final value of user-defined costs, by named subset\tnote{\ddag} \\ 129 | \bottomrule 130 | \end{tabular} 131 | \begin{tablenotes} 132 | \scriptsize 133 | \item [\S] {AC power flow only.} 134 | \item [\dag] {See help for \code{opf\_model} and \code{opt\_model} for more details.} 135 | \item [\ddag] {See help for \code{opf} for more details.} 136 | \end{tablenotes} 137 | \end{threeparttable} 138 | \end{table} 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /MPNG_User's_Manual/Chapters/Introduction.tex: -------------------------------------------------------------------------------- 1 | \normalsize 2 | \pagenumbering{arabic} 3 | \setcounter{page}{1} 4 | 5 | \chapter{Introduction} 6 | \label{chap:intro} 7 | 8 | \section{Background} 9 | \label{sec:background} 10 | 11 | \mpng{} is a \matpower{}-based~\cite{zimmerman2011,matpower} package for solving optimal power and natural gas flow problems. \mpng{} uses the general user nonlinear constraints capability of \matpower{} to model the gas network taking into account gas-fired power generators, storage units, wells, power-and-gas-driven compressors, and nodes with stratified demand (different market segments get different priorities). The \mpng{} source code can be found at: 12 | 13 | \bigskip 14 | ~~~~~~~~~~~~~~~~~~~~~~\url{\mpngurl} 15 | \bigskip 16 | 17 | \noindent \mpng{} was developed by Sergio~García-Marín~\footnote[1]{ Universidad Nacional de Colombia - sede Manizales.\label{foot:UNAL}} and Wilson~González-Vanegas~\footnote[2]{ Universidad Tecnológica de Pereira.\label{foot:UTP}} under the direction of Professor Carlos~E.~Murillo-S\'anchez~\footref{foot:UNAL}. The initial need for a \matpower{}-based power and natural gas optimal flow package was born out of a project aimed at analyzing the integrated operation of the Colombian power and natural gas systems.\footnote[3]{ Project number 1110-745-58696 funded by Colciencias, Colombia.} 18 | 19 | \section{License and Terms of Use} 20 | \label{sec:license} 21 | 22 | As a \matpower{}-based package, \mpng{} is distributed under the 3-clause BSD license~\cite{bsd}. The full text of the license can be found in the \code{LICENSE} file at the top level of the distribution or at \url{https://github.com/MATPOWER/mpng/blob/master/LICENSE} and reads as follows. 23 | 24 | \begin{Notice} 25 | Copyright (c) 2019, individual contributors (see AUTHORS file for 26 | details). All rights reserved. 27 | 28 | Redistribution and use in source and binary forms, with or without 29 | modification, are permitted provided that the following conditions 30 | are met: 31 | 32 | 1. Redistributions of source code must retain the above copyright 33 | notice, this list of conditions and the following disclaimer. 34 | 35 | 2. Redistributions in binary form must reproduce the above copyright 36 | notice, this list of conditions and the following disclaimer in the 37 | documentation and/or other materials provided with the distribution. 38 | 39 | 3. Neither the name of the copyright holder nor the names of its 40 | contributors may be used to endorse or promote products derived from 41 | this software without specific prior written permission. 42 | 43 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 44 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 45 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 46 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 47 | COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 48 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 49 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 50 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 51 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 52 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 53 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 54 | POSSIBILITY OF SUCH DAMAGE. 55 | \end{Notice} 56 | 57 | \section{Citing MPNG} 58 | \label{sec:citing_MPNG} 59 | 60 | While not required by the terms of the license, we do request that publications derived from the use of \mpng{} explicitly acknowledge that fact by citing this manual~\cite{mpng2019}. In the near future, a journal publication to appear should be cited instead. 61 | 62 | \begin{quote} 63 | \small 64 | S.~García-Marín, W.~González-Vanegas, and C.~E. Murillo-Sánchez, ``MPNG: \matpower{}-Natural Gas,'' 2019. 65 | [Online]. Available: \url{\mpngurl} 66 | \end{quote} -------------------------------------------------------------------------------- /MPNG_User's_Manual/Chapters/Natural_Gas_Flow.tex: -------------------------------------------------------------------------------- 1 | \chapter{Natural Gas Flow} 2 | \label{chap:fund_NGF} 3 | 4 | The steady-state Natural Gas Flow (NGF) problem for transmission networks is aimed at finding the value for a set of state-variables that satisfy the flow balance in all nodes. We show how the NGF can be derived in a similar way as the Power Flow (PF) problem is introduced for power systems. In particular, a set of nonlinear equations must be solved where the definition of the state-variables depends on the selected models for all of the elements of the system. In this section, we derive the NGF problem and introduce the modeling for the main elements considered in \mpng{}: nodes, wells, pipelines, compressors, and storage units. 5 | 6 | \section{Modeling} 7 | \label{sec:gas_modeling} 8 | 9 | An exact description of the natural gas flow in transmission networks requires applying the laws of fluid mechanics and thermodynamics \cite{Osiadacz2001}. Complex analyses provide an accurate description for variables such as temperature, pressure, flow, adiabatic head, among others, for all time instants. However, as the primary concern of \matpower{} (and of \mpng{}) is the system operation in steady-state, we define some models to describe the main elements of the default natural gas network, as explained below. 10 | 11 | \subsection{Nodes} 12 | \label{subsec:nodes} 13 | 14 | By definition, a node is the location of a natural gas system where one or more elements are connected. Users are commonly associated with a node where a stratified demand is modeled as different market segments that get different priorities. Figure \ref{fig:node} shows the $i$-th node of a gas network with some traditional markets connected to form the nodal demand $f_{dem}=\sum_{j} f_{\text{dem}_j}$. The primary variable related to a node is pressure $p_i$, although, as explained later, the actual state variable used in \mpng{} is the quadratic pressure. 15 | 16 | \begin{figure}[!ht] 17 | \centering 18 | \includegraphics[scale=1.2]{Figures/Node} 19 | \caption{A natural gas node and some traditional markets.} 20 | \label{fig:node} 21 | \end{figure} 22 | 23 | 24 | \subsection{Wells} 25 | \label{subsec:wells} 26 | 27 | Natural gas is extracted from deep underground and injected into the system from wells. Depending on the well capacity, the injection can be made either at constant pressure, where a control system regulates the amount of gas flow such that pressure behaves constant, or at constant flow, where pressure is adjusted such that injected flow remains constant. Figure \ref{fig:well} shows a well connected to the $i$-th node whose operation depends on two principal variables, the injected gas flow $f_{inj}^w$, and the nodal pressure $p_i$. 28 | 29 | \begin{figure}[!ht] 30 | \centering 31 | \includegraphics[scale=0.9]{Figures/Well} 32 | \caption{A natural gas well.} 33 | \label{fig:well} 34 | \end{figure} 35 | 36 | \subsection{Pipelines} 37 | \label{subsec:pipelines} 38 | 39 | In general, the flow of gas through pipes is studied using the energy equation of fluid mechanics~\cite{Banda2006}. However, in practice, the relationship between the gas flow in the pipe and the upstream and downstream pressures can be described by various equations. The Weymouth's general flow equation is a frequent choice in gas industry applications to model the steady-state flow in pipes in gas transports networks~\cite{Woldeyohannes2011}. Figure \ref{fig:pipeline} shows a pipeline $o$ whose gas flow from node $i$ to node $j$ is represented by $f_{ij}^o$. The Weymouth equation states the relationship between $f_{ij}^o$, $p_i$, and $p_j$ in the following form: 40 | 41 | \begin{equation} 42 | \label{eq:Weymouth_eq1} 43 | \text{sgn}(f_{ij}^o)(f_{ij}^o)^2 = K_{ij}(p_i^2-p_j^2). 44 | \vspace{0.3cm} 45 | \end{equation} 46 | 47 | \begin{figure}[!ht] 48 | \centering 49 | \includegraphics[scale=1]{Figures/Pipeline} 50 | \caption{A natural gas pipeline.} 51 | \label{fig:pipeline} 52 | \end{figure} 53 | 54 | In Equation \ref{eq:Kij}, $\text{sgn}(\cdot)$ represents the sign function, and $K_{ij}$ is the Weymouth constant\footnote{Measured in Million Standard Cubic Feet per Day (MMSCFD) over psia. Different expressions for $K_{ij}$ can be derived depending on the parameters used in the flow equations. See \cite{Woldeyohannes2011} and reference therein for details.} of the pipeline defined in terms of the pipe length and diameter as below~\cite{Wolf2000}: 55 | 56 | \begin{equation} 57 | \label{eq:Kij} 58 | K_{ij} = \sqrt{5.695756510\times 10^{-13}\:\frac{D^5}{\lambda Z T L\delta}}\quad \left[\frac{\text{MSCFD}}{\text{psia}}\right], 59 | \vspace{0.3cm} 60 | \end{equation} 61 | 62 | where: 63 | 64 | \begin{equation} 65 | \label{eq:lambda_Kij} 66 | \frac{1}{\lambda} = \left[2\log \left(\frac{3.7D}{\varepsilon}\right)\right]^2, 67 | \vspace{0.3cm} 68 | \end{equation} 69 | 70 | with: 71 | 72 | \begin{labeling}{alligator} 73 | \item [$\qquad \qquad D$] \hspace{0.8cm} Diameter [in]. 74 | \item [$\qquad \qquad L$] \hspace{0.8cm} Length [km]. 75 | \item [$\qquad \qquad T$] \hspace{0.8cm} Gas temperature [K]. 76 | \item [$\qquad \qquad \varepsilon$] \hspace{0.8cm} Absolute rugosity [mm]. 77 | \item [$\qquad \qquad \delta$] \hspace{0.8cm} Gas density relative to air [-]. 78 | \item [$\qquad \qquad Z$] \hspace{0.8cm} Gas compressibility factor [-]. 79 | \end{labeling} 80 | 81 | For mathematical convenience, we rewrite Equation \ref{eq:Weymouth_eq1} as follows: 82 | 83 | \begin{equation} 84 | \label{eq:Wymouth_eq_2} 85 | f_{ij}^o = K_{ij} \;\text{sgn}(\pi_i - \pi_j)\sqrt{|\pi_i-\pi_j|}, 86 | \vspace{0.3cm} 87 | \end{equation} 88 | 89 | \noindent where $\pi=p^2$ is defined as the quadratic pressure. 90 | 91 | As seen, the gas flow through a pipeline is a nonlinear function of the quadratic pressures of the initial and final nodes, that is, $f_{ij}^o=g(\pi_i,\pi_j)$. 92 | 93 | \subsection{Compressors} 94 | \label{subsec:compressors} 95 | As seen in Equation \ref{eq:Wymouth_eq_2}, there exists a downstream pressure drop when transporting large flows through pipes caused by energy losses. Analogous to the transformer in power systems, compressors are installed in the gas network to compensate pressure drops. Figure \ref{fig:compressor} shows a compressor $c$ that increases the discharge pressure $p_j$ with respect to the suction pressure $p_i$ by compressing gas in a way that a flow $f_{ij}^c$ passes through it. Assuming an adiabatic process, the power demanded by the compressor, $\psi_c$, states the relationship between the flow and the suction and discharge pressures in the following way~\cite{Shabanpour2016}: 96 | 97 | \begin{equation} 98 | \label{eq:comp_flow} 99 | f_{ij}^c = \frac{\psi_c}{B_c \left[\left(\frac{\pi_j}{\pi_i}\right)^{\frac{Z_c}{2}}-1\right]}, 100 | \vspace{0.3cm} 101 | \end{equation} 102 | 103 | where $B_c$ is the compressor constant that describes its construction features, $Z_c$ is the compressibility factor, and $\pi=p^2$ is again the quadratic pressure. 104 | 105 | \begin{figure}[!ht] 106 | \centering 107 | \includegraphics[scale=0.9]{Figures/Compressor} 108 | \caption{A natural gas compressor.} 109 | \label{fig:compressor} 110 | \end{figure} 111 | 112 | Moreover, the compressor ratio, $\beta_c$, is defined as below: 113 | 114 | \begin{equation} 115 | \label{eq:comp_ratio} 116 | \beta_c = \frac{\pi_j}{\pi_i}, \quad \beta_c\geq 1. 117 | \vspace{0.3cm} 118 | \end{equation} 119 | 120 | In general, there exist two types of compressors: the power-driven compressors, whose demanded energy is supplied from the power system, and the gas-driven compressors, that require additional gas to operate. In the latter, the additional gas demanded at the suction node, $\phi_c$, can be expressed as a quadratic function of the power as~\cite{Chen2017}: 121 | 122 | \begin{equation} 123 | \label{eq:f_cons_gas_comp} 124 | \phi_c = x+y\psi_c+z\psi_c^2, 125 | \vspace{0.3cm} 126 | \end{equation} 127 | 128 | where $x,y,z \in \Real$. 129 | 130 | Notice that the gas flow through a compressor (as well as the consumed flow for a gas-driven compressor) is a function of the consumed power and the quadratic suction and discharge pressures, that is, $f_{ij}^c=h(\pi_i,\pi_j,\psi_c)$. 131 | 132 | \subsection{Storage Units} 133 | \label{subsec:sto_units} 134 | 135 | The possibility of storing natural gas provides flexibility with regards to production and transportation decisions~\cite{Midthun2007}. A storage unit is a reservoir that allows both storing from and injecting gas to the gas network. Figure \ref{fig:storage} shows a storage unit located at node $i$ with an associated gas flow $f_s$ that could be either an \textit{outflow} in the case of injection to the system or an \textit{inflow} in the case of a storing operation. Then, in a node with a specific demand and injection, the (known) value of $f_s$ could be added to the nodal demand when it is a storage inflow or could be summed to the injection flow of a constant-flow well when it is a storage outflow. 136 | 137 | \begin{figure}[!ht] 138 | \centering 139 | \includegraphics[scale=1]{Figures/Storage_unit} 140 | \caption{A natural gas storage unit.} 141 | \label{fig:storage} 142 | \end{figure} 143 | 144 | \section{Deriving the Natural Gas Flow Problem} 145 | \label{sec:NGF_problem} 146 | 147 | Let us consider the transmission natural gas network shown in Figure \ref{fig:nodal_balance}. According to the principle of conservation of mass, the balance equation applied to the node $i$ states: 148 | 149 | \begin{equation} 150 | \label{eq:balance_eq} 151 | f_{inj} - f_{dem} \pm f_s = \sum_{\substack{j=1 \\ j \neq i}}^{m} f_{ij}, 152 | \end{equation} 153 | 154 | where $f_{dem}$ is the known demand flow, $f_s$ is either the inflow (negative) or outflow (positive) of the storage unit, and $f_{inj}$ is the injected flow of the well. 155 | 156 | \begin{figure}[!ht] 157 | \centering 158 | \includegraphics[scale=0.95]{Figures/Gas_flow_problem} 159 | \caption{Nodal balance in a transmission natural gas network.} 160 | \label{fig:nodal_balance} 161 | \end{figure} 162 | 163 | Notice in equation \ref{eq:balance_eq} that the left hand side is a known value if injection is produced by a constant-flow well. However, for a constant-pressure well, the value of $f_{iny}$ must be determined. In turn, the algebraic sum of the right hand side depends on the nature of the elements connected between nodes $i$ and $j$ such that $f_{ij}$ takes the form of $f_{ij}^o$ or $f_{ij}^c$, according to Equations \ref{eq:Wymouth_eq_2} and \ref{eq:comp_flow}, for a pipeline or a compressor, respectively. Moreover, for a gas-driven compressor, the additional gas consumption $\phi_c$ must be considered as an outflow in Equation \ref{eq:balance_eq} if node $i$ matches the suction node for compressor $c$. 164 | 165 | %such that $f_{ij}$ is $g(\pi_i,\pi_j)$, $h(\pi_i,\pi_j,\psi_c)$, or $h(\pi_i,\pi_j,\psi_c)+\phi_c(\psi_c)$ for a pipeline, a power-driven compressor, and a gas-driven-compressor, respectively. 166 | 167 | As a consequence, we can rewrite the balance equation applied at node $i$ in a functional form as follows: 168 | 169 | \begin{equation} 170 | \label{eq:balance_eq_funtional} 171 | \mathbb{F}_i\left(\pi,\psi_c,f_{iny}^{w}\right) = 0. 172 | \vspace{0.3cm} 173 | \end{equation} 174 | 175 | In practice, for a given gas network with $n_n$ nodes, $n_c$ compressors, and $n_{w_p}$ constant-pressure wells, the application of the balance equation for all nodes will produce a set of $n_n$ nonlinear equations with a number of $(n_n-n_{w_p})+n_c+n_{w_p} = n_n+n_c$ unknown variables. To get a square system with the same number of equations and variables, the $n_c$ missing equations are obtained from the compressor ratios of all compressors. Then, the NGF problem can be formulated as follows: 176 | 177 | \begin{equation} 178 | \label{eq:F_i=0} 179 | \mathbb{F}_i\left(\pi,\psi_c,f_{iny}^{w}\right) = 0, \quad \forall i\in\mathcal{N}, c\in\mathcal{C}; w\in\mathcal{W}_p, 180 | \end{equation} 181 | 182 | \begin{equation} 183 | \label{eq:R_c=0} 184 | \beta_c = \frac{\pi_j}{\pi_i}, \quad \forall c\in\mathcal{C}, \; i,j\in\mathcal{N}, 185 | \vspace{0.3cm} 186 | \end{equation} 187 | 188 | where 189 | 190 | \begin{labeling}{alligator} 191 | \item [$\qquad \qquad \mathcal{N}$] \hspace{0.85cm} Set of gas nodes, $|\mathcal{N}|=n_n$. 192 | \item [$\qquad \qquad \mathcal{C}$] \hspace{1cm} Set of compressors, $|\mathcal{C}|=n_c$. 193 | \item [$\qquad \qquad \mathcal{W}_p$] \hspace{0.65cm} Set of constant-pressure wells, $|\mathcal{W}_p|=n_{w_p}$. 194 | \end{labeling} 195 | 196 | 197 | 198 | -------------------------------------------------------------------------------- /MPNG_User's_Manual/Chapters/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=Esta carpeta se ha compartido online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /MPNG_User's_Manual/Figures/Compressor.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/MPNG_User's_Manual/Figures/Compressor.pdf -------------------------------------------------------------------------------- /MPNG_User's_Manual/Figures/Example1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/MPNG_User's_Manual/Figures/Example1.pdf -------------------------------------------------------------------------------- /MPNG_User's_Manual/Figures/Gas_flow_problem.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/MPNG_User's_Manual/Figures/Gas_flow_problem.pdf -------------------------------------------------------------------------------- /MPNG_User's_Manual/Figures/MPNG_logo.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/MPNG_User's_Manual/Figures/MPNG_logo.pdf -------------------------------------------------------------------------------- /MPNG_User's_Manual/Figures/MPNG_logo_md.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/MPNG_User's_Manual/Figures/MPNG_logo_md.PNG -------------------------------------------------------------------------------- /MPNG_User's_Manual/Figures/NG48.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/MPNG_User's_Manual/Figures/NG48.pdf -------------------------------------------------------------------------------- /MPNG_User's_Manual/Figures/Node.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/MPNG_User's_Manual/Figures/Node.pdf -------------------------------------------------------------------------------- /MPNG_User's_Manual/Figures/Pipeline.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/MPNG_User's_Manual/Figures/Pipeline.pdf -------------------------------------------------------------------------------- /MPNG_User's_Manual/Figures/Storage_unit.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/MPNG_User's_Manual/Figures/Storage_unit.pdf -------------------------------------------------------------------------------- /MPNG_User's_Manual/Figures/Time_resolution.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/MPNG_User's_Manual/Figures/Time_resolution.pdf -------------------------------------------------------------------------------- /MPNG_User's_Manual/Figures/Well.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/MPNG_User's_Manual/Figures/Well.pdf -------------------------------------------------------------------------------- /MPNG_User's_Manual/Figures/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=Esta carpeta se ha compartido online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /MPNG_User's_Manual/Figures/ex2_fgc.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/MPNG_User's_Manual/Figures/ex2_fgc.pdf -------------------------------------------------------------------------------- /MPNG_User's_Manual/Figures/ex2_fgo.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/MPNG_User's_Manual/Figures/ex2_fgo.pdf -------------------------------------------------------------------------------- /MPNG_User's_Manual/Figures/ex2_inj.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/MPNG_User's_Manual/Figures/ex2_inj.pdf -------------------------------------------------------------------------------- /MPNG_User's_Manual/Figures/ex2_pressure-eps-converted-to.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/MPNG_User's_Manual/Figures/ex2_pressure-eps-converted-to.pdf -------------------------------------------------------------------------------- /MPNG_User's_Manual/Figures/ex2_pressure.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/MPNG_User's_Manual/Figures/ex2_pressure.pdf -------------------------------------------------------------------------------- /MPNG_User's_Manual/MPNG_Manual_V0.99a.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/MPNG_User's_Manual/MPNG_Manual_V0.99a.pdf -------------------------------------------------------------------------------- /MPNG_User's_Manual/MPNG_Manual_V0.99a.tex: -------------------------------------------------------------------------------- 1 | \documentclass[12pt,a4paper,oneside]{book} 2 | \usepackage{float} 3 | \usepackage{booktabs} 4 | \usepackage{scrextend} 5 | \usepackage[utf8]{inputenc} 6 | \usepackage{amsmath,amsfonts,amssymb,bm,dsfont} 7 | \usepackage{amsthm} 8 | \usepackage{graphics} 9 | \usepackage{graphicx} 10 | \usepackage[usenames]{color} 11 | \usepackage[usenames,dvipsnames,svgnames,table]{xcolor} 12 | \usepackage{xr-hyper} 13 | \usepackage{geometry} 14 | \usepackage{rotating} 15 | \usepackage{enumerate} 16 | \usepackage{textcomp} 17 | \usepackage{cite} 18 | \usepackage{subcaption} 19 | \usepackage{titlesec} 20 | \usepackage{fancyhdr} 21 | \pagestyle{plain} % Do not print headers 22 | \usepackage{epsfig} 23 | \usepackage[percent]{overpic} 24 | \usepackage{listings} 25 | \usepackage{footmisc} 26 | \usepackage[pdfstartview=FitB,pdfstartpage=1,backref=true]{hyperref} 27 | \hypersetup{ 28 | colorlinks=true, 29 | linkcolor={red}, 30 | citecolor={LimeGreen}, 31 | urlcolor={blue}} 32 | \usepackage{makeidx} 33 | \usepackage[nottoc,notlot,notlof]{tocbibind} 34 | \usepackage{float} 35 | \usepackage{epsfig} 36 | \usepackage[percent]{overpic} 37 | \usepackage{listings} 38 | \usepackage{titlesec} 39 | \usepackage{fancyvrb} 40 | \usepackage{relsize} 41 | \usepackage{textcomp} 42 | \usepackage{threeparttable} 43 | 44 | %%%%%%%%%%%%%%%%%%%%%%%%%%%% Some configurations %%%%%%%%%%%%%%%%%%%%%%%%%%%% 45 | 46 | 47 | 48 | \titleformat{\chapter} % No print chapter headings 49 | {\Large\bfseries} 50 | {} 51 | {0pt} 52 | {\huge} 53 | 54 | % define my verbatim environment, requires packages fancyvrb & relsize 55 | \renewcommand{\FancyVerbFormatLine}[1]{\makebox[2mm][l]{}#1} 56 | \DefineVerbatimEnvironment% 57 | {Code}{Verbatim} 58 | {fontsize=\relsize{-1.5}, 59 | samepage=true, 60 | frame=single} 61 | 62 | \newcommand{\codeq}[1]{\code{\textquotesingle{}#1\textquotesingle}} % requires package textcomp 63 | 64 | % define my verbatim environment, requires packages fancyvrb & relsize 65 | \renewcommand{\FancyVerbFormatLine}[1]{\makebox[2mm][l]{}#1} 66 | \DefineVerbatimEnvironment% 67 | {Notice}{Verbatim} 68 | {fontsize=\relsize{-1.5}, 69 | samepage=true, 70 | xleftmargin=10mm, 71 | framesep=5mm, 72 | frame=single} 73 | 74 | \usepackage{paralist} %for the environment compactitem with less space between items 75 | \let\itemize\compactitem 76 | \let\enditemize\endcompactitem 77 | \let\enumerate\compactenum 78 | \let\endenumerate\endcompactenum 79 | \let\description\compactdesc 80 | \let\enddescription\endcompactdesc 81 | \pltopsep=\medskipamount 82 | \plitemsep=1pt 83 | \plparsep=1pt 84 | 85 | \setkomafont{labelinglabel}{\normalfont}%{\ttfamily} 86 | \setkomafont{labelingseparator}{\normalfont} 87 | \makeatletter 88 | \renewenvironment{labeling}[2][]{% 89 | \def\sc@septext{#1}% 90 | \list{}{\settowidth{\labelwidth}{{% 91 | \usekomafont{labelinglabel}{#2% 92 | \usekomafont{labelingseparator}{\sc@septext}}% 93 | }}% 94 | \leftmargin\labelwidth \advance\leftmargin by \labelsep 95 | \let\makelabel\labelinglabel 96 | \itemsep-4pt% <- Here 97 | }% 98 | }{% 99 | \endlist 100 | } 101 | 102 | 103 | %%%%%%%%%%%%%%%%%%%%%%%%%%%% Some new commands %%%%%%%%%%%%%%%%%%%%%%%%%%%% 104 | 105 | \newcommand{\mpng}[0]{{\tt MPNG}} 106 | \newcommand{\mpgc}[0]{{\tt MPGC}} 107 | \newcommand{\mpngpath}[1]{\textsf{\textsl{{\relsize{-1.0}\textless{}\mbox{MPNG}\textgreater{}}}}\code{{#1}}} 108 | \newcommand{\mpnggitpath}[1]{\textsf{\textsl{{\relsize{-1.0}\textless{}\mbox{\code{E:\textbackslash GITHUB\textbackslash MPNG}}\textgreater{}}}}\code{{#1}}} 109 | \newcommand{\mpngcasepath}[1]{\textsf{\textsl{{\relsize{-1.0}\textless{}\mbox{MPNG/Cases}\textgreater{}}}}\code{{#1}}} 110 | \newcommand{\mpngexamplepath}[1]{\textsf{\textsl{{\relsize{-1.0}\textless{}\mbox{MPNG/Examples}\textgreater{}}}}\code{{#1}}} 111 | \newcommand{\mpngurl}[0]{https://github.com/MATPOWER/mpng.git} 112 | \newcommand{\mpngversion}[0]{0.99a} 113 | \newcommand{\matlab}[0]{{\sc Matlab}} 114 | \newcommand{\matpower}[0]{{\sc Matpower}} 115 | \newcommand{\pserc}[0]{{\sc PSerc}} 116 | \newcommand{\doi}[1]{doi:~\href{https://doi.org/#1}{#1}} 117 | \newcommand{\Real}{\mathbb{R}} 118 | \newcommand{\code}[1]{{\relsize{-0.5}{\tt{{#1}}}}} % requires package relsize 119 | % Note: to get straight single quotes in \code you have to use one of the 120 | % following: \char13 \char'15 \char"0D \textquotesingle 121 | 122 | 123 | %%%%%%%%%%%%%%%%%%%%%%%%%%%% Main document %%%%%%%%%%%%%%%%%%%%%%%%%%%% 124 | 125 | \pagenumbering{roman} 126 | \begin{document} 127 | \include{Chapters/Front_matter} 128 | \addtocontents{toc}{\vspace{-4ex}} 129 | \tableofcontents 130 | \listoffigures 131 | \listoftables 132 | \include{Chapters/Introduction} 133 | \include{Chapters/Getting_started} 134 | \include{Chapters/Natural_Gas_Flow} 135 | \include{Chapters/Formulation} 136 | \include{Chapters/Examples} 137 | \include{Chapters/Acknowledgements} 138 | \part*{Appendix} 139 | \include{Chapters/Appendixes} 140 | 141 | \clearpage 142 | \begin{thebibliography}{99} 143 | \bibitem{zimmerman2011} 144 | R.~D. Zimmerman, C.~E. Murillo-S{\'a}nchez, and R.~J. Thomas, ``\matpower{}: Steady-State Operations, Planning and Analysis Tools for Power Systems Research and Education,'' \emph{Power Systems, IEEE Transactions on}, vol.~26, no.~1, pp.~12--19, Feb.~2011. 145 | \doi{10.1109/TPWRS.2010.2051168} 146 | 147 | \bibitem{matpower} 148 | R.~D. Zimmerman, C.~E. Murillo-S{\'a}nchez (2019). \matpower{}\\~ 149 | [Software]. Available: \url{https://matpower.org}\\ 150 | \doi{10.5281/zenodo.3236535} 151 | 152 | \bibitem{bsd} 153 | The BSD 3-Clause License. [Online]. Available: \url{https://opensource.org/licenses/BSD-3-Clause}. 154 | 155 | \bibitem{mpng2019} 156 | S.~García-Marín, W.~González-Vanegas, and C.~E. Murillo-Sánchez, ``MPNG:\matpower{}-Natural Gas,'' 2019. 157 | [Online]. Available: \url{\mpngurl} 158 | 159 | \bibitem{matpower_manual} 160 | \matpower{} User's Manual. [Online]. Available: \url{https://matpower.org/doc/manuals/}. 161 | 162 | \bibitem{Woldeyohannes2011} 163 | Abraham~Debebe Woldeyohannes and Mohd Amin~Abd Majid. 164 | \newblock Simulation model for natural gas transmission pipeline network 165 | system. 166 | \newblock {\em Simulation Modelling Practice and Theory}, 19(1):196--212, 2011.\\ 167 | \doi{10.1016/j.simpat.2010.06.006} 168 | 169 | \bibitem{Osiadacz2001} 170 | Andrzej~J. Osiadacz and Maciej Chaczykowski. 171 | \newblock Comparison of isothermal and non-isothermal pipeline gas flow models. 172 | \newblock {\em Chemical Engineering Journal}, 81(1):41 -- 51, 2001.\\ 173 | \doi{10.1016/S1385-8947(00)00194-7} 174 | 175 | \bibitem{Banda2006} 176 | Mapundi~K. Banda, Michael Herty, Axel Klar. 177 | \newblock Gas flow in pipeline networks. 178 | \newblock {\em Networks \& Heterogeneous Media}, 1(1): 41 -- 56, 2006.\\ 179 | \doi{10.3934/nhm.2006.1.41} 180 | 181 | \bibitem{Wolf2000} 182 | Daniel de Wolf and Yves Smeers. 183 | \newblock The Gas Transmission Problem Solved by an Extension of the Simplex Algorithm. 184 | \newblock {\em Management Science}, 59(1): 1454 -- 1465, 2000.\\ 185 | \doi{10.1287/mnsc.46.11.1454.12087} 186 | 187 | \bibitem{Shabanpour2016} 188 | Amin Shabanpour-Haghighi and Ali Reza Seifi. 189 | \newblock Effects of district heating networks on optimal energy flow of multi-carrier systems. 190 | \newblock {\em Renewable and Sustainable Energy Reviews}, 46(11): 379 -- 387, 2016.\\ 191 | \doi{10.1016/j.rser.2015.12.349} 192 | 193 | \bibitem{Chen2017} 194 | S. Cheng, Z. Wei, G. Sun, K.W. Cheung, Y. Sun. 195 | \newblock Multi-Linear Probabilistic Energy Flow Analysis of Integrated Electrical and Natural-Gas Systems. 196 | \newblock {\em IEEE Transactions on Power Systems}, 32(3): 1970 -- 1979, 2017.\\ 197 | \doi{10.1109/TPWRS.2016.2597162} 198 | 199 | \bibitem{Midthun2007} 200 | K. T. Midhunt. 201 | \newblock Optimization models for liberalized natural gas markets. 202 | \newblock {\em Norwegian University of Science and Technology, Faculty of Social Science and Technology Management, Department of Sociology and Political Science}, 2007. 203 | 204 | \bibitem{Cui2016} 205 | H. Cui., F. Li., Q. Hu., L. Bai., and X. Fang. 206 | \newblock Day-ahead coordinated operation of utility-scale electricity and natural gas networks considering demand response based virtual power plants. 207 | \newblock {\em Applied Energy}, 176: 183 -- 195, 2016.\\ 208 | \doi{10.1016/j.apenergy.2016.05.007} 209 | 210 | \end{thebibliography} 211 | \end{document} -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![GitHub Logo](/MPNG_User's_Manual/Figures/MPNG_logo_md.PNG) 2 | 3 | # An open-source simulation package for solving Optimal Power and Natural Gas Flow problems 4 | 5 | ----------------------------------------------------------------------------------- 6 | 7 | MPNG is a [MATPOWER][1]-based package for solving optimal power and natural gas flow 8 | problems. MPNG uses the general user nonlinear constraints capability of MATPOWER to 9 | model the gas network taking into account gas-fired power generators, storage units, 10 | wells, power-and-gas-driven compressors, and nodes with stratified demand 11 | (different market segments get different priorities). 12 | 13 | 14 | System Requirements 15 | ------------------- 16 | * [MATLAB][2] version 7.3 (R2016b) or later. 17 | * [MATPOWER][3] version 7.0 or later. 18 | 19 | 20 | Installation 21 | ------------ 22 | Installation and use of MPNG requires familiarity with basic operations of MATLAB and 23 | MATPOWER. It is assumed that the user has installed a functional and operating MATPOWER 24 | version. In short, installing MPNG is as simple as adding all the distribution files 25 | to the MATLAB's path. The user could either proceed manually with such an addition, 26 | or run the quick installer released with the package by opening MATLAB at the 27 | `` directory and typing: 28 | 29 | install_mpng 30 | 31 | 32 | Citing MPNG 33 | ----------- 34 | We do request that publications derived from the use of MPNG explicitly acknowledge 35 | that fact by including the following cites: 36 | 37 | > S. García-Marín, W. González-Vanegas and C. E. Murillo-Sánchez, "MPNG: A MATPOWER-Based Tool for Optimal Power and 38 | Natural Gas Flow Analyses," in IEEE Transactions on Power Systems, 2022, doi: [10.1109/TPWRS.2022.3195684][5] 39 | 40 | > S.García-Marín, W.González-Vanegas, and C.E. Murillo-Sánchez, "MPNG: MATPOWER-Natural Gas," 41 | 2019. [Online]. Available: [https://github.com/MATPOWER/mpng][4] 42 | 43 | 44 | 45 | ---- 46 | [1]: https://matpower.org 47 | [2]: https://www.mathworks.com/ 48 | [3]: https://github.com/MATPOWER/matpower 49 | [4]: https://github.com/MATPOWER/mpng 50 | [5]: https://doi.org/10.1109/TPWRS.2022.3195684 51 | -------------------------------------------------------------------------------- /install_mpng.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MATPOWER/mpng/70d98d112117c9af07e81adf16c34b8314a6ab6c/install_mpng.m --------------------------------------------------------------------------------