Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cost calc #30

Closed
wants to merge 177 commits into from
Closed

Cost calc #30

wants to merge 177 commits into from

Conversation

dguittet
Copy link
Collaborator

@dguittet dguittet commented May 3, 2022

Updates to Cost Calculator for #29

Code is currently not working

@barker59

barker59 and others added 30 commits January 8, 2021 07:55
dguittet and others added 25 commits March 16, 2022 08:58
* Adds test_h2_main.py. Modifies h2_main and hopp_for_h2.py for better path compatibility when run from different dir

* Merge dev_merge from bayc into add_tests_h2_main (#2)

* fix if statement for weight_option checking

* update pysam version 2.2.2

* update requirements for new version 0.0.4

* update release notes for v 0.0.4

* update release to 0.0.5 by yanking 0.0.4

* Publish on release actions (#8)

* add conda packaging needs
add version file
update setup.py and README

* import version from package

* revert version get process

* fix version path

Co-authored-by: Darice L Guittet <dguittet@nrel.gov>

* Create ci.yml

* Update requirements.txt

* Update ci.yml

* Update ci.yml

* Update ci.yml

* Update ci.yml

* Battery dispatch (#10)

* open sourcing repo; all 5 examples running

* adding battery dispatch optimization and clustering code

These capabilities do not work in their current state.

* update latest open sourcing repo

* update gitignore to ignore log files

* merge in changes from master

* Revert deletion of battery dispatch scripts

* removed dynamic_voltage_model and main_dispatch

main_dispatch.py is outdated, dynamic_voltage_model.py is a toy model not required for dispatch.

* delete parameters folder

* restore deleted files

* delete accidentally duplicated files

* update to PySAM 2.2.0

* Adding integrated dispatch optimization model, a new battery class using statefulBattery model (storage.py), and a example file to run hybrid with dispatch.  Updated requirements to include Pyomo dependency.  Battery financial model has not be fully integrated.

* Adding normalized price data

* Add ElectricityPrices as Resource and start hybrid_npv.py as optimization example

* modify error messages on ElectricityPrices

* start creating Layout classes

* modify error messages on ElectricityPrices

* Move wind layout functions to WindLayout class; all tests passing

* Updates to dispatch integration

-Added battery Outputs class to store stateful and dispatch outputs
-Added plotting tools for viewing dispatch output
-updated battery surface area calculation (will update again when pySAM updates
-integrated gird prices from site to dispatch

* Update dispatch.py

removed made up price schedule

* Move solar layout functions to SolarLayout class; all tests passing

* Added number of look-ahead periods to dispatch class. Removed numpy dependence in dispatch class.  General clean up.

* Move grid prices from SiteInfo into all the financial models & update examples

* start adding HybridLayout

* added storage kw and kwh getter and setter

* add HybridLayout into HybridSimulation; change cost calculator; rename classes in PowerSources; add tests

* fix tests in hybrid_layout.py

* start flicker addition to HybridLayout

* make inputs and outputs of PySAM models class properties; need to check tests

* nearest flicker map loaded; all tests passing and examples working

* Add flicker loss calculation to hybrid_layout.py

* Update hybrid_npv.py example with layout plotting

* Adds storage cost to CostCalculator

* added simulation clustering to dispatch simulation method

Defaults for clustering have not been vetted!

* Adds storage_installed_cost to total_installed_cost

* changes storage_size to storage_size_mw in cost_calculator

* minor updates formatting

* Fix expected value for test_calculate_installed_costs_per_mw

* Updates expected value for test_calculate_installed_costs

* Add ATBLookup - atb_lookup.py function to look up ATB costs from 2018 - 2050. Modifies create_cost_calculator to accomodate

* Adds test_calculate_installed_costs_per_mw_atb to test ATB functionality

* Updates expected result for test_run_hopp_calc

* Added floris as an option for wind modeling

* Refactoring Dispatch Optimization model

- Split dispatch model by technology
- Combine Pyomo Block to create hybrid dispatch
- Added dispatch tests for each technology
- Added hybrid test with dispatch
- NEED to remove old dispatch full integration
- NEED to implement detailed battery dispatch
- NEED to re-implement clustering

* Adding Detailed battery dispatch

Detailed battery dispatch is not fully integrated. Detailed battery dispatch test will fail.  Working to get non-linear problem to solve with Mindtpy.

* Clean up interface for custom modules

* Convert wind_source.py to use "value" for accessing system model variables

* Rename `get_variable` fxn in PowerSource to `value` similar to that of component models

* Allow timestepping with FLORIS model

* annual_energy_kw to annual_energy

* cleaned up a couple thing before dispatch refactoring

* Refactored battery dispatch types into different classes

- built HybridDispatchBuilderSolver to build and solve dispatch problem
- moved HybridDispatch class which now:
     - links ports and builds arcs between technology dispatch models
     - builds objective function based on variables provided by other dispatch models
- created a Dispatch base class
- created a PowerStorageDispatch class which provides a simple battery dispatch and could be used to model other storage devices
- removed some out dated project files
- created directories for dispatch models

* handle project life in HybridSimulation.simulate

* fix solar layout; rename initialization fx in hybrid layout

* update lifetime input handling for simulation

* Add new optimization classes for OptimizationProblem and OptimizationDriver (base and HOPP)

* add lifetime degradation property; add DOF check in test_dispatch.py and only simulate for 1 year

* move module_specs to class var & add test for battery's simulate_with_dispatch

* change Constraint rule functions from class methods to local functions

* break out hybrid_dispatch_options.py and make Dispatch class instantiation based on RE type more generalized

* reduce number of functions in hybrid_dispatch.py & keep dictionary of variables

* minor re-org in hybrid_dispatch.py and add DOF test

* Rename "solar" objects to "pv" & fix up tests

* some missed conversion from 'solar' to 'pv'

* Added sizing design problem

Additionally,
 - Fixed 1-year simulate() dispatch error for available generation
- Fixed recursion bug when setting battery capacity property

* Added Battery Simple Heuristic Dispatch

- fixed "is" compare
- moved is_test to dispatch options
- added idaes_pse to requirements

* adding heuristic to sizing optimization problem

* updates based on comments

- refactored storage class to battery
- reduced the number of rounded digits between tech models and dispatch from 6 to 4 (To reduce the number of round-off warnings from setting dispatch initial SOC)
- added some comments to dispatch options
- reverted lifecycle rule to a class function so the linear voltage dispatch model can override this method
- refactored simple dispatch heuristic

* Added one cycle battery dispatch heuristic

* update merging of FLORIS module

* use dictionary for battery tech specs

* add floris to requirements.txt

* added floris to requirements

- removed a TODO in heuristic

* Updated pySAM and fixed dispatch test

- reduced assert window to the first 24 periods of dispatch solution
- relaxed assert tolerance

* Update test_dispatch.py

- Compare dispatch power to stateful battery model power only if battery is not on the SOC limits.

* Fix high temps in battery simulation

* update requirements.txt

* update requirements.txt

* Update ci.yml

* Update ci.yml

* Update ci.yml

* Update ci.yml

* remove degrees_of_freedom tests

* comment out where mindtpy_test.py not running

* update test_run_hopp_calc.py

* fix shapely version in requirements.txt

* update test_layout.py

* less precision in test_run_hopp_calc.py

* less precision in test_layout.py.py

* less precision in test_layout.py.py

* add json for inputs for costs & PV

* fixed lifecycle warning

* checking if test on GitHub is configured correctly

* checking dispatch available generation

* fix broken dispatch tests by fixing Pyomo version

* Update ci.yml

* Fix financial calculations and allow CAPEX to be defined in input dictionary

* update example with battery

* Add hybrid_size_grid.py for parametric exploration

* add path

* minor edit to error reporting

* updates for pysam v2.2.3

* minor edits to hybrid_size_grid

* turn off print statement

* om_replacement_cost1 for PySAM v2.2.2

* clean up files before merging

* fix paths

* Clean up old files & examples

* Updated scaling in plot_tools

* Clean up old files & examples

Co-authored-by: WHamilt2 <william.hamilton@nrel.gov>
Co-authored-by: Aaron Barker <barker59@gmail.com>
Co-authored-by: King <jennifer.king@nrel.gov>
Co-authored-by: William Hamilton <34353104+qualand@users.noreply.github.com>

* Delete examples/ENGIE directory

* update requirements.txt

* Update requirements and readme for proper initial setup

* Detailed Financial Runs (#11)

* open sourcing repo; all 5 examples running

* adding battery dispatch optimization and clustering code

These capabilities do not work in their current state.

* update latest open sourcing repo

* update gitignore to ignore log files

* merge in changes from master

* Revert deletion of battery dispatch scripts

* removed dynamic_voltage_model and main_dispatch

main_dispatch.py is outdated, dynamic_voltage_model.py is a toy model not required for dispatch.

* delete parameters folder

* restore deleted files

* delete accidentally duplicated files

* update to PySAM 2.2.0

* Adding integrated dispatch optimization model, a new battery class using statefulBattery model (storage.py), and a example file to run hybrid with dispatch.  Updated requirements to include Pyomo dependency.  Battery financial model has not be fully integrated.

* Adding normalized price data

* Add ElectricityPrices as Resource and start hybrid_npv.py as optimization example

* modify error messages on ElectricityPrices

* start creating Layout classes

* modify error messages on ElectricityPrices

* Move wind layout functions to WindLayout class; all tests passing

* Updates to dispatch integration

-Added battery Outputs class to store stateful and dispatch outputs
-Added plotting tools for viewing dispatch output
-updated battery surface area calculation (will update again when pySAM updates
-integrated gird prices from site to dispatch

* Update dispatch.py

removed made up price schedule

* Move solar layout functions to SolarLayout class; all tests passing

* Added number of look-ahead periods to dispatch class. Removed numpy dependence in dispatch class.  General clean up.

* Move grid prices from SiteInfo into all the financial models & update examples

* start adding HybridLayout

* added storage kw and kwh getter and setter

* add HybridLayout into HybridSimulation; change cost calculator; rename classes in PowerSources; add tests

* fix tests in hybrid_layout.py

* start flicker addition to HybridLayout

* make inputs and outputs of PySAM models class properties; need to check tests

* nearest flicker map loaded; all tests passing and examples working

* Add flicker loss calculation to hybrid_layout.py

* Update hybrid_npv.py example with layout plotting

* Adds storage cost to CostCalculator

* added simulation clustering to dispatch simulation method

Defaults for clustering have not been vetted!

* Adds storage_installed_cost to total_installed_cost

* changes storage_size to storage_size_mw in cost_calculator

* minor updates formatting

* Fix expected value for test_calculate_installed_costs_per_mw

* Updates expected value for test_calculate_installed_costs

* Add ATBLookup - atb_lookup.py function to look up ATB costs from 2018 - 2050. Modifies create_cost_calculator to accomodate

* Adds test_calculate_installed_costs_per_mw_atb to test ATB functionality

* Updates expected result for test_run_hopp_calc

* Added floris as an option for wind modeling

* Refactoring Dispatch Optimization model

- Split dispatch model by technology
- Combine Pyomo Block to create hybrid dispatch
- Added dispatch tests for each technology
- Added hybrid test with dispatch
- NEED to remove old dispatch full integration
- NEED to implement detailed battery dispatch
- NEED to re-implement clustering

* Adding Detailed battery dispatch

Detailed battery dispatch is not fully integrated. Detailed battery dispatch test will fail.  Working to get non-linear problem to solve with Mindtpy.

* Clean up interface for custom modules

* Convert wind_source.py to use "value" for accessing system model variables

* Rename `get_variable` fxn in PowerSource to `value` similar to that of component models

* Allow timestepping with FLORIS model

* annual_energy_kw to annual_energy

* cleaned up a couple thing before dispatch refactoring

* Refactored battery dispatch types into different classes

- built HybridDispatchBuilderSolver to build and solve dispatch problem
- moved HybridDispatch class which now:
     - links ports and builds arcs between technology dispatch models
     - builds objective function based on variables provided by other dispatch models
- created a Dispatch base class
- created a PowerStorageDispatch class which provides a simple battery dispatch and could be used to model other storage devices
- removed some out dated project files
- created directories for dispatch models

* handle project life in HybridSimulation.simulate

* fix solar layout; rename initialization fx in hybrid layout

* update lifetime input handling for simulation

* Add new optimization classes for OptimizationProblem and OptimizationDriver (base and HOPP)

* add lifetime degradation property; add DOF check in test_dispatch.py and only simulate for 1 year

* move module_specs to class var & add test for battery's simulate_with_dispatch

* change Constraint rule functions from class methods to local functions

* break out hybrid_dispatch_options.py and make Dispatch class instantiation based on RE type more generalized

* reduce number of functions in hybrid_dispatch.py & keep dictionary of variables

* minor re-org in hybrid_dispatch.py and add DOF test

* Rename "solar" objects to "pv" & fix up tests

* some missed conversion from 'solar' to 'pv'

* Added sizing design problem

Additionally,
 - Fixed 1-year simulate() dispatch error for available generation
- Fixed recursion bug when setting battery capacity property

* Added Battery Simple Heuristic Dispatch

- fixed "is" compare
- moved is_test to dispatch options
- added idaes_pse to requirements

* adding heuristic to sizing optimization problem

* updates based on comments

- refactored storage class to battery
- reduced the number of rounded digits between tech models and dispatch from 6 to 4 (To reduce the number of round-off warnings from setting dispatch initial SOC)
- added some comments to dispatch options
- reverted lifecycle rule to a class function so the linear voltage dispatch model can override this method
- refactored simple dispatch heuristic

* Added one cycle battery dispatch heuristic

* update merging of FLORIS module

* use dictionary for battery tech specs

* add floris to requirements.txt

* added floris to requirements

- removed a TODO in heuristic

* Updated pySAM and fixed dispatch test

- reduced assert window to the first 24 periods of dispatch solution
- relaxed assert tolerance

* Update test_dispatch.py

- Compare dispatch power to stateful battery model power only if battery is not on the SOC limits.

* Fix high temps in battery simulation

* update requirements.txt

* update requirements.txt

* Update ci.yml

* Update ci.yml

* Update ci.yml

* Update ci.yml

* remove degrees_of_freedom tests

* comment out where mindtpy_test.py not running

* update test_run_hopp_calc.py

* fix shapely version in requirements.txt

* update test_layout.py

* less precision in test_run_hopp_calc.py

* less precision in test_layout.py.py

* less precision in test_layout.py.py

* add json for inputs for costs & PV

* fixed lifecycle warning

* checking if test on GitHub is configured correctly

* checking dispatch available generation

* fix broken dispatch tests by fixing Pyomo version

* Update ci.yml

* Fix financial calculations and allow CAPEX to be defined in input dictionary

* update example with battery

* Add hybrid_size_grid.py for parametric exploration

* add path

* minor edit to error reporting

* updates for pysam v2.2.3

* minor edits to hybrid_size_grid

* turn off print statement

* om_replacement_cost1 for PySAM v2.2.2

* clean up files before merging

* fix paths

* Clean up old files & examples

* Updated scaling in plot_tools

* Clean up old files & examples

* add capacity payments

* remove setuptools_scm from requirements.txt

* fix tests

* add HOPP_examples to .gitignore

* update gitignore

* use absolute paths for examples

* update requirements.txt

* update financial model

* update analysis test results

* fix wind_resource.py to use PySAM converter

* add new financial outputs to hybrid simulation and update example

* fix typos

* Add grid charging to dispatch_options

* default construction financing cost multiplier to 0

* add more financial outputs

* add comments to financial outputs

* fix typo

* update test results

* update tests

* add new outputs for energy sales and purchases

* updates for hybrid simulation to be iterated with different sizes and layouts

* fix test_dispatch.py

* add time limit to dispatch solver

* Fix solar_resource data converter

* fix tests

* rename pv's degradation to dc_degradation

* allow assigning hybrid_plant inputs from dictionaries

* fix logging

* fix logging

* change exception to warning for hybrid_simulation's assign

* assign renamed to assign_fin_inputs and assign_tech_inputs

* minor edits to one_cycle_battery_dispatch_heuristic.py; test results show ~50% less energy revenue than optimized

* edit logging level for console reporting

* fix broken tests

* copy over replacements for battery to grid

* fix assign

* fix if battery statement

* add taxes to grid dispatch

* update test_run_hopp_calc.py expected results

* fix tests

* add financials test to test_hybrid.py

* fix test_reopt timeout reporting

* update pyomo requirement

* fix pv_layout when using Simple parameters

* reopt test fails but no error is returned, print warning

* update logging and error handling

* error handle when system_model has 0 capacity

* error handle when system_model has 0 capacity

* fix battery size = 0 while battery enabled

* add reporting to hybrid_simulation.py

* remove manual battery replacement in battery.py

* fix cf.hybrid calculation

* fix num iterations hybrid_npv.py

* pv_layout error catching

* fix broken tests

* fix pv_layout.py excess_buffer calculation

* modify error reporting for binary search fxns

* fix PV layout to use num_modules as design variable

* make hybrid, wind, and pv layout parameters size-agnostic

* replace exception of pv_layout failure with warning

* allow hybrid_size = 0

Co-authored-by: WHamilt2 <william.hamilton@nrel.gov>
Co-authored-by: Aaron Barker <barker59@gmail.com>
Co-authored-by: King <jennifer.king@nrel.gov>
Co-authored-by: William Hamilton <34353104+qualand@users.noreply.github.com>

* Improves verbosity of ValueError when getting developer key fails (#14)

* Increases verbosity of API value error in keys.py and provides better .env file guidance in Readme.md

* Adds set_nrel_key_dot_env() to site_info.py

* Fix setup.py (#15)

* fix files

* update README.md and keys.py

* Merge branch 'detail_example'

* removed glpk from requirements to fix install.py error

* update simulate_hybrid_wbattery_dispatch.py

* rename solar files in Docs to pv

* Readthedocs updates (#19)

* Update .readthedocs.yml

* add requirements-dev.txt

* update docs for flicker

* fix ReadTheDocs files

* fix _fix_dispatch_model_variables by adding (0, 1) bounds for soc

* Update ci.yml

* update expected_run_all_hybrid_calcs_result.csv

* Update ci.yml

* Update pysam (#17)

* update to pysam v 2.2.4

* fix some battery inputs for pysam v2.2.4

* fix om_expense outputs

* fix warning with log_name

* remove construction financing and add depreciation and debt

* fix test results

* update .gitignore

* fix battery financials for new version

* add battery replacement output

* remove taxes from grid_dispatch.py

* fix test results

* fix test results

* Update ci.yml

* fix test results

* fix test results

* fix test results

* modify solar PTC, add location from paper

* weight hybrid financials by production or cost ratio or evenly; add tax incentives output

* update tests

* fix tests

* add pv_charging_only to dispatch options for ITC qualification

* fix battery financial simulation to not run if 0 battery

* fix test results

* use power_sources for system_capacity_kw property

* rename solar files in Docs to pv

* add battery.rst

* update requirements-dev.txt

* update to pysam 3.0.0

* pvwattsv8 & O&M for battery

* O&M costs for hybrid with tests

* more tests for battery O&M variable cost

* production tax credits test

* fix tests

* fix accidental commit

* update test results

* Fixes csv.writer for Windows (#20)

* Fixes csv.writer for Windows: https://stackoverflow.com/questions/3191528

* Moving to vscode_debug branch

* Fix csv.writer for Windows compatibility

* Merge Attempt

* Update ci.yml

* Merge

* update tests

* fix cost_calculator

* set default dc_degradation

* set default log name for dispatch

* fix reopt test

* fix test_reopt.py

* update test_hybrid.py

* fix cost_calculator

* fix all tests

* Merge ino merge_H2

* update test_run_hopp_calc

* update test_results

* update test_result

Co-authored-by: dguittet <dguittet@nrel.gov>
Co-authored-by: Michael Rossol <18647211+MRossol@users.noreply.github.com>
Co-authored-by: WHamilt2 <william.hamilton@nrel.gov>
Co-authored-by: King <jennifer.king@nrel.gov>
Co-authored-by: William Hamilton <34353104+qualand@users.noreply.github.com>
Co-authored-by: Matthew Boyd <mr.matthew.boyd@gmail.com>
Co-authored-by: Jonathan Martin <94018654+jmartin4nrel@users.noreply.github.com>

* Update paths in run_reopt.py and h2_main.py

* Complete dev_merge -> feature/add_tests_h2_main and fix run issues. N.B. test_h2_main not passing (wrong lcoh)

* Rename H2 Analysis to H2_Analysis. NB test_h2_main.py still not passing

* merges in dev_merge changes including lifetime simulation adjustment

* test_h2_main.py running

* copy H2_Analysis into H2 Analysis

* rename folder

* clean up

* Add docstrings to hopp_for_h2.py. Removes H2 Analysis folder (H2_Analysis remains)

* Revert "Add docstrings to hopp_for_h2.py. Removes H2 Analysis folder (H2_Analysis remains)"

This reverts commit a3b2c87e5ccbdb9895c5eabf879f1b2b7c225d0a, reversing
changes made to c5b1adf396340e3a31efcf300289ca41e03800b3.

* fix merge

* revert merge conflicts

* delete unneeded import

* Updates merge conflicts in h2_main and hopp_for_h2

* Removes uneccessary analysis files and csv results

Co-authored-by: dguittet <dguittet@nrel.gov>
Co-authored-by: Michael Rossol <18647211+MRossol@users.noreply.github.com>
Co-authored-by: WHamilt2 <william.hamilton@nrel.gov>
Co-authored-by: King <jennifer.king@nrel.gov>
Co-authored-by: William Hamilton <34353104+qualand@users.noreply.github.com>
Co-authored-by: Matthew Boyd <mr.matthew.boyd@gmail.com>
Co-authored-by: Jonathan Martin <94018654+jmartin4nrel@users.noreply.github.com>
@dguittet dguittet changed the base branch from master to merge_H2 May 3, 2022 17:17
Base automatically changed from merge_H2 to master May 21, 2022 03:14
@camirmas camirmas closed this Aug 11, 2023
@camirmas camirmas mentioned this pull request Aug 11, 2023
4 tasks
@dguittet dguittet deleted the cost_calc branch August 21, 2023 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants