-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Template initial microgrid subsystem example (#569)
* pvsubsystem template and code to render * test to build pvsubsystem model from template * transformer template and code to render * hacking in some sample transformer data to the sys-param file * new tests for transformer, and simulation tests for previous components * add calculation for line power in line and pvsubsystem templates * skip test_build_pv_subsystem because it is captured in the simulation test * add comments to pv_subsystem.mot for future improvements * add todo to get ditto-reader info about transformers into the sys-param file * add code to read transformer in- and out-going voltages from uo sdk * fix transformer template and code to use new variable names * update test sys-param file with current variable names * use .get() method for looking at opendss values * use .get() method for other transformer properties as well * formatting instance file * remove single 5g test file - district 5g test already exists * unskip testing district 5g system * add start/stop/step times to dhc test setup * re-skip the dhc simulation test * use appropriate cable in pv subsystem model * capacitor was confused with capacitive load. fixed capacitive load * use pathlib instead of os.path when adding microgrid to sys-params * tests for capacitive load model * `poetry update` * gix typo in transformer data for sys-param * potential solution to poetry dependency installation failures * fix district heating and cooling test assert path
- Loading branch information
Showing
16 changed files
with
676 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...nslator/modelica/GMT_Lib/Electrical/AC/ThreePhasesBalanced/Conversion/ACACTransformer.mot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
within; | ||
model ACACTransformer | ||
"Isolated transformer template model for GMT level 1 testing" | ||
parameter Modelica.Units.SI.Voltage VHigh = {{data["tx_incoming_voltage"]}} "Rms voltage on side 1 of the transformer (primary side)"; | ||
parameter Modelica.Units.SI.Voltage VLow = {{data["tx_outgoing_voltage"]}} "Rms voltage on side 2 of the transformer (secondary side)"; | ||
parameter Modelica.Units.SI.ApparentPower VABase = {{data["nominal_capacity"]}} "Nominal power of the transformer"; | ||
parameter Real XoverR = {{data["reactance_resistance_ratio"]}} "Ratio between the complex and real components of the impedance (XL/R)"; | ||
extends Buildings.Electrical.AC.ThreePhasesBalanced.Conversion.Examples.ACACTransformer( | ||
tra_load( | ||
VHigh=VHigh, | ||
VLow=VLow, | ||
VABase=VABase, | ||
XoverR=XoverR) | ||
); | ||
annotation ( | ||
Icon( | ||
coordinateSystem( | ||
preserveAspectRatio=false)), | ||
Diagram( | ||
coordinateSystem( | ||
preserveAspectRatio=false)), | ||
experiment( | ||
StopTime=86400, | ||
Tolerance=1e-06), | ||
Documentation( | ||
info="<html> | ||
<p>This model validates the transformer template model implemented in | ||
<a href=\"Buildings.Electrical.AC.ThreePhasesBalanced.Conversion.Examples.ACACTransformer.mo\"> | ||
Buildings.Electrical.AC.ThreePhasesBalanced.Conversion.Examples.ACACTransformer.mot</a>. | ||
</p> | ||
</html>", | ||
revisions="<html> | ||
<ul> | ||
<li> | ||
April 20, 2023 by Zhanwei He:<br/> | ||
First implementation. | ||
</li> | ||
</ul> | ||
</html>")); | ||
|
||
end ACACTransformer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from pathlib import Path | ||
|
||
from geojson_modelica_translator.modelica.simple_gmt_base import SimpleGMTBase | ||
|
||
|
||
class ACACTransformer(SimpleGMTBase): | ||
def __init__(self, system_parameters): | ||
self.system_parameters = system_parameters | ||
self.template_dir = Path(__file__).parent | ||
super().__init__(self.system_parameters, self.template_dir) | ||
|
||
def build_from_template(self, output_dir: Path): | ||
transformer_params = self.system_parameters.get_param("$.transformers") | ||
# There can be multiple capacitors so we need to loop over them | ||
for index, transformer in enumerate(transformer_params): | ||
cap_params = { | ||
'nominal_capacity': transformer["nominal_capacity"], | ||
"reactance_resistance_ratio": transformer["reactance_resistance_ratio"], | ||
"tx_incoming_voltage": transformer["tx_incoming_voltage"], | ||
"tx_outgoing_voltage": transformer["tx_outgoing_voltage"], | ||
'model_name': f"Transformer{index}", | ||
} | ||
# render template to final modelica file | ||
self.to_modelica(output_dir=output_dir, model_name='ACACTransformer', param_data=cap_params, iteration=index) |
3 changes: 2 additions & 1 deletion
3
...n_modelica_translator/modelica/GMT_Lib/Electrical/AC/ThreePhasesBalanced/Lines/ACLine.mot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
...C/ThreePhasesBalanced/Loads/Capacitor.mot → .../ThreePhasesBalanced/Loads/Capacitive.mot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...odelica_translator/modelica/GMT_Lib/Electrical/AC/ThreePhasesBalanced/Loads/capacitive.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import logging | ||
from pathlib import Path | ||
|
||
from geojson_modelica_translator.modelica.simple_gmt_base import SimpleGMTBase | ||
|
||
logger = logging.getLogger(__name__) | ||
logging.basicConfig( | ||
level=logging.INFO, | ||
format='%(asctime)s - %(levelname)s: %(message)s', | ||
datefmt='%d-%b-%y %H:%M:%S', | ||
) | ||
|
||
|
||
class Capacitive_load(SimpleGMTBase): | ||
def __init__(self, system_parameters): | ||
self.system_parameters = system_parameters | ||
self.template_dir = Path(__file__).parent | ||
super().__init__(self.system_parameters, self.template_dir) | ||
|
||
def build_from_template(self, output_dir: Path): | ||
for building_index, building in enumerate(self.system_parameters.get_param("$.buildings")): | ||
capacitive_params = { | ||
'nominal_power_consumption': building["load"]["max_power_kw"], | ||
'nominal_voltage': building["load"]["nominal_voltage"], | ||
'model_name': f"Capacitive{building_index}", | ||
} | ||
# render template to final modelica file | ||
self.to_modelica( | ||
output_dir=output_dir, | ||
model_name='Capacitive', | ||
param_data=capacitive_params, | ||
iteration=building_index | ||
) | ||
# If the sys-param file is missing an entry, it will show up as a jinja2.exceptions.UndefinedError |
File renamed without changes.
99 changes: 99 additions & 0 deletions
99
geojson_modelica_translator/modelica/GMT_Lib/Electrical/Examples/PVsubsystem.mot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
within ; | ||
model PVsubsystem | ||
"microgrid template model for GMT level 1 testing" | ||
//grid parameters | ||
parameter Modelica.Units.SI.Frequency f_gri= {{data["electrical_grid"]["frequency"]}}; | ||
parameter Modelica.Units.SI.Voltage V_gri = {{data["electrical_grid"]["source_rms_voltage"]}}; | ||
parameter Modelica.Units.SI.Angle phiSou_gri = {{data["electrical_grid"]["source_phase_shift"]}}; | ||
//PVPanels parameters | ||
parameter Modelica.Units.SI.Area A_PV = {{ data["photovoltaic_panels"][0]["net_surface_area"] }}; | ||
parameter Modelica.Units.SI.Voltage V_nominalPV = {{ data["photovoltaic_panels"][0]["nominal_voltage"] }}; | ||
parameter Modelica.Units.SI.Angle til_PV = {{ data["photovoltaic_panels"][0]["surface_tilt"] }}; | ||
parameter Modelica.Units.SI.Angle azi_PV = {{ data["photovoltaic_panels"][0]["surface_azimuth"] }}; | ||
//inductive load parameters | ||
parameter Modelica.Units.SI.Power P_nominalInd=-{{ data["buildings"][0]["load"]["max_power_kw"] }} "The negative sign means this the load consumption"; | ||
|
||
parameter Real line_safety_factor = 1.2; | ||
|
||
//PV line parameters | ||
// FIXME: We should use more than a single entry in the sys-param file. pv_subsystem.py should be more sophisticated | ||
parameter Modelica.Units.SI.Length l_LPV={{ data["distribution_lines"][0]["length"] }}; | ||
parameter Modelica.Units.SI.Voltage V_nominal_LPV={{ data["distribution_lines"][0]["nominal_voltage"] }}; | ||
// P_nominal is a required parameter of the line. I think the MBL model should use ampacity instead, but se la vie. | ||
parameter Modelica.Units.SI.Voltage P_nominal_LPV={{ data["distribution_lines"][0]["nominal_voltage"] }}*{{ data["distribution_lines"][0]["ampacity"] }}*line_safety_factor; | ||
//inductive load line parameters | ||
parameter Modelica.Units.SI.Length l_Lind={{ data["distribution_lines"][1]["length"] }}; | ||
parameter Modelica.Units.SI.Voltage V_nominal_Lind={{ data["distribution_lines"][1]["nominal_voltage"]}}; | ||
// P_nominal is a required parameter of the line. I think the MBL model should use ampacity instead, but se la vie. | ||
parameter Modelica.Units.SI.Voltage P_nominal_Lind={{ data["distribution_lines"][1]["nominal_voltage"] }}*{{ data["distribution_lines"][1]["ampacity"] }}*line_safety_factor; | ||
|
||
|
||
Modelica.Blocks.Sources.Constant load(k=1) "Load consumption" | ||
{% raw %}annotation (Placement(transformation(extent={{124,-34},{100,-10}}))); | ||
Buildings.BoundaryConditions.WeatherData.ReaderTMY3 | ||
weaDat(computeWetBulbTemperature=false, filNam= | ||
ModelicaServices.ExternalReferences.loadResource( | ||
"modelica://Buildings/Resources/weatherdata/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.mos")) | ||
annotation (Placement(transformation(extent={{-16,108},{-40,132}}))); | ||
Buildings.Electrical.AC.ThreePhasesBalanced.Loads.Inductive InductiveLoad( | ||
mode=Buildings.Electrical.Types.Load.VariableZ_y_input, | ||
P_nominal=P_nominalInd) | ||
annotation (Placement(transformation(extent={{40,-56},{76,-24}}))); | ||
Buildings.Electrical.AC.ThreePhasesBalanced.Sources.PVSimpleOriented PV( | ||
A=A_PV, | ||
V_nominal=V_nominalPV, | ||
til=til_PV, | ||
azi=azi_PV) "PV array oriented" | ||
annotation (Placement(transformation(extent={{-78,42},{-40,78}}))); | ||
Buildings.Electrical.AC.ThreePhasesBalanced.Sources.Grid grid( | ||
f=f_gri, | ||
V=V_gri, | ||
phiSou=phiSou_gri) | ||
"Electrical grid model" | ||
annotation (Placement(transformation(extent={{-132,2},{-106,26}}))); | ||
Buildings.Electrical.AC.ThreePhasesBalanced.Lines.Line line_PV( | ||
l=l_LPV, | ||
P_nominal=P_nominal_LPV, | ||
redeclare Buildings.Electrical.Transmission.MediumVoltageCables.Generic | ||
// TODO: commercialCable should be templatized using the same selection from Lines.py | ||
commercialCable = Buildings.Electrical.Transmission.MediumVoltageCables.Annealed_Al_1000(), | ||
V_nominal=V_nominal_LPV) "line model uses the medium voltage option" | ||
annotation (Placement(transformation( | ||
extent={{10,-10},{-10,10}}, | ||
rotation=90, | ||
origin={-80,20}))); | ||
Buildings.Electrical.AC.ThreePhasesBalanced.Lines.Line line_ind( | ||
l=l_Lind, | ||
P_nominal=P_nominal_Lind, | ||
redeclare Buildings.Electrical.Transmission.MediumVoltageCables.Generic | ||
// TODO: commercialCable should be templatized using the same selection from Lines.py | ||
commercialCable = Buildings.Electrical.Transmission.MediumVoltageCables.Annealed_Al_1000(), | ||
V_nominal=V_nominal_Lind) "line model uses the medium voltage option" | ||
annotation (Placement(transformation( | ||
extent={{-10,-10},{10,10}}, | ||
rotation=0, | ||
origin={10,-40}))); | ||
equation | ||
connect(weaDat.weaBus, PV.weaBus) annotation (Line( | ||
points={{-40,120},{-59,120},{-59,76.2}}, | ||
color={255,204,51}, | ||
thickness=0.5)); | ||
connect(load.y, InductiveLoad.y) annotation (Line(points={{98.8,-22},{90,-22}, | ||
{90,-40},{76,-40}}, color={0,0,127})); | ||
connect(PV.terminal, line_PV.terminal_n) | ||
annotation (Line(points={{-78,60},{-80,60},{-80,30}}, color={0,120,120})); | ||
connect(line_PV.terminal_p, line_ind.terminal_n) annotation (Line(points={{ | ||
-80,10},{-80,-40},{-8.88178e-16,-40}}, color={0,120,120})); | ||
connect(line_ind.terminal_p, InductiveLoad.terminal) | ||
annotation (Line(points={{20,-40},{40,-40}}, color={0,120,120})); | ||
connect(grid.terminal, line_ind.terminal_n) annotation (Line(points={{-119,2}, | ||
{-119,-40},{-8.88178e-16,-40}}, color={0,120,120})); | ||
annotation ( | ||
Icon(coordinateSystem(preserveAspectRatio=false, extent={{-160,-80},{140, | ||
140}})), | ||
Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-160,-80},{140, | ||
140}})), | ||
uses( Modelica(version="4.0.0"), | ||
ModelicaServices(version="4.0.0"), | ||
Buildings(version="9.1.0"))); | ||
{% endraw %}end PVsubsystem; |
14 changes: 14 additions & 0 deletions
14
geojson_modelica_translator/modelica/GMT_Lib/Electrical/Examples/pv_subsystem.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from pathlib import Path | ||
|
||
from geojson_modelica_translator.modelica.simple_gmt_base import SimpleGMTBase | ||
|
||
|
||
class PVSubsystem(SimpleGMTBase): | ||
def __init__(self, system_parameters): | ||
self.system_parameters = system_parameters | ||
self.template_dir = Path(__file__).parent | ||
super().__init__(self.system_parameters, self.template_dir) | ||
|
||
def build_from_template(self, output_dir: Path): | ||
pv_subsystem_params = self.system_parameters.get_param("$") | ||
self.to_modelica(output_dir=output_dir, model_name='PVsubsystem', param_data=pv_subsystem_params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.