private void comboBoxExtractorType_SelectedIndexChanged(object sender, EventArgs e) { int idx = comboBoxExtractorType.SelectedIndex; extractorType = (ExtractorType)idx; if (extractorType == ExtractorType.Yaws) { fileFilter = "htm files (*.htm)|*.htm"; } else { fileFilter = "htm files (*.html)|*.html"; } if (extractorType == ExtractorType.Perrys) { comboBoxSubstanceType.Visible = false; } else if (extractorType == ExtractorType.YawsOrganic) { comboBoxSubstanceType.Visible = false; substanceType = SubstanceType.Organic; thermPropType = ThermPropType.CriticalProp; } else { comboBoxSubstanceType.Visible = true; thermPropType = ThermPropType.CriticalProp; } }
private string GetFileName(ThermPropType prop) { string fileName = "SubstancesOrganic.dat";; if (prop == ThermPropType.GasCp) { fileName = "YawsOrganicGasCpCorrelations.dat"; } else if (prop == ThermPropType.LiquidCp) { fileName = "YawsOrganicLiquidCpCorrelations.dat"; } if (prop == ThermPropType.SolidCp) { fileName = "YawsOrganicSolidCpCorrelations.dat"; } else if (prop == ThermPropType.EvapHeat) { fileName = "YawsOrganicEvaporationHeatCorrelations.dat"; } else if (prop == ThermPropType.VapPressure) { fileName = "YawsOrganicVaporPressureCorrelations.dat"; } else if (prop == ThermPropType.LiquidDensity) { fileName = "YawsOrganicLiquidDensityCorrelations.dat"; } else if (prop == ThermPropType.GasVisc) { fileName = "YawsOrganicGasViscosityCorrelations.dat"; } else if (prop == ThermPropType.LiquidVisc) { fileName = "YawsOrganicLiquidViscosityCorrelations.dat"; } else if (prop == ThermPropType.GasK) { fileName = "YawsOrganicGasThermalConductivityCorrelations.dat"; } else if (prop == ThermPropType.LiquidK) { fileName = "YawsOrganicLiquidThermalConductivityCorrelations.dat"; } else if (prop == ThermPropType.SurfaceTension) { fileName = "YawsOrganicSurfaceTensionCorrelations.dat"; } else if (prop == ThermPropType.EnthalpyOfFormation) { fileName = "YawsOrganicEnthalpyOfFormationCorrelations.dat"; } else if (prop == ThermPropType.EnthalpyOfCombustion) { fileName = "YawsOrganicEnthalpyOfCombustionCorrelations.dat"; } return(fileName); }
private void propComboBox_SelectedIndexChanged(object sender, EventArgs e) { int idx = propComboBox.SelectedIndex; if (idx == 0) { thermProp = ThermPropType.GasCp; } else if (idx == 1) { thermProp = ThermPropType.LiquidCp; } else if (idx == 2) { thermProp = ThermPropType.SolidCp; } else if (idx == 3) { thermProp = ThermPropType.EvapHeat; } else if (idx == 4) { thermProp = ThermPropType.VapPressure; } else if (idx == 5) { thermProp = ThermPropType.LiquidDensity; } else if (idx == 6) { thermProp = ThermPropType.GasVisc; } else if (idx == 7) { thermProp = ThermPropType.LiquidVisc; } else if (idx == 8) { thermProp = ThermPropType.GasK; } else if (idx == 9) { thermProp = ThermPropType.LiquidK; } else if (idx == 10) { thermProp = ThermPropType.SurfaceTension; } else if (idx == 11) { thermProp = ThermPropType.EnthalpyOfFormation; } else if (idx == 12) { thermProp = ThermPropType.CriticalProp; } }
private string GetFileName(ThermPropType prop) { string fileName = "PerrysGasCpCorrelations.dat"; if (prop == ThermPropType.LiquidCp) { fileName = "PerrysLiquidCpCorrelations.dat"; } else if (prop == ThermPropType.EvapHeat) { fileName = "PerrysEvaporationHeatCorrelations.dat"; } else if (prop == ThermPropType.VapPressure) { fileName = "PerrysVaporPressureCorrelations.dat"; } else if (prop == ThermPropType.LiquidDensity) { fileName = "PerrysLiquidDensityCorrelations.dat"; } return(fileName); }
private void UnpersistProp(ThermPropType prop) { Stream stream = null; try { string fileName = "c:\\temp\\YawsGasCpCorrelations.dat"; if (prop == ThermPropType.LiquidCp) { fileName = "c:\\temp\\YawsLiquidCpCorrelations.dat"; } if (prop == ThermPropType.SolidCp) { fileName = "c:\\temp\\YawsSolidCpCorrelations.dat"; } else if (prop == ThermPropType.EvapHeat) { fileName = "c:\\temp\\YawsEvaporationHeatCorrelations.dat"; } else if (prop == ThermPropType.VapPressure) { fileName = "c:\\temp\\YawsVaporPressureCorrelations.dat"; } else if (prop == ThermPropType.LiquidDensity) { fileName = "c:\\temp\\YawsLiquidDensityCorrelations.dat"; } else if (prop == ThermPropType.GasVisc) { fileName = "c:\\temp\\YawsGasViscosityCorrelations.dat"; } else if (prop == ThermPropType.LiquidVisc) { fileName = "c:\\temp\\YawsLiquidViscosityCorrelations.dat"; } else if (prop == ThermPropType.GasK) { fileName = "c:\\temp\\YawsGasThermalConductivityCorrelations.dat"; } else if (prop == ThermPropType.LiquidK) { fileName = "c:\\temp\\YawsLiquidThermalConductivityCorrelations.dat"; } else if (prop == ThermPropType.SurfaceTension) { fileName = "c:\\temp\\YawsSurfaceTensionCorrelations.dat"; } else if (prop == ThermPropType.EnthalpyOfFormation) { fileName = "c:\\temp\\YawsEnthalpyOfFormationCorrelations.dat"; } stream = new FileStream(fileName, FileMode.Open); SoapFormatter serializer = new SoapFormatter(); IList thermalPropCorrelationList = (IList)serializer.Deserialize(stream); foreach (Storable s in thermalPropCorrelationList) { s.SetObjectData(); } } catch (Exception e) { string message = e.ToString(); MessageBox.Show(message, "Save Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); throw; } finally { stream.Close(); } }
private void PersistProp(ThermPropType prop) { FileStream fs = null; try { string fileName = "c:\\temp\\YawsGasCpCorrelations.dat"; IList listToPersist = gasCpCorrList; if (prop == ThermPropType.LiquidCp) { fileName = "c:\\temp\\YawsLiquidCpCorrelations.dat"; listToPersist = liquidCpCorrList; } if (prop == ThermPropType.SolidCp) { fileName = "c:\\temp\\YawsSolidCpCorrelations.dat"; listToPersist = solidCpCorrList; } else if (prop == ThermPropType.EvapHeat) { fileName = "c:\\temp\\YawsEvaporationHeatCorrelations.dat"; listToPersist = evapHeatCorrList; } else if (prop == ThermPropType.VapPressure) { fileName = "c:\\temp\\YawsVaporPressureCorrelations.dat"; listToPersist = vapPressureCorrList; } else if (prop == ThermPropType.LiquidDensity) { fileName = "c:\\temp\\YawsLiquidDensityCorrelations.dat"; listToPersist = liquidDensityCorrList; } else if (prop == ThermPropType.GasVisc) { fileName = "c:\\temp\\YawsGasViscosityCorrelations.dat"; listToPersist = gasViscCorrList; } else if (prop == ThermPropType.LiquidVisc) { fileName = "c:\\temp\\YawsLiquidViscosityCorrelations.dat"; listToPersist = liquidViscCorrList; } else if (prop == ThermPropType.GasK) { fileName = "c:\\temp\\YawsGasThermalConductivityCorrelations.dat"; listToPersist = gasKCorrList; } else if (prop == ThermPropType.LiquidK) { fileName = "c:\\temp\\YawsLiquidThermalConductivityCorrelations.dat"; listToPersist = liquidKCorrList; } else if (prop == ThermPropType.SurfaceTension) { fileName = "c:\\temp\\YawsSurfaceTensionCorrelations.dat"; listToPersist = surfaceTensionCorrList; } else if (prop == ThermPropType.EnthalpyOfFormation) { fileName = "c:\\temp\\YawsEnthalpyOfFormationCorrelations.dat"; listToPersist = enthalpyOfFormationCorrList; } if (File.Exists(fileName)) { fs = new FileStream(fileName, FileMode.Open); } else { fs = new FileStream(fileName, FileMode.Create); } SoapFormatter serializer = new SoapFormatter(); serializer.Serialize(fs, listToPersist); } catch (Exception e) { string message = e.ToString(); MessageBox.Show(message, "Save Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { if (fs != null) { fs.Flush(); fs.Close(); } } }
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 comboBoxProp_SelectedIndexChanged(object sender, EventArgs e) { int idx = comboBoxProp.SelectedIndex; thermPropType = (ThermPropType)idx; }
internal virtual void ExtractCoeffs(ListBox listBox, SubstanceType substanceType, ThermPropType thermalProp) { }
override internal void ExtractCoeffs(ListBox listBox, SubstanceType substanceType, ThermPropType thermProp) { propList.Clear(); string[] separatorsStr1 = { "</td>" }; string[] separatorsStr2 = { "<i>", "</i>" }; string name; string casRegestryNo; double a, b, c, d = 1, e = 1; double tc = 1; double minTemp = 1, maxTemp = 1; string line1, line2, lineTemp; int correlationType; int counter; FileStream fsRead = null; StreamReader reader; ThermalPropCorrelationBase thermalPropCorrelation; try { foreach (object fullFileName in listBox.Items) { 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(); if (line1.Contains(" ") || line1.Contains("<a border")) { counter++; correlationType = 1; name = ExtractName(line2, separatorsStr1, separatorsStr2); lineTemp = reader.ReadLine(); //formula lineTemp = reader.ReadLine().Trim(); casRegestryNo = ExtractCasNo(lineTemp, separatorsStr1); if (thermProp != ThermPropType.VapPressure) //molar weight is not listed in vapor pressure table { lineTemp = reader.ReadLine(); } lineTemp = reader.ReadLine(); if (lineTemp == null) { continue; } a = ExtractValue(lineTemp, separatorsStr1); lineTemp = reader.ReadLine(); b = ExtractValue(lineTemp, separatorsStr1); lineTemp = reader.ReadLine(); c = ExtractValue(lineTemp, separatorsStr1); lineTemp = reader.ReadLine(); d = ExtractValue(lineTemp, separatorsStr1); if (thermProp == ThermPropType.GasCp || thermProp == ThermPropType.LiquidCp || thermProp == ThermPropType.VapPressure) { lineTemp = reader.ReadLine(); e = ExtractValue(lineTemp, separatorsStr1); } lineTemp = reader.ReadLine(); minTemp = ExtractValue(lineTemp, separatorsStr1); lineTemp = reader.ReadLine(); lineTemp = reader.ReadLine(); maxTemp = ExtractValue(lineTemp, separatorsStr1); if (thermProp == ThermPropType.LiquidCp || thermProp == ThermPropType.EvapHeat) { lineTemp = reader.ReadLine(); lineTemp = reader.ReadLine(); tc = ExtractValue(lineTemp, separatorsStr1); } if (thermProp == ThermPropType.GasCp) { correlationType = 1; if (name == "helium-4" || name == "nitric oxide") { correlationType = 2; } else if (name == "propylbenzene") { correlationType = 3; } thermalPropCorrelation = new PerrysGasCpCorrelation(name, casRegestryNo, a * 1e5, b * 1e5, c * 1e3, d * 1e5, e, minTemp, maxTemp, correlationType); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.LiquidCp) { correlationType = 1; if (name == "methane" || name == "ethane" || name == "propane" || name == "n-butane" || name == "n-heptane" || name == "hydrogen" || name == "ammonia" || name == "carbon monoxide" || name == "hydrogen sulfide") { correlationType = 2; } thermalPropCorrelation = new PerrysLiquidCpCorrelation(name, casRegestryNo, a, b, c, d, e, tc, minTemp, maxTemp, correlationType); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.EvapHeat) { thermalPropCorrelation = new PerrysEvaporationHeatCorrelation(name, casRegestryNo, a * 1.0e7, b, c, d, tc, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.VapPressure) { thermalPropCorrelation = new PerrysVaporPressureCorrelation(name, casRegestryNo, a, b, c, d, e, minTemp, maxTemp); propList.Add(thermalPropCorrelation); } else if (thermProp == ThermPropType.LiquidDensity) { thermalPropCorrelation = new PerrysLiquidDensityCorrelation(name, casRegestryNo, a, b, c, d, minTemp, maxTemp); 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(); } } PersistProp(GetFileName(thermProp), propList); UnpersistProp(GetFileName(thermProp)); }