Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Strömer committed Aug 20, 2024
2 parents 4a5c9e9 + 4d15a55 commit 810038c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "IESoptLib"
uuid = "b98f706d-40ec-4ce6-a66c-1c6e71d3cef6"
version = "0.2.0"
version = "0.3.0"

[compat]
julia = "1.9"
29 changes: 7 additions & 22 deletions assets/addons/CHP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,14 @@ module Addon_CHP

import IESopt

function build(comp::IESopt._CoreComponent)
model = comp.model
linked_unit = IESopt.component(model, comp.config["linked"])

# Check if linked Unit is already initialized, if not it will be the one to handle everything.
(linked_unit.init_state[] != :initialized) && return

# Prepare the "heat" and "power" components (for easy access).
if occursin("power", comp.name)
comp_power = comp
comp_heat = linked_unit
elseif occursin("heat", comp.name)
comp_power = linked_unit
comp_heat = comp
else
@error "[Addon_CHP] Encountered unknown heat<>power setup" name = comp.name
return false
end
function build(comp_heat::IESopt._CoreComponent)
model = comp_heat.model
comp_power = IESopt.component(model, comp_heat.config["linked"])

# Get all needed objects / parameters.
T = model.ext[:iesopt].model.T
cm = comp.config["cm"]
cv = comp.config["cv"]
cm = comp_heat.config["cm"]
cv = comp_heat.config["cv"]

# Extract P_max from the "power component"
if comp_power.capacity_carrier.carrier.name != "electricity"
Expand All @@ -36,12 +21,12 @@ function build(comp::IESopt._CoreComponent)

# Construct the backpressure constraint.
# `c_m \cdot heat_t <= power_t`
comp.ext["constr_addon_CHP_backpressure"] =
comp_heat.ext["constr_addon_CHP_backpressure"] =
IESopt.@constraint(model, [t = T], cm * comp_heat.exp.out_heat[t] <= comp_power.exp.out_electricity[t])

# Construct the isofuel constraint.
# `power_t <= p_max - c_v \cdot heat_t`
comp.ext["constr_addon_CHP_isofuel"] =
comp_heat.ext["constr_addon_CHP_isofuel"] =
IESopt.@constraint(model, [t = T], comp_power.exp.out_electricity[t] <= p_max - cv * comp_heat.exp.out_heat[t])

@info "[Addon_CHP] Finished constructing constraints"
Expand Down
6 changes: 1 addition & 5 deletions assets/templates/CHP.iesopt.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ components:
outputs: {electricity: <power_out>, co2: <co2_out>}
conversion: 1 <fuel> -> <efficiency> electricity + <fuel_co2_emission_factor> co2
capacity: <p_max> out:electricity
addon: chp_addon
config:
cm: <power_ratio>
cv: <power_loss_ratio>
linked: <self>.heat
build_priority: 1 # this component will be built before the heat component with default priority 0

heat:
type: Unit
Expand Down

0 comments on commit 810038c

Please sign in to comment.