Browse Source

Added a Bisection function that works for Biot values of 1, which unfortunately is not good enough. Better, but not much better than the previous transient model.

formula
Scott Mobley 11 years ago
parent
commit
654da49e2d
  1. 81
      js/CookingFormula.js

81
js/CookingFormula.js

@ -51,7 +51,7 @@ console.log("Simple Radius " + simpleRadius + " Meters") @@ -51,7 +51,7 @@ console.log("Simple Radius " + simpleRadius + " Meters")
console.log("Complex Radius " + complexRadius + " Meters")
}
function LumpedCapacitanceMethod (radiusTotal,radiusInner tempInitial,tempInfini, t) {
function LumpedCapacitanceMethod (radiusTotal,radiusInner,tempInitial,tempInfini, t) {
name : "Skin"
volume = (4/3)*Math.PI*Math.pow(radiusTotal,3) - (4/3)*Math.PI*Math.pow(radiusInner,3); //3D Sphere
surfaceArea = 4*Math.PI*Math.pow(radiusTotal,2); //3D Sphere
@ -77,7 +77,7 @@ Qdot = -1*heatConvection*surfaceArea*(tempAtTime-tempInfini) //Heat Transfer Rat @@ -77,7 +77,7 @@ Qdot = -1*heatConvection*surfaceArea*(tempAtTime-tempInfini) //Heat Transfer Rat
console.log("The Heat Flux is " + Qdot )
}
function transientSphere (rPosition,rTotal,tempInitial,tempInfini,t) {
function transientSphereOneTerm (rPosition,rTotal,tempInitial,tempInfini,t) {
heatConvection = 12; // W/m2 K Some Reasonable estimate for natural Convection. Change as needed. 5-25
thermalConduct = 0.412 // W/m K
alpha = thermalConduct/(density*cp)
@ -124,4 +124,81 @@ sinPortion= Math.sin(lambdaOne*rPosition/rTotal)/(lambdaOne*rPosition/rTotal); @@ -124,4 +124,81 @@ sinPortion= Math.sin(lambdaOne*rPosition/rTotal)/(lambdaOne*rPosition/rTotal);
expotentialPortion = alphaOne*(1/Math.exp(Math.pow(lambdaOne,2)*Fourier))
tempAtTimeAndRadius=(sinPortion*expotentialPortion*(tempInitial-tempInfini))+tempInfini
console.log("The Temperature At radius " + rPosition +" m and time " + t + " seconds is " + tempAtTimeAndRadius + " C or " + celsiusToFarenheit(tempAtTimeAndRadius) + " F" );
}
function findAllRoots (Biot) {
limit = 11; //Terms to Compute too
storage = [];
for (var k=0; k<=limit; k++) {
minK = (k+0.5)*Math.PI;
maxK = (k+1)*Math.PI;
answer = bisectionMethod(minK,maxK,Biot);
if (answer !=null) {
storage.push(answer);
}
}
console.log(storage)
return(storage)
}
function bisectionMethod(min,max,Biot) {
errorTolerance = (1/Math.pow(10,8))
result = 100 // some large value to ensure the calculation goes through.
negativeTest =lambdaFormula(min, Biot)*lambdaFormula(max, Biot)
if (negativeTest <=0 ) {
while (Math.abs(result) > errorTolerance) {
lambdaN = (min+max)/2
result=lambdaFormula(lambdaN, Biot)
if (Math.abs(result) <= errorTolerance) {
return (lambdaN); //At Root
}
else if ((lambdaFormula(min, Biot)*lambdaFormula(lambdaN, Biot))>=0) {
min=lambdaN;
}
else if ((lambdaFormula(max, Biot)*lambdaFormula(lambdaN, Biot))>=0) {
max=lambdaN;
}
}
return (lambdaN);
}
else
{
//console.log("No Bracketed Root " + negativeTest)
}
}
function lambdaFormula(lambdaN, Biot) {
result = 1-lambdaN*(1/Math.tan(lambdaN))-Biot;
return(result)
}
function transientSphereSeries (rPosition,rTotal,tempInitial,tempInfini,t) {
heatConvection = 6000; // W/m2 K Some Reasonable estimate for natural Convection. Change as needed. 5-25
thermalConduct = 20 // W/m K
//alpha = thermalConduct/(density*cp)
alpha = 6.66 * (1/Math.pow(10,6))
console.log("Alpha is " + alpha)
sum=0;
Fourier = (alpha*t)/Math.pow(rTotal,2)
console.log("Fourier is " + Fourier)
biotNum = heatConvection * rTotal/thermalConduct
console.log("The Biot Value is " + biotNum)
lambdaTerms = findAllRoots(biotNum)
for (var i = 0; i<lambdaTerms.length; i++) {
lambdaN = lambdaTerms[i]
sinPortion= Math.sin(lambdaN*rPosition/rTotal)/(lambdaN*rPosition/rTotal);
exponentialPortion = (1/Math.exp(Math.pow(lambdaN,2)*Fourier))
frontCoefficientPortion = 4*(Math.sin(lambdaN)-(lambdaN*Math.cos(lambdaN)))/ (2*lambdaN-Math.sin(2*lambdaN))
sum = frontCoefficientPortion*exponentialPortion*sinPortion + sum
}
tempAtTimeAndRadius=(sum*(tempInitial-tempInfini))+tempInfini
console.log("The Temperature at radius " + rPosition + " m and time " + t + " seconds is " + tempAtTimeAndRadius + " C or " + celsiusToFarenheit(tempAtTimeAndRadius) + " F");
}
Loading…
Cancel
Save