diff --git a/src/case_runners/case_runner.jl b/src/case_runners/case_runner.jl index 9ac5431f82..dd769d11ce 100644 --- a/src/case_runners/case_runner.jl +++ b/src/case_runners/case_runner.jl @@ -35,10 +35,11 @@ function run_genx_case_simple!(case::AbstractString, mysetup::Dict, optimizer::A settings_path = get_settings_path(case) ### Cluster time series inputs if necessary and if specified by the user - TDRpath = joinpath(case, mysetup["TimeDomainReductionFolder"]) - + if mysetup["TimeDomainReduction"] == 1 - prevent_doubled_timedomainreduction(case) + TDRpath = joinpath(case, mysetup["TimeDomainReductionFolder"]) + system_path = joinpath(case, mysetup["SystemFolder"]) + prevent_doubled_timedomainreduction(system_path) if !time_domain_reduced_files_exist(TDRpath) println("Clustering Time Series Data (Grouped)...") cluster_inputs(case, settings_path, mysetup) @@ -92,13 +93,14 @@ function run_genx_case_multistage!(case::AbstractString, mysetup::Dict, optimize mysetup["MultiStageSettingsDict"] = YAML.load(open(multistage_settings)) ### Cluster time series inputs if necessary and if specified by the user - tdr_settings = get_settings_path(case, "time_domain_reduction_settings.yml") # Multi stage settings YAML file path - TDRSettingsDict = YAML.load(open(tdr_settings)) - - first_stage_path = joinpath(case, "Inputs", "Inputs_p1") - TDRpath = joinpath(first_stage_path, mysetup["TimeDomainReductionFolder"]) if mysetup["TimeDomainReduction"] == 1 - prevent_doubled_timedomainreduction(first_stage_path) + tdr_settings = get_settings_path(case, "time_domain_reduction_settings.yml") # Multi stage settings YAML file path + TDRSettingsDict = YAML.load(open(tdr_settings)) + + first_stage_path = joinpath(case, "Inputs", "Inputs_p1") + TDRpath = joinpath(first_stage_path, mysetup["TimeDomainReductionFolder"]) + system_path = joinpath(first_stage_path, mysetup["SystemFolder"]) + prevent_doubled_timedomainreduction(system_path) if !time_domain_reduced_files_exist(TDRpath) if (mysetup["MultiStage"] == 1) && (TDRSettingsDict["MultiStageConcatenate"] == 0) println("Clustering Time Series Data (Individually)...") diff --git a/src/configure_settings/configure_settings.jl b/src/configure_settings/configure_settings.jl index 92074cada0..d733cbcdb1 100644 --- a/src/configure_settings/configure_settings.jl +++ b/src/configure_settings/configure_settings.jl @@ -25,7 +25,10 @@ function default_settings() "HydrogenHourlyMatching" => 0, "EnableJuMPStringNames" => false, "ComputeConflicts" => 0, - "ResourcePath" => "Resources", + "ResourcesFolder" => "Resources", + "ResourcePoliciesFolder" => "Policy_assignments", + "SystemFolder" => "System", + "PoliciesFolder" => "Policies", ) end diff --git a/src/load_inputs/load_demand_data.jl b/src/load_inputs/load_demand_data.jl index e9b66a7fbf..13556ec936 100644 --- a/src/load_inputs/load_demand_data.jl +++ b/src/load_inputs/load_demand_data.jl @@ -31,7 +31,8 @@ function load_demand_data!(setup::Dict, path::AbstractString, inputs::Dict) if setup["TimeDomainReduction"] == 1 && time_domain_reduced_files_exist(data_directory) my_dir = data_directory else - my_dir = path + # If TDR is not used, then use the directory specified in the default setup + my_dir = joinpath(path, setup["SystemFolder"]) end demand_in = get_demand_dataframe(my_dir) diff --git a/src/load_inputs/load_fuels_data.jl b/src/load_inputs/load_fuels_data.jl index a32a9cfe6f..23e2a02320 100644 --- a/src/load_inputs/load_fuels_data.jl +++ b/src/load_inputs/load_fuels_data.jl @@ -9,7 +9,8 @@ function load_fuels_data!(setup::Dict, path::AbstractString, inputs::Dict) if setup["TimeDomainReduction"] == 1 && time_domain_reduced_files_exist(data_directory) my_dir = data_directory else - my_dir = path + # If TDR is not used, then use the directory specified in the default setup + my_dir = joinpath(path, setup["SystemFolder"]) end filename = "Fuels_data.csv" fuels_in = load_dataframe(joinpath(my_dir, filename)) diff --git a/src/load_inputs/load_generators_variability.jl b/src/load_inputs/load_generators_variability.jl index 711f9d36cd..d5c2d100f9 100644 --- a/src/load_inputs/load_generators_variability.jl +++ b/src/load_inputs/load_generators_variability.jl @@ -10,7 +10,7 @@ function load_generators_variability!(setup::Dict, path::AbstractString, inputs: if setup["TimeDomainReduction"] == 1 && time_domain_reduced_files_exist(data_directory) my_dir = data_directory else - my_dir = path + my_dir = joinpath(path, setup["SystemFolder"]) end filename = "Generators_variability.csv" gen_var = load_dataframe(joinpath(my_dir, filename)) diff --git a/src/load_inputs/load_inputs.jl b/src/load_inputs/load_inputs.jl index 16b3b22c31..c0b21b8156 100644 --- a/src/load_inputs/load_inputs.jl +++ b/src/load_inputs/load_inputs.jl @@ -13,11 +13,15 @@ function load_inputs(setup::Dict,path::AbstractString) ## Read input files println("Reading Input CSV Files") + ## input paths + system_path = joinpath(path, setup["SystemFolder"]) + resources_path = joinpath(path, setup["ResourcesFolder"]) + policy_path = joinpath(path, setup["PoliciesFolder"]) ## Declare Dict (dictionary) object used to store parameters inputs = Dict() # Read input data about power network topology, operating and expansion attributes - if isfile(joinpath(path,"Network.csv")) - network_var = load_network_data!(setup, path, inputs) + if isfile(joinpath(system_path,"Network.csv")) + network_var = load_network_data!(setup, system_path, inputs) else inputs["Z"] = 1 inputs["L"] = 0 @@ -28,14 +32,14 @@ function load_inputs(setup::Dict,path::AbstractString) # Read fuel cost data, including time-varying fuel costs load_fuels_data!(setup, path, inputs) # Read in generator/resource related inputs - load_resources_data!(inputs, setup, path) + load_resources_data!(inputs, setup, path, resources_path) # Read in generator/resource availability profiles load_generators_variability!(setup, path, inputs) validatetimebasis(inputs) if setup["CapacityReserveMargin"]==1 - load_cap_reserve_margin!(setup, path, inputs) + load_cap_reserve_margin!(setup, policy_path, inputs) if inputs["Z"] >1 load_cap_reserve_margin_trans!(setup, inputs, network_var) end @@ -43,32 +47,32 @@ function load_inputs(setup::Dict,path::AbstractString) # Read in general configuration parameters for reserves (resource-specific reserve parameters are read in generators_data()) if setup["Reserves"]==1 - load_reserves!(setup, path, inputs) + load_reserves!(setup, system_path, inputs) end if setup["MinCapReq"] == 1 - load_minimum_capacity_requirement!(path, inputs, setup) + load_minimum_capacity_requirement!(policy_path, inputs, setup) end if setup["MaxCapReq"] == 1 - load_maximum_capacity_requirement!(path, inputs, setup) + load_maximum_capacity_requirement!(policy_path, inputs, setup) end if setup["EnergyShareRequirement"]==1 - load_energy_share_requirement!(setup, path, inputs) + load_energy_share_requirement!(setup, policy_path, inputs) end if setup["CO2Cap"] >= 1 - load_co2_cap!(setup, path, inputs) + load_co2_cap!(setup, policy_path, inputs) end if !isempty(inputs["VRE_STOR"]) - load_vre_stor_variability!(setup, path, inputs) + load_vre_stor_variability!(setup, system_path, inputs) end # Read in mapping of modeled periods to representative periods - if is_period_map_necessary(inputs) && is_period_map_exist(setup, path, inputs) - load_period_map!(setup, path, inputs) + if is_period_map_necessary(inputs) && is_period_map_exist(setup, system_path, inputs) + load_period_map!(setup, system_path, inputs) end # Virtual charge discharge cost diff --git a/src/load_inputs/load_resources_data.jl b/src/load_inputs/load_resources_data.jl index e8dd30229e..310b8b9152 100644 --- a/src/load_inputs/load_resources_data.jl +++ b/src/load_inputs/load_resources_data.jl @@ -32,10 +32,10 @@ Internal function to get policy file information. """ function _get_policyfile_info() policyfile_info = ( - esr = (filename="Resource_energy_share_requirement.csv"), - cap_res = (filename="Resource_capacity_reserve_margin.csv"), - min_cap = (filename="Resource_minimum_capacity_requirement.csv"), - max_cap = (filename="Resource_maximum_capacity_requirement.csv"), + esr = (filename="Resource_energy_share_requirement.csv", setupflag="EnergyShareRequirement"), + cap_res = (filename="Resource_capacity_reserve_margin.csv", setupflag="CapacityReserveMargin"), + min_cap = (filename="Resource_minimum_capacity_requirement.csv", setupflag="MinCapReq"), + max_cap = (filename="Resource_maximum_capacity_requirement.csv", setupflag="MaxCapReq"), ) return policyfile_info end @@ -444,34 +444,56 @@ function validate_resources(resources::T) where T <: Vector{AbstractResource} end """ - create_resources(setup::Dict, case_path::AbstractString) + create_resources(setup::Dict, resources_path::AbstractString) -Function that loads and scales resources data from folder specified in `setup["ResourcePath"] and returns an array of GenX resources. +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. -- `case_path (AbstractString)`: The path to the case. +- `resources_path (AbstractString)`: The path to the resources folder. # Returns - `resources (Vector{AbstractResource})`: An array of scaled resources. """ -function create_resource_array(setup::Dict, case_path::AbstractString) +function create_resource_array(setup::Dict, resources_path::AbstractString) scale_factor = setup["ParameterScale"] == 1 ? ModelScalingFactor : 1.0 - resources_folder = setup["ResourcePath"] - resources_folder = joinpath(case_path,resources_folder) - # get filename and GenX type for each type of resources available in GenX resources_info = _get_resource_info() # load each resource type, scale data and return array of resources - resources = create_resource_array(resources_folder, resources_info, scale_factor) + resources = create_resource_array(resources_path, resources_info, scale_factor) # validate input before returning resources validate_resources(resources) return resources end + +""" + 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 resource_policies_path. + +""" +function validate_policy_files(resource_policies_path::AbstractString, setup::Dict) + policyfile_info = _get_policyfile_info() + for (filename, setup_flag) in values(policyfile_info) + if setup[setup_flag] == 1 && !isfile(joinpath(resource_policies_path, filename)) + msg = string(setup_flag, " is set to 1 in settings but the file ", filename, " was not found in ", resource_policies_path) + @warn(msg) + end + end + return nothing +end + """ validate_policy_dataframe!(filename::AbstractString, policy_in::DataFrame) @@ -578,23 +600,20 @@ function add_policy_to_resources!(resources::Vector{<:AbstractResource}, path::A end """ - add_policies_to_resources!(resources::Vector{<:AbstractResource}, setup::Dict, case_path::AbstractString) + 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. -- `setup (Dict)`: Dictionary containing GenX settings. -- `case_path::AbstractString`: The path to the case. +- `resources_path::AbstractString`: The path to the resources folder. """ -function add_policies_to_resources!(resources::Vector{<:AbstractResource}, setup::Dict, case_path::AbstractString) - policy_folder = setup["ResourcePath"] - policy_folder = joinpath(case_path, policy_folder) +function add_policies_to_resources!(resources::Vector{<:AbstractResource}, resource_policy_path::AbstractString) # get filename for each type of policy available in GenX policies_info = _get_policyfile_info() # loop over policy files - for filename in values(policies_info) - path = joinpath(policy_folder, filename) + for (filename,_) in values(policies_info) + path = joinpath(resource_policy_path, filename) # if file exists, add policy to resources if isfile(path) add_policy_to_resources!(resources, path, filename) @@ -620,25 +639,22 @@ function add_module_to_resources!(resources::Vector{<:AbstractResource}, module_ end """ - add_modules_to_resources!(resources::Vector{<:AbstractResource}, setup::Dict, case_path::AbstractString) + 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. -- `case_path::AbstractString`: The path to the case. +- `resources_path::AbstractString`: The path to the resources folder. """ -function add_modules_to_resources!(resources::Vector{<:AbstractResource}, setup::Dict, case_path::AbstractString) +function add_modules_to_resources!(resources::Vector{<:AbstractResource}, setup::Dict, resources_path::AbstractString) modules = Vector{DataFrame}() - module_folder = setup["ResourcePath"] - module_folder = joinpath(case_path, module_folder) - ## Load all modules and add them to the list of modules to be added to resources # Add multistage if multistage is activated if setup["MultiStage"] == 1 - filename = joinpath(module_folder, "Resource_multistage_data.csv") + filename = joinpath(resources_path, "Resource_multistage_data.csv") multistage_in = load_multistage_dataframe(filename) push!(modules, multistage_in) @info "Multistage data successfully read." @@ -847,18 +863,17 @@ function split_storage_resources!(inputs::Dict, gen::Vector{<:AbstractResource}) end """ - add_resources_to_input_data!(inputs::Dict, setup::Dict, case_path::AbstractString, gen::Vector{<:AbstractResource}) + add_resources_to_input_data!(inputs::Dict, setup::Dict, 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. """ -function add_resources_to_input_data!(inputs::Dict, setup::Dict, case_path::AbstractString, gen::Vector{<:AbstractResource}) +function add_resources_to_input_data!(inputs::Dict, setup::Dict, gen::Vector{<:AbstractResource}) # Number of resources G = length(gen) @@ -1094,19 +1109,20 @@ function summary(rs::Vector{<:AbstractResource}) end """ - load_resources_data!(inputs::Dict, setup::Dict, case_path::AbstractString) + load_resources_data!(inputs::Dict, setup::Dict, case_path::AbstractString, resources_path::AbstractString) -This function loads resources data from the `setup["ResourcePath"]` folder and create the GenX data structures and add them to the `inputs` `Dict`. +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. +- `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. """ -function load_resources_data!(inputs::Dict, setup::Dict, case_path::AbstractString) +function load_resources_data!(inputs::Dict, setup::Dict, case_path::AbstractString, resources_path::AbstractString) if isfile(joinpath(case_path, "Generators_data.csv")) msg = "The `Generators_data.csv` file was deprecated in release v0.4. " * "Please use the new interface for generators creation, and see the documentation for additional details." @@ -1114,16 +1130,18 @@ function load_resources_data!(inputs::Dict, setup::Dict, case_path::AbstractStri error("Exiting GenX...") else # create vector of resources from dataframes - resources = create_resource_array(setup, case_path) + resources = create_resource_array(setup, resources_path) # read policy files and add policies-related attributes to resource dataframe - add_policies_to_resources!(resources, setup, case_path) + resource_policies_path = joinpath(resources_path, setup["ResourcePoliciesFolder"]) + validate_policy_files(resource_policies_path, setup) + add_policies_to_resources!(resources, resource_policies_path) # read module files add module-related attributes to resource dataframe - add_modules_to_resources!(resources, setup, case_path) + add_modules_to_resources!(resources, setup, resources_path) # add resources information to inputs dict - add_resources_to_input_data!(inputs, setup, case_path, resources) + add_resources_to_input_data!(inputs, setup, resources) # print summary of resources summary(resources) diff --git a/src/multi_stage/dual_dynamic_programming.jl b/src/multi_stage/dual_dynamic_programming.jl index b3e2c23c14..b9ed9565f0 100644 --- a/src/multi_stage/dual_dynamic_programming.jl +++ b/src/multi_stage/dual_dynamic_programming.jl @@ -336,7 +336,7 @@ function write_multi_stage_outputs(stats_d::Dict, outpath::String, settings_d::D write_multi_stage_network_expansion(outpath, multi_stage_settings_d) end write_multi_stage_costs(outpath, multi_stage_settings_d, inputs_dict) - write_multi_stage_stats(outpath, stats_d) + multi_stage_settings_d["Myopic"] == 0 && write_multi_stage_stats(outpath, stats_d) write_multi_stage_settings(outpath, settings_d) end diff --git a/src/time_domain_reduction/time_domain_reduction.jl b/src/time_domain_reduction/time_domain_reduction.jl index 1bc854e6c8..e0b2d85faa 100644 --- a/src/time_domain_reduction/time_domain_reduction.jl +++ b/src/time_domain_reduction/time_domain_reduction.jl @@ -605,7 +605,8 @@ function cluster_inputs(inpath, settings_path, mysetup, stage_id=-99, v=false; r # this prevents doubled time domain reduction in stages past # the first, even if the first stage is okay. - prevent_doubled_timedomainreduction(inpath_sub) + system_path = joinpath(inpath_sub, mysetup["SystemFolder"]) + prevent_doubled_timedomainreduction(system_path) inputs_dict[t] = load_inputs(mysetup_MS, inpath_sub) @@ -1000,7 +1001,7 @@ function cluster_inputs(inpath, settings_path, mysetup, stage_id=-99, v=false; r # Save output data to stage-specific locations ### TDR_Results/Demand_data_clustered.csv - demand_in = get_demand_dataframe(joinpath(inpath, "Inputs", "Inputs_p$per")) + demand_in = get_demand_dataframe(joinpath(inpath, "Inputs", "Inputs_p$per"), mysetup["SystemFolder"]) demand_in[!,:Sub_Weights] = demand_in[!,:Sub_Weights] * 1. demand_in[1:length(Stage_Weights[per]),:Sub_Weights] .= Stage_Weights[per] demand_in[!,:Rep_Periods][1] = length(Stage_Weights[per]) @@ -1058,7 +1059,7 @@ function cluster_inputs(inpath, settings_path, mysetup, stage_id=-99, v=false; r end ### TDR_Results/Fuels_data.csv - fuel_in = load_dataframe(joinpath(inpath, "Inputs", "Inputs_p$per", "Fuels_data.csv")) + fuel_in = load_dataframe(joinpath(inpath, "Inputs", "Inputs_p$per", mysetup["SystemFolder"], "Fuels_data.csv")) select!(fuel_in, Not(:Time_Index)) SepFirstRow = DataFrame(fuel_in[1, :]) NewFuelOutput = vcat(SepFirstRow, FPOutputData) @@ -1084,7 +1085,7 @@ function cluster_inputs(inpath, settings_path, mysetup, stage_id=-99, v=false; r mkpath(joinpath(inpath,"Inputs",input_stage_directory, TimeDomainReductionFolder)) ### TDR_Results/Demand_data.csv - demand_in = get_demand_dataframe(joinpath(inpath, "Inputs", input_stage_directory)) + demand_in = get_demand_dataframe(joinpath(inpath, "Inputs", input_stage_directory, mysetup["SystemFolder"])) demand_in[!,:Sub_Weights] = demand_in[!,:Sub_Weights] * 1. demand_in[1:length(W),:Sub_Weights] .= W demand_in[!,:Rep_Periods][1] = length(W) @@ -1147,7 +1148,7 @@ function cluster_inputs(inpath, settings_path, mysetup, stage_id=-99, v=false; r ### TDR_Results/Fuels_data.csv - fuel_in = load_dataframe(joinpath(inpath,"Inputs",input_stage_directory,"Fuels_data.csv")) + fuel_in = load_dataframe(joinpath(inpath, "Inputs", input_stage_directory, mysetup["SystemFolder"], "Fuels_data.csv")) select!(fuel_in, Not(:Time_Index)) SepFirstRow = DataFrame(fuel_in[1, :]) NewFuelOutput = vcat(SepFirstRow, FPOutputData) @@ -1169,7 +1170,8 @@ function cluster_inputs(inpath, settings_path, mysetup, stage_id=-99, v=false; r mkpath(joinpath(inpath, TimeDomainReductionFolder)) ### TDR_Results/Demand_data.csv - demand_in = get_demand_dataframe(inpath) + system_path = joinpath(inpath, mysetup["SystemFolder"]) + demand_in = get_demand_dataframe(system_path) demand_in[!,:Sub_Weights] = demand_in[!,:Sub_Weights] * 1. demand_in[1:length(W),:Sub_Weights] .= W demand_in[!,:Rep_Periods][1] = length(W) @@ -1231,8 +1233,8 @@ function cluster_inputs(inpath, settings_path, mysetup, stage_id=-99, v=false; r end ### TDR_Results/Fuels_data.csv - - fuel_in = load_dataframe(joinpath(inpath, "Fuels_data.csv")) + system_path = joinpath(inpath, mysetup["SystemFolder"]) + fuel_in = load_dataframe(joinpath(system_path, "Fuels_data.csv")) select!(fuel_in, Not(:Time_Index)) SepFirstRow = DataFrame(fuel_in[1, :]) NewFuelOutput = vcat(SepFirstRow, FPOutputData) diff --git a/src/write_outputs/write_outputs.jl b/src/write_outputs/write_outputs.jl index 0cef6db417..d474e65d36 100644 --- a/src/write_outputs/write_outputs.jl +++ b/src/write_outputs/write_outputs.jl @@ -41,6 +41,8 @@ function write_outputs(EP::Model, path::AbstractString, setup::Dict, inputs::Dic end end + write_settings_file(path, setup) + write_status(path, inputs, setup, EP) elapsed_time_costs = @elapsed write_costs(path, inputs, setup, EP) println("Time elapsed for writing costs is") @@ -217,3 +219,5 @@ function write_outputs(EP::Model, path::AbstractString, setup::Dict, inputs::Dic return path end # END output() + +write_settings_file(path, setup) = YAML.write_file(joinpath(path, "run_settings.yml"), setup) \ No newline at end of file diff --git a/test/test_load_resource_data.jl b/test/test_load_resource_data.jl index e84a0cf900..3d8712925e 100644 --- a/test/test_load_resource_data.jl +++ b/test/test_load_resource_data.jl @@ -200,36 +200,42 @@ function test_load_resources_data() "Reserves" => 1, "UCommit" => 2, "MultiStage" => 1, - "ResourcePath" => "Resources", ) + + # Merge the setup with the default settings + settings = GenX.default_settings() + merge!(settings, setup) test_path = joinpath("LoadResourceData", "test_gen_non_colocated") # load dfGen and inputs_true to compare against input_true_filenames = InputsTrue("generators_data.csv", "inputs_after_loadgen.jld2") - dfGen, inputs_true = prepare_inputs_true(test_path, input_true_filenames, setup) + dfGen, inputs_true = prepare_inputs_true(test_path, input_true_filenames, settings) # Test resource data is loaded correctly - gen = GenX.create_resource_array(setup, test_path) + resources_path = joinpath(test_path, settings["ResourcesFolder"]) + gen = GenX.create_resource_array(settings, resources_path) @testset "Default fields" begin test_load_scaled_resources_data(gen, dfGen) end # Test policy fields are correctly added to the resource structs - GenX.add_policies_to_resources!(gen, setup, test_path) + resource_policies_path = joinpath(resources_path, settings["ResourcePoliciesFolder"]) + GenX.validate_policy_files(resource_policies_path, settings) + GenX.add_policies_to_resources!(gen, resource_policies_path) @testset "Policy attributes" begin test_add_policies_to_resources(gen, dfGen) end # Test modules are correctly added to the resource structs - GenX.add_modules_to_resources!(gen, setup, test_path) + GenX.add_modules_to_resources!(gen, settings, resources_path) @testset "Module attributes" begin test_add_modules_to_resources(gen, dfGen) end # Test that the inputs keys are correctly set inputs = load(joinpath(test_path, "inputs_before_loadgen.jld2")) - GenX.add_resources_to_input_data!(inputs, setup, test_path, gen) + GenX.add_resources_to_input_data!(inputs, settings, gen) @testset "Inputs keys" begin test_inputs_keys(inputs, inputs_true) end @@ -247,22 +253,28 @@ function test_load_VRE_STOR_data() "Reserves" => 1, "UCommit" => 2, "MultiStage" => 0, - "ResourcePath" => "Resources", ) + + # Merge the setup with the default settings + settings = GenX.default_settings() + merge!(settings, setup) test_path = joinpath("LoadResourceData","test_gen_vre_stor") input_true_filenames = InputsTrue("generators_data.csv", "inputs_after_loadgen.jld2") - dfGen, inputs_true = prepare_inputs_true(test_path, input_true_filenames, setup) + dfGen, inputs_true = prepare_inputs_true(test_path, input_true_filenames, settings) dfVRE_STOR = GenX.load_dataframe(joinpath(test_path, "Vre_and_stor_data.csv")) dfVRE_STOR = GenX.rename!(dfVRE_STOR, lowercase.(names(dfVRE_STOR))) - scale_factor = setup["ParameterScale"] == 1 ? GenX.ModelScalingFactor : 1. + scale_factor = settings["ParameterScale"] == 1 ? GenX.ModelScalingFactor : 1. GenX.scale_vre_stor_data!(dfVRE_STOR, scale_factor) - gen = GenX.create_resource_array(setup, test_path) - GenX.add_policies_to_resources!(gen, setup, test_path) + resources_path = joinpath(test_path, settings["ResourcesFolder"]) + gen = GenX.create_resource_array(settings, resources_path) + resource_policies_path = joinpath(resources_path, settings["ResourcePoliciesFolder"]) + GenX.validate_policy_files(resource_policies_path, settings) + GenX.add_policies_to_resources!(gen, resource_policies_path) inputs = load(joinpath(test_path, "inputs_before_loadgen.jld2")) - GenX.add_resources_to_input_data!(inputs, setup, test_path, gen) + GenX.add_resources_to_input_data!(inputs, settings, gen) @test GenX.vre_stor(gen) == dfGen[dfGen.vre_stor .== 1, :r_id] sort!(dfVRE_STOR, :resource) diff --git a/test/test_multistage.jl b/test/test_multistage.jl index ea7f1b646b..c69435ae64 100644 --- a/test/test_multistage.jl +++ b/test/test_multistage.jl @@ -25,7 +25,6 @@ genx_setup = Dict( "UCommit" => 2, "MultiStage" => 1, "MultiStageSettingsDict" => multistage_setup, - "ResourcePath" => "Resources", ) # Run the case and get the objective value and tolerance