Spaces:
Running
Running
| import streamlit as st | |
| import pandas as pd | |
| import numpy as np | |
| import plotly.graph_objects as go | |
| # --- Page Configuration --- | |
| st.set_page_config( | |
| page_title="US AI Emissions in 2030", | |
| page_icon="⚡", | |
| layout="wide" | |
| ) | |
| # --- Custom CSS --- | |
| st.markdown(""" | |
| <style> | |
| /* --- 1. Global Font Reset --- */ | |
| /* Applies a clean, modern system font to the whole app */ | |
| html, body, [class*="css"] { | |
| font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol" !important; | |
| } | |
| /* --- 2. Sidebar Layout & Width --- */ | |
| [data-testid="stSidebar"] { | |
| width: 450px !important; | |
| min-width: 450px !important; | |
| } | |
| /* --- 3. Sidebar Typography --- */ | |
| /* Target the text inside the sidebar's markdown container */ | |
| [data-testid="stSidebarContent"] .stMarkdown { | |
| color: white !important; | |
| } | |
| /* Optional: Target specific headers or paragraphs in the sidebar for clarity */ | |
| [data-testid="stSidebarContent"] p, | |
| [data-testid="stSidebarContent"] h1, | |
| [data-testid="stSidebarContent"] h2, | |
| [data-testid="stSidebarContent"] h3 { | |
| color: white !important; | |
| } | |
| /* The Custom Question Headers */ | |
| .sidebar-question { | |
| font-size: 1.4rem; | |
| font-weight: 700; | |
| /* Use 'inherit' so Streamlit handles the Light/Dark color shift automatically */ | |
| color: inherit; | |
| margin-bottom: 8px; | |
| line-height: 1.3; | |
| } | |
| /* Standard Streamlit Labels (e.g., above sliders if visible) */ | |
| [data-testid="stSidebar"] label { | |
| font-size: 1.1rem !important; | |
| font-weight: 600 !important; | |
| } | |
| /* Markdown Paragraphs in Sidebar (e.g., in Expanders) */ | |
| [data-testid="stSidebar"] .stMarkdown p { | |
| font-size: 1.05rem !important; | |
| line-height: 1.5; | |
| color: #4b5563; | |
| } | |
| /* --- 4. Sidebar Input Styling --- */ | |
| /* Number Input: The actual number text */ | |
| [data-testid="stSidebar"] [data-testid="stNumberInput"] input { | |
| font-size: 1.4rem !important; | |
| font-weight: 700 !important; | |
| color: #ff4b4b; /* Matches your theme color */ | |
| padding-top: 5px; | |
| padding-bottom: 5px; | |
| } | |
| /* Slider: Min/Max/Current Values */ | |
| [data-testid="stSidebar"] [data-testid="stTickBarMin"], | |
| [data-testid="stSidebar"] [data-testid="stTickBarMax"] { | |
| font-size: 1rem !important; | |
| font-weight: 600 !important; | |
| } | |
| /* Slider: The Hover/Drag Value Popup */ | |
| [data-testid="stSidebar"] .stSlider [data-testid="stThumbValue"] { | |
| font-size: 1.2rem !important; | |
| font-weight: bold !important; | |
| } | |
| /* --- 5. Main Dashboard Components --- */ | |
| .metric-card { | |
| background-color: #ffffff; | |
| padding: 20px; | |
| border-radius: 12px; | |
| text-align: center; | |
| margin-bottom: 15px; | |
| border: 1px solid #e5e7eb; | |
| box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); | |
| } | |
| .big-number { | |
| font-size: 3.5rem; | |
| font-weight: 800; | |
| color: #ff4b4b; | |
| margin: 10px 0; | |
| line-height: 1; | |
| } | |
| .sub-text { | |
| font-size: 1.6rem; | |
| font-weight: 500; | |
| color: #36454F; | |
| } | |
| /* Custom Spacer for Sidebar */ | |
| .spacer { | |
| margin-top: 1.5rem; | |
| margin-bottom: 1.5rem; | |
| height: 1px; | |
| background-color: #e5e7eb; /* Subtle divider line */ | |
| } | |
| /* --- 6. Layout Tweaks --- */ | |
| /* Removes the large gap at the top of the page */ | |
| .block-container { | |
| padding-top: 5rem !important; | |
| padding-bottom: 0rem !important; | |
| } | |
| </style> | |
| """, unsafe_allow_html=True) | |
| # --- Title --- | |
| #st.title("🌍 The Climate Cost of the AI Race ⛽️") | |
| # --- Sidebar Inputs --- | |
| st.sidebar.markdown(""" | |
| **What will the US emissions of AI be in 2030?** Model the 3 variables below to see. | |
| """) | |
| st.sidebar.markdown('<div class="spacer"></div>', unsafe_allow_html=True) | |
| # 1. AI Power Demand | |
| st.sidebar.markdown('<p class="sidebar-question">1. How much power will AI require in 2030? (GW)</p>', unsafe_allow_html=True) | |
| ai_demand_gw = st.sidebar.number_input( | |
| "Demand (GW)", | |
| value=100, | |
| step=10, | |
| format="%d", | |
| label_visibility="collapsed" | |
| ) | |
| with st.sidebar.expander("More on AI Demand Forecasts"): | |
| st.markdown(""" | |
| Current forecasts vary wildly, suggesting US AI data centers will need anywhere from **50 GW to over 250 GW** in the coming decade.$^{1,2,3}$ | |
| * Epoch AI analysts currently project that **100 GW** is the best forecast for AI power demand by 2030, representing roughly **10% of America's total peak power capacity**, requiring growth rates not seen since the 1980s.$^{1}$ | |
| * Anthropic projects the U.S. AI sector needs at least **50 GW** by 2028 to maintain global leadership, which is roughly double the peak electricity demand of New York City.$^{2}$ | |
| * OpenAI leadership has indicated a desire for up to **250 GW** of power by 2033 to support future model scaling.$^{3}$ | |
| *Sources:* | |
| 1. [Epoch AI: America's AI Power Problem (Dec 2025)](https://epoch.ai/gradient-updates/is-almost-everyone-wrong-about-americas-ai-power-problem) | |
| 2. [Anthropic: Build AI in America (July 2025)](https://www.anthropic.com/news/build-ai-in-america) | |
| 3. [The Information: Sam Altman Wants 250 GW (2025)](https://www.theinformation.com/articles/sam-altman-wants-250-gigawatts-power-possible) | |
| """) | |
| st.sidebar.markdown('<div class="spacer"></div>', unsafe_allow_html=True) | |
| # 2. Gas Share | |
| st.sidebar.markdown('<p class="sidebar-question">2. What proportion of this power will be supplied by natural gas?</p>', unsafe_allow_html=True) | |
| gas_share = st.sidebar.slider( | |
| "Gas Share", | |
| min_value=0, max_value=100, value=90, step=5, | |
| format="%d%%", | |
| label_visibility="collapsed" | |
| ) | |
| with st.sidebar.expander("More on Energy Mix"): | |
| st.markdown(""" | |
| **Why Gas?** | |
| The electric grid in major hubs like Texas is effectively "sold out," with wait times for connection approaching 5 years. To bypass this, AI labs are adopting "Bring Your Own Generation" (BYOG) strategies, primarily using natural gas which can be deployed in months rather than years. In fact, current projections suggest that **nearly a third of all new data center development will deploy behind-the-meter (BTM) gas generation** to circumvent these bottlenecks.$^{1,2}$ | |
| Even when projects connected to the grid, natural gas is the backbone of the US power system, accounting for approximately **43% of total utility-scale electricity generation** in 2023.$^{3,4}$ | |
| "Demand response" (or data center flexibility) could theoretically pull gigawatts "out of thin air" by matching AI training jobs to times when the grid has spare capacity.$^{5}$ However, many experts remain skeptical of the true magnitude of this solution, as large-scale implementation faces significant technical hurdles and pushback from major grid operators like PJM.$^{5,6}$ | |
| **What about Solar?** | |
| While solar prices have dropped ~88% since 2009, it faces physical limits. 2 GW of solar requires a land area roughly the size of Manhattan (approx. 60 km²). Solar requires massive battery storage for 24/7 reliability, adding complexity for off-grid "island" data centers that cannot draw on spare grid capacity at night.$^{5}$ | |
| *Sources:* | |
| 1. [Latitude Media (Jan 2026)](https://www.latitudemedia.com/news/what-the-michigan-stargate-site-says-about-todays-ai-market) | |
| 2. [JLL 2026 Global Data Center Outlook](https://www.jll.com/en-us/insights/market-outlook/data-center-outlook) | |
| 3. [U.S. Energy Information Administration (EIA)](https://www.eia.gov/energyexplained/electricity/electricity-in-the-us.php) | |
| 4. [Ember Energy - U.S. Country Profile](https://ember-energy.org/countries-and-regions/united-states-of-america/) | |
| 5. [Epoch AI: America's AI Power Problem (Dec 2025)](https://epoch.ai/gradient-updates/is-almost-everyone-wrong-about-americas-ai-power-problem) | |
| 6. [Woodway Energy: Bridging the 5-Year Gap](https://www.woodwayenergy.com/off-grid-btm-gas-power-generation-data-centers/) | |
| """) | |
| st.sidebar.markdown('<div class="spacer"></div>', unsafe_allow_html=True) | |
| # 3. Turbine Efficiency | |
| st.sidebar.markdown('<p class="sidebar-question">3. What will the efficiency of the gas turbines be?</p>', unsafe_allow_html=True) | |
| turbine_eff_percent = st.sidebar.slider( | |
| "Efficiency", | |
| min_value=35, max_value=60, value=45, step=1, | |
| format="%d%%", | |
| label_visibility="collapsed" | |
| ) | |
| with st.sidebar.expander("More on Turbine Tech"): | |
| st.markdown(""" | |
| **Trade-offs: Efficiency vs. Speed**: The efficiency of gas turbines, which determines their carbon emissions, varies from 35-60%. The most efficient, are, generally, the slowest to build. In frontier data centers, AI chips cost roughly 10x more than the power infrastructure, driving companies to prioritize deployment speed over energy efficiency. | |
| * **Aeroderivative (35-40%):** Modified jet engines (e.g., GE LM2500). They are less efficient but can be deployed in weeks via truck. xAI used these to bypass multi-year grid delays. | |
| * **Reciprocating Engines (40-50%):** Modular internal combustion engines (e.g., Wärtsilä). They maintain high efficiency even at partial loads, making them ideal for flexible "demand response" strategies. | |
| * **Combined Cycle (50-60%):** The gold standard, using waste heat to drive a steam turbine. However, lead times of **36-60 months** make them too slow for the current AI race. These are representative of utility-scale gas turbines. | |
| * **Solid Oxide Fuel Cells (50-55%):** (e.g., Bloom Energy). These offer high efficiency and fast deployment (no combustion permitting), but come with a high capital cost. | |
| [Source](https://open.substack.com/pub/semianalysis/p/how-ai-labs-are-solving-the-power) | |
| """) | |
| # Constants | |
| CAPACITY_FACTOR = 0.90 | |
| US_BASELINE_MMT = 4900 | |
| FUEL_CARBON_CONSTANT = 486 * 0.60 | |
| # --- Calculations --- | |
| # 1. Calculate Emissions Factor | |
| if turbine_eff_percent > 0: | |
| calculated_ef = FUEL_CARBON_CONSTANT / (turbine_eff_percent / 100) | |
| else: | |
| calculated_ef = 0 | |
| # 2. Calculate Total Energy | |
| gas_gw_capacity = ai_demand_gw * (gas_share/100) | |
| total_gwh = gas_gw_capacity * CAPACITY_FACTOR * 8760 | |
| # 3. Calculate Emissions (MMT CO2e) | |
| ai_emissions_mmt = (total_gwh * calculated_ef) / 1_000_000 | |
| percent_increase = (ai_emissions_mmt / US_BASELINE_MMT) * 100 | |
| # --- Dashboard Layout --- | |
| # 1. The Big Number | |
| c1, c2, c3 = st.columns([1, 2, 1]) | |
| with c2: | |
| st.markdown(f""" | |
| <div class="metric-card"> | |
| <div class="sub-text">2030 US Energy/Industry Emissions Increase due to AI</div> | |
| <div class="big-number">+{percent_increase:.2f}%</div> | |
| <div class="sub-text">{ai_emissions_mmt:.1f} Million tCO<sub>2</sub>e</div> | |
| <div style="font-size: 1em; color: #888; margin-top: 10px;"> | |
| </div> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| # 2. Charts | |
| years = [2020, 2021, 2022, 2023, 2024] | |
| emissions_hist = [4690, 5020, 5060, 4920, 4900] | |
| target_2030 = 3065 | |
| bau_2030 = 4900 | |
| fig1 = go.Figure() | |
| # History Line | |
| fig1.add_trace(go.Scatter( | |
| x=years, y=emissions_hist, | |
| mode='lines+markers', | |
| name='Historical CO₂', | |
| line=dict(color='lightgray', width=4), | |
| marker=dict(size=12) | |
| )) | |
| fig1.add_trace(go.Scatter( | |
| x=[2030], y=[target_2030], | |
| mode='markers', | |
| name='2030 Climate Goal', | |
| marker=dict(color='green', size=15, symbol='circle') | |
| )) | |
| fig1.add_trace(go.Bar( | |
| x=[2030], y=[bau_2030], | |
| name='2030 Baseline Estimate', | |
| marker_color='lightgray' | |
| )) | |
| fig1.add_trace(go.Bar( | |
| x=[2030], y=[ai_emissions_mmt], | |
| name='Additional AI Gas Emissions', | |
| base=bau_2030, | |
| marker_color='#ff4b4b' | |
| )) | |
| fig1.update_layout( | |
| height=650, | |
| font=dict(size=18), | |
| title={ | |
| 'text': "US Emissions Trajectory vs. AI Impact", | |
| 'font': {'size': 22}, | |
| 'x': 0.5, | |
| 'xanchor': 'center', | |
| 'y': 0.9, # Keeps title low and close to the chart | |
| 'yanchor': 'top' | |
| }, | |
| yaxis={ | |
| 'title': { | |
| 'text': "Emissions (Million tCO<sub>2</sub>)", | |
| 'font': {'size': 20} | |
| }, | |
| 'tickfont': {'size': 16} | |
| }, | |
| xaxis={ | |
| 'tickfont': {'size': 16} | |
| }, | |
| barmode='stack', | |
| legend={ | |
| 'orientation': "h", | |
| 'y': -0.15, | |
| 'x': 0.5, | |
| 'xanchor': 'center', | |
| 'font': {'size': 18} | |
| }, | |
| margin=dict(l=50, r=50, t=80, b=100), | |
| hovermode="x unified" | |
| ) | |
| st.plotly_chart(fig1, use_container_width=True) | |
| st.markdown("---") | |
| with st.expander("Methodology"): | |
| st.markdown(f""" | |
| **Baseline & Context** | |
| * Annual CO₂ emissions data from [Our World in Data](https://ourworldindata.org/profile/co2/united-states) (fossil fuels and industry) is used to visualize the 2020-2024 trajectory. | |
| * The 2030 percentage increase is calculated against the 2024 annual CO₂ emissions (approx. {US_BASELINE_MMT} Million TCO₂e). | |
| * 2030 Climate Goal is based on the Paris Agreement commitment to halve 2005 emissions (6130 TCO₂e). | |
| **The Physics of Efficiency:** | |
| The critical driver in this model is **Thermal Efficiency** ($\eta$). | |
| * Lower efficiency turbines (like simple-cycle Aeroderivatives) must burn *more* fuel to generate the same amount of electricity. Therefore, emissions scale inversely with efficiency. | |
| * We use [NREL Life Cycle Assessment](https://docs.nrel.gov/docs/fy21osti/80580.pdf) data for a modern Combined Cycle Gas Turbine (CCGT) as the anchor: **486 gCO₂e/kWh @ 60% efficiency**. | |
| * This implies a fuel carbon content constant ($C_{{fuel}}$) of approx. **291.6**. | |
| $$ EF_{{scenario}} = \\frac{{291.6}}{{\\eta_{{selected}}}} $$ | |
| *Example:* A 35% efficient turbine results in an emissions factor of ~833 gCO₂e/kWh ($291.6 / 0.35$). | |
| **Total Emissions Formula:** | |
| The final annual emissions ($E_{{total}}$) are calculated as: | |
| $$ E_{{total}} = P_{{GW}} \\times 8,760 \\times CF \\times S_{{gas}} \\times EF_{{scenario}} $$ | |
| * $P_{{GW}}$: AI Power Demand (selected in sidebar). | |
| * $8,760$: Total hours in a year. | |
| * $CF$: **Capacity Factor (90%)**. Fixed to represent the "always-on" baseload nature of AI data centers, which run significantly harder than typical residential usage. | |
| * $S_{{gas}}$: The % of that power demand supplied by Natural Gas (vs. zero-carbon sources or flexibility), selected in sidebar. | |
| **Assumptions:** Assumes only natural gas emissions, and that all other power infrastructure is non-emitting. In reality, even clean energy technologies have emissions, and coal could be used. Assumes only direct emissions, ignores indirect emissions or reductions. | |
| """) |