Skip to content

How NEMS Modernizes Without Starting Over

From FORTRAN and OML to GAMS, AIMMS, and Python

The modular nature of NEMS allows for discrete changes without interrupting the annual forecast cycle. Model improvements include both conceptual updates and technical progress. As hardware improves, more complex representations of energy markets become possible. Furthermore, the increasing flexibility and value of open-source software have opened new possibilities in modeling. On the other hand, improved proprietary software has provided new capabilities. This post looks at some technical improvements in the software used to solve the equilibrium energy system model: in particular, the evolution of the languages used to solve linear programs in NEMS.

Several NEMS modules use linear programming to allocate production, transportation, capacity, or dispatch subject to resource, engineering, and policy constraints. Linear programs are computationally mature and can provide both quantities and economically meaningful shadow prices. Samuelson (1952) showed that when supply and demand are represented in linear form, a linear program that maximizes consumer and producer surplus yields a market equilibrium. The duals associated with the demand rows can be used to determine prices. Therefore, any market that could plausibly be represented as competitive could be solved using an LP. Because there are so many applications beyond energy modeling, linear programming software is ubiquitous, efficient, and robust.

New Software, New Solutions

NEMS modernization has proceeded incrementally rather than through a single system-wide rewrite. The major milestones show how EIA has replaced older optimization routines, adopted specialized modeling environments, and added capabilities that were not envisioned when NEMS was first developed.

Selected milestones in NEMS modernization

First AEO useComponentSoftware or formulationPrincipal change
AEO2013Liquid Fuels Market Model (LFMM)GAMS; linear programReplaced the Petroleum Market Model and consolidated the representation of petroleum refining, renewable fuels, other liquid-fuel production, and distribution.
AEO2015–AEO2016Coal Market Module (CMM)AIMMS; optimization and supporting econometric routinesEIA converted the Coal Production Submodule to AIMMS for AEO2015 and completed the multiyear CMM conversion and redesign for AEO2016.
AEO2018Natural Gas Market Module (NGMM)AIMMS; quadratic programReplaced the Natural Gas Transmission and Distribution Module with a state- and month-level network model that represents market balancing, pipeline flows, prices, and capacity expansion.
AEO2020Renewable Storage Submodule (REStore)AIMMS; linear programAdded 576 representative hours per year to estimate renewable generation, curtailment, storage operation, and the marginal value of additional storage capacity.
AEO2025Electricity Capacity Planning and Fuel Dispatch submodulesAIMMS; linear programsMoved ECP coefficient generation and solution from the older OML-based process into AIMMS. By AEO2025, EIA also used only AIMMS to formulate and solve the EFD linear program, although some processing and integration remain in Fortran.
AEO2025Hydrogen Market Module (HMM)AIMMS; linear programAdded an integrated representation of hydrogen production, interregional transportation, storage, prices, and demand.
AEO2025Carbon Capture, Allocation, Transportation, and Sequestration module (CCATS)Python and Pyomo; linear programReplaced the distributed CTUS representation with an integrated network that allocates captured CO₂ among pipelines, enhanced oil recovery, and saline storage.
AEO2025Hydrocarbon Supply Model (HSM)Python; project-level discounted cash-flow modelingReplaced the Oil and Gas Supply Module with a more maintainable, project-level representation of domestic oil and natural gas development.
AEO2025Emissions Policy Module (EPM)PythonMoved the emissions accounting and policy code base from Fortran to Python while adding new fuel uses and natural gas processing emissions.

Source: U.S. EIA NEMS Model Documentation: https://www.eia.gov/outlooks/aeo/nems/documentation/

The starting point for this transition was a gradual phasing out of Ketron’s Optimization Management Library, or OML, which NEMS used to construct and solve linear programs through calls embedded in the Fortran code. With the change in ownership of Ketron, further development generally ceased, and the package became increasingly obsolete.

The first major module to be re-written was the Petroleum Market Module (PMM). With the increasing penetration of renewable fuels into the liquid fuels market, it became increasingly difficult to incorporate changes in the PMM. The PMM used OML, which is not a modeling language but rather a series of calls to build and solve a standard mathematical program entry by entry. Each entry, representing a single element of the problem, is input independently of all others, while all the logic in the model development must reside in the Fortran code. This makes modification of the module time-consuming and error prone.

