Computing all values of equation with multiple variable ranges.

14 views (last 30 days)
I am trying to compute the outcome for all possible combinations within a system of equations by changing three variables. The function is to determine the cooling power required at different flowrates, pressures and temperatures of air. I have pasted the code below. The outcome runs the for loops in parallel, and I am unsure how to achieve every combination. I realize that this program will take some time to run, if there is a more efficient way of doing it, let me know. Obviously the reference functions cannot be accessed. Thanks!
sizingTablePower = [];
inTempMin = 40;
inPressMin = 60;
AmbientMin = 40;
inTempMax = 205;
inPressMax = 225;
AmbientMax = 120;
inFlowMin = 10;
inFlowMax = 2000;
for aa = inTempMin:5:inTempMax
for bb = inPressMin:5:inPressMax
for cc = inFlowMin:10:inFlowMax
%Operating conditions, change whichever variable to aa and set the
%previous, Flow in SCFM; Ambient, InletTemp, and DewPoint in F; InletP in psi.
InletFlow = 100;
Ambient = 100;
InletTemp = aa;
InletPressUS = bb;
DewPoint = 38;
if InletPressUS < 725
hxRatio = 0.5;
else
hxRatio = 1;
end
%Define standard pressure (MPA)
standardPressure = 0.101325;
%Convert inlet pressure to MPa
InletP = convertPSItoMPa(InletPressUS) + standardPressure;
%Convert inlet and dewpoint temp from F to K
InletTempK = convertFtoK(InletTemp);
DewPointK = convertFtoK(DewPoint);
%Convert vol. flow to mass flow
massAirFlow = getAirMassFlowRateFromSCFM(InletFlow);
%Determine vapor pressure at inlet, function of InletTemp
vaporPressureInlet = getVaporPressure(InletTempK);
%Determine specific humidity at dryer inlet and outlet
specificHumidityEntering = getSpecificHumidity(InletTempK, InletP);
specificHumidityLeaving = getSpecificHumidity(DewPointK, InletP);
%Solve for condensate flowrate (= mass entering - mass leaving)
waterEntering = specificHumidityEntering * massAirFlow;
waterLeaving = specificHumidityLeaving * massAirFlow;
condensateMassFlow = waterEntering - waterLeaving;
%Calculate change in enthalpy (steam enthalpy entering - water enthalpy
%exiting
steamEnthalpy = getSteamEnthalpy(vaporPressureInlet, InletTempK);
waterEnthalpy = getWaterEnthalpy(DewPointK);
dEnthalpy = steamEnthalpy - waterEnthalpy;
%calculate energy required to condense water vapor (latent heat)
netEnergySteam = dEnthalpy * condensateMassFlow;
%calculate energy required to cool air (sensible heat)
netEnergyAir = coolDryAir(massAirFlow, InletTempK, DewPointK);
%Total energy is sum of sensible and latent
totalEnergyRequired = netEnergySteam + netEnergyAir;
%Convert to BTU/hr
energyRequired = totalEnergyRequired * 3415.179 * hxRatio;
sizingTablePower(1, aa/5 - ((inTempMin/5) - 1)) = aa;
sizingTablePower(2, aa/5 - ((inTempMin/5) - 1)) = energyRequired;
sizingTablePower(3, bb/5 - ((inPressMin/5) - 1)) = bb;
sizingTablePower(4, cc/10 - ((inFlowMin/10) - 1)) = cc;
end
end
end

Answers (0)

Categories

Find more on Thermal Analysis in Help Center and File Exchange

Tags

Products


Release

R2014a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!