-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #789 from RWTH-EBC/771-add-besmod-export
771 add besmod export
- Loading branch information
Showing
67 changed files
with
1,970 additions
and
252 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,213 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": "# Example 11: Export Modelica models for BESMod library using TEASER API\nThis module demonstrates how to export building models from a TEASER project\nto ready-to-run simulation models for the Modelica BESMod library.\nBESMod enables seamless integration with state-of-the-art energy systems,\nsuch as heat pumps and photovoltaic systems. These systems can be utilized\nto generate primary energy demand curves (e.g., for electricity or gas) or\nto conduct in-depth analyses of building energy systems. In contrast,\nAixLib focuses on ideal heat demand calculation, and IBPSA on\nfree floating temperature without an ideal heater.\nYou can execute this example using\n[jupyter-notebook](https://mybinder.org/v2/gh/RWTH-EBC/TEASER/main?labpath=docs%2Fjupyter_notebooks)\n" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": "import teaser.examples.e1_generate_archetype as e1\nimport teaser.logic.utilities as utilities\nimport os\n" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": "## Standard export\nIn e1_generate_archetype we created a Project with three archetype\nbuildings to get this Project we rerun this example\n" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": "prj = e1.example_generate_archetype()\n" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": "Configure project settings to ensure compatibility with BESMod. The BESMod\nlibrary uses the AixLib.ThermalZones.ReducedOrder.ThermalZone.ThermalZone model\nwith 4 elements for the demand building model. Other numbers of elements are possible,\nbut compatability with ARoof for PV and AFloor for UFH systems must be checked first.\nSet these parameters in the project:\n" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": "prj.used_library_calc = 'AixLib'\nprj.number_of_elements_calc = 4\n" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": "BESMod allows building models to be included in predefined example energy systems:\n" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": "examples = [\n \"TEASERHeatLoadCalculation\", # Ideal electric heater for heat load calculations\n \"HeatPumpMonoenergetic\", # Heat pump with radiators, buffer and DHW storage, and PV\n \"GasBoilerBuildingOnly\" # Gas boiler with radiators\n]\n" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": "For the hydraulic systems, you have to specify a nominal supply temperature\nfor heat transfer, e.g. in radiators.\nMultiple options are available:\n" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": "Option 1: Set a single value for all buildings and zones.\n" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": "THydSup_nominal = 55 + 273.15\n" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": "Option 2: Set values for each building or thermal zone.\n" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": "THydSup_nominal = {\"ResidentialBuilding\": 328.15,\n \"OfficeBuilding\": 328.15,\n \"InstituteBuilding\": {\"Office\": 343.15,\n \"Floor\": 343.15,\n \"Storage\": 343.15,\n \"Meeting\": 343.15,\n \"Restroom\": 343.15,\n \"ICT\": 343.15,\n \"Laboratory\": 328.15},\n \"InstituteBuildingMoisture\": 343.15,\n \"ResidentialBuildingTabula\": 328.15,\n \"ResidentialBuildingTabulaMulti\": 328.15}\n" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": "Option 3: Specify values based on construction year.\nHere, the value of the next higher specified year is set to the building.\nThe classification here is taken from:\nhttps://www.ffe.de/projekte/waermepumpen-fahrplan-finanzielle-kipppunkte-zur-modernisierung-mit-waermepumpen-im-wohngebaeudebestand/\n" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": "THydSup_nominal = {\n 1950: 90 + 273.15,\n 1980: 70 + 273.15,\n 2010: 55 + 273.15,\n 2024: 35 + 273.15\n}\n" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": "In the examples, the parameters for BESMod.Systems.UserProfiles.TEASERProfiles are configured,\nincluding internal gains and heating profiles for each zone.\nBESMod requires 24-hour heating profiles, which are used\nto define the parameters of the `setBakTSetZone` Pulse block.\nBy default, the TEASER profiles are applied, but these can be customized if needed.\n" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": "Additionally, location-specific parameters must be set, which can be achieved using the following function.\nThe default values provided here correspond to Mannheim.\n" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": "weather_file_path = utilities.get_full_path(\n os.path.join(\n \"data\",\n \"input\",\n \"inputdata\",\n \"weatherdata\",\n \"DEU_BW_Mannheim_107290_TRY2010_12_Jahr_BBSR.mos\"))\n\nprj.set_location_parameters(t_outside=262.65,\n t_ground=286.15,\n weather_file_path=weather_file_path,\n calc_all_buildings=True)\n" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": "To make sure the parameters are calculated correctly we recommend to\nrun prj.calc_all_buildings() function which is here already done in the set_location_parameters function.\n" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": "Export all buildings to BESMod and include them in predefined example systems.\n" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": "path = prj.export_besmod(\n THydSup_nominal=THydSup_nominal,\n path=None,\n examples=examples\n)\n" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": "## Partial retrofit export\nThe partial retrofit option of the energy system in BESMod can also be utilized.\nFor more information on this see BESMod.UsersGuide.GettingStarted.Parameterization.\nTo enable this here, the nominal heat flow of each zone in the building must be extracted prior to the retrofit.\n" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": "QBuiOld_flow_design = {\n bldg.name: {\n tz.name: tz.model_attr.heat_load for tz in bldg.thermal_zones\n }\n for bldg in prj.buildings\n}\n" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": "Retrofit project buildings and recalculate parameters.\n" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": "prj.name = \"ArchetypeExample_partial_retrofit\"\nprj.retrofit_all_buildings(\n year_of_retrofit=2015,\n type_of_retrofit=\"adv_retrofit\",\n window_type='Alu- oder Stahlfenster, Isolierverglasung',\n material='EPS_perimeter_insulation_top_layer'\n)\nprj.calc_all_buildings()\n" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": "By default, radiator transfer systems are not retrofitted when the\nQBuiOld_flow_design parameter is provided and differs from the new nominal heat flow.\nAdditionally, new THydSup_nominal temperatures can be specified alongside\nTHydSupOld_design values, which are used for radiator sizing but not for control settings.\n" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": "path = prj.export_besmod(\n THydSup_nominal=THydSup_nominal,\n QBuiOld_flow_design=QBuiOld_flow_design,\n path=None,\n examples=examples\n)\n" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": "## Custom export\nAdditionally, we have the flexibility to define custom templates for including buildings in specific setups.\nFor instance, a custom template is defined here to include the building in the\nModelicaConferencePaper example from BESMod, which features an integrated battery system.\n" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": "Custom template\n```\n< %namespace file = \"/modelica_language/\" import=\"get_list\" / >\nwithin ${bldg.parent.name}.${bldg.name};\nmodel ModelicaConferencePaper${bldg.name}\n extends BESMod.Examples.ModelicaConferencePaper.PartialModelicaConferenceUseCase(\n redeclare ${bldg.name} building,\n redeclare BESMod.Systems.UserProfiles.TEASERProfiles\n userProfiles(fileNameIntGains=Modelica.Utilities.Files.loadResource(\n \"modelica://${bldg.parent.name}/${bldg.name}/InternalGains_${bldg.name}.txt\"),\n setBakTSetZone(amplitude=${get_list(setBakTSetZone_amplitude)},\n width =${get_list(setBakTSetZone_width)},\n startTime =${get_list(setBakTSetZone_startTime)})),\n systemParameters(nZones=${len(bldg.thermal_zones)},\n QBui_flow_nominal = building.QRec_flow_nominal,\n TOda_nominal =${TOda_nominal},\n TSetZone_nominal =${get_list(TSetZone_nominal)},\n THydSup_nominal =${THydSup_nominal},\n QBuiOld_flow_design =${QBuiOld_flow_design},\n THydSupOld_design =${THydSupOld_design},\n filNamWea = Modelica.Utilities.Files.loadResource(\n \"modelica://${bldg.parent.name}/Resources/${bldg.parent.weather_file_name}\")));\n\n extends Modelica.Icons.Example;\n\n annotation(experiment(StopTime=172800,\n Interval=600,\n Tolerance=1e-06),\n __Dymola_Commands(file=\n \"Resources/Scripts/Dymola/${bldg.name}/ModelicaConferencePaper${bldg.name}.mos\"\n \"Simulate and plot\"));\nend\nModelicaConferencePaper${bldg.name};\n```\n" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": "prj.name = \"ArchetypeExample_custom\"\n\ncustom_template_path = os.path.join(\n os.path.dirname(__file__), \"examplefiles\", \"custom_besmod_templates\"\n)\ncustom_example_template = {\"ModelicaConferencePaper\": os.path.join(custom_template_path, \"custom_template.txt\")}\n" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": "The template also includes a .mos script as part of its annotation.\nBy default, the provided examples export a basic \"simulate and plot\" script,\nwhich is incorporated into their annotation, as shown in the custom example.\nAdditionally, you have the flexibility to modify the template for existing examples\nand define custom scripts for your tailored examples.\n" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": "custom_script = {\"HeatPumpMonoenergetic\": os.path.join(custom_template_path, \"custom_script_hp_mono.txt\"),\n \"ModelicaConferencePaper\": os.path.join(custom_template_path, \"custom_script.txt\")}\n\npath = prj.export_besmod(\n THydSup_nominal=THydSup_nominal,\n path=None,\n examples=examples,\n custom_examples=custom_example_template,\n custom_script=custom_script\n)\n" | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
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
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.