The new model, the Liquid Fuels Market Module (LFMM), was rewritten in the General Algebraic Modeling System (GAMS), introduced in 2013. GAMS is a set-oriented symbolic algebraic modeling language, designed to establish the framework for an optimization problem and interact with several specialized solvers. Using such a tool greatly simplifies changes to the model structure and enables rapid integration of new fuel development processes.

An alternative modeling system to GAMS is the Advanced Interactive Multidimensional Modeling System (AIMMS). This software comprises an entire development environment, including a graphical user interface with point-and-click capabilities for adding model structure, a database that stores the model structure with robust error checking, and sophisticated tools for profiling and debugging. The first module redesigned using AIMMS was the coal model. The revised model was introduced in AEO 2016.

With the success of the coal module update, the Natural Gas Transportation and Distribution Module was replaced with the Natural Gas Market Module, also written in AIMMS. The new module, adopted in AEO 2018, added additional granularity in the natural gas transmission system. It introduced a linear program for gas transportation and a capability to project capacity expansion.

The Electricity Market Module (EMM) is by far the most complex module in all of NEMS and has required the most radical changes since its initial development. Because model size grows exponentially with the number of periods, the model comprises two distinct linear programs with different emphases. Capacity planning provides a supply-demand balance over the aggregate lifetime of power plants, including plant expansions and retirements, while the current year dispatch has far more granular detail on existing power plants.

There are two distinct aspects of modeling: creating the logic necessary to model the electricity market and translating these rules into equations. Over several AEOs, the coefficients of the equations for both the capacity planning and dispatch optimization models were replicated in AIMMS. In AEO 2025, the OML code was removed and solely AIMMS was used to develop the optimization solution. However, most of the remaining logic remains embedded in the Fortran code. This completed EIA’s deprecation of the OML software.

New Models

The original NEMS had thirteen distinct modules. This structure served remarkably well over 25 years. Starting in AEO 2020, one submodule and two distinct modules were added to the NEMS framework. Two other modules were substantially reworked. A brief overview of these changes is presented below.

RESTore Submodule

Intermittent resources, in isolation, generally reduce grid reliability, as they are limited in the times they can produce power. This can be mitigated by storage resources such as batteries, which time-shift power to when it is needed. Given the limited number of time slices in the EMM, the value storage provides to reliability lies outside the EMM’s analytic capability. In response, EIA developed the Renewable and Electricity Storage model (RESTore), a distinct submodule of the EMM. This submodule, introduced in AEO 2020, uses disaggregated load shapes to estimate marginal price differences within a single day, and thus the value of batteries, which can shift generation from hours when renewable output is high to hours when it is otherwise unavailable. The RESTore model trades disaggregation for time slices with reaggregation of dispatchable resources into groups with a composite cost. The RESTore model is another example of a linear program written in AIMMS. It is disaggregated by time period and includes hourly generation capability for wind and solar intermittents, available dispatchable sources, and storage resources such as batteries. In this way, the value of storage, which otherwise cannot be captured, is provided to the rest of the EMM.

Hydrogen Market Module

The hydrogen market module (HMM), introduced in AEO 2025, is the first distinct new module since NEMS’s initial development. The hydrogen market module represents the production, transportation, and storage of hydrogen in the domestic market. Since hydrogen can be both an intermediate and an end-use product, this module interacts with both the supply and demand modules. The model provides hydrogen prices and fuel consumption for the transportation, electricity, refining, and industrial sectors. Furthermore, since hydrogen is already embedded in the economy, the boundaries between the models are particularly hard to discern. Hydrogen is used in refining for desulfurization and other petrochemical conversions. It is also a key component in manufacturing ammonia for fertilizer production. Hydrogen used as an intermediate product is modeled in the industrial and refining industries. In contrast, commercial hydrogen is modeled in the HMM even though it plays an identical role in the industrial process. Following the NGMM, the hydrogen market is represented as a linear program using AIMMS.

CCATS Module

