-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnetFlow.m
69 lines (52 loc) · 2.34 KB
/
netFlow.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function res = netFlow(~, params) %doesn't account for mass loss because we are bad and everything sucks.
params = params.';
airSA = (.04^2 * pi) - (.02^2 * pi); %surface area in contact with air
mugSA = airSA*1.2;%temp SA
massOfBar = params(1);
barEnergy = params(3);
emissivity = params(4);
specificHeatBar = params(5);
thermalConductivity = params(7);
mugThickness = params(8);
liquidEnergy = params(10);
liquidMass = params(11);
specificHeatLiquid = params(13);
thermalConductivitySteam = params(14);
thicknessSteam = params(15);
steamSA = params(16);
barTemp = energyToTemperature(barEnergy, massOfBar, specificHeatBar);
liquidTemp = energyToTemperature(liquidEnergy, liquidMass, specificHeatLiquid);
thermalHeatCoefficient = 10;%shitshitshitshitshitshitshitshitshitshitshitshit
conductionLHL = thermalConductivity * mugSA * ( liquidTemp - 290) / mugThickness;
convectionLHL = thermalHeatCoefficient * airSA * (liquidTemp - 290);
flowParams = zeros(1, length(params));
flowParamsLHL = -(conductionLHL + convectionLHL);
deltaT = energyToTemperature(barEnergy, massOfBar, specificHeatBar) - energyToTemperature(liquidEnergy, liquidMass, specificHeatLiquid);
conductionBTL = thermalConductivitySteam * steamSA * deltaT / thicknessSteam;
deltaRT = barTemp^4 - liquidTemp^4;
radiation = emissivity * 5.67 * 10^(-8) * deltaRT * steamSA * .9;%not all radiation goes directly to water
deltaEnergy = liquidEnergy - temperatureToEnergy(373, liquidMass, specificHeatLiquid);
massChange = [0, 0];
if deltaEnergy > 0
massChange = -phaseChange(deltaEnergy, params);
end
flowParams(3) = (-conductionBTL - radiation);
flowParams(10) = (conductionBTL + radiation + flowParamsLHL + massChange(1));
flowParams(11) = massChange(2);
res = flowParams.';
% display(conductionBTL);
% display(radiation);
% display(massChange(1));
display(liquidTemp);
display(conductionLHL);
% display(convectionLHL);
end
function res = energyToTemperature(U, m, c)
res = U / heatCapacity(m,c);
end
function res = heatCapacity(mass, specificHeat)
res = mass * specificHeat;
end
function res = temperatureToEnergy( T, m, c)
res = T * heatCapacity(m,c);
end