From 654da49e2dbf0bcca7194cf9f686829d748ea412 Mon Sep 17 00:00:00 2001 From: Scott Mobley Date: Sat, 9 Nov 2013 01:39:18 -0800 Subject: [PATCH] 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. --- js/CookingFormula.js | 81 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 2 deletions(-) diff --git a/js/CookingFormula.js b/js/CookingFormula.js index 11895a0..45864fd 100644 --- a/js/CookingFormula.js +++ b/js/CookingFormula.js @@ -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 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); 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