Skip to content

Commit

Permalink
Merge pull request #143 from Breakthrough-Energy/lane/fix_read
Browse files Browse the repository at this point in the history
Refactor read_demand_flexibility to include duration parameter check
  • Loading branch information
lanesmith authored Jul 9, 2021
2 parents 2d610ca + 83283b5 commit f38cb6e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/REISE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function run_scenario(;
stderr_filepath = joinpath(outputfolder, "stderr.err")
case = read_case(inputfolder)
storage = read_storage(inputfolder)
demand_flexibility = read_demand_flexibility(inputfolder)
demand_flexibility = read_demand_flexibility(inputfolder, interval)
println("All scenario files loaded!")
case = reise_data_mods(case, num_segments=num_segments)
save_input_mat(case, storage, inputfolder, outputfolder)
Expand Down
12 changes: 0 additions & 12 deletions src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -261,18 +261,6 @@ function _build_model(
bus_demand_flex_amt = _make_bus_demand_flexibility_amount(
case, demand_flexibility, start_index, end_index
)
if (
demand_flexibility.duration == nothing
|| demand_flexibility.duration > interval_length
)
if demand_flexibility.duration > interval_length
@warn (
"Demand flexibility durations greater than the interval length are "
* "set equal to the interval length."
)
end
demand_flexibility.duration = interval_length
end
end

println("variables: ", Dates.now())
Expand Down
19 changes: 18 additions & 1 deletion src/read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ end


"""Load demand flexibility profile from .csv files into DataFrame(s)."""
function read_demand_flexibility(filepath)::DemandFlexibility
function read_demand_flexibility(filepath, interval)::DemandFlexibility
# Initialize demand flexibility
demand_flexibility = Dict()

Expand Down Expand Up @@ -165,13 +165,30 @@ function read_demand_flexibility(filepath)::DemandFlexibility
println(demand_flexibility_params_errs[k])
end
end

# Set the demand flexibility constraints to false if enabled is false
if !demand_flexibility["enabled"]
demand_flexibility["interval_balance"] = false
demand_flexibility["rolling_balance"] = false
end
catch e
println("Demand flexibility parameters not found in " * filepath)
println(
"Demand flexibility parameters will default to allowing demand "
* "flexibility to occur."
)
end

# Check the feasibility of the duration parameter
if demand_flexibility["duration"] == nothing
demand_flexibility["duration"] = interval
elseif demand_flexibility["duration"] > interval
@warn (
"Demand flexibility durations greater than the interval length are "
* "set equal to the interval length."
)
demand_flexibility["duration"] = interval
end
end

# Convert Dict to NamedTuple
Expand Down

0 comments on commit f38cb6e

Please sign in to comment.