Skip to content

Commit

Permalink
Changed naming convention and removed old CSVs
Browse files Browse the repository at this point in the history
  • Loading branch information
clizbe authored and abelsiqueira committed Oct 18, 2023
1 parent b70f654 commit d7530a1
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 276 deletions.
22 changes: 11 additions & 11 deletions src/input_tables.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
struct NodeData
id::Int # Node ID
name::String # Name of node (geographical?)
struct AssetData
id::Int # Asset ID
name::String # Name of Asset (geographical?)
type::String # Producer/Consumer - maybe an enum?
active::Bool # Active or decomissioned
investable::Bool # Whether able to invest
Expand All @@ -11,11 +11,11 @@ struct NodeData
peak_demand::Float64 # MW
end

struct EdgeData
id::Int # Edge ID
struct FlowData
id::Int # Flow ID
carrier::String # (Optional?) Energy carrier
from_node_id::Int # Node ID
to_node_id::Int # Node ID
from_asset_id::Int # Asset ID
to_asset_id::Int # Asset ID
active::Bool # Active or decomissioned
investable::Bool # Whether able to invest
variable_cost::Float64 # kEUR/MWh
Expand All @@ -24,15 +24,15 @@ struct EdgeData
initial_capacity::Float64 # MW
end

struct EdgeProfiles
id::Int # Edge ID
struct FlowProfiles
id::Int # Flow ID
rep_period_id::Int
time_step::Int
value::Float64 # p.u.
end

struct NodeProfiles
id::Int # Node ID
struct AssetProfiles
id::Int # Asset ID
rep_period_id::Int
time_step::Int
value::Float64 # p.u.
Expand Down
44 changes: 22 additions & 22 deletions src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,35 @@ input files in the `input_folder`.
"""
function create_parameters_and_sets_from_file(input_folder::AbstractString)
# Read data
nodes_data_df = get_df(input_folder, "nodes-data.csv", NodeData; header = 2)
nodes_profiles_df = get_df(input_folder, "nodes-profiles.csv", NodeProfiles; header = 2)
# edges_data_df = get_df(input_folder, "edges-data.csv", EdgeData; header = 2)
# edges_profiles_df = get_df(input_folder, "edges-profiles.csv", EdgeProfiles; header = 2)
assets_data_df = get_df(input_folder, "assets-data.csv", AssetData; header = 2)
assets_profiles_df = get_df(input_folder, "assets-profiles.csv", AssetProfiles; header = 2)
# flows_data_df = get_df(input_folder, "flows-data.csv", FlowData; header = 2)
# flows_profiles_df = get_df(input_folder, "flows-profiles.csv", FlowProfiles; header = 2)
rep_period_df = get_df(input_folder, "rep-periods-data.csv", RepPeriodData; header = 2)

# Sets and subsets that depend on input data
A = assets = nodes_data_df[nodes_data_df.active.==true, :].name #assets in the energy system that are active
Ap = assets_producer = nodes_data_df[nodes_data_df.type.=="producer", :].name #producer assets in the energy system
Ac = assets_consumer = nodes_data_df[nodes_data_df.type.=="consumer", :].name #consumer assets in the energy system
assets_investment = nodes_data_df[nodes_data_df.investable.==true, :].name #assets with investment method in the energy system
rep_periods = unique(nodes_profiles_df.rep_period_id) #representative periods
time_steps = unique(nodes_profiles_df.time_step) #time steps in the RP (e.g., hours)
A = assets = assets_data_df[assets_data_df.active.==true, :].name #assets in the energy system that are active
Ap = assets_producer = assets_data_df[assets_data_df.type.=="producer", :].name #producer assets in the energy system
Ac = assets_consumer = assets_data_df[assets_data_df.type.=="consumer", :].name #consumer assets in the energy system
assets_investment = assets_data_df[assets_data_df.investable.==true, :].name #assets with investment method in the energy system
rep_periods = unique(assets_profiles_df.rep_period_id) #representative periods
time_steps = unique(assets_profiles_df.time_step) #time steps in the RP (e.g., hours)

# Parameters for system
rep_weight = Dict((row.id) => row.weight for row in eachrow(rep_period_df)) #representative period weight [h]

# Parameters for assets
profile = Dict(
(A[row.id], row.rep_period_id, row.time_step) => row.value for
row in eachrow(nodes_profiles_df)
row in eachrow(assets_profiles_df)
) # asset profile [p.u.]

# Parameters for producers
variable_cost = Dict{String,Float64}()
investment_cost = Dict{String,Float64}()
unit_capacity = Dict{String,Float64}()
init_capacity = Dict{String,Float64}()
for row in eachrow(nodes_data_df)
for row in eachrow(assets_data_df)
if row.name in Ap
variable_cost[row.name] = row.variable_cost
investment_cost[row.name] = row.investment_cost
Expand All @@ -47,7 +47,7 @@ function create_parameters_and_sets_from_file(input_folder::AbstractString)

# Parameters for consumers
peak_demand = Dict{String,Float64}()
for row in eachrow(nodes_data_df)
for row in eachrow(assets_data_df)
if row.name in Ac
peak_demand[row.name] = row.peak_demand
end
Expand Down Expand Up @@ -113,19 +113,19 @@ function save_solution_to_file(
end

"""
graph = create_graph(nodes_path, edges_path)
graph = create_graph(assets_path, flows_path)
Read the nodes and edges data CSVs and create a graph object.
Read the assets and flows data CSVs and create a graph object.
"""
function create_graph(nodes_path, edges_path)
nodes_df = CSV.read(nodes_path, DataFrames.DataFrame; header = 2)
edges_df = CSV.read(edges_path, DataFrames.DataFrame; header = 2)
function create_graph(assets_path, flows_path)
assets_df = CSV.read(assets_path, DataFrames.DataFrame; header = 2)
flows_df = CSV.read(flows_path, DataFrames.DataFrame; header = 2)

num_nodes = DataFrames.nrow(nodes_df)
num_assets = DataFrames.nrow(assets_df)

graph = Graphs.DiGraph(num_nodes)
for row in eachrow(edges_df)
Graphs.add_edge!(graph, row.from_node_id, row.to_node_id)
graph = Graphs.DiGraph(num_assets)
for row in eachrow(flows_df)
Graphs.add_edge!(graph, row.from_asset_id, row.to_asset_id)
end

return graph
Expand Down
8 changes: 0 additions & 8 deletions test/inputs/assets.csv

This file was deleted.

218 changes: 0 additions & 218 deletions test/inputs/profiles.csv

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 0 additions & 7 deletions test/inputs/tiny/edges-data.csv

This file was deleted.

7 changes: 7 additions & 0 deletions test/inputs/tiny/flows-data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
,,asset_id,asset_id,{true;false},{true;false},kEUR/MWh,kEUR/MW/year,MW,MW
id,carrier,from_asset_id,to_asset_id,active,investable,variable_cost,investment_cost,capacity,initial_capacity
1,electricity,1,6,true,,,,,
2,electricity,2,6,true,,,,,
3,electricity,3,6,true,,,,,
4,electricity,4,6,true,,,,,
5,electricity,5,6,true,,,,,
File renamed without changes.
5 changes: 0 additions & 5 deletions test/inputs/weights.csv

This file was deleted.

0 comments on commit d7530a1

Please sign in to comment.