Skip to content

Conversation

@Junwenlaw
Copy link
Collaborator

8_Zones_Power.zip
TDR with Extreme Periods

New time_domain_reduction folder in src

  • run_time_domain_reduction.jl: master script
  • pre_clustering_tdr.jl for loading and pre-processing
  • clustering_tdr.jl to call algorithms in MacroEnergyTimeReduction package (kmeans, kmedoids, autoencoder_sequential, autoencoder_simultanous etc., autoencoder methods require additional inputs in TDR_settings.json - refer to "TDR_settings_for_autoencoder_method_change_name_before_use.json" in attached in example.
  • post_clustering_tdr.jl for post-processing and period map
  • write_outputs_tdr.jl for time_data.json, period_map.csv and reduced files csv output in a new folder: “system/TDR_results”

New write_time_weights.jl

  • Write the time weight of each period

Modified run_tools.jl

  • Global flag for TDR based on TimeDomainReduction in TDR_settings.json and If TDR is on (flag = 1), go to run_time_domain_reduction.jl script

Modified load_json_inputs

  • Read time series “TDR_path” for assets.json and nodes.json instead of time series “path” if TDR flag = 1

Modified load_tine_data.jl

  • Read time_data.json in system”TDR_Results” folder if TDR flag = 1

How TDR will work:

  • User to create add time series “TDR_path” in assets.json and nodes.json, refer the time series of the system/TDR_results folder (See modified load_json_inputs and refer to attached example)
  • User to create TDR_settings.json file in “system” folder
  • TDR will not run if there is existing “system/TDR_results” folder (Use existing TDR files)
  • If TDR = 0, model will run according to time_data.json file in “system” folder and read “path” of time series in assets.json and nodes.json files
  • If TDR = 1, model will run according to time_data.json file in “system/TDR_Results” folder and read “TDR_path” of time series in assets.json and nodes.json files

Attached Example

  • 8 zones power sector, use "system/TDR_settings.json" to turn on TDR, then run the case to see "system/TDR_Results" created and Macro will use the files there to run the model

Done Checks

  • Checked time weights
  • Compare with Dolphyn TDR – Period map exact match with and without extreme periods!

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement (please add a section below for benchmark results or performance metrics)
  • Other (please describe)

Related Issues

Link to any related issues using one of the following keywords:

  • Fixes #123 - Closes the issue when the PR is merged
  • Closes #123 - Same as Fixes
  • Resolves #123 - Same as Fixes
  • Addresses #123 - References the issue but doesn't close it
  • Related to #123 - For issues that are related but not directly addressed

You can link multiple issues by using multiple lines:

Fixes #123
Addresses #456
Related to #789

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (e.g., docstrings for new functions, updated/new .md files in the docs folder)
  • My changes generate no new warnings
  • I have tested the code to ensure it works as expected
  • New and existing unit tests pass locally with my changes:
julia> using Pkg
julia> Pkg.test("MacroEnergy")

How to test the code

Reference to an example case or a test case that can be run to verify the changes.

Additional context

Add any other context about the PR here. If you have any questions, please contact the maintainers.

TDR with Extreme Periods

New time_domain_reduction folder in src
-	run_time_domain_reduction.jl: master script
-	pre_clustering_tdr.jl for loading and pre-processing
-	clustering_tdr.jl to call algorithms in MacroEnergyTimeReduction package (kmeans, kmedoids, autoencoder_sequential, autoencoder_simultanous etc., autoencoder methods require additional inputs in TDR_settings.json - refer to "TDR_settings_for_autoencoder_method_change_name_before_use.json" in attached in example.
-	post_clustering_tdr.jl for post-processing and period map
-	write_outputs_tdr.jl for time_data.json, period_map.csv and reduced files csv output in a new folder: “system/TDR_results”

New write_time_weights.jl
-	Write the time weight of each period

Modified run_tools.jl
-	Global flag for TDR based on TimeDomainReduction in TDR_settings.json and If TDR is on (flag = 1), go to run_time_domain_reduction.jl  script

Modified load_json_inputs
-	Read time series “TDR_path” for assets.json and nodes.json instead of time series “path” if TDR flag = 1

Modified load_tine_data.jl
-	Read time_data.json in system”TDR_Results” folder if TDR flag = 1

How TDR will work:
-	User to create add time series “TDR_path” in assets.json and nodes.json, refer the time series of the system/TDR_results folder (See modified load_json_inputs and refer to attached example)
-	User to create TDR_settings.json file in “system” folder
-	TDR will not run if there is existing “system/TDR_results” folder (Use existing TDR files)
-	If TDR = 0, model will run according to time_data.json file in “system” folder and read “path” of time series in assets.json and nodes.json files
-	If TDR = 1, model will run according to time_data.json file in “system/TDR_Results” folder and read “TDR_path” of time series in assets.json and nodes.json files

Attached Example
-	8 zones power sector, use "system/TDR_settings.json" to turn on TDR, then run the case to see "system/TDR_Results" created and Macro will use the files there to run the model

Done Checks
-	Checked time weights
-	Compare with Dolphyn TDR – Period map exact match with and without extreme periods!
Utilize CEM output features for clustering, in addition to existing input time series of availability, demand, and fuel prices.

run_subperiod_cases.jl: Run individual subperiods independently to obtain individual CEM results (optimal flow) for each subperiod, and stacked together to a full year series to include in clustering. Each subperiod will be weighted to represent the full model hours. This is like solving 1 representative day or week for the year, using the input time series of the particular day or week.

For example, if we are modeling 24 hours in each subperiod for 1 full year, there will be 365 CEMs to run (can be done in parallel, to implement threads in a next update, similar to Benders approach), and each of the 24 hours in each CEM will have a weight of 365 when solved independently. Note that if we use 168 hours in each subperiod, there will be a 53rd subperiod of 24 hours, but it does not have effect in the clustering, since the TDR script will drop any incomplete last subperiods - Only use 8736 hours for clustering in a 8760 hours timseries if modeling representative weeks with 168 hours each.

Users to specify in TDR_settings.json which output feature to include for TDR, at the commodity and asset level, such as VRE and battery electricity edge flow results

In addition, users can choose to turn on policy or not for each subperiod solve.

The output feature flows will be created in a subperiod_results.csv in the system folder with the other time series for clustering, and loaded in the TDR script for parsing and clustering to choose representative weeks.

In addition, a bug in the TDR script is fixed by ensuring that TDR will not run only if required files exists in addition to the folder, or the TDR will run to generate the required files.

Also updated the solar and wind columns such that it does not identify the edges columns in the parsed dataframe when identifying extreme periods for solar and wind.

The new TDR settings include:
   "ClusterSubperiodResults": 1,
    "ClusterSubperiodFileName": "subperiod_results.csv",
    "Zero_Threshold": 0.1, #This is an optional feature to set a threshold that set all output features value to zero if smaller, to prevent very small values in clustering.

    "SubperiodPolicyConstraints": 1,

    "SubperiodResults" : {
        "Commodities" : {
            "Electricity" : {
                "Include": 1,
                "Assets": {
                    "VRE": 1,
                    "Battery": 1,
                    "ThermalPower": 0,
                    "ThermalPowerCCS": 0,
                    "HydroRes": 0,
                    "MustRun": 0
                }
            },
            "Hydrogen" : {
                "Include": 0,
                "Assets": {
                    "Electrolyzer": 0,
                    "ThermalHydrogen": 0,
                    "ThermalHydrogenCCS": 0,
                    "GasStorage": 0
                }
            }
        }
    }
@Junwenlaw
Copy link
Collaborator Author

TDR_settings.json

Updated TDR_settings.json to run output based TDR, refer to latest commit on details.

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.

1 participant