Virtual Reservoir - Building
The data for this case is available in the folder
data/case_5
Virtual Reservoir overview
Before getting into the details of the case, let's understand the concept of a virtual reservoir.
A virtual reservoir is a mechanism to aggregate multiple hydro units into a single entity. More than one Asset Owner can be linked into the same Virtual Reservoir
Each Asset Owner has an inflow allocation, which is the percentage of inflow that each Asset Owner has in the Virtual Reservoir. This percentage is also used to compute the initial energy in the Virtual Reservoir for each Asset Owner.
Case overview
In this case, we will have two Hydro Units and two Asset Owners linked to a single Virtual Reservoir. The inflow allocation for the first Asset Owner is 40%, and for the second Asset Owner is 60%.
The second Asset Owner will place higher bids than the first Asset Owner. So what we expect is that the first Asset Owner will be generating more energy in the beginning and, as the energy of the first Asset Owner decreases, the second Asset Owner will start generating more energy.
Also, the hydro units will be in a cascade relationship, where the first hydro unit will be able to turbine and spill water to the second hydro unit.
It is necessary to associate each hydro unit with a bidding group. In this case, we will use the same bidding group for both hydro units.
Creating the case
We'll start by importing the necessary packages.
using Dates
using DataFrames
using IARA
The case will have the following characteristics
number_of_periods = 3
number_of_scenarios = 1
number_of_subperiods = 4
subperiod_duration_in_hours = 1000.0 / number_of_subperiods
cycle_duration_in_hours =
subperiod_duration_in_hours * number_of_subperiods * number_of_periods
Let's define a few conversion factors that we will use later.
m3_per_second_to_hm3_per_hour = 3600.0 / 1e6
As we have done in the previous tutorials, we will start by creating a new case.
const PATH_CASE = joinpath(@__DIR__, "data", "case_5")
db = IARA.create_study!(PATH_CASE;
number_of_periods = number_of_periods,
number_of_scenarios = number_of_scenarios,
number_of_subperiods = number_of_subperiods,
initial_date_time = "2020",
subperiod_duration_in_hours = [
subperiod_duration_in_hours for _ in 1:number_of_subperiods
],
policy_graph_type = IARA.Configurations_PolicyGraphType.LINEAR,
cycle_discount_rate = 0.0,
cycle_duration_in_hours = cycle_duration_in_hours,
demand_deficit_cost = 500.0,
hydro_minimum_outflow_violation_cost = 600.0,
clearing_hydro_representation = IARA.Configurations_ClearingHydroRepresentation.VIRTUAL_RESERVOIRS,
bid_data_source = IARA.Configurations_BidDataSource.READ_FROM_FILE,
demand_scenarios_files = IARA.Configurations_UncertaintyScenariosFiles.ONLY_EX_ANTE,
inflow_scenarios_files = IARA.Configurations_UncertaintyScenariosFiles.ONLY_EX_ANTE,
)
Zone and Bus
Let's add a zone and a bus to our case. This case will have a single zone and a single bus for simplicity.
IARA.add_zone!(db; label = "zone_1")
IARA.add_bus!(db; label = "bus_1", zone_id = "zone_1")
Hydro Unit
Now we can add our hydro units that will be linked to the virtual reservoir.
IARA.add_hydro_unit!(db;
label = "hydro_1",
initial_volume = 100.0,
bus_id = "bus_1",
parameters = DataFrame(;
date_time = [DateTime(0)],
existing = 1,
production_factor = 1000.0 * m3_per_second_to_hm3_per_hour,
max_generation = 400.0,
min_volume = 0.0,
max_turbining = 400.0 / m3_per_second_to_hm3_per_hour, # maybe it is 0.4 instead of 400
max_volume = 2000.0,
min_outflow = 0.3 / m3_per_second_to_hm3_per_hour,
om_cost = 10.0,
),
)
IARA.add_hydro_unit!(db;
label = "hydro_2",
initial_volume = 0.0,
bus_id = "bus_1",
parameters = DataFrame(;
date_time = [DateTime(0)],
existing = 1,
production_factor = 1000.0 * m3_per_second_to_hm3_per_hour,
max_generation = 400.0,
max_turbining = 400.0 / m3_per_second_to_hm3_per_hour,
min_volume = 0.0,
max_volume = 0.0,
min_outflow = 0.0,
om_cost = 100.0,
),
)
Setting Hydro Unit relations
IARA.set_hydro_turbine_to!(db, "hydro_1", "hydro_2")
IARA.set_hydro_spill_to!(db, "hydro_1", "hydro_2")
Asset Owner
Let's add two asset owners to our case. Both of them will be price makers.
IARA.add_asset_owner!(db; label = "asset_owner_1")
IARA.add_asset_owner!(db; label = "asset_owner_2")
Virtual Reservoir
Now we can add the virtual reservoir to our case. Notice that we are setting the inflow allocation and linking the asset owners and hydro units.
IARA.add_virtual_reservoir!(db;
label = "reservoir_1",
assetowner_id = ["asset_owner_1", "asset_owner_2"],
inflow_allocation = [0.4, 0.6],
hydrounit_id = ["hydro_1", "hydro_2"],
)
Bidding Group
Let's add a bidding group to our case. Both hydro units will be linked to this bidding group.
IARA.add_bidding_group!(db;
label = "bidding_group_1",
assetowner_id = "asset_owner_1",
segment_fraction = [1.0],
risk_factor = [0.0],
)
IARA.update_hydro_unit_relation!(db,
"hydro_1";
collection = "BiddingGroup",
relation_type = "id",
related_label = "bidding_group_1",
)
IARA.update_hydro_unit_relation!(db,
"hydro_2";
collection = "BiddingGroup",
relation_type = "id",
related_label = "bidding_group_1",
)
PSRClassesInterface.PSRDatabaseSQLite.DatabaseSQLite(SQLite.DB("/home/runner/work/IARA.jl/IARA.jl/docs/build/tutorial/data/case_5/study.iara"), "/home/runner/work/IARA.jl/IARA.jl/docs/build/tutorial/data/case_5/study.iara", OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.Collection}("Configuration" => PSRClassesInterface.PSRDatabaseSQLite.Collection("Configuration", OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter}("id" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("id", Int64, missing, false, "Configuration", "Configuration"), "label" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{String}("label", String, "\"Configuration\"", true, "Configuration", "Configuration"), "number_of_nodes" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("number_of_nodes", Int64, missing, false, "Configuration", "Configuration"), "number_of_subscenarios" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("number_of_subscenarios", Int64, 1, true, "Configuration", "Configuration"), "train_mincost_iteration_limit" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("train_mincost_iteration_limit", Int64, missing, false, "Configuration", "Configuration"), "initial_date_time" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{String}("initial_date_time", String, "\"2024-01-01\"", true, "Configuration", "Configuration"), "time_series_step" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("time_series_step", Int64, 0, true, "Configuration", "Configuration"), "hydro_balance_subperiod_resolution" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("hydro_balance_subperiod_resolution", Int64, 0, false, "Configuration", "Configuration"), "loop_subperiods_for_thermal_constraints" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("loop_subperiods_for_thermal_constraints", Int64, missing, false, "Configuration", "Configuration"), "cycle_discount_rate" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Float64}("cycle_discount_rate", Float64, missing, true, "Configuration", "Configuration")…), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.VectorParameter}("subperiod_duration_in_hours" => PSRClassesInterface.PSRDatabaseSQLite.VectorParameter{Float64}("subperiod_duration_in_hours", Float64, missing, false, "subperiod_duration", "Configuration", "Configuration_vector_subperiod_duration"), "expected_number_of_repeats_per_node" => PSRClassesInterface.PSRDatabaseSQLite.VectorParameter{Float64}("expected_number_of_repeats_per_node", Float64, missing, false, "expected_number_of_repeats_per_node", "Configuration", "Configuration_vector_expected_number_of_repeats_per_node")), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.VectorRelation}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.TimeSeries}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.TimeSeriesFile}("hour_subperiod_map" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeriesFile{String}("hour_subperiod_map", String, missing, false, "Configuration", "Configuration_time_series_files"), "fcf_cuts" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeriesFile{String}("fcf_cuts", String, missing, false, "Configuration", "Configuration_time_series_files"), "period_season_map" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeriesFile{String}("period_season_map", String, missing, false, "Configuration", "Configuration_time_series_files"))), "RenewableUnit" => PSRClassesInterface.PSRDatabaseSQLite.Collection("RenewableUnit", OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter}("id" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("id", Int64, missing, false, "RenewableUnit", "RenewableUnit"), "label" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{String}("label", String, missing, true, "RenewableUnit", "RenewableUnit"), "technology_type" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("technology_type", Int64, missing, false, "RenewableUnit", "RenewableUnit")), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation}("biddinggroup_id" => PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation{Int64}("biddinggroup_id", Int64, missing, false, "RenewableUnit", "BiddingGroup", "id", "RenewableUnit"), "bus_id" => PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation{Int64}("bus_id", Int64, missing, false, "RenewableUnit", "Bus", "id", "RenewableUnit")), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.VectorParameter}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.VectorRelation}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.TimeSeries}("existing" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Int64}("existing", Int64, missing, false, "parameters", "RenewableUnit", "RenewableUnit_time_series_parameters", ["date_time"], 1), "max_generation" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("max_generation", Float64, missing, false, "parameters", "RenewableUnit", "RenewableUnit_time_series_parameters", ["date_time"], 1), "om_cost" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("om_cost", Float64, missing, false, "parameters", "RenewableUnit", "RenewableUnit_time_series_parameters", ["date_time"], 1), "curtailment_cost" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("curtailment_cost", Float64, missing, false, "parameters", "RenewableUnit", "RenewableUnit_time_series_parameters", ["date_time"], 1)), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.TimeSeriesFile}("generation_ex_ante" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeriesFile{String}("generation_ex_ante", String, missing, false, "RenewableUnit", "RenewableUnit_time_series_files"), "generation_ex_post" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeriesFile{String}("generation_ex_post", String, missing, false, "RenewableUnit", "RenewableUnit_time_series_files"))), "HydroUnit" => PSRClassesInterface.PSRDatabaseSQLite.Collection("HydroUnit", OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter}("id" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("id", Int64, missing, false, "HydroUnit", "HydroUnit"), "label" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{String}("label", String, missing, true, "HydroUnit", "HydroUnit"), "initial_volume" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Float64}("initial_volume", Float64, missing, false, "HydroUnit", "HydroUnit"), "initial_volume_type" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("initial_volume_type", Int64, 2, false, "HydroUnit", "HydroUnit"), "has_commitment" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("has_commitment", Int64, 0, false, "HydroUnit", "HydroUnit"), "operation_type" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("operation_type", Int64, 0, false, "HydroUnit", "HydroUnit")), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation}("hydrounit_spill_to" => PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation{Int64}("hydrounit_spill_to", Int64, missing, false, "HydroUnit", "HydroUnit", "spill_to", "HydroUnit"), "hydrounit_turbine_to" => PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation{Int64}("hydrounit_turbine_to", Int64, missing, false, "HydroUnit", "HydroUnit", "turbine_to", "HydroUnit"), "gaugingstation_id" => PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation{Int64}("gaugingstation_id", Int64, missing, false, "HydroUnit", "GaugingStation", "id", "HydroUnit"), "biddinggroup_id" => PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation{Int64}("biddinggroup_id", Int64, missing, false, "HydroUnit", "BiddingGroup", "id", "HydroUnit"), "bus_id" => PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation{Int64}("bus_id", Int64, missing, false, "HydroUnit", "Bus", "id", "HydroUnit")), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.VectorParameter}("waveguide_volume" => PSRClassesInterface.PSRDatabaseSQLite.VectorParameter{Float64}("waveguide_volume", Float64, missing, true, "waveguide", "HydroUnit", "HydroUnit_vector_waveguide")), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.VectorRelation}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.TimeSeries}("existing" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Int64}("existing", Int64, missing, false, "parameters", "HydroUnit", "HydroUnit_time_series_parameters", ["date_time"], 1), "production_factor" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("production_factor", Float64, missing, false, "parameters", "HydroUnit", "HydroUnit_time_series_parameters", ["date_time"], 1), "min_generation" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("min_generation", Float64, missing, false, "parameters", "HydroUnit", "HydroUnit_time_series_parameters", ["date_time"], 1), "max_generation" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("max_generation", Float64, missing, false, "parameters", "HydroUnit", "HydroUnit_time_series_parameters", ["date_time"], 1), "max_turbining" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("max_turbining", Float64, missing, false, "parameters", "HydroUnit", "HydroUnit_time_series_parameters", ["date_time"], 1), "min_volume" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("min_volume", Float64, missing, false, "parameters", "HydroUnit", "HydroUnit_time_series_parameters", ["date_time"], 1), "max_volume" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("max_volume", Float64, missing, false, "parameters", "HydroUnit", "HydroUnit_time_series_parameters", ["date_time"], 1), "min_outflow" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("min_outflow", Float64, missing, false, "parameters", "HydroUnit", "HydroUnit_time_series_parameters", ["date_time"], 1), "om_cost" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("om_cost", Float64, missing, false, "parameters", "HydroUnit", "HydroUnit_time_series_parameters", ["date_time"], 1)), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.TimeSeriesFile}("inflow_ex_ante" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeriesFile{String}("inflow_ex_ante", String, missing, false, "HydroUnit", "HydroUnit_time_series_files"), "inflow_ex_post" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeriesFile{String}("inflow_ex_post", String, missing, false, "HydroUnit", "HydroUnit_time_series_files"))), "GaugingStation" => PSRClassesInterface.PSRDatabaseSQLite.Collection("GaugingStation", OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter}("id" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("id", Int64, missing, false, "GaugingStation", "GaugingStation"), "label" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{String}("label", String, missing, true, "GaugingStation", "GaugingStation")), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation}("gaugingstation_downstream" => PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation{Int64}("gaugingstation_downstream", Int64, missing, false, "GaugingStation", "GaugingStation", "downstream", "GaugingStation")), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.VectorParameter}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.VectorRelation}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.TimeSeries}("historical_inflow" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("historical_inflow", Float64, missing, false, "historical_inflow", "GaugingStation", "GaugingStation_time_series_historical_inflow", ["date_time"], 1)), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.TimeSeriesFile}()), "ThermalUnit" => PSRClassesInterface.PSRDatabaseSQLite.Collection("ThermalUnit", OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter}("id" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("id", Int64, missing, false, "ThermalUnit", "ThermalUnit"), "label" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{String}("label", String, missing, true, "ThermalUnit", "ThermalUnit"), "has_commitment" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("has_commitment", Int64, 0, true, "ThermalUnit", "ThermalUnit"), "max_ramp_up" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Float64}("max_ramp_up", Float64, missing, false, "ThermalUnit", "ThermalUnit"), "max_ramp_down" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Float64}("max_ramp_down", Float64, missing, false, "ThermalUnit", "ThermalUnit"), "min_uptime" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Float64}("min_uptime", Float64, missing, false, "ThermalUnit", "ThermalUnit"), "max_uptime" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Float64}("max_uptime", Float64, missing, false, "ThermalUnit", "ThermalUnit"), "min_downtime" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Float64}("min_downtime", Float64, missing, false, "ThermalUnit", "ThermalUnit"), "max_startups" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("max_startups", Int64, missing, false, "ThermalUnit", "ThermalUnit"), "max_shutdowns" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("max_shutdowns", Int64, missing, false, "ThermalUnit", "ThermalUnit")…), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation}("biddinggroup_id" => PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation{Int64}("biddinggroup_id", Int64, missing, false, "ThermalUnit", "BiddingGroup", "id", "ThermalUnit"), "bus_id" => PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation{Int64}("bus_id", Int64, missing, false, "ThermalUnit", "Bus", "id", "ThermalUnit")), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.VectorParameter}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.VectorRelation}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.TimeSeries}("existing" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Int64}("existing", Int64, missing, false, "parameters", "ThermalUnit", "ThermalUnit_time_series_parameters", ["date_time"], 1), "startup_cost" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("startup_cost", Float64, missing, false, "parameters", "ThermalUnit", "ThermalUnit_time_series_parameters", ["date_time"], 1), "min_generation" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("min_generation", Float64, missing, false, "parameters", "ThermalUnit", "ThermalUnit_time_series_parameters", ["date_time"], 1), "max_generation" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("max_generation", Float64, missing, false, "parameters", "ThermalUnit", "ThermalUnit_time_series_parameters", ["date_time"], 1), "om_cost" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("om_cost", Float64, missing, false, "parameters", "ThermalUnit", "ThermalUnit_time_series_parameters", ["date_time"], 1)), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.TimeSeriesFile}()), "Zone" => PSRClassesInterface.PSRDatabaseSQLite.Collection("Zone", OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter}("id" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("id", Int64, missing, false, "Zone", "Zone"), "label" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{String}("label", String, missing, true, "Zone", "Zone")), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.VectorParameter}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.VectorRelation}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.TimeSeries}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.TimeSeriesFile}()), "Bus" => PSRClassesInterface.PSRDatabaseSQLite.Collection("Bus", OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter}("id" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("id", Int64, missing, false, "Bus", "Bus"), "label" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{String}("label", String, missing, true, "Bus", "Bus"), "latitude" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Float64}("latitude", Float64, missing, false, "Bus", "Bus"), "longitude" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Float64}("longitude", Float64, missing, false, "Bus", "Bus")), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation}("zone_id" => PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation{Int64}("zone_id", Int64, missing, false, "Bus", "Zone", "id", "Bus")), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.VectorParameter}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.VectorRelation}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.TimeSeries}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.TimeSeriesFile}()), "DCLine" => PSRClassesInterface.PSRDatabaseSQLite.Collection("DCLine", OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter}("id" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("id", Int64, missing, false, "DCLine", "DCLine"), "label" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{String}("label", String, missing, true, "DCLine", "DCLine")), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation}("bus_from" => PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation{Int64}("bus_from", Int64, missing, false, "DCLine", "Bus", "from", "DCLine"), "bus_to" => PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation{Int64}("bus_to", Int64, missing, false, "DCLine", "Bus", "to", "DCLine")), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.VectorParameter}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.VectorRelation}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.TimeSeries}("existing" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Int64}("existing", Int64, missing, false, "parameters", "DCLine", "DCLine_time_series_parameters", ["date_time"], 1), "capacity_to" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("capacity_to", Float64, missing, false, "parameters", "DCLine", "DCLine_time_series_parameters", ["date_time"], 1), "capacity_from" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("capacity_from", Float64, missing, false, "parameters", "DCLine", "DCLine_time_series_parameters", ["date_time"], 1)), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.TimeSeriesFile}()), "Branch" => PSRClassesInterface.PSRDatabaseSQLite.Collection("Branch", OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter}("id" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("id", Int64, missing, false, "Branch", "Branch"), "label" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{String}("label", String, missing, true, "Branch", "Branch"), "line_model" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("line_model", Int64, 0, true, "Branch", "Branch")), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation}("bus_from" => PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation{Int64}("bus_from", Int64, missing, false, "Branch", "Bus", "from", "Branch"), "bus_to" => PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation{Int64}("bus_to", Int64, missing, false, "Branch", "Bus", "to", "Branch")), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.VectorParameter}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.VectorRelation}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.TimeSeries}("existing" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Int64}("existing", Int64, missing, false, "parameters", "Branch", "Branch_time_series_parameters", ["date_time"], 1), "capacity" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("capacity", Float64, missing, false, "parameters", "Branch", "Branch_time_series_parameters", ["date_time"], 1), "reactance" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("reactance", Float64, missing, false, "parameters", "Branch", "Branch_time_series_parameters", ["date_time"], 1)), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.TimeSeriesFile}()), "BatteryUnit" => PSRClassesInterface.PSRDatabaseSQLite.Collection("BatteryUnit", OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter}("id" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Int64}("id", Int64, missing, false, "BatteryUnit", "BatteryUnit"), "label" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{String}("label", String, missing, true, "BatteryUnit", "BatteryUnit"), "initial_storage" => PSRClassesInterface.PSRDatabaseSQLite.ScalarParameter{Float64}("initial_storage", Float64, missing, false, "BatteryUnit", "BatteryUnit")), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation}("biddinggroup_id" => PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation{Int64}("biddinggroup_id", Int64, missing, false, "BatteryUnit", "BiddingGroup", "id", "BatteryUnit"), "bus_id" => PSRClassesInterface.PSRDatabaseSQLite.ScalarRelation{Int64}("bus_id", Int64, missing, false, "BatteryUnit", "Bus", "id", "BatteryUnit")), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.VectorParameter}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.VectorRelation}(), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.TimeSeries}("existing" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Int64}("existing", Int64, missing, false, "parameters", "BatteryUnit", "BatteryUnit_time_series_parameters", ["date_time"], 1), "min_storage" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("min_storage", Float64, missing, false, "parameters", "BatteryUnit", "BatteryUnit_time_series_parameters", ["date_time"], 1), "max_storage" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("max_storage", Float64, missing, false, "parameters", "BatteryUnit", "BatteryUnit_time_series_parameters", ["date_time"], 1), "max_capacity" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("max_capacity", Float64, missing, false, "parameters", "BatteryUnit", "BatteryUnit_time_series_parameters", ["date_time"], 1), "om_cost" => PSRClassesInterface.PSRDatabaseSQLite.TimeSeries{Float64}("om_cost", Float64, missing, false, "parameters", "BatteryUnit", "BatteryUnit_time_series_parameters", ["date_time"], 1)), OrderedCollections.OrderedDict{String, PSRClassesInterface.PSRDatabaseSQLite.TimeSeriesFile}())…), false, PSRClassesInterface.PSRDatabaseSQLite.TimeController(Dict{Tuple{String, String}, PSRClassesInterface.PSRDatabaseSQLite.AttributeTimeSeriesCache}(), Dict{String, Bool}()))
Demand
This case will have a single demand, which we can add with the function IARA.add_demand_unit!
.
IARA.add_demand_unit!(db;
label = "dem_1",
parameters = DataFrame(;
date_time = [DateTime(0)],
existing = [1],
),
bus_id = "bus_1",
max_demand = 5.0,
)
Time Series
For this case, we have added time series files for the
- Demand
- Inflow
- Virtual Reservoir Energy Offer
- Virtual Reservoir Price Offer
They are available in the folder data/case_5
Let's take a look into each of these files before linking them.
IARA.time_series_dataframe(
joinpath(PATH_CASE, "demand.csv"),
)
Row | period | scenario | subperiod | dem_1 |
---|---|---|---|---|
Int64 | Int64 | Int64 | Float32 | |
1 | 1 | 1 | 1 | 1.0 |
2 | 1 | 1 | 2 | 1.4 |
3 | 1 | 1 | 3 | 1.8 |
4 | 1 | 1 | 4 | 2.2 |
5 | 2 | 1 | 1 | 2.6 |
6 | 2 | 1 | 2 | 3.0 |
7 | 2 | 1 | 3 | 3.4 |
8 | 2 | 1 | 4 | 3.8 |
9 | 3 | 1 | 1 | 4.2 |
10 | 3 | 1 | 2 | 4.6 |
11 | 3 | 1 | 3 | 5.0 |
12 | 3 | 1 | 4 | 5.4 |
IARA.link_time_series_to_file(
db,
"DemandUnit";
demand_ex_ante = "demand",
)
To simplify our case, we are setting the inflow to zero, so we are only working with the initial volume of the first Hydro Unit.
IARA.time_series_dataframe(
joinpath(PATH_CASE, "inflow.csv"),
)
Row | period | scenario | subperiod | hydro_1 | hydro_2 |
---|---|---|---|---|---|
Int64 | Int64 | Int64 | Float32 | Float32 | |
1 | 1 | 1 | 1 | 0.0 | 0.0 |
2 | 1 | 1 | 2 | 0.0 | 0.0 |
3 | 1 | 1 | 3 | 0.0 | 0.0 |
4 | 1 | 1 | 4 | 0.0 | 0.0 |
5 | 2 | 1 | 1 | 0.0 | 0.0 |
6 | 2 | 1 | 2 | 0.0 | 0.0 |
7 | 2 | 1 | 3 | 0.0 | 0.0 |
8 | 2 | 1 | 4 | 0.0 | 0.0 |
9 | 3 | 1 | 1 | 0.0 | 0.0 |
10 | 3 | 1 | 2 | 0.0 | 0.0 |
11 | 3 | 1 | 3 | 0.0 | 0.0 |
12 | 3 | 1 | 4 | 0.0 | 0.0 |
IARA.link_time_series_to_file(
db,
"HydroUnit";
inflow_ex_ante = "inflow",
)
IARA.time_series_dataframe(
joinpath(PATH_CASE, "virtual_reservoir_energy_offer.csv"),
)
IARA.time_series_dataframe(
joinpath(PATH_CASE, "virtual_reservoir_price_offer.csv"),
)
Row | period | scenario | bid_segment | reservoir_1 - asset_owner_1 | reservoir_1 - asset_owner_2 |
---|---|---|---|---|---|
Int64 | Int64 | Int64 | Float32 | Float32 | |
1 | 1 | 1 | 1 | 0.66 | 1.14 |
2 | 1 | 1 | 2 | 0.0 | 0.0 |
3 | 2 | 1 | 1 | 0.66 | 1.14 |
4 | 2 | 1 | 2 | 0.0 | 0.0 |
5 | 3 | 1 | 1 | 0.66 | 1.14 |
6 | 3 | 1 | 2 | 0.0 | 0.0 |
IARA.link_time_series_to_file(
db,
"VirtualReservoir";
quantity_offer = "virtual_reservoir_energy_offer",
price_offer = "virtual_reservoir_price_offer",
)
Closing the study
IARA.close_study!(db)
This page was generated using Literate.jl.