Foam TCalcs
Quick Start
From an analysis of the temperature dependence of foam conductivity, you can learn a lot about your foam.
Credits
This app was developed for the Science of (PU) Foam with Dr Grażyna Mitchener.
Foam TCalcs
//One universal basic required here to get things going once loaded
window.onload = function () {
//restoreDefaultValues(); //Un-comment this if you want to start with defaults
Main();
};
//Main() is hard wired as THE place to start calculating when inputs change
//It does no calculations itself, it merely sets them up, sends off variables, gets results and, if necessary, plots them.
function Main() {
//Save settings every time you calculate, so they're always ready on a reload
saveSettings();
//Send all the inputs as a structured object
//If you need to convert to, say, SI units, do it here!
const inputs = {
Tlo: sliders.SlideTlo.value,
Thi: sliders.SlideThi.value,
Klo: sliders.SlideKlo.value,
Khi: sliders.SlideKhi.value,
Kgas: sliders.SlideKgas.value,
Ksolid: sliders.SlideKsolid.value,
rhorel: sliders.Sliderhorel.value,
};
//Send inputs off to CalcIt where the names are instantly available
//Get all the resonses as an object, result
const result = CalcIt(inputs);
//Set all the text box outputs
document.getElementById('Ks').value = result.Ks;
document.getElementById('Kr').value = result.Kr;
document.getElementById('g').value = result.g;
//Do all relevant plots by calling plotIt - if there's no plot, nothing happens
//plotIt is part of the app infrastructure in app.new.js
if (result.plots) {
for (let i = 0; i < result.plots.length; i++) {
plotIt(result.plots[i], result.canvas[i]);
}
}
//You might have some other stuff to do here, but for most apps that's it for Main!
}
//Here's the app calculation
function CalcIt({ Tlo, Thi, Klo, Khi, Kgas, Ksolid,rhorel }) {
let Ks=5, Kr=3, g=0.66
let pTot=[], pGas=[], pSR=[],pK3=[],pK3ex=[]
pTot.push({x:Tlo,y:Klo})
pTot.push({x:Thi,y:Khi})
pGas.push({x:Tlo,y:(Kgas-0.075*(25-Tlo))*(1-rhorel)})
pGas.push({x:Thi,y:(Kgas+0.075*(Thi-25))*(1-rhorel)})
const loVal=Klo-(Kgas-0.075*(25-Tlo))
const hiVal=Khi-(Kgas+0.075*(Thi-25))
const Tlo3=Math.pow(Tlo+273,3)/1e6
const Thi3=Math.pow(Thi+273,3)/1e6
const slope=(hiVal-loVal)/(Thi3-Tlo3)
const intercept=loVal-slope*Tlo3
const KSR25=loVal+slope*(Math.pow(298,3)/1e6-Tlo3)
Ks=intercept
Kr=KSR25-Ks
g=Ks/(Ksolid*rhorel)
pSR.push({x:Tlo,y:loVal})
pSR.push({x:Thi,y:hiVal})
pK3.push({x:Tlo3,y:loVal})
pK3.push({x:Thi3,y:hiVal})
pK3ex.push({x:Tlo3,y:loVal})
pK3ex.push({x:0,y:intercept})
const plotData = [pTot,pGas,pSR]
const plotData1 = [pK3,pK3ex]
const lineLabels = ["Total","Gas", "S+R"]
const lineLabels1 = ["S+R","Extrapolated"]
const myColors = ["blue","orange","green"]
const myColors1 = ["green","gray"]
const borderWidth = [2,2]
//Now set up all the graphing data detail by detail.
const prmap = {
plotData: plotData, //An array of 1 or more datasets
lineLabels: lineLabels, //An array of labels for each dataset
colors: myColors, //An array of colors for each dataset
hideLegend: false,
borderWidth: borderWidth,
xLabel: 'T&°C', //Label for the x axis, with an & to separate the units
yLabel: 'K&mW/mK', //Label for the y axis, with an & to separate the units
y2Label: null, //Label for the y2 axis, null if not needed
yAxisL1R2: [], //Array to say which axis each dataset goes on. Blank=Left=1
logX: false, //Is the x-axis in log form?
xTicks: undefined, //We can define a tick function if we're being fancy
logY: false, //Is the y-axis in log form?
yTicks: undefined, //We can define a tick function if we're being fancy
legendPosition: 'top', //Where we want the legend - top, bottom, left, right
xMinMax: [,], //Set min and max, e.g. [-10,100], leave one or both blank for auto
yMinMax: [,], //Set min and max, e.g. [-10,100], leave one or both blank for auto
y2MinMax: [,], //Set min and max, e.g. [-10,100], leave one or both blank for auto
xSigFigs: 'F0', //These are the sig figs for the Tooltip readout. A wide choice!
ySigFigs: 'F2', //F for Fixed, P for Precision, E for exponential
};
const prmap1 = {
plotData: plotData1, //An array of 1 or more datasets
lineLabels: lineLabels1, //An array of labels for each dataset
dottedLine:[false,true],
colors: myColors1, //An array of colors for each dataset
hideLegend: false,
borderWidth: borderWidth,
xLabel: 'T³/1e6&K³', //Label for the x axis, with an & to separate the units
yLabel: 'K&mW/mK', //Label for the y axis, with an & to separate the units
y2Label: null, //Label for the y2 axis, null if not needed
yAxisL1R2: [], //Array to say which axis each dataset goes on. Blank=Left=1
logX: false, //Is the x-axis in log form?
xTicks:undefined,
logY: false, //Is the y-axis in log form?
yTicks: undefined, //We can define a tick function if we're being fancy
legendPosition: 'top', //Where we want the legend - top, bottom, left, right
xMinMax: [0,], //Set min and max, e.g. [-10,100], leave one or both blank for auto
yMinMax: [0,], //Set min and max, e.g. [-10,100], leave one or both blank for auto
y2MinMax: [,], //Set min and max, e.g. [-10,100], leave one or both blank for auto
xSigFigs: 'F0', //These are the sig figs for the Tooltip readout. A wide choice!
ySigFigs: 'F2', //F for Fixed, P for Precision, E for exponential
};
//Now we return everything - text boxes, plot and the name of the canvas, which is 'canvas' for a single plot
return {
plots: [prmap, prmap1],
canvas: ['canvas', 'canvas1'],
Ks: (Ks).toFixed(1) ,
Kr: (Kr).toFixed(1) ,
g: (g).toFixed(2) ,
};
}
Insights from T-dependent conductivity
If you set up your conductivity machine to measure at, say, 0, 10, 20, 30 °C you can learn a lot about your system. In the app, for simplicity we use only conductivities at Tlo and Thi; use your real dataset and common sense to create these values.
First, you need to know the conductivity of the gas(es) in the cells at a reference temperature of 25 °C. CO2 = 16.6, Air = 26.2, Pentane = 14.4 (this is a virtual number). If you have, say, a CO2/Air mix then you can take the weighted average - that will be good enough.
The reason for providing the gas conductivity reference is that we can then calculate its conductivity at the Lo and Hi temperatures you've specified and can then subtract those values from the measured total conductivity. The values that remain once the gas has been subtracted are the combined solid (S) and radiative (R) values. Already it's interesting to see how the majority of your change of conductivity with temperature is due to the gas conductivity.
Because the radiative component falls of as T³ (when T is in K), we can extrapolate the T³ plot to 0K and this gives us the solid conductivity, KS. Returning to 25 °C we can then work out what the radiative componenent, KR is at this temperature. Purists will note that KS is assumed to be a constant - the errors from this assumption are generally assumed to be small.
We can calculate one more parameter. KS depends on the conductivity of the pure solid, the relative density ρrel and a factor g which is 1/3 for pure struts and 2/3 for a strutless foam.
`K_S=gK_"Solid"ρ_"rel"`
Therefore we can estimate g from our calculated KS and our input values of ρrel and KSolid. If g is in the range 0.4 to 0.7 the chances are that it is valid. If it is higher or lower that's saying that something in your data or assumptions is wrong. For example, if you assume that your gas is pure CO2 when it contains, say, 20% air, then your gas subtraction is wrong and g will be incorrect.
Pentanes
It is well known that the conductivity of a pentane foam falls, then rises, as the temperature is lowered. At lower temperatures (typically below 15 °C), the cells contain liquid pentane which has a higher conductivity. So to use this technique for a pentane foam you need to measure values from, say, 20 to 45 °C. Although 20 is below the BPt of pentanes, data still seem to be reasonably linear, presumably because the cells are at a relatively low pressure so pentane is still volatile.
How reliable is this procedure?
There are a bunch of assumptions behind all this, so any single dataset should be considered with caution. The point is that if you use the system regularly with your different formulations, you should start seeing patterns of how KS and KR vary, allowing you insights into the subtle properties of your foams.