3D-ICE 3.0.0
channel.c
1/******************************************************************************
2 * This file is part of 3D-ICE, version 3.1.0 . *
3 * *
4 * 3D-ICE is free software: you can redistribute it and/or modify it under *
5 * the terms of the GNU General Public License as published by the Free *
6 * Software Foundation, either version 3 of the License, or any later *
7 * version. *
8 * *
9 * 3D-ICE is distributed in the hope that it will be useful, but WITHOUT *
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
12 * more details. *
13 * *
14 * You should have received a copy of the GNU General Public License along *
15 * with 3D-ICE. If not, see <http://www.gnu.org/licenses/>. *
16 * *
17 * Copyright (C) 2021 *
18 * Embedded Systems Laboratory - Ecole Polytechnique Federale de Lausanne *
19 * All Rights Reserved. *
20 * *
21 * Authors: Arvind Sridhar Alessandro Vincenzi *
22 * Giseong Bak Martino Ruggiero *
23 * Thomas Brunschwiler Eder Zulian *
24 * Federico Terraneo Darong Huang *
25 * Luis Costero Marina Zapater *
26 * David Atienza *
27 * *
28 * For any comment, suggestion or request about 3D-ICE, please register and *
29 * write to the mailing list (see http://listes.epfl.ch/doc.cgi?liste=3d-ice) *
30 * Any usage of 3D-ICE for research, commercial or other purposes must be *
31 * properly acknowledged in the resulting products or publications. *
32 * *
33 * EPFL-STI-IEL-ESL Mail : 3d-ice@listes.epfl.ch *
34 * Batiment ELG, ELG 130 (SUBSCRIPTION IS NECESSARY) *
35 * Station 11 *
36 * 1015 Lausanne, Switzerland Url : http://esl.epfl.ch/3d-ice *
37 ******************************************************************************/
38
39#include <stdlib.h> // For the memory functions malloc/free
40
41#include "channel.h"
42#include "macros.h"
43
44/******************************************************************************/
45
46void channel_init (Channel_t *channel)
47{
49 channel->Height = (CellDimension_t) 0.0 ;
50 channel->Length = (ChannelDimension_t) 0.0 ;
51 channel->Pitch = (ChannelDimension_t) 0.0 ;
52 channel->Porosity = (ChannelDimension_t) 0.0 ;
53 channel->NChannels = (Quantity_t) 0u ;
54 channel->NLayers = (CellIndex_t) 0u ;
55 channel->SourceLayerOffset = (CellIndex_t) 0u ;
56
57 coolant_init (&channel->Coolant) ;
58 material_init (&channel->WallMaterial) ;
59}
60
61/******************************************************************************/
62
64{
65 channel_destroy (dst) ;
66
67 dst->ChannelModel = src->ChannelModel ;
68 dst->Height = src->Height ;
69 dst->Length = src->Length ;
70 dst->Pitch = src->Pitch ;
71 dst->Porosity = src->Porosity ;
72 dst->NChannels = src->NChannels ;
73 dst->NLayers = src->NLayers ;
74 dst->SourceLayerOffset = src->SourceLayerOffset ;
75
76 coolant_copy (&dst->Coolant, &src->Coolant) ;
77 material_copy (&dst->WallMaterial, &src->WallMaterial) ;
78}
79
80/******************************************************************************/
81
83{
84 coolant_destroy (&channel->Coolant) ;
85 material_destroy (&channel->WallMaterial) ;
86
87 channel_init (channel) ;
88}
89/******************************************************************************/
90
92{
93 Channel_t *channel = (Channel_t *) malloc (sizeof(Channel_t)) ;
94
95 if (channel != NULL)
96
97 channel_init (channel) ;
98
99 return channel ;
100}
101
102/******************************************************************************/
103
105{
106 if (channel == NULL)
107
108 return NULL ;
109
110 Channel_t *newc = channel_calloc ( ) ;
111
112 if (newc != NULL)
113
114 channel_copy (newc, channel) ;
115
116 return newc ;
117}
118
119/******************************************************************************/
120
121void channel_free (Channel_t *channel)
122{
123 if (channel == NULL)
124
125 return ;
126
127 channel_destroy (channel) ;
128
129 free (channel) ;
130}
131
132/******************************************************************************/
133
135(
136 Channel_t *channel,
137 FILE *stream,
138 String_t prefix,
139 Dimensions_t *dimensions
140)
141{
143 {
144 fprintf (stream, "%smicrochannel 4rm :\n", prefix) ;
145 fprintf (stream, "%s height %7.1f ;\n", prefix, channel->Height) ;
146 fprintf (stream, "%s channel length %7.1f ;\n", prefix, dimensions->Cell.ChannelLength) ;
147 fprintf (stream, "%s wall length %7.1f ;\n", prefix, dimensions->Cell.WallLength) ;
148 fprintf (stream, "%s\n", prefix) ;
149 fprintf (stream, "%s first wall length %7.1f ;\n", prefix, dimensions->Cell.FirstWallLength) ;
150 fprintf (stream, "%s last wall length %7.1f ;\n", prefix, dimensions->Cell.LastWallLength) ;
151 fprintf (stream, "%s\n", prefix) ;
152 fprintf (stream, "%s wall material %s ;\n", prefix, channel->WallMaterial.Id) ;
153 fprintf (stream, "%s\n", prefix) ;
154 fprintf (stream, "%s coolant flow rate %.2f ;\n", prefix, FLOW_RATE_FROM_UM3SEC_TO_MLMIN(channel->Coolant.FlowRate)) ;
155 fprintf (stream, "%s\n", prefix) ;
156 fprintf (stream, "%s coolant heat transfer coefficient side %.4e ,\n", prefix, channel->Coolant.HTCSide) ;
157 fprintf (stream, "%s top %.4e ,\n", prefix, channel->Coolant.HTCTop) ;
158 fprintf (stream, "%s bottom %.4e ;\n", prefix, channel->Coolant.HTCBottom) ;
159 fprintf (stream, "%s\n", prefix) ;
160 fprintf (stream, "%s coolant volumetric heat capacity %.4e ;\n", prefix, channel->Coolant.VHC) ;
161 fprintf (stream, "%s\n", prefix) ;
162 fprintf (stream, "%s coolant incoming temperature %.2f ;\n", prefix, channel->Coolant.TIn ) ;
163 }
164
166 {
167 fprintf (stream, "%smicrochannel 2rm :\n", prefix) ;
168 fprintf (stream, "%s height %7.1f ;\n", prefix, channel->Height) ;
169 fprintf (stream, "%s channel length %7.1f ;\n", prefix, channel->Length) ;
170 fprintf (stream, "%s wall length %7.1f ;\n", prefix, channel->Pitch - channel->Length) ;
171 fprintf (stream, "%s\n", prefix) ;
172 fprintf (stream, "%s wall material %s ;\n", prefix, channel->WallMaterial.Id) ;
173 fprintf (stream, "%s\n", prefix) ;
174 fprintf (stream, "%s coolant flow rate %.2f ;\n", prefix, FLOW_RATE_FROM_UM3SEC_TO_MLMIN(channel->Coolant.FlowRate)) ;
175 fprintf (stream, "%s\n", prefix) ;
176 fprintf (stream, "%s coolant heat transfer coefficient top %.4e ,\n", prefix, channel->Coolant.HTCTop) ;
177 fprintf (stream, "%s bottom %.4e ;\n", prefix, channel->Coolant.HTCBottom) ;
178 fprintf (stream, "%s\n", prefix) ;
179 fprintf (stream, "%s coolant volumetric heat capacity %.4e ;\n", prefix, channel->Coolant.VHC) ;
180 fprintf (stream, "%s\n", prefix) ;
181 fprintf (stream, "%s coolant incoming temperature %.2f ;\n", prefix, channel->Coolant.TIn ) ;
182 }
183
185 {
186 fprintf (stream, "%spinfin :\n", prefix) ;
187 fprintf (stream, "%s height %7.1f ;\n", prefix, channel->Height) ;
188 fprintf (stream, "%s pin diameter %7.1f ;\n", prefix, DIAMETER(channel->Porosity, channel->Pitch)) ;
189 fprintf (stream, "%s pin pitch %7.1f ;\n", prefix, channel->Pitch) ;
190 fprintf (stream, "%s\n", prefix) ;
191 fprintf (stream, "%s pin distribution inline ;\n", prefix) ;
192 fprintf (stream, "%s\n", prefix) ;
193 fprintf (stream, "%s pin material %s ;\n", prefix, channel->WallMaterial.Id) ;
194 fprintf (stream, "%s\n", prefix) ;
195 fprintf (stream, "%s darcy velocity %.4e ;\n", prefix, channel->Coolant.DarcyVelocity) ;
196 fprintf (stream, "%s\n", prefix) ;
197 fprintf (stream, "%s coolant volumetric heat capacity %.4e ;\n", prefix, channel->Coolant.VHC) ;
198 fprintf (stream, "%s\n", prefix) ;
199 fprintf (stream, "%s coolant incoming temperature %.2f ;\n", prefix, channel->Coolant.TIn ) ;
200 }
201
203 {
204 fprintf (stream, "%spinfin :\n", prefix) ;
205 fprintf (stream, "%s height %7.1f ;\n", prefix, channel->Height) ;
206 fprintf (stream, "%s pin diameter %7.1f ;\n", prefix, DIAMETER(channel->Porosity, channel->Pitch)) ;
207 fprintf (stream, "%s pin pitch %7.1f ;\n", prefix, channel->Pitch) ;
208 fprintf (stream, "%s\n", prefix) ;
209 fprintf (stream, "%s pin distribution staggered ;\n", prefix) ;
210 fprintf (stream, "%s\n", prefix) ;
211 fprintf (stream, "%s pin material %s ;\n", prefix, channel->WallMaterial.Id) ;
212 fprintf (stream, "%s\n", prefix) ;
213 fprintf (stream, "%s darcy velocity %.4e ;\n", prefix, channel->Coolant.DarcyVelocity) ;
214 fprintf (stream, "%s\n", prefix) ;
215 fprintf (stream, "%s coolant volumetric heat capacity %.4e ;\n", prefix, channel->Coolant.VHC) ;
216 fprintf (stream, "%s\n", prefix) ;
217 fprintf (stream, "%s coolant incoming temperature %.2f ;\n", prefix, channel->Coolant.TIn ) ;
218 }
219}
220
221/******************************************************************************/
222
224(
225 Channel_t *channel,
226 Dimensions_t *dimensions,
227 CellIndex_t layer_index,
228 CellIndex_t __attribute__ ((unused)) row_index,
229 CellIndex_t column_index
230)
231{
232 Cconv_t C = (Cconv_t) 0.0 ;
233
234 switch (channel->ChannelModel)
235 {
237
238 C = CCONV_MC_4RM
239
240 (channel->NChannels, channel->Coolant.VHC,
241 channel->Coolant.FlowRate);
242
243 break ;
244
246
247 C = CCONV_MC_2RM
248
249 (channel->NChannels, channel->Coolant.VHC,
250 channel->Coolant.FlowRate, channel->Porosity,
251 get_cell_length (dimensions, column_index),
252 channel->Length) ;
253
254 break ;
255
258
259 C = CCONV_PF
260
261 (channel->Coolant.VHC, channel->Coolant.DarcyVelocity,
262 get_cell_length (dimensions, column_index),
263 get_cell_height (dimensions, layer_index));
264
265 break ;
266
268
269 fprintf (stderr, "WARNING: unsert channel model\n") ;
270
271 break ;
272
273 default :
274
275 fprintf (stderr, "ERROR: unknown channel model %d\n",
276 channel->ChannelModel) ;
277 }
278
279 return C ;
280}
281
282/******************************************************************************/
283
285(
286 Channel_t *channel,
287 Dimensions_t *dimensions,
288 CellIndex_t layer_index,
289 ChipDimension_t cell_length
290)
291{
292 Cconv_t C = (Cconv_t) 0.0 ;
293
294 switch (channel->ChannelModel)
295 {
297
298 C = CCONV_MC_4RM
299
300 (channel->NChannels, channel->Coolant.VHC,
301 channel->Coolant.FlowRate);
302
303 break ;
304
306
307 C = CCONV_MC_2RM
308
309 (channel->NChannels, channel->Coolant.VHC,
310 channel->Coolant.FlowRate, channel->Porosity,
311 cell_length,
312 channel->Length) ;
313
314 break ;
315
318
319 C = CCONV_PF
320
321 (channel->Coolant.VHC, channel->Coolant.DarcyVelocity,
322 cell_length,
323 get_cell_height (dimensions, layer_index));
324
325 break ;
326
328
329 fprintf (stderr, "WARNING: unsert channel model\n") ;
330
331 break ;
332
333 default :
334
335 fprintf (stderr, "ERROR: unknown channel model %d\n",
336 channel->ChannelModel) ;
337 }
338
339 return C ;
340}
341
342/******************************************************************************/
343
345(
346 Channel_t *channel,
347 Dimensions_t *dimensions,
348 Temperature_t *temperatures
349)
350{
351 temperatures += get_cell_offset_in_layer
352
353 (dimensions, last_row(dimensions), first_column (dimensions)) ;
354
355 Temperature_t max = *temperatures ;
356
357 CellIndex_t column ;
358
359 for (column = first_column (dimensions) ; column <= last_column (dimensions) ; column++)
360 {
361 if (IS_CHANNEL_COLUMN(channel->ChannelModel, column) == true)
362
363 max = MAX (max, *temperatures) ;
364
365 temperatures++ ;
366 }
367
368 return max ;
369}
370
371/******************************************************************************/
372
374(
375 Channel_t *channel,
376 Dimensions_t *dimensions,
377 Temperature_t *temperatures
378)
379{
380 temperatures += get_cell_offset_in_layer
381
382 (dimensions, last_row(dimensions), first_column (dimensions)) ;
383
384 Temperature_t min = *temperatures ;
385
386 CellIndex_t column ;
387
388 for (column = first_column (dimensions) ; column <= last_column (dimensions) ; column++)
389 {
390 if (IS_CHANNEL_COLUMN(channel->ChannelModel, column) == true)
391
392 min = MIN (min, *temperatures) ;
393
394 temperatures++ ;
395 }
396
397 return min ;
398}
399
400/******************************************************************************/
401
403(
404 Channel_t *channel,
405 Dimensions_t *dimensions,
406 Temperature_t *temperatures
407)
408{
409 temperatures += get_cell_offset_in_layer
410
411 (dimensions, last_row (dimensions), first_column (dimensions)) ;
412
413 Temperature_t avg = *temperatures ;
414
415 CellIndex_t column ;
416
417 for (column = first_column (dimensions) ; column <= last_column (dimensions) ; column++)
418 {
419 if (IS_CHANNEL_COLUMN(channel->ChannelModel, column) == true)
420
421 avg += *temperatures ;
422
423 temperatures++ ;
424 }
425
426 return avg / (Temperature_t) channel->NChannels ;
427}
428
429/******************************************************************************/
430
432(
433 Channel_t *channel,
434 Dimensions_t *dimensions,
435 Temperature_t *temperatures
436)
437{
438 temperatures += get_cell_offset_in_layer
439
440 (dimensions, last_row(dimensions), first_column (dimensions)) ;
441
442 Temperature_t max = *temperatures ;
443 Temperature_t min = *temperatures ;
444
445 CellIndex_t column ;
446
447 for (column = first_column (dimensions) ; column <= last_column (dimensions) ; column++)
448 {
449 if (IS_CHANNEL_COLUMN(channel->ChannelModel, column) == true)
450 {
451 min = MIN (min, *temperatures) ;
452 max = MAX (max, *temperatures) ;
453 }
454
455 temperatures++ ;
456 }
457
458 return max ;
459}
460
461/******************************************************************************/
Temperature_t get_max_temperature_channel_outlet(Channel_t *channel, Dimensions_t *dimensions, Temperature_t *temperatures)
Definition: channel.c:345
void channel_print(Channel_t *channel, FILE *stream, String_t prefix, Dimensions_t *dimensions)
Definition: channel.c:135
void channel_init(Channel_t *channel)
Definition: channel.c:46
Channel_t * channel_calloc(void)
Definition: channel.c:91
void channel_copy(Channel_t *dst, Channel_t *src)
Definition: channel.c:63
Temperature_t get_gradient_temperature_channel_outlet(Channel_t *channel, Dimensions_t *dimensions, Temperature_t *temperatures)
Definition: channel.c:432
void channel_free(Channel_t *channel)
Definition: channel.c:121
Channel_t * channel_clone(Channel_t *channel)
Definition: channel.c:104
void channel_destroy(Channel_t *channel)
Definition: channel.c:82
Temperature_t get_min_temperature_channel_outlet(Channel_t *channel, Dimensions_t *dimensions, Temperature_t *temperatures)
Definition: channel.c:374
Cconv_t get_convective_term(Channel_t *channel, Dimensions_t *dimensions, CellIndex_t layer_index, CellIndex_t row_index, CellIndex_t column_index)
Cconv_t get_convective_term_nonuniform(Channel_t *channel, Dimensions_t *dimensions, CellIndex_t layer_index, ChipDimension_t cell_length)
Definition: channel.c:285
Temperature_t get_avg_temperature_channel_outlet(Channel_t *channel, Dimensions_t *dimensions, Temperature_t *temperatures)
Definition: channel.c:403
void coolant_init(Coolant_t *coolant)
Definition: coolant.c:43
void coolant_copy(Coolant_t *dst, Coolant_t *src)
Definition: coolant.c:56
void coolant_destroy(Coolant_t *coolant)
Definition: coolant.c:71
CellDimension_t get_cell_height(Dimensions_t *dimensions, CellIndex_t layer_index)
Definition: dimensions.c:536
CellDimension_t get_cell_length(Dimensions_t *dimensions, CellIndex_t column_index)
Definition: dimensions.c:478
CellIndex_t last_column(Dimensions_t *dimensions)
Definition: dimensions.c:456
CellIndex_t get_cell_offset_in_layer(Dimensions_t *dimensions, CellIndex_t row_index, CellIndex_t column_index)
Definition: dimensions.c:674
CellIndex_t first_column(Dimensions_t *dimensions)
CellIndex_t last_row(Dimensions_t *dimensions)
Definition: dimensions.c:442
#define CCONV_MC_2RM(nchannels, vhc, fr, porosity, cell_l, channel_l)
Definition: macros.h:158
#define MIN(a, b)
Definition: macros.h:78
#define DIAMETER(porosity, pitch)
Definition: macros.h:251
#define CCONV_PF(vhc, darcy_velocity, cell_l, cavity_h)
Definition: macros.h:175
#define CCONV_MC_4RM(nchannels, vhc, fr)
Definition: macros.h:129
#define FLOW_RATE_FROM_UM3SEC_TO_MLMIN(fr)
Definition: macros.h:231
#define IS_CHANNEL_COLUMN(channel_model, column)
Definition: macros.h:101
#define MAX(a, b)
Definition: macros.h:69
void material_copy(Material_t *dst, Material_t *src)
Definition: material.c:55
void material_destroy(Material_t *material)
Definition: material.c:67
void material_init(Material_t *material)
Definition: material.c:45
char * String_t
Definition: string_t.h:55
CellDimension_t LastWallLength
Definition: dimensions.h:102
CellDimension_t ChannelLength
Definition: dimensions.h:96
CellDimension_t FirstWallLength
Definition: dimensions.h:85
CellDimension_t WallLength
Definition: dimensions.h:91
Structure used to store data about the channel that compose the 2D/3D stack.
Definition: channel.h:71
ChannelDimension_t Length
Definition: channel.h:82
CellDimension_t Height
Definition: channel.h:78
Coolant_t Coolant
Definition: channel.h:106
CellIndex_t NLayers
Definition: channel.h:98
ChannelModel_t ChannelModel
Definition: channel.h:74
Material_t WallMaterial
Definition: channel.h:110
CellIndex_t SourceLayerOffset
Definition: channel.h:102
ChannelDimension_t Pitch
Definition: channel.h:86
ChannelDimension_t Porosity
Definition: channel.h:90
Quantity_t NChannels
Definition: channel.h:94
CoolantVHC_t VHC
Definition: coolant.h:82
CoolantHTC_t HTCSide
Definition: coolant.h:66
CoolantHTC_t HTCTop
Definition: coolant.h:72
CoolantFR_t FlowRate
Definition: coolant.h:89
DarcyVelocity_t DarcyVelocity
Definition: coolant.h:93
Temperature_t TIn
Definition: coolant.h:97
CoolantHTC_t HTCBottom
Definition: coolant.h:78
Collections of all the structures that are needed for the thermal simulation.
Definition: dimensions.h:311
CellDimensions_t Cell
Definition: dimensions.h:314
String_t Id
Definition: material.h:73
double Cconv_t
Definition: types.h:165
ChannelModel_t
Definition: types.h:346
@ TDICE_CHANNEL_MODEL_PF_INLINE
Inline pin fins - 2 Resistors model.
Definition: types.h:350
@ TDICE_CHANNEL_MODEL_PF_STAGGERED
Staggered pin fins - 2 Resistors model.
Definition: types.h:351
@ TDICE_CHANNEL_MODEL_NONE
Undefined type.
Definition: types.h:347
@ TDICE_CHANNEL_MODEL_MC_4RM
Microchannel - 4 Resistors model.
Definition: types.h:348
@ TDICE_CHANNEL_MODEL_MC_2RM
Microchannel - 2 Resistors model.
Definition: types.h:349
double ChipDimension_t
Definition: types.h:187
double ChannelDimension_t
Definition: types.h:205
double Temperature_t
Definition: types.h:71
double CellDimension_t
Definition: types.h:177
uint32_t Quantity_t
Definition: types.h:59
uint32_t CellIndex_t
Definition: types.h:213