Guest User

Untitled

a guest
Jun 24th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include "UnitConversion_winters0.h"
  4.  
  5. /* PA 5.2.1 Task2: Heat loss from a house
  6. * File: PA_5_2_1_Task2_winters0.c
  7. * Date: 15 February 2012
  8. * By: Colleen Winters
  9. * Login: winters0
  10. * Section: 3
  11. * Team: 46
  12. *
  13. * ELECTRONIC SIGNATURE
  14. * Colleen Winters
  15. *
  16. * The electronic signature above indicates the program submitted for
  17. * evaluation is my individual work, and I have a general understanding of
  18. * all aspects of its development and execution.
  19. *
  20. * PROGRAM DESCRIPTION
  21. * Find the heat lost from a house in keeping the house at a constant temperature.
  22. */
  23.  
  24.  
  25. /* Defined variables */
  26.  
  27. /* gravity */
  28. #define g 9.81
  29.  
  30. /* Prandtl number */
  31. #define Pr .7
  32.  
  33. /* Kinematic viscosity of air */
  34. #define y .0000178
  35.  
  36. /* thermal conductivity of air */
  37. #define K .25
  38.  
  39.  
  40. /* --- functions prototypes --- */
  41. float Rayleigh( float Th, float Te, float L);
  42. float HeatLoss( float L, float W, float Th, float Te, float HeTrans);
  43. float Nusselt( float Ra);
  44. float HeTrans( float Nusselt, float L);
  45.  
  46.  
  47.  
  48. int main(void)
  49. {
  50. /* ---- Variable declaration ---- */
  51.  
  52.  
  53. /* L = height, W = length */
  54. float TempH, TempE, L, W;
  55.  
  56. /* storage for outputs from functions */
  57. float Ra, HL, Nu, TCo;
  58.  
  59. /* ---- Input section ---- */
  60.  
  61. printf("\nThis function takes the user inputs to find the heat loss from a \
  62. house due to the difference in the temperature inside and outside.\n");
  63.  
  64. printf("\nInput temperature of the house in F: \n");
  65. scanf("%f", &TempH);
  66. printf("Input temperature outside in K: \n");
  67. scanf("%f", &TempE);
  68. printf("Input the height of the house in feet: \n");
  69. scanf("%f", &L);
  70. printf("Input the total length of the house in feet: \n");
  71. scanf("%f", &W);
  72.  
  73. /* ---- transforming variables into proper units ---- */
  74.  
  75. TempH = Fahr2Kel(TempH);
  76. L = Ft2M(L);
  77. W = Ft2M(W);
  78.  
  79. /* ---- storage of calculated values from functions. ---- */
  80.  
  81. Ra = Rayleigh(TempH, TempE, L);
  82. Nu = Nusselt(Ra);
  83. TCo = HeTrans(Nu, L);
  84. HL = HeatLoss(L, W, TempH, TempE, TCo);
  85.  
  86. /* ---- Output section ---- */
  87.  
  88. printf("\nRayleigh = %f ", Ra);
  89. printf("\nNusselt = %f ", Nu);
  90. printf("\nHeat Transfer coeff = %f", TCo);
  91. printf("\nThe amount of heat lost from a house is %.6f BTU/s\n", HL);
  92. return 0;
  93. }
  94.  
  95.  
  96. /* --- Called functions --- */
  97.  
  98.  
  99.  
  100. float Rayleigh( float Th, float Te, float L)
  101. {
  102. /* --- Variable declaration --- */
  103. float Ra;
  104.  
  105. /* --- Calculations --- */
  106.  
  107. Ra = (g * ((Th - Te)/Te) * pow(L , 2.0) * Pr);
  108. Ra = Ra / pow(y , 2.0);
  109.  
  110. return Ra;
  111. }
  112.  
  113.  
  114.  
  115. float Nusselt( float Ra)
  116. {
  117. /* --- Variable declaration --- */
  118. float Nu;
  119.  
  120. /* --- Calculations --- */
  121.  
  122. Nu = .59 * pow(Ra , .25);
  123.  
  124. return Nu;
  125. }
  126.  
  127.  
  128. float HeTrans( float Nusselt, float L)
  129. {
  130. /* --- Variable declaration --- */
  131. float TCo;
  132.  
  133. /* --- Calculations --- */
  134.  
  135. TCo = (Nusselt * K) / L;
  136.  
  137. return TCo;
  138. }
  139.  
  140.  
  141. float HeatLoss( float L, float W, float Th, float Te, float HeTrans)
  142. {
  143. /* --- Variable declaration --- */
  144. float Q;
  145.  
  146. /* --- Calculations --- */
  147.  
  148. Q = HeTrans * L * W * (Th - Te);
  149.  
  150. return Q;
  151. }
Add Comment
Please, Sign In to add comment