With the passage of the Inflation Reduction Act (IRA), the need for a more comprehensive model of the CO2 market became more urgent. The previous representation, the Capture, Transport, Utilization, Storage (CTUS) submodule, was scattered across oil and gas, liquid fuels, and electricity market modules.  With AEO 2025, EIA introduced a centralized representation of the CO2 market. Within the Carbon Capture, Allocation, Transportation and Sequestration (CCATS) module, CO2 is supplied from carbon capture in the industrial, refining, and electricity sectors. The model optimizes transportation and storage by projecting pipeline capacity and allocating CO2 to saline storage sites or for use in Enhanced Oil Recovery. This is unique in that the model structure is developed in Python and is entirely open source. EIA uses a commercial solver to improve execution time. However, NEMS Connect has designed, built, and tested the model using only open-source software.

Hydrocarbon Supply Module

In AEO 2025, the Oil and Gas Supply Module (OGSM) was replaced by the Hydrocarbon Supply Module (HSM). An object-oriented Python implementation entirely replaced the previous Fortran code. A common discounted cash flow algorithm replaced the geography-specific (such as onshore and offshore) methodology in OGSM. Improvements in the onshore submodule included geology-specific cost equations and a simplified secondary oil recovery algorithm. Carbon sequestration was moved to the new CCATS module, while the module, for the first time, differentiated between production from Federal and non-Federal lands.

Emissions Policy Module

The Emissions Policy Module (EPM) provides an accounting framework for criteria pollutants and greenhouse gases. It also supports policy implementations such as carbon caps and taxes that cut across multiple sectors and modules. For AEO 2025, the Fortran implementation was substantially expanded and re-written in Python. The revisions allow machine-generated documentation, improve readability, and support easier code maintenance.

An Architecture Built to Evolve

The history of NEMS is a history of continual improvements. As software improves, EIA leverages these changes to provide flexibility and depth in modeling. Over the years, key questions have changed, and EIA has had to adapt the model to remain relevant.

NEMS has remained relevant not by preserving its original software unchanged, nor by periodically replacing the entire system, but by modernizing selected components as analytical needs and software capabilities evolve. Its modular architecture has allowed EIA to replace older optimization routines, adopt GAMS and AIMMS, introduce Python-based models, and add new representations of storage, hydrogen, carbon management, and hydrocarbon supply while maintaining the interfaces needed for an integrated energy projection.

These changes are more than programming updates. They allow for greater geographic and temporal detail, make model formulations easier to understand and maintain, and create capabilities not envisioned when NEMS was first developed. At the same time, effective portions of the existing Fortran system can remain in place where wholesale replacement would provide little analytical benefit.

The durability of NEMS therefore does not depend on any particular programming language, modeling environment, or solver. It rests on an architecture that permits individual components to be revised or replaced without starting over. That capacity for selective reinvention is what has kept NEMS useful through decades of changes in energy markets, policy questions, and computing technology, and it remains essential to the system’s future value.

References:

EIA, The Electricity Market Module of the National Energy Modeling System: Model Documentation 2020, July 2020.

EIA, Hydrogen Market Module of the National Energy Modeling System: Model Documentation 2025, August, 2025.

EIA,Carbon Capture, Allocation, Transportation, and Sequestration (CCATS) Module of the National Energy Modeling System: Model Documentation 2025, July, 2025.

EIA, Liquid Fuels Market Model of the National Energy Modeling System: Model Documentation 2013, December 2013.

EIA, Annual Energy Outlook 2025 Fact Sheet: Hydrocarbon Supply Module, April, 2025.

EIA, National Energy Modeling System (NEMS) Integration framework improvements in Annual Energy Outlook 2025 (AEO2025), April, 2025.

EIA, Coal Market Module of the National Energy Modeling System: Model Documentation 2016, May, 2018.

EIA, Natural Gas Market Module of the National Energy Modeling System: Model Documentation  2018, October, 2018.

Quintanilla, G., OnLocation’s REStore Model Optimizes Renewable Energy Storage for the U.S. Power Grid, AIMMS Case Studies, June, 2021.

Samuelson, P., Spatial Price Equilibrium and Linear Programming, The American Economic, Review, Vol. 42 No. 3, June, 1952.

Leave a Reply

Your email address will not be published. Required fields are marked *