private void ExtractCoeffs() { FileStream fsRead = null; try { //char[] separator1 = { '>' }; //string[] separator1 = { "</td>" }; //char[] emptySeparator = { ' ' }; //char[] separators = { '>', '<' }; string[] separatorsStr1 = { "</td>" }; string[] separatorsStr2 = { "<i>", "</i>" }; //string[] subStrs; //string formula; string name; string casRegestryNo; double a, b, c, d = 1, e = 1; double molarWeight, criticalRho, criticalT, criticalP, criticalV, criticalComp, accentricF; molarWeight = criticalRho = criticalT = criticalP = criticalV = criticalComp = accentricF = -2147483D; double minTemp = 1, maxTemp = 1; //StringBuilder sb; CriticalPropsAndAcentricFactor criticalProps; Substance substance; YawsGasCpCorrelation gasCpCorrelation; YawsLiquidCpCorrelation liquidCpCorrelation; YawsSolidCpCorrelation solidCpCorrelation; YawsGasThermalConductivityCorrelation gasKCorrelation; YawsLiquidThermalConductivityCorrelation liquidKCorrelation; YawsGasViscosityCorrelation gasViscCorrelation; YawsLiquidViscosityCorrelation liquidViscCorrelation; YawsLiquidDensityCorrelation liquidDensityCorrelation; YawsEvaporationHeatCorrelation evapHeatCorrelation; YawsVaporPressureCorrelation vapPressureCorrelation; YawsSurfaceTensionCorrelation surfaceTensionCorrelation; YawsEnthalpyOfFormationCorrelation enthalpyOfFormationCorrelation; substanceList = new ArrayList(); gasCpCorrList = new ArrayList(); liquidCpCorrList = new ArrayList(); solidCpCorrList = new ArrayList(); evapHeatCorrList = new ArrayList(); vapPressureCorrList = new ArrayList(); liquidDensityCorrList = new ArrayList(); gasKCorrList = new ArrayList(); liquidKCorrList = new ArrayList(); gasViscCorrList = new ArrayList(); liquidViscCorrList = new ArrayList(); surfaceTensionCorrList = new ArrayList(); enthalpyOfFormationCorrList = new ArrayList(); string line1, line2, lineTemp; //string elementStr; //string tmpStr; //int elementCount; int fileNo = 0; int substanceNo = 0; int counter; int totalCounter = 0; StreamReader reader; foreach (object fullFileName in listBoxFiles.Items) { fileNo++; counter = 0; fsRead = new FileStream((string)fullFileName, FileMode.Open, FileAccess.Read); reader = new StreamReader(fsRead); line1 = reader.ReadLine(); while (!reader.EndOfStream && counter < 50) { line2 = reader.ReadLine(); name = ""; if (thermProp != ThermPropType.CriticalProp) { if (line1.Contains("<a border")) { counter++; name = MainFormYaws.ExtractName(line2, separatorsStr1, separatorsStr2); lineTemp = reader.ReadLine(); lineTemp = reader.ReadLine(); lineTemp = reader.ReadLine(); lineTemp = reader.ReadLine(); a = MainFormYaws.ExtractValue(lineTemp, separatorsStr1); if (a == -2147483D) { continue; } lineTemp = reader.ReadLine(); b = MainFormYaws.ExtractValue(lineTemp, separatorsStr1); lineTemp = reader.ReadLine(); c = MainFormYaws.ExtractValue(lineTemp, separatorsStr1); if (thermProp == ThermPropType.GasCp || thermProp == ThermPropType.LiquidCp || thermProp == ThermPropType.VapPressure || thermProp == ThermPropType.LiquidDensity || thermProp == ThermPropType.LiquidDensity || thermProp == ThermPropType.LiquidVisc) { lineTemp = reader.ReadLine(); d = MainFormYaws.ExtractValue(lineTemp, separatorsStr1); } if (thermProp == ThermPropType.GasCp || thermProp == ThermPropType.VapPressure) { lineTemp = reader.ReadLine(); e = MainFormYaws.ExtractValue(lineTemp, separatorsStr1); } lineTemp = reader.ReadLine(); minTemp = MainFormYaws.ExtractValue(lineTemp, separatorsStr1); lineTemp = reader.ReadLine(); maxTemp = MainFormYaws.ExtractValue(lineTemp, separatorsStr1); if (thermProp == ThermPropType.GasCp) { gasCpCorrelation = new YawsGasCpCorrelation(name, a, b, c, d, e, minTemp, maxTemp); gasCpCorrList.Add(gasCpCorrelation); } else if (thermProp == ThermPropType.LiquidCp) { liquidCpCorrelation = new YawsLiquidCpCorrelation(name, a, b, c, d, minTemp, maxTemp); liquidCpCorrList.Add(liquidCpCorrelation); } else if (thermProp == ThermPropType.SolidCp) { solidCpCorrelation = new YawsSolidCpCorrelation(name, a, b, c, minTemp, maxTemp); solidCpCorrList.Add(solidCpCorrelation); } else if (thermProp == ThermPropType.EvapHeat) { evapHeatCorrelation = new YawsEvaporationHeatCorrelation(name, a, b, c, minTemp, maxTemp); evapHeatCorrList.Add(evapHeatCorrelation); } else if (thermProp == ThermPropType.VapPressure) { vapPressureCorrelation = new YawsVaporPressureCorrelation(name, a, b, c, d, e, minTemp, maxTemp); vapPressureCorrList.Add(vapPressureCorrelation); } else if (thermProp == ThermPropType.LiquidDensity) { liquidDensityCorrelation = new YawsLiquidDensityCorrelation(name, a, b, c, d, minTemp, maxTemp); liquidDensityCorrList.Add(liquidDensityCorrelation); } else if (thermProp == ThermPropType.GasVisc) { gasViscCorrelation = new YawsGasViscosityCorrelation(name, a, b, c, minTemp, maxTemp); gasViscCorrList.Add(gasViscCorrelation); } else if (thermProp == ThermPropType.LiquidVisc) { liquidViscCorrelation = new YawsLiquidViscosityCorrelation(name, a, b, c, d, minTemp, maxTemp); liquidViscCorrList.Add(liquidViscCorrelation); } else if (thermProp == ThermPropType.GasK) { gasKCorrelation = new YawsGasThermalConductivityCorrelation(name, a, b, c, minTemp, maxTemp); gasKCorrList.Add(gasKCorrelation); } else if (thermProp == ThermPropType.LiquidK) { liquidKCorrelation = new YawsLiquidThermalConductivityCorrelation(name, a, b, c, minTemp, maxTemp); liquidKCorrList.Add(liquidKCorrelation); } else if (thermProp == ThermPropType.SurfaceTension) { surfaceTensionCorrelation = new YawsSurfaceTensionCorrelation(name, a, b, c, minTemp, maxTemp); surfaceTensionCorrList.Add(surfaceTensionCorrelation); } else if (thermProp == ThermPropType.EnthalpyOfFormation) { enthalpyOfFormationCorrelation = new YawsEnthalpyOfFormationCorrelation(name, a, b, c, minTemp, maxTemp); enthalpyOfFormationCorrList.Add(enthalpyOfFormationCorrelation); } } line1 = line2; } else { substanceNo = totalCounter + counter + 1; if ((line1.StartsWith(substanceNo.ToString() + "</td><td align=") || //since there is a duplicate for No. 3976 this condition must be added to handle it line1.StartsWith((substanceNo - 1).ToString() + "</td><td align=")) && counter < 50) { counter++; name = MainFormYaws.ExtractName(line2, separatorsStr1, separatorsStr2); lineTemp = reader.ReadLine(); //if (lineTemp.StartsWith(" ")) { // casRegestryNo = ""; //} //else { // subStrs = lineTemp.Trim().Split(separatorsStr1, StringSplitOptions.RemoveEmptyEntries); // casRegestryNo = subStrs[0].Trim(); //} casRegestryNo = MainFormYaws.ExtractCasNo(lineTemp, separatorsStr1); lineTemp = reader.ReadLine(); substanceFormula = ExtractSubstanceFormula(lineTemp); //for debugging use only //formula = sb.ToString(); lineTemp = reader.ReadLine(); molarWeight = MainFormYaws.ExtractValue(lineTemp, separatorsStr1); lineTemp = reader.ReadLine(); criticalT = MainFormYaws.ExtractValue(lineTemp, separatorsStr1); lineTemp = reader.ReadLine(); criticalP = MainFormYaws.ExtractValue(lineTemp, separatorsStr1); lineTemp = reader.ReadLine(); criticalV = MainFormYaws.ExtractValue(lineTemp, separatorsStr1); lineTemp = reader.ReadLine(); //skip critical density since it can be obtained from critical volume and molar weight //subStrs = lineTemp.Trim().Split(separators); //criticalRho = double.Parse(subStrs[0]); lineTemp = reader.ReadLine(); criticalComp = MainFormYaws.ExtractValue(lineTemp, separatorsStr1); lineTemp = reader.ReadLine(); accentricF = MainFormYaws.ExtractValue(lineTemp, separatorsStr1); criticalProps = new CriticalPropsAndAcentricFactor(criticalT, criticalP, criticalV, criticalComp, accentricF); substance = new Substance(name, substanceType, casRegestryNo, substanceFormula, molarWeight, criticalProps); substanceList.Add(substance); } line1 = line2; } } totalCounter = totalCounter + counter; reader.Close(); fsRead.Close(); } } catch (Exception ex) { Console.WriteLine("The process failed: {0}", ex.ToString()); } finally { if (fsRead != null) { fsRead.Close(); } } if (thermProp == ThermPropType.CriticalProp) { PersistSubstances(); } else { PersistProp(thermProp); UnpersistProp(thermProp); } }
override internal void ExtractCoeffs(ListBox listBox, SubstanceType substanceType, ThermPropType thermProp) { if ((prevThermalProp != thermProp) || (prevThermalProp == thermProp && prevSubstanceType == substanceType)) { propList.Clear(); } ThermalPropCorrelationBase thermalPropCorrelation; string[] separatorsStr1 = { "<TD class=BorderHelper noWrap>", "<TD class=BorderBottomHelper noWrap>", "</TD>" }; string[] separatorsStr2 = { "<I>", "</I>" }; string[] separatorsStr3 = { "<TD class=BorderHelper>", "<TD class=BorderBottomHelper>", "</TD>" }; string[] separatorsStr4 = { "<SUB>", "</SUB>" }; string name; string casRegestryNo; string state = ""; double a, b, c, d = 1, e = 1, f, g; //, bp = 1; double molarWeight, freezingPoint, boilingPoint, criticalT, criticalP, criticalV, criticalComp, acentricF; molarWeight = freezingPoint = boilingPoint = criticalT = criticalP = criticalV = criticalComp = acentricF = -2147483D; double minTemp = 1, maxTemp = 1; string line1, line2, line3, lineTemp; bool isStartOfData; CriticalPropsAndAcentricFactor criticalProps; Substance substance; SubstanceFormula substanceFormula; StreamReader reader; FileStream fsRead = null; try { foreach (object fullFileName in listBox.Items) { fsRead = new FileStream((string)fullFileName, FileMode.Open, FileAccess.Read); reader = new StreamReader(fsRead); lineTemp = reader.ReadLine().Trim(); line1 = lineTemp; while (!reader.EndOfStream) { isStartOfData = false; if (line1.StartsWith("<TD class=BorderHelper>") || line1.Contains("SUB")) { isStartOfData = true; //need to repair the first line some times if (!line1.EndsWith("</TD>")) { while (!line1.EndsWith("</TD>")) { line1 += " " + reader.ReadLine().Trim(); } } } line2 = reader.ReadLine().Trim(); //need to repair the second line some times if (isStartOfData && line2.StartsWith("<TD class=BorderHelper") && !line2.EndsWith("</TD>")) { while (!line2.EndsWith("</TD>")) { line2 += " " + reader.ReadLine().Trim(); } } if (isStartOfData && (line2.StartsWith("<TD class=BorderHelper noWrap>") || line2.StartsWith("<TD class=BorderBottomHelper noWrap>"))) { substanceFormula = ExtractFormula(line1, separatorsStr3, separatorsStr4); name = ExtractName(line2, separatorsStr1, separatorsStr2); line3 = reader.ReadLine().Trim(); casRegestryNo = ExtractCasNo(line3, separatorsStr3); lineTemp = reader.ReadLine(); a = 0; if (thermProp == ThermPropType.EnthalpyOfCombustion) { state = ExtractCasNo(lineTemp, separatorsStr3); } else { a = ExtractValue(lineTemp, separatorsStr3); } if (thermProp == ThermPropType.CriticalProp) { molarWeight = a; } lineTemp = reader.ReadLine(); b = ExtractValue(lineTemp, separatorsStr3); if (thermProp == ThermPropType.CriticalProp) { freezingPoint = b; } lineTemp = reader.ReadLine(); c = ExtractValue(lineTemp, separatorsStr3); if (thermProp == ThermPropType.CriticalProp) { boilingPoint = c; } lineTemp = reader.ReadLine(); if (thermProp != ThermPropType.EnthalpyOfCombustion) { d = ExtractValue(lineTemp, separatorsStr3); } if (thermProp == ThermPropType.SolidCp || thermProp == ThermPropType.EvapHeat || thermProp == ThermPropType.GasVisc || thermProp == ThermPropType.GasK || thermProp == ThermPropType.LiquidK || thermProp == ThermPropType.SurfaceTension || thermProp == ThermPropType.EnthalpyOfFormation) { minTemp = d; } else if (thermProp == ThermPropType.CriticalProp) { criticalT = d; } lineTemp = reader.ReadLine(); if (thermProp != ThermPropType.EnthalpyOfCombustion) { e = ExtractValue(lineTemp, separatorsStr3); } if (thermProp == ThermPropType.SolidCp || thermProp == ThermPropType.EvapHeat || thermProp == ThermPropType.GasVisc || thermProp == ThermPropType.GasK || thermProp == ThermPropType.LiquidK || thermProp == ThermPropType.SurfaceTension || thermProp == ThermPropType.EnthalpyOfFormation) { maxTemp = e; } else if (thermProp == ThermPropType.LiquidCp || thermProp == ThermPropType.LiquidDensity || thermProp == ThermPropType.LiquidVisc) { minTemp = e; } else if (thermProp == ThermPropType.CriticalProp) { criticalP = 1.0e5 * e;//convert from bar to Pa } if (thermProp == ThermPropType.EvapHeat || thermProp == ThermPropType.CriticalProp || thermProp == ThermPropType.GasCp || thermProp == ThermPropType.VapPressure || thermProp == ThermPropType.LiquidCp || thermProp == ThermPropType.LiquidDensity || thermProp == ThermPropType.LiquidVisc) { lineTemp = reader.ReadLine(); f = ExtractValue(lineTemp, separatorsStr3); //if (thermProp == ThermProp.EvapHeat) { // bp = f; //} if (thermProp == ThermPropType.CriticalProp) { criticalV = f * 1.0e-6; //convert from cm3/mol to m3/mol lineTemp = reader.ReadLine(); //skip critical density } else if (thermProp == ThermPropType.GasCp || thermProp == ThermPropType.VapPressure) { minTemp = f; } else if (thermProp == ThermPropType.LiquidCp || thermProp == ThermPropType.LiquidDensity || thermProp == ThermPropType.LiquidVisc) { maxTemp = f; } } if (thermProp == ThermPropType.CriticalProp || thermProp == ThermPropType.GasCp || thermProp == ThermPropType.VapPressure) { lineTemp = reader.ReadLine(); g = ExtractValue(lineTemp, separatorsStr3); if (thermProp == ThermPropType.CriticalProp) { criticalComp = g; } else if (thermProp == ThermPropType.GasCp || thermProp == ThermPropType.VapPressure) { maxTemp = g; } } if (thermProp == ThermPropType.CriticalProp) { lineTemp = reader.ReadLine(); acentricF = ExtractValue(lineTemp, separatorsStr3); } if (thermProp == ThermPropType.CriticalProp) { criticalProps = new CriticalPropsAndAcentricFactor(freezingPoint, boilingPoint, criticalT, criticalP, criticalV, criticalComp, acentricF); substance = new Substance(name, substanceType, casRegestryNo, substanceFormula, molarWeight, criticalProps); propList.Add(substance); } else if (thermProp == ThermPropType.GasCp) { thermalPropCorrelation = new YawsGasCpCorrelation(name, casRegestryNo, a, b, c, d, e, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.LiquidCp) { thermalPropCorrelation = new YawsLiquidCpCorrelation(name, casRegestryNo, a, b, c, d, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.SolidCp) { thermalPropCorrelation = new YawsSolidCpCorrelation(name, casRegestryNo, a, b, c, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.EvapHeat) { thermalPropCorrelation = new YawsEvaporationHeatCorrelation(name, casRegestryNo, a, b, c, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.VapPressure) { thermalPropCorrelation = new YawsVaporPressureCorrelation(name, casRegestryNo, a, b, c, d, e, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.LiquidDensity) { thermalPropCorrelation = new YawsLiquidDensityCorrelation(name, casRegestryNo, a, b, c, d, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.GasVisc) { thermalPropCorrelation = new YawsGasViscosityCorrelation(name, casRegestryNo, a, b, c, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.LiquidVisc) { thermalPropCorrelation = new YawsLiquidViscosityCorrelation(name, casRegestryNo, a, b, c, d, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.GasK) { thermalPropCorrelation = new YawsGasThermalConductivityCorrelation(name, casRegestryNo, a, b, c, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.LiquidK) { thermalPropCorrelation = new YawsLiquidSolidThermalConductivityCorrelation(name, casRegestryNo, a, b, c, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.SurfaceTension) { thermalPropCorrelation = new YawsSurfaceTensionCorrelation(name, casRegestryNo, a, b, c, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.EnthalpyOfFormation) { thermalPropCorrelation = new YawsEnthalpyOfFormationCorrelation(name, casRegestryNo, a, b, c, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.EnthalpyOfCombustion) { thermalPropCorrelation = new YawsEnthalpyOfCombustionCorrelation(name, casRegestryNo, state, b, c, 298.15); propList.Add(thermalPropCorrelation); } } line1 = line2; } reader.Close(); fsRead.Close(); } } catch (Exception ex) { Console.WriteLine("The process failed: {0}", ex.ToString()); } finally { if (fsRead != null) { fsRead.Close(); } } //if (substanceType == SubstanceType.Inorganic) { PersistProp(GetFileName(thermProp), propList); UnpersistProp(GetFileName(thermProp)); //} prevSubstanceType = substanceType; prevThermalProp = thermProp; }
override internal void ExtractCoeffs(ListBox listBox, SubstanceType substanceType, ThermPropType thermProp) { propList.Clear(); ThermalPropCorrelationBase thermalPropCorrelation; string[] separatorsStr1 = { "</td>" }; string[] separatorsStr2 = { "<i>", "</i>" }; string name; string casRegestryNo; double a, b, c, d = 1, e = 1; double molarWeight, criticalRho, criticalT, criticalP, criticalV, criticalComp, accentricF; molarWeight = criticalRho = criticalT = criticalP = criticalV = criticalComp = accentricF = -2147483D; double minTemp = 1, maxTemp = 1; CriticalPropsAndAcentricFactor criticalProps; Substance substance; SubstanceFormula substanceFormula; string line1, line2, lineTemp; int fileNo = 0; int substanceNo = 0; string state = ""; int counter; int totalCounter = 0; StreamReader reader; FileStream fsRead = null; try { foreach (object fullFileName in listBox.Items) { fileNo++; counter = 0; fsRead = new FileStream((string)fullFileName, FileMode.Open, FileAccess.Read); reader = new StreamReader(fsRead); line1 = reader.ReadLine(); while (!reader.EndOfStream && counter < 50) { line2 = reader.ReadLine(); name = ""; casRegestryNo = ""; if (thermProp != ThermPropType.CriticalProp && thermProp != ThermPropType.EnthalpyOfCombustion) { if (line1.Contains("<a border")) { counter++; name = ExtractName(line2, separatorsStr1, separatorsStr2); if (!(thermProp == ThermPropType.LiquidCp || thermProp == ThermPropType.SolidCp || thermProp == ThermPropType.SurfaceTension)) { lineTemp = reader.ReadLine().Trim(); casRegestryNo = ExtractCasNo(lineTemp, separatorsStr1); } else { lineTemp = reader.ReadLine(); } lineTemp = reader.ReadLine(); //formula if (thermProp == ThermPropType.LiquidCp || thermProp == ThermPropType.SolidCp || thermProp == ThermPropType.SurfaceTension) { lineTemp = reader.ReadLine().Trim(); casRegestryNo = ExtractCasNo(lineTemp, separatorsStr1); } else { lineTemp = reader.ReadLine(); //molar weight } lineTemp = reader.ReadLine(); a = ExtractValue(lineTemp, separatorsStr1); lineTemp = reader.ReadLine(); b = ExtractValue(lineTemp, separatorsStr1); lineTemp = reader.ReadLine(); c = ExtractValue(lineTemp, separatorsStr1); if (a == -2147483D || b == -2147483D || c == -2147483D) { line1 = line2; continue; } if (thermProp == ThermPropType.GasCp || thermProp == ThermPropType.LiquidCp || thermProp == ThermPropType.VapPressure || thermProp == ThermPropType.LiquidDensity || thermProp == ThermPropType.LiquidDensity || thermProp == ThermPropType.LiquidVisc) { lineTemp = reader.ReadLine(); d = ExtractValue(lineTemp, separatorsStr1); if (d == -2147483D) { line1 = line2; continue; } } if (thermProp == ThermPropType.GasCp || thermProp == ThermPropType.VapPressure) { lineTemp = reader.ReadLine(); e = ExtractValue(lineTemp, separatorsStr1); if (e == -2147483D) { line1 = line2; continue; } } lineTemp = reader.ReadLine(); minTemp = ExtractValue(lineTemp, separatorsStr1); lineTemp = reader.ReadLine(); maxTemp = ExtractValue(lineTemp, separatorsStr1); if (thermProp == ThermPropType.GasCp) { thermalPropCorrelation = new YawsGasCpCorrelation(name, casRegestryNo, a, b, c, d, e, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.LiquidCp) { thermalPropCorrelation = new YawsLiquidCpCorrelation(name, casRegestryNo, a, b, c, d, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.SolidCp) { thermalPropCorrelation = new YawsSolidCpCorrelation(name, casRegestryNo, a, b, c, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.EvapHeat) { thermalPropCorrelation = new YawsEvaporationHeatCorrelation(name, casRegestryNo, a, b, c, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.VapPressure) { thermalPropCorrelation = new YawsVaporPressureCorrelation(name, casRegestryNo, a, b, c, d, e, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.LiquidDensity) { thermalPropCorrelation = new YawsLiquidDensityCorrelation(name, casRegestryNo, a, b, c, d, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.GasVisc) { thermalPropCorrelation = new YawsGasViscosityCorrelation(name, casRegestryNo, a, b, c, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.LiquidVisc) { thermalPropCorrelation = new YawsLiquidViscosityCorrelation(name, casRegestryNo, a, b, c, d, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.GasK) { thermalPropCorrelation = new YawsGasThermalConductivityCorrelation(name, casRegestryNo, a, b, c, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.LiquidK) { //Liquid thermal conductivity of Yaws organic is different from Yaws thermalPropCorrelation = new YawsOrganicLiquidThermalConductivityCorrelation(name, casRegestryNo, a, b, c, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.SurfaceTension) { thermalPropCorrelation = new YawsSurfaceTensionCorrelation(name, casRegestryNo, a, b, c, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.EnthalpyOfFormation) { thermalPropCorrelation = new YawsEnthalpyOfFormationCorrelation(name, casRegestryNo, a, b, c, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } } line1 = line2; } else { substanceNo = totalCounter + counter + 1; if ((line1.StartsWith(substanceNo.ToString() + "</td><td") || //since there is a duplicate for No. 3976 this condition must be added to handle it line1.StartsWith((substanceNo - 1).ToString() + "</td><td")) && counter < 50) { counter++; name = ExtractName(line2, separatorsStr1, separatorsStr2); lineTemp = reader.ReadLine(); if (thermProp != ThermPropType.EnthalpyOfCombustion) { casRegestryNo = ExtractCasNo(lineTemp, separatorsStr1); } else { while (!lineTemp.Contains("<a border")) { lineTemp = reader.ReadLine(); } } lineTemp = reader.ReadLine(); substanceFormula = ExtractSubstanceFormula(lineTemp); //for debugging use only //formula = sb.ToString(); lineTemp = reader.ReadLine(); if (thermProp != ThermPropType.EnthalpyOfCombustion) { molarWeight = ExtractValue(lineTemp, separatorsStr1); } else { casRegestryNo = ExtractCasNo(lineTemp, separatorsStr1); } lineTemp = reader.ReadLine(); if (thermProp != ThermPropType.EnthalpyOfCombustion) { criticalT = ExtractValue(lineTemp, separatorsStr1); } else { state = ExtractCasNo(lineTemp, separatorsStr1); } lineTemp = reader.ReadLine(); criticalP = ExtractValue(lineTemp, separatorsStr1);//for EnthalpyOfCombustion this is the value for mole based if (thermProp != ThermPropType.EnthalpyOfCombustion) { if (criticalP != -2147483D) { criticalP *= 1.0e5;//convert from bar to Pa } } lineTemp = reader.ReadLine(); criticalV = ExtractValue(lineTemp, separatorsStr1); //for EnthalpyOfCombustion this is the value for kg based if (thermProp != ThermPropType.EnthalpyOfCombustion) { if (criticalV != -2147483D) { criticalV *= 1.0e-6; //convert from cm3/mol to m3/mol } } lineTemp = reader.ReadLine(); //skip critical density since it can be obtained from critical volume and molar weight //subStrs = lineTemp.Trim().Split(separators); //criticalRho = double.Parse(subStrs[0]); if (thermProp != ThermPropType.EnthalpyOfCombustion) { lineTemp = reader.ReadLine(); criticalComp = ExtractValue(lineTemp, separatorsStr1); lineTemp = reader.ReadLine(); accentricF = ExtractValue(lineTemp, separatorsStr1); } if (thermProp == ThermPropType.EnthalpyOfCombustion) { thermalPropCorrelation = new YawsEnthalpyOfCombustionCorrelation(name, casRegestryNo, state, criticalP, criticalV, 298.15); propList.Add(thermalPropCorrelation); } else { criticalProps = new CriticalPropsAndAcentricFactor(criticalT, criticalP, criticalV, criticalComp, accentricF); substance = new Substance(name, substanceType, casRegestryNo, substanceFormula, molarWeight, criticalProps); propList.Add(substance); } } line1 = line2; } } totalCounter = totalCounter + counter; reader.Close(); fsRead.Close(); } } catch (Exception ex) { Console.WriteLine("The process failed: {0}", ex.ToString()); } finally { if (fsRead != null) { fsRead.Close(); } } PersistProp(GetFileName(thermProp), propList); UnpersistProp(GetFileName(thermProp)); }
private void ExtractCoeffs() { FileStream fsRead = null; try { char[] separator1 = { '>' }; char[] separator2 = { '<' }; char[] emptySeparator = { ' ' }; char[] separators = { '>', '<' }; string[] subStrs; string[] subSubStrs; string formula; string name; string htmlTaggedName; string casRegestryNo; double a, b, c, d = 1, e = 1, f, g, bp = 1; double molarWeight, freezingPoint, boilingPoint, criticalT, criticalP, criticalV, criticalComp, accentricF; molarWeight = freezingPoint = boilingPoint = criticalT = criticalP = criticalV = criticalComp = accentricF = -2147483D; double minTemp = 1, maxTemp = 1; StringBuilder sb; CriticalPropsAndAccentricFactor criticalProps; Substance substance; YawsGasCpCorrelation gasCpCorrelation; YawsLiquidCpCorrelation liquidCpCorrelation; YawsSolidCpCorrelation solidCpCorrelation; YawsGasThermalConductivityCorrelation gasKCorrelation; YawsLiquidThermalConductivityCorrelation liquidKCorrelation; YawsGasViscosityCorrelation gasViscCorrelation; YawsLiquidViscosityCorrelation liquidViscCorrelation; YawsLiquidDensityCorrelation liquidDensityCorrelation; YawsEvaporationHeatCorrelation evapHeatCorrelation; YawsVaporPressureCorrelation vapPressureCorrelation; YawsSurfaceTensionCorrelation surfaceTensionCorrelation; YawsEnthalpyOfFormationCorrelation enthalpyOfFormationCorrelation; string line1, line2, line3, line4, line5, line6, line7, line8, line9, line10, line11, lineTemp; string tmpStrOld = ""; string tmpStr; int number; StreamReader reader; foreach (object fullFileName in listBoxFiles.Items) { fsRead = new FileStream((string)fullFileName, FileMode.Open, FileAccess.Read); reader = new StreamReader(fsRead); line1 = reader.ReadLine(); while (!reader.EndOfStream) { line2 = reader.ReadLine(); if (line1.Contains("<TD class=BorderHelper>") && line2.Contains("<TD class=BorderHelper noWrap>")) { substanceFormula = new SubstanceFormula(); subStrs = line1.Split(separator1); sb = new StringBuilder(); for (int i = 1; i < subStrs.Length - 1; i++) { subSubStrs = subStrs[i].Split(separator2); sb.Append(subSubStrs[0]); tmpStr = subSubStrs[0]; if (char.IsDigit(tmpStr[0])) { number = int.Parse(tmpStr); substanceFormula.AddElement(tmpStrOld, number); } else { if (!tmpStr.Equals(" ")) { tmpStr = Parse(tmpStr.TrimEnd()); } if (i == (subStrs.Length - 2) && !tmpStr.Equals(" ") && !tmpStr.Equals("")) { substanceFormula.AddElement(tmpStr, 1); } } tmpStrOld = tmpStr; } formula = sb.ToString(); if (!line2.Contains("</TD>")) { lineTemp = reader.ReadLine(); lineTemp = lineTemp.TrimStart(); if (!lineTemp.StartsWith("</TD>")) { line2 = line2 + " " + lineTemp; } else { line2 = line2 + lineTemp; } } htmlTaggedName = line2; if (!(line2.Contains("<I>") || line2.Contains("</SPAN>"))) { subStrs = line2.Split(separators); name = subStrs[2]; } else { subStrs = line2.Split(separators); sb = new StringBuilder(); for (int i = 2; i < subStrs.Length; i++) { if (!(subStrs[i].Equals("") || subStrs[i].Equals("I") || subStrs[i].Equals("/I") || subStrs[i].Equals("SPAN class=Greek") || subStrs[i].Equals("/SPAN") || subStrs[i].Equals("/TD"))) { sb.Append(subStrs[i]); } } name = sb.ToString(); } name = name.TrimEnd(emptySeparator); line3 = reader.ReadLine(); subStrs = line3.Split(separators); if (subStrs[2].Contains("&")) { casRegestryNo = ""; } else { casRegestryNo = subStrs[2]; } line4 = reader.ReadLine(); subStrs = line4.Split(separators); a = double.Parse(subStrs[2]); if (thermProp == ThermProp.CriticalProp) { molarWeight = a; } line5 = reader.ReadLine(); subStrs = line5.Split(separators); if (subStrs[2].Contains("&")) { b = -2147483D; } else { b = double.Parse(subStrs[2]); } if (thermProp == ThermProp.CriticalProp) { freezingPoint = b; } line6 = reader.ReadLine(); subStrs = line6.Split(separators); if (subStrs[2].Contains("&")) { c = -2147483D;; } else { c = double.Parse(subStrs[2]); } if (thermProp == ThermProp.CriticalProp) { boilingPoint = c; } line7 = reader.ReadLine(); subStrs = line7.Split(separators); if (subStrs[2].Contains("&")) { d = -2147483D; } else { d = double.Parse(subStrs[2]); } if (thermProp == ThermProp.SolidCp || thermProp == ThermProp.EvapHeat || thermProp == ThermProp.GasVisc || thermProp == ThermProp.GasK || thermProp == ThermProp.LiquidK || thermProp == ThermProp.SurfaceTension || thermProp == ThermProp.EnthalpyOfFormation) { minTemp = d; } else if (thermProp == ThermProp.CriticalProp) { criticalT = d; } line8 = reader.ReadLine(); subStrs = line8.Split(separators); if (subStrs[2].Contains("&")) { e = -2147483D; } else { e = double.Parse(subStrs[2]); } if (thermProp == ThermProp.SolidCp || thermProp == ThermProp.EvapHeat || thermProp == ThermProp.GasVisc || thermProp == ThermProp.GasK || thermProp == ThermProp.LiquidK || thermProp == ThermProp.SurfaceTension || thermProp == ThermProp.EnthalpyOfFormation) { maxTemp = e; } else if (thermProp == ThermProp.LiquidCp || thermProp == ThermProp.LiquidDensity || thermProp == ThermProp.LiquidVisc) { minTemp = e; } else if (thermProp == ThermProp.CriticalProp) { criticalP = 1.0e5 * e;//convert from bar to Pa.sec } if (thermProp == ThermProp.EvapHeat || thermProp == ThermProp.CriticalProp || thermProp == ThermProp.GasCp || thermProp == ThermProp.VapPressure || thermProp == ThermProp.LiquidCp || thermProp == ThermProp.LiquidDensity || thermProp == ThermProp.LiquidVisc) { line9 = reader.ReadLine(); subStrs = line9.Split(separators); if (!subStrs[2].Contains("&")) { f = double.Parse(subStrs[2]); } else { f = -2147483D; } if (thermProp == ThermProp.EvapHeat) { bp = f; } else if (thermProp == ThermProp.CriticalProp) { criticalV = f * 1.0e-6; //convert from cm3/mol to m3/mol line9 = reader.ReadLine(); //skip critical density } else if (thermProp == ThermProp.GasCp || thermProp == ThermProp.VapPressure) { minTemp = f; } else if (thermProp == ThermProp.LiquidCp || thermProp == ThermProp.LiquidDensity || thermProp == ThermProp.LiquidVisc) { maxTemp = f; } } if (thermProp == ThermProp.CriticalProp || thermProp == ThermProp.GasCp || thermProp == ThermProp.VapPressure) { line10 = reader.ReadLine(); subStrs = line10.Split(separators); if (!subStrs[2].Contains("&")) { g = double.Parse(subStrs[2]); } else { g = -2147483D; } if (thermProp == ThermProp.CriticalProp) { criticalComp = g; } else if (thermProp == ThermProp.GasCp || thermProp == ThermProp.VapPressure) { maxTemp = g; } } if (thermProp == ThermProp.CriticalProp) { line11 = reader.ReadLine(); subStrs = line11.Split(separators); if (!subStrs[2].Contains("&")) { accentricF = double.Parse(subStrs[2]); } else { accentricF = -2147483D; } } if (thermProp == ThermProp.CriticalProp) { criticalProps = new CriticalPropsAndAccentricFactor(freezingPoint, boilingPoint, criticalT, criticalP, criticalV, criticalComp, accentricF); substance = new Substance(name, htmlTaggedName, substanceType, casRegestryNo, substanceFormula, molarWeight, criticalProps); substanceList.Add(substance); } else if (thermProp == ThermProp.GasCp) { gasCpCorrelation = new YawsGasCpCorrelation(name, a, b, c, d, e, minTemp, maxTemp); gasCpCorrList.Add(gasCpCorrelation); } else if (thermProp == ThermProp.LiquidCp) { liquidCpCorrelation = new YawsLiquidCpCorrelation(name, a, b, c, d, minTemp, maxTemp); liquidCpCorrList.Add(liquidCpCorrelation); } else if (thermProp == ThermProp.SolidCp) { solidCpCorrelation = new YawsSolidCpCorrelation(name, a, b, c, minTemp, maxTemp); solidCpCorrList.Add(solidCpCorrelation); } else if (thermProp == ThermProp.EvapHeat) { evapHeatCorrelation = new YawsEvaporationHeatCorrelation(name, a, b, c, minTemp, maxTemp); evapHeatCorrList.Add(evapHeatCorrelation); } else if (thermProp == ThermProp.VapPressure) { vapPressureCorrelation = new YawsVaporPressureCorrelation(name, a, b, c, d, e, minTemp, maxTemp); vapPressureCorrList.Add(vapPressureCorrelation); } else if (thermProp == ThermProp.LiquidDensity) { liquidDensityCorrelation = new YawsLiquidDensityCorrelation(name, a, b, c, d, minTemp, maxTemp); liquidDensityCorrList.Add(liquidDensityCorrelation); } else if (thermProp == ThermProp.GasVisc) { gasViscCorrelation = new YawsGasViscosityCorrelation(name, a, b, c, minTemp, maxTemp); gasViscCorrList.Add(gasViscCorrelation); } else if (thermProp == ThermProp.LiquidVisc) { liquidViscCorrelation = new YawsLiquidViscosityCorrelation(name, a, b, c, d, minTemp, maxTemp); liquidViscCorrList.Add(liquidViscCorrelation); } else if (thermProp == ThermProp.GasK) { gasKCorrelation = new YawsGasThermalConductivityCorrelation(name, a, b, c, minTemp, maxTemp); gasKCorrList.Add(gasKCorrelation); } else if (thermProp == ThermProp.LiquidK) { liquidKCorrelation = new YawsLiquidThermalConductivityCorrelation(name, a, b, c, minTemp, maxTemp); liquidKCorrList.Add(liquidKCorrelation); } else if (thermProp == ThermProp.SurfaceTension) { surfaceTensionCorrelation = new YawsSurfaceTensionCorrelation(name, a, b, c, minTemp, maxTemp); surfaceTensionCorrList.Add(surfaceTensionCorrelation); } else if (thermProp == ThermProp.EnthalpyOfFormation) { enthalpyOfFormationCorrelation = new YawsEnthalpyOfFormationCorrelation(name, a, b, c, minTemp, maxTemp); enthalpyOfFormationCorrList.Add(enthalpyOfFormationCorrelation); } } line1 = line2; } reader.Close(); fsRead.Close(); } } catch (Exception ex) { Console.WriteLine("The process failed: {0}", ex.ToString()); } finally { if (fsRead != null) { fsRead.Close(); } } if (substanceType == SubstanceType.Inorganic && thermProp == ThermProp.CriticalProp) { PersistSubstances(); } else if (substanceType == SubstanceType.Organic && thermProp == ThermProp.EnthalpyOfFormation) { PersistProp(thermProp); UnpersistProp(thermProp); } else if (substanceType == SubstanceType.Inorganic) { PersistProp(thermProp); UnpersistProp(thermProp); } }
private void ExtractCoeffs() { FileStream fsRead = null; try { //char[] separator1 = { '>' }; //char[] separator2 = { '<' }; //char[] emptySeparator = { ' ' }; //char[] separators = { '>', '<' }; string[] separatorsStr1 = { "<TD class=BorderHelper noWrap>", "</TD>" }; string[] separatorsStr2 = { "<I>", "</I>" }; string[] separatorsStr3 = { "<TD class=BorderHelper>", "</TD>" }; string[] separatorsStr4 = { "<SUB>", "</SUB>" }; //string[] subStrs; //string[] subSubStrs; //string formula; //StringBuilder sb; string name; //string htmlTaggedName; string casRegestryNo; double a, b, c, d = 1, e = 1, f, g; //, bp = 1; double molarWeight, freezingPoint, boilingPoint, criticalT, criticalP, criticalV, criticalComp, acentricF; molarWeight = freezingPoint = boilingPoint = criticalT = criticalP = criticalV = criticalComp = acentricF = -2147483D; double minTemp = 1, maxTemp = 1; CriticalPropsAndAcentricFactor criticalProps; Substance substance; YawsGasCpCorrelation gasCpCorrelation; YawsLiquidCpCorrelation liquidCpCorrelation; YawsSolidCpCorrelation solidCpCorrelation; YawsGasThermalConductivityCorrelation gasKCorrelation; YawsLiquidThermalConductivityCorrelation liquidKCorrelation; YawsGasViscosityCorrelation gasViscCorrelation; YawsLiquidViscosityCorrelation liquidViscCorrelation; YawsLiquidDensityCorrelation liquidDensityCorrelation; YawsEvaporationHeatCorrelation evapHeatCorrelation; YawsVaporPressureCorrelation vapPressureCorrelation; YawsSurfaceTensionCorrelation surfaceTensionCorrelation; YawsEnthalpyOfFormationCorrelation enthalpyOfFormationCorrelation; //string line1, line2, line3, line4, line5, line6, line7, line8, line9, line10, line11, lineTemp; string line1, line2, line3, lineTemp; //string tmpStrOld = ""; //string tmpStr; //string elementStr; //int elementCount; //bool isLine3ExtensionOfLine2; StreamReader reader; foreach (object fullFileName in listBoxFiles.Items) { fsRead = new FileStream((string)fullFileName, FileMode.Open, FileAccess.Read); reader = new StreamReader(fsRead); line1 = reader.ReadLine(); while (!reader.EndOfStream) { line2 = reader.ReadLine(); if (line2.StartsWith("<TD class=BorderHelper noWrap>") && !line2.EndsWith("</TD>")) { line2 += reader.ReadLine(); } if (line1.Contains("<TD class=BorderHelper>") && line2.Contains("<TD class=BorderHelper noWrap>")) { ExtractFormula(line1, separatorsStr3, separatorsStr4); name = ExtractName(line2, separatorsStr1, separatorsStr2); line3 = reader.ReadLine(); casRegestryNo = ExtractCasNo(line3, separatorsStr3); lineTemp = reader.ReadLine(); a = ExtractValue(lineTemp, separatorsStr3); if (thermProp == ThermPropType.CriticalProp) { molarWeight = a; } lineTemp = reader.ReadLine(); b = ExtractValue(lineTemp, separatorsStr3); if (thermProp == ThermPropType.CriticalProp) { freezingPoint = b; } lineTemp = reader.ReadLine(); c = ExtractValue(lineTemp, separatorsStr3); if (thermProp == ThermPropType.CriticalProp) { boilingPoint = c; } lineTemp = reader.ReadLine(); d = ExtractValue(lineTemp, separatorsStr3); if (thermProp == ThermPropType.SolidCp || thermProp == ThermPropType.EvapHeat || thermProp == ThermPropType.GasVisc || thermProp == ThermPropType.GasK || thermProp == ThermPropType.LiquidK || thermProp == ThermPropType.SurfaceTension || thermProp == ThermPropType.EnthalpyOfFormation) { minTemp = d; } else if (thermProp == ThermPropType.CriticalProp) { criticalT = d; } lineTemp = reader.ReadLine(); e = ExtractValue(lineTemp, separatorsStr3); if (thermProp == ThermPropType.SolidCp || thermProp == ThermPropType.EvapHeat || thermProp == ThermPropType.GasVisc || thermProp == ThermPropType.GasK || thermProp == ThermPropType.LiquidK || thermProp == ThermPropType.SurfaceTension || thermProp == ThermPropType.EnthalpyOfFormation) { maxTemp = e; } else if (thermProp == ThermPropType.LiquidCp || thermProp == ThermPropType.LiquidDensity || thermProp == ThermPropType.LiquidVisc) { minTemp = e; } else if (thermProp == ThermPropType.CriticalProp) { criticalP = 1.0e5 * e;//convert from bar to Pa } if (thermProp == ThermPropType.EvapHeat || thermProp == ThermPropType.CriticalProp || thermProp == ThermPropType.GasCp || thermProp == ThermPropType.VapPressure || thermProp == ThermPropType.LiquidCp || thermProp == ThermPropType.LiquidDensity || thermProp == ThermPropType.LiquidVisc) { lineTemp = reader.ReadLine(); f = ExtractValue(lineTemp, separatorsStr3); //if (thermProp == ThermProp.EvapHeat) { // bp = f; //} if (thermProp == ThermPropType.CriticalProp) { criticalV = f * 1.0e-6; //convert from cm3/mol to m3/mol lineTemp = reader.ReadLine(); //skip critical density } else if (thermProp == ThermPropType.GasCp || thermProp == ThermPropType.VapPressure) { minTemp = f; } else if (thermProp == ThermPropType.LiquidCp || thermProp == ThermPropType.LiquidDensity || thermProp == ThermPropType.LiquidVisc) { maxTemp = f; } } if (thermProp == ThermPropType.CriticalProp || thermProp == ThermPropType.GasCp || thermProp == ThermPropType.VapPressure) { lineTemp = reader.ReadLine(); g = ExtractValue(lineTemp, separatorsStr3); if (thermProp == ThermPropType.CriticalProp) { criticalComp = g; } else if (thermProp == ThermPropType.GasCp || thermProp == ThermPropType.VapPressure) { maxTemp = g; } } if (thermProp == ThermPropType.CriticalProp) { lineTemp = reader.ReadLine(); acentricF = ExtractValue(lineTemp, separatorsStr3); } if (thermProp == ThermPropType.CriticalProp) { criticalProps = new CriticalPropsAndAcentricFactor(freezingPoint, boilingPoint, criticalT, criticalP, criticalV, criticalComp, acentricF); substance = new Substance(name, substanceType, casRegestryNo, substanceFormula, molarWeight, criticalProps); substanceList.Add(substance); } else if (thermProp == ThermPropType.GasCp) { gasCpCorrelation = new YawsGasCpCorrelation(name, a, b, c, d, e, minTemp, maxTemp); gasCpCorrList.Add(gasCpCorrelation); } else if (thermProp == ThermPropType.LiquidCp) { liquidCpCorrelation = new YawsLiquidCpCorrelation(name, a, b, c, d, minTemp, maxTemp); liquidCpCorrList.Add(liquidCpCorrelation); } else if (thermProp == ThermPropType.SolidCp) { solidCpCorrelation = new YawsSolidCpCorrelation(name, a, b, c, minTemp, maxTemp); solidCpCorrList.Add(solidCpCorrelation); } else if (thermProp == ThermPropType.EvapHeat) { evapHeatCorrelation = new YawsEvaporationHeatCorrelation(name, a, b, c, minTemp, maxTemp); evapHeatCorrList.Add(evapHeatCorrelation); } else if (thermProp == ThermPropType.VapPressure) { vapPressureCorrelation = new YawsVaporPressureCorrelation(name, a, b, c, d, e, minTemp, maxTemp); vapPressureCorrList.Add(vapPressureCorrelation); } else if (thermProp == ThermPropType.LiquidDensity) { liquidDensityCorrelation = new YawsLiquidDensityCorrelation(name, a, b, c, d, minTemp, maxTemp); liquidDensityCorrList.Add(liquidDensityCorrelation); } else if (thermProp == ThermPropType.GasVisc) { gasViscCorrelation = new YawsGasViscosityCorrelation(name, a, b, c, minTemp, maxTemp); gasViscCorrList.Add(gasViscCorrelation); } else if (thermProp == ThermPropType.LiquidVisc) { liquidViscCorrelation = new YawsLiquidViscosityCorrelation(name, a, b, c, d, minTemp, maxTemp); liquidViscCorrList.Add(liquidViscCorrelation); } else if (thermProp == ThermPropType.GasK) { gasKCorrelation = new YawsGasThermalConductivityCorrelation(name, a, b, c, minTemp, maxTemp); gasKCorrList.Add(gasKCorrelation); } else if (thermProp == ThermPropType.LiquidK) { liquidKCorrelation = new YawsLiquidThermalConductivityCorrelation(name, a, b, c, minTemp, maxTemp); liquidKCorrList.Add(liquidKCorrelation); } else if (thermProp == ThermPropType.SurfaceTension) { surfaceTensionCorrelation = new YawsSurfaceTensionCorrelation(name, a, b, c, minTemp, maxTemp); surfaceTensionCorrList.Add(surfaceTensionCorrelation); } else if (thermProp == ThermPropType.EnthalpyOfFormation) { enthalpyOfFormationCorrelation = new YawsEnthalpyOfFormationCorrelation(name, a, b, c, minTemp, maxTemp); enthalpyOfFormationCorrList.Add(enthalpyOfFormationCorrelation); } } line1 = line2; } reader.Close(); fsRead.Close(); } } catch (Exception ex) { Console.WriteLine("The process failed: {0}", ex.ToString()); } finally { if (fsRead != null) { fsRead.Close(); } } if (substanceType == SubstanceType.Inorganic && thermProp == ThermPropType.CriticalProp) { PersistSubstances(); } else if (substanceType == SubstanceType.Organic && thermProp == ThermPropType.EnthalpyOfFormation) { PersistProp(thermProp); UnpersistProp(thermProp); } else if (substanceType == SubstanceType.Inorganic) { PersistProp(thermProp); UnpersistProp(thermProp); } }