Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include "UnitConversion_winters0.h"
- /* PA 5.2.1 Task2: Heat loss from a house
- * File: PA_5_2_1_Task2_winters0.c
- * Date: 15 February 2012
- * By: Colleen Winters
- * Login: winters0
- * Section: 3
- * Team: 46
- *
- * ELECTRONIC SIGNATURE
- * Colleen Winters
- *
- * The electronic signature above indicates the program submitted for
- * evaluation is my individual work, and I have a general understanding of
- * all aspects of its development and execution.
- *
- * PROGRAM DESCRIPTION
- * Find the heat lost from a house in keeping the house at a constant temperature.
- */
- /* Defined variables */
- /* gravity */
- #define g 9.81
- /* Prandtl number */
- #define Pr .7
- /* Kinematic viscosity of air */
- #define y .0000178
- /* thermal conductivity of air */
- #define K .25
- /* --- functions prototypes --- */
- float Rayleigh( float Th, float Te, float L);
- float HeatLoss( float L, float W, float Th, float Te, float HeTrans);
- float Nusselt( float Ra);
- float HeTrans( float Nusselt, float L);
- int main(void)
- {
- /* ---- Variable declaration ---- */
- /* L = height, W = length */
- float TempH, TempE, L, W;
- /* storage for outputs from functions */
- float Ra, HL, Nu, TCo;
- /* ---- Input section ---- */
- printf("\nThis function takes the user inputs to find the heat loss from a \
- house due to the difference in the temperature inside and outside.\n");
- printf("\nInput temperature of the house in F: \n");
- scanf("%f", &TempH);
- printf("Input temperature outside in K: \n");
- scanf("%f", &TempE);
- printf("Input the height of the house in feet: \n");
- scanf("%f", &L);
- printf("Input the total length of the house in feet: \n");
- scanf("%f", &W);
- /* ---- transforming variables into proper units ---- */
- TempH = Fahr2Kel(TempH);
- L = Ft2M(L);
- W = Ft2M(W);
- /* ---- storage of calculated values from functions. ---- */
- Ra = Rayleigh(TempH, TempE, L);
- Nu = Nusselt(Ra);
- TCo = HeTrans(Nu, L);
- HL = HeatLoss(L, W, TempH, TempE, TCo);
- /* ---- Output section ---- */
- printf("\nRayleigh = %f ", Ra);
- printf("\nNusselt = %f ", Nu);
- printf("\nHeat Transfer coeff = %f", TCo);
- printf("\nThe amount of heat lost from a house is %.6f BTU/s\n", HL);
- return 0;
- }
- /* --- Called functions --- */
- float Rayleigh( float Th, float Te, float L)
- {
- /* --- Variable declaration --- */
- float Ra;
- /* --- Calculations --- */
- Ra = (g * ((Th - Te)/Te) * pow(L , 2.0) * Pr);
- Ra = Ra / pow(y , 2.0);
- return Ra;
- }
- float Nusselt( float Ra)
- {
- /* --- Variable declaration --- */
- float Nu;
- /* --- Calculations --- */
- Nu = .59 * pow(Ra , .25);
- return Nu;
- }
- float HeTrans( float Nusselt, float L)
- {
- /* --- Variable declaration --- */
- float TCo;
- /* --- Calculations --- */
- TCo = (Nusselt * K) / L;
- return TCo;
- }
- float HeatLoss( float L, float W, float Th, float Te, float HeTrans)
- {
- /* --- Variable declaration --- */
- float Q;
- /* --- Calculations --- */
- Q = HeTrans * L * W * (Th - Te);
- return Q;
- }
Add Comment
Please, Sign In to add comment