GenXProject / GenX.jl

GenX: a configurable power system capacity expansion model for studying low-carbon energy futures. More details at : https://genx.mit.edu
https://genxproject.github.io/GenX.jl/
GNU General Public License v2.0
256 stars 105 forks source link

[Question]: Basic modifications to have additional/new zones and new/additional fuels. #713

Open abooda1981 opened 2 weeks ago

abooda1981 commented 2 weeks ago

Question

Hello. I am hoping to modify GenX by doing two things:

  1. Add further zones with specified generators.
  2. Add additional types of fossil fuels, with their own emissions factors, heat rates etc.

I did not attempt the first of these, yet, but I would like to. For the second, I modified two files: "Thermal.csv" in the resources folder, and the "Fuels_data.csv". I came up with the name "NB_FO". I do notice that the prefix isn't matched to one of the other three "ME," "CT" and "MA". (Although I don't know if that's the reason).

I'd be grateful for any advice about how to do this. I have been trawling through the online help notes found here, with no luck: https://genxproject.github.io/GenX.jl/stable/

Additional context

The error message I receive when trying to implement a new fuel type, "NB_FO," this is the error message I get:

ERROR: LoadError: KeyError: key InlineStrings.String7("NB_FO") not found Stacktrace: [1] getindex(h::Dict{AbstractString, Array{Float64}}, key::InlineStrings.String7) @ Base ./dict.jl:498 [2] macro expansion @ ~/.julia/packages/GenX/QT3Ub/src/model/core/fuel.jl:182 [inlined] [3] macro expansion @ ~/.julia/packages/MutableArithmetics/xVyia/src/rewrite.jl:327 [inlined] [4] macro expansion @ ~/.julia/packages/JuMP/glJ0u/src/macros.jl:257 [inlined] [5] macro expansion @ ~/.julia/packages/JuMP/glJ0u/src/macros/@expression.jl:86 [inlined] [6] (::GenX.var"#129#176"{Dict{AbstractString, Array{Float64}}, Vector{Int64}, Vector{GenX.AbstractResource}, JuMP.Model})(y::Int64, t::Int64) @ GenX ~/.julia/packages/JuMP/glJ0u/src/Containers/macro.jl:539 [7] #84 @ ~/.julia/packages/JuMP/glJ0u/src/Containers/container.jl:85 [inlined] [8] iterate @ ./generator.jl:47 [inlined] [9] collect_to!(dest::Matrix{JuMP.AffExpr}, itr::Base.Generator{JuMP.Containers.VectorizedProductIterator{Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, JuMP.Containers.var"#84#85"{GenX.var"#129#176"{Dict{AbstractString, Array{Float64}}, Vector{Int64}, Vector{GenX.AbstractResource}, JuMP.Model}}}, offs::Int64, st::Tuple{Tuple{Int64, Int64}, Tuple{Int64, Int64}})
@ Base ./array.jl:845 [10] collect_to_with_first!(dest::Matrix{JuMP.AffExpr}, v1::JuMP.AffExpr, itr::Base.Generator{JuMP.Containers.VectorizedProductIterator{Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, JuMP.Containers.var"#84#85"{GenX.var"#129#176"{Dict{AbstractString, Array{Float64}}, Vector{Int64}, Vector{GenX.AbstractResource}, JuMP.Model}}}, st::Tuple{Tuple{Int64, Int64}, Tuple{Int64, Int64}})
@ Base ./array.jl:823 [11] collect(itr::Base.Generator{JuMP.Containers.VectorizedProductIterator{Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, JuMP.Containers.var"#84#85"{GenX.var"#129#176"{Dict{AbstractString, Array{Float64}}, Vector{Int64}, Vector{GenX.AbstractResource}, JuMP.Model}}})
@ Base ./array.jl:797 [12] map(f::Function, A::JuMP.Containers.VectorizedProductIterator{Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}) @ Base ./abstractarray.jl:2961 [13] container @ ~/.julia/packages/JuMP/glJ0u/src/Containers/container.jl:85 [inlined] [14] container @ ~/.julia/packages/JuMP/glJ0u/src/Containers/container.jl:71 [inlined] [15] container(f::Function, indices::JuMP.Containers.VectorizedProductIterator{Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, #unused#::Type{JuMP.Containers.AutoContainerType}, names::Vector{Any})
@ JuMP.Containers ~/.julia/packages/JuMP/glJ0u/src/Containers/container.jl:75 [16] macro expansion @ ~/.julia/packages/JuMP/glJ0u/src/macros.jl:393 [inlined] [17] fuel!(EP::JuMP.Model, inputs::Dict{Any, Any}, setup::Dict{Any, Any}) @ GenX ~/.julia/packages/GenX/QT3Ub/src/model/core/fuel.jl:180 [18] generate_model(setup::Dict{Any, Any}, inputs::Dict{Any, Any}, OPTIMIZER::MathOptInterface.OptimizerWithAttributes) @ GenX ~/.julia/packages/GenX/QT3Ub/src/model/generate_model.jl:127 [19] macro expansion @ ./timing.jl:382 [inlined] [20] run_genx_case_simple!(case::String, mysetup::Dict{Any, Any}, optimizer::Type) @ GenX ~/.julia/packages/GenX/QT3Ub/src/case_runners/case_runner.jl:77 [21] run_genx_case!(case::String, optimizer::Type) @ GenX ~/.julia/packages/GenX/QT3Ub/src/case_runners/case_runner.jl:37 [22] run_genx_case!(case::String) @ GenX ~/.julia/packages/GenX/QT3Ub/src/case_runners/case_runner.jl:32 [23] top-level scope @ ~/GenX.jl-main/example_systems/1_three_zones/Run.jl:3 [24] include(fname::String) @ Base.MainInclude ./client.jl:476 [25] top-level scope @ REPL[2]:1 in expression starting at /home/abed/GenX.jl-main/example_systems/1_three_zones/Run.jl:3

abooda1981 commented 2 weeks ago

...and also, to be clear, I have looked through the documentation on adding resources, but from what I can tell this doesn't apply, because I am not trying to add a new abstract type of energy resource ("thermal," "hydro," etc) but I am trying to create one ("fuel_oil") which inherits the "Thermal" properties. I assumed that I could do this by adding it to the Thermal.csv file, but what else am I missing?

lbonaldo commented 1 week ago

Hi @abooda1981. Yes, you're correct. The column names in Fuels_data.csv must match the fuel names referenced in the Fuel column of Thermal.csv. Are you using the TDR? If yes, please double-check for a TDR_results folder inside example_systems/1_three_zones. If it exists, GenX will use the time series data from that folder, including Fuels_data.csv.

abooda1981 commented 1 week ago

Hello @lbonaldo and many thanks for your reply! As a heads up: I am going to add a second question about how to add a zone/region but maybe it was my mistake to try to solve two questions at once.

I want to confirm that I did indeed change the appropriate column headings as explained. I have also ensured that TimeDomainReduction is set to "1" in the file genxsettings. Unfortunately, I have the same error as before.

I should add: I tried this with TDR set to 0, as well, and that did not help. Below I list the steps I took and also show a screen shot of the error message.

I am running Julia version 1.8.1 and I downloaded this project in the last 5 days or so.

Many thanks again!

In /resources/Thermal.csv:

1. I entered an additional row which is a copy of MA_NG (row 1)
2. I replaced the entry in column "A" with "MA_fuel_oil" instead of "MA_natural_gas_combined_cycle"
3. I replaced column "M" with "MA_FO" instead of "MA_NG"

Additionally, in the file "Fuels_data.csv" in the folder "TDR_results":

1. I copy-pasted the column for "MA_NG" and placed "MA_FO" at the top of that column. 

None of the above steps helped. Here is a screenshot:

image

abooda1981 commented 1 week ago

Okay, thanks. Not sure what I did differently but I got it to work--it's possible that I missed a space or maybe I had another typo. Many thanks! I now have a new fuel.

lbonaldo commented 1 week ago

Great news!