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