Advertisement
Guest User

F28 Cooling Simulation

a guest
Sep 19th, 2020
3,230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 11.06 KB | None | 0 0
  1. %F28 Cooling Calculations
  2. clc; clear; format compact
  3.  
  4. %% Constants
  5.  
  6. CpWat = 4.1813; %kj/kg*C
  7. CpStm = 2.08; %kj/kg*C
  8. CpAir = 1.012; %kj/kg*C
  9. InitPress = 101325; %Pa
  10. Rair = 287.058; %J/kg*R
  11. FOS = .66
  12.  
  13. %% Inputs
  14.  
  15. TorqueRange = 0:5:200; %Range of torques to calculate cooling load
  16. waterTemps = 25:1:200;
  17. Tamb = 40; %C
  18. FrontalArea = .071/2; %M^2  F26 = .071 **one big radiator double size  F25 = .0565 **one radiator
  19. HeatTransferArea = FrontalArea*46; %m^2 place holder for now reference: F26= 3.3, F25= 2.6
  20. %heat transfer area is calculated to be 46 times the frontal area for the standard fin density
  21. SpeedRatio = .66; % Percent speed of air through radiator relative to car speed  F25 = .52  F26 = .66
  22. HeatTransferCoefficient = .4615; %Must be from empirical testing. .46 was found with f25 and mishimoto radiator. Should be related to construction of radiator only.
  23.  
  24. CarWaterm = 1; %kg of water in the cooling system
  25.  
  26. %% Density Change Water, calculation for equation in F27 cooling spreadsheet
  27.  
  28. % ***not used in f28 stuff, yet***
  29. Twat = 0:1:180; %C
  30. TwatK = Twat+273; %K
  31. RhoWat = -2.86508609805697E-12.*TwatK.^6+6.38960553206707E-09.*TwatK.^5-5.95203372006815E-06.*TwatK.^4+0.00296781391817375.*TwatK.^3-0.838664938806037.*TwatK.^2+127.427758320699.*TwatK-7109.55709155285; %Density of Water Based on Temp [kg/m^3]
  32.  
  33. %% Density Change Air, calculation for equation in F27 cooling spreadsheet
  34.  
  35. Tair = 0:1:45; %C
  36. TairK = Tair+273; %K
  37. RhoAir = InitPress./(Rair.*TairK); %Density of Air Based On Temp [kg/m^3]
  38.  
  39. %% RPM and Speed
  40. gearRatio = 2.65;
  41. WheelCir = pi*18; %in
  42. RevsPerMile = 1/(WheelCir/12/5280);
  43. SpeedArray = 0:1:70; % [MPH]
  44. SpeedArrayMS = SpeedArray.*.44704; % [m/s]
  45. rpmArray = SpeedArray*gearRatio*63360/(WheelCir*60);
  46.  
  47. % for i = 1:1:size(SpeedArray,2)
  48. %     RPMArray(i)=SpeedArray(i)*RevsPerMile*gearRatio/60;
  49. % end
  50. %% Volumetric Flow of Air
  51.  
  52. FrontalArea = FrontalArea; %M^2  F26 = .071 **one big radiator double size  F25 = .0565 **one radiator
  53. %changed previously, placeholder
  54. LPSAir = SpeedArrayMS.*FrontalArea*SpeedRatio*1000; %L/s
  55.  
  56. %% Volumetric Flow of Water
  57.  
  58. for i = 1:1:size(SpeedArray,2)
  59.     LPSWat(i) = 8/60; % L/s   8L/min to L/s
  60. end
  61.  
  62. %% Mass Flow of Air
  63.  
  64. AmbDensity = RhoAir(find(Tair == Tamb)); %kg/m^3
  65. MdotAir = LPSAir./1000.*AmbDensity; %kg/s
  66. for i = 2:1:size(waterTemps,2)
  67.     MdotAir(i,:)=MdotAir(1,:); %kg/s
  68. end
  69.  
  70. %% Mass Flow of Water
  71. for j = 1:1:size(waterTemps,2)
  72.     WatDensity(j,1) = 997; %kg/m^3
  73. end
  74. MdotWat = LPSWat./1000.*WatDensity; %Mdot Water   kg/s
  75.  
  76. %% Radiator Cooling
  77. Ch = MdotWat*CpWat;  %Heat capacity rate water
  78. Cc = MdotAir*CpAir;  %Heat capacity rate air
  79. for i = 1:1:size(SpeedArray,2)
  80.     for j = 1:1:size(waterTemps,2)
  81.         Cmin(j,i) = min(Ch(j,i),Cc(j,i));
  82.         Cmax(j,i) = max(Ch(j,i),Cc(j,i));
  83.     end
  84. end
  85. Cr = Cmin./Cmax;
  86. for i = 1:1:size(waterTemps,2)
  87.     DeltaT(i,1:size(SpeedArray,2)) = waterTemps(i)-Tamb;
  88. end
  89. % for i=1:1:size(SpeedArray,2)
  90. %     DeltaT(:,i) = DeltaT(:,1);
  91. % end
  92.  
  93. qmax = Cmin.*DeltaT;
  94.  
  95. NTU = (HeatTransferCoefficient*HeatTransferArea)./Cmin;
  96.  
  97. for i = 1:1:size(SpeedArray,2)
  98.     for j = 1:1:size(waterTemps,2)
  99.         e(j,i) = 1-exp((-1/Cr(j,i))*(1-exp(-Cr(j,i)*NTU(j,i))));
  100.     end
  101. end
  102. q = qmax.*e;
  103. %Coco's code for radiation
  104. % qRadiation = transpose(.09 * 5.6703*10^-8 * (Th.^4-Tamb^4) * HeatTransferArea);
  105. %
  106. % q = (q + qRadiation).*FOS;
  107. % q(:,1) = qRadiation;
  108. q = q.*FOS;
  109.  
  110. %% Radiator Cooling - Radiators in parallel, flow/2
  111. Ch = MdotWat*CpWat;  %Heat capacity rate water
  112. Ch2 = Ch/2;
  113. Cc = MdotAir*CpAir;  %Heat capacity rate air
  114. for i = 1:1:size(SpeedArray,2)
  115.     for j = 1:1:size(waterTemps,2)
  116.         Cmin(j,i) = min(Ch2(j,i),Cc(j,i));
  117.         Cmax(j,i) = max(Ch2(j,i),Cc(j,i));
  118.     end
  119. end
  120. Cr = Cmin./Cmax;
  121. for i = 1:1:size(waterTemps,2)
  122.     DeltaT(i,1)=waterTemps(i)-Tamb;
  123. end
  124. for i=1:1:size(SpeedArray,2)
  125.     DeltaT(:,i)=DeltaT(:,1);
  126. end
  127. qmax2 = Cmin.*DeltaT;
  128. NTU = (HeatTransferCoefficient*HeatTransferArea)./Cmin;
  129. for i = 1:1:size(SpeedArray,2)
  130.     for j = 1:1:size(waterTemps,2)
  131.         e(j,i) = 1-exp((-1/Cr(j,i))*(1-exp(-Cr(j,i)*NTU(j,i))));
  132.     end
  133. end
  134. q2 = (qmax2.*e).*FOS;
  135. %% Heat Rejected From Motor and Motor Controller
  136.  
  137. %*** old, not used right now ***
  138. motorControllerEfficiency = 0.97;
  139.  
  140. for i = 1:1:size(rpmArray,2)
  141.     for j = 1:1:size(TorqueRange,2)
  142.         Q(j,i) = ((1-calculateEfficiency(rpmArray(i),TorqueRange(j)))...
  143.             *rpmArray(i)*TorqueRange(j)*(motorControllerEfficiency)...
  144.             +(1-motorControllerEfficiency)*rpmArray(i)*TorqueRange(j))/1000/9.5488;
  145.     end
  146. end
  147.  
  148.  
  149. % surf(SpeedArray,waterTemps,q)
  150. % xlabel('Speed[MPH]')
  151. % ylabel('Water Temp [C]')
  152. % zlabel('Kilowatts')
  153. % title('Cooling Potential')
  154. %
  155. % figure
  156. %
  157. % surf(rpmArray,TorqueRange,Q)
  158. % xlabel('Speed[RPM]')
  159. % ylabel('Torque [NM]')
  160. % zlabel('Kilowatts')
  161. % title('Cooling Load')
  162.  
  163.  
  164. %% ************** Endurance Sim **************
  165.  
  166. %% Import and setup data
  167. %xtime  aps   speed [km/h]  Torque
  168.  
  169. data = csvread('HeyFilipUseThisOneModified.csv'); % Import csv file
  170.  
  171. %can data files
  172. % time = data(:,1)-data(1,1);
  173. % SimPower = data(:,2)/1000; % kw
  174. % SimRPMs = -data(:,3); %rpm
  175. % SimSpeeds = SimRPMs*pi*18*60/(gearRatio*63360); % mph
  176. % SimTorque = data(:,4); %NM
  177. % actualMotorTemp = data(:,5); %C
  178. % actualBoardTemp = data(:,6); %C
  179.  
  180. %F27 north autocross [time speed torque]
  181. time = data(:,1)-data(1,1);
  182. SimSpeeds = data(:,3)*0.621371; %mph (originally kpm)
  183. SimTorque = data(:,2)*120; %NM
  184. SimRPMs = SimSpeeds*(gearRatio*63360)/(pi*18*60); %rpm
  185. SimPower = SimTorque.*SimRPMs/9.5488/1000; % kw
  186.  
  187. %% Running System Temp
  188.  
  189. OperatingT = zeros(length(SimSpeeds),1);
  190.  
  191. RunT = Tamb(1,1);
  192.  
  193. q(:,1) = 0;
  194. q2(:,1) = 0;
  195. timeStep = (time(end) - time(1))/size(time,1);
  196.  
  197. % SimPower(:,1) = 100;
  198. % SimRPMs(:,1) = 3000;
  199. % SimSpeeds = SimRPMs*pi*18*60/(gearRatio*63360); % mph
  200.  
  201. for i = 1:1:length(SimSpeeds)
  202.     %Q
  203.     torqueID = abs(round(SimTorque(i)/(TorqueRange(2)-TorqueRange(1))))+1; %Row Coordinate
  204.     SimSpeedID = round(SimSpeeds(i))+1; % Column Coordinate
  205.  
  206.     overallInefficiency = motorControllerEfficiency*(1-calculateEfficiency(SimRPMs(i),SimTorque(i))) + (1-motorControllerEfficiency);
  207.     SimQadd = SimPower(i)*overallInefficiency/(1-overallInefficiency)+.078;
  208.     %SimQadd = SimQadd*1.5;
  209.     %SimQadd = 0.11*abs(SimPower(i));
  210.    
  211.     %SimQadd = abs(SimPower(i)*motorControllerEfficiency*.09+SimPower(i)*(1-motorControllerEfficiency)); %constant efficiency
  212. %     SimPower(i)*motorControllerEfficiency*(1-calculateEfficiency(SimRPMs(i),SimTorque(i)))
  213. %     SimPower(i)*(1-motorControllerEfficiency)
  214.    
  215.     %q
  216.     waterTempID = round(RunT + SimQadd/Ch(1,1))-waterTemps(1)+1; %Row Coordinate
  217.     %column coordinate is speed (calculated above)
  218.  
  219.     %one radiator
  220.     SimQrej = q(waterTempID, SimSpeedID); %Row coordinate
  221.  
  222.     %%two radiators series
  223. %     SimQrej = q(waterTempID, SimSpeedID);
  224. %     waterTempID = round(RunT + SimQadd/Ch(1,1) - SimQrej/Ch(1,1))-waterTemps(1)+1;%recalculate water temp for the 2nd radiator
  225. %     SimQrej2 = q(waterTempID, SimSpeedID);
  226. %     SimQrej = SimQrej+SimQrej2;
  227.    
  228.     %%two radiators parallel
  229.      %SimQrej = 2*q2(waterTempID, SimSpeedID);
  230.  
  231.     %%radiator - motor - radiator - motor controller
  232. %     waterTempID = round(RunT + abs(SimPower(i)*motorControllerEfficiency*(1-calculateEfficiency(SimRPMs(i),SimTorque(i))))/...
  233. %         Ch(1,1))-waterTemps(1)+1; %Water temp ID after motor heat
  234. %     SimQrej = q(waterTempID, SimSpeedID);
  235. %     waterTempID = round(RunT + (SimQadd - SimQrej)/Ch(1,1))-waterTemps(1)+1;%water temp id after motor heat, 1st radiator, motor controller
  236. %     SimQrej2 = q(waterTempID, SimSpeedID);
  237. %     SimQrej = SimQrej+SimQrej2;
  238.    
  239.    
  240.     if i == length(SimSpeeds) %accounts for time end conditions
  241.         SystemDeltaT = (SimQadd-SimQrej)*(time(i)-time(i-1))/(CarWaterm*CpWat);
  242.     else
  243.         SystemDeltaT = (SimQadd-SimQrej)*(time(i+1)-time(i))/(CarWaterm*CpWat);
  244.     end
  245.    
  246.     OperatingT(i,1) = RunT;
  247.    
  248.     RunT = RunT+SystemDeltaT;
  249.    
  250.     QPlot(i) = SimQadd;
  251.     qPlot(i) = SimQrej;
  252. end
  253.  
  254. % sum = 0;
  255. % for i = 1:1:length(SimSpeeds)
  256. %     sum = sum + qPlot(i)*timeStep;
  257. %    
  258. % end
  259. % sum
  260.  
  261.  
  262. % figure
  263. % hold on
  264. % plot(time,QPlot)
  265. % plot(time,qPlot)
  266. % hold off
  267.  
  268. figure
  269.  
  270. plot(time,OperatingT)
  271. %legend('Sim Water Temp')
  272. xlabel('Time [s]')
  273. ylabel('Inlet Temp [C]')
  274. ylim([35 55])
  275. %yticks(linspace(0,150,16));
  276.  
  277. % plot(time,actualMotorTemp,time,actualBoardTemp,time,OperatingT)
  278. % legend('Actual Motor Temp','Actual Board Temp', 'Sim Water Temp')
  279. % xlabel('Time [s]')
  280. % ylabel('Temp (water calculated, driver temp actual) [C]')
  281. % ylim([0 150])
  282. % yticks(linspace(0,150,16));
  283.  
  284. %Correlation = corr(ActualTmot,OperatingT)^2
  285.  
  286.  
  287.  
  288. %% Efficiency Calculator
  289. function efficiency = calculateEfficiency(speed,torque)
  290. x = abs(speed);
  291. y = abs(torque);
  292.  
  293. efficiency = - (806664293702051*x^5)/20282409603651670423947251286016 +...
  294.     (6048007753972789*x^4*y)/10141204801825835211973625643008 + ...
  295.     (3858718125134139*x^4)/39614081257132168796771975168 - ...
  296.     (8119859474032225*x^3*y^2)/158456325028528675187087900672 + ...
  297.     (1162191950534967*x^3*y)/77371252455336267181195264 + ...
  298.     (7691715718733423*x^3)/19342813113834066795298816 + ...
  299.     (168269694257541*x^2*y^3)/618970019642690137449562112 + ...
  300.     (4759399600574169*x^2*y^2)/19342813113834066795298816 - ...
  301.     (8528200935620531*x^2*y)/75557863725914323419136 - ...
  302.     (227101689919517*x^2)/147573952589676412928 - ...
  303.     (8160261108718595*x*y^4)/1237940039285380274899124224 + ...
  304.     (7160371450690221*x*y^3)/2417851639229258349412352 - ...
  305.     (5557099576819671*x*y^2)/4722366482869645213696 + ...
  306.     (5647427185526377*x*y)/18446744073709551616 + ...
  307.     (8205125120791685*x)/9223372036854775808 - ...
  308.     (6467694548799879*y^5)/19342813113834066795298816 + ...
  309.     (3733480271491167*y^4)/18889465931478580854784 - ...
  310.     (734208328307895*y^3)/18446744073709551616 + ...
  311.     (3293080008253099*y^2)/1152921504606846976 - ...
  312.     (5254708633221437*y)/72057594037927936 + ...
  313.     5822063360154223/70368744177664;
  314.  
  315. %with zeros
  316. %efficiency = (6118954630883355*x^5)/5070602400912917605986812821504 - (628743307164999*x^4*y)/79228162514264337593543950336 - (1237302700538721*x^4)/77371252455336267181195264 - (7745120690570423*x^3*y^2)/158456325028528675187087900672 + (3814286486564477*x^3*y)/38685626227668133590597632 + (2916752717070675*x^3)/37778931862957161709568 - (5175192990316947*x^2*y^3)/4951760157141521099596496896 + (8568359820921115*x^2*y^2)/9671406556917033397649408 - (8949491904219383*x^2*y)/18889465931478580854784 - (3044699724539383*x^2)/18446744073709551616 - (2867994058066611*x*y^4)/77371252455336267181195264 + (1989910368635113*x*y^3)/75557863725914323419136 - (4418780740430701*x*y^2)/590295810358705651712 + (5935188183222337*x*y)/4611686018427387904 + (5123346934399649*x)/36028797018963968 + (1333537606059827*y^5)/302231454903657293676544 - (6958707506744367*y^4)/2361183241434822606848 + (6598756891909927*y^3)/9223372036854775808 - (5487796372908753*y^2)/72057594037927936 + (28006681917705*y)/8796093022208 - 6964734157412463/562949953421312;
  317.  
  318. efficiency = abs(efficiency)/100;
  319. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement