Foam Formulation
Quick Start
Each part of a foam formulation plays a role. Here you can juggle each part and find the weight of each component required for your lab batch.
Credits
This app was developed for the Science of (PU) Foam with Dr Grażyna Mitchener.
Foam Formulation
//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 = {
g: sliders.Slideg.value,
Pmeq: sliders.SlidePmeq.value,
Nmeq: sliders.SlideNmeq.value,
Index: sliders.SlideIndex.value,
rho: sliders.Sliderho.value,
T: sliders.SlideT.value,
PercC: sliders.SlidePercC.value/100, //To fraction
PercS: sliders.SlidePercS.value/100, //To fraction
PercW: sliders.SlidePercW.value/100, //To fraction
};
//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('Water').value = result.Water;
document.getElementById('Polyol').value = result.Polyol;
document.getElementById('MDI').value = result.MDI;
document.getElementById('Catalyst').value = result.Catalyst;
document.getElementById('Surfactant').value = result.Surfactant;
document.getElementById('WaterPO').value = result.WaterPO;
}
//Here's the app calculation
//The inputs are just the names provided - their order in the curly brackets is unimportant!
//By convention the input values are provided with the correct units within Main
function CalcIt({ g, Pmeq, Nmeq, Index, rho, T, PercC, PercS, PercW}) {
const MWt= 18, gk=g/1000
const Volg=1/rho*(gk-rho/1200*gk)
const Ideal=24000 //Ideal gas at 20
let Water=1e6*Volg/Ideal*MWt*293/(273+T) //1000 to l then 1000 to g
Index*=Pmeq/Nmeq
const Cwt=PercC*g, Swt=PercS*g, gx=g-Cwt-Swt-Water
const Polyol=(1+PercW)*gx/(1+Index), MDI=Polyol/(1+PercW)*Index
const WaterPO=Polyol*PercW
Water-=WaterPO
//Now we return everything - text boxes, plot and the name of the canvas, which is 'canvas' for a single plot
return {
Water: (Water).toFixed(2),
WaterPO: (WaterPO).toFixed(2),
Polyol: (Polyol).toFixed(2),
MDI: (MDI).toFixed(2),
Catalyst: (Cwt).toFixed(2),
Surfactant: (Swt).toFixed(2),
};
}
Our aim is a foam with a desired density ρ, of a chosen g of formulation, blown by water and with, for reasons connected to other properties, a chosen Index. Our polyol has a known milliequivalents meq/g (56.1/LOH) and the equivalent isocyanate value.
The volume of CO2 created depends on the effective blowing temperature T. We add % of catalyst and surfactant. The polyol already contains a known % water.
The outputs are the required weights of each of the components, with the key value being the Extra Water to be added beyond the shown amount from the polyol.