//Useful Websites // http://math.stackexchange.com/questions/406082/numerical-method-to-solve-a-trigonometric-cotangent-function-transient-heat // http://web.cecs.pdx.edu/~gerry/epub/pdf/transientConductionSphere.pdf // http://web.cecs.pdx.edu/~gerry/epub/ //Global Variables for Turkey density = 996; // kg/m3 Assuming Density of Water 1000 kg/m3 cp = 2810 // J/kg K for Turkey heatConvection = 5; // W/m2 K Some Reasonable estimate for natural Convection. Change as needed. 5-25 thermalConduct = 0.412 // W/m K function celsiusToFarenheit(celsius) { farenheit = (celsius*(9/5)) + 32; return(farenheit) } function poundsToKilograms(pounds) { kilograms = (pounds * 0.453592); return(kilograms) } function findClosest(value,array) { closestDiff = null; closestPosition = null; for (var i=0;i errorTolerance && antiFreeze<=500) { //The greater the antiFreeze, the more wasted cycles around a singularity lambdaN = (min+max)/2 result=lambdaFormula(lambdaN, Biot) if (Math.abs(result) <= errorTolerance && 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; } antiFreeze++ } } } function lambdaFormula(lambdaN, Biot) { result = 1-lambdaN*(1/Math.tan(lambdaN))-Biot; return(result) } function oven() { this.tempInfini=0; //C this.setTemp = 0; var proportional = 0.01; // This value is arbitrary to how fast you want the temperatures to converge. (Or oscillate, which could be realistic as well) var errorTolerance = 1; //Stove is accurate to 1 degree Celcius Should hopefully oscillate below that value. this.changeTemp = function(setTemp) { this.setTemp = setTemp; } this.equalizeTemp = function() { // Equalize Temp will need to be sent each time iteration var error = Math.abs(this.setTemp-this.tempInfini); if (this.setTemp>this.tempInfini) { this.tempInfini = this.tempInfini + error*proportional; } else if (this.setTemperrorTolerance) { return (true) //Need to run the Heat Calculations again next cycle } } } ovenObject = new oven (); function Turkey(weight,time) { totalRadius = calculateRadius(weight) function Layer(name) { this.name = name this.temperature = 20; this.waterContent =100; this.Qdot = 0; } skin= new Layer("Skin") body = new Layer("Body") core = new Layer("Core") skin.temperature = lumpedCapacitance(totalRadius,totalRadius*0.85,skin.temperature,ovenTemp,airConvection,time)[0] body.temperature = lumpedCapacitance(totalRadius*0.85,totalRadius*0.30,body.temperature,skin.temperature,airConvection*1000,time)[0] core.temperature = lumpedCapacitance(totalRadius*0.30,0,core.temperature,body.temperature,airConvection*1000,time)[0] } function transientSphereSeries (rPosition,rTotal,tempInitial,tempInfini,t) { var sum=0; var alpha = thermalConduct/(density*cp) console.log("Alpha is " + alpha) var Fourier = (alpha*t)/Math.pow(rTotal,2) console.log("Fourier is " + Fourier) var biotNum = heatConvection * rTotal/thermalConduct console.log("The Biot Value is " + biotNum) var min = 0; var max = 1000; lambdaTerms=findAllRootsAlternative (min,max,max*Math.PI*10,biotNum) for (var i = 0; i