Coverage for bim2sim/plugins/PluginOpenFOAM/bim2sim_openfoam/openfoam_elements/airterminal.py: 0%
95 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-01 10:24 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-01 10:24 +0000
1from OCC.Core.gp import gp_Pnt
3from bim2sim.plugins.PluginOpenFOAM.bim2sim_openfoam.openfoam_elements.openfoam_base_boundary_conditions import \
4 OpenFOAMBaseBoundaryFields
5from bim2sim.plugins.PluginOpenFOAM.bim2sim_openfoam.openfoam_elements.openfoam_base_element import \
6 OpenFOAMBaseElement
7from bim2sim.utilities.pyocc_tools import PyOCCTools
10class AirDiffuser(OpenFOAMBaseBoundaryFields, OpenFOAMBaseElement):
11 def __init__(self, shape, triSurface_path, air_type,
12 inlet_outlet_type, bbox_min_max, solid_name='diffuser'):
13 super().__init__()
14 self.solid_name = air_type + '_' + solid_name
15 self.patch_info_type = 'wall'
16 self.stl_name = self.solid_name + '.stl'
17 self.stl_file_path_name = (triSurface_path.as_posix() + '/' +
18 self.stl_name)
19 self.refinement_level = [2, 5]
21 if inlet_outlet_type == 'IfcDiffusor':
22 raise NotImplementedError
23 elif inlet_outlet_type == 'Original':
24 self.tri_geom = PyOCCTools.triangulate_bound_shape(shape)
25 self.refinement_level = [2, 5]
26 elif inlet_outlet_type == 'SimpleStlDiffusor':
27 self.tri_geom = PyOCCTools.triangulate_bound_shape(
28 shape)
29 self.refinement_level = [2, 5]
30 elif inlet_outlet_type == 'StlDiffusor':
31 self.tri_geom = PyOCCTools.triangulate_bound_shape(
32 shape)
33 self.refinement_level = [2, 5]
34 elif inlet_outlet_type == 'Plate':
35 x1 = bbox_min_max[0][0] - 0.05
36 x2 = bbox_min_max[1][0] + 0.05
37 y1 = bbox_min_max[0][1] - 0.05
38 y2 = bbox_min_max[1][1] + 0.05
39 z = bbox_min_max[0][2] - 0.02
40 self.tri_geom = PyOCCTools.triangulate_bound_shape(
41 PyOCCTools.make_faces_from_pnts([
42 gp_Pnt(x1, y1, z),
43 gp_Pnt(x2, y1, z),
44 gp_Pnt(x2, y2, z),
45 gp_Pnt(x1, y2, z)]
46 ))
47 self.refinement_level = [2, 5]
48 else:
49 self.tri_geom = None
50 self.solid_name = None
51 self.refinement_level = [2, 5]
54class AirSourceSink(OpenFOAMBaseBoundaryFields, OpenFOAMBaseElement):
55 def __init__(self, shape, triSurface_path, air_type, volumetric_flow,
56 air_temp, solid_name='source_sink'):
57 super().__init__()
58 self.solid_name = air_type + '_' + solid_name
59 self.patch_info_type = 'wall'
60 self.stl_name = self.solid_name + '.stl'
61 self.stl_file_path_name = (triSurface_path.as_posix() + '/' +
62 self.stl_name)
63 self.refinement_level = [2, 5]
64 if shape:
65 self.tri_geom = PyOCCTools.triangulate_bound_shape(shape)
66 else:
67 self.tri_geom = None
68 self.solid_name = None
69 self.volumetric_flow = volumetric_flow / 3600 # convert to m3/s
70 self.temperature = air_temp
73class AirBox(OpenFOAMBaseBoundaryFields, OpenFOAMBaseElement):
74 def __init__(self, shape, triSurface_path, air_type, solid_name='box'):
75 super().__init__()
76 self.solid_name = air_type + '_' + solid_name
77 self.patch_info_type = 'wall'
78 self.stl_name = self.solid_name + '.stl'
79 self.stl_file_path_name = (triSurface_path.as_posix() + '/' +
80 self.stl_name)
81 self.refinement_level = [1, 3]
82 if shape:
83 self.tri_geom = PyOCCTools.triangulate_bound_shape(shape)
84 else:
85 self.tri_geom = None
86 self.solid_name = None
90class AirTerminal:
91 def __init__(self, air_type, inlet_shapes, triSurface_path,
92 inlet_outlet_type, solid_name='AirTerminal', air_temp=
93 293.15,
94 volumetric_flow=0,
95 increase_small_refinement=0.10,
96 increase_large_refinement=0.20):
97 self.solid = None
98 self.air_type = air_type
99 self.solid_name = air_type + '_' + solid_name
100 (diffuser_shape, source_sink_shape, box_shape, self.bbox_min_max_shape,
101 self.bbox_min_max) = inlet_shapes
102 self.diffuser = AirDiffuser(diffuser_shape, triSurface_path, air_type,
103 inlet_outlet_type, self.bbox_min_max)
104 self.source_sink = AirSourceSink(source_sink_shape, triSurface_path,
105 air_type, volumetric_flow, air_temp)
106 self.box = AirBox(box_shape, triSurface_path, air_type)
108 self.refinement_zone_small = []
109 self.refinement_zone_small.append([c - increase_small_refinement for c
110 in self.bbox_min_max[0]])
111 self.refinement_zone_small.append([c + increase_small_refinement for c
112 in self.bbox_min_max[1]])
113 self.refinement_zone_level_small = [0,
114 self.diffuser.refinement_level[0]+2]
115 self.refinement_zone_large = []
116 self.refinement_zone_large.append(
117 [c - increase_large_refinement for c in
118 self.bbox_min_max[0]])
119 self.refinement_zone_large.append(
120 [c + increase_large_refinement for c in
121 self.bbox_min_max[1]])
122 self.refinement_zone_level_large = [0,
123 self.diffuser.refinement_level[0]]
125 def set_boundary_conditions(self, air_temp, volumetric_flow):
126 # set air temperature
127 self.source_sink.volumetric_flow = volumetric_flow / 1000 # l/s to m3/s
128 self.source_sink.temperature = air_temp
129 self.source_sink.alphat = \
130 {'type': 'calculated', 'value': 'uniform 0'}
131 self.source_sink.nut = {'type': 'calculated', 'value': 'uniform 0'
132 }
133 if 'INLET' in self.air_type.upper():
134 self.source_sink.aoa = \
135 {'type': 'fixedValue', 'value': 'uniform 0'
136 }
137 self.source_sink.k = {
138 'type': 'turbulentIntensityKineticEnergyInlet',
139 'intensity': 0.02,
140 'value': 'uniform 1'
141 }
142 self.source_sink.omega = {
143 'type': 'turbulentMixingLengthFrequencyInlet',
144 'mixingLength': 0.1,
145 'k': 'k',
146 'value': 'uniform 0.01'
147 }
148 self.source_sink.T = \
149 {'type': 'fixedValue',
150 'value': f'uniform {self.source_sink.temperature}'}
151 self.source_sink.U = \
152 {'type': 'flowRateInletVelocity',
153 'flowRate': 'volumetricFlowRate',
154 'volumetricFlowRate': f'constant '
155 f'{self.source_sink.volumetric_flow}',
156 'value': 'uniform (0.000 0.000 0.000)'
157 }
158 else:
159 self.source_sink.aoa = {'type': 'inletOutlet',
160 'inletValue': 'uniform 0',
161 'value': 'uniform 0'
162 }
163 self.source_sink.k = {'type': 'inletOutlet',
164 'inletValue': 'uniform 0.1',
165 'value': 'uniform 0.1'
166 }
167 self.source_sink.omega = {'type': 'inletOutlet',
168 'inletValue': 'uniform 0.01',
169 'value': 'uniform 0.01'
170 }
171 self.source_sink.p_rgh = {'type': 'fixedValue',
172 'value': 'uniform 101325'
173 }
174 self.source_sink.T = \
175 {'type': 'inletOutlet',
176 'inletValue': '$internalField',
177 'value': '$internalField'}
178 self.source_sink.U = \
179 {'type': 'inletOutlet',
180 'inletValue': 'uniform (0.000 0.000 0.000)',
181 'value': 'uniform (0.000 0.000 0.000)'
182 }
183 pass