Idf corrections and intermediate solution

This commit is contained in:
Guille 2020-10-26 10:00:42 -04:00
parent d559d1a43a
commit ee9364d704
6 changed files with 215 additions and 230 deletions

View File

@ -36,7 +36,7 @@ class Building(CityObject):
self._function = function
self._lower_corner = lower_corner
self._average_storey_height = None
self._storeys_above_ground = None
self._storeys_above_ground = 1
self._foot_print = None
self._usage_zones = []
self._building_units = []

View File

@ -71,7 +71,6 @@ class Polyhedron:
@property
def _polyhedron_mesh(self):
if self._mesh is None:
self._mesh = Trimesh(vertices=self.vertices, faces=self.faces)
return self._mesh

View File

@ -50,7 +50,7 @@ class CityGml:
else:
self._lower_corner = np.fromstring(envelope['lowerCorner'], dtype=float, sep=' ')
self._upper_corner = np.fromstring(envelope['upperCorner'], dtype=float, sep=' ')
if '@srsName' in envelope:
self._srs_name = envelope['@srsName']
@property

View File

@ -9,6 +9,11 @@ from pathlib import Path
class IdfHelper:
idf_surfaces = {
'Wall': 'wall',
'Ground': 'floor',
'Roof': 'roof'
}
def __init__(self, idf_file_path, idd_file_path, epw_file_path, eso_file_path):
self._idd_file_path = str(idd_file_path)
@ -17,12 +22,30 @@ class IdfHelper:
self._eso_file_path = str(eso_file_path)
IDF.setiddname(self._idd_file_path)
self._idf = IDF(self._idf_file_path)
self._idf.epw = epw_file_path
self._idf.epw = self._epw_file_path
self._eso_file_path = str((Path.cwd() / 'eplusout.eso').resolve())
def add_zone(self, building_name):
self._idf.newidfobject(key='ZONE', Name=building_name, Ceiling_Height='autocalculate', Volume='autocalculate',
Floor_Area='autocalculate', Part_of_Total_Floor_Area='yes', )
self._idf.newidfobject("HVACTEMPLATE:ZONE:IDEALLOADSAIRSYSTEM", Zone_Name=building_name,
Template_Thermostat_Name='', Outdoor_Air_Method="DetailedSpecification", )
def add_heating_system(self):
self._idf.intersect_match()
self._idf.set_default_constructions()
stat = self._idf.newidfobject(
"HVACTEMPLATE:THERMOSTAT",
Name="Zone Stat",
Constant_Heating_Setpoint=20,
Constant_Cooling_Setpoint=25,
)
for zone in self._idf.idfobjects["ZONE"]:
self._idf.newidfobject("HVACTEMPLATE:ZONE:IDEALLOADSAIRSYSTEM",
Zone_Name=zone.Name,
Template_Thermostat_Name=stat.Name
)
@staticmethod
def _matrix_to_list(points):
@ -30,31 +53,47 @@ class IdfHelper:
for point in points:
point_tuple = (point[0], point[1], point[2])
points_list.append(point_tuple)
print(points_list)
return points_list
def add_surface(self, surface, building_name):
wall = self._idf.newidfobject('BUILDINGSURFACE:DETAILED', Name=surface.name, Surface_Type=surface.type,
Zone_Name=building_name, )
self._matrix_to_list(surface.points)
wall.setcoords(IdfHelper._matrix_to_list(surface.points))
@staticmethod
def _matrix_to_2d_list(points):
points_list = []
for point in points:
point_tuple = (point[0], point[1])
points_list.append(point_tuple)
points_list.reverse()
return points_list
def add_block(self, building):
_points = IdfHelper._matrix_to_2d_list(building.foot_print.points)
self._idf.add_block(name=building.name, coordinates=_points,
height=building.max_height, num_stories=building.storeys_above_ground)
def add_surfaces(self, building):
for surface in building.surfaces:
wall = self._idf.newidfobject('BUILDINGSURFACE:DETAILED', Name=surface.name,
Surface_Type=self.idf_surfaces[surface.type], Zone_Name=building.name)
wall.setcoords(IdfHelper._matrix_to_list(surface.ground_points))
def run(self, window_ratio=0.35, display_render=False):
self._idf.set_default_constructions()
self._idf.intersect_match()
self._idf.set_wwr(window_ratio)
self._idf.translate_to_origin()
# self._idf.translate_to_origin()
if display_render:
self._idf.view_model()
self._idf.newidfobject("HVACTEMPLATE:THERMOSTAT", Name="Zone Stat", Constant_Heating_Setpoint=20,
Constant_Cooling_Setpoint=24, )
for zone in self._idf.idfobjects["ZONE"]:
self._idf.newidfobject("HVACTEMPLATE:ZONE:IDEALLOADSAIRSYSTEM", Zone_Name=zone.Name,
Template_Thermostat_Name='', Outdoor_Air_Method="DetailedSpecification", )
else:
self._idf.to_obj('city.obj')
# Run
self._idf.newidfobject("OUTPUT:METER", Key_Name="Heating:DistrictHeating", Reporting_Frequency="hourly", )
self._idf.newidfobject("OUTPUT:METER", Key_Name="Cooling:DistrictCooling", Reporting_Frequency="hourly", )
self._idf.run()
"""
dd, data = esoreader.read(self._eso_file_path)
list_values = [v for v in data.values()]
heating = [(float(x)) / 3600000.0 for x in list_values[0]]
cooling = [(float(x)) / 3600000.0 for x in list_values[1]]
print("text")
return heating, cooling
"""

View File

@ -37,8 +37,13 @@ class TestIdf(TestCase):
_idf = IdfHelper(idf_file_path, idd_file_path, epw_file_path, self._example_path)
city = self._get_citygml()
for building in city.buildings:
_idf.add_block(building)
_idf.add_zone(building.name)
for surface in building.surfaces:
_idf.add_surface(surface, building.name)
# _idf.add_surfaces(building)
# for surface in building.surfaces:
# _idf.add_surface(surface, building.name)
_idf.add_heating_system()
_idf.run()
self.assertTrue(True)

View File

@ -1,12 +1,3 @@
!-Generator IDFEditor 1.50
!-Option SortedOrder
!-NOTE: All comments with '!-' are ignored by the IDFEditor and are generated automatically.
!- Use '!' comments if they need to be retained when using the IDFEditor.
!- =========== ALL OBJECTS IN CLASS: VERSION ===========
! Minimal.idf
! Basic file description: This is a minimal configuration necessary to run.
! Highlights: Illustrates minimal items necessary to perform run.
@ -21,90 +12,38 @@
!
! HVAC: None.
!
Version,
9.2; !- Version Identifier
Version,9.4;
!- =========== ALL OBJECTS IN CLASS: SIMULATIONCONTROL ===========
Timestep,4;
SimulationControl,
No, !- Do Zone Sizing Calculation
No, !- Do System Sizing Calculation
No, !- Do Plant Sizing Calculation
No, !- Run Simulation for Sizing Periods
Yes; !- Run Simulation for Weather File Run Periods
!- =========== ALL OBJECTS IN CLASS: BUILDING ===========
Building,
Building,
None, !- Name
0, !- North Axis {deg}
0.0000000E+00, !- North Axis {deg}
Suburbs, !- Terrain
0.04, !- Loads Convergence Tolerance Value
0.04, !- Loads Convergence Tolerance Value {W}
0.40, !- Temperature Convergence Tolerance Value {deltaC}
FullInteriorAndExterior, !- Solar Distribution
25, !- Maximum Number of Warmup Days
6; !- Minimum Number of Warmup Days
GlobalGeometryRules,
UpperLeftCorner, !- Starting Vertex Position
CounterClockWise, !- Vertex Entry Direction
World; !- Coordinate System
!- =========== ALL OBJECTS IN CLASS: SHADOWCALCULATION ===========
ShadowCalculation,
AverageOverDaysInFrequency, !- Calculation Method
20, !- Calculation Frequency
15000, !- Maximum Figures in Shadow Overlap Calculations
SutherlandHodgman, !- Polygon Clipping Algorithm
SimpleSkyDiffuseModeling,!- Sky Diffuse Modeling Algorithm
InternalCalculation, !- External Shading Calculation Method
No, !- Output External Shading Calculation Results
No, !- Disable Self-Shading Within Shading Zone Groups
No; !- Disable Self-Shading From Shading Zone Groups to Other Zones
!- =========== ALL OBJECTS IN CLASS: SURFACECONVECTIONALGORITHM:INSIDE ===========
SurfaceConvectionAlgorithm:Inside,
TARP; !- Algorithm
!- =========== ALL OBJECTS IN CLASS: SURFACECONVECTIONALGORITHM:OUTSIDE ===========
SurfaceConvectionAlgorithm:Outside,
DOE-2; !- Algorithm
!- =========== ALL OBJECTS IN CLASS: HEATBALANCEALGORITHM ===========
HeatBalanceAlgorithm,
ConductionTransferFunction, !- Algorithm
200, !- Surface Temperature Upper Limit {C}
0.1, !- Minimum Surface Convection Heat Transfer Coefficient Value {W/m2-K}
1000; !- Maximum Surface Convection Heat Transfer Coefficient Value {W/m2-K}
!- =========== ALL OBJECTS IN CLASS: TIMESTEP ===========
Timestep,
4; !- Number of Timesteps per Hour
!- =========== ALL OBJECTS IN CLASS: SITE:LOCATION ===========
Site:Location,
Site:Location,
DENVER_STAPLETON_CO_USA_WMO_724690, !- Name
45.508888, !- Latitude {deg}
-73.561668, !- Longitude {deg}
-5, !- Time Zone {hr}
44; !- Elevation {m}
39.77, !- Latitude {deg}
-104.87, !- Longitude {deg}
-7.00, !- Time Zone {hr}
1611.00; !- Elevation {m}
! DENVER_STAPLETON_CO_USA Annual Heating Design Conditions Wind Speed=2.3m/s Wind Dir=180
! Coldest Month=December
! DENVER_STAPLETON_CO_USA Annual Heating 99.6%, MaxDB=-20°C
!- =========== ALL OBJECTS IN CLASS: SIZINGPERIOD:DESIGNDAY ===========
! DENVER_STAPLETON_CO_USA Annual Heating Design Conditions Wind Speed=2.3m/s Wind Dir=180
! Coldest Month=December
! DENVER_STAPLETON_CO_USA Annual Heating 99.6%, MaxDB=-20°C
SizingPeriod:DesignDay,
SizingPeriod:DesignDay,
DENVER_STAPLETON Ann Htg 99.6% Condns DB, !- Name
12, !- Month
21, !- Day of Month
@ -132,10 +71,11 @@ SizingPeriod:DesignDay,
, !- ASHRAE Clear Sky Optical Depth for Diffuse Irradiance (taud) {dimensionless}
0.00; !- Sky Clearness
! DENVER_STAPLETON Annual Cooling Design Conditions Wind Speed=4m/s Wind Dir=120
! Hottest Month=July
! DENVER_STAPLETON_CO_USA Annual Cooling (DB=>MWB) .4%, MaxDB=34.1°C MWB=15.8°C
SizingPeriod:DesignDay,
! DENVER_STAPLETON Annual Cooling Design Conditions Wind Speed=4m/s Wind Dir=120
! Hottest Month=July
! DENVER_STAPLETON_CO_USA Annual Cooling (DB=>MWB) .4%, MaxDB=34.1°C MWB=15.8°C
SizingPeriod:DesignDay,
DENVER_STAPLETON Ann Clg .4% Condns DB=>MWB, !- Name
7, !- Month
21, !- Day of Month
@ -163,10 +103,7 @@ SizingPeriod:DesignDay,
, !- ASHRAE Clear Sky Optical Depth for Diffuse Irradiance (taud) {dimensionless}
1.00; !- Sky Clearness
!- =========== ALL OBJECTS IN CLASS: RUNPERIOD ===========
RunPeriod,
RunPeriod,
Run Period 1, !- Name
1, !- Begin Month
1, !- Begin Day of Month
@ -174,36 +111,41 @@ RunPeriod,
12, !- End Month
31, !- End Day of Month
, !- End Year
Sunday, !- Day of Week for Start Day
Tuesday, !- Day of Week for Start Day
Yes, !- Use Weather File Holidays and Special Days
Yes, !- Use Weather File Daylight Saving Period
No, !- Apply Weekend Holiday Rule
Yes, !- Use Weather File Rain Indicators
Yes; !- Use Weather File Snow Indicators
SimulationControl,
No, !- Do Zone Sizing Calculation
No, !- Do System Sizing Calculation
No, !- Do Plant Sizing Calculation
Yes, !- Run Simulation for Sizing Periods
No, !- Run Simulation for Weather File Run Periods
No, !- Do HVAC Sizing Simulation for Sizing Periods
1; !- Maximum Number of HVAC Sizing Simulation Passes
!- =========== ALL OBJECTS IN CLASS: GLOBALGEOMETRYRULES ===========
Output:VariableDictionary,Regular;
GlobalGeometryRules,
UpperLeftCorner, !- Starting Vertex Position
CounterClockWise, !- Vertex Entry Direction
World; !- Coordinate System
Output:Variable,*,Site Outdoor Air Drybulb Temperature,Timestep;
Output:Variable,*,Site Outdoor Air Wetbulb Temperature,Timestep;
!- =========== ALL OBJECTS IN CLASS: OUTPUT:VARIABLEDICTIONARY ===========
Output:Variable,*,Site Outdoor Air Dewpoint Temperature,Timestep;
Output:VariableDictionary,
IDF; !- Key Field
Output:Variable,*,Site Solar Azimuth Angle,Timestep;
Output:Variable,*,Site Solar Altitude Angle,Timestep;
!- =========== ALL OBJECTS IN CLASS: OUTPUT:TABLE:SUMMARYREPORTS ===========
Output:Variable,*,Site Direct Solar Radiation Rate per Area,Timestep;
Output:Table:SummaryReports,
AllSummary; !- Report 1 Name
Output:Variable,*,Site Diffuse Solar Radiation Rate per Area,Timestep;
!- =========== ALL OBJECTS IN CLASS: OUTPUTCONTROL:TABLE:STYLE ===========
OutputControl:Table:Style,
OutputControl:Table:Style,
HTML; !- Column Separator
Output:Table:SummaryReports,
AllSummary; !- Report 1 Name