|
| 1 | +# SPDX-FileCopyrightText: 2022-2025 UChicago Argonne, LLC |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | + |
| 4 | +""" |
| 5 | +This example demonstrates how to use WATTS to run an A-LEAF calculation. |
| 6 | +""" |
| 7 | + |
| 8 | +import watts |
| 9 | +from pathlib import Path |
| 10 | +import pandas as pd |
| 11 | + |
| 12 | +params = watts.Parameters() |
| 13 | + |
| 14 | + |
| 15 | +fuel_price = { |
| 16 | + 2022: 0.62, 2023: 0.62, 2024: 0.62, 2025: 0.62, 2026: 0.62, 2027: 0.62, |
| 17 | + 2028: 0.63, 2029: 0.63, 2030: 0.63, 2031: 0.76, 2032: 0.76, 2033: 0.76, |
| 18 | + 2034: 0.76, 2035: 0.76, 2036: 0.77, 2037: 0.77, 2038: 0.77, 2039: 0.77, |
| 19 | + 2040: 0.77, 2041: 0.78, 2042: 0.78, 2043: 0.78, 2044: 0.78, 2045: 0.78, |
| 20 | + 2046: 0.79, 2047: 0.79, 2048: 0.79, 2049: 0.79, 2050: 0.79, 2051: 0.80, |
| 21 | + 2052: 0.80, 2053: 0.80, 2054: 0.80, 2055: 0.80, 2056: 0.81, 2057: 0.81, |
| 22 | + 2058: 0.81, 2059: 0.81, 2060: 0.81 |
| 23 | +} |
| 24 | + |
| 25 | + |
| 26 | +# Set nuclear prices from reference and calculated growth |
| 27 | +starting_year = 2031 |
| 28 | +starting_price = 0.76 |
| 29 | + |
| 30 | +# Compute prices dynamically for years after the starting year |
| 31 | +growth_rates = {year: 1.0028 if year <= 2050 else 1.057 for year in range(starting_year + 1, 2061)} |
| 32 | +computed_prices = {starting_year: starting_price} |
| 33 | +for year in range(starting_year + 1, 2061): |
| 34 | + prev_price = computed_prices[year - 1] |
| 35 | + computed_prices[year] = round(prev_price * growth_rates[year], 3) |
| 36 | + |
| 37 | +fuel_price.update(computed_prices) |
| 38 | + |
| 39 | +# Initialize parameters and pass the fuel price dictionary |
| 40 | +params = watts.Parameters() |
| 41 | +params['fuel_price'] = fuel_price |
| 42 | +# Display parameter summary |
| 43 | +params.show_summary(show_metadata=True, sort_by='key') |
| 44 | + |
| 45 | +# Set default path for results |
| 46 | +results_path = Path.cwd() / 'results' |
| 47 | +results_path.mkdir(exist_ok=True, parents=True) |
| 48 | +watts.Database.set_default_path(results_path) |
| 49 | + |
| 50 | +# Create ALEAF plugin |
| 51 | +# aleaf_plugin = watts.PluginALEAF('Fuel.txt', extra_templates={'Simulation Configuration': 'Simulation Configuration.txt'}) |
| 52 | +aleaf_plugin = watts.PluginALEAF('Fuel.txt') |
| 53 | +# Run ALEAF |
| 54 | +aleaf_result = aleaf_plugin(params) |
| 55 | +print('ALEAF simulation completed.') |
| 56 | + |
| 57 | +# Get the technology summary |
| 58 | +techsummary = aleaf_result.csv_data |
| 59 | +# keep only the capacity columns |
| 60 | +techsummary = techsummary[['Year', 'UnitGroup', 'Unit_Type', 'Fuel', 'ICAP', 'ICap_New', 'ICap_Ret']] |
| 61 | + |
| 62 | +# group the technology summary by year and fuel |
| 63 | +grouped_df = techsummary.groupby(['Year','Fuel']).sum() |
| 64 | +# print out the grouped dataframe |
| 65 | +print(grouped_df) |
| 66 | + |
| 67 | + |
0 commit comments