Skip to content

Commit 2e9d209

Browse files
committed
minor changes
1 parent 4bfada0 commit 2e9d209

File tree

4 files changed

+37
-40
lines changed

4 files changed

+37
-40
lines changed

examples/House/config.json

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,6 @@
178178
"Vehicles_Propulsion": {
179179
"carrier_color": "tomato1"
180180
},
181-
"Heat": {
182-
"carrier_color": "firebrick2"
183-
},
184181
"Electricity": {
185182
"carrier_color": "orange"
186183
}
@@ -189,18 +186,10 @@
189186
"Import_Electricity": {
190187
"carrier_in": "Dummy",
191188
"carrier_out": "Electricity",
192-
"operational_cost_energy": 0.30,
189+
"operational_cost_energy": 0.50,
193190
"process_color": "lightcyan",
194191
"process_order": 1
195192
},
196-
"Demand_Heat": {
197-
"carrier_in": "Heat",
198-
"carrier_out": "Dummy",
199-
"min_energy_out": 3000,
200-
"output_profile": "./time_series/Household_Heat_Demand.txt",
201-
"process_color": "plum2",
202-
"process_order": 300
203-
},
204193
"Demand_Electricity": {
205194
"carrier_in": "Electricity",
206195
"carrier_out": "Dummy",
@@ -214,7 +203,7 @@
214203
"carrier_out": "Electricity",
215204
"lifetime": 20,
216205
"operational_cost_power": 15,
217-
"capital_cost_power": 1500,
206+
"capital_cost_power": 1200,
218207
"availability_profile": "./time_series/PV_availability_rescaled.txt",
219208
"process_color": "darkgoldenrod1",
220209
"process_order": 406
@@ -224,29 +213,19 @@
224213
"carrier_out": "Electricity",
225214
"lifetime": 25,
226215
"operational_cost_power": 20,
227-
"capital_cost_power": 4000,
216+
"capital_cost_power": 3500,
228217
"availability_profile": "./time_series/Onshore_Wind_Availability_rescaled.txt",
229218
"process_color": "royalblue1",
230219
"process_order": 409
231220
},
232-
"Heat_Pump": {
233-
"carrier_in": "Electricity",
234-
"carrier_out": "Heat",
235-
"efficiency": 3.7,
236-
"lifetime": 17,
237-
"operational_cost_power": 20,
238-
"capital_cost_power": 2000,
239-
"process_color": "tomato2",
240-
"process_order": 603
241-
},
242221
"Battery": {
243222
"_comment": "energy storage capacity of the battery is equal to the capacity of the conversion process(max power in and out) divided by c_rate",
244223
"carrier_in": "Electricity",
245224
"carrier_out": "Electricity",
246225
"lifetime": 15,
247-
"capital_cost_power": 1500,
226+
"capital_cost_power": 2000,
248227
"is_storage": true,
249-
"c_rate": 0.5,
228+
"c_rate": 0.3,
250229
"process_color": "green2",
251230
"process_order": 1001
252231
}

src/core/model.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function build_model(input::Input, model::Union{JuMP.Model,Nothing}=nothing)
2121
if model === nothing
2222
# Gurobi
2323
model = JuMP.Model(Gurobi.Optimizer)
24-
set_attribute(model, "Crossover", 0)
24+
# set_attribute(model, "Crossover", 0)
2525
set_attribute(model, "Method", 2)
2626

2727
# HiGHS

src/core/visualization.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ module Visualization
4242
columns = Vector{Int}()
4343
values = Vector{Float64}()
4444
colors = Vector{String}()
45-
stacks = Vector{String}()
45+
stacks = Vector{Int}()
4646

4747
for p in processes
4848
for y in input.years
4949
if (p,y) in keys(output[var_name])
5050
push!(columns,Int(y))
5151
push!(values, output[var_name][p,y])
52-
push!(stacks, string(p))
52+
push!(stacks, findfirst(==(p), processes))
5353
push!(colors, input.parameters["process_color"][p])
5454
end
5555
end
@@ -68,15 +68,14 @@ module Visualization
6868
ax,
6969
columns,
7070
values,
71-
stack = UInt64.(hash.(stacks)),
71+
stack = stacks,
7272
color = colors
7373
)
7474

7575
# Legend
76-
uniqueidx(v) = unique(i -> v[i], eachindex(v))
77-
indices = uniqueidx(stacks)
78-
labels = stacks[indices]
79-
elements = [PolyElement(polycolor =colors[i]) for i in indices]
76+
indices = unique(stacks)
77+
labels = [string(processes[i]) for i in reverse(indices)]
78+
elements = [PolyElement(polycolor =input.parameters["process_color"][processes[i]]) for i in reverse(indices)]
8079
title = "Processes"
8180

8281
Legend(fig[1,2], elements, labels, title)

test.jl

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,36 @@
2121
# model = read_from_file("model.mps")
2222
# set_optimizer(model, Gurobi.Optimizer)
2323
# optimize!(model)
24+
# PP_Wind = first(filter(p -> p.name == "PP_Wind", input.processes))
25+
# println(sum(get(output["new_capacity"],(Battery,y),0) for y in input.years))
2426

2527
# println("Conversion complete: '$input_file' -> '$output_file'")
2628

29+
# (model,vars,constraints) = CESM.Model.build_model(input)
30+
# Battery = first(filter(p -> p.name == "Battery", input.processes))
31+
# @constraint(model, sum(vars["new_capacity"][Battery,y] for y in input.years if Int(y)<=2050) >= 2, base_name="battery_increase")
32+
# CESM.Model.optimize_model(model)
33+
# output = CESM.Model.get_output(input, vars)
34+
35+
36+
37+
using JuMP
2738

2839
include("./src/core/CESM.jl")
2940
using .CESM
3041
# input = CESM.Parser.parse_input("./examples/House/config.json");
31-
# output = CESM.Model.run_model(input)
32-
# using Serialization
33-
# serialize("output.jls", output)
34-
# serialize("input.jls", input)
35-
output = deserialize("output.jls")
36-
input = deserialize("input.jls")
42+
# input = CESM.Parser.parse_input("./examples/Germany/GETM.json");
43+
# output = CESM.Model.run_optimization(input)
44+
using Serialization
45+
# serialize("output_Germany.jls", output)
46+
# serialize("input_Germany.jls", input)
47+
# output = deserialize("output_Germany.jls")
48+
# input = deserialize("input_Germany.jls")
49+
50+
# serialize("output_House.jls", output)
51+
# serialize("input_House.jls", input)
52+
output = deserialize("output_House.jls")
53+
input = deserialize("input_House.jls")
3754

3855

3956
# CESM.Visualization.plot_P_Y(input,output,"new_capacity", carrier_out=CESM.Components.Carrier("Industrial_Heat_LT"))
@@ -45,6 +62,8 @@ CESM.Visualization.plot_P_Y_T(input,output,"energy_out_time", 2030, carrier_out=
4562
# CESM.Visualization.plot_scalar(input,output,["total_cost", "operational_cost", "capital_cost"])
4663
# CESM.Visualization.plot_sankey(input,output,2050)
4764

65+
66+
4867
# using CairoMakie
4968
# using WGLMakie
5069
# WGLMakie.activate!()

0 commit comments

Comments
 (0)