private static double CalculateViscosity(ArrayList materialComponents, double temperature, SubstanceState state) { double viscosity = 0.0; double visc; double molarWt; double moleFrac; double massFrac; double numerator = 0.0; double denominator = 0.0; foreach (MaterialComponent mc in materialComponents) { Substance s = mc.Substance; ThermalPropsAndCoeffs tpc = s.ThermalPropsAndCoeffs; molarWt = s.MolarWeight; moleFrac = mc.GetMoleFractionValue(); massFrac = mc.GetMassFractionValue(); if (moleFrac == Constants.NO_VALUE) { moleFrac = massFrac; } if (state == SubstanceState.Gas) { if (s.Name == "Air") { visc = ThermalPropCalculator.CalculateAirGasViscosity(temperature); } else { visc = ThermalPropCalculator.CalculateGasViscosity(temperature, tpc.GasViscCoeffs); } numerator += visc * moleFrac * Math.Sqrt(molarWt); denominator += moleFrac * Math.Sqrt(molarWt); } else if (state == SubstanceState.Liquid) { visc = ThermalPropCalculator.CalculateLiquidViscosity(temperature, tpc.LiqViscCoeffs); numerator += moleFrac * Math.Log10(visc); } } if (state == SubstanceState.Gas) { if (denominator > 1.0e-8) { viscosity = numerator / denominator; } } else if (state == SubstanceState.Liquid) { viscosity = Math.Pow(10, numerator); } return(viscosity); }