3D-ICE 3.0.0
system_matrix.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 "system_matrix.h"
42#include "macros.h"
43
44/******************************************************************************/
45
47{
48 sysmatrix->ColumnPointers = NULL ;
49 sysmatrix->RowIndices = NULL;
50 sysmatrix->Values = NULL ;
51 sysmatrix->Size = (CellIndex_t) 0u ;
52 sysmatrix->NNz = (CellIndex_t) 0u ;
53
54 sysmatrix->SLU_PermutationMatrixR = NULL ;
55 sysmatrix->SLU_PermutationMatrixC = NULL ;
56 sysmatrix->SLU_Etree = NULL ;
57
58 sysmatrix->SLUMatrix_A.Store = NULL ;
59 sysmatrix->SLUMatrix_A_Permuted.Store = NULL ;
60 sysmatrix->SLUMatrix_L.Store = NULL ;
61 sysmatrix->SLUMatrix_U.Store = NULL ;
62
63 sysmatrix->SLU_Info = 0 ;
64
65 sysmatrix->SLU_Stat.panel_histo = NULL ;
66 sysmatrix->SLU_Stat.utime = NULL ;
67 sysmatrix->SLU_Stat.ops = NULL ;
68 sysmatrix->SLU_Stat.TinyPivots = (int) 0 ;
69 sysmatrix->SLU_Stat.RefineSteps = (int) 0 ;
70 sysmatrix->SLU_Stat.expansions = (int) 0 ;
71
72 set_default_options (&sysmatrix->SLU_Options) ;
73
74 sysmatrix->SLU_Options.Fact = DOFACT ;
75 sysmatrix->SLU_Options.PrintStat = NO ;
76 sysmatrix->SLU_Options.Equil = NO ;
77 sysmatrix->SLU_Options.SymmetricMode = YES ;
78 sysmatrix->SLU_Options.ColPerm = MMD_AT_PLUS_A ;
79 sysmatrix->SLU_Options.RowPerm = NOROWPERM ;
80 sysmatrix->SLU_Options.DiagPivotThresh = 0.001 ;
81}
82
83/******************************************************************************/
84
86(
87 SystemMatrix_t *sysmatrix,
88 CellIndex_t size,
89 CellIndex_t nnz
90)
91{
92 sysmatrix->Size = size ;
93 sysmatrix->NNz = nnz ;
94
95 sysmatrix->RowIndices = (CellIndex_t *) malloc (sizeof(CellIndex_t) * nnz) ;
96
97 if (sysmatrix->RowIndices == NULL)
98
99 return TDICE_FAILURE ;
100
101 sysmatrix->ColumnPointers = (CellIndex_t *) malloc (sizeof(CellIndex_t) * (size + 1)) ;
102
103 if (sysmatrix->ColumnPointers == NULL)
104 {
105 free (sysmatrix->RowIndices) ;
106 return TDICE_FAILURE ;
107 }
108
109 sysmatrix->Values = (SystemMatrixCoeff_t *) malloc (sizeof(SystemMatrixCoeff_t) * nnz) ;
110
111 if (sysmatrix->Values == NULL)
112 {
113 free (sysmatrix->ColumnPointers) ;
114 free (sysmatrix->RowIndices) ;
115 return TDICE_FAILURE ;
116 }
117
118 dCreate_CompCol_Matrix
119
120 (&sysmatrix->SLUMatrix_A, sysmatrix->Size, sysmatrix->Size, sysmatrix->NNz,
121 sysmatrix->Values, (int*) sysmatrix->RowIndices, (int*) sysmatrix->ColumnPointers,
122 SLU_NC, SLU_D, SLU_GE) ;
123
124 /* Alloc SLU permutation matrices and elimination tree */
125
126 sysmatrix->SLU_PermutationMatrixR = (int *) malloc (sizeof(int) * sysmatrix->Size) ;
127
128 if (sysmatrix->SLU_PermutationMatrixR == NULL )
129 {
130 free (sysmatrix->ColumnPointers) ;
131 free (sysmatrix->RowIndices) ;
132 free (sysmatrix->Values) ;
133
134 Destroy_SuperMatrix_Store (&sysmatrix->SLUMatrix_A) ;
135
136 return TDICE_FAILURE ;
137 }
138
139 sysmatrix->SLU_PermutationMatrixC = (int *) malloc(sizeof(int) * sysmatrix->Size) ;
140
141 if (sysmatrix->SLU_PermutationMatrixC == NULL )
142 {
143 free (sysmatrix->ColumnPointers) ;
144 free (sysmatrix->RowIndices) ;
145 free (sysmatrix->Values) ;
146
147 Destroy_SuperMatrix_Store (&sysmatrix->SLUMatrix_A) ;
148
149 free (sysmatrix->SLU_PermutationMatrixR) ;
150
151 return TDICE_FAILURE ;
152 }
153
154 sysmatrix->SLU_Etree = (int *) malloc (sizeof(int) * sysmatrix->Size) ;
155
156 if (sysmatrix->SLU_Etree == NULL)
157 {
158 free (sysmatrix->ColumnPointers) ;
159 free (sysmatrix->RowIndices) ;
160 free (sysmatrix->Values) ;
161
162 Destroy_SuperMatrix_Store (&sysmatrix->SLUMatrix_A) ;
163
164 free (sysmatrix->SLU_PermutationMatrixR) ;
165 free (sysmatrix->SLU_PermutationMatrixC) ;
166
167 return TDICE_FAILURE ;
168 }
169
170 StatInit (&sysmatrix->SLU_Stat) ;
171
172 return TDICE_SUCCESS ;
173}
174
175/******************************************************************************/
176
178{
179 if (sysmatrix->SLU_Options.Fact == DOFACT)
180 {
181 get_perm_c
182
183 (sysmatrix->SLU_Options.ColPerm, &sysmatrix->SLUMatrix_A,
184 sysmatrix->SLU_PermutationMatrixC) ;
185
186 sp_preorder
187
188 (&sysmatrix->SLU_Options, &sysmatrix->SLUMatrix_A,
189 sysmatrix->SLU_PermutationMatrixC, sysmatrix->SLU_Etree,
190 &sysmatrix->SLUMatrix_A_Permuted) ;
191 }
192 else if (sysmatrix->SLU_Options.Fact == FACTORED)
193 {
194 sysmatrix->SLU_Options.Fact = SamePattern_SameRowPerm ;
195 }
196 else
197 {
198 fprintf (stderr, "ERROR: wrong factorization status %d\n",
199 sysmatrix->SLU_Options.Fact) ;
200
201 return TDICE_FAILURE ;
202 }
203
204 dgstrf
205
206 (&sysmatrix->SLU_Options, &sysmatrix->SLUMatrix_A_Permuted,
207 sp_ienv(2), sp_ienv(1), /* relax and panel size */
208 sysmatrix->SLU_Etree,
209 NULL, 0, /* work and lwork */
210 sysmatrix->SLU_PermutationMatrixC, sysmatrix->SLU_PermutationMatrixR,
211 &sysmatrix->SLUMatrix_L, &sysmatrix->SLUMatrix_U,
212 &sysmatrix->SLU_Stat, &sysmatrix->SLU_Info) ;
213
214 if (sysmatrix->SLU_Info == 0)
215 {
216 sysmatrix->SLU_Options.Fact = FACTORED ;
217
218 return TDICE_SUCCESS ;
219 }
220 else
221 {
222 fprintf (stderr, "SuperLu factorization error %d\n", sysmatrix->SLU_Info) ;
223
224 return TDICE_FAILURE ;
225 }
226}
227
228/******************************************************************************/
229
231{
232 free (sysmatrix->ColumnPointers) ;
233 free (sysmatrix->RowIndices) ;
234 free (sysmatrix->Values) ;
235
236 free (sysmatrix->SLU_PermutationMatrixR) ;
237 free (sysmatrix->SLU_PermutationMatrixC) ;
238 free (sysmatrix->SLU_Etree) ;
239
240 StatFree (&sysmatrix->SLU_Stat) ;
241
242 Destroy_SuperMatrix_Store (&sysmatrix->SLUMatrix_A) ;
243
244 if (sysmatrix->SLU_Options.Fact != DOFACT )
245 {
246 Destroy_CompCol_Permuted (&sysmatrix->SLUMatrix_A_Permuted) ;
247 Destroy_SuperNode_Matrix (&sysmatrix->SLUMatrix_L) ;
248 Destroy_CompCol_Matrix (&sysmatrix->SLUMatrix_U) ;
249 }
250
251 system_matrix_init (sysmatrix) ;
252}
253
254/******************************************************************************/
255// implemented for qsort, find the small index
256// by comparing both the column and row index
257static int compare(const void* p1, const void* p2) {
258 const ChipDimension_t (*a)[3] = p1;
259 const ChipDimension_t (*b)[3] = p2;
260
261 if ( (*a)[1] < (*b)[1] )
262 return -1;
263 else if ((*a)[1] > (*b)[1])
264 return 1;
265 else
266 {
267 if ( (*a)[0] >= (*b)[0] ) return 1;
268 return -1;
269 }
270
271}
272
273/******************************************************************************/
274
275static SystemMatrix_t add_solid_column_non_uniform
276(
277 SystemMatrix_t sysmatrix,
278 ThermalGrid_t *thermal_grid,
279 Analysis_t *analysis,
280 Dimensions_t *dimensions
281)
282{
283 // Conductance_t conductance = 0.0 ;
284 // SystemMatrixCoeff_t diagonal_value = 0.0 ;
285 // SystemMatrixCoeff_t *diagonal_pointer = NULL ;
286
287 // Conductance_t g_bottom, g_top, g_north, g_south, g_east, g_west ;
288
289 // *sysmatrix.ColumnPointers = *(sysmatrix.ColumnPointers - 1) ;
290 ChipDimension_t matrix_tmp[dimensions->Grid.NConnections][3];
291 memset(matrix_tmp, 0, sizeof matrix_tmp);
292 CellIndex_t matrix_tmp_index = 0;
293 ConnectionListNode_t* i_cell;
294 Conductance_t sign_note;
295 for(i_cell = dimensions->connections_list.First; i_cell!=NULL; i_cell=i_cell->Next)
296 {
297 matrix_tmp[matrix_tmp_index][0] = i_cell->Data.node2; //r
298 matrix_tmp[matrix_tmp_index][1] = i_cell->Data.node1; //c
299 matrix_tmp[matrix_tmp_index][2] = get_conductance_non_uniform(thermal_grid, dimensions, i_cell, i_cell->Data.node2, i_cell->Data.node1, &sign_note); //v
300 #ifdef PRINT_DEBUG_INFO
301 printf("r:%d, c:%d, v:%f\n",i_cell->Data.node2,i_cell->Data.node1,matrix_tmp[matrix_tmp_index][2]);
302 #endif
303 matrix_tmp_index++;
304 matrix_tmp[matrix_tmp_index][0] = i_cell->Data.node1; //r
305 matrix_tmp[matrix_tmp_index][1] = i_cell->Data.node2; //c
306 matrix_tmp[matrix_tmp_index][2] = sign_note*matrix_tmp[matrix_tmp_index-1][2]; //v
307 matrix_tmp_index++;
308 }
309
310 // fill diagnal value with boundary condition
311 CellIndex_t matrix_tmp_index_2 = matrix_tmp_index;
312 CellIndex_t matrix_tmp_index_3 = matrix_tmp_index_2;
313 //Darong_TODO: Can be optimized
314 for(; matrix_tmp_index_3 < dimensions->Grid.NConnections; matrix_tmp_index_3++)
315 {
316 // fill the index
317 matrix_tmp[matrix_tmp_index_3][0] = matrix_tmp_index_3-matrix_tmp_index_2;
318 matrix_tmp[matrix_tmp_index_3][1] = matrix_tmp_index_3-matrix_tmp_index_2;
319
320 // fill the value
321 Non_uniform_cellListNode_t* node = dimensions->Cell_list.First;
322 CellIndex_t node_index = matrix_tmp_index_3-matrix_tmp_index_2;
323 for (CellIndex_t i = 0; i<node_index; i++)
324 node = node->Next;
325
327 {
328 matrix_tmp[matrix_tmp_index_3][2] = get_capacity_non_uniform (thermal_grid, dimensions, node);
329
330 matrix_tmp[matrix_tmp_index_3][2] /= analysis->StepTime ;
331 }
332
333 CellIndex_t layer_index = node->Data.layer_info;
334 if (layer_index < dimensions->Grid.NLayers)
335 {
336 switch (thermal_grid->LayersTypeProfile [layer_index])
337 {
338 // Darong_TODO: Support more layers
341
342 matrix_tmp[matrix_tmp_index_3][2] += ( 2.0
343 * get_thermal_conductivity (thermal_grid->LayersProfile + layer_index,
344 0, 0,
345 dimensions)
346 * thermal_grid->TopHeatSink->AmbientHTC
347 * node->Data.length
348 * node->Data.width
349 )
350 /
351 ( get_cell_height (dimensions, layer_index)
352 * thermal_grid->TopHeatSink->AmbientHTC
353 + 2.0
354 * get_thermal_conductivity (thermal_grid->LayersProfile + layer_index,
355 0, 0,
356 dimensions)
357 ) ;
358 break;
359
361 if (node->Data.isChannel == 1)
362 {
363 if (node->Data.left_y+node->Data.width == dimensions->Chip.Width)
364 {
365 matrix_tmp[matrix_tmp_index_3][2] += 2*get_conductance_non_uniform_y(thermal_grid, dimensions, 0, node, 1) ;
366 }
367 }
368
369 break;
373 if (node->Data.isChannel == 1)
374 {
375 if (node->Data.left_y+node->Data.width == dimensions->Chip.Width)
376 {
377 matrix_tmp[matrix_tmp_index_3][2] += 2*get_conductance_non_uniform_y(thermal_grid, dimensions, node->Data.length, node, 1) ;
378 }
379 }
380
381 break;
382
383 default:
384 matrix_tmp[matrix_tmp_index_3][2] += 0.0;
385 }
386 }
387 }
388
389 // sum
390 matrix_tmp_index_3 = matrix_tmp_index_2;
391 for(; matrix_tmp_index>0; matrix_tmp_index--) // go back and add all the conductance to the diagnal one
392 {
393 matrix_tmp_index_3 = matrix_tmp_index_2+matrix_tmp[matrix_tmp_index-1][1]; // find the diagnal index
394 matrix_tmp[matrix_tmp_index_3][2] += -matrix_tmp[matrix_tmp_index-1][2]; // add the conduactance
395 }
396
397 qsort(matrix_tmp, dimensions->Grid.NConnections, sizeof matrix_tmp[0],compare);
398
399
400 // fill the system matrix
401 *sysmatrix.ColumnPointers = *(sysmatrix.ColumnPointers - 1) ;
402 CellIndex_t layer_tmp = matrix_tmp[0][1];
403 for (CellIndex_t i = 0; i<dimensions->Grid.NConnections; i++)
404 {
405
406 *sysmatrix.RowIndices++ = matrix_tmp[i][0];
407 *sysmatrix.Values++ = matrix_tmp[i][2];
408
409 if (layer_tmp != (CellIndex_t) matrix_tmp[i][1])
410 {
411 sysmatrix.ColumnPointers++ ;
412 *sysmatrix.ColumnPointers = *(sysmatrix.ColumnPointers - 1) ;
413 layer_tmp = (CellIndex_t) matrix_tmp[i][1];
414 }
415 (*sysmatrix.ColumnPointers)++ ;
416 // printf("r:%d, c:%d, v:%f\n",*(sysmatrix.RowIndices-1),*(sysmatrix.ColumnPointers-1),*(sysmatrix.Values-1));
417
418 }
419
420
421 return sysmatrix ;
422}
423
424/******************************************************************************/
425
426static SystemMatrix_t add_solid_column
427(
428 SystemMatrix_t sysmatrix,
429 ThermalGrid_t *thermal_grid,
430 Analysis_t *analysis,
431 Dimensions_t *dimensions,
432 CellIndex_t layer_index,
433 CellIndex_t row_index,
434 CellIndex_t column_index
435)
436{
437 // #define PRINT_SYSTEM_MATRIX 1
438 Conductance_t conductance = 0.0 ;
439 SystemMatrixCoeff_t diagonal_value = 0.0 ;
440 SystemMatrixCoeff_t *diagonal_pointer = NULL ;
441
442 Conductance_t g_bottom, g_top, g_north, g_south, g_east, g_west ;
443
444#ifdef PRINT_SYSTEM_MATRIX
445 fpos_t diag_fposition, last_fpos ;
446
447 fprintf (stderr,
448 "add_solid_column l %2d r %4d c %4d [%7d]\n",
449 layer_index, row_index, column_index,
450 get_cell_offset_in_stack (dimensions, layer_index, row_index, column_index)) ;
451#endif
452
453 *sysmatrix.ColumnPointers = *(sysmatrix.ColumnPointers - 1) ;
454
455 /********************************* BOTTOM *********************************/
456
457 if (layer_index == first_layer (dimensions))
458
459 goto skip_bottom ;
460
462
463 (dimensions, layer_index - 1, row_index, column_index) ;
464
465 g_bottom = get_conductance_bottom
466
467 (thermal_grid, dimensions, layer_index , row_index, column_index) ;
468
469 g_top = get_conductance_top
470
471 (thermal_grid, dimensions, layer_index - 1, row_index, column_index) ;
472
473 if (g_top == 0)
474
475 conductance = g_bottom ;
476
477 else
478
479 conductance = PARALLEL (g_bottom, g_top) ;
480
481 *sysmatrix.Values++ = -conductance ;
482 diagonal_value += conductance ;
483
484 (*sysmatrix.ColumnPointers)++ ;
485
486#ifdef PRINT_SYSTEM_MATRIX
487 fprintf (stderr,
488 " bottom \t%d\t% .4e = % .4e (B) || % .4e (T)\n",
489 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1), g_bottom, g_top) ;
490#endif
491
492skip_bottom :
493
494 /********************************* SOUTH **********************************/
495
496 if (row_index == first_row (dimensions)) goto skip_south ;
497
499
500 (dimensions, layer_index, row_index - 1, column_index) ;
501
502 g_south = get_conductance_south
503
504 (thermal_grid, dimensions, layer_index, row_index , column_index) ;
505
506 g_north = get_conductance_north
507
508 (thermal_grid, dimensions, layer_index, row_index - 1, column_index) ;
509
510 conductance = PARALLEL (g_south, g_north) ;
511
512 *sysmatrix.Values++ = -conductance ;
513 diagonal_value += conductance ;
514
515 (*sysmatrix.ColumnPointers)++ ;
516
517#ifdef PRINT_SYSTEM_MATRIX
518 fprintf (stderr,
519 " south \t%d\t% .4e = % .4e (S) || % .4e (N)\n",
520 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1), g_south, g_north) ;
521#endif
522
523skip_south :
524
525 /********************************* WEST ***********************************/
526
527 if (column_index == first_column (dimensions)) goto skip_west ;
528
530
531 (dimensions, layer_index, row_index, column_index - 1) ;
532
533 g_west = get_conductance_west
534
535 (thermal_grid, dimensions, layer_index, row_index, column_index ) ;
536
537 g_east = get_conductance_east
538
539 (thermal_grid, dimensions, layer_index, row_index, column_index - 1) ;
540
541 conductance = PARALLEL (g_west, g_east) ;
542
543 *sysmatrix.Values++ = -conductance ;
544 diagonal_value += conductance ;
545
546 (*sysmatrix.ColumnPointers)++ ;
547
548#ifdef PRINT_SYSTEM_MATRIX
549 fprintf (stderr,
550 " west \t%d\t% .4e = % .4e (W) || % .4e (E)\n",
551 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1), g_west, g_east) ;
552#endif
553
554skip_west :
555
556 /********************************* DIAGONAL *******************************/
557
559
560 (dimensions, layer_index, row_index, column_index) ;
561
562 *sysmatrix.Values = 0.0 ;
563
565 {
566 *sysmatrix.Values = get_capacity
567
568 (thermal_grid, dimensions, layer_index, row_index, column_index) ;
569
570 *sysmatrix.Values /= analysis->StepTime ;
571 }
572
573 if ( thermal_grid->LayersTypeProfile [layer_index] == TDICE_LAYER_SOLID_CONNECTED_TO_AMBIENT
574 || thermal_grid->LayersTypeProfile [layer_index] == TDICE_LAYER_SOURCE_CONNECTED_TO_AMBIENT)
575 {
576 *sysmatrix.Values += get_conductance_top
577
578 (thermal_grid, dimensions, layer_index, row_index, column_index) ;
579 }
580 else if ( thermal_grid->LayersTypeProfile [layer_index] == TDICE_LAYER_SOLID_CONNECTED_TO_PCB
581 || thermal_grid->LayersTypeProfile [layer_index] == TDICE_LAYER_SOURCE_CONNECTED_TO_PCB)
582 {
583 *sysmatrix.Values += get_conductance_bottom
584
585 (thermal_grid, dimensions, layer_index, row_index, column_index) ;
586 }
587
588 diagonal_pointer = sysmatrix.Values++ ;
589
590 (*sysmatrix.ColumnPointers)++ ;
591
592#ifdef PRINT_SYSTEM_MATRIX
593 fprintf (stderr, " diagonal\t%d\t", *(sysmatrix.RowIndices-1)) ;
594 fgetpos (stderr, &diag_fposition) ;
595 fprintf (stderr, " ( + % .4e [capacity] )\n", *(sysmatrix.Values-1)) ;
596#endif
597
598 /********************************* EAST ***********************************/
599
600 if (column_index == last_column (dimensions)) goto skip_east ;
601
603
604 (dimensions, layer_index, row_index, column_index + 1) ;
605
606 g_east = get_conductance_east
607
608 (thermal_grid, dimensions, layer_index, row_index, column_index ) ;
609
610 g_west = get_conductance_west
611
612 (thermal_grid, dimensions, layer_index, row_index, column_index + 1) ;
613
614 conductance = PARALLEL (g_east, g_west) ;
615
616 *sysmatrix.Values++ = -conductance ;
617 diagonal_value += conductance ;
618
619 (*sysmatrix.ColumnPointers)++ ;
620
621#ifdef PRINT_SYSTEM_MATRIX
622 fprintf (stderr,
623 " east \t%d\t% .4e = % .4e (E) || % .4e (W)\n",
624 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1), g_east, g_west) ;
625#endif
626
627skip_east :
628
629 /********************************* NORTH **********************************/
630
631 if (row_index == last_row (dimensions)) goto skip_north ;
632
634
635 (dimensions, layer_index, row_index + 1, column_index) ;
636
637 g_north = get_conductance_north
638
639 (thermal_grid, dimensions, layer_index, row_index , column_index) ;
640
641 g_south = get_conductance_south
642
643 (thermal_grid, dimensions, layer_index, row_index + 1, column_index) ;
644
645 conductance = PARALLEL (g_north, g_south) ;
646
647 *sysmatrix.Values++ = -conductance ;
648 diagonal_value += conductance ;
649
650 (*sysmatrix.ColumnPointers)++ ;
651
652#ifdef PRINT_SYSTEM_MATRIX
653 fprintf (stderr,
654 " north \t%d\t% .4e = % .4e (N) || % .4e (S)\n",
655 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1), g_north, g_south) ;
656#endif
657
658skip_north :
659
660 /********************************* TOP ************************************/
661
662 if (layer_index == last_layer (dimensions)) goto skip_top ;
663
665
666 (dimensions, layer_index + 1, row_index, column_index) ;
667
668 g_top = get_conductance_top
669
670 (thermal_grid, dimensions, layer_index, row_index, column_index) ;
671
672 g_bottom = get_conductance_bottom
673
674 (thermal_grid, dimensions, layer_index + 1, row_index, column_index) ;
675
676 if (g_bottom == 0.0)
677
678 conductance = g_top ;
679
680 else
681
682 conductance = PARALLEL (g_top, g_bottom) ;
683
684 *sysmatrix.Values++ = -conductance ;
685 diagonal_value += conductance ;
686
687 (*sysmatrix.ColumnPointers)++ ;
688
689#ifdef PRINT_SYSTEM_MATRIX
690 fprintf (stderr,
691 " top \t%d\t% .4e = % .4e (T) || % .4e (B)\n",
692 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1),
693 g_top, g_bottom) ;
694#endif
695
696skip_top :
697
698 // Connection between the layer submatrix and the spreader submatrix
699 if ( thermal_grid->LayersTypeProfile [layer_index] == TDICE_LAYER_SOLID_CONNECTED_TO_SPREADER
700 || thermal_grid->LayersTypeProfile [layer_index] == TDICE_LAYER_SOURCE_CONNECTED_TO_SPREADER)
701 {
703 (dimensions, thermal_grid->TopHeatSink, row_index, column_index) ;
704
705 g_top = get_conductance_top(thermal_grid, dimensions, layer_index, row_index, column_index) ;
706
707 g_bottom = get_spreader_conductance_top_bottom(thermal_grid->TopHeatSink);
708
709 conductance = PARALLEL (g_bottom, g_top) ;
710
711 *sysmatrix.Values++ = -conductance ;
712 diagonal_value += conductance ;
713
714 (*sysmatrix.ColumnPointers)++ ;
715
716 #ifdef PRINT_SYSTEM_MATRIX
717 fprintf (stderr,
718 " top \t%d\t% .4e = % .4e (T) || % .4e (B)\n",
719 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1),
720 g_top, g_bottom) ;
721 #endif
722 }
723
724 /************************** DIAGONAL ELEMENT ******************************/
725
726 *diagonal_pointer += diagonal_value ;
727
728#ifdef PRINT_SYSTEM_MATRIX
729 fgetpos (stderr, &last_fpos) ;
730 fsetpos (stderr, &diag_fposition) ;
731 fprintf (stderr, "% .4e", *diagonal_pointer) ;
732 fsetpos (stderr, &last_fpos) ;
733
734 fprintf (stderr, " %d\n", *sysmatrix.ColumnPointers) ;
735#endif
736
737 sysmatrix.ColumnPointers++ ;
738
739 return sysmatrix ;
740}
741
742/******************************************************************************/
743
744static SystemMatrix_t add_liquid_column_4rm
745(
746 SystemMatrix_t sysmatrix,
747 ThermalGrid_t *thermal_grid,
748 Analysis_t *analysis,
749 Dimensions_t *dimensions,
750 CellIndex_t layer_index,
751 CellIndex_t row_index,
752 CellIndex_t column_index
753)
754{
755 Conductance_t conductance = 0.0 ;
756 SystemMatrixCoeff_t diagonal_value = 0.0 ;
757 SystemMatrixCoeff_t *diagonal_pointer = NULL ;
758
759#ifdef PRINT_SYSTEM_MATRIX
760 fpos_t diag_fposition, last_fpos ;
761 fprintf (stderr,
762 "add_liquid_column_4rm l %2d r %4d c %4d [%7d]\n",
763 layer_index, row_index, column_index,
764 get_cell_offset_in_stack (dimensions, layer_index, row_index, column_index)) ;
765#endif
766
767 *sysmatrix.ColumnPointers = *(sysmatrix.ColumnPointers - 1) ;
768
769 /* BOTTOM */
770
771 if ( layer_index != first_layer(dimensions) )
772 {
774
775 (dimensions, layer_index - 1, row_index, column_index) ;
776
777 conductance = PARALLEL
778 (
779 get_conductance_bottom (thermal_grid, dimensions, layer_index , row_index, column_index),
780 get_conductance_top (thermal_grid, dimensions, layer_index - 1, row_index, column_index)
781 ) ;
782
783 *sysmatrix.Values++ = -conductance ;
784 diagonal_value += conductance ;
785
786 (*sysmatrix.ColumnPointers)++ ;
787
788#ifdef PRINT_SYSTEM_MATRIX
789 fprintf (stderr,
790 " bottom \t%d\t% .4e = % .4e (B) || % .4e (T)\n",
791 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1),
792 get_conductance_bottom (thermal_grid, dimensions, layer_index , row_index, column_index),
793 get_conductance_top (thermal_grid, dimensions, layer_index - 1, row_index, column_index)) ;
794#endif
795 }
796
797 /* SOUTH */
798
799 if ( row_index != first_row (dimensions) )
800 {
802
803 (dimensions, layer_index, row_index - 1, column_index) ;
804
805 *sysmatrix.Values++ = get_conductance_north /* == C */
806
807 (thermal_grid, dimensions, layer_index, row_index, column_index) ;
808
809 (*sysmatrix.ColumnPointers)++ ;
810
811#ifdef PRINT_SYSTEM_MATRIX
812 fprintf (stderr,
813 " south \t%d\t% .4e (N)\n",
814 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1)) ;
815#endif
816 }
817
818 /* WEST */
819
820 if ( column_index != first_column (dimensions) )
821 {
823
824 (dimensions, layer_index, row_index, column_index - 1) ;
825
826 conductance = PARALLEL
827 (
828 get_conductance_west (thermal_grid, dimensions, layer_index, row_index, column_index ),
829 get_conductance_east (thermal_grid, dimensions, layer_index, row_index, column_index - 1)
830 ) ;
831
832 *sysmatrix.Values++ = -conductance ;
833 diagonal_value += conductance ;
834
835 (*sysmatrix.ColumnPointers)++ ;
836
837#ifdef PRINT_SYSTEM_MATRIX
838 fprintf (stderr,
839 " west \t%d\t% .4e = % .4e (W) || % .4e (E)\n",
840 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1),
841 get_conductance_west (thermal_grid, dimensions, layer_index, row_index, column_index ),
842 get_conductance_east (thermal_grid, dimensions, layer_index, row_index, column_index - 1));
843#endif
844 }
845
846 /* DIAGONAL */
847
849
850 (dimensions, layer_index, row_index, column_index) ;
851
852 *sysmatrix.Values = 0.0 ;
853
855 {
856 *sysmatrix.Values = get_capacity
857
858 (thermal_grid, dimensions, layer_index, row_index, column_index) ;
859
860 *sysmatrix.Values /= analysis->StepTime ;
861 }
862
863 diagonal_pointer = sysmatrix.Values++ ;
864
865 (*sysmatrix.ColumnPointers)++ ;
866
867#ifdef PRINT_SYSTEM_MATRIX
868 fprintf (stderr, " diagonal\t%d\t", *(sysmatrix.RowIndices-1)) ;
869 fgetpos (stderr, &diag_fposition) ;
870 fprintf (stderr, " ( + % .4e [capacity] )\n", *(sysmatrix.Values-1)) ;
871#endif
872
873 /* EAST */
874
875 if ( column_index != last_column (dimensions) )
876 {
878
879 (dimensions, layer_index, row_index, column_index + 1) ;
880
881 conductance = PARALLEL
882 (
883 get_conductance_east (thermal_grid, dimensions, layer_index, row_index, column_index ),
884 get_conductance_west (thermal_grid, dimensions, layer_index, row_index, column_index + 1)
885 ) ;
886
887 *sysmatrix.Values++ = -conductance ;
888 diagonal_value += conductance ;
889
890 (*sysmatrix.ColumnPointers)++ ;
891
892#ifdef PRINT_SYSTEM_MATRIX
893 fprintf (stderr,
894 " east \t%d\t% .4e = % .4e (E) || % .4e (W)\n",
895 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1),
896 get_conductance_east (thermal_grid, dimensions, layer_index, row_index, column_index ),
897 get_conductance_west (thermal_grid, dimensions, layer_index, row_index, column_index + 1));
898#endif
899 }
900
901 /* NORTH */
902
903 if ( row_index != last_row(dimensions) )
904 {
906
907 (dimensions, layer_index, row_index + 1, column_index) ;
908
909 *sysmatrix.Values++ = get_conductance_south /* == - C */
910
911 (thermal_grid, dimensions, layer_index, row_index, column_index) ;
912
913 (*sysmatrix.ColumnPointers)++ ;
914
915#ifdef PRINT_SYSTEM_MATRIX
916 fprintf (stderr,
917 " north \t%d\t% .4e (S)\n",
918 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1)) ;
919#endif
920 }
921
922 /* TOP */
923
924 if ( layer_index != last_layer (dimensions) )
925 {
927
928 (dimensions, layer_index + 1, row_index, column_index) ;
929
930 conductance = PARALLEL
931 (
932 get_conductance_top (thermal_grid, dimensions, layer_index , row_index, column_index),
933 get_conductance_bottom (thermal_grid, dimensions, layer_index + 1, row_index, column_index)
934 ) ;
935
936 *sysmatrix.Values++ = -conductance ;
937 diagonal_value += conductance ;
938
939 (*sysmatrix.ColumnPointers)++ ;
940
941#ifdef PRINT_SYSTEM_MATRIX
942 fprintf (stderr,
943 " top \t%d\t% .4e = % .4e (T) || % .4e (B)\n",
944 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1),
945 get_conductance_top (thermal_grid, dimensions, layer_index , row_index, column_index),
946 get_conductance_bottom (thermal_grid, dimensions, layer_index + 1, row_index, column_index)) ;
947#endif
948 }
949
950 /* DIAGONAL ELEMENT */
951
952 *diagonal_pointer += diagonal_value ;
953
954 if (row_index == first_row (dimensions) || row_index == last_row (dimensions))
955
956 *diagonal_pointer += get_conductance_north /* == C */
957
958 (thermal_grid, dimensions, layer_index, row_index, column_index) ;
959
960#ifdef PRINT_SYSTEM_MATRIX
961 fgetpos (stderr, &last_fpos) ;
962 fsetpos (stderr, &diag_fposition) ;
963 fprintf (stderr, "% .4e", *diagonal_pointer) ;
964 fsetpos (stderr, &last_fpos) ;
965
966 fprintf (stderr, " %d\n", *sysmatrix.ColumnPointers) ;
967#endif
968
969 sysmatrix.ColumnPointers++ ;
970
971 return sysmatrix ;
972}
973
974/******************************************************************************/
975
976static SystemMatrix_t add_liquid_column_2rm
977(
978 SystemMatrix_t sysmatrix,
979 ThermalGrid_t *thermal_grid,
980 Analysis_t *analysis,
981 Dimensions_t *dimensions,
982 CellIndex_t layer_index,
983 CellIndex_t row_index,
984 CellIndex_t column_index
985)
986{
987 Conductance_t conductance = 0.0 ;
988 SystemMatrixCoeff_t diagonal_value = 0.0 ;
989 SystemMatrixCoeff_t *diagonal_pointer = NULL ;
990
991#ifdef PRINT_SYSTEM_MATRIX
992 fpos_t diag_fposition, last_fpos ;
993 fprintf (stderr,
994 "add_liquid_column_2rm l %2d r %4d c %4d [%7d]\n",
995 layer_index, row_index, column_index,
996 get_cell_offset_in_stack (dimensions, layer_index, row_index, column_index)) ;
997#endif
998
999 *sysmatrix.ColumnPointers = *(sysmatrix.ColumnPointers - 1) ;
1000
1001 /* BOTTOM */
1002
1003 if ( layer_index != first_layer (dimensions) ) // FIXME
1004 {
1006
1007 (dimensions, layer_index - 2, row_index, column_index) ;
1008
1009 conductance = get_conductance_bottom
1010
1011 (thermal_grid, dimensions, layer_index, row_index, column_index) ;
1012
1013 *sysmatrix.Values++ = -conductance ;
1014 diagonal_value += conductance ;
1015
1016 (*sysmatrix.ColumnPointers)++ ;
1017
1018#ifdef PRINT_SYSTEM_MATRIX
1019 fprintf (stderr,
1020 " bottom \t%d\t% .4e (B)\n",
1021 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1)) ;
1022#endif
1023 }
1024
1025 /* SOUTH */
1026
1027 if ( row_index != first_row (dimensions) )
1028 {
1030
1031 (dimensions, layer_index, row_index - 1, column_index) ;
1032
1033 *sysmatrix.Values++ = get_conductance_north /* == C */
1034
1035 (thermal_grid, dimensions, layer_index, row_index, column_index) ;
1036
1037 (*sysmatrix.ColumnPointers)++ ;
1038
1039#ifdef PRINT_SYSTEM_MATRIX
1040 fprintf (stderr,
1041 " south \t%d\t% .4e (N)\n",
1042 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1)) ;
1043#endif
1044 }
1045
1046 /* DIAGONAL */
1047
1049
1050 (dimensions, layer_index, row_index, column_index) ;
1051
1052 *sysmatrix.Values = 0.0 ;
1053
1055 {
1056 *sysmatrix.Values = get_capacity
1057
1058 (thermal_grid, dimensions, layer_index, row_index, column_index) ;
1059
1060 *sysmatrix.Values /= analysis->StepTime ;
1061 }
1062
1063 diagonal_pointer = sysmatrix.Values++ ;
1064
1065 (*sysmatrix.ColumnPointers)++ ;
1066
1067#ifdef PRINT_SYSTEM_MATRIX
1068 fprintf (stderr, " diagonal\t%d\t", *(sysmatrix.RowIndices-1)) ;
1069 fgetpos (stderr, &diag_fposition) ;
1070 fprintf (stderr, " ( + % .4e [capacity] )\n", *(sysmatrix.Values-1)) ;
1071#endif
1072
1073 /* NORTH */
1074
1075 if ( row_index != last_row(dimensions) )
1076 {
1078
1079 (dimensions, layer_index, row_index + 1, column_index) ;
1080
1081 *sysmatrix.Values++ = get_conductance_south /* == -C */
1082
1083 (thermal_grid, dimensions, layer_index, row_index, column_index) ;
1084
1085 (*sysmatrix.ColumnPointers)++ ;
1086
1087#ifdef PRINT_SYSTEM_MATRIX
1088 fprintf (stderr,
1089 " north \t%d\t% .4e (S)\n",
1090 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1)) ;
1091#endif
1092 }
1093
1094 /* TOP */
1095
1096 if ( layer_index != last_layer (dimensions) )
1097 {
1099
1100 (dimensions, layer_index + 1, row_index, column_index) ;
1101
1102 conductance = get_conductance_top
1103
1104 (thermal_grid, dimensions, layer_index, row_index, column_index) ;
1105
1106 *sysmatrix.Values++ = -conductance ;
1107 diagonal_value += conductance ;
1108
1109 (*sysmatrix.ColumnPointers)++ ;
1110
1111#ifdef PRINT_SYSTEM_MATRIX
1112 fprintf (stderr,
1113 " top \t%d\t% .4e (T)\n",
1114 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1)) ;
1115#endif
1116 }
1117
1118 /* DIAGONAL ELEMENT */
1119
1120 *diagonal_pointer += diagonal_value ;
1121
1122 if (row_index == first_row (dimensions) || row_index == last_row (dimensions))
1123
1124 *diagonal_pointer += get_conductance_north /* == C */
1125
1126 (thermal_grid, dimensions, layer_index, row_index, column_index) ;
1127
1128#ifdef PRINT_SYSTEM_MATRIX
1129 fgetpos (stderr, &last_fpos) ;
1130 fsetpos (stderr, &diag_fposition) ;
1131 fprintf (stderr, "% .4e", *diagonal_pointer) ;
1132 fsetpos (stderr, &last_fpos) ;
1133
1134 fprintf (stderr, " %d\n", *sysmatrix.ColumnPointers) ;
1135#endif
1136
1137 sysmatrix.ColumnPointers++ ;
1138
1139 return sysmatrix ;
1140}
1141
1142/******************************************************************************/
1143
1144static SystemMatrix_t add_bottom_wall_column_2rm
1145(
1146 SystemMatrix_t sysmatrix,
1147 ThermalGrid_t *thermal_grid,
1148 Analysis_t *analysis,
1149 Dimensions_t *dimensions,
1150 CellIndex_t layer_index,
1151 CellIndex_t row_index,
1152 CellIndex_t column_index
1153)
1154{
1155 Conductance_t conductance = 0.0 ;
1156 SystemMatrixCoeff_t diagonal_value = 0.0 ;
1157 SystemMatrixCoeff_t *diagonal_pointer = NULL ;
1158
1159#ifdef PRINT_SYSTEM_MATRIX
1160 fpos_t diag_fposition, last_fpos ;
1161 fprintf (stderr,
1162 "add_bottom_wall_column_2rm l %2d r %4d c %4d [%7d]\n",
1163 layer_index, row_index, column_index,
1164 get_cell_offset_in_stack (dimensions, layer_index, row_index, column_index)) ;
1165#endif
1166
1167 *sysmatrix.ColumnPointers = *(sysmatrix.ColumnPointers - 1) ;
1168
1169 /* BOTTOM connected to Silicon */
1170
1171 if ( layer_index != first_layer (dimensions) )
1172 {
1174
1175 (dimensions, layer_index - 1, row_index, column_index) ;
1176
1177 conductance = get_conductance_top
1178
1179 (thermal_grid, dimensions, layer_index - 1, row_index, column_index) ;
1180
1181 *sysmatrix.Values++ = -conductance ;
1182 diagonal_value += conductance ;
1183
1184 (*sysmatrix.ColumnPointers)++ ;
1185
1186#ifdef PRINT_SYSTEM_MATRIX
1187 fprintf (stderr,
1188 " Bottom connected to Silicon \t%d\t% .4e\n",
1189 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1)) ;
1190#endif
1191 }
1192
1193 /* DIAGONAL */
1194
1196
1197 (dimensions, layer_index, row_index, column_index) ;
1198
1199 *sysmatrix.Values = 0.0 ;
1200
1202 {
1203 *sysmatrix.Values = get_capacity
1204
1205 (thermal_grid, dimensions, layer_index, row_index, column_index) ;
1206
1207 *sysmatrix.Values /= analysis->StepTime ;
1208 }
1209
1210 diagonal_pointer = sysmatrix.Values++ ;
1211
1212 (*sysmatrix.ColumnPointers)++ ;
1213
1214#ifdef PRINT_SYSTEM_MATRIX
1215 fprintf (stderr, " diagonal\t%d\t", *(sysmatrix.RowIndices-1)) ;
1216 fgetpos (stderr, &diag_fposition) ;
1217 fprintf (stderr, " ( + % .4e [capacity] )\n", *(sysmatrix.Values-1)) ;
1218#endif
1219
1220 /* Top connected to Virtual Wall */
1221
1222 if ( layer_index != last_layer (dimensions) )
1223 {
1225
1226 (dimensions, layer_index + 1, row_index, column_index) ;
1227
1228 conductance = get_conductance_top
1229
1230 (thermal_grid, dimensions, layer_index + 1, row_index, column_index) ;
1231
1232 *sysmatrix.Values++ = -conductance ;
1233 diagonal_value += conductance ;
1234
1235 (*sysmatrix.ColumnPointers)++ ;
1236
1237#ifdef PRINT_SYSTEM_MATRIX
1238 fprintf (stderr,
1239 " Top connected to Channel \t%d\t% .4e\n",
1240 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1)) ;
1241#endif
1242 }
1243
1244 /* Top connected to Channel */
1245
1246 if ( layer_index != last_layer (dimensions) )
1247 {
1249
1250 (dimensions, layer_index + 2, row_index, column_index) ;
1251
1252 conductance = get_conductance_bottom
1253
1254 (thermal_grid, dimensions, layer_index + 2, row_index, column_index) ;
1255
1256 *sysmatrix.Values++ = -conductance ;
1257 diagonal_value += conductance ;
1258
1259 (*sysmatrix.ColumnPointers)++ ;
1260
1261#ifdef PRINT_SYSTEM_MATRIX
1262 fprintf (stderr,
1263 " Top connceted to Virtual Wall \t%d\t% .4e\n",
1264 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1)) ;
1265#endif
1266 }
1267
1268 /* DIAGONAL ELEMENT */
1269
1270 *diagonal_pointer += diagonal_value ;
1271
1272#ifdef PRINT_SYSTEM_MATRIX
1273 fgetpos (stderr, &last_fpos) ;
1274 fsetpos (stderr, &diag_fposition) ;
1275 fprintf (stderr, "% .4e", *diagonal_pointer) ;
1276 fsetpos (stderr, &last_fpos) ;
1277
1278 fprintf (stderr, " %d\n", *sysmatrix.ColumnPointers) ;
1279#endif
1280
1281 sysmatrix.ColumnPointers++ ;
1282
1283 return sysmatrix ;
1284}
1285
1286/******************************************************************************/
1287
1288static SystemMatrix_t add_top_wall_column_2rm
1289(
1290 SystemMatrix_t sysmatrix,
1291 ThermalGrid_t *thermal_grid,
1292 Analysis_t *analysis,
1293 Dimensions_t *dimensions,
1294 CellIndex_t layer_index,
1295 CellIndex_t row_index,
1296 CellIndex_t column_index
1297)
1298{
1299 Conductance_t conductance = 0.0 ;
1300 SystemMatrixCoeff_t diagonal_value = 0.0 ;
1301 SystemMatrixCoeff_t *diagonal_pointer = NULL ;
1302
1303#ifdef PRINT_SYSTEM_MATRIX
1304 fpos_t diag_fposition, last_fpos ;
1305 fprintf (stderr,
1306 "add_top_wall_column_2rm l %2d r %4d c %4d [%7d]\n",
1307 layer_index, row_index, column_index,
1308 get_cell_offset_in_stack (dimensions, layer_index, row_index, column_index)) ;
1309#endif
1310
1311 *sysmatrix.ColumnPointers = *(sysmatrix.ColumnPointers - 1) ;
1312
1313 /* BOTTOM connected to Virtual Wall */
1314
1315 if ( layer_index != first_layer (dimensions) )
1316 {
1318
1319 (dimensions, layer_index - 2, row_index, column_index) ;
1320
1321 conductance = get_conductance_top
1322
1323 (thermal_grid, dimensions, layer_index - 2, row_index, column_index) ;
1324
1325 *sysmatrix.Values++ = -conductance ;
1326 diagonal_value += conductance ;
1327
1328 (*sysmatrix.ColumnPointers)++ ;
1329
1330#ifdef PRINT_SYSTEM_MATRIX
1331 fprintf (stderr,
1332 " Bottom connected to Channel \t%d\t% .4e\n",
1333 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1)) ;
1334#endif
1335 }
1336
1337 /* BOTTOM connected to Channel */
1338
1339 if ( layer_index != first_layer (dimensions) )
1340 {
1342
1343 (dimensions, layer_index - 1, row_index, column_index) ;
1344
1345 conductance = get_conductance_top
1346
1347 (thermal_grid, dimensions, layer_index - 1, row_index, column_index) ;
1348
1349 *sysmatrix.Values++ = -conductance ;
1350 diagonal_value += conductance ;
1351
1352 (*sysmatrix.ColumnPointers)++ ;
1353
1354#ifdef PRINT_SYSTEM_MATRIX
1355 fprintf (stderr,
1356 " Bottom connected to Virtual Wall \t%d\t% .4e\n",
1357 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1)) ;
1358#endif
1359 }
1360
1361 /* DIAGONAL */
1362
1364
1365 (dimensions, layer_index, row_index, column_index) ;
1366
1367 *sysmatrix.Values = 0.0 ;
1368
1370 {
1371 *sysmatrix.Values = get_capacity
1372
1373 (thermal_grid, dimensions, layer_index, row_index, column_index) ;
1374
1375 *sysmatrix.Values /= analysis->StepTime ;
1376 }
1377
1378 diagonal_pointer = sysmatrix.Values++ ;
1379
1380 (*sysmatrix.ColumnPointers)++ ;
1381
1382#ifdef PRINT_SYSTEM_MATRIX
1383 fprintf (stderr, " diagonal\t%d\t", *(sysmatrix.RowIndices-1)) ;
1384 fgetpos (stderr, &diag_fposition) ;
1385 fprintf (stderr, " ( + % .4e [capacity] )\n", *(sysmatrix.Values-1)) ;
1386#endif
1387
1388 /* Top connected to Silicon */
1389
1390 if ( layer_index != last_layer (dimensions) )
1391 {
1393
1394 (dimensions, layer_index + 1, row_index, column_index) ;
1395
1396 conductance = get_conductance_bottom
1397
1398 (thermal_grid, dimensions, layer_index + 1, row_index, column_index) ;
1399
1400 *sysmatrix.Values++ = -conductance ;
1401 diagonal_value += conductance ;
1402
1403 (*sysmatrix.ColumnPointers)++ ;
1404
1405#ifdef PRINT_SYSTEM_MATRIX
1406 fprintf (stderr,
1407 " Top connected to Silicon \t%d\t% .4e\n",
1408 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1)) ;
1409#endif
1410 }
1411
1412 /* DIAGONAL ELEMENT */
1413
1414 *diagonal_pointer += diagonal_value ;
1415
1416#ifdef PRINT_SYSTEM_MATRIX
1417 fgetpos (stderr, &last_fpos) ;
1418 fsetpos (stderr, &diag_fposition) ;
1419 fprintf (stderr, "% .4e", *diagonal_pointer) ;
1420 fsetpos (stderr, &last_fpos) ;
1421
1422 fprintf (stderr, " %d\n", *sysmatrix.ColumnPointers) ;
1423#endif
1424
1425 sysmatrix.ColumnPointers++ ;
1426
1427 return sysmatrix ;
1428}
1429
1430
1431/******************************************************************************/
1432
1433static SystemMatrix_t add_virtual_wall_column_2rm
1434(
1435 SystemMatrix_t sysmatrix,
1436 ThermalGrid_t *thermal_grid,
1437 Analysis_t *analysis,
1438 Dimensions_t *dimensions,
1439 ChannelModel_t channel_model,
1440 CellIndex_t layer_index,
1441 CellIndex_t row_index,
1442 CellIndex_t column_index
1443)
1444{
1445 Conductance_t conductance = 0.0 ;
1446 SystemMatrixCoeff_t diagonal_value = 0.0 ;
1447 SystemMatrixCoeff_t *diagonal_pointer = NULL ;
1448
1449#ifdef PRINT_SYSTEM_MATRIX
1450 fpos_t diag_fposition, last_fpos ;
1451 fprintf (stderr,
1452 "add_virtual_wall_column l %2d r %4d c %4d [%7d]\n",
1453 layer_index, row_index, column_index,
1454 get_cell_offset_in_stack (dimensions, layer_index, row_index, column_index)) ;
1455#endif
1456
1457 *sysmatrix.ColumnPointers = *(sysmatrix.ColumnPointers - 1) ;
1458
1459 /* BOTTOM */
1460
1461 if ( layer_index != first_layer (dimensions) )
1462 {
1464
1465 (dimensions, layer_index - 1, row_index, column_index) ;
1466
1467 conductance = get_conductance_bottom
1468
1469 (thermal_grid, dimensions, layer_index, row_index, column_index) ;
1470
1471 *sysmatrix.Values++ = -conductance ;
1472 diagonal_value += conductance ;
1473
1474 (*sysmatrix.ColumnPointers)++ ;
1475
1476#ifdef PRINT_SYSTEM_MATRIX
1477 fprintf (stderr,
1478 " bottom \t%d\t% .4e\n",
1479 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1)) ;
1480#endif
1481 }
1482
1483 /* SOUTH */
1484
1485 if ( channel_model == TDICE_CHANNEL_MODEL_MC_2RM
1486 && row_index != first_row (dimensions))
1487 {
1489
1490 (dimensions, layer_index, row_index - 1, column_index) ;
1491
1492 conductance = PARALLEL
1493 (
1494 get_conductance_south (thermal_grid, dimensions, layer_index, row_index, column_index),
1495 get_conductance_north (thermal_grid, dimensions, layer_index, row_index, column_index)
1496 ) ;
1497
1498 *sysmatrix.Values++ = -conductance ;
1499 diagonal_value += conductance ;
1500
1501 (*sysmatrix.ColumnPointers)++ ;
1502
1503#ifdef PRINT_SYSTEM_MATRIX
1504 fprintf (stderr,
1505 " south \t%d\t% .4e\n", *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1)) ;
1506#endif
1507 }
1508
1509 /* DIAGONAL */
1510
1512
1513 (dimensions, layer_index, row_index, column_index) ;
1514
1515 *sysmatrix.Values = 0.0 ;
1516
1518 {
1519 *sysmatrix.Values = get_capacity
1520
1521 (thermal_grid, dimensions, layer_index, row_index, column_index) ;
1522
1523 *sysmatrix.Values /= analysis->StepTime ;
1524 }
1525
1526 diagonal_pointer = sysmatrix.Values++ ;
1527
1528 (*sysmatrix.ColumnPointers)++ ;
1529
1530#ifdef PRINT_SYSTEM_MATRIX
1531 fprintf (stderr, " diagonal\t%d\t", *(sysmatrix.RowIndices-1)) ;
1532 fgetpos (stderr, &diag_fposition) ;
1533 fprintf (stderr, " ( + % .4e [capacity] )\n", *(sysmatrix.Values-1)) ;
1534#endif
1535
1536 /* NORTH */
1537
1538 if ( channel_model == TDICE_CHANNEL_MODEL_MC_2RM
1539 && row_index != last_row (dimensions))
1540 {
1542
1543 (dimensions, layer_index, row_index + 1, column_index) ;
1544
1545 conductance = PARALLEL
1546 (
1547 get_conductance_north (thermal_grid, dimensions, layer_index, row_index, column_index),
1548 get_conductance_south (thermal_grid, dimensions, layer_index, row_index, column_index)
1549 ) ;
1550
1551 *sysmatrix.Values++ = -conductance ;
1552 diagonal_value += conductance ;
1553
1554 (*sysmatrix.ColumnPointers)++ ;
1555
1556#ifdef PRINT_SYSTEM_MATRIX
1557 fprintf (stderr,
1558 " north \t%d\t% .4e\n",
1559 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1)) ;
1560#endif
1561 }
1562
1563 /* TOP */
1564
1565 if ( layer_index != last_layer (dimensions) )
1566 {
1568
1569 (dimensions, layer_index + 2, row_index, column_index) ;
1570
1571 conductance = get_conductance_top
1572
1573 (thermal_grid, dimensions, layer_index, row_index, column_index) ;
1574
1575 *sysmatrix.Values++ = -conductance ;
1576 diagonal_value += conductance ;
1577
1578 (*sysmatrix.ColumnPointers)++ ;
1579
1580#ifdef PRINT_SYSTEM_MATRIX
1581 fprintf (stderr,
1582 " top \t%d\t% .4e\n",
1583 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1)) ;
1584#endif
1585 }
1586
1587 /* DIAGONAL ELEMENT */
1588
1589 *diagonal_pointer += diagonal_value ;
1590
1591#ifdef PRINT_SYSTEM_MATRIX
1592 fgetpos (stderr, &last_fpos) ;
1593 fsetpos (stderr, &diag_fposition) ;
1594 fprintf (stderr, "% .4e", *diagonal_pointer) ;
1595 fsetpos (stderr, &last_fpos) ;
1596
1597 fprintf (stderr, " %d\n", *sysmatrix.ColumnPointers) ;
1598#endif
1599
1600 sysmatrix.ColumnPointers++ ;
1601
1602 return sysmatrix ;
1603}
1604
1605static SystemMatrix_t add_spreader_column
1606(
1607 SystemMatrix_t sysmatrix,
1608 ThermalGrid_t *thermal_grid,
1609 Analysis_t *analysis,
1610 Dimensions_t *dimensions,
1611 CellIndex_t row_index,
1612 CellIndex_t column_index
1613)
1614{
1615 HeatSink_t *sink = thermal_grid->TopHeatSink;
1616 Conductance_t conductance = 0.0 ;
1617 SystemMatrixCoeff_t diagonal_value = 0.0 ;
1618 SystemMatrixCoeff_t *diagonal_pointer = NULL ;
1619
1620 Conductance_t g_bottom, g_top, g_north, g_south, g_east, g_west ;
1621
1622#ifdef PRINT_SYSTEM_MATRIX
1623 fpos_t diag_fposition, last_fpos ;
1624
1625 fprintf (stderr,
1626 "add_spreader_column r %4d c %4d [%7d]\n",
1627 row_index, column_index,
1628 get_spreader_cell_offset (dimensions, sink, row_index, column_index)) ;
1629#endif
1630
1631 *sysmatrix.ColumnPointers = *(sysmatrix.ColumnPointers - 1) ;
1632
1633 /********************************* BOTTOM *********************************/
1634
1635 if (has_layer_underneath(dimensions, sink, row_index, column_index) == false)
1636
1637 goto skip_bottom ;
1638
1639 // Connection between the layer submatrix and the spreader submatrix
1641 (dimensions, sink, last_layer(dimensions), row_index, column_index) ;
1642
1643 g_bottom = get_spreader_conductance_top_bottom(sink);
1644
1645 g_top = get_conductance_top
1646 (thermal_grid, dimensions, last_layer(dimensions),
1647 row_index - sink->NumRowsBorder, column_index - sink->NumColumnsBorder) ;
1648
1649 conductance = PARALLEL (g_bottom, g_top) ;
1650
1651 *sysmatrix.Values++ = -conductance ;
1652 diagonal_value += conductance ;
1653
1654 (*sysmatrix.ColumnPointers)++ ;
1655
1656#ifdef PRINT_SYSTEM_MATRIX
1657 fprintf (stderr,
1658 " bottom \t%d\t% .4e = % .4e (B) || % .4e (T)\n",
1659 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1), g_bottom, g_top) ;
1660#endif
1661
1662skip_bottom :
1663
1664 /********************************* SOUTH **********************************/
1665
1666 if (row_index == 0) goto skip_south ;
1667
1669 (dimensions, sink, row_index - 1, column_index) ;
1670
1671 g_south = g_north = get_spreader_conductance_north_south(sink);
1672
1673 conductance = PARALLEL (g_south, g_north) ;
1674
1675 *sysmatrix.Values++ = -conductance ;
1676 diagonal_value += conductance ;
1677
1678 (*sysmatrix.ColumnPointers)++ ;
1679
1680#ifdef PRINT_SYSTEM_MATRIX
1681 fprintf (stderr,
1682 " south \t%d\t% .4e = % .4e (S) || % .4e (N)\n",
1683 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1), g_south, g_north) ;
1684#endif
1685
1686skip_south :
1687
1688 /********************************* WEST ***********************************/
1689
1690 if (column_index == 0) goto skip_west ;
1691
1693 (dimensions, sink, row_index, column_index - 1) ;
1694
1695 g_west = g_east = get_spreader_conductance_east_west(sink);
1696
1697 conductance = PARALLEL (g_west, g_east) ;
1698
1699 *sysmatrix.Values++ = -conductance ;
1700 diagonal_value += conductance ;
1701
1702 (*sysmatrix.ColumnPointers)++ ;
1703
1704#ifdef PRINT_SYSTEM_MATRIX
1705 fprintf (stderr,
1706 " west \t%d\t% .4e = % .4e (W) || % .4e (E)\n",
1707 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1), g_west, g_east) ;
1708#endif
1709
1710skip_west :
1711
1712 /********************************* DIAGONAL *******************************/
1713
1715 (dimensions, sink, row_index, column_index) ;
1716
1717 *sysmatrix.Values = 0.0 ;
1718
1720 {
1721 *sysmatrix.Values = get_spreader_capacity(sink) / analysis->StepTime;
1722 }
1723
1724 diagonal_pointer = sysmatrix.Values++ ;
1725
1726 (*sysmatrix.ColumnPointers)++ ;
1727
1728#ifdef PRINT_SYSTEM_MATRIX
1729 fprintf (stderr, " diagonal\t%d\t", *(sysmatrix.RowIndices-1)) ;
1730 fgetpos (stderr, &diag_fposition) ;
1731 fprintf (stderr, " ( + % .4e [capacity] )\n", *(sysmatrix.Values-1)) ;
1732#endif
1733
1734 /********************************* EAST ***********************************/
1735
1736 if (column_index == sink->NColumns - 1) goto skip_east ;
1737
1739 (dimensions, sink, row_index, column_index + 1) ;
1740
1741 g_east = g_west = get_spreader_conductance_east_west(sink);
1742
1743 conductance = PARALLEL (g_east, g_west) ;
1744
1745 *sysmatrix.Values++ = -conductance ;
1746 diagonal_value += conductance ;
1747
1748 (*sysmatrix.ColumnPointers)++ ;
1749
1750#ifdef PRINT_SYSTEM_MATRIX
1751 fprintf (stderr,
1752 " east \t%d\t% .4e = % .4e (E) || % .4e (W)\n",
1753 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1), g_east, g_west) ;
1754#endif
1755
1756skip_east :
1757
1758 /********************************* NORTH **********************************/
1759
1760 if (row_index == sink->NRows - 1) goto skip_north ;
1761
1763 (dimensions, sink, row_index + 1, column_index) ;
1764
1765 g_north = g_south = get_spreader_conductance_north_south(sink);
1766
1767 conductance = PARALLEL (g_north, g_south) ;
1768
1769 *sysmatrix.Values++ = -conductance ;
1770 diagonal_value += conductance ;
1771
1772 (*sysmatrix.ColumnPointers)++ ;
1773
1774#ifdef PRINT_SYSTEM_MATRIX
1775 fprintf (stderr,
1776 " north \t%d\t% .4e = % .4e (N) || % .4e (S)\n",
1777 *(sysmatrix.RowIndices-1), *(sysmatrix.Values-1), g_north, g_south) ;
1778#endif
1779
1780skip_north :
1781
1782 /********************************* TOP ************************************/
1783
1784 // The top of the spreader is connected with the pluggable heat sink,
1785 // whose state variables are not part of the system matrix.
1786 // Thus, no other nonzero element appears in the system matrix.
1787
1788 /************************** DIAGONAL ELEMENT ******************************/
1789
1790 *diagonal_pointer += diagonal_value ;
1791
1792#ifdef PRINT_SYSTEM_MATRIX
1793 fgetpos (stderr, &last_fpos) ;
1794 fsetpos (stderr, &diag_fposition) ;
1795 fprintf (stderr, "% .4e", *diagonal_pointer) ;
1796 fsetpos (stderr, &last_fpos) ;
1797
1798 fprintf (stderr, " %d\n", *sysmatrix.ColumnPointers) ;
1799#endif
1800
1801 sysmatrix.ColumnPointers++ ;
1802
1803 return sysmatrix ;
1804}
1805
1806/******************************************************************************/
1807
1809(
1810 SystemMatrix_t *sysmatrix,
1811 ThermalGrid_t *thermal_grid,
1812 Analysis_t *analysis,
1813 Dimensions_t *dimensions
1814)
1815{
1816// #define PRINT_SYSTEM_MATRIX 1
1817#ifdef PRINT_SYSTEM_MATRIX
1818 fprintf (stderr,
1819 "fill_system_matrix ( l %d r %d c %d )\n",
1820 get_number_of_layers (dimensions),
1821 get_number_of_rows (dimensions),
1822 get_number_of_columns (dimensions)) ;
1823#endif
1824
1825 SystemMatrix_t tmp_matrix ;
1826
1827 tmp_matrix.Size = sysmatrix->Size ;
1828 tmp_matrix.NNz = sysmatrix->NNz ;
1829
1830 tmp_matrix.ColumnPointers = sysmatrix->ColumnPointers ;
1831 tmp_matrix.RowIndices = sysmatrix->RowIndices ;
1832 tmp_matrix.Values = sysmatrix->Values ;
1833
1834 tmp_matrix.ColumnPointers[0] = 0u ;
1835
1836 tmp_matrix.ColumnPointers++ ;
1837
1838 if(dimensions->NonUniform==1)
1839 {
1840 tmp_matrix = add_solid_column_non_uniform(tmp_matrix, thermal_grid, analysis, dimensions) ;
1841 }
1842 else
1843 {
1844 CellIndex_t lindex ;
1845
1846 for (lindex = 0u ; lindex != thermal_grid->NLayers ; lindex++)
1847 {
1848 switch (thermal_grid->LayersTypeProfile [lindex])
1849 {
1850 case TDICE_LAYER_SOLID :
1851 case TDICE_LAYER_SOURCE :
1858 {
1859 CellIndex_t row ;
1860 CellIndex_t column ;
1861
1862 for (row = first_row (dimensions) ; row <= last_row (dimensions) ; row++)
1863 {
1864 for (column = first_column (dimensions) ; column <= last_column (dimensions) ; column++)
1865 {
1866 tmp_matrix = add_solid_column
1867
1868 (tmp_matrix, thermal_grid, analysis, dimensions,
1869 lindex, row, column) ;
1870
1871 } // FOR_EVERY_COLUMN
1872 } // FOR_EVERY_ROW
1873
1874 break ;
1875 }
1877 {
1878 CellIndex_t row ;
1879 CellIndex_t column ;
1880
1881 for (row = first_row (dimensions) ; row <= last_row (dimensions) ; row++)
1882 {
1883 for (column = first_column (dimensions) ; column <= last_column (dimensions) ; column++)
1884 {
1885 if (IS_CHANNEL_COLUMN (thermal_grid->Channel->ChannelModel, column) == true)
1886
1887 tmp_matrix = add_liquid_column_4rm
1888
1889 (tmp_matrix, thermal_grid, analysis, dimensions,
1890 lindex, row, column) ;
1891
1892 else
1893
1894 tmp_matrix = add_solid_column
1895
1896 (tmp_matrix, thermal_grid, analysis, dimensions,
1897 lindex, row, column) ;
1898
1899 } // FOR_EVERY_COLUMN
1900 } // FOR_EVERY_ROW
1901
1902 break ;
1903 }
1907 {
1908 CellIndex_t row ;
1909 CellIndex_t column ;
1910
1911 for (row = first_row (dimensions) ; row <= last_row (dimensions) ; row++)
1912 {
1913 for (column = first_column (dimensions) ; column <= last_column (dimensions) ; column++)
1914 {
1915 tmp_matrix = add_liquid_column_2rm
1916
1917 (tmp_matrix, thermal_grid, analysis, dimensions,
1918 lindex, row, column) ;
1919
1920 } // FOR_EVERY_COLUMN
1921 } // FOR_EVERY_ROW
1922
1923 break ;
1924 }
1927 {
1928 CellIndex_t row ;
1929 CellIndex_t column ;
1930
1931 for (row = first_row (dimensions) ; row <= last_row (dimensions) ; row++)
1932 {
1933 for (column = first_column (dimensions) ; column <= last_column (dimensions) ; column++)
1934 {
1935 tmp_matrix = add_virtual_wall_column_2rm
1936
1937 (tmp_matrix, thermal_grid, analysis, dimensions,
1938 thermal_grid->Channel->ChannelModel,
1939 lindex, row, column) ;
1940
1941 } // FOR_EVERY_COLUMN
1942 } // FOR_EVERY_ROW
1943
1944 break ;
1945 }
1947 {
1948 CellIndex_t row ;
1949 CellIndex_t column ;
1950
1951 for (row = first_row (dimensions) ; row <= last_row (dimensions) ; row++)
1952 {
1953 for (column = first_column (dimensions) ; column <= last_column (dimensions) ; column++)
1954 {
1955 tmp_matrix = add_top_wall_column_2rm
1956
1957 (tmp_matrix, thermal_grid, analysis, dimensions,
1958 lindex, row, column) ;
1959
1960 } // FOR_EVERY_COLUMN
1961 } // FOR_EVERY_ROW
1962
1963 break ;
1964 }
1966 {
1967 CellIndex_t row ;
1968 CellIndex_t column ;
1969
1970 for (row = first_row (dimensions) ; row <= last_row (dimensions) ; row++)
1971 {
1972 for (column = first_column (dimensions) ; column <= last_column (dimensions) ; column++)
1973 {
1974 tmp_matrix = add_bottom_wall_column_2rm
1975
1976 (tmp_matrix, thermal_grid, analysis, dimensions,
1977 lindex, row, column) ;
1978
1979 } // FOR_EVERY_COLUMN
1980 } // FOR_EVERY_ROW
1981 break ;
1982
1983 }
1984 case TDICE_LAYER_NONE :
1985 {
1986 fprintf (stderr, "ERROR: unset layer type\n") ;
1987
1988 break ;
1989 }
1990 default :
1991
1992 fprintf (stderr, "ERROR: unknown layer type %d\n", thermal_grid->LayersTypeProfile [lindex]) ;
1993 }
1994
1995 }
1996
1997 if(thermal_grid->TopHeatSink && thermal_grid->TopHeatSink->SinkModel == TDICE_HEATSINK_TOP_PLUGGABLE)
1998 {
1999 CellIndex_t row ;
2000 CellIndex_t column ;
2001 for(row = 0; row < thermal_grid->TopHeatSink->NRows; row++)
2002 for(column = 0; column < thermal_grid->TopHeatSink->NColumns; column++)
2003 tmp_matrix = add_spreader_column
2004 (tmp_matrix, thermal_grid, analysis, dimensions,
2005 row, column);
2006 }
2007 }
2008
2009#ifdef PRINT_DEBUG_INFO
2010 printf("system matrix info:\n");
2011 for(CellIndex_t i = 0; i < dimensions->Grid.NConnections; i++)
2012 printf("%d:\t%f\n", i, *(sysmatrix->Values+i));
2013#endif
2014
2015}
2016
2017/******************************************************************************/
2018
2020{
2021 dgstrs
2022
2023 (NOTRANS, &sysmatrix->SLUMatrix_L, &sysmatrix->SLUMatrix_U,
2024 sysmatrix->SLU_PermutationMatrixC, sysmatrix->SLU_PermutationMatrixR,
2025 b, &sysmatrix->SLU_Stat, &sysmatrix->SLU_Info) ;
2026
2027 if (sysmatrix->SLU_Info < 0)
2028 {
2029 fprintf (stderr,
2030 "Error (%d) while solving linear system\n", sysmatrix->SLU_Info) ;
2031
2032 return TDICE_FAILURE ;
2033 }
2034
2035 return TDICE_SUCCESS ;
2036}
2037
2038/******************************************************************************/
2039
2041{
2042 FILE* file = fopen (file_name, "w") ;
2043
2044 if (file == NULL)
2045 {
2046 fprintf(stderr, "Cannot open file %s\n", file_name) ;
2047 return ;
2048 }
2049
2050 CellIndex_t row, column ;
2051
2052 for (column = 0 ; column < sysmatrix.Size ; column++)
2053
2054 for (row = sysmatrix.ColumnPointers[column] ;
2055 row < sysmatrix.ColumnPointers[column + 1] ;
2056 row++)
2057
2058 fprintf (file, "%9d\t%9d\t%32.24f\n",
2059 sysmatrix.RowIndices[row] + 1, column + 1,
2060 sysmatrix.Values[row]) ;
2061
2062 fclose (file) ;
2063}
2064
2065/******************************************************************************/
CellDimension_t get_cell_height(Dimensions_t *dimensions, CellIndex_t layer_index)
Definition: dimensions.c:536
CellIndex_t get_number_of_layers(Dimensions_t *dimensions)
Definition: dimensions.c:631
CellIndex_t get_layer_cell_offset_from_spreader_coordinates(Dimensions_t *dimensions, struct HeatSink_t *hsink, CellIndex_t layer_index, CellIndex_t row_index, CellIndex_t column_index)
Definition: dimensions.c:783
CellIndex_t get_cell_offset_in_stack(Dimensions_t *dimensions, CellIndex_t layer_index, CellIndex_t row_index, CellIndex_t column_index)
Definition: dimensions.c:686
CellIndex_t get_spreader_cell_offset(Dimensions_t *dimensions, struct HeatSink_t *hsink, CellIndex_t row_index, CellIndex_t column_index)
Definition: dimensions.c:721
CellIndex_t get_spreader_cell_offset_from_layer_coordinates(Dimensions_t *dimensions, struct HeatSink_t *hsink, CellIndex_t row_index, CellIndex_t column_index)
Definition: dimensions.c:747
CellIndex_t last_column(Dimensions_t *dimensions)
Definition: dimensions.c:456
CellIndex_t last_layer(Dimensions_t *dimensions)
Definition: dimensions.c:470
CellIndex_t get_number_of_rows(Dimensions_t *dimensions)
Definition: dimensions.c:638
bool has_layer_underneath(Dimensions_t *dimensions, struct HeatSink_t *hsink, CellIndex_t row_index, CellIndex_t column_index)
Definition: dimensions.c:764
CellIndex_t first_layer(Dimensions_t *dimensions)
CellIndex_t first_column(Dimensions_t *dimensions)
CellIndex_t get_number_of_columns(Dimensions_t *dimensions)
Definition: dimensions.c:645
CellIndex_t first_row(Dimensions_t *dimensions)
CellIndex_t last_row(Dimensions_t *dimensions)
Definition: dimensions.c:442
Conductance_t get_spreader_conductance_top_bottom(HeatSink_t *hsink)
Definition: heat_sink.c:405
Conductance_t get_spreader_conductance_north_south(HeatSink_t *hsink)
Definition: heat_sink.c:396
Capacity_t get_spreader_capacity(HeatSink_t *hsink)
Definition: heat_sink.c:377
Conductance_t get_spreader_conductance_east_west(HeatSink_t *hsink)
Definition: heat_sink.c:387
SolidTC_t get_thermal_conductivity(Layer_t *layer, CellIndex_t row_index, CellIndex_t column_index, Dimensions_t *dimensions)
Definition: layer.c:187
#define PARALLEL(x, y)
Definition: macros.h:88
#define IS_CHANNEL_COLUMN(channel_model, column)
Definition: macros.h:101
char * String_t
Definition: string_t.h:55
Informations about the type of thermal simulation to be run, timing and its initial settings.
Definition: analysis.h:65
AnalysisType_t AnalysisType
Definition: analysis.h:68
Time_t StepTime
Definition: analysis.h:72
ChannelModel_t ChannelModel
Definition: channel.h:74
ChipDimension_t Width
Definition: dimensions.h:262
Collections of all the structures that are needed for the thermal simulation.
Definition: dimensions.h:311
GridDimensions_t Grid
Definition: dimensions.h:318
ConnectionList_t connections_list
Definition: dimensions.h:340
uint8_t NonUniform
Definition: dimensions.h:326
ChipDimensions_t Chip
Definition: dimensions.h:322
Non_uniform_cellList_t Cell_list
Definition: dimensions.h:337
CellIndex_t NConnections
Definition: dimensions.h:207
Structure used to store data about the heat dissipation through the top or bottom surfaces of the 2D/...
Definition: heat_sink.h:69
CellIndex_t NColumns
Definition: heat_sink.h:114
CellIndex_t NumColumnsBorder
Definition: heat_sink.h:126
HeatSinkModel_t SinkModel
Definition: heat_sink.h:72
CellIndex_t NumRowsBorder
Definition: heat_sink.h:120
AmbientHTC_t AmbientHTC
Definition: heat_sink.h:77
CellIndex_t NRows
Definition: heat_sink.h:110
Structure representing the squared matrix storing the coefficients of the linear system that is solve...
Definition: system_matrix.h:73
SuperLUStat_t SLU_Stat
SuperMatrix SLUMatrix_A_Permuted
CellIndex_t Size
Definition: system_matrix.h:92
SuperMatrix SLUMatrix_L
SystemMatrixCoeff_t * Values
Definition: system_matrix.h:88
int * SLU_PermutationMatrixR
SuperMatrix SLUMatrix_A
CellIndex_t * ColumnPointers
Definition: system_matrix.h:79
CellIndex_t NNz
Definition: system_matrix.h:96
superlu_options_t SLU_Options
CellIndex_t * RowIndices
Definition: system_matrix.h:84
int * SLU_PermutationMatrixC
SuperMatrix SLUMatrix_U
Structure used to store data about the thermal cells / RC nodes.
Definition: thermal_grid.h:68
StackLayerType_t * LayersTypeProfile
Definition: thermal_grid.h:75
Channel_t * Channel
Definition: thermal_grid.h:84
HeatSink_t * TopHeatSink
Definition: thermal_grid.h:88
Layer_t * LayersProfile
Definition: thermal_grid.h:80
CellIndex_t NLayers
Definition: thermal_grid.h:71
Error_t system_matrix_build(SystemMatrix_t *sysmatrix, CellIndex_t size, CellIndex_t nnz)
Definition: system_matrix.c:86
void system_matrix_init(SystemMatrix_t *sysmatrix)
Definition: system_matrix.c:46
void system_matrix_destroy(SystemMatrix_t *sysmatrix)
Error_t do_factorization(SystemMatrix_t *sysmatrix)
void fill_system_matrix(SystemMatrix_t *sysmatrix, ThermalGrid_t *thermal_grid, Analysis_t *analysis, Dimensions_t *dimensions)
Error_t solve_sparse_linear_system(SystemMatrix_t *sysmatrix, SuperMatrix *b)
void system_matrix_print(SystemMatrix_t sysmatrix, String_t file_name)
Conductance_t get_conductance_non_uniform(ThermalGrid_t *tgrid, Dimensions_t *dimensions, ConnectionListNode_t *i_cell, CellIndex_t node1_index, CellIndex_t node2_index, Conductance_t *sign_note)
Definition: thermal_grid.c:820
Capacity_t get_capacity(ThermalGrid_t *tgrid, Dimensions_t *dimensions, CellIndex_t layer_index, CellIndex_t row_index, CellIndex_t column_index)
Definition: thermal_grid.c:425
Conductance_t get_conductance_south(ThermalGrid_t *tgrid, Dimensions_t *dimensions, CellIndex_t layer_index, CellIndex_t row_index, CellIndex_t column_index)
Conductance_t get_conductance_east(ThermalGrid_t *tgrid, Dimensions_t *dimensions, CellIndex_t layer_index, CellIndex_t row_index, CellIndex_t column_index)
Conductance_t get_conductance_top(ThermalGrid_t *tgrid, Dimensions_t *dimensions, CellIndex_t layer_index, CellIndex_t row_index, CellIndex_t column_index)
Definition: thermal_grid.c:904
Conductance_t get_conductance_non_uniform_y(ThermalGrid_t *tgrid, Dimensions_t *dimensions, ChipDimension_t value, Non_uniform_cellListNode_t *node, Conductance_t direction_note)
Definition: thermal_grid.c:641
Conductance_t get_conductance_north(ThermalGrid_t *tgrid, Dimensions_t *dimensions, CellIndex_t layer_index, CellIndex_t row_index, CellIndex_t column_index)
Capacity_t get_capacity_non_uniform(ThermalGrid_t *tgrid, Dimensions_t *dimensions, Non_uniform_cellListNode_t *i_cell)
Definition: thermal_grid.c:326
Conductance_t get_conductance_bottom(ThermalGrid_t *tgrid, Dimensions_t *dimensions, CellIndex_t layer_index, CellIndex_t row_index, CellIndex_t column_index)
Conductance_t get_conductance_west(ThermalGrid_t *tgrid, Dimensions_t *dimensions, CellIndex_t layer_index, CellIndex_t row_index, CellIndex_t column_index)
double SystemMatrixCoeff_t
Definition: types.h:125
double Conductance_t
Definition: types.h:113
Error_t
Definition: types.h:401
@ TDICE_SUCCESS
The function returns with success.
Definition: types.h:402
@ TDICE_FAILURE
The function retuerns with a generic error.
Definition: types.h:403
@ TDICE_LAYER_CHANNEL_2RM
Definition: types.h:286
@ TDICE_LAYER_CHANNEL_4RM
Definition: types.h:282
@ TDICE_LAYER_SOURCE_CONNECTED_TO_SPREADER
Definition: types.h:274
@ TDICE_LAYER_SOLID_CONNECTED_TO_AMBIENT
Definition: types.h:258
@ TDICE_LAYER_SOLID_CONNECTED_TO_SPREADER
Definition: types.h:262
@ TDICE_LAYER_NONE
Definition: types.h:246
@ TDICE_LAYER_SOURCE_CONNECTED_TO_PCB
Definition: types.h:278
@ TDICE_LAYER_PINFINS_STAGGERED
Definition: types.h:294
@ TDICE_LAYER_SOLID
Definition: types.h:250
@ TDICE_LAYER_SOLID_CONNECTED_TO_PCB
Definition: types.h:266
@ TDICE_LAYER_SOURCE
Definition: types.h:254
@ TDICE_LAYER_SOURCE_CONNECTED_TO_AMBIENT
Definition: types.h:270
@ TDICE_LAYER_PINFINS_INLINE
Definition: types.h:290
@ TDICE_LAYER_BOTTOM_WALL
Definition: types.h:310
@ TDICE_LAYER_VWALL_CHANNEL
Definition: types.h:298
@ TDICE_LAYER_VWALL_PINFINS
Definition: types.h:302
@ TDICE_LAYER_TOP_WALL
Definition: types.h:306
ChannelModel_t
Definition: types.h:346
@ TDICE_CHANNEL_MODEL_MC_2RM
Microchannel - 2 Resistors model.
Definition: types.h:349
double ChipDimension_t
Definition: types.h:187
@ TDICE_ANALYSIS_TYPE_TRANSIENT
Transient analysis.
Definition: types.h:457
uint32_t CellIndex_t
Definition: types.h:213
@ TDICE_HEATSINK_TOP_PLUGGABLE
Top pluggable heat sink.
Definition: types.h:228