{"id":13708882,"url":"https://github.com/mpimd-csc/morgen","last_synced_at":"2026-03-17T11:03:28.395Z","repository":{"id":56083225,"uuid":"315621916","full_name":"mpimd-csc/morgen","owner":"mpimd-csc","description":"morgen - Model Order Reduction for Gas and Energy Networks","archived":false,"fork":false,"pushed_at":"2023-05-31T18:53:00.000Z","size":8030,"stargazers_count":18,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-03-13T15:27:40.320Z","etag":null,"topics":["digital-twin","dimensionality-reduction","euler-equations","gas-dynamics","gas-flow","gas-network","gas-network-simulation","gas-transport","gasmor","matlab","model-order-reduction","model-reduction","morgen","natural-gas","octave"],"latest_commit_sha":null,"homepage":"https://git.io/morgen","language":"MATLAB","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mpimd-csc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS"}},"created_at":"2020-11-24T12:14:31.000Z","updated_at":"2025-11-12T10:37:44.000Z","dependencies_parsed_at":"2024-01-07T00:08:24.522Z","dependency_job_id":null,"html_url":"https://github.com/mpimd-csc/morgen","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/mpimd-csc/morgen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpimd-csc%2Fmorgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpimd-csc%2Fmorgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpimd-csc%2Fmorgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpimd-csc%2Fmorgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mpimd-csc","download_url":"https://codeload.github.com/mpimd-csc/morgen/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpimd-csc%2Fmorgen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30622422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T08:10:05.930Z","status":"ssl_error","status_checked_at":"2026-03-17T08:10:04.972Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["digital-twin","dimensionality-reduction","euler-equations","gas-dynamics","gas-flow","gas-network","gas-network-simulation","gas-transport","gasmor","matlab","model-order-reduction","model-reduction","morgen","natural-gas","octave"],"created_at":"2024-08-02T23:00:33.744Z","updated_at":"2026-03-17T11:03:28.366Z","avatar_url":"https://github.com/mpimd-csc.png","language":"MATLAB","funding_links":[],"categories":["Model Reduction"],"sub_categories":[],"readme":"![morgen logo](morgen.png) morgen - Model Order Reduction for Gas and Energy Networks (1.2)\n===========================================================================================\n\n**morgen** is an open-source MATLAB and OCTAVE test platform to compare models,\nsolvers, and model reduction methods (reductors) for gas networks and other\nenergy network systems that are based on the (isothermal) Euler equations.\n\n## Version\n\nCurrent Version: [morgen 1.2](https://doi.org/10.5281/zenodo.7157808) (2022-10-07)\n\n## Compatibility\n\n* Mathworks [MATLAB](https://www.mathworks.com/products/matlab.html) \u003e= 2020b\n* GNU [Octave](https://octave.org) \u003e= 6.1\n\n## Dependencies\n\n* [emgr](https://gramian.de) == 5.99 (included, see `reductors/private`)\n\n## License\n\n**morgen** is licensed under the [BSD-2-Clause](https://opensource.org/licenses/BSD-2-Clause) license,\nwith copyright (c) 2020--2022: _Christian Himpe_, _Sara Grundel_; see [LICENSE](LICENSE).\n\n## Disclaimer\n\n**morgen** is research software.\n\n## Citation\n\nPlease cite the **morgen** platform via its companion paper:\n\nC. Himpe, S. Grundel, P. Benner:\n**Model Order Reduction for Gas and Energy Networks**;\nJournal of Mathematics in Industry 11: 13, 2021.\n[doi:10.1186/s13362-021-00109-4](https://doi.org/10.1186/s13362-021-00109-4)\n\nYou can link to **morgen** via: [git.io/morgen](https://git.io/morgen)\n\n## Getting Started\n\nTo setup simulation and reduction tests and demos:\n\n```\n\u003e SETUP % adds the \"tests\" folder to the path and lists scripts\n```\n\nTests can then be called directly as listed. To try **morgen**:\n\n```\n\u003e DEMO  % runs a sample pipeline model reduction code\n```\n\n### Reproducibility\n\nTo reproduce the experiments from the companion paper,\n**Model Order Reduction for Gas and Energy Networks**, run:\n\n```\n\u003e RUNME_HimpeGB21\n```\n\nTo reproduce the experiments from the first add-on paper,\n**Next-Gen Gas Network Simulation**, run:\n\n```\n\u003e RUNME_HimpeGB22\n```\n\nTo reproduce the experiments from the second add-on paper,\n**System Order Reduction for Gas and Energy Networks**, run:\n\n```\n\u003e RUNME_HimpeG22\n```\n\n### Extending **morgen**\n\n**morgen**'s modules can be easily extended in the following ways:\n\n* to add a new model, see and modify: `models/template_model.m`\n* to add a new solver, see and modify: `solvers/template_solver.m`\n* to add a new reductor, see and modify: `reductors/template_reductor.m`\n* to add a new network, see and modify: `networks/template_network.net`\n* to add a new scenario, see and modify: `networks/template_network/training.ini`\n* to add a new simulation test, see and modify: `tests/sim_template.m`\n* to add a new reduction test, see and modify: `tests/mor_template.m`\n\n## Usage\n\n### Main Function\n\n\u003cdetails\u003e\u003csummary markdown=\"span\"\u003e(click to expand)\u003c/summary\u003e\n\nThe **morgen** platform is called via the `morgen.m` function:\n\n```\nR = morgen(network_id,scenario_id,model_id,solver_id,reductor_ids,varargin)\n```\n\nand has four mandatory arguments:\n\n* `network_id`   (**string**) The network identifier\n* `scenario_id`  (**string**) The scenario identifier\n* `model_id`     (**string**) The model identifier\n* `solver_id`    (**string**) The solver identifier\n\nas well as an optional argument and an additional variable length argument list:\n\n* `reductor_ids` (**cell**) An array of reductor identifiers (can be empty, too)\n* `varargin`     Variable argument list each containing a string (see below)\n\nAll admissible additional (**string**) arguments are described below:\n\n* `dt=X`    - Override time step in configuration with X (in seconds)\n* `tf=X`    - Override tunable efficiency factor in configuration with X (positive real)\n* `ys=X`    - Force minimum y-scale for error plots with 10^X (default: -16)\n* `ord=X`   - Override maximum reduced order in configuration with X (natural number)\n* `pid=X`   - Add custom string identifier to plot files (default: '')\n* `notest`  - Do not test the reduced order models\n* `compact` - Display plots all in one figure\n\nThe `morgen.m` function returns a structure `R` with members depending on the arguments.\nIf only reduced order models are computed:\n\n* `.reductors` (**cell**) Array of strings with names of the reductors\n* `.offline`   (**cell**) Array of offline times for the reductors\n\nIf reduced order models are computed and tested:\n\n* `.name`      (**string**) Output name of the experiment (as used by saved plots and scores)\n* `.reductors` (**cell**) Array of strings with names of the reductors\n* `.orders`    (**vector**) The tested reduced orders\n* `.l0error` , `.l1error` , `.l2error` , `.l8error` (**cell**) Arrays of per reduced order average errors\n* `.l0score` , `.l1score` , `.l2score` , `.l8score` (**cell**) Arrays of per reduced order average [MORscore](https://doi.org/10.1007/978-3-030-72983-7_7)s\n* `.offline`   (**cell**) Array of offline times for the reductors\n* `.online`    (**cell**) Array of average relative online times for the reductors\n* `.breven`    (**cell**) Array of average relative offline/online break even numbers\n\nIf only a simulation is run, `R` is a matrix,\nand contains the discrete output trajectory with dimensions outputs-times-time-steps.\n\n\u003c/details\u003e\n\n### Network\n\n\u003cdetails\u003e\u003csummary markdown=\"span\"\u003e(click to expand)\u003c/summary\u003e\n\nA network is described by a (directed) graph, given through an edgelist,\nwhich also specifies its edge type, and their physical dimensions and properties.\n\n#### Network Topology Rules\n\n* A network must have at least one supply node!\n* All boundary nodes (supply or demand) must connect by exactly one edge!\n  * Short pipes can be inserted to enforce this.\n* The edge from a supply node must be directed away from it!\n  * Hence, no two supply nodes can be directly connected.\n* The edge to a demand node must be directed toward it!\n  * Hence, no two demand nodes can be directly connected.\n\n#### Available Networks\n\nAll available network datasets are listed with the network's number of\n\n* internal junction nodes (`n0`),\n* supply boundary nodes (`nS`), and\n* demand boundary nodes (`nD`).\n\n##### Test Networks\n\n* `diamond`  - Diamond Network     (`n0=8, nS=1, nD=1, nC=0`)\n* `fork1`    - Forked Pipeline     (`n0=12, nS=1, nD=2, nC=0`)\n* `fork2`    - Forked Pipeline     (`n0=12, nS=2, nD=1, nC=0`)\n* `comptest` - Compressor Test     (`n0=1, nS=1, nD=1, nC=1`)\n* `paratest` - Parallel Pipes Test (`n0=2, nS=1, nD=1, nC=0`)\n* `PamDB16`  - Triangle Network    (`n0=0, nS=1, nD=2, nC=0`)\n\n##### Synthetic Networks\n\n* `MORGEN`      - Small Network  (`n0=27, nS=2, nD=4, nC=1`)\n* `AzeJ07`      - Small Network  (`n0=5, nS=1, nD=2, nC=1`)\n* `GruHKetal13` - Small Network  (`n0=11, nS=1, nD=8, nC=0`)\n* `Kiu94`       - Small Network  (`n0=8, nS=1, nD=14, nC=0`)\n* `GruJHetal14` - Medium Network (`n0=45, nS=4, nD=2, nC=0`)\n* `GasLib11`    - Medium Network (`n0=6, nS=3, nD=3, nC=2`)\n* `GasLib24`    - Medium Network (`n0=14, nS=3, nD=5, nC=3`)\n* `GasLib40`    - Medium Network (`n0=40, nS=3, nD=29, nC=6`)\n* `GasLib135`   - Medium Network (`n0=135, nS=3, nD=45, nC=29`)\n* `PelLL17a`    - Medium Network (`n0=41, nS=1, nD=15, nC=5`)\n\n##### Pipelines\n\n* `pipeline` - Pipeline (`n0=0, nS=1, nD=1, nC=0`)\n* `Cha09`    - Pipeline (`n0=0, nS=1, nD=1, nC=0`)\n* `RodS18`   - Tree     (`n0=6, nS=1, nD=4, nC=0`)\n* `Guy67`    - Tree     (`n0=8, nS=1, nD=8, nC=0`)\n* `LotH67a`  - Pipeline (`n0=0, nS=1, nD=1, nC=0`)\n* `LotH67b`  - Pipeline (`n0=0, nS=1, nD=1, nC=0`)\n* `LotH67c`  - Tree     (`n0=6, nS=2, nD=2, nC=2`)\n* `LotH67d`  - Tree     (`n0=4, nS=2, nD=2, nC=1`)\n\n##### Realistic Networks\n\n* `AzePA19`     - Portugal (`n0=0, nS=1, nD=1, nC=0`)\n* `BerS19`      - Spain    (`n0=6, nS=1, nD=5, nC=0`)\n* `DeWS00`      - Belgium  (`n0=20, nS=6, nD=9, nC=0`)\n* `EkhDLetal19` - Ireland  (`n0=26, nS=3, nD=10, nC=0`)\n* `GasLib134`   - Greece   (`n0=134, nS=3, nD=45, nC=1`)\n* `GasLib582`   - Germany  (`n0=582, nS=31, nD=129, nC=5`)\n* `GasLib4197`  - Germany  (`n0=4197, nS=11, nD=1009, nC=12`)\n* `SciGrid_NO`  - Norway   (`n0=44, nS=11, nD=9, nC=0`)\n* `JinW`        - China    (`n0=45, nS=5, nD=3, nC=38`)\n\n#### Data Origin\n\nThe GasLib network data-sets are derived from:\n\nM. Schmidt, D. Aßmann, R. Burlacu, J. Humpola, I. Joormann, N. Kanelakis,\nT. Koch, D. Oucherif, M.E. Pfetsch, L. Schewe, R. Schwarz, M. Sirvent:\n**GasLib - A Library of Gas Network Instances**;\nData 2(4): 40, 2017.\n\nand licensed under **CC-BY 3.0**, see: https://gaslib.zib.de\n\nThe SciGrid network data-sets are derived from:\n\nJ. Dasenbrock, J. Diettrich, A. Pluta, W. Medjroubi:\n**SciGRID_gas NO_Raw**;\nZenodo: 10.5281/zenodo.3985268, 2020.\n\nand licensed under **CC-BY 4.0**, see: https://www.gas.scigrid.de\n\n#### File Format\n\nA network is encoded in a [CSV](https://en.wikipedia.org/wiki/Comma-separated_values)\nfile with the file extension `.net`. The first line is a comment header with a\ndescription of the columns, their meaning, and units.\n```\n# type, identifier-in, identifier-out, pipe-length [m], pipe diameter [m], height difference [m], pipe roughness [m]\n```\nEach line below the first holds one edge definition with the columns:\n\n* Edge type (`P`:pipe, `S`:shortpipe, `C`:compressor, `V`:valve)\n* Start node identifier (positive integer)\n* End node identifier (positive integer)\n* Pipe length [`m`] (positive real)\n* Pipe diameter [`m`] (positive real)\n* Pipe height difference [`m`] (positive real)\n* Pipe roughness [`m`] (positive real)\n\nThus, the gas network's directed graph is represented as an edge list,\nwhereas the edge directions are not corresponding to flow directions except for boundary nodes.\nNote, currently only positive integers can be used as start and end identifiers.\n\n#### Parsed Network Structure\n\nA parsed network `.net` file is given as a `network` structure with members:\n\n* `network`        (**struct**)\n  * `.length`      (**vector**) Pipe lengths\n  * `.incline`     (**vector**) Pipe inclines\n  * `.diameter`    (**vector**) Pipe diameters\n  * `.roughness`   (**vector**) Pipe roughnesses\n  * `.nomLen`      (**vector**) Per pipe length\n  * `.A0`          (**matrix**) Incidence matrix reduced by supply nodes\n  * `.Ac`          (**matrix**) Incidence matrix of only compressor outlet nodes \n  * `.Bs`          (**matrix**) Incidence matrix of supply nodes\n  * `.Bd`          (**matrix**) Incidence matrix of demand nodes\n  * `.Fc`          (**vector**) Load vector of compressors\n  * `.nEdges`      (**scalar**) Number of edges\n  * `.nSupply`     (**scalar**) Number of supply nodes\n  * `.nDemand`     (**scalar**) Number of demand nodes\n  * `.nInternal`   (**scalar**) Number of internal nodes\n  * `.nCompressor` (**scalar**) Number of compressors\n\n\u003c/details\u003e\n\n### Scenario\n\n\u003cdetails\u003e\u003csummary markdown=\"span\"\u003e(click to expand)\u003c/summary\u003e\n\nA scenario data set describes the boundary values and external inhomogeneities of the gas net.\nTransient behaviour of supply and demand functions is represented as step functions in compressed form by only marking changes.\nEach network has a training scenario (`training.ini`), which has constant boundary values for reduced order model assembly.\n\n#### File Format\n\nA scenario is encoded in an [INI](https://en.wikipedia.org/wiki/INI_file) file,\nwith the extension `.ini`. Each line holds a key-value pair, for the following keys:\n\n* `T0` - Average ambient temperature [`C`]\n* `Rs` - Average specific gas constant [`J/(kg*K)`]\n* `tH` - Time horizon [`s`]\n* `vs` - Valve setting [`1`] (pipe separated list of {0,1}) {UNDER CONSTRUCTION, currently treated as short pipe}\n* `cp` - Compressor (output) pressure [`bar`] (pipe separated list)\n* `up` - Supply pressure changes [`bar`] (pipe separated list of semi-colon separated series)\n* `uq` - Demand flow changes [`kg/s`] (pipe separated list of semi-colon separated series)\n* `ut` - Time markers for changes in `up` and `uq` [s]\n\n#### Parsed Scenario Structure\n\nA parsed network `.ini` file is given as:\n\n* `scenario` (**struct**)\n  * `.T0`    (**scalar**) Global mean temperature\n  * `.Rs`    (**scalar**) Global mean specific gas constant\n  * `.tH`    (**scalar**) Time horizon\n  * `.us`    (**vector**) Steady-state input\n  * `.ut`    (**handle**) Function handle with signature u_t = ut(t)\n  * `.cp`    (**vector**) Compressor outlet pressures\n\n\u003c/details\u003e\n\n### Model\n\n\u003cdetails\u003e\u003csummary markdown=\"span\"\u003e(click to expand)\u003c/summary\u003e\n\nA model encodes a spatially discrete input-output system of the form:\n\n```\nE(p) x'(t) = A x(t) + B u(t) + F c_p + f(x(t),u(t),p)\n\n      y(t) = C x(t)\n```\n\nwhich consists of an implicit nonlinear ordinary differential equation,\nand an (uni-directionally coupled algebraic) output equation.\n\n#### Interface\n\n`discrete = model(network,config)`\n\n#### Arguments\n\n* `network`   (**struct**) Parsed network structure\n* `config`    (**struct**) Configuration structure\n\n#### Returns\n\n* `discrete`  (**struct**) (Semi-)Discrete model structure\n  * `.nP`     (**scalar**) Number of pressure states\n  * `.nQ`     (**scalar**) Number of mass-flux states\n  * `.nPorts` (**scalar**) Number of ports\n  * `.E`      (**handle**) Mass matrix function handle `E_rtz = E(rtz)`\n  * `.A`      (**matrix**) System matrix\n  * `.B`      (**matrix**) Input matrix (models boundary nodes)\n  * `.F`      (**matrix**) Source matrix (models the compressor action)\n  * `.C`      (**matrix**) Output matrix (sensors at boundary nodes)\n  * `.f`      (**handle**) Nonlinear vector field `x = f(xs,x,us,u,rtz)`\n  * `.J`      (**handle**) Jacobian `x = J(xs,x,u,rtz)`\n  * `.dual`    (**bool**)  This is only a member (of any value) if it is a dual model!\n\n#### Available Models\n\n* `ode_mid` - ODE model using the mid-point discretization\n* `ode_end` - ODE model using the end-point discretization (port-Hamiltonian)\n\n#### Notes\n\n* The argument `xs` is the steady state computed in the solver (wrapper).\n* The argument `x` in nonlinearity `f` and Jacobian `J` refers to the difference to the steady-state.\n  This means `xs + x` yields the actual state.\n* Only the components `E`, `f` and `J` are parametrized.\n  Particularly, `A` and `B` do not depend on the parameter.\n* Compressors can only be operated in discharge pressure control mode.\n* The argument `rtz` is the product `Rs*T0*z0` formed in the solver.\n\n\u003c/details\u003e\n\n### Solver\n\n\u003cdetails\u003e\u003csummary markdown=\"span\"\u003e(click to expand)\u003c/summary\u003e\n\nA solver is a time stepper that simulates a trajectory of a model and a scenario.\nThe prerequisite steady-state initial value is computed from the scenario's boundary values.\n\n#### Interface\n\n`solution = solver(discrete,scenario,config)`\n\n#### Arguments\n\n* `discrete` (**struct**) Discrete model structure\n* `scenario` (**struct**) Scenario structure\n* `config`   (**struct**) Configuration structure\n\n#### Returns\n\n* `solution`       (**struct**)\n  * `t`            (**vector**) Time-steps vector\n  * `u`            (**matrix**) Discrete inputs-times-steps trajectory\n  * `y`            (**matrix**) Discrete outputs-times-steps trajectory\n  * `steady_z0`    (**scalar**) Global average compressibility\n  * `steady_error` (**scalar**) Steady-state error\n  * `steady_iter1` (**scalar**) Algebraic steady-state iterations\n  * `steady_iter2` (**scalar**) Differential steady-state iterations\n  * `runtime`      (**scalar**) Transient solver runtime\n\n#### Available Solvers\n\n* `imex1`      - First-order implicit-explicit solver\n* `imex2`      - Second-order implicit-explicit Runge-Kutta solver\n* `cnab2`      - Second-order Crank-Nicolson-Adams-Bashforth solver\n* `rk4`        - Fourth-order \"classic\" explicit Runge-Kutta solver (unstable, use only for testing)\n* `rk2hyp`     - Second-order explicit Runge-Kutta solver (increased hyperbolic stability)\n* `rk4hyp`     - Fourth-order explicit Runge-Kutta solver (increased hyperbolic stability)\n* `generic`    - Second-order implicit adaptive `ode23s` Rosenbrock solver\n\n* `linear_export` - Linearize and export state-space model (wraps `imex1` solver)\n\n#### Model Export\n\nThe `linear_export` \"solver\" is not an actual solver,\nbut exports a linearization with fixed parametrization:\n```\nE x'(t) = A x(t) + B u(t) + F,\n\n   y(t) = C x(t),\n```\nof the selected network-scenario as a `(E,A,B,C,F)` state-space model, with\nthe load vector `F` jointly describing the compressors, steady-state, and\nsteady-state effects:\n```\nF := F * c_p + A * xs + B * us.\n```\nThese sparse system matrices are stored in a `.mat` file and named\n`network_id--scenario_id--IySxOy.mat`, where `y` is the number of boundary ports\n(inputs and outputs), and `x` is the discretized state-space dimension.\n\n* Internally, `linear_export` calls the `imex1` solver to return a solution.\n\n* For the `linear_export` \"solver\", the `model_gravity` configuration should be\n  set to `none`.\n\n* To obtain a `(E,A,B,C)` system, the load vector `F` can be concatenated to the\n  input matrix `B`, i.e.: `B' := [B, F]`, incrementing the number of inputs.\n\n\u003c/details\u003e\n\n### Reductors\n\n\u003cdetails\u003e\u003csummary markdown=\"span\"\u003e(click to expand)\u003c/summary\u003e\n\nA reductor computes a reduced order discrete model, aiming to approximate the\ninput-output (boundary-quantity-of-interest) behavior.\n\n#### Interface\n\n`[proj,name] = reductor(solver,discrete,scenario,config)`\n\n#### Arguments\n\n* `solver`   (**handle**) Solver procedure handle\n* `discrete` (**struct**) Discrete model structure\n* `scenario` (**struct**) Scenario structure\n* `config`   (**struct**) Configuration structure\n\n#### Returns\n\n* `proj`  (**cell**)  Array of projectors `{LP,RP;LQ,RQ}` (Bi-Orthogonal / Oblique) or `{LP;LQ}` (Orthogonal)\n* `name` (**string**) Detailed name of reductor\n\n#### Available Reductors\n\nThese structured reductors approximate pressure and mass-flux components\nseparately (\"Structured\" is abbreviated as \"Struct.\"):\n\n* `pod_r`                 _Struct. Proper Orthogonal Decomposition_\n* `eds_ro` / `eds_ro_l`   _Struct. Empirical Dominant Subspaces_\n* `eds_wx` / `eds_wx_l`   _Struct. Empirical Cross-Gramian-Based Dominant Subspaces_\n* `eds_wz` / `eds_wz_l`   _Struct. Empirical Non-Symmetric-Cross-Gramian-Based Dominant Subspaces_\n* `mpod_ro` / `mpod_ro_l` _Struct. Modified Proper Orthogonal Decomposition_\n* `mpod_wx` / `mpod_wx_l` _Struct. Modified Proper Orthogonal Decomposition_\n* `mpod_wz` / `mpod_wz_l` _Struct. Modified Proper Orthogonal Decomposition_\n* `bpod_ro` / `bpod_ro_l` _Struct. Empirical Balanced Proper Orthogonal Decomposition_\n* `ebt_ro` / `ebt_ro_l`   _Struct. Empirical Balanced Truncation_\n* `ebt_wx` / `ebt_wx_l`   _Struct. Empirical Cross-Gramian-Based Balanced Truncation_\n* `ebt_wz` / `ebt_wz_l`   _Struct. Empirical Non-Symmetric-Cross-Gramian-Based Balanced Truncation_\n* `gopod_r`               _Struct. Goal-Oriented Proper Orthogonal Decomposition_\n* `ebg_ro` / `ebg_ro_l`   _Struct. Empirical Balanced Gains_\n* `ebg_wx` / `ebg_wx_l`   _Struct. Empirical Cross-Gramian-Based Balanced Gains_\n* `ebg_wz`  /`ebg_wz_l`   _Struct. Empirical Non-Symmetric-Cross-Gramian-Based Balanced Gains_\n* `dmd_r`                 _Struct. Dynamic Mode Decomposition Galerkin_\n\nAll reductors utilizing observability information are available in two variants.\nBy default the nonlinear variant (no suffix) is used. The `_l` suffix signifies\na \"linear\" variant of the reductor, which assumes a dual system is available.\nWhile either method can be applied to both, `ode_mid` and `ode_end`, models,\ntheory suggest to use the linear variant only with the port-Hamiltonian `ode_end`.\n\n\u003c/details\u003e\n\n### Tests\n\n\u003cdetails\u003e\u003csummary markdown=\"span\"\u003e(click to expand)\u003c/summary\u003e\n\nA test defines an experiment, which is implemented as a script whose filename\nconsists of a prefix and the tested network's name. Two types of experiments are\ncurrently implemented:\n\n* A simulation experiment is prefixed with `sim_` and executes the `morgen.m`\n  function for combinations of models and solvers against a fixed network and\n  scenario.\n\n* A model order reduction experiment is prefixed with `mor_` and executes the\n  `morgen.m` function for combinations of models, solvers and reductors against\n  a network and scenario while using the `training.ini` scenario for computing\n  the reduced order model.\n\nNote that tests can only be called from the **morgen** base directory,\nafter running the `SETUP` script, or manually adding the `tests` folder to the path:\n```\naddpath('tests');\n```\n\n#### Available Tests\n\nThe available experiments are listed by running the `SETUP` script,\nwhich lists the contents of the `tests` folder.\n\n#### Reduced Order Models\n\nReduced order models are saved in the `z_roms` folder (or the folder specified\nby the `morgen_roms` configuration entry).\n\nA reduced order model is saved by storing the projectors and encoding the\nassociated: network, model, and reductor in the filename as follows:\n\n`network--model--reductor--pid.rom`\n\nwith `pid` being custom identifier configurable via optional arguments.\n\nTo load a reduced order model provide a filename of a saved reduced order model\ninstead of the reductor identifier.\n\n#### Results \n\nPlots and MORscores computed by `morgen.m` are stored in the `z_plots` folder\n(or the folder specified by the `morgen_plots` configuration entry).\n\n#### MORscore\n\nThe [MORscore](https://doi.org/10.1007/978-3-030-72983-7_7) is a benchmark index\nmeasuring the area above the model reduction error graph, which is also plotted.\nThis score jointly assesses the model reduction goals of minimum size and maximum accuracy.\nUnstable reduced order models are counted as evaluated with relative error of `1.0`.\n\n\u003c/details\u003e\n\n## Configuration\n\n\u003cdetails\u003e\u003csummary markdown=\"span\"\u003e(click to expand)\u003c/summary\u003e\n\nThe **morgen** platform assumes a configuration [INI](https://en.wikipedia.org/wiki/INI_file)-file\nin the base folder named `morgen.ini`, if not found hard-coded default values\nare used.\n\n* `morgen_plots` (**String**) Folder to store plots, default: `z_plots`\n* `morgen_roms`  (**String**) Folder to store reduced order models, defaut: `z_roms`\n\n* `network_dt`   (**Positive float**) Requested time step width in seconds, default: `60.0`\n* `network_vmax` (**Positive float**) Maximum velocity of gas in meters per second, default: `20.0`\n* `network_cfl`  (**Positive float**) Target CFL constant of spatial discretization, default: `0.5`\n\n* `model_tuning`          (**Positive float**) Tunable efficiency factor scaling the friction term, default: `1.0`\n* `model_reynolds`        (**Positive float**) Estimated Reynolds number, default: `1000000.0`\n* `model_friction`        (**String**) Friction factor model, select from `hofer`, `nikuradse`, `altshul`, `schifrinson`, `pmt1025`, `igt`, default: `schifrinson`\n* `model_compressibility` (**String**) Compressibility factor model, select from: `ideal`, `dvgw`, `aga88`, `papay`, default: `aga88`\n* `model_compref`         (**String**) Reference for compressibility: `steady`, `normal`, default: `steady`\n* `model_gravity`         (**String**) Gravity computation: `none`, `static`, `dynamic`, default: `static`\n\n* `steady_maxiter_lin` (**Positive Integer**) Number of least-norm iterations to refine steady-state estimation, default: `20`\n* `steady_maxiter_non` (**Positive Integer**) Number of time-step iterations to refine steady-state estimation, default: `1000`\n* `steady_maxerror`    (**Positive Float**) Maximal error of refined steady-state, default: `1e-6`\n* `steady_Tc`          (**Float**) Critical temperature in Celsius, default: `-82.595`\n* `steady_pc`          (**Float**) Critical pressure in Bar, default: `45.988`\n* `steady_pn`          (**Float**) Normal pressure in Bar, default: `1.01325`\n\n* `solver_relax`   (**Float in (0,1]**) IMEX solver relaxation, default: `1.0`\n* `solver_rk2type` (**Positive Integer**) Number of 2nd order hyperbolic Runge-Kutta stages `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`, default: `11`\n* `solver_rk4type` (**String**) 4th order hyperbolic Runge-Kutta type `MeaR99a`, `MeaR99b`, `TseS05`, default: `MeaR99a`\n\n* `T0_min` (**Float**) Minimum ambient temperature in Celsius, default: `0.0`\n* `T0_max` (**Float**) Maximum ambient temperature in Celsius, default: `20.0`\n* `Rs_min` (**Float**) Minimum specific gas constant in [J/(kg*K)], default: `500.0`\n* `Rs_max` (**Float**) Maximum specific gas constant in [J/(kg*K)], default: `600.0`\n\n* `mor_excitation` (**String**) Generic training input type, select from: `impulse`, `step`, `random-binary`, `white-noise`, default: `step`\n* `mor_max`        (**Positive Integer**) Maximum reduced order, default: `200`\n* `mor_parametric` (**Boolean**) Use parametric model order reduction, select from `true`, `false`, default: `true`\n* `mor_pgrid`      (**Positive Integer**) Sparse parameter grid refinement level, default: `1`\n\n* `eval_pnorm`      (**Float**) Parameter norm: `1`, `2`, `Inf`, default: `2`\n* `eval_skip`       (**Positive Integer**) Evaluate every n-th reduced order model, default: `3`\n* `eval_max`        (**Positive Integer**) Maximum reduced order to evaluate, default: `200` (use `Inf` for maximum possible)\n* `eval_parametric` (**Boolean**) Parametric reduced order model evaluation: `true`, `false`, default: `true`\n* `eval_ptest`      (**Positive Integer**) Number of test parameters, default: `5`\n* `eval_gain`       (**Boolean**) Use gain correction: `true`, `false`, default: `true`\n\n### Internal Configuration Structure\n\nInternally, the configuration is stored in a structure of structures as follows:\n\n* `config`     (**struct**)\n  * `.network` (**struct**) Members: `.dt`, `.vmax`, `.cfl`\n  * `.model`   (**struct**) Members: `.tuning`, `.reynolds`, `.friction`, `.gravity`\n  * `.steady`  (**struct**) Members: `.dt`, `.maxiter_lin`, `.maxiter_non`, `.maxerror`, `.Tc`, `.pc`, `.pn`, `.compressibility`\n  * `.solver`  (**struct**) Members: `.dt`, `.relax`, `.rk2type`, `.rk4type`\n  * `.mor`     (**struct**) Members: `.rom_max`, `.parametric`, `.solver`, `.excitation`, `.T0_min`, `.T0_max`, `.Rs_min`, `.Rs_max`, `.pgrid`\n  * `.eval`    (**struct**) Members: `.parametric`, `.ptest`, `.T0_min`, `.T0_max`, `.Rs_min`, `.Rs_max`, `.skip`, `.max`, `.pnorm`, `.gain`\n\n### Temperature Units\n\nAll input temperatures, i.e., in:\n\n* `morgen.ini` configuration\n* `XXXXXX.ini` scenario\n\nand all output temperatures are in **Celsius**.\nInternally, all temperatures are in **Kelvin**.\n\n\u003c/details\u003e\n\n## Tools\n\n\u003cdetails\u003e\u003csummary markdown=\"span\"\u003e(click to expand)\u003c/summary\u003e\n\n* `xml2net.xsl`    Converts [gaslib](https://gaslib.zib.de) `.net` XML network definitions into **MORGEN**-compatible `.net` CSV network definitions via XSLTproc:\n```\nxsltproc -o GasLib-X.csv xml2net.xsl GasLib-X.xml\n```\n* `csv2net.m`      Converts [SciGRID_Gas](https://gas.scigrid.de) `.csv` CSV network definitions into **MORGEN**-compatible `.net` CSV network definitions:\n```\ncsv2net('X_Y_PipeSegments.csv','myX_Y')\n```\n* `json2net.m`     Converts [MathEnergy](https://mathenergy.de) `.json` network definitions into **MORGEN**-compatible `.net` CSV network definitions:\n```\njson2net('X.json','myX')\n```\n* `vf2kgs.m`       Converts volume flow to kg/s (default gas density is 0.7)\n```\nvf2kgs(value,vol_unit,time_unit,density)\n```\n* `psi2bar.m`      Converts psi to bar\n```\nb = psi2bar(p)\n```\n* `randscen.m`     Generates a random scenario given a network, implicitly defining training scenario\n```\nrandscen(network,scenario_name)\n```\n* `cmp_friction.m` Compare friction factors\n```\ncmp_friction(Re,D,k)\n```\n* `cmp_compressibility.m` Compare compressibility factors\n```\ncmp_compressibility(p,T,pc,Tc)\n```\n\n\u003c/details\u003e\n\n## Notes\n\nBased on numerous numerical experiments we _currently_ recommend the following\nmodel-solver-reductor ensemble(s):\n\n* Model:    `ode_end` (Port-Hamiltonian Endpoint Discretization)\n* Solver:   `imex1` (First-Order Implicit-Explicit)\n* Reductor: `eds_ro_l` (Structured Linear Empirical Dominant Subspaces)\n\n## Log\n\n* 1.2 (2022-10-07): [doi:10.5281/zenodo.7157808](https://doi.org/10.5281/zenodo.7157808)\n  * `ADDED`    Modified POD `mpod` reductor in six variants\n  * `ADDED`    configurable number of stages for `rk2hyp` solver\n  * `ADDED`    configurable coefficient sets for `rk4hyp` solver\n  * `ADDED`    Crank-Nicolson/Adams-Bashforth `cnab2` solver\n  * `ADDED`    total elapsed time\n  * `ADDED`    MORscore horizontal bar plot\n  * `ADDED`    optional argument `cfl`\n  * `ADDED`    networks and tests\n  * `FIXED`    `randscen` tool\n  * `IMPROVED` formulation of model nonlinearities\n  * `IMPROVED` model reduction backend `emgr` via 5.99 update\n  * `IMPROVED` memory footprint of `rk2hyp` solver\n  * `IMPROVED` steady-state extra steps\n  * `IMPROVED` plot labels and legends\n  * `CHANGED`  reductor full names\n\n* 1.1 (2021-08-08): [doi:10.5281/zenodo.5168949](https://doi.org/10.5281/zenodo.5168949)\n  * `ADDED`    optional static gravity term\n  * `ADDED`    optional gain correction\n  * `ADDED`    explicit RK2 solver `rk2hyp` with increased stability\n  * `ADDED`    explicit RK4 solver `rk4hyp` with increased stability\n  * `ADDED`    linearized model export pseudo-solver\n  * `ADDED`    networks and tests\n  * `CHANGED`  nonlinear vector field model-interface\n  * `IMPROVED` ROM test logging\n  * `IMPROVED` steady state solver stopping criteria\n  * `IMPROVED` plot presentation\n  * `FIXED`    generic path separators\n  * `FIXED`    solver caching\n  * `FIXED`    `rk4` solver\n  * `FIXED`    compact plot labels\n\n* 1.0 (2021-06-22): [doi:10.5281/zenodo.5012357](https://doi.org/10.5281/zenodo.5012357)\n  * `ADDED`    configurable CFL constant\n  * `ADDED`    `psi2bar` converter tool\n  * `ADDED`    tunable efficiency factor\n  * `ADDED`    networks and tests\n  * `IMPROVED` steady-state interface\n  * `IMPROVED` model-solver interface\n  * `IMPROVED` reductor interface\n  * `IMPROVED` `rk4` solver\n  * `IMPROVED` logging\n  * `IMPROVED` `vf2kgs` tool\n\n* 0.99 (2021-04-12): [doi:10.5281/zenodo.4680265](https://doi.org/10.5281/zenodo.4680265)\n  * `ADDED`    `gopod_r` reductor\n  * `ADDED`    linear reductor variants\n  * `ADDED`    SciGRID_gas CSV converter\n  * `ADDED`    DEMO code\n  * `IMPROVED` model structure\n\n* 0.9 (2020-11-24): [doi:10.5281/zenodo.4288510](https://doi.org/10.5281/zenodo.4288510)\n  * Initial release\n\n## References\n\n* C. Himpe, S. Grundel: **System Order Reduction for Gas and Energy Networks**;\n  in: Proceedings in Applied Mathematics and Mechanics, 22: e202200201, 2023.\n  [doi:10.1002/pamm.202200201](https://doi.org/10.1002/pamm.202200201)\n  * See also the references listed herein.\n\n* C. Himpe, S. Grundel, P. Benner: **Next-Gen Gas Network Simulation**;\n  in: Progress in Industrial Mathematics at ECMI 2021: 107--113, 2022.\n  [doi:10.1007/978-3-031-11818-0_15](https://doi.org/10.1007/978-3-031-11818-0_15)\n  * See also the references listed herein.\n\n* C. Himpe, S. Grundel, P. Benner: **Model Order Reduction for Gas and Energy Networks**;\n  Journal of Mathematics in Industry 11: 13, 2021.\n  [doi:10.1186/s13362-021-00109-4](https://doi.org/10.1186/s13362-021-00109-4)\n  * See also the references listed herein.\n\n* P. Benner, S. Grundel, C. Himpe, C. Huck, T. Streubel, C. Tischendorf: **Gas Network Benchmark Models**;\n  in: Applications of Differential-Algebraic Equations: Examples and Benchmarks: 171--197, 2019.\n  [doi:10.1007/11221_2018_5](https://doi.org/10.1007/11221_2018_5)\n\n* C. Himpe: **Comparing (Empirical-Gramian-Based) Model Order Reduction Algorithms**;\n  in: Model Reduction of Complex Dynamical Systems: 141--164, 2021.\n  [doi:10.1007/978-3-030-72983-7_7](https://doi.org/10.1007/978-3-030-72983-7_7)\n\n* C. Himpe, S. Grundel, P. Benner: **Efficient Gas Network Simulations**;\n  in: German Success Stories in Industrial Mathematics: 17--22, 2022.\n  [doi:10.1007/978-3-030-81455-7_4](https://doi.org/10.1007/978-3-030-81455-7_4)\n\n* T. Clees, A. Baldin, P. Benner, S. Grundel, C. Himpe, B. Klaassen, F. Küsters, N. Marheineke,\n  L. Nikitina, I. Nikitin, J. Pade, N. Stahl, C. Strohm, C. Tischendorf, A. Wirsen: **MathEnergy – Mathematical Key Technologies for Evolving Energy Grids**;\n  in: Mathematical Modeling, Simulation and Optimization for Power Engineering and Management: 233--262, 2021.\n  [doi:10.1007/978-3-030-62732-4_11](https://doi.org/10.1007/978-3-030-62732-4_11)\n\nFor references see also: [GasMOR](https://www.mpi-magdeburg.mpg.de/4124328/gasmor)\n\n## Roadmap\n\n### 2.0\n\n* [Model]    `ADD` variable supply-demand input-output boundaries\n* [Model]    `ADD` scenario valve handling\n* [Model]    `ADD` generic compressors as input-output combination\n* [Reductor] `ADD` hyper-reductor module (DMD, DEIM, Q-DEIM, Numerical linearization)\n* [Octave]   `FIX` slow convergence of `ode23s` in generic solver\n* [Octave]   `FIX` incompatibilities in `format_network` (`textscan`)\n\n## Development Guidelines\n\n* The main branch must complete reproducibility (`RUNME_xxx`) system tests successfully **!**\n* All source code headers must include: project, version, authors, license, summary **!**\n* Understand closures in [Matlab](https://research.wmz.ninja/articles/2017/05/closures-in-matlab.html) **!**\n* This project uses [Readme-Driven Development](https://tom.preston-werner.com/2010/08/23/readme-driven-development.html) **!**\n\n## Authors\n\n* Christian Himpe ([orcid:0000-0003-2194-6754](http://orcid.org/0000-0003-2194-6754))\n* Sara Grundel ([orcid:0000-0002-0209-6566](http://orcid.org/0000-0002-0209-6566))\n\n## Origin\n\nThe `morgen` gas network simulation, testing and benchmarking platform was\ndeveloped as part of the [MathEnergy](https://www.mathenergy.de) project.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpimd-csc%2Fmorgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmpimd-csc%2Fmorgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpimd-csc%2Fmorgen/lists"}