Skip to content

Commit

Permalink
Merge branch 'develop' into microgrid-subsystem
Browse files Browse the repository at this point in the history
  • Loading branch information
vtnate committed Jul 20, 2023
2 parents ae88af4 + 88c0748 commit be46295
Show file tree
Hide file tree
Showing 17 changed files with 9,095 additions and 8,841 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Borefield ambient coupling connections
connect(supHeaWat_{{ sys_params.num_buildings }}.ports[1], {{ coupling.plant.id }}.port_a)
connect(supHeaWat_1.ports[1], {{ coupling.plant.id }}.port_a)
{% raw %}annotation (Line(points={{-70,10},{-10,10}}, color={0,127,255}));
{% endraw %}connect({{ coupling.plant.id }}.port_b, sinHeaWat.ports[1])
{% raw %}annotation (Line(points={{10,10},{60,10}}, color={0,127,255}));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// No components for borefield and ambient loop coupling
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Borefield ambient coupling connections
connect(pumDis.port_b, {{ coupling.plant.id }}.port_a)
{% raw %}annotation (Line(points={{-44,-50},{-44,-10},{-20,-10}},color={0,127,255}));
{% endraw %}connect({{ coupling.plant.id }}.port_b, dis.port_aDisSup)
{% raw %}annotation (Line(points={{0,-10},{50,-10}},color={0,127,255}));
{% endraw %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
inner parameter
Buildings.Experimental.DHC.Examples.Combined.BaseClasses.DesignDataSeries
datDes(
nBui={{ sys_params.num_buildings }},
{% if sys_params.district_system.fifth_generation.ghe_parameters.design.flow_type == 'borehole' %}
mPumDis_flow_nominal={{ sys_params.district_system.fifth_generation.ghe_parameters.design.flow_rate*
sys_params.district_system.fifth_generation.ghe_parameters.ghe_specific_params[0].borehole.number_of_boreholes }},
{% else %}
mPumDis_flow_nominal={{ sys_params.district_system.fifth_generation.ghe_parameters.design.flow_rate }},
{% endif %}
mPipDis_flow_nominal=datDes.mPumDis_flow_nominal,
dp_length_nominal=250,
final mCon_flow_nominal={
{% for building in range( sys_params.num_buildings-1 ) %}
{{ graph.couplings_by_type(coupling.network.id).load_couplings[building].load.id }}.ets.mSerWat_flow_nominal,
{% endfor %}
{{ graph.couplings_by_type(coupling.network.id).load_couplings[sys_params.num_buildings-1].load.id }}.ets.mSerWat_flow_nominal})
"Design data"
{% raw %}annotation (Placement(transformation(extent={{-140,100},{-120,120}})));
{% endraw %}parameter Boolean allowFlowReversalSer = true
"Set to true to allow flow reversal in the service lines"
{% raw %}annotation(Dialog(tab="Assumptions"), Evaluate=true);
{% endraw %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Connections for sub-components
{% raw %}connect(masFloMaiPum.y,pumDis.m_flow_in)
annotation (Line(points={{-21,-60},{-32,-60}}, color={0,0,127}));
connect(pumDis.port_a, expVes.ports[1])
annotation (Line(points={{-44,-70},{-44,-80},{100,-80},{100,-64},{120,-64}}, color={0,127,255}));
connect(expVes.ports[2], dis.port_bDisSup)
annotation (Line(points={{120,-68},{100,-68},{100,-10},{90,-10}}, color={0,127,255}));
{% endraw %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Buildings.Controls.OBC.CDL.Continuous.Sources.Constant THeaWatSupMaxSet_{{ coupling.id }}(k=38 +
273.15) "Heating water supply temperature set point - Maximum value"
{% raw %}annotation (Placement(transformation(extent={{-120,40},{-100,60}})));
{% endraw %}Buildings.Controls.OBC.CDL.Continuous.Sources.Constant TChiWatSupSet_{{ coupling.id }}(k=18 + 273.15)
"Chilled water supply temperature set point"
{% raw %}annotation (Placement(transformation(extent={{-120,10},{-100,30}})));
{% endraw %}Buildings.Controls.OBC.CDL.Continuous.Sources.Constant THeaWatSupMinSet_{{ coupling.id }}(k=28
+ 273.15) "Heating water supply temperature set point - Minimum value"
{% raw %}annotation (Placement(transformation(extent={{-120,70},{-100,90}})));
{% endraw %}Buildings.Controls.OBC.CDL.Continuous.Sources.Constant THotWatSupSet_{{ coupling.id }}(k=63 + 273.15)
"Hot water supply temperature set point"
{% raw %}annotation (Placement(transformation(extent={{-120,-20},{-100,0}})));
{% endraw %}Buildings.Controls.OBC.CDL.Continuous.Sources.Constant TColWat_{{ coupling.id }}(k=15 + 273.15)
"Cold water temperature"
{% raw %}annotation (Placement(transformation(extent={{-120,-50},{-100,-30}})));
{% endraw %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Timeseries load and network coupling connections
connect(dis.ports_bCon[{{ sys_params.load_num }}], {{ coupling.load.id }}.port_aSerAmb)
{% raw %}annotation (Line(points={{58,0},{58,6},{46,6},{46,30},{60,30}}, color={0,127,255}));
{% endraw %}connect({{ coupling.load.id }}.port_bSerAmb, dis.ports_aCon[{{ sys_params.load_num }}])
{% raw %}annotation (Line(points={{80,30},{92,30},{92,6},{82,6},{82,0}}, color={0,127,255}));
{% endraw %}connect(THeaWatSupMinSet_{{ coupling.id }}.y, {{ coupling.load.id }}.THeaWatSupMinSet)
{% raw %}annotation (Line(points={{-98,80},{-80,80},{-80,100},{26,100},{26,39},{58,39}}, color={0,0,127}));
{% endraw %}connect(THeaWatSupMaxSet_{{ coupling.id }}.y, {{ coupling.load.id }}.THeaWatSupMaxSet)
{% raw %}annotation (Line(points={{-98,50},{34,50},{34,37},{58,37}}, color={0,0,127}));
{% endraw %}connect(TChiWatSupSet_{{ coupling.id }}.y, {{ coupling.load.id }}.TChiWatSupSet)
{% raw %}annotation (Line(points={{-98,20},{42,20},{42,35},{58,35}}, color={0,0,127}));
{% endraw %}connect(THotWatSupSet_{{ coupling.id }}.y, {{ coupling.load.id }}.THotWatSupSet)
{% raw %}annotation (Line(points={{-98,-10},{-66,-10},{-66,16},{52,16},{52,33},{58,33}}, color={0,0,127}));
{% endraw %}connect(TColWat_{{ coupling.id }}.y, {{ coupling.load.id }}.TColWat)
{% raw %}annotation (Line(points={{-98,-40},{-62,-40},{-62,4},{62,4},{62,18}}, color={0,0,127}));
{% endraw %}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{{ model.modelica_type }} {{ model.id }}(
{% if model.is_5g_district == 'bui' %}
allowFlowReversalBui = true,
allowFlowReversalSer = true,
{{ model.is_5g_district }}(T_aHeaWat_nominal(displayUnit="K")=318.15,
T_aChiWat_nominal(displayUnit="K")=291.15,
delTAirCoo(displayUnit="degC")=10,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# :copyright (c) URBANopt, Alliance for Sustainable Energy, LLC, and other contributors.
# See also https://github.com/urbanopt/geojson-modelica-translator/blob/develop/LICENSE.md

from geojson_modelica_translator.model_connectors.networks.network_base import (
NetworkBase
)


class NetworkDistributionPump(NetworkBase):
model_name = 'NetworkDistributionPump'

def __init__(self, system_parameters):
super().__init__(system_parameters)
self.id = 'MyNetworkDistributionPump'

def to_modelica(self, scaffold):
"""
:param scaffold: Scaffold object, Scaffold of the entire directory of the project.
"""
# this stub has no model to generate, its fully implemented in the coupling currently

def get_modelica_type(self, scaffold):
# this stub has no model, so there's no type
return 'UNIMPLEMENTED'
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// district distribution pipiline
Buildings.Experimental.DHC.Networks.Combined.UnidirectionalSeries dis(
redeclare final package Medium = {{ globals.medium_w }},
final nCon= datDes.nBui,
show_TOut=true,
final mDis_flow_nominal=datDes.mPipDis_flow_nominal,
final mCon_flow_nominal=datDes.mCon_flow_nominal,
final dp_length_nominal=datDes.dp_length_nominal,
final lDis=datDes.lDis,
final lCon=datDes.lCon,
final lEnd=datDes.lEnd,
final allowFlowReversal=allowFlowReversalSer)
"Distribution network"
{% raw %}annotation (Placement(transformation(extent={{50,-20},{90,0}})));
{% endraw %}// ambient loop pump
Buildings.Experimental.DHC.EnergyTransferStations.BaseClasses.Pump_m_flow pumDis(
redeclare final package Medium = {{ globals.medium_w }},
m_flow_nominal=datDes.mPumDis_flow_nominal)
"Distribution pump"
{% raw %}annotation (Placement(transformation(extent={{10,-10},{-10,10}},rotation=270,origin={-44,-60})));
{% endraw %}Modelica.Blocks.Sources.Constant masFloMaiPum(k=datDes.mPumDis_flow_nominal)
"Distribution pump mass flow rate"
{% raw %}annotation (Placement(transformation(extent={{0,-70},{-20,-50}})));
{% endraw %}// expansion vessel
Buildings.Fluid.Sources.Boundary_pT expVes(
redeclare final package Medium = {{ globals.medium_w }},
T={{ sys_params.district_system.fifth_generation.ghe_parameters.soil.undisturbed_temp}}+273.15,
nPorts=2)
"Expansion vessel"
{% raw %}annotation (Placement(transformation(extent={{140,-76},{120,-56}})));
{% endraw %}
14 changes: 7 additions & 7 deletions geojson_modelica_translator/model_connectors/plants/borefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ def to_modelica(self, scaffold):

# process g-function file
if Path(template_data["gfunction"]["input_path"]).expanduser().is_absolute():
gfunction = pd.read_csv(Path(template_data["gfunction"]["input_path"]) / "Gfunction.csv", header=0)
gfunction = pd.read_csv(Path(template_data["gfunction"]["input_path"]) / "Gfunction.csv", header=0, usecols=[0, 2])
else:
sys_param_dir = Path(self.system_parameters.filename).parent.resolve()
try:
gfunction = pd.read_csv(sys_param_dir / template_data["gfunction"]["input_path"] / "Gfunction.csv", header=0)
gfunction = pd.read_csv(sys_param_dir / template_data["gfunction"]["input_path"] / "Gfunction.csv", header=0, usecols=[0, 2])
except FileNotFoundError:
raise SystemExit(f'When using a relative path to your ghe_dir, your path \'{template_data["gfunction"]["input_path"]}\' must be relative to the dir your sys-param file is in.')
template_data["gfunction"]["gfunction_file_rows"] = gfunction.shape[0] + 1
Expand All @@ -124,11 +124,14 @@ def to_modelica(self, scaffold):
new_row = pd.Series({gfunction.columns[0]: 0, gfunction.columns[1]: 0})
gfunction = pd.concat([gfunction.iloc[:0], pd.DataFrame([new_row]), gfunction.iloc[0:]]).reset_index(drop=True)

# create borefield package paths
b_modelica_path = ModelicaPath(self.borefield_name, scaffold.plants_path.files_dir, True)

# add to dict and save MAT file to the borefield's resources folder
data_dict = {'TStep': gfunction.values}
gfunction_path = os.path.join(scaffold.plants_path.resources_dir, 'Gfunction.mat')
gfunction_path = os.path.join(b_modelica_path.resources_dir, 'Gfunction.mat')
sio.savemat(gfunction_path, data_dict)
template_data["gfunction"]["gfunction_file_path"] = gfunction_path.replace('\\', '/')
template_data["gfunction"]["gfunction_file_path"] = b_modelica_path.resources_relative_dir + "/Gfunction.mat"

# process nominal mass flow rate
if template_data["configuration"]["flow_type"] == "system":
Expand All @@ -150,9 +153,6 @@ def to_modelica(self, scaffold):
oneutube_template = self.template_env.get_template("BorefieldOneUTube.mot")
twoutube_template = self.template_env.get_template("BorefieldTwoUTubes.mot")

# create borefield package paths
b_modelica_path = ModelicaPath(self.borefield_name, scaffold.plants_path.files_dir, True)

if template_data["configuration"]["borehole_configuration"] == "singleutube":
plant_template = oneutube_template
template_data["configuration"]["borehole_configuration"] = "Buildings.Fluid.Geothermal.Borefields.Types.BoreholeConfiguration.SingleUTube"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ within {{ project_name }}.Plants.{{ model_name }};
"Set to true to force the thermal response to be calculated at the start instead of checking whether this has been pre-computed"
annotation (Dialog(tab="Advanced"));
{% endraw %}parameter String gFunFilNam=Modelica.Utilities.Files.loadResource(
"{{ghe_data["gfunction"]["gfunction_file_path"]}}")
"modelica://{{project_name}}/Plants/{{ghe_data["gfunction"]["gfunction_file_path"]}}")
{% raw %} "File name of g-function data file in MAT format";
{% endraw %}parameter Integer nTimTot={{ghe_data["gfunction"]["gfunction_file_rows"]}}
{% raw %} "Total length of g-function vector";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ within {{ project_name }}.Plants.{{ model_name }};
"Set to true to force the thermal response to be calculated at the start instead of checking whether this has been pre-computed"
annotation (Dialog(tab="Advanced"));
{% endraw %}parameter String gFunFilNam=Modelica.Utilities.Files.loadResource(
"{{ghe_data["gfunction"]["gfunction_file_path"]}}")
"modelica://{{project_name}}/Plants/{{ghe_data["gfunction"]["gfunction_file_path"]}}")
{% raw %} "File name of g-function data file in MAT format";
{% endraw %}parameter Integer nTimTot={{ghe_data["gfunction"]["gfunction_file_rows"]}}
{% raw %} "Total length of g-function vector";
Expand Down
116 changes: 58 additions & 58 deletions tests/model_connectors/data/Gfunction.csv
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
ln(t/ts),H:91.93
-48.91979309319371,-1.822663364108207
-47.5294629144498,-1.8162256957364589
-46.13913273570589,-1.809788027364711
-44.748802556961984,-1.8033503589929627
-43.358472378218075,-1.7969126906212147
-41.968142199474165,-1.7904750222494665
-40.577812020730256,-1.7840373538777183
-39.18748184198635,-1.7775996855059704
-37.79715166324244,-1.7711620171342222
-36.40682148449853,-1.764724348762474
-35.01649130575462,-1.758286680390726
-33.62616112701071,-1.7518490120189778
-32.23583094826681,-1.7454113436472298
-30.845500769522896,-1.7389736752754816
-29.455170590778987,-1.7325360069037334
-28.06484041203508,-1.7260983385319855
-26.67451023329117,-1.7196606701602373
-25.28418005454726,-1.7132230017884893
-23.89384987580335,-1.706785333416741
-22.503519697059442,-1.700347665044993
-21.113189518315533,-1.693909996673245
-19.722859339571624,-1.6874723283014967
-18.332529160827715,-1.6810346599297485
-16.942198982083806,-1.6745969915580006
-15.5518688033399,-1.4885153990472844
-14.161538624595991,-0.9616800791950322
-12.771208445852082,-0.1373890752849003
-11.380878267108173,0.7309045226911854
-9.990548088364264,1.4989474930073818
-8.600217909620355,2.21722778837189
-8.5,2.333668799654772
-7.8,2.680028116277204
-7.2,2.976579525355174
-6.5,3.3214979060006318
-5.9,3.6183780569291937
-5.2,3.985646165293046
-4.5,4.412741731362534
-3.963,4.78967983323376
-3.27,5.31964109001558
-2.864,5.639933817910789
-2.577,5.865880520772372
-2.171,6.179506729029434
-1.884,6.394511116374665
-1.191,6.876431928932908
-0.497,7.287549994326967
-0.274,7.400576450933945
-0.051,7.5026878612451275
0.196,7.602592987479888
0.419,7.680573087757184
0.642,7.747331143270593
0.873,7.8050691854404395
1.112,7.85358553376416
1.335,7.889798403899954
1.679,7.931270827487374
2.028,7.9595647196376795
2.275,7.973416909236491
3.003,7.995749059734852
ln(t/ts),H:133.24,H:133.24_bhw
-49.197432820441875,-2.4257833063534004,2.17698353724539e-06
-47.797524465506555,-2.418191266516507,2.7487739376090265e-06
-46.397616110571235,-2.410599226679613,3.320564337972663e-06
-44.99770775563591,-2.403007186842719,3.892354738336303e-06
-43.59779940070059,-2.3954151470058256,4.464145138699939e-06
-42.19789104576527,-2.3878231071689315,5.0359355390635755e-06
-40.79798269082995,-2.380231067332038,5.607725939427212e-06
-39.39807433589462,-2.3726390274951443,6.179516339790852e-06
-37.9981659809593,-2.3650469876582503,6.751306740154488e-06
-36.59825762602398,-2.3574549478213567,7.323097140518125e-06
-35.19834927108866,-2.349862907984463,7.894887540881761e-06
-33.79844091615334,-2.342270868147569,8.466677941245398e-06
-32.39853256121802,-2.3346788283106754,9.038468341609036e-06
-30.99862420628269,-2.327086788473782,9.610258741972673e-06
-29.59871585134737,-2.319494748636888,1.018204914233631e-05
-28.198807496412048,-2.311902708799994,1.0753839542699949e-05
-26.798899141476728,-2.3043106689631006,1.1325629943063585e-05
-25.398990786541408,-2.296718629126207,1.1897420343427222e-05
-23.999082431606084,-2.289126589289313,1.2469210743790859e-05
-22.599174076670764,-2.2815345494524193,1.3041001144154496e-05
-21.19926572173544,-2.2739425096155257,1.3612791544518134e-05
-19.79935736680012,-2.2663504697786316,1.4184581944881771e-05
-18.399449011864796,-2.258758429941738,1.4756372345245408e-05
-16.999540656929476,-2.2511663901048444,1.5328162745609045e-05
-15.599632301994156,-1.9633457463534643,0.00022093932160754815
-14.199723947058835,-1.2793009507075148,0.013437594652659925
-12.799815592123508,-0.2676769059738712,0.23425514610947828
-11.399907237188188,0.7791454853971596,0.8698944115300616
-9.999998882252868,1.6365310591924795,1.623825738679552
-8.60009052731755,2.3851329784030577,2.351162601844801
-8.5,2.5375745353142536,2.5375745353142536
-7.8,2.8844225526126053,2.8844225526126053
-7.2,3.1818369351009945,3.1818369351009945
-6.5,3.5426090867223863,3.5426090867223863
-5.9,3.907112809844877,3.907112809844877
-5.2,4.463841666959389,4.463841666959389
-4.5,5.2183638168277415,5.2183638168277415
-3.963,5.98662924590561,5.98662924590561
-3.27,7.398479216081889,7.398479216081889
-2.864,8.565946102105237,8.565946102105237
-2.577,9.58663143055789,9.58663143055789
-2.171,11.337770243053047,11.337770243053047
-1.884,12.81134041357907,12.81134041357907
-1.191,17.088273826464388,17.088273826464388
-0.497,22.106725017992446,22.106725017992446
-0.274,23.78106359305601,23.78106359305601
-0.051,25.380688549071017,25.380688549071017
0.196,27.027910906640415,27.027910906640415
0.419,28.355137633515394,28.355137633515394
0.642,29.523729257561136,29.523729257561136
0.873,30.54318092758083,30.54318092758083
1.112,31.39947474986325,31.39947474986325
1.335,32.04117581700403,32.04117581700403
1.679,32.76909878187493,32.76909878187493
2.028,33.26950396281488,33.26950396281488
2.275,33.518759673113806,33.518759673113806
3.003,33.933183498577804,33.933183498577804
Loading

0 comments on commit be46295

Please sign in to comment.