-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
78 changed files
with
91,317 additions
and
78 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,312 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "f4e7d0fc", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import sys\n", | ||
"sys.path.append('../../src')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "69913c07", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import pandas\n", | ||
"import numpy\n", | ||
"from energiapy.components.temporal_scale import TemporalScale\n", | ||
"from energiapy.components.resource import Resource, VaryingResource\n", | ||
"from energiapy.components.process import Process, ProcessMode, VaryingProcess\n", | ||
"from energiapy.components.material import Material\n", | ||
"from energiapy.components.location import Location\n", | ||
"from energiapy.components.scenario import Scenario\n", | ||
"from energiapy.components.result import Result\n", | ||
"from energiapy.model.formulate import formulate, Constraints, Objective\n", | ||
"from energiapy.plot import plot_results, plot_scenario\n", | ||
"from energiapy.plot.plot_results import CostY, CostX\n", | ||
"from energiapy.model.solve import solve" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "26c05ddf", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"scales=TemporalScale(discretization_list=[1]) " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"id": "8d2abe06", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"Biomass= Resource(name='Biomass', price=36.11, cons_max= 10**10, basis='GJ', label='Biomass') #table 2\n", | ||
"\n", | ||
"GridPower = Resource(name='GridPower', cons_max = 10**10, price=9.72, basis='GJ', label='Grid Electricity')\n", | ||
"\n", | ||
"NG = Resource(name='NG', price= 8.89, cons_max= 10*10, basis='GJ', label='Natural gas')\n", | ||
"Power=Resource(name='Power', basis='kW',label='Electrical Power')\n", | ||
"Heat=Resource(name='Heat', basis='kW',label='Heat Power')\n", | ||
"\n", | ||
"CO2_Vent = Resource(name='CO2_Vent', sell=True, basis='tons', label='Carbon dioxide')\n", | ||
"\n", | ||
"Solar = Resource(name = 'Solar', cons_max=10**10, basis ='GJ', label ='Solar energy') \n", | ||
"Wind = Resource(name = 'Wind', cons_max=10**10, basis ='GJ', label ='Wind energy')\n", | ||
"\n", | ||
"Lighting = Resource(name='Lighting', demand=True, basis='kW',label='Lighting')\n", | ||
"Refrigeration = Resource(name='Refrigeration', demand=True, basis='kW',label='Refrigeration') \n", | ||
"Heating = Resource(name='Heating', demand=True, basis='kW',label='Heating')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"id": "79b7479d", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"ST= Process(name='BM_ST', conversion={Biomass: -1, Power: 277.78*0.68, CO2_Vent:100},capex=250, fopex=15,\n", | ||
" prod_min=100, prod_max=1000000, label='Biomass ST', basis='PJ') #table 3 \n", | ||
"\n", | ||
"\n", | ||
"CHP= Process(name='NG_CHP', conversion={NG: -1, Power: 277.78*0.44, CO2_Vent: 56, Heat: 277.78*0.28},\n", | ||
" capex=500, fopex=15, prod_max=1000000, prod_min=800, label='Natural Gas CHP', basis='PJ')\n", | ||
"\n", | ||
"\n", | ||
"PV= Process(name='PV', conversion={Solar: -1, Power: 277.78*0.09}, capex=2000, fopex = 500, \n", | ||
" prod_max=300, prod_min=10, label='Solar PV', basis='kW')\n", | ||
"\n", | ||
"\n", | ||
"WF= Process(name='WF',conversion={Wind: -1, Power: 277.78*0.22}, capex=2000, fopex=1200,\n", | ||
" prod_max=500, prod_min=10, label='Wind Farm', basis='kW') \n", | ||
"\n", | ||
"\n", | ||
"Grid = Process(name = 'Grid', conversion = {GridPower:-1, Power:277.78, CO2_Vent:90}, \n", | ||
" basis = 'PJ', label = 'Grid Electricity', prod_max = 1000)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"id": "4c848748", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"Refrigerator = Process(name = 'Refrigerator', conversion = {Power:-1, Refrigeration:1*3}, capex = 70, vopex = 4, \n", | ||
" basis = 'kW', label = 'Refrigerator', prod_max = 1000)\n", | ||
"\n", | ||
"LED = Process(name = 'LED', conversion = {Power:-1, Lighting:1*0.8}, capex = 10, vopex = 1, \n", | ||
" basis = 'kW', label = 'LED', prod_max = 1000)\n", | ||
"\n", | ||
"Heater = Process(name = 'Heater', conversion = {Heat:-1, Heating:1*0.85}, capex = 30, vopex = 3, \n", | ||
" basis = 'kW', label = 'Heater', prod_max = 1000)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"id": "3d961b80", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"place = Location(name = 'place', processes = {ST, CHP, PV, WF, Grid, Refrigerator, LED, Heater}, \n", | ||
" scales = scales, label = 'College Station')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"id": "24221c99", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"scenario= Scenario(name='scenario', network=place, \n", | ||
" demand= {place:{Heating:100, Lighting:200, Refrigeration:1000}},\n", | ||
" network_scale_level=0,scheduling_scale_level=0, scales=scales, \n", | ||
" label='scenario', demand_scale_level = 0)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 16, | ||
"id": "e705312e", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"constraint process capex\n", | ||
"constraint process fopex\n", | ||
"constraint process vopex\n", | ||
"constraint process incidental\n", | ||
"constraint production mode\n", | ||
"constraint inventory balance\n", | ||
"constraint storage facility\n", | ||
"constraint production facility\n", | ||
"constraint min production facility\n", | ||
"constraint min storage facility\n", | ||
"constraint demand\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"lp=formulate(scenario=scenario, constraints=\n", | ||
" {\n", | ||
" Constraints.COST,\n", | ||
" Constraints.PRODUCTION,\n", | ||
" Constraints.RESOURCE_BALANCE,\n", | ||
" Constraints.INVENTORY,\n", | ||
" Constraints.NETWORK,\n", | ||
" Constraints.DEMAND})" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 17, | ||
"id": "b400feeb", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"C : Resource Consumption\n", | ||
" Size=5, Index=C_index\n", | ||
" Key : Lower : Value : Upper : Fixed : Stale : Domain\n", | ||
" ('place', 'Biomass', 0) : 0 : None : None : False : True : NonNegativeReals\n", | ||
" ('place', 'GridPower', 0) : 0 : None : None : False : True : NonNegativeReals\n", | ||
" ('place', 'NG', 0) : 0 : None : None : False : True : NonNegativeReals\n", | ||
" ('place', 'Solar', 0) : 0 : None : None : False : True : NonNegativeReals\n", | ||
" ('place', 'Wind', 0) : 0 : None : None : False : True : NonNegativeReals\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"lp.C.pprint()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 18, | ||
"id": "2ba52357", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from pyomo.environ import Objective\n", | ||
"\n", | ||
"lp.objective = Objective(expr = sum(lp.C['place', resource_, 0] for resource_ in lp.resources_purch))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 19, | ||
"id": "c8bf390b", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Set parameter QCPDual to value 1\n", | ||
"Gurobi Optimizer version 10.0.2 build v10.0.2rc0 (win64)\n", | ||
"\n", | ||
"CPU model: Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz, instruction set [SSE2|AVX|AVX2]\n", | ||
"Thread count: 4 physical cores, 8 logical processors, using up to 8 threads\n", | ||
"\n", | ||
"Optimize a model with 148 rows, 143 columns and 291 nonzeros\n", | ||
"Model fingerprint: 0xd615be88\n", | ||
"Variable types: 135 continuous, 8 integer (8 binary)\n", | ||
"Coefficient statistics:\n", | ||
" Matrix range [8e-01, 1e+06]\n", | ||
" Objective range [1e+00, 1e+00]\n", | ||
" Bounds range [1e+00, 1e+00]\n", | ||
" RHS range [1e+02, 1e+10]\n", | ||
"Warning: Model contains large rhs\n", | ||
" Consider reformulating model or setting NumericFocus parameter\n", | ||
" to avoid numerical issues.\n", | ||
"Presolve removed 148 rows and 143 columns\n", | ||
"Presolve time: 0.00s\n", | ||
"Presolve: All rows and columns removed\n", | ||
"\n", | ||
"Explored 0 nodes (0 simplex iterations) in 0.01 seconds (0.00 work units)\n", | ||
"Thread count was 1 (of 8 available processors)\n", | ||
"\n", | ||
"Solution count 1: 2.94704 \n", | ||
"\n", | ||
"Optimal solution found (tolerance 1.00e-04)\n", | ||
"Best objective 2.947035247247e+00, best bound 2.947035247247e+00, gap 0.0000%\n", | ||
"WARNING: Cannot get duals for MIP.\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"results=solve(scenario= scenario, instance=lp, solver='gurobi', name='lp')\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 20, | ||
"id": "99ac9d0a", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"C : Resource Consumption\n", | ||
" Size=5, Index=C_index\n", | ||
" Key : Lower : Value : Upper : Fixed : Stale : Domain\n", | ||
" ('place', 'Biomass', 0) : 0 : 0.0 : None : False : False : NonNegativeReals\n", | ||
" ('place', 'GridPower', 0) : 0 : 1.4344423059741573 : None : False : False : NonNegativeReals\n", | ||
" ('place', 'NG', 0) : 0 : 1.5125929412732766 : None : False : False : NonNegativeReals\n", | ||
" ('place', 'Solar', 0) : 0 : 0.0 : None : False : False : NonNegativeReals\n", | ||
" ('place', 'Wind', 0) : 0 : 0.0 : None : False : False : NonNegativeReals\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"lp.C.pprint()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "bdf53815", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.