Skip to content

Commit

Permalink
Modify PV panel to scale with sun resource
Browse files Browse the repository at this point in the history
Need to warn user if the PVPanel has existing capacity, otherwise
solution is unbounded.

The output power does not make any sense, there must be a typo
The aggragated delivered power correspond to aggregated ghi multiplied
by the optimized capacity
  • Loading branch information
Bachibouzouk committed Oct 14, 2024
1 parent e8bea9d commit 1e2b690
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name;type
equal_solar_resource;equal_solar_resource
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name;type;carrier;tech;capacity;capacity_cost;bus;marginal_cost;carrier_cost;profile;output_parameters;expandable
solar-radiation;dispatchable;solar-energy;source;0;0;solar-energy-bus;0.0;0;ghi-profile;{};True
back-up-elec;dispatchable;electricity;source;0;0;elec-bus;0.5;0;;{};True
solar-radiation;volatile;solar-energy;source;0;0;solar-energy-bus;0.0;0.0;ghi;{};True
back-up-elec;dispatchable;electricity;source;0;10;elec-bus;10.0;0.3;1.0;{};True
4 changes: 2 additions & 2 deletions examples/scenarios/wefe_pv_panel/data/elements/pv_panel.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
name;type;carrier;tech;capacity;capacity_cost;marginal_cost;carrier_cost;from_bus;to_bus;t_air;ghi;pv_type;expandable
pv-panel;pv-panel;solar-energy;pv;0;0;0;0;solar-energy-bus;elec-bus;t-air;ghi;boviet_450;False
name;type;carrier;tech;capacity;capacity_cost;marginal_cost;carrier_cost;capacity_potential;from_bus;to_bus;t_air;ghi;p_rpv;r_ref;n_t;t_c_ref;noct;expandable
pv-panel;pv-panel;solar-energy;pv;0;0;0;-0.1;100;solar-energy-bus;elec-bus;t-air;ghi;270;1000;-0.0037;25;48;True
62 changes: 56 additions & 6 deletions examples/scenarios/wefe_pv_panel/datapackage.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
{
"profile": "tabular-data-package",
"name": "wefe_pv_panel",
"oemof_tabular_version": "0.0.5",
"oemof_tabular_version": "0.0.6dev",
"resources": [
{
"path": "data/constraints/solar_constraints.csv",
"profile": "tabular-data-resource",
"name": "solar_constraints",
"format": "csv",
"mediatype": "text/csv",
"encoding": "utf-8",
"schema": {
"fields": [
{
"name": "name",
"type": "string",
"format": "default"
},
{
"name": "type",
"type": "string",
"format": "default"
}
],
"missingValues": [
""
]
}
},
{
"path": "data/elements/bus.csv",
"profile": "tabular-data-resource",
Expand Down Expand Up @@ -86,7 +111,7 @@
},
{
"name": "carrier_cost",
"type": "integer",
"type": "number",
"format": "default"
},
{
Expand Down Expand Up @@ -120,7 +145,7 @@
{
"fields": "profile",
"reference": {
"resource": "dispatchable_profile"
"resource": "pv_panel_profile"
}
}
]
Expand Down Expand Up @@ -273,6 +298,11 @@
},
{
"name": "carrier_cost",
"type": "number",
"format": "default"
},
{
"name": "capacity_potential",
"type": "integer",
"format": "default"
},
Expand All @@ -297,8 +327,28 @@
"format": "default"
},
{
"name": "pv_type",
"type": "string",
"name": "p_rpv",
"type": "integer",
"format": "default"
},
{
"name": "r_ref",
"type": "integer",
"format": "default"
},
{
"name": "n_t",
"type": "number",
"format": "default"
},
{
"name": "t_c_ref",
"type": "integer",
"format": "default"
},
{
"name": "noct",
"type": "integer",
"format": "default"
},
{
Expand Down Expand Up @@ -427,4 +477,4 @@
}
}
]
}
}
31 changes: 27 additions & 4 deletions src/oemof_tabular_plugins/wefe/constraints/constraint_facades.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
from dataclasses import dataclass
from oemof.solph.components import Source
from oemof.solph.constraints import equate_variables
from oemof.tabular.constraint_facades import ConstraintFacade

Expand All @@ -13,19 +14,41 @@ def build_constraint(self, model):
# to use the constraints in oemof.solph, we need to pass the model.
# Check if there are flows with the keyword attribute

crops = [n for n in model.nodes if n.type == "crop"]
crops = [n for n in model.nodes if n.type in ("pv-panel", "crop", "mimo-crop")]
for crop in crops:
harvest_bus = crop.harvest_bus
solar_bus = crop.solar_bus
if crop.type == "crop":
invest_bus = crop.harvest_bus
component_capacity = model.InvestmentFlowBlock.invest[
crop, invest_bus, 0
]
solar_bus = crop.solar_bus
elif crop.type == "pv-panel":
invest_bus = crop.to_bus
component_capacity = model.InvestmentFlowBlock.invest[
crop, invest_bus, 0
]
solar_bus = crop.from_bus

elif crop.type == "mimo-crop":
if crop.expandable is True:
invest_bus = model.es.groups[crop.primary]
component_capacity = model.InvestmentFlowBlock.invest[
invest_bus, crop, 0
]
else:
component_capacity = None
solar_bus = crop.solar_energy_bus

solar_nodes = [n for n in solar_bus.inputs if n.tech == "source"]

solar_radiation = solar_nodes[0]
if crop.expandable is True and solar_radiation.expandable is True:
try:
# Add constraint to the model
equate_variables(
model,
model.InvestmentFlowBlock.invest[crop, harvest_bus, 0],
model.InvestmentFlowBlock.invest[solar_radiation, solar_bus, 0],
component_capacity,
)
except KeyError:
logging.error(
Expand Down
17 changes: 9 additions & 8 deletions src/oemof_tabular_plugins/wefe/facades/pv_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def build_solph_components(self):

self.conversion_factors.update(
{
self.from_bus: sequence(1),
self.from_bus: sequence(ghi_values),
self.to_bus: sequence(pv_efficiency_list),
}
)
Expand All @@ -136,6 +136,7 @@ def build_solph_components(self):
self.outputs.update(
{
self.to_bus: Flow(
fix=pv_tf_values,
nominal_value=self._nominal_value(),
variable_costs=self.marginal_cost,
investment=self._investment(),
Expand All @@ -144,12 +145,12 @@ def build_solph_components(self):
}
)

def processing_raw_inputs(self, resource, results_df):
# function to apply on df from above
def processing_raw_inputs(self, resource, results_df):
# function to apply on df from above

return results_df
return results_df

def validate_datapackage(self, resource):
# modify the resource (datapackage.resource)
# should it return the resource?
pass
def validate_datapackage(self, resource):
# modify the resource (datapackage.resource)
# should it return the resource?
pass

0 comments on commit 1e2b690

Please sign in to comment.