#ifndef __PACKAGE_H_1#define __PACKAGE_H_23#include "flp.h"4#include "util.h"5#include "temperature.h"67/* santity check convection resistance boundary values.8if outside this range, most likely some settings of9the heat sink or the fan are unreasonable.10*/11#define R_CONVEC_HIGH 50.0 /* upper-bound value for natural convection without heat sink */12#define R_CONVEC_LOW 0.01 /* lower-bound value for best cooling solution, e.g. liquid cooling */1314/* fluid (air) properties */15#define AIR_DSTY 1.059 /* density */16#define AIR_SPECHT 1007 /* specific heat */17#define AIR_COND 0.028 /* thermal conductivity */18#define AIR_DIFF 2.6e-5 /* thermal diffusivity */19#define AIR_DYNVISC 2.0e-5 /* dynamic viscosity */20#define AIR_KINVISC 1.9e-5 /* kinetic viscosity */2122#define PRANTDL_NUM 0.73 /* Prantdl Number of air */23#define REY_THRESHOLD 3500 /* laminar/turbulent reynolds threshold */2425/* parameters specific to natural convection and radiation */26#define VOL_EXP_COEFF 3.0e-3 /* volume expansion coefficient */27#define GRAVITY 9.8 /* gravity acceleration rate */28#define STEFAN 5.67e-8 /* Stefan-Boltzmann constant */29#define EMISSIVITY 0.95 /* emissivity, typical value for most heatsink materials */30#define SMALL_FOR_CONVEC 0.01 /* initial small temperature diff b/w heatsink and ambient, to avoid sigular matrices */31#define NATURAL_CONVEC_TOL 0.01 /* r_convec convergence criterion for natural convection calculations */32#define MAX_SINK_TEMP 1000 /* max avg sink temperature during iteration for natural convection. if exceeded, report thermal runaway*/3334/* flow resistance constants */35#define KC 0.4236#define KE 1.037#define PI 3.14163839/* fan constants */40#define FAN_ALPHA 1 /* 1 for laminar flow, >=2 for turbulent flow */41#define FAN_BETA 4 /* 4 for laminar flow, 4.6 for turbulent flow */42#define FAN_POWER_COEFF 2.8 /* fan_power=b*omega^2.8 */43#define RPM_TO_RAD 0.105 /* convert rpm to radians per sec */44#define RAD_TO_RPM 9.55 /* convert radians per sec to rpm */4546/* package model configuration */47typedef struct package_config_t_st48{49/* natural convection or not - 0: forced convection, 1: natural convection*/50int natural_convec;5152/* airflow type - 0: lateral airflow from sink side, 1: impinging airflow from sink top*/53int flow_type;5455/* heatsink type - 0: fin-channel sink, 1: pin-fin sink */56int sink_type;5758/* sink specs */59/* sink base size is defined in thermal_config */60/* 1) fin-channel sink */61double fin_height;62double fin_width;63double channel_width;64/* 2) pin-fin sink */65double pin_height;66double pin_diam;67double pin_dist; /* distance between pins */6869/* fan specs */70double fan_radius;71double motor_radius;72int rpm;73}package_config_t;7475/* defaults */76package_config_t default_package_config(void);77/*78* parse a table of name-value string pairs and add the configuration79* parameters to 'package_config'80*/81void package_config_add_from_strs(package_config_t *package_config, str_pair *package_table, int size);82/*83* convert package_config into a table of name-value pairs. returns the no.84* of parameters converted85*/86int package_config_to_strs(package_config_t *package_config, str_pair *package_table, int max_entries);8788/* airflow parameters */89typedef struct convection_t_st90{91double n_fin; /* number of fins */92double sur_area_fin; /* total surface area */9394double n_pin; /* number of pins */95double sur_area_pin; /* total surface area */9697/* flow charateristics */98double reynolds;99double nusselt;100double h_coeff; /* heat transfer coefficient */101double v; /* air velocity */102double r_th; /* lumped convection thermal resistance */103}convection_t;104105/* airflow parameter routines */106void calculate_flow(convection_t *p, package_config_t *package_config, thermal_config_t *thermal_config);107108/* debug print */109void debug_print_convection(convection_t *p);110111/* parse thermal config table and update r_conv if needed */112int package_model(thermal_config_t *thermal_config, str_pair *table, int size, double sink_temp);113114#endif115116117