Пример #1
0
void compute_temp(double *power, double *temp, int n_units, double time_elapsed)
{
    int i;
    double *pow, h, n_iter;
    pow = vector(NL*n_units+EXTRA);

    /* set power numbers for the virtual nodes */
    set_internal_power(power, n_units);

    /* find (inv_A)*POWER */
    matvectmult(pow, inva, power, NL*n_units+EXTRA);

    /* step size for 4th-order Runge-Kutta  - assume worst case	*/
    h = PRECISION / max_slope;
    n_iter = time_elapsed / h;
    n_iter = (n_iter > MIN_ITER) ? n_iter : MIN_ITER;	/* do at least MIN_ITER iterations	*/
    h = time_elapsed / n_iter;

    if (n_iter >= TOO_LONG)
        fprintf(stderr, "warning: calling interval too large, performing %.0f iterations - it may take REALLY long\n", n_iter);

    /* Obtain temp at time (t+h).
     * Instead of getting the temperature at t+h directly, we do it
     * in n_iter steps to reduce the error due to rk4
     */
    for (i = 0; i < n_iter; i++)
        rk4(c, temp, pow, NL*n_units+EXTRA, h, temp);

    free_vector(pow);
}
/* compute the slope vector dy for the transient equation
 * dy + cy = p. useful in the transient solver
 */
void slope_fn_block(block_model_t *model, double *y, double *p, double *dy)
{
	/* shortcuts	*/
	int n = model->n_nodes;
	double **c = model->c;

	/* for our equation, dy = p - cy */
	#if (MATHACCEL == MA_INTEL || MATHACCEL == MA_APPLE)
	/* dy = p	*/
	cblas_dcopy(n, p, 1, dy, 1);
	/* dy = dy - c*y = p - c*y */
	cblas_dgemv(CblasRowMajor, CblasNoTrans, n, n, -1, c[0],
				n, y, 1, 1, dy, 1);
	#elif (MATHACCEL == MA_AMD || MATHACCEL == MA_SUN)
	/* dy = p	*/
	dcopy(n, p, 1, dy, 1);
	/* dy = dy - c*y = p - c*y */
	dgemv('T', n, n, -1, c[0], n, y, 1, 1, dy, 1);
	#else
	int i;
	double *t = dvector(n);
	matvectmult(t, c, y, n);
	for (i = 0; i < n; i++)
		dy[i] = p[i]-t[i];
	free_dvector(t);
	#endif
}
Пример #3
0
/* power and temp should both be alloced using hotspot_vector.
 * 'b' is the 'thermal conductance' matrix. i.e, b * temp = power
 *  => temp = invb * power
 */
void steady_state_temp(double *power, double *temp, int n_units)
{
    /* set power numbers for the virtual nodes */
    set_internal_power(power, n_units);

    /* find temperatures	*/
    matvectmult(temp, invb, power, NL*n_units+EXTRA);
}