diff --git a/.DS_Store b/.DS_Store index 4759423..90afdee 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/graph.js b/graph.js index b73bde0..93eec5b 100644 --- a/graph.js +++ b/graph.js @@ -15,8 +15,6 @@ var n = boundaries[meatType].length*2+1, // number of layers for(var i=0;i=boundaries[meatType][i])return i; - - } return 5; diff --git a/heat-diffusion.js b/heat-diffusion.js index 2da0b87..82db096 100644 --- a/heat-diffusion.js +++ b/heat-diffusion.js @@ -1,6 +1,7 @@ function HeatSolver(startingTemps){ var tempArray = [startingTemps]; + var D = .14; // in units of mm^2/sec var timestep = 1; @@ -208,7 +209,12 @@ var len= tempArray[0].length; var graphlabels = []; var temperatures = []; var count=0; - var maxTemps = tempArray[0]; + var maxTemps=[]; + for(var i=0;i"); + var clicked=false; + inputTable.change(function(){console.log("click"); model.buildData(); if(clicked){graph()}}) var displayDiv = $("
"); displayDiv.append(inputTable); // div.append(displayDiv); @@ -133,7 +136,7 @@ var perfectSteak = function (div) { var len = model.currentInfo["data"].length; var newData = [] // $("#cookButton").remove(); - + var sumtime=0; for (var i = 0; i < model.currentInfo["numRows"]; i++) { var iminus = i - 1; addButton = $(""); @@ -141,9 +144,19 @@ var perfectSteak = function (div) { flipButton = $(""); var row = $(""); - var minSecs=model.convertTime(i*model.timeStep); - console.log("minSecs"+minSecs) - var timeCol=$(""+minSecs+"") + if(i>0){ + var vals=parseFloat($("#row" + (i-1) + "time").val()); + + var info=$("#timeCol"+(i-1)).html(); + info = info.replace(":", ".").split('.'); + console.log(info); + vals=vals+60*parseFloat(info[0])+parseFloat(info[1]); + var minSecs=model.convertTime(vals); + } + else{ + var minSecs=model.convertTime(i*timeStep); + } + var timeCol=$(""+minSecs+""); var duration = $(""); var inp1 = $(""); var inp2 = $(""); @@ -152,28 +165,29 @@ var perfectSteak = function (div) { var step2Col = $(""); step2Col.append(inp2); step1Col.append(flipButton); - row.append(timeCol, duration, step1Col, step2Col); + row.append( timeCol,duration, step1Col, step2Col); inputTable.append(row); if (i == model.currentInfo["numRows"] - 1) { inputTable.append(addButton, subButton); // displayDiv.append(cookButton); } if (len == 0) { - + inp1.val(23); inp2.val(23); - model.dataAdd([parseFloat($("#row" + i + "time").val()), parseFloat($("#inp1_" + i).val()), parseFloat($("#inp2_" + i).val())]) - + model.dataAdd([parseFloat($("#row" + i + "time").val()), parseFloat($("#inp1_" + i).val()), parseFloat($("#inp2_" + i).val())]); + } else if (i <= len) { - + inp1.val(model.currentInfo["data"][i][1]); inp2.val(model.currentInfo["data"][i][2]); - + model.dataAdd([parseFloat($("#row" + i + "time").val()), parseFloat($("#inp1_" + i).val()), parseFloat($("#inp2_" + i).val())]) } else { inp1.val(model.currentInfo["data"][i - 1][1]); inp2.val(model.currentInfo["data"][i - 1][2]); + model.dataAdd([parseFloat($("#row" + i + "time").val()), parseFloat($("#inp1_" + iminus).val()), parseFloat($("#inp2_" + iminus).val())]) } timeFun(i); @@ -191,10 +205,19 @@ var perfectSteak = function (div) { flipButton = $(""); var row = $(""); var i = model.currentInfo["numRows"] - 1; - - var val=parseFloat($("#row" + (i-1) + "time").val())+model.timeStep; + if(i>0){ + var vals=parseFloat($("#row" + (i-1) + "time").val()); + + var info=$("#timeCol"+(i-1)).html(); + info = info.replace(":", ".").split('.'); + console.log(info); + vals=vals+60*parseFloat(info[0])+parseFloat(info[1]); + var minSecs=model.convertTime(vals); + } + else{ + var minSecs=model.convertTime(i*timeStep); + } - var minSecs=model.convertTime(i*model.timeStep); var timeCol=$(""+minSecs+""); var duration = $(""); var inp1 = $(""); @@ -233,7 +256,7 @@ var perfectSteak = function (div) { var subButtonFun = function () { subButton.on("click", function () { - console.log(model.currentInfo["data"]); + model.numRowsMinus(); model.buildData(); delRow(); @@ -247,12 +270,13 @@ var perfectSteak = function (div) { } }); }; - - var CookButtonFun = function () { - cookButton.on("click", function () { - d3.select("svg") +var graph=function(){ + d3.select("svg") + .remove(); + d3.select("svg") .remove(); model.dataClear(); + for (var e = 0; e < model.currentInfo["numRows"]; e++) { var curTime = parseFloat($("#row" + e + "time").val()); var cur1 = parseFloat($("#inp1_" + e).val()); @@ -289,7 +313,7 @@ var perfectSteak = function (div) { //add to on click and calculate(blah,blah,blah, meatType) var meatType = $("input[type='radio'][name='meat']:checked").attr('id'); - console.log(meatType); + //THIS WILL COOK THE STEAK IF WE HAVE VALID INPUTS if (OKtoCook==true){ var steak = [model.currentInfo["data"][0][1]]; @@ -299,6 +323,12 @@ var perfectSteak = function (div) { steak.push(model.currentInfo["data"][0][2]); calculate(model.currentInfo["data"], steak,meatType) } +} + var CookButtonFun = function () { + cookButton.on("click", function () { + clicked=true; + graph(); + }); } diff --git a/sample.js b/sample.js index dbbf47c..3fef99d 100644 --- a/sample.js +++ b/sample.js @@ -1,13 +1,10 @@ var calculate=function(data,steak,meatType){ - var myheatsolver = HeatSolver(steak); var Thedata=myheatsolver.sixty_graph_arrays_duration(data); - var sampledata=Thedata.temps; var flame=Thedata.points; var timestep=1/Thedata.step; var maxTemps=Thedata.maxTemps; - console.log(maxTemps); graphSteak(sampledata,flame,timestep,meatType,maxTemps); } \ No newline at end of file