diff --git a/Buildings/Resources/C-Sources/EnergyPlus_24_2_0_Wrapper.c b/Buildings/Resources/C-Sources/EnergyPlus_24_2_0_Wrapper.c index 359130db4fe..965152bd129 100644 --- a/Buildings/Resources/C-Sources/EnergyPlus_24_2_0_Wrapper.c +++ b/Buildings/Resources/C-Sources/EnergyPlus_24_2_0_Wrapper.c @@ -36,6 +36,10 @@ void* allocate_Modelica_EnergyPlus_24_2_0( const char* idfVersion, const char* idfName, const char* epwName, + const char* epName, + const char* hvacZone, + const int autosizeHVAC, + const int use_sizingPeriods, int runPeriod_dayOfWeekForStartDay, int runPeriod_applyWeekEndHolidayRule, int runPeriod_use_weatherFileDaylightSavingPeriod, @@ -43,7 +47,6 @@ void* allocate_Modelica_EnergyPlus_24_2_0( int runPeriod_use_weatherFileRainIndicators, int runPeriod_use_weatherFileSnowIndicators, double relativeSurfaceTolerance, - const char* epName, int usePrecompiledFMU, const char* fmuName, const char* buildingsRootFileLocation, @@ -88,9 +91,12 @@ void* allocate_Modelica_EnergyPlus_24_2_0( idfVersion, idfName, epwName, + epName, + hvacZone, + autosizeHVAC, + use_sizingPeriods, &runPer, relativeSurfaceTolerance, - epName, usePrecompiledFMU, fmuName, buildingsRootFileLocation, diff --git a/Buildings/Resources/C-Sources/EnergyPlus_24_2_0_Wrapper.h b/Buildings/Resources/C-Sources/EnergyPlus_24_2_0_Wrapper.h index 7707346cfcd..4649e603d09 100644 --- a/Buildings/Resources/C-Sources/EnergyPlus_24_2_0_Wrapper.h +++ b/Buildings/Resources/C-Sources/EnergyPlus_24_2_0_Wrapper.h @@ -49,9 +49,12 @@ extern void* allocate_Spawn_EnergyPlus_24_2_0( const char* idfVersion, const char* idfName, const char* epwName, + const char* epName, + const char* hvacZone, + const int autosizeHVAC, + const int use_sizingPeriods, const runPeriod* runPer, double relativeSurfaceTolerance, - const char* epName, int usePrecompiledFMU, const char* fmuName, const char* buildingsRootFileLocation, diff --git a/Buildings/Resources/Library/linux64/libModelicaBuildingsEnergyPlus_24_2_0.so b/Buildings/Resources/Library/linux64/libModelicaBuildingsEnergyPlus_24_2_0.so index 874b47a7ad0..74929efaa67 100644 --- a/Buildings/Resources/Library/linux64/libModelicaBuildingsEnergyPlus_24_2_0.so +++ b/Buildings/Resources/Library/linux64/libModelicaBuildingsEnergyPlus_24_2_0.so @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bfe26f706fd2494f0471000932798630934b208e10610c7892524f4e5c251bfa -size 81672 +oid sha256:40f0cf0f8214f1af23aacc18edfeb4758c772c6dc2123cd3b58a681c23117046 +size 85848 diff --git a/Buildings/Resources/Scripts/travis/pyfmi/runSpawnFromOtherDirectory.py b/Buildings/Resources/Scripts/travis/pyfmi/runSpawnFromOtherDirectory.py index 7ea88f447bb..50f2b551526 100755 --- a/Buildings/Resources/Scripts/travis/pyfmi/runSpawnFromOtherDirectory.py +++ b/Buildings/Resources/Scripts/travis/pyfmi/runSpawnFromOtherDirectory.py @@ -79,7 +79,7 @@ def print_output(typ, stream): def run_test(pathVariable): # List of files to be moved fileMoves = [ - {"src": os.path.abspath(os.path.join("Buildings", "Resources", "bin", "spawn-0.6.0-9f1b36b00b", "linux64")), + {"src": os.path.abspath(os.path.join("Buildings", "Resources", "bin", "spawn-0.6.0-47c6610ff8", "linux64")), "des": "my-bin"}, {"src": os.path.abspath(os.path.join("Buildings", "Resources", "weatherdata")), "des": "some_weather_directory_that_the_fmu_does_not_know_about"}, diff --git a/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/BuildingInstantiate.c b/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/BuildingInstantiate.c index b9818c90fe7..536e802049c 100644 --- a/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/BuildingInstantiate.c +++ b/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/BuildingInstantiate.c @@ -62,30 +62,41 @@ void buildJSONKeyDoubleValue( buildJSONKeyLiteralValue(buffer, level, key, litVal, addComma, size, SpawnFormatError); } -void openJSONModelBracket(char* *buffer, size_t* size, void (*SpawnFormatError)(const char *string, ...)){ - saveAppend(buffer, " {\n", size, SpawnFormatError); +void openJSONModelBracket(char* *buffer, size_t level, size_t* size, void (*SpawnFormatError)(const char *string, ...)){ + size_t iLevel; + for(iLevel = 0; iLevel < level; iLevel++) + saveAppend(buffer, " ", size, SpawnFormatError); + saveAppend(buffer, "{\n", size, SpawnFormatError); } void closeJSONModelBracket( - char* *buffer, size_t i, size_t iMax, size_t* size, + char* *buffer, size_t level, size_t i, size_t iMax, size_t* size, void (*SpawnFormatError)(const char *string, ...)){ + size_t iLevel; + for(iLevel = 0; iLevel < level; iLevel++) + saveAppend(buffer, " ", size, SpawnFormatError); if (i < iMax -1) - saveAppend(buffer, " },\n", size, SpawnFormatError); + saveAppend(buffer, "},\n", size, SpawnFormatError); else - saveAppend(buffer, " }\n", size, SpawnFormatError); + saveAppend(buffer, "}\n", size, SpawnFormatError); } void closeJSONModelArrayBracket( - char* *buffer, size_t iMod, size_t nMod, size_t* size, + char* *buffer, size_t level, size_t iMod, size_t nMod, size_t* size, void (*SpawnFormatError)(const char *string, ...)){ + + size_t iLevel; + for(iLevel = 0; iLevel < level; iLevel++) + saveAppend(buffer, " ", size, SpawnFormatError); + /* Close json array bracket */ if (iMod == nMod){ /* There are no more other objects that belong to "model" */ - saveAppend(buffer, " ]\n", size, SpawnFormatError); + saveAppend(buffer, "]\n", size, SpawnFormatError); } else{ /* There are other objects that belong to "model" */ - saveAppend(buffer, " ],\n", size, SpawnFormatError); + saveAppend(buffer, "],\n", size, SpawnFormatError); } } @@ -117,6 +128,104 @@ char* getStartDayOfYear( return day; } +void buildJSONModelStructureForEnergyPlusHVACZones( + const FMUBuilding* bui, char* *buffer, size_t iMod, size_t nMod, size_t* size){ + size_t i; + size_t iWri; + size_t k; + size_t iHVACZones; + size_t nTheZon = 0; /* Number of thermal zones */ + size_t nHVACZones = 0; /* Number of HVACZones */ + bool recorded; + char **arrHVACZones = NULL; + size_t *couTheZon = NULL; + + SpawnObject** ptrSpaObj = (SpawnObject**)bui->exchange; + + void (*SpawnFormatError)(const char *string, ...) = bui->SpawnFormatError; + + /* Count how many thermal zones there are in each HVACZone */ + /* Number of HVAC zones */ + for(i = 0; i < bui->nExcObj; i++){ + if ( ptrSpaObj[i]->objectType == THERMALZONE ) { + nTheZon++; + } + } + /* Array of names of HVACZone, or NULL if there are no more HVAC zones */ + arrHVACZones = malloc(nTheZon * sizeof(char*)); + if (arrHVACZones == NULL){ + SpawnFormatError("%s", "Failed to allocate array for arrHVACZones."); + } + for(i = 0; i < nTheZon; i++) + arrHVACZones[i] = NULL; + /* Build set of names of all HVACZones */ + + for(i=0; i < bui->nExcObj; i++){ + if ( ptrSpaObj[i]->objectType == THERMALZONE ) { + /* Check if we already have this HVACZone */ + recorded = false; + for(k = 0; k < i; k++){ + if ( ptrSpaObj[k]->objectType == THERMALZONE ){ + if (strcmp(ptrSpaObj[i]->hvacZone, ptrSpaObj[k]->hvacZone) == 0){ + /* Had the zone already */ + recorded = true; + } + } + } + if (!recorded){ + arrHVACZones[nHVACZones] = ptrSpaObj[i]->hvacZone; + nHVACZones++; + } + } + } + /* Create a size_t array with the number of thermal zones in each HVACZone. + This is used to avoid the comma after the last thermal zone. */ + couTheZon = malloc(nHVACZones * sizeof(size_t)); + if (couTheZon == NULL){ + SpawnFormatError("%s", "Failed to allocate array for couTheZon."); + } + + for(iHVACZones = 0; iHVACZones < nHVACZones; iHVACZones++){ + couTheZon[iHVACZones] = 0; + for(i = 0; i < bui->nExcObj; i++){ + if ( ptrSpaObj[i]->objectType == THERMALZONE ) { + if (strcmp(ptrSpaObj[i]->hvacZone, arrHVACZones[iHVACZones]) == 0){ + couTheZon[iHVACZones]++; + } + } + } + } + + /* Write the "hvacZones" objects */ + saveAppend(buffer, " \"", size, SpawnFormatError); + saveAppend(buffer, "hvacZones", size, SpawnFormatError); + saveAppend(buffer, "\": [\n", size, SpawnFormatError); + /* Write all thermalZones that belong to the hvacZone */ + for(iHVACZones = 0; iHVACZones < nHVACZones; iHVACZones++){ + openJSONModelBracket(buffer, 3, size, SpawnFormatError); + buildJSONKeyStringValue(buffer, 4, "name", arrHVACZones[iHVACZones], true, size, SpawnFormatError); + saveAppend(buffer, " \"zones\": [\n", size, SpawnFormatError); + + for(i = 0, iWri = 0; i < bui->nExcObj; i++){ + if ( ptrSpaObj[i]->objectType == THERMALZONE ) { + /* Check if this thermal zone belongs to the HVACZone */ + if (strcmp(ptrSpaObj[i]->hvacZone, arrHVACZones[iHVACZones]) == 0){ + /* Found a match */ + openJSONModelBracket(buffer, 6, size, SpawnFormatError); + buildJSONKeyStringValue(buffer, 6, "name", ptrSpaObj[i]->epName, false, size, SpawnFormatError); + closeJSONModelBracket(buffer, 6, iWri, couTheZon[iHVACZones], size, SpawnFormatError); + iWri++; + } + } + } + /* We are done iterating over all objects, close the array */ + closeJSONModelArrayBracket(buffer, 5, 0, 0, size, SpawnFormatError); + closeJSONModelBracket(buffer, 3, iHVACZones, nHVACZones, size, SpawnFormatError); + } + closeJSONModelArrayBracket(buffer, 2, iMod, nMod, size, SpawnFormatError); + free(arrHVACZones); +} + void buildJSONModelStructureForEnergyPlus( const FMUBuilding* bui, char* *buffer, size_t* size, char** modelHash){ size_t i; @@ -154,6 +263,16 @@ void buildJSONModelStructureForEnergyPlus( /* weather file */ buildJSONKeyStringValue(buffer, 2, "weather", bui->weather, true, size, SpawnFormatError); + /* Flag to request HVAC autosizing */ + if (bui->autosizeHVAC) { + buildJSONKeyLiteralValue(buffer, 2, "autosize", "true", true, size, SpawnFormatError); + buildJSONKeyLiteralValue(buffer, 2, "runSimulationForSizingPeriods", bui->use_sizingPeriods ? "true": "false", true, size, SpawnFormatError); + } + else{ + buildJSONKeyLiteralValue(buffer, 2, "autosize", "false", true, size, SpawnFormatError); + buildJSONKeyLiteralValue(buffer, 2, "runSimulationForSizingPeriods", "false", true, size, SpawnFormatError); + } + /* Tolerance of solver for surface heat balance */ buildJSONKeyDoubleValue(buffer, 2, "relativeSurfaceTolerance", bui->relativeSurfaceTolerance, false, size, SpawnFormatError); @@ -191,22 +310,29 @@ void buildJSONModelStructureForEnergyPlus( saveAppend(buffer, "\": [\n", size, SpawnFormatError); } /* Write content */ - openJSONModelBracket(buffer, size, SpawnFormatError); + openJSONModelBracket(buffer, 3, size, SpawnFormatError); saveAppend(buffer, ptrSpaObj[i]->jsonKeysValues, size, SpawnFormatError); saveAppend(buffer, "\n", size, SpawnFormatError); - closeJSONModelBracket(buffer, iWri, objectCount[objectType], size, SpawnFormatError); + closeJSONModelBracket(buffer, 3, iWri, objectCount[objectType], size, SpawnFormatError); iWri++; } } iMod += iWri; - if (iWri > 0) - closeJSONModelArrayBracket(buffer, iMod, nMod, size, SpawnFormatError); + if (iWri > 0){ + closeJSONModelArrayBracket(buffer, 2, iMod, (objectType == 0) ? 0 : nMod, size, SpawnFormatError); + } + + /* After the first object type, which is "zones", we also write the "hvacZones". */ + if (objectType == 0){ + buildJSONModelStructureForEnergyPlusHVACZones(bui, buffer, iWri, bui->nExcObj, size); + } } /* Close json object for model */ saveAppend(buffer, " },\n", size, SpawnFormatError); + /* Create the model hash */ *modelHash = (char*)( cryptographicsHash(*buffer, bui->SpawnError) ); /* fmu */ @@ -258,7 +384,7 @@ void writeModelStructureForEnergyPlus(const FMUBuilding* bui, char** modelicaBui SpawnFormatError("Failed to open '%s' with write mode.", *modelicaBuildingsJsonFile); fprintf(fp, "%s", buffer); fclose(fp); -} + } void setAttributesReal( FMUBuilding* bui, diff --git a/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/SpawnFMU.c b/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/SpawnFMU.c index 40b6ecb861d..e5434e8a364 100644 --- a/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/SpawnFMU.c +++ b/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/SpawnFMU.c @@ -28,6 +28,8 @@ size_t AllocateBuildingDataStructure( const char* idfVersion, const char* idfName, const char* epwName, + const int autosizeHVAC, + const int use_sizingPeriods, const runPeriod* runPer, double relativeSurfaceTolerance, int usePrecompiledFMU, @@ -140,6 +142,9 @@ size_t AllocateBuildingDataStructure( SpawnFormatError); strcpy(Buildings_FMUS[nFMU]->weather, epwName); + /* Set flag for autosizing HVAC */ + Buildings_FMUS[nFMU]->autosizeHVAC = autosizeHVAC; + Buildings_FMUS[nFMU]->use_sizingPeriods = use_sizingPeriods; /* Assign the RunPeriod object */ Buildings_FMUS[nFMU]->runPer = malloc(sizeof(runPeriod)); if ( Buildings_FMUS[nFMU]->runPer == NULL ) diff --git a/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/SpawnFMU.h b/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/SpawnFMU.h index 2ec383a30be..d1060bd8ac8 100644 --- a/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/SpawnFMU.h +++ b/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/SpawnFMU.h @@ -23,10 +23,12 @@ size_t getBuildings_nFMU(); size_t AllocateBuildingDataStructure( double startTime, const char* modelicaNameBuilding, - const char* idfName, - const char* epwName, const char* spawnExe, const char* idfVersion, + const char* idfName, + const char* epwName, + const int autosizeHVAC, + const int use_sizingPeriods, const runPeriod* runPer, double relativeSurfaceTolerance, int usePrecompiledFMU, diff --git a/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/SpawnObjectAllocate.c b/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/SpawnObjectAllocate.c index 6dc37364ba9..464266de342 100644 --- a/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/SpawnObjectAllocate.c +++ b/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/SpawnObjectAllocate.c @@ -95,9 +95,12 @@ void* allocate_Spawn_EnergyPlus_24_2_0( const char* idfVersion, const char* idfName, const char* epwName, + const char* epName, + const char* hvacZone, + const int autosizeHVAC, + const int use_sizingPeriods, const runPeriod* runPer, double relativeSurfaceTolerance, - const char* epName, int usePrecompiledFMU, const char* fmuName, const char* buildingsRootFileLocation, @@ -200,6 +203,22 @@ void* allocate_Spawn_EnergyPlus_24_2_0( SpawnFormatError); strcpy(ptrSpaObj->modelicaName, modelicaName); + /* Assign the EnergyPlus instance name */ + mallocString( + strlen(epName)+1, + "Not enough memory in allocate_Spawn_EnergyPlus_9_6_0.c. to allocate EnergyPlus instance name.", + &(ptrSpaObj->epName), + SpawnFormatError); + strcpy(ptrSpaObj->epName, epName); + + /* Assign the HVAC zone name */ + mallocString( + strlen(hvacZone)+1, + "Not enough memory in allocate_Spawn_EnergyPlus_9_6_0.c. to allocate HVAC zone name.", + &(ptrSpaObj->hvacZone), + SpawnFormatError); + strcpy(ptrSpaObj->hvacZone, hvacZone); + /* Assign the json name */ mallocString( strlen(jsonName)+1, @@ -326,6 +345,8 @@ void* allocate_Spawn_EnergyPlus_24_2_0( idfVersion, idfName, epwName, + autosizeHVAC, + use_sizingPeriods, runPer, relativeSurfaceTolerance, usePrecompiledFMU, diff --git a/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/SpawnObjectAllocate.h b/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/SpawnObjectAllocate.h index 4a86fa505b2..479ebefd41e 100644 --- a/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/SpawnObjectAllocate.h +++ b/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/SpawnObjectAllocate.h @@ -20,9 +20,12 @@ LBNL_Spawn_EXPORT void* allocate_Spawn_EnergyPlus_24_2_0( const char* idfVersion, const char* idfName, const char* epwName, + const char* epName, + const char* hvacZone, + const int autosizeHVAC, + const int use_sizingPeriods, const runPeriod* runPer, double relativeSurfaceTolerance, - const char* epName, int usePrecompiledFMU, const char* fmuName, const char* buildingsRootFileLocation, diff --git a/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/SpawnTypes.h b/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/SpawnTypes.h index 3791562e887..667d120d74a 100644 --- a/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/SpawnTypes.h +++ b/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/C-Sources/SpawnTypes.h @@ -86,6 +86,8 @@ typedef struct FMUBuilding char* idfVersion; /* IDF version with underscores, such as 24_2_0. This must be the same as is used as suffix for Buildings.ThermalZones.EnergyPlus_ */ fmi2Byte* idfName; /* if usePrecompiledFMU == true, the user-specified fmu name, else the idf name */ fmi2Byte* weather; + bool autosizeHVAC; /* If true, EnergyPlus is requested to run the HVAC sizing calculations */ + bool use_sizingPeriods; /* If true, run HVAC sizing calculations on all the included SizingPeriod objects in the idf file */ runPeriod* runPer; /* EnergyPlus RunPeriod */ double relativeSurfaceTolerance; /* Relative surface tolerance for heat balance calculations */ size_t nExcObj; /* Number of exc that use this FMU */ @@ -135,7 +137,8 @@ typedef struct SpawnObject int objectType; /* Type of the EnergyPlus object */ FMUBuilding* bui; /* Pointer to building with this zone */ char* modelicaName; /* Name of the Modelica instance of this zone */ - + char* epName; /* Name of the EnergyPlus instance in the idf file */ + char* hvacZone; /* Name of the HVAC zone that this room belongs to. For other objects, this will be "n/a". */ char* jsonName; /* Name of the json keyword */ char* jsonKeysValues; /* Keys and values string to be written to the json configuration file */ char** parOutNames; diff --git a/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/install.py b/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/install.py index 5d3616fb944..a5ada721b7e 100755 --- a/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/install.py +++ b/Buildings/Resources/src/ThermalZones/EnergyPlus_24_2_0/install.py @@ -23,7 +23,7 @@ # build_type is either custom or builds spawn_dists = [ {"version": "0.6.0", - "commit": "9f1b36b00b", + "commit": "47c6610ff8", "build_type": "custom"} ] ########################################################################### diff --git a/Buildings/ThermalZones/EnergyPlus_24_2_0/Actuator.mo b/Buildings/ThermalZones/EnergyPlus_24_2_0/Actuator.mo index e8bafdbc976..d4ab65cc0d1 100644 --- a/Buildings/ThermalZones/EnergyPlus_24_2_0/Actuator.mo +++ b/Buildings/ThermalZones/EnergyPlus_24_2_0/Actuator.mo @@ -45,9 +45,12 @@ protected idfVersion=idfVersion, idfName=idfName, epwName=epwName, + epName=variableName, + hvacZone="n/a", + autosizeHVAC=autosizeHVAC, + use_sizingPeriods=use_sizingPeriods, runPeriod=runPeriod, relativeSurfaceTolerance=relativeSurfaceTolerance, - epName=variableName, usePrecompiledFMU=usePrecompiledFMU, fmuName=fmuName, buildingsRootFileLocation=Buildings.ThermalZones.EnergyPlus_24_2_0.BaseClasses.buildingsRootFileLocation, @@ -420,6 +423,18 @@ must be used as the value for the parameter controlType. Air Exchange Flow Rate m3/s m3/s + + + Zone Temperature Control + Cooling Setpoint + K + degC + + + Zone Temperature Control + Heating Setpoint + K + degC diff --git a/Buildings/ThermalZones/EnergyPlus_24_2_0/BaseClasses/PartialEnergyPlusObject.mo b/Buildings/ThermalZones/EnergyPlus_24_2_0/BaseClasses/PartialEnergyPlusObject.mo index 57a8a23198f..442b0128922 100644 --- a/Buildings/ThermalZones/EnergyPlus_24_2_0/BaseClasses/PartialEnergyPlusObject.mo +++ b/Buildings/ThermalZones/EnergyPlus_24_2_0/BaseClasses/PartialEnergyPlusObject.mo @@ -22,6 +22,10 @@ protected "Name of the IDF file that contains this zone"; final parameter String epwName=building.epwName "Name of the EnergyPlus weather file (but with mos extension)"; + final parameter Boolean autosizeHVAC=building.autosizeHVAC + "If true, EnergyPlus will run the HVAC autosizing calculations and report results to Modelica thermal zone model"; + final parameter Boolean use_sizingPeriods=building.use_sizingPeriods + "Set to true to run the HVAC sizing on all the included SizingPeriod objects in the idf file"; final parameter Real relativeSurfaceTolerance=building.relativeSurfaceTolerance "Relative tolerance of surface temperature calculations"; @@ -46,14 +50,10 @@ protected output Real y; algorithm - y := - if - (u > 0) then - floor( - u/accuracy+0.5)*accuracy - else - ceil( - u/accuracy-0.5)*accuracy; + y := if (u > 0) then + floor(u/accuracy+0.5)*accuracy + else + ceil(u/accuracy-0.5)*accuracy; end round; initial equation diff --git a/Buildings/ThermalZones/EnergyPlus_24_2_0/BaseClasses/SpawnExternalObject.mo b/Buildings/ThermalZones/EnergyPlus_24_2_0/BaseClasses/SpawnExternalObject.mo index e509a82b8bc..208de87d5d2 100644 --- a/Buildings/ThermalZones/EnergyPlus_24_2_0/BaseClasses/SpawnExternalObject.mo +++ b/Buildings/ThermalZones/EnergyPlus_24_2_0/BaseClasses/SpawnExternalObject.mo @@ -20,12 +20,18 @@ class SpawnExternalObject "Name of the IDF"; input String epwName "Name of the weather file"; + input String epName + "Name of the object in EnergyPlus"; + input String hvacZone + "Name of the HVAC zone to which the thermal zone belongs to, or n/a for other objects. Used for autosizing"; + input Boolean autosizeHVAC + "If true, EnergyPlus will run the HVAC autosizing calculations and report results to Modelica thermal zone model"; + input Boolean use_sizingPeriods + "Set to true to run the HVAC sizing on all the included SizingPeriod objects in the idf file"; input Buildings.ThermalZones.EnergyPlus_24_2_0.Data.RunPeriod runPeriod "EnergyPlus RunPeriod configuration"; input Real relativeSurfaceTolerance "Relative tolerance of surface temperature calculations"; - input String epName - "Name of the object in EnergyPlus"; input Boolean usePrecompiledFMU "Set to true to use precompiled FMU with name specified by input fmuName"; input String fmuName @@ -74,6 +80,10 @@ class SpawnExternalObject idfVersion, idfName, epwName, + epName, + hvacZone, + autosizeHVAC, + use_sizingPeriods, runPeriod.startDayOfYear, runPeriod.applyWeekEndHolidayRule, runPeriod.use_weatherFileDaylightSavingPeriod, @@ -81,7 +91,6 @@ class SpawnExternalObject runPeriod.use_weatherFileRainIndicators, runPeriod.use_weatherFileSnowIndicators, relativeSurfaceTolerance, - epName, usePrecompiledFMU, fmuName, buildingsRootFileLocation, @@ -113,35 +122,35 @@ class SpawnExternalObject annotation ( Documentation( info=" -

- The function constructor is a C function that is called by a Modelica simulator - exactly once during the initialization. - The function returns the object adapter that - will be used to store the data structure needed to communicate with EnergyPlus. -

- ", +

+The function constructor is a C function that is called by a Modelica simulator +exactly once during the initialization. +The function returns the object adapter that +will be used to store the data structure needed to communicate with EnergyPlus. +

+", revisions=" - - ")); + +")); end constructor; pure function destructor diff --git a/Buildings/ThermalZones/EnergyPlus_24_2_0/BaseClasses/ThermalZoneAdapter.mo b/Buildings/ThermalZones/EnergyPlus_24_2_0/BaseClasses/ThermalZoneAdapter.mo index fba38a159d9..c8e509f372e 100644 --- a/Buildings/ThermalZones/EnergyPlus_24_2_0/BaseClasses/ThermalZoneAdapter.mo +++ b/Buildings/ThermalZones/EnergyPlus_24_2_0/BaseClasses/ThermalZoneAdapter.mo @@ -21,14 +21,24 @@ model ThermalZoneAdapter "Name of the IDF file that contains this zone"; parameter String epwName "Name of the Energyplus weather file including the epw extension"; + parameter String zoneName + "Name of the thermal zone as specified in the EnergyPlus input"; + parameter String hvacZone + "Name of the HVAC system that this zone belongs to for auto-sizing" + annotation(Dialog(group="Auto-sizing")); + + parameter Boolean autosizeHVAC + "If true, EnergyPlus will run the HVAC autosizing calculations and report results to Modelica thermal zone model" + annotation(Dialog(group="Auto-sizing")); + parameter Boolean use_sizingPeriods + "Set to true to run the HVAC sizing on all the included SizingPeriod objects in the idf file" + annotation(Dialog(group="Auto-sizing")); parameter Real relativeSurfaceTolerance "Relative tolerance of surface temperature calculations"; + parameter Buildings.ThermalZones.EnergyPlus_24_2_0.Data.RunPeriod runPeriod "EnergyPlus RunPeriod configuration" annotation (Dialog(tab="Run period")); - - parameter String zoneName - "Name of the thermal zone as specified in the EnergyPlus input"; parameter Boolean usePrecompiledFMU=false "Set to true to use pre-compiled FMU with name specified by fmuName" annotation (Dialog(tab="Debug")); @@ -115,9 +125,12 @@ protected idfVersion=idfVersion, idfName=idfName, epwName=epwName, + epName=zoneName, + hvacZone=hvacZone, + autosizeHVAC=autosizeHVAC, + use_sizingPeriods=use_sizingPeriods, runPeriod=runPeriod, relativeSurfaceTolerance=relativeSurfaceTolerance, - epName=zoneName, usePrecompiledFMU=usePrecompiledFMU, fmuName=fmuName, buildingsRootFileLocation=Buildings.ThermalZones.EnergyPlus_24_2_0.BaseClasses.buildingsRootFileLocation, @@ -190,14 +203,10 @@ protected output Real y; algorithm - y := - if - (u > 0) then - floor( - u/accuracy+0.5)*accuracy - else - ceil( - u/accuracy-0.5)*accuracy; + y := if (u > 0) then + floor(u/accuracy+0.5)*accuracy + else + ceil(u/accuracy-0.5)*accuracy; end round; initial equation @@ -235,7 +244,7 @@ initial equation yEP=Buildings.ThermalZones.EnergyPlus_24_2_0.BaseClasses.exchange( adapter=adapter, nY=nY, - u={ T, X_w/(1.-X_w), mInlet_flow, TAveInlet, QGaiRadAve_flow, round(time,1E-3)}, + u={T, X_w/(1.-X_w), mInlet_flow, TAveInlet, QGaiRadAve_flow, round(time,1E-3)}, dummy=AFlo); TRad=yEP[1]; diff --git a/Buildings/ThermalZones/EnergyPlus_24_2_0/Building.mo b/Buildings/ThermalZones/EnergyPlus_24_2_0/Building.mo index 606bb173c17..f43029e6da0 100644 --- a/Buildings/ThermalZones/EnergyPlus_24_2_0/Building.mo +++ b/Buildings/ThermalZones/EnergyPlus_24_2_0/Building.mo @@ -3,8 +3,8 @@ model Building "Model that declares a building to which EnergyPlus objects belong to" extends Modelica.Blocks.Icons.Block; - constant String spawnExe="spawn-0.6.0-9f1b36b00b" - "Name of the spawn executable, without extension, such as spawn-0.6.0-9f1b36b00baaa" + constant String spawnExe="spawn-0.6.0-47c6610ff8" + "Name of the spawn executable, without extension, such as spawn-0.6.0-47c6610ff8aaa" annotation (HideResult=true); constant String idfVersion = "24_2_0" @@ -31,6 +31,13 @@ model Building "Name of the weather file, in .mos format and with .mos extension" annotation(Evaluate=false); + parameter Boolean autosizeHVAC=false + "Set to true to enable EnergyPlus HVAC autosizing"; + + parameter Boolean use_sizingPeriods=true + "Set to true to run the HVAC sizing on all the included SizingPeriod objects in the idf file" + annotation(Dialog(enable=autosizeHVAC)); + parameter Buildings.ThermalZones.EnergyPlus_24_2_0.Types.LogLevels logLevel=Buildings.ThermalZones.EnergyPlus_24_2_0.Types.LogLevels.Warning "Log level of EnergyPlus output" annotation (Dialog(tab="Debug")); diff --git a/Buildings/ThermalZones/EnergyPlus_24_2_0/Examples/SingleFamilyHouse/Radiator.mo b/Buildings/ThermalZones/EnergyPlus_24_2_0/Examples/SingleFamilyHouse/Radiator.mo index 3fdd8f544f4..de9efdf209e 100644 --- a/Buildings/ThermalZones/EnergyPlus_24_2_0/Examples/SingleFamilyHouse/Radiator.mo +++ b/Buildings/ThermalZones/EnergyPlus_24_2_0/Examples/SingleFamilyHouse/Radiator.mo @@ -231,4 +231,4 @@ This is for Icon( coordinateSystem( extent={{-100,-100},{100,100}}))); -end Radiator; \ No newline at end of file +end Radiator; diff --git a/Buildings/ThermalZones/EnergyPlus_24_2_0/Examples/SmallOffice/IdealHeatingCoolingSpring.mo b/Buildings/ThermalZones/EnergyPlus_24_2_0/Examples/SmallOffice/IdealHeatingCoolingSpring.mo index 5369f499c05..2b284c49654 100644 --- a/Buildings/ThermalZones/EnergyPlus_24_2_0/Examples/SmallOffice/IdealHeatingCoolingSpring.mo +++ b/Buildings/ThermalZones/EnergyPlus_24_2_0/Examples/SmallOffice/IdealHeatingCoolingSpring.mo @@ -26,7 +26,7 @@ but configured for simulation of a few days in summer. "), - __Dymola_Commands( - file="modelica://Buildings/Resources/Scripts/Dymola/ThermalZones/EnergyPlus/Validation/SurfaceComparison/ZoneSurfaces.mos" - "Simulate and Plot", file="../test.mos" "test"), - experiment( - StopTime=2592000, - Tolerance=1e-06), Diagram(coordinateSystem(extent={{-100,-100},{100,100}})), Icon(coordinateSystem(extent={{-100,-100},{100,100}}))); end ZoneSurfaces;