AI Power Agents

"Mothers Little Helper"

Posted by dave on May 05, 2024

The US electric grid is a very large, complex machine that powers our lives and is a key component in our journey to a sustainable future. Understanding it has never been more important. The grid will need to evolve and adapt as more distributed, variable, renewable energy sources are integrated, older fossil fuel plants are shutdown, and new nuclear plants stay on the drawing board. The grid is poised to become more dynamic, and new energy rate structures that reflect this dynamic behavior will emerge. Where could AI potentially help? Could AI monitor the grid and become "Mothers Little Helper"? (re: Rolling Stones)

(Very) Simple Overview

The US power grid is made up of three separate regions; east of the Rockies, west of the Rockies and Texas. Each region is highly interconnected for reliability and runs like a well-oiled machine providing AC power from high voltages that power industries to low voltages that run homes. The regions are further divided into about seventy (70) "balancing authorities". These are organizations responsible for operating an area of the grid within a region, under supervision from Washington, DC.

In the next level down from grid balancing operations are the distribution utilities. These companies operate the equipment that ultimately brings lower voltage electricity to homes. There are over 3000 utilities ranging from large conglomerates to small cooperatives and towns.

Grid Operations

PJM is the grid operator in the mid-Atlantic. It balances a large territory that includes some or all of 13 states, including Pennsylvania, Jersey, Maryland (PJM?), and Delaware. That is a lot of turf. PJM manages up to 150 gigawatts of power mainly through energy markets and is the largest grid operator in the US. To put that number in context, 150 gigawatts is equivalent to about 200 million horsepower. That's a lot of horses!

Operating a large grid is not a walk in the park. The 2021 Texas power crisis stands out as an example of what can go wrong, when things go wrong. For a long time, US grids were operated by vertically integrated companies, regulated by a government entity. This approach has evolved toward wholesale electricity markets, and more recently, retail electricity markets. Markets encourage open participation but they are not typically stable by nature. Prices in markets fluctuate and stability is not a slam dunk. This poses an issue if the system has to maintain supply-demand balance in real time. Not a lot a wiggle room. To address this, PJM developed a suite of market products and mechanisms that cover long term generation capacity for enabling capital investment, day-to-day markets for energy supply, and real-time ancillary services for handling fast power fluctuations. These markets are all directed toward ensuring the reliable delivery of power and have proven to be successful. They are described in more detail at https://learn.pjm.com/electricity-basics/market-for-electricity.aspx

Energy Markets

The core PJM electricity markets are the day-ahead energy market and the real-time energy market. These are spread across over 10,000 pricing nodes that use marginal pricing based on location, called LMP (Locational Marginal Price). LMPs are the prices paid to generators for supplying the next megawatt-hour of energy and are based on a wholesale energy price modified to include transmission losses, network congestion and other factors. They fluctuate daily and seasonally, and are affected by power demand, weather and other factors. In 2023, the total PJM wholesale cost was about $50 MWh (megawatt-hour), or 5 cents a kilowatt-hour. The pricing nodes have hourly LMPs and real-time five-minute LMPs that reflect the marginal cost of supplying electricity at a particular point on the grid at a given moment in time. Along with the pricing nodes are load areas that have seven-day hourly load forecasts that reflect grid demand. Typically, PJM matches offers from the lowest-to-highest priced generators so when energy demand is low, prices are lower. When energy demand is high, prices are higher.

The distribution utilities typically buy wholesale electricity from the grid operator and resell that electricity to their retail consumers at a price per kilowatt-hour rate, managed by local and state authorities. Retail prices include the wholesale price along with other charges and expenses. Most retail home customers are then billed for the quantity of electricity used over a month period.

Enter Demand Charges

But this isn't the whole story. Large commercial and industrial customers, more often than not, have what are known as "demand charges" added to their bill. These are charges based upon the maximum amount of power required over a specified period of time, such as an hour or fifteen-minutes. Demand charges reflect the cost of maintaining enough capacity to supply the maximum power that each customer might require. Essentially, demand charges help cover the fixed costs of the power system infrastructure needed to meet peak demand levels, ensuring that sufficient electricity generation and distribution resources are always available. If a customer is on a demand charge rate, then monitoring and reacting to peak demand can significantly lower energy costs. Can an AI Power Agent assist in identifying these peaks?

What is an AI Power Agent?

An AI Power Agent is a mathematically-literate Large Language Model (LLM) advisor that is connected to the real world and can ingest and analyze power data that is accessible through a permissioned application programming interface (API). A power agent can sample and process data at whatever time interval makes sense and send the results to humans and/or other systems.

An AI Power Agent Proof-of-Concept

Goal: Detect Peak Demand of an Electric Cooperative

A local electric cooperative, Delaware Electric Cooperative (DEC), buys wholesale electricity from Old Dominion Electric Cooperative (ODEC). ODEC has a variety of generation facilities and also purchases electricity from PJM. This helps give smaller distribution cooperatives, such as DEC, larger purchasing power with PJM. DEC is subjected to a demand charge that is related to the highest six (6) peaks during the year that last for over an hour. I am confident similar use cases affect other cooperatives and municipal utilities as well as many large commercial and industrial facilities around the country. The cooperative monitors PJM data and when a significant load peak is detected, it signals a demand response event to reduce as much load as it can.

Sounds simple. So, what's the issue? Well, predicting the future behavior of two highly complex, interrelated "beasts" is tough, especially with rising temperatures and turbulent weather. PJM provides a seven-day hourly load forecast that is based on modern power system models along with a deep understanding of their grid, and the National Weather Service provides seven-day weather forecasts that are based on weather models that run on supercomputers and try to predict the behavior of a massive chaotic system. PJM hedges their bets with a real-time energy market and ancillary services for fine-grained control while customers must manage their consumption and costs.

DEC closely monitors the PJM_COMBINED and the DPL_MIDATL load forecast areas along with the weather and other variables during the hot summer season from June to September, when AC's are cranked up. The cooperative can typically detect the six (6) summer peaks while triggering about ten (10) demand response events.

How close could an AI Peak Power Agent come to identifying the summer peaks? Could it pick out the six (6) peaks with under twenty (20) attempts? Let's see what a prototype can do…

AI Peak Power Agent Prototype

The prototype agent was built using the open-source OpenAI Agent Toolkit…

https://upperbay.com/v1/blogs/beachblogs/openai-agent-toolkit

The agent data feeds are built using software tools in my CurrentForCarbon C# code base…

https://upperbay.com/v1/blogs/beachblogs/current-for-carbon

Agent behavior is based on information gathered from…

https://upperbay.com/v1/blogs/beachblogs/electric-summertime-blues

The AI agent runs every morning and extracts the following data from PJM:

  • Load = Day-ahead hourly load forecast for PJM_COMBINED in megawatts
  • Price = Day-ahead hourly LMP forecast for PJM_RTO in dollars per megawatt hour
  • LocalLoad = Day-ahead hourly load forecast for DPL_MIDATL in megawatts
  • LocalPrice = Day-ahead hourly LMP forecast for DPL_ODEC in dollars per megawatt-hour

And from the National Weather Service:

  • Temp and Forecast = Day-ahead hourly local temperature and condition forecast

The above data is assembled into a comma-separated-value (CSV) file that can be understood by the agent and imported into Excel for verification. My relationship with AI is "trust but verify".

The following is the initial baseline prompt that includes some application-specific functionality along with grid data. It is basically code in natural language that directs the LLM to write and execute Python code. Coding without the coding!

Prompt To Agent

Examine the following time series data. The data is in comma separated format (CSV) with seven columns. The columns are Datetime, Load, Price, Temp, Forecast, LocalLoad and LocalPrice. The first row of CSV data has the column names. The values are at 1 hour intervals and are for the current day. Calculate the following statistics for each of the columns; average, maximum and minimum values and standard deviation. Display the statistics with the Datetime of the maximum values. If the maximum Load value is greater than 130,000, then the gametype is "SHEDPOWER", the awardlevel is "GOLD", the startime is the Datetime of the maximum Load and the LMP is the Price at the maximum Load. Otherwise, if the maximum LocalLoad is greater than 3500, then the gametype is "SHEDPOWER", the awardlevel is "GOLD", the startime is the Datetime of the maximum LocalLoad and the LMP is the LocalPrice at the maximum LocalLoad. If these two conditions are not met then if the maximum Price value is greater than 30, then the gametype is "SHEDPOWER" and the awardlevel is "SILVER", the startime is the Datetime of the maximum Price and the LMP is the Price at the maximum Load. Otherwise, if the maximum Price is greater than 25, then the gametype is "SHEDPOWER" and the awardlevel is "BRONZE", the startime is the Datetime of the maximum Price and the LMP is the maximum Price. If none of these conditions are met then there is "NOGAME". If the awardlevel is "SILVER", "BRONZE" or "GOLD", then send a GridPeakDetected massage using the function GridPeakDetected to C2Agent. Use two decimal places for all calculations. If a GridPeakDetected message is sent, then also send the message as a notice to CommandCenter and to the ControlPanel using functions. The grid node is "PJM". Set the duration to 120 mins. Display all results.

Data values are Time,Load,Price,Temp,Forecast,LocalLoad,LocalPrice

  • 05/01/2024 10:00:00,86872,22.84055,68,Mostly Sunny,1876,20.25853
  • 05/01/2024 11:00:00,88834,23.72052,71,Mostly Sunny,1915,20.05243
  • 05/01/2024 12:00:00,90871,24.89518,73,Sunny,1971,19.09148
  • 05/01/2024 13:00:00,93163,25.996,75,Sunny,2016,18.5976
  • 05/01/2024 14:00:00,94968,29.86987,77,Sunny,2083,20.47876
  • 05/01/2024 15:00:00,96838,32.23935,78,Sunny,2173,22.3145
  • 05/01/2024 16:00:00,98914,37.7367,78,Sunny,2253,25.29433
  • 05/01/2024 17:00:00,100081,42.83683,78,Sunny,2325,31.03653
  • 05/01/2024 18:00:00,99606,49.22736,77,Mostly Clear,2358,36.16602
  • 05/01/2024 19:00:00,98358,52.27295,74,Mostly Clear,2340,38.35506
  • 05/01/2024 20:00:00,96324,50.32808,70,Clear,2259,36.26955
  • 05/01/2024 21:00:00,92457,36.21581,66,Mostly Clear,2117,23.48338
  • 05/01/2024 22:00:00,86319,24.71693,63,Mostly Clear,1928,18.24574
  • 05/01/2024 23:00:00,80239,22.20951,61,Mostly Clear,1750,20.08887

Agent Response

The statistics for each of the columns are calculated as follows:

  • Load: Mean = 93,131.71, Max = 100,081, Min = 80,239, STD = 5,910.31
  • Price: Mean = 33.94, Max = 52.27, Min = 22.21, STD = 10.93
  • Temp: Mean = 72.07, Max = 78, Min = 61, STD = 5.76
  • LocalLoad: Mean = 2,097.43, Max = 2,358, Min = 1,750, STD = 194.04
  • LocalPrice: Mean = 24.98, Max = 38.36, Min = 18.25, STD = 7.28

The conditions identified a SHEDPOWER game with the SILVER award level, triggered by a peak price. The key details are:

  • Start time: 05/01/2024 19:00:00
  • LMP: 52.27295

I've sent a GridPeakDetected message to C2Agent with the appropriate details and also sent notice messages to both the CommandCenter and the ControlPanel regarding this event.

Next Steps

The base prototype is only the starting point. I plan to monitor the agent's performance and modify its behavior during the summer. Some areas I would like to investigate are:

  • Adding the daily operations summary for PJM.
  • Adding more statistical metrics.
  • Setting event duration and start time from forecast statistics.
  • Setting load and price thresholds from historical data.
  • Analyzing last year's historical load data at startup to learn past load behaviors dynamically.
  • Analyzing weather forecast vs actual and tweaking the forecasted load and price.
  • Analyzing load forecast vs actual to understand the accuracy of the PJM forecasts.
  • Investigating other time-series data feeds and similar use cases.

Conclusion

Initial tests are very promising. The math is simple and straight forward but that powerful Python engine running under the hood is ready to do my bidding.

Do I need an AI Agent for this application? No. I could easily hardcode the functionality. To be fair, I'm a boomer geek with miles of software development in the rearview. In the new world, fast approaching, AI Agents will do the hard work of coding while we humans use words to express our desires. That opens the door for lots of folks.

The AI Power Agent is still young, but it is learning and growing fast. OpenAI's next release is around the corner. Now is the time to play and teach it how it to be a useful "Mothers Little Helper".

Having Fun With AI!

Dave Hardin