forked from laurabreiman/science-of-cooking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.js
56 lines (47 loc) · 1.53 KB
/
sample.js
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
/*
calculate: function that takes in data about the meat that is cooking and restructures
it into graphable data arrays and values that are then displayed to the screen
with the function graphSteak
*/
var calculate=function(data,steak,meatType,first,totalTime,mode){
//sets the parameters for the iterations of the diffusion equations.
//parameters are initially set to a timestep of 1 second and a spacestep of 1mm,
//but these can be increased with minimal error if calculation time is too great
console.log("calc");
var toC=function(F)
{
return ((5/9)*(F-32));
}
if(mode=='F'){
for(var i=0;i<data.length;i++)
{
data[i][1]=toC(data[i][1]);
data[i][2]=toC(data[i][2]);
}
console.log(data);
}
var timestep = 1;
var spacestep = 1;
var myheatsolver = HeatSolver(steak,timestep,spacestep);
var Thedata=myheatsolver.sixty_graph_arrays_duration(data);
if(meatType=='False'){
var sampledata=Thedata.temps;
}
else{
var sampledata=Thedata.allMaxTemps.slice(1,Thedata.allMaxTemps.length);
for(var i=0;i<sampledata.length;i++)
{
sampledata[i]=sampledata[i].slice(1,sampledata[i].length-1);
}
}
var flame=Thedata.points;
var timestep=1/Thedata.step;
var maxTemps=Thedata.maxTemps;
/* if(first){
drawFinished(meatType,maxTemps,data,steak[0],0,(steak.length-2)/10,'C');
drawFinished(meatType,maxTemps,data,steak[0],1,(steak.length-2)/10,'C');
}
*/
if(!first){
graphSteak(sampledata,flame,timestep,meatType,maxTemps,mode);}
}