Skip to content

Commit

Permalink
updated notebook steps
Browse files Browse the repository at this point in the history
  • Loading branch information
bpulluta committed Jul 24, 2024
1 parent 3b0dd90 commit 8d5e983
Show file tree
Hide file tree
Showing 7 changed files with 510,239 additions and 20 deletions.
337 changes: 320 additions & 17 deletions reoptjl/IEDO_custom_table.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,31 @@
"- **Scenario 1: PV only** - Incorporates only a photovoltaic (PV) system.\n",
"- **Scenario 2: PV + BESS** - Includes both a PV system and a Battery Energy Storage System (BESS).\n",
"\n",
"The API responses are stored as JSON files in the outputs folder for subsequent processing.\n"
"The API responses are stored as JSON files in the outputs folder for subsequent processing.\n",
"\n",
"\n",
"## Note:\n",
"Run this section of code first (before running the rest) and copy the Run UUIDs provided at the end as inputs within the main script as `run_uuid_1` and `run_uuid_2`"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Run UUID for Scenario 1: b620d505-3891-47e4-9be2-b7f150a6dd82\n",
"Run UUID for Scenario 2: 9e7b3977-f3a0-4d2b-b371-392e34b34c50\n",
"Results retrieved successfully for Scenario 1.\n",
"Results retrieved successfully for Scenario 2.\n",
"Results saved to response_b620d505-3891-47e4-9be2-b7f150a6dd82.json\n",
"Results saved to response_9e7b3977-f3a0-4d2b-b371-392e34b34c50.json\n"
]
}
],
"source": [
"import pandas as pd\n",
"import json\n",
Expand All @@ -28,7 +45,7 @@
"from collections import defaultdict\n",
"import re\n",
"\n",
"API_KEY = \"gYV8t7d6c5naotp67meIJyJRi6DksKv0VfPSQzEa\" # Replace with your API key\n",
"API_KEY = \"your_key_here\" # Replace with your API key\n",
"\n",
"# following is not necessary but silences warnings:\n",
"# InsecureRequestWarning: Unverified HTTPS request is being made to host 'developer.nrel.gov'. Adding certificate verification is strongly advised.\n",
Expand All @@ -51,7 +68,7 @@
" \"array_type\": 0\n",
" },\n",
" \"ElectricLoad\": {\n",
" \"doe_reference_name\": \"Hospital\",\n",
" \"doe_reference_name\": \"RetailStore\",\n",
" \"annual_kwh\": 100000.0,\n",
" \"year\": 2017\n",
" },\n",
Expand Down Expand Up @@ -99,13 +116,6 @@
" }\n",
"}\n",
"\n",
"# Save the post data to json files\n",
"with open(os.path.join(inputs_path, \"post_1.json\"), 'w') as fp:\n",
" json.dump(post_1, fp)\n",
"\n",
"with open(os.path.join(inputs_path, \"post_2.json\"), 'w') as fp:\n",
" json.dump(post_2, fp)\n",
"\n",
"# Function to POST inputs to the API\n",
"def post_inputs_to_api(post_data, api_key, api_url):\n",
" headers = {'x-api-key': api_key}\n",
Expand Down Expand Up @@ -182,7 +192,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -382,13 +392,306 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Scenario</th>\n",
" <th>PV Size (kW)</th>\n",
" <th>Battery Size (kW)</th>\n",
" <th>Battery Capacity (kWh)</th>\n",
" <th>PV Total Electricity Produced (kWh)</th>\n",
" <th>Grid Purchased Electricity (kWh)</th>\n",
" <th>Electricity Energy Cost ($)</th>\n",
" <th>Electricity Demand Cost ($)</th>\n",
" <th>Utility Fixed Cost($)</th>\n",
" <th>Payback Period (years)</th>\n",
" <th>...</th>\n",
" <th>Year 1 Energy Charge Savings ($)</th>\n",
" <th>Year 1 Demand Charge Savings ($)</th>\n",
" <th>Year 1 Total Electric Bill Savings ($)</th>\n",
" <th>Lifecycle Utility Electricity Cost ($)</th>\n",
" <th>Total Lifecycle Cost ($)</th>\n",
" <th>Net Present Value ($)</th>\n",
" <th>Savings Compared to BAU (%)</th>\n",
" <th>Annual PV Production (kWh)</th>\n",
" <th>PV Curtailed (kWh)</th>\n",
" <th>PV Levelized Cost of Energy ($/kWh)</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>BAU</td>\n",
" <td>-</td>\n",
" <td>-</td>\n",
" <td>-</td>\n",
" <td>-</td>\n",
" <td>100000.00</td>\n",
" <td>9893.91</td>\n",
" <td>7689.50</td>\n",
" <td>1600.0</td>\n",
" <td>-</td>\n",
" <td>...</td>\n",
" <td>-</td>\n",
" <td>-</td>\n",
" <td>-</td>\n",
" <td>13416.92</td>\n",
" <td>160889.6584</td>\n",
" <td>-</td>\n",
" <td>-</td>\n",
" <td>-</td>\n",
" <td>-</td>\n",
" <td>-</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>b620d505-3891-47e4-9be2-b7f150a6dd82</td>\n",
" <td>32.8409</td>\n",
" <td>-</td>\n",
" <td>-</td>\n",
" <td>58151.95</td>\n",
" <td>47041.00</td>\n",
" <td>4587.02</td>\n",
" <td>6340.71</td>\n",
" <td>1600.0</td>\n",
" <td>5.42</td>\n",
" <td>...</td>\n",
" <td>5306.89</td>\n",
" <td>1348.79</td>\n",
" <td>6655.68</td>\n",
" <td>105068.25</td>\n",
" <td>134164.0247</td>\n",
" <td>26725.63</td>\n",
" <td>17</td>\n",
" <td>58151.95</td>\n",
" <td>5192.78</td>\n",
" <td>0.0448</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>9e7b3977-f3a0-4d2b-b371-392e34b34c50</td>\n",
" <td>45.2187</td>\n",
" <td>13.08</td>\n",
" <td>65.62</td>\n",
" <td>80069.28</td>\n",
" <td>26455.65</td>\n",
" <td>2441.63</td>\n",
" <td>2702.23</td>\n",
" <td>1600.0</td>\n",
" <td>5.9</td>\n",
" <td>...</td>\n",
" <td>7452.28</td>\n",
" <td>4987.27</td>\n",
" <td>12439.55</td>\n",
" <td>56558.73</td>\n",
" <td>123789.1177</td>\n",
" <td>37100.54</td>\n",
" <td>23</td>\n",
" <td>80069.28</td>\n",
" <td>4704.679</td>\n",
" <td>0.0448</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>3 rows × 32 columns</p>\n",
"</div>"
],
"text/plain": [
" Scenario PV Size (kW) Battery Size (kW) \\\n",
"0 BAU - - \n",
"1 b620d505-3891-47e4-9be2-b7f150a6dd82 32.8409 - \n",
"2 9e7b3977-f3a0-4d2b-b371-392e34b34c50 45.2187 13.08 \n",
"\n",
" Battery Capacity (kWh) PV Total Electricity Produced (kWh) \\\n",
"0 - - \n",
"1 - 58151.95 \n",
"2 65.62 80069.28 \n",
"\n",
" Grid Purchased Electricity (kWh) Electricity Energy Cost ($) \\\n",
"0 100000.00 9893.91 \n",
"1 47041.00 4587.02 \n",
"2 26455.65 2441.63 \n",
"\n",
" Electricity Demand Cost ($) Utility Fixed Cost($) Payback Period (years) \\\n",
"0 7689.50 1600.0 - \n",
"1 6340.71 1600.0 5.42 \n",
"2 2702.23 1600.0 5.9 \n",
"\n",
" ... Year 1 Energy Charge Savings ($) Year 1 Demand Charge Savings ($) \\\n",
"0 ... - - \n",
"1 ... 5306.89 1348.79 \n",
"2 ... 7452.28 4987.27 \n",
"\n",
" Year 1 Total Electric Bill Savings ($) \\\n",
"0 - \n",
"1 6655.68 \n",
"2 12439.55 \n",
"\n",
" Lifecycle Utility Electricity Cost ($) Total Lifecycle Cost ($) \\\n",
"0 13416.92 160889.6584 \n",
"1 105068.25 134164.0247 \n",
"2 56558.73 123789.1177 \n",
"\n",
" Net Present Value ($) Savings Compared to BAU (%) \\\n",
"0 - - \n",
"1 26725.63 17 \n",
"2 37100.54 23 \n",
"\n",
" Annual PV Production (kWh) PV Curtailed (kWh) \\\n",
"0 - - \n",
"1 58151.95 5192.78 \n",
"2 80069.28 4704.679 \n",
"\n",
" PV Levelized Cost of Energy ($/kWh) \n",
"0 - \n",
"1 0.0448 \n",
"2 0.0448 \n",
"\n",
"[3 rows x 32 columns]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[\n",
" {\n",
" \"index\": 0,\n",
" \"Scenario\": \"BAU\",\n",
" \"PV Size (kW)\": \"-\",\n",
" \"Battery Size (kW)\": \"-\",\n",
" \"Battery Capacity (kWh)\": \"-\",\n",
" \"PV Total Electricity Produced (kWh)\": \"-\",\n",
" \"Grid Purchased Electricity (kWh)\": 100000.0,\n",
" \"Electricity Energy Cost ($)\": 9893.91,\n",
" \"Electricity Demand Cost ($)\": 7689.5,\n",
" \"Utility Fixed Cost($)\": 1600.0,\n",
" \"Payback Period (years)\": \"-\",\n",
" \"Gross Capital Cost ($)\": \"-\",\n",
" \"CO2 Emissions (tonnes)\": 4.2,\n",
" \"Year 1 Utility Savings (%)\": \"-\",\n",
" \"RE Penetration (%)\": \"-\",\n",
" \"Annual CO2 Emissions (Tons)\": 4.2,\n",
" \"Lifecycle CO2 Emissions (Tons)\": 84.0,\n",
" \"Lifecycle CO2 Reduction (%)\": \"-\",\n",
" \"Year 1 Electric Grid Purchases (kWh)\": 100000.0,\n",
" \"Year 1 Energy Charges ($)\": 9893.91,\n",
" \"Year 1 Demand Charges ($)\": 7689.5,\n",
" \"Year 1 Fixed Cost Charges ($)\": 1600.0,\n",
" \"Year 1 Total Electric Bill Costs ($)\": 19183.41,\n",
" \"Year 1 Energy Charge Savings ($)\": \"-\",\n",
" \"Year 1 Demand Charge Savings ($)\": \"-\",\n",
" \"Year 1 Total Electric Bill Savings ($)\": \"-\",\n",
" \"Lifecycle Utility Electricity Cost ($)\": 13416.92,\n",
" \"Total Lifecycle Cost ($)\": 160889.6584,\n",
" \"Net Present Value ($)\": \"-\",\n",
" \"Savings Compared to BAU (%)\": \"-\",\n",
" \"Annual PV Production (kWh)\": \"-\",\n",
" \"PV Curtailed (kWh)\": \"-\",\n",
" \"PV Levelized Cost of Energy ($/kWh)\": \"-\"\n",
" },\n",
" {\n",
" \"index\": 1,\n",
" \"Scenario\": \"b620d505-3891-47e4-9be2-b7f150a6dd82\",\n",
" \"PV Size (kW)\": 32.8409,\n",
" \"Battery Size (kW)\": \"-\",\n",
" \"Battery Capacity (kWh)\": \"-\",\n",
" \"PV Total Electricity Produced (kWh)\": 58151.95,\n",
" \"Grid Purchased Electricity (kWh)\": 47041.0,\n",
" \"Electricity Energy Cost ($)\": 4587.02,\n",
" \"Electricity Demand Cost ($)\": 6340.71,\n",
" \"Utility Fixed Cost($)\": 1600.0,\n",
" \"Payback Period (years)\": 5.42,\n",
" \"Gross Capital Cost ($)\": 24182.6258,\n",
" \"CO2 Emissions (tonnes)\": 3.309,\n",
" \"Year 1 Utility Savings (%)\": 35,\n",
" \"RE Penetration (%)\": 53,\n",
" \"Annual CO2 Emissions (Tons)\": 3.309,\n",
" \"Lifecycle CO2 Emissions (Tons)\": 66.18,\n",
" \"Lifecycle CO2 Reduction (%)\": 21,\n",
" \"Year 1 Electric Grid Purchases (kWh)\": 47041.0,\n",
" \"Year 1 Energy Charges ($)\": 4587.02,\n",
" \"Year 1 Demand Charges ($)\": 6340.71,\n",
" \"Year 1 Fixed Cost Charges ($)\": 1600.0,\n",
" \"Year 1 Total Electric Bill Costs ($)\": 12527.73,\n",
" \"Year 1 Energy Charge Savings ($)\": 5306.889999999999,\n",
" \"Year 1 Demand Charge Savings ($)\": 1348.79,\n",
" \"Year 1 Total Electric Bill Savings ($)\": 6655.68,\n",
" \"Lifecycle Utility Electricity Cost ($)\": 105068.25,\n",
" \"Total Lifecycle Cost ($)\": 134164.0247,\n",
" \"Net Present Value ($)\": 26725.63,\n",
" \"Savings Compared to BAU (%)\": 17,\n",
" \"Annual PV Production (kWh)\": 58151.95,\n",
" \"PV Curtailed (kWh)\": 5192.779999999999,\n",
" \"PV Levelized Cost of Energy ($/kWh)\": 0.0448\n",
" },\n",
" {\n",
" \"index\": 2,\n",
" \"Scenario\": \"9e7b3977-f3a0-4d2b-b371-392e34b34c50\",\n",
" \"PV Size (kW)\": 45.2187,\n",
" \"Battery Size (kW)\": 13.08,\n",
" \"Battery Capacity (kWh)\": 65.62,\n",
" \"PV Total Electricity Produced (kWh)\": 80069.28,\n",
" \"Grid Purchased Electricity (kWh)\": 26455.65,\n",
" \"Electricity Energy Cost ($)\": 2441.63,\n",
" \"Electricity Demand Cost ($)\": 2702.23,\n",
" \"Utility Fixed Cost($)\": 1600.0,\n",
" \"Payback Period (years)\": 5.9,\n",
" \"Gross Capital Cost ($)\": 60465.457,\n",
" \"CO2 Emissions (tonnes)\": 2.353,\n",
" \"Year 1 Utility Savings (%)\": 65,\n",
" \"RE Penetration (%)\": 74,\n",
" \"Annual CO2 Emissions (Tons)\": 2.353,\n",
" \"Lifecycle CO2 Emissions (Tons)\": 47.06,\n",
" \"Lifecycle CO2 Reduction (%)\": 44,\n",
" \"Year 1 Electric Grid Purchases (kWh)\": 26455.65,\n",
" \"Year 1 Energy Charges ($)\": 2441.63,\n",
" \"Year 1 Demand Charges ($)\": 2702.23,\n",
" \"Year 1 Fixed Cost Charges ($)\": 1600.0,\n",
" \"Year 1 Total Electric Bill Costs ($)\": 6743.860000000001,\n",
" \"Year 1 Energy Charge Savings ($)\": 7452.28,\n",
" \"Year 1 Demand Charge Savings ($)\": 4987.27,\n",
" \"Year 1 Total Electric Bill Savings ($)\": 12439.55,\n",
" \"Lifecycle Utility Electricity Cost ($)\": 56558.73,\n",
" \"Total Lifecycle Cost ($)\": 123789.1177,\n",
" \"Net Present Value ($)\": 37100.54,\n",
" \"Savings Compared to BAU (%)\": 23,\n",
" \"Annual PV Production (kWh)\": 80069.28,\n",
" \"PV Curtailed (kWh)\": 4704.679000000002,\n",
" \"PV Levelized Cost of Energy ($/kWh)\": 0.0448\n",
" }\n",
"]\n"
]
}
],
"source": [
"def main():\n",
" run_uuid_1 = \"0ea46c21-0076-4437-98b9-f1d3f4d5255d\"\n",
" run_uuid_2 = \"c9835dac-7ff7-43b1-9676-6bd135e3d167\"\n",
" run_uuid_1 = \"b620d505-3891-47e4-9be2-b7f150a6dd82\"\n",
" run_uuid_2 = \"9e7b3977-f3a0-4d2b-b371-392e34b34c50\"\n",
"\n",
" run_uuids = [run_uuid_1, run_uuid_2]\n",
"\n",
Expand Down
Loading

0 comments on commit 8d5e983

Please sign in to comment.