Reading Input Files
GenX.get_systemfiles_path — Method
get_systemfiles_path(setup::Dict, TDR_directory::AbstractString, path::AbstractString)Determine the directory based on the setup parameters.
This function checks if the TimeDomainReduction setup parameter is equal to 1 and if time domain reduced files exist in the data directory. If the condition is met, it returns the path to the TDR_results data directory. Otherwise, it returns the system directory specified in the setup.
Parameters:
- setup: Dict{String, Any} - The GenX settings parameters containing TimeDomainReduction and SystemFolder information.
- TDR_directory: String - The data directory where files are located.
- path: String - Path to the case folder.
Returns:
- String: The directory path based on the setup parameters.
GenX.load_inputs — Method
load_inputs(setup::Dict,path::AbstractString)Loads various data inputs from multiple input .csv files in path directory and stores variables in a Dict (dictionary) object for use in model() function
inputs: setup - dict object containing setup parameters path - string path to working directory
returns: Dict (dictionary) object containing all data inputs
Fuels Data
GenX.load_fuels_data! — Method
load_fuels_data!(setup::Dict, path::AbstractString, inputs::Dict)Read input parameters related to fuel costs and CO$_2$ content of fuels
Generators Input Data
GenX._get_policyfile_info — Method
_get_policyfile_info()Internal function to get policy file information.
Returns
policyfile_info (NamedTuple): A tuple containing policy file information.GenX._get_resource_info — Method
_get_resource_info()Internal function to get resource information (filename and GenX type) for each type of resource available in GenX.
resource_info (NamedTuple): A tuple containing resource information.GenX._get_summary_map — Method
_get_summary_map()Internal function to get a map of GenX resource type their corresponding names in the summary table.
GenX.add_attributes_to_resource! — Method
add_attributes_to_resource!(resource::AbstractResource, new_symbols::Vector{Symbol}, new_values::T) where T <: DataFrameRowAdds a set of new attributes (names and corresponding values) to a resource. The resource is modified in-place.
Arguments
resource::AbstractResource: The resource to add attributes to.new_symbols::Vector{Symbol}: Vector of symbols containing the names of the new attributes.new_values::DataFrameRow: DataFrameRow containing the values of the new attributes.
GenX.add_df_to_resources! — Method
add_df_to_resources!(resources::Vector{<:AbstractResource}, module_in::DataFrame)Adds the data contained in a DataFrame to a vector of resources. Each row in the DataFrame corresponds to a resource. If the name of the resource in the DataFrame matches a name of a resource in the model, all the columns of that DataFrameRow are added as new attributes to the corresponding resource.
Arguments
resources::Vector{<:AbstractResource}: A vector of resources.module_in::DataFrame: The dataframe to add.
GenX.add_id_to_resource_df! — Method
add_id_to_resource_df!(df::DataFrame, indices::AbstractVector)Adds a new column 'id' to the DataFrame with the provided resource indices. The dataframe is modified in-place.
Arguments
df::DataFrame: The input DataFrame to which the indices are to be added.indices::AbstractVector: The array of indices to be added as a new column.
GenX.add_module_to_resources! — Method
add_module_to_resources!(resources::Vector{<:AbstractResource}, module_in::DataFrame)Reads module dataframe and adds columns as new attributes to the resources in the model if the resource name in the module file matches a resource name in the model. The module file is assumed to have a column named "resource" containing the resource names.
Arguments
resources::Vector{<:AbstractResource}: A vector of resources.module_in::DataFrame: The dataframe with the columns to add to the resources.
GenX.add_modules_to_resources! — Method
add_modules_to_resources!(resources::Vector{<:AbstractResource}, setup::Dict, resources_path::AbstractString)Reads module dataframes, loops over files and adds columns as new attributes to the resources in the model.
Arguments
resources::Vector{<:AbstractResource}: A vector of resources.setup (Dict): A dictionary containing GenX settings.resources_path::AbstractString: The path to the resources folder.
GenX.add_policies_to_resources! — Method
add_policies_to_resources!(resources::Vector{<:AbstractResource}, resources_path::AbstractString)Reads policy files and adds policies-related attributes to resources in the model.
Arguments
resources::Vector{<:AbstractResource}: Vector of resources in the model.resources_path::AbstractString: The path to the resources folder.
GenX.add_policy_to_resources! — Method
add_policy_to_resources!(resources::Vector{<:AbstractResource}, path::AbstractString, filename::AbstractString)Loads a single policy file and adds the columns as new attributes to resources in the model if the resource name in the policy file matches a resource name in the model. The policy file is assumed to have a column named "resource" containing the resource names.
Arguments
resources::Vector{<:AbstractResource}: A vector of resources.path::AbstractString: The path to the policy file.filename::AbstractString: The name of the policy file.
GenX.add_resources_to_input_data! — Method
add_resources_to_input_data!(inputs::Dict, setup::Dict, case_path::AbstractString, gen::Vector{<:AbstractResource})Adds resources to the inputs Dict with the key "RESOURCES" together with sevaral sets of resource indices that are used inside GenX to construct the optimization problem. The inputs Dict is modified in-place.
Arguments
inputs (Dict): Dictionary to store the GenX input data.setup (Dict): Dictionary containing GenX settings.case_path (AbstractString): Path to the case.gen (Vector{<:AbstractResource}): Array of GenX resources.
GenX.check_mustrun_reserve_contribution — Method
check_mustrun_reserve_contribution(r::AbstractResource)Make sure that a MUSTRUN resource has RegMax and Rsv_Max set to 0 (since they cannot contribute to reserves).
GenX.check_resource — Method
check_resource(setup::Dict, resources::Vector{T})::Vector{String} where T <: AbstractResourceValidate the consistency of a vector of GenX resources Reports any errors/warnings as a vector of messages.
GenX.compute_resource_indices — Method
compute_resource_indices(resources_in::DataFrame, offset::Int64)Computes the indices for the resources loaded from a single dataframe by shifting the indices by an offset value.
Arguments
resources_in::DataFrame: The input DataFrame containing the resources.offset::Int64: The offset value to be added to the indices.
Returns
UnitRange{Int64}: An array of indices.
GenX.create_resource_array — Function
create_resource_array(resource_folder::AbstractString, resources_info::NamedTuple, scale_factor::Float64=1.0)Construct the array of resources from multiple files of different types located in the specified resource_folder. The resources_info NamedTuple contains the filename and GenX type for each type of resource available in GenX.
Arguments
resource_folder::AbstractString: The path to the folder containing the resource files.resources_info::NamedTuple: A NamedTuple that maps a resource type to its filename and GenX type.scale_factor::Float64: A scaling factor to adjust the attributes of the resources (default: 1.0).
Returns
Vector{<:AbstractResource}: An array of GenX resources.
Raises
Error: If no resources data is found. Check the data path or the configuration file "genx_settings.yml" inside Settings.
GenX.create_resource_array — Method
create_resource_array(setup::Dict, resources_path::AbstractString)Function that loads and scales resources data from folder specified in resources_path and returns an array of GenX resources.
Arguments
setup (Dict): Dictionary containing GenX settings.resources_path (AbstractString): The path to the resources folder.
Returns
resources (Vector{<:AbstractResource}): An array of scaled resources.
GenX.create_resources_sametype — Method
create_resources_sametype(resource_in::DataFrame, ResourceType)This function takes a DataFrame resource_in and a GenX ResourceType type, and converts the DataFrame to an array of AbstractResource of the specified type.
Arguments
resource_in::DataFrame: The input DataFrame containing the resources belonging to a specific type.ResourceType: The GenX type of resources to be converted to.
Returns
resources::Vector{ResourceType}: An array of resources of the specified type.
GenX.dataframerow_to_dict — Method
dataframerow_to_dict(dfr::DataFrameRow)Converts a DataFrameRow to a Dict.
Arguments
dfr::DataFrameRow: The DataFrameRow to be converted.
Returns
Dict: Dictionary containing the DataFrameRow data.
GenX.load_multi_fuels_data! — Method
load_multi_fuels_data!(inputs::Dict, gen::Vector{<:AbstractResource}, setup::Dict, path::AbstractString)Function for reading input parameters related to multi fuels
GenX.load_resource_df — Method
load_resource_df(path::AbstractString, scale_factor::Float64, resource_type::Type)Function to load and scale the dataframe of a given resource.
Arguments
path::AbstractString: Path to the resource dataframe.scale_factor::Float64: Scaling factor for the resource data.resource_type::Type: GenX type of the resource.
Returns
resource_in::DataFrame: The loaded and scaled resource data.
GenX.load_resources_data! — Method
load_resources_data!(inputs::Dict, setup::Dict, case_path::AbstractString, resources_path::AbstractString)This function loads resources data from the resources_path folder and create the GenX data structures and add them to the inputs Dict.
Arguments
inputs (Dict): A dictionary to store the input data.setup (Dict): A dictionary containing GenX settings.case_path (AbstractString): The path to the case folder.resources_path (AbstractString): The path to the case resources folder.
Raises: DeprecationWarning: If the Generators_data.csv file is found, a deprecation warning is issued, together with an error message.
GenX.process_piecewisefuelusage! — Method
process_piecewisefuelusage!(setup::Dict, case_path::AbstractString, gen::Vector{<:AbstractResource}, inputs::Dict)Reads piecewise fuel usage data from the vector of generators, create a PWFU_data that contain processed intercept and slope (i.e., heat rate) and add them to the inputs dictionary.
Arguments
setup::Dict: The dictionary containing the setup parameterscase_path::AbstractString: The path to the case foldergen::Vector{<:AbstractResource}: The vector of generators in the modelinputs::Dict: The dictionary containing the input data
GenX.scale_allamcycle_data! — Method
scale_allamcycle_data!(allamcycle_in::DataFrame, scale_factor::Float64)Scales allamcycle attributes in-place if necessary. Generally, these scalings converts energy and power units from MW to GW and /MW to M/GW. Both are done by dividing the values by 1000. See documentation for descriptions of each column being scaled.
Arguments
allamcycle_in(DataFrame): A dataframe containing data for flexible ccs (e.g, AllamCycle or
storage coupled NGCC-CCS)
scale_factor(Float64): A scaling factor for energy and currency units.
GenX.scale_columns! — Method
scale_columns!(df::DataFrame, columns_to_scale::Vector{Symbol}, scale_factor::Float64)Scales in-place the columns in columns_to_scale of a dataframe df by a scale_factor.
Arguments
df(DataFrame): A dataframe containing data to scale.columns_to_scale(Vector{Symbol}): A vector of column names to scale.scale_factor(Float64): A scaling factor for energy and currency units.
GenX.scale_resources_data! — Method
scale_resources_data!(resource_in::DataFrame, scale_factor::Float64)Scales resources attributes in-place if necessary. Generally, these scalings converts energy and power units from MW to GW and /MW to M/GW. Both are done by dividing the values by 1000. See documentation for descriptions of each column being scaled.
Arguments
resource_in(DataFrame): A dataframe containing data for a specific resource.scale_factor(Float64): A scaling factor for energy and currency units.
GenX.scale_vre_stor_data! — Method
scale_vre_stor_data!(vre_stor_in::DataFrame, scale_factor::Float64)Scales vre_stor attributes in-place if necessary. Generally, these scalings converts energy and power units from MW to GW and /MW to M/GW. Both are done by dividing the values by 1000. See documentation for descriptions of each column being scaled.
Arguments
vre_stor_in(DataFrame): A dataframe containing data for co-located VREs and storage.scale_factor(Float64): A scaling factor for energy and currency units.
GenX.split_storage_resources! — Method
split_storage_resources!(inputs::Dict, gen::Vector{<:AbstractResource})For co-located VRE-storage resources, this function returns the storage type (1. long-duration or short-duration storage, 2. symmetric or asymmetric storage) for charging and discharging capacities
GenX.summary — Method
summary(rs::Vector{<:AbstractResource})Prints a summary of the resources loaded into the model.
Arguments
rs (Vector{<:AbstractResource}): An array of GenX resources.
GenX.update_retrofit_id — Method
update_retrofit_id(r::AbstractResource)Updates the retrofitid of a resource that can be retrofit or is a retrofit option by appending the region to the retrofitid.
Arguments
r::AbstractResource: The resource to update.
GenX.validate_policy_dataframe! — Method
validate_policy_dataframe!(filename::AbstractString, policy_in::DataFrame)Validate the policy dataframe by checking if it has any attributes and if the column names are valid. The dataframe is modified in-place.
Arguments
filename::AbstractString: The name of the policy file.policy_in::DataFrame: The policy dataframe.
GenX.validate_policy_files — Method
validate_policy_files(resource_policies_path::AbstractString, setup::Dict)Validate the policy files by checking if they exist in the specified folder and if the setup flags are consistent with the files found.
Arguments
resource_policies_path::AbstractString: The path to the policy files.setup::Dict: Dictionary containing GenX settings.
Returns
- warning messages if the polcies are set to 1 in settings but the files are not found in the resourcepoliciespath.
!isfile(joinpath(resourcepoliciespath, filename))
Variability of Generators' Outputs
GenX.load_generators_variability! — Method
load_generators_variability!(setup::Dict, path::AbstractString, inputs::Dict)Read input parameters related to hourly maximum capacity factors for generators, storage, and flexible demand resources
Demand Data
GenX.load_demand_data! — Method
load_demand_data!(setup::Dict, path::AbstractString, inputs::Dict)Read input parameters related to electricity demand (load)
GenX.prevent_doubled_timedomainreduction — Method
prevent_doubled_timedomainreduction(path::AbstractString)This function prevents TimeDomainReduction from running on a case which already has more than one Representative Period or has more than one Sub_Weight specified.
Transmission Network
GenX.load_network_data! — Method
load_network_data!(setup::Dict, path::AbstractString, inputs_nw::Dict)Function for reading input parameters related to the electricity transmission network
GenX.load_network_map_from_list — Method
load_network_map_from_list(network_var::DataFrame, Z, L, list_columns)Loads the network map from a list-style interface
..., Network_Lines, Start_Zone, End_Zone, ...
1, 1, 2,
2, 1, 3,GenX.load_network_map_from_matrix — Method
load_network_map_from_matrix(network_var::DataFrame, Z, L)Loads the network map from a matrix-style interface
..., Network_Lines, z1, z2, z3, ...
1, 1, -1, 0,
2, 1, 0, -1,This is equivalent to the list-style interface where the zone zN with entry +1 is the starting zone of the line and the zone with entry -1 is the ending zone of the line.
Minimum Capacity Requirements
GenX.load_minimum_capacity_requirement! — Method
load_minimum_capacity_requirement!(path::AbstractString, inputs::Dict, setup::Dict)Read input parameters related to minimum capacity requirement constraints (e.g. technology specific deployment mandates)
Capacity Reserve Margin
GenX.load_cap_reserve_margin! — Method
load_cap_reserve_margin!(setup::Dict, path::AbstractString, inputs::Dict)Read input parameters related to planning reserve margin constraints
GenX.load_cap_reserve_margin_trans! — Method
load_cap_reserve_margin_trans!(setup::Dict, inputs::Dict, network_var::DataFrame)Read input parameters related to participation of transmission imports/exports in capacity reserve margin constraint.
CO$_2$ Emissions Cap
GenX.load_co2_cap! — Method
load_co2_cap!(setup::Dict, path::AbstractString, inputs::Dict)Read input parameters related to CO$_2$ emissions cap constraints
Energy Share Requirement
GenX.load_energy_share_requirement! — Method
load_energy_share_requirement!(setup::Dict, path::AbstractString, inputs::Dict)Read input parameters related to minimum energy share requirement constraints (e.g. renewable portfolio standard or clean electricity standard policies)
Hydrogen Production Demand Requirement
GenX.load_hydrogen_demand! — Function
load_hydrogen_demand!(setup::Dict, path::AbstractString, inputs::Dict)Read input parameters related to regional hydrogen demand from electrolysis
Mapping Representative Time Periods
GenX.load_period_map! — Method
load_period_map!(setup::Dict, path::AbstractString, inputs::Dict)Read input parameters related to mapping of representative time periods to full chronological time series
Variability of the Solar PV and Wind Components' Outputs (for Co-located Storage Resources)
GenX.load_process_variability! — Method
load_process_variability!(filepath::AbstractString, all_resources::Vector{T},
inputs::Dict, maxpower_key::String) where {T <: AbstractString}Load and process variability data for different VRE_storage components.
This function reads a CSV file specified by filepath, containing variability data for different VREstorage components. The function then sets the variability to zero for resources not in the file, selects the resources in the order of `allresources, and stores the maximum power output and variability of each energy resource in theinputs` dictionary.
Arguments
filepath::AbstractString: Path to the CSV file with variability data.all_resources::Vector{T}: Vector containing all the energy resources.inputs::Dict: Dictionary to store input data.maxpower_key::String: Identifier for the key for the maximum power
output in the inputs dict.
GenX.load_vre_stor_variability! — Method
load_vre_stor_variability!(setup::Dict, path::AbstractString, inputs::Dict)Read input parameters related to hourly maximum capacity factors for the solar PV (DC capacity factors) component and wind (AC capacity factors) component of co-located generators
Functions for developers
Standardized loading of dataframes from CSV files
GenX.extract_matrix_from_dataframe — Method
extract_matrix_from_dataframe(df::DataFrame, columnprefix::AbstractString)Finds all columns in the dataframe which are of the form columnprefix_[Integer], and extracts them in order into a matrix. The function also checks that there's at least one column with this prefix, and that all columns numbered from 1...N exist.
This is now acceptable:
ESR_1, other_thing, ESR_3, ESR_2,
0.1, 1, 0.3, 0.2,
0.4, 2, 0.6, 0.5,GenX.file_exists — Method
file_exists(dir::AbstractString, basenames::Vector{String})::BoolChecks that a file exists in a directory under (at least) one of a list of 'aliases'.
GenX.load_dataframe — Method
load_dataframe(dir::AbstractString, base::AbstractString)Attempts to load a dataframe from a csv file with the given directory and file name. If not found immediately, look for files with a different case (lower/upper) in the file's basename.
GenX.load_dataframe — Method
load_dataframe(path::AbstractString)Attempts to load a dataframe from a csv file with the given path. If it's not found immediately, it will look for files with a different case (lower/upper) in the file's basename.
GenX.validate_df_cols — Method
validate_df_cols(df::DataFrame, df_name::AbstractString, required_cols::Vector{AbstractString})Check that the dataframe has all the required columns.
Arguments
df::DataFrame: the dataframe to checkdf_name::AbstractString: the name of the dataframe, for error messagesrequired_cols::Vector{AbstractString}: the names of the required columns