From 612d6500bc8168c4eba92d194d558a5ab9f3f765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?= <34712686+asmfstatoil@users.noreply.github.com> Date: Sun, 24 Jul 2022 15:19:42 +0200 Subject: [PATCH] Refact process simulation (#503) * refact: autoformatting and fixing style warnings --- .../measurementDevice/MultiPhaseMeter.java | 175 ++- .../online/OnlineSignal.java | 205 ++-- .../AbsorptionColumnDesignStandard.java | 4 +- .../AdsorptionDehydrationDesignStandard.java | 4 +- .../CompressorDesignStandard.java | 4 +- .../GasScrubberDesignStandard.java | 4 +- .../MaterialPipeDesignStandard.java | 4 +- .../MaterialPlateDesignStandard.java | 4 +- .../PipelineDesignStandard.java | 4 +- .../SeparatorDesignStandard.java | 4 +- .../CompressorChartAlternativeMapLookup.java | 999 +++++++++--------- .../distillation/SimpleTray.java | 2 +- .../processEquipment/pipeline/Fittings.java | 184 ++-- .../processEquipment/separator/Separator.java | 2 +- .../processEquipment/stream/EnergyStream.java | 4 +- .../stream/EquilibriumStream.java | 4 +- .../stream/IronIonSaturationStream.java | 4 +- .../processEquipment/stream/NeqStream.java | 4 +- .../stream/ScalePotentialCheckStream.java | 4 +- .../processEquipment/stream/Stream.java | 8 +- .../processEquipment/util/Calculator.java | 4 +- .../processEquipment/util/Recycle.java | 4 +- .../processSystem/ProcessSystem.java | 28 +- .../gasQuality/Standard_ISO6578.java | 8 +- .../gasQuality/Standard_ISO6976.java | 10 +- .../gasQuality/Standard_ISO6976_2016.java | 6 +- .../standards/salesContract/BaseContract.java | 8 +- 27 files changed, 841 insertions(+), 854 deletions(-) diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeter.java b/src/main/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeter.java index 51292af953..1d27f9a020 100644 --- a/src/main/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeter.java +++ b/src/main/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeter.java @@ -2,7 +2,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import neqsim.processSimulation.processEquipment.splitter.Splitter; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermo.system.SystemInterface; @@ -110,96 +109,96 @@ public double getMeasuredValue() { } /** {@inheritDoc} */ - @Override - public double getMeasuredValue(String measurement) { - if (measurement.equals("mass rate")) { - return stream.getThermoSystem().getFlowRate("kg/hr"); + @Override + public double getMeasuredValue(String measurement) { + if (measurement.equals("mass rate")) { + return stream.getThermoSystem().getFlowRate("kg/hr"); + } + + if (stream.getThermoSystem().getFlowRate("kg/hr") < 1e-10) { + return Double.NaN; + } + + if (measurement.equals("GOR")) { + SystemInterface tempFluid = stream.getThermoSystem().clone(); + tempFluid.setTemperature(temperature, unitT); + tempFluid.setPressure(pressure, unitP); + ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid); + try { + thermoOps.TPflash(); + } catch (Exception ex) { + logger.error(ex.getStackTrace()); + return Double.NaN; + } + // tempFluid.display(); + if (!tempFluid.hasPhaseType("gas")) { + return Double.NaN; + } + if (!tempFluid.hasPhaseType("oil")) { + return Double.NaN; + } + tempFluid.initPhysicalProperties("density"); + return tempFluid.getPhase("gas").getCorrectedVolume() + / tempFluid.getPhase("oil").getCorrectedVolume(); + } + if (measurement.equals("gasDensity") || measurement.equals("oilDensity") + || measurement.equals("waterDensity")) { + SystemInterface tempFluid = stream.getThermoSystem().clone(); + tempFluid.setTemperature(temperature, unitT); + tempFluid.setPressure(pressure, unitP); + ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid); + try { + thermoOps.TPflash(); + } catch (Exception ex) { + logger.error(ex.getStackTrace()); + return Double.NaN; + } + tempFluid.initPhysicalProperties(); + if (measurement.equals("gasDensity")) { + if (!tempFluid.hasPhaseType("gas")) { + return 0.0; + } else { + return tempFluid.getPhase("gas").getDensity("kg/m3"); } - - if(stream.getThermoSystem().getFlowRate("kg/hr")<1e-10) { - return Double.NaN; + } + if (measurement.equals("oilDensity")) { + if (!tempFluid.hasPhaseType("oil")) { + return 0.0; + } else { + return tempFluid.getPhase("oil").getDensity("kg/m3"); } - - if (measurement.equals("GOR")) { - SystemInterface tempFluid = stream.getThermoSystem().clone(); - tempFluid.setTemperature(temperature, unitT); - tempFluid.setPressure(pressure, unitP); - ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid); - try { - thermoOps.TPflash(); - } catch (Exception e) { - logger.error(e.getStackTrace()); - return Double.NaN; - } - // tempFluid.display(); - if (!tempFluid.hasPhaseType("gas")) { - return Double.NaN; - } - if (!tempFluid.hasPhaseType("oil")) { - return Double.NaN; - } - tempFluid.initPhysicalProperties("density"); - return tempFluid.getPhase("gas").getCorrectedVolume() - / tempFluid.getPhase("oil").getCorrectedVolume(); + } + if (measurement.equals("waterDensity")) { + if (!tempFluid.hasPhaseType("aqueous")) { + return 0.0; + } else { + return tempFluid.getPhase("aqueous").getDensity("kg/m3"); } - if (measurement.equals("gasDensity") || measurement.equals("oilDensity") - || measurement.equals("waterDensity")) { - SystemInterface tempFluid = stream.getThermoSystem().clone(); - tempFluid.setTemperature(temperature, unitT); - tempFluid.setPressure(pressure, unitP); - ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid); - try { - thermoOps.TPflash(); - } catch (Exception e) { - logger.error(e.getStackTrace()); - return Double.NaN; - } - tempFluid.initPhysicalProperties(); - if (measurement.equals("gasDensity")) { - if (!tempFluid.hasPhaseType("gas")) { - return 0.0; - } else { - return tempFluid.getPhase("gas").getDensity("kg/m3"); - } - } - if (measurement.equals("oilDensity")) { - if (!tempFluid.hasPhaseType("oil")) { - return 0.0; - } else { - return tempFluid.getPhase("oil").getDensity("kg/m3"); - } - } - if (measurement.equals("waterDensity")) { - if (!tempFluid.hasPhaseType("aqueous")) { - return 0.0; - } else { - return tempFluid.getPhase("aqueous").getDensity("kg/m3"); - } - } - return 0.0; - } else if (measurement.equals("GOR_std")) { - SystemInterface tempFluid = stream.getThermoSystem().clone(); - tempFluid.setTemperature(15.0, "C"); - tempFluid.setPressure(1.01325, "bara"); - ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid); - try { - thermoOps.TPflash(); - } catch (Exception e) { - logger.error(e.getStackTrace()); - return Double.NaN; - } - if (!tempFluid.hasPhaseType("gas")) { - return Double.NaN; - } - if (!tempFluid.hasPhaseType("oil")) { - return Double.NaN; - } - tempFluid.initPhysicalProperties("density"); - return tempFluid.getPhase("gas").getCorrectedVolume() - / tempFluid.getPhase("oil").getCorrectedVolume(); - } else - return 0.0; - } + } + return 0.0; + } else if (measurement.equals("GOR_std")) { + SystemInterface tempFluid = stream.getThermoSystem().clone(); + tempFluid.setTemperature(15.0, "C"); + tempFluid.setPressure(1.01325, "bara"); + ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid); + try { + thermoOps.TPflash(); + } catch (Exception ex) { + logger.error(ex.getStackTrace()); + return Double.NaN; + } + if (!tempFluid.hasPhaseType("gas")) { + return Double.NaN; + } + if (!tempFluid.hasPhaseType("oil")) { + return Double.NaN; + } + tempFluid.initPhysicalProperties("density"); + return tempFluid.getPhase("gas").getCorrectedVolume() + / tempFluid.getPhase("oil").getCorrectedVolume(); + } else + return 0.0; + } /** *

diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/online/OnlineSignal.java b/src/main/java/neqsim/processSimulation/measurementDevice/online/OnlineSignal.java index 90902b5214..a7a33301ec 100644 --- a/src/main/java/neqsim/processSimulation/measurementDevice/online/OnlineSignal.java +++ b/src/main/java/neqsim/processSimulation/measurementDevice/online/OnlineSignal.java @@ -11,117 +11,116 @@ * @version $Id: $Id */ public class OnlineSignal implements java.io.Serializable { - private static final long serialVersionUID = 1000; + private static final long serialVersionUID = 1000; - /** - *

- * Getter for the field unit. - *

- * - * @return the unit - */ - public String getUnit() { - return unit; - } + /** + *

+ * Getter for the field unit. + *

+ * + * @return the unit + */ + public String getUnit() { + return unit; + } - /** - *

- * Setter for the field unit. - *

- * - * @param unit the unit to set - */ - public void setUnit(String unit) { - this.unit = unit; - } + /** + *

+ * Setter for the field unit. + *

+ * + * @param unit the unit to set + */ + public void setUnit(String unit) { + this.unit = unit; + } - Date dateStamp = new Date(); - String name = ""; - String plantName = "Kaarsto"; - String transmitterName = "21TI1117"; - java.sql.ResultSet dataSet = null; - double value = 1.0; - private String unit = "C"; - neqsim.util.database.AspenIP21Database database = null; + Date dateStamp = new Date(); + String name = ""; + String plantName = "Kaarsto"; + String transmitterName = "21TI1117"; + java.sql.ResultSet dataSet = null; + double value = 1.0; + private String unit = "C"; + neqsim.util.database.AspenIP21Database database = null; - /** - *

- * Constructor for OnlineSignal. - *

- * - * @param plantName a {@link java.lang.String} object - * @param transmitterName a {@link java.lang.String} object - */ - public OnlineSignal(String plantName, String transmitterName) { - this.plantName = plantName; - this.transmitterName = transmitterName; + /** + *

+ * Constructor for OnlineSignal. + *

+ * + * @param plantName a {@link java.lang.String} object + * @param transmitterName a {@link java.lang.String} object + */ + public OnlineSignal(String plantName, String transmitterName) { + this.plantName = plantName; + this.transmitterName = transmitterName; - connect(); - } + connect(); + } - /** - *

- * connect. - *

- * - * @return a boolean - */ - public boolean connect() { - if (plantName.equals("Karsto")) { - database = new neqsim.util.database.AspenIP21Database(); - } else { - database = new neqsim.util.database.AspenIP21Database(); - } - try { - dataSet = - database.getResultSet(("SELECT * FROM IP_AnalogDef WHERE NAME='" + name + "'")); - dataSet.next(); - value = dataSet.getDouble("IP_VALUE"); - } catch (Exception e) { - // dataSet.close(); - return false; - } - return true; + /** + *

+ * connect. + *

+ * + * @return a boolean + */ + public boolean connect() { + if (plantName.equals("Karsto")) { + database = new neqsim.util.database.AspenIP21Database(); + } else { + database = new neqsim.util.database.AspenIP21Database(); } - - /** - *

- * getTimeStamp. - *

- * - * @return a {@link java.util.Date} object - */ - public Date getTimeStamp() { - return dateStamp; + try { + dataSet = database.getResultSet(("SELECT * FROM IP_AnalogDef WHERE NAME='" + name + "'")); + dataSet.next(); + value = dataSet.getDouble("IP_VALUE"); + } catch (Exception ex) { + // dataSet.close(); + return false; } + return true; + } + + /** + *

+ * getTimeStamp. + *

+ * + * @return a {@link java.util.Date} object + */ + public Date getTimeStamp() { + return dateStamp; + } - /** - *

- * Getter for the field value. - *

- * - * @return a double - */ - public double getValue() { - try { - // System.out.println("reading online vale from: " + transmitterName ); - dataSet = database.getResultSet( - ("SELECT * FROM IP_AnalogDef WHERE NAME='" + transmitterName + "'")); - dataSet.next(); - value = dataSet.getDouble("IP_VALUE"); - // System.out.println("value + " + value ); - } catch (Exception e) { - // dataSet.close(); - return 0; - } finally { - try { - dataSet.close(); - } catch (Exception e) { - // dataSet.close(); - return 0; - } - } - dateStamp = new Date(); // read dateStamp - return value; // read online measurement + /** + *

+ * Getter for the field value. + *

+ * + * @return a double + */ + public double getValue() { + try { + // System.out.println("reading online vale from: " + transmitterName ); + dataSet = database + .getResultSet(("SELECT * FROM IP_AnalogDef WHERE NAME='" + transmitterName + "'")); + dataSet.next(); + value = dataSet.getDouble("IP_VALUE"); + // System.out.println("value + " + value ); + } catch (Exception ex) { + // dataSet.close(); + return 0; + } finally { + try { + dataSet.close(); + } catch (Exception ex) { + // dataSet.close(); + return 0; + } } + dateStamp = new Date(); // read dateStamp + return value; // read online measurement + } } diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/AbsorptionColumnDesignStandard.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/AbsorptionColumnDesignStandard.java index 09e6ce406a..ebb7303b8d 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/AbsorptionColumnDesignStandard.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/AbsorptionColumnDesignStandard.java @@ -52,9 +52,9 @@ public AbsorptionColumnDesignStandard(String name, MechanicalDesign equipmentInn if (dataSet != null) { dataSet.close(); } - } catch (Exception e) { + } catch (Exception ex) { System.out.println("error closing database.....GasScrubberDesignStandard"); - logger.error(e.getMessage()); + logger.error(ex.getMessage()); } } } diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/AdsorptionDehydrationDesignStandard.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/AdsorptionDehydrationDesignStandard.java index c632f9eba0..e300c0d185 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/AdsorptionDehydrationDesignStandard.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/AdsorptionDehydrationDesignStandard.java @@ -53,9 +53,9 @@ public AdsorptionDehydrationDesignStandard(String name, MechanicalDesign equipme if (dataSet != null) { dataSet.close(); } - } catch (Exception e) { + } catch (Exception ex) { System.out.println("error closing database.....GasScrubberDesignStandard"); - logger.error(e.getMessage()); + logger.error(ex.getMessage()); } } } diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/CompressorDesignStandard.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/CompressorDesignStandard.java index 70097af041..56b35e27d8 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/CompressorDesignStandard.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/CompressorDesignStandard.java @@ -55,9 +55,9 @@ public CompressorDesignStandard(String name, MechanicalDesign equipmentInn) { if (dataSet != null) { dataSet.close(); } - } catch (Exception e) { + } catch (Exception ex) { System.out.println("error closing database.....GasScrubberDesignStandard"); - logger.error(e.getMessage()); + logger.error(ex.getMessage()); } } } diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/GasScrubberDesignStandard.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/GasScrubberDesignStandard.java index 6fb127820f..1bcddcffc8 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/GasScrubberDesignStandard.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/GasScrubberDesignStandard.java @@ -68,9 +68,9 @@ public GasScrubberDesignStandard(String name, MechanicalDesign equipmentInn) { if (dataSet != null) { dataSet.close(); } - } catch (Exception e) { + } catch (Exception ex) { System.out.println("error closing database.....GasScrubberDesignStandard"); - logger.error(e.getMessage()); + logger.error(ex.getMessage()); } } } diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/MaterialPipeDesignStandard.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/MaterialPipeDesignStandard.java index d3e6cf6e81..1851d6b173 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/MaterialPipeDesignStandard.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/MaterialPipeDesignStandard.java @@ -172,9 +172,9 @@ public void readMaterialDesignStandard(String specNo, String grade) { if (dataSet != null) { dataSet.close(); } - } catch (Exception e) { + } catch (Exception ex) { System.out.println("error closing database.....GasScrubberDesignStandard"); - logger.error(e.getMessage()); + logger.error(ex.getMessage()); } } } diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/MaterialPlateDesignStandard.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/MaterialPlateDesignStandard.java index cb7ae6044b..3659bb3636 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/MaterialPlateDesignStandard.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/MaterialPlateDesignStandard.java @@ -109,9 +109,9 @@ public void readMaterialDesignStandard(String name, String specNo, String grade, if (dataSet != null) { dataSet.close(); } - } catch (Exception e) { + } catch (Exception ex) { System.out.println("error closing database.....GasScrubberDesignStandard"); - logger.error(e.getMessage()); + logger.error(ex.getMessage()); } } } diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/PipelineDesignStandard.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/PipelineDesignStandard.java index 7d620fa4c2..d01cabb928 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/PipelineDesignStandard.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/PipelineDesignStandard.java @@ -58,9 +58,9 @@ public PipelineDesignStandard(String name, MechanicalDesign equipmentInn) { if (dataSet != null) { dataSet.close(); } - } catch (Exception e) { + } catch (Exception ex) { System.out.println("error closing database.....GasScrubberDesignStandard"); - logger.error(e.getMessage()); + logger.error(ex.getMessage()); } } } diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/SeparatorDesignStandard.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/SeparatorDesignStandard.java index 5faae7ed5e..f918e107c1 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/SeparatorDesignStandard.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/SeparatorDesignStandard.java @@ -88,9 +88,9 @@ public SeparatorDesignStandard(String name, MechanicalDesign equipmentInn) { if (dataSet != null) { dataSet.close(); } - } catch (Exception e) { + } catch (Exception ex) { System.out.println("error closing database.....GasScrubberDesignStandard"); - logger.error(e.getMessage()); + logger.error(ex.getMessage()); } } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartAlternativeMapLookup.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartAlternativeMapLookup.java index 288e3e085d..3c9944996e 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartAlternativeMapLookup.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartAlternativeMapLookup.java @@ -21,528 +21,519 @@ * @version $Id: $Id */ public class CompressorChartAlternativeMapLookup - implements CompressorChartInterface, java.io.Serializable { - private static final long serialVersionUID = 1000; - - static Logger logger = LogManager.getLogger(CompressorChart.class); - ArrayList chartValues = new ArrayList(); - ArrayList chartSpeeds = new ArrayList(); - private SurgeCurve surgeCurve = new SurgeCurve(); - private StoneWallCurve stoneWallCurve = new StoneWallCurve(); - boolean isSurge = false; - boolean isStoneWall = false; - double refMW; - private String headUnit = "meter"; - private boolean useCompressorChart = false; - double refTemperature; - double refPressure; - double referenceSpeed = 1000.0; - double refZ; - private boolean useRealKappa = false; - double[] chartConditions = null; - final WeightedObservedPoints reducedHeadFitter = new WeightedObservedPoints(); - final WeightedObservedPoints reducedFlowFitter = new WeightedObservedPoints(); - final WeightedObservedPoints fanLawCorrectionFitter = new WeightedObservedPoints(); - final WeightedObservedPoints reducedPolytropicEfficiencyFitter = new WeightedObservedPoints(); - PolynomialFunction reducedHeadFitterFunc = null; - PolynomialFunction reducedPolytropicEfficiencyFunc = null; - PolynomialFunction fanLawCorrectionFunc = null; - double gearRatio = 1.0; - - /** - *

- * Constructor for CompressorChartAlternativeMapLookup. - *

- */ - public CompressorChartAlternativeMapLookup() {} - - /** {@inheritDoc} */ - @Override - public void addCurve(double speed, double[] flow, double[] head, - double[] polytropicEfficiency) { - CompressorCurve curve = new CompressorCurve(speed, flow, head, polytropicEfficiency); - chartValues.add(curve); - chartSpeeds.add(speed); + implements CompressorChartInterface, java.io.Serializable { + private static final long serialVersionUID = 1000; + + static Logger logger = LogManager.getLogger(CompressorChart.class); + ArrayList chartValues = new ArrayList(); + ArrayList chartSpeeds = new ArrayList(); + private SurgeCurve surgeCurve = new SurgeCurve(); + private StoneWallCurve stoneWallCurve = new StoneWallCurve(); + boolean isSurge = false; + boolean isStoneWall = false; + double refMW; + private String headUnit = "meter"; + private boolean useCompressorChart = false; + double refTemperature; + double refPressure; + double referenceSpeed = 1000.0; + double refZ; + private boolean useRealKappa = false; + double[] chartConditions = null; + final WeightedObservedPoints reducedHeadFitter = new WeightedObservedPoints(); + final WeightedObservedPoints reducedFlowFitter = new WeightedObservedPoints(); + final WeightedObservedPoints fanLawCorrectionFitter = new WeightedObservedPoints(); + final WeightedObservedPoints reducedPolytropicEfficiencyFitter = new WeightedObservedPoints(); + PolynomialFunction reducedHeadFitterFunc = null; + PolynomialFunction reducedPolytropicEfficiencyFunc = null; + PolynomialFunction fanLawCorrectionFunc = null; + double gearRatio = 1.0; + + /** + *

+ * Constructor for CompressorChartAlternativeMapLookup. + *

+ */ + public CompressorChartAlternativeMapLookup() {} + + /** {@inheritDoc} */ + @Override + public void addCurve(double speed, double[] flow, double[] head, double[] polytropicEfficiency) { + CompressorCurve curve = new CompressorCurve(speed, flow, head, polytropicEfficiency); + chartValues.add(curve); + chartSpeeds.add(speed); + } + + /** {@inheritDoc} */ + @Override + public void setCurves(double[] chartConditions, double[] speed, double[][] flow, double[][] head, + double[][] polyEff) { + for (int i = 0; i < speed.length; i++) { + CompressorCurve curve = new CompressorCurve(speed[i], flow[i], head[i], polyEff[i]); + chartValues.add(curve); + chartSpeeds.add(speed[i]); } - /** {@inheritDoc} */ - @Override - public void setCurves(double[] chartConditions, double[] speed, double[][] flow, - double[][] head, double[][] polyEff) { - for (int i = 0; i < speed.length; i++) { - CompressorCurve curve = new CompressorCurve(speed[i], flow[i], head[i], polyEff[i]); - chartValues.add(curve); - chartSpeeds.add(speed[i]); - } - - setUseCompressorChart(true); + setUseCompressorChart(true); + } + + /** + *

+ * getClosestRefSpeeds. + *

+ * + * @param speed a double + * @return a {@link java.util.ArrayList} object + */ + public ArrayList getClosestRefSpeeds(double speed) { + ArrayList closestRefSpeeds = new ArrayList(); + Double[] speedArray = new Double[chartSpeeds.size()]; + speedArray = chartSpeeds.toArray(speedArray); + Arrays.sort(speedArray); + boolean speedOnRef = false; + + for (int i = 0; i < chartSpeeds.size(); i++) { + double s = chartValues.get(i).speed; + if (speed == s) { // speed is equal to a reference speed + closestRefSpeeds.add(s); + speedOnRef = true; + } } - /** - *

- * getClosestRefSpeeds. - *

- * - * @param speed a double - * @return a {@link java.util.ArrayList} object - */ - public ArrayList getClosestRefSpeeds(double speed) { - ArrayList closestRefSpeeds = new ArrayList(); - Double[] speedArray = new Double[chartSpeeds.size()]; - speedArray = chartSpeeds.toArray(speedArray); - Arrays.sort(speedArray); - boolean speedOnRef = false; - - for (int i = 0; i < chartSpeeds.size(); i++) { - double s = chartValues.get(i).speed; - if (speed == s) { // speed is equal to a reference speed - closestRefSpeeds.add(s); - speedOnRef = true; - } - } - - if (!speedOnRef) { - int pos = bisect_left(speedArray, speed); - if (pos == 0) { // speed is lower than the lowest reference speed - closestRefSpeeds.add(speedArray[0]); - } else if (pos == chartSpeeds.size()) { // speed is higher than the highest reference - // speed - closestRefSpeeds.add(speedArray[speedArray.length - 1]); - } else { // speed is in between two reference speeds - closestRefSpeeds.add(speedArray[pos - 1]); - closestRefSpeeds.add(speedArray[pos]); - } - } - return closestRefSpeeds; + if (!speedOnRef) { + int pos = bisect_left(speedArray, speed); + if (pos == 0) { // speed is lower than the lowest reference speed + closestRefSpeeds.add(speedArray[0]); + } else if (pos == chartSpeeds.size()) { // speed is higher than the highest reference + // speed + closestRefSpeeds.add(speedArray[speedArray.length - 1]); + } else { // speed is in between two reference speeds + closestRefSpeeds.add(speedArray[pos - 1]); + closestRefSpeeds.add(speedArray[pos]); + } } - - /** {@inheritDoc} */ - @Override - public double getPolytropicHead(double flow, double speed) { - ArrayList closestRefSpeeds = new ArrayList(); - closestRefSpeeds = getClosestRefSpeeds(speed); - double s; - // double speedRatio; - ArrayList tempHeads = new ArrayList(); - SplineInterpolator asi = new SplineInterpolator(); - - for (int i = 0; i < closestRefSpeeds.size(); i++) { - s = closestRefSpeeds.get(i); - // speedRatio = speed * gearRatio / s; - PolynomialSplineFunction psf = - asi.interpolate(getCurveAtRefSpeed(s).flow, getCurveAtRefSpeed(s).head); - tempHeads.add(psf.value(flow)); - } - - double sum = 0.0; - for (int i = 0; i < tempHeads.size(); i++) { - sum += tempHeads.get(i); - } - return sum / tempHeads.size(); + return closestRefSpeeds; + } + + /** {@inheritDoc} */ + @Override + public double getPolytropicHead(double flow, double speed) { + ArrayList closestRefSpeeds = new ArrayList(); + closestRefSpeeds = getClosestRefSpeeds(speed); + double s; + // double speedRatio; + ArrayList tempHeads = new ArrayList(); + SplineInterpolator asi = new SplineInterpolator(); + + for (int i = 0; i < closestRefSpeeds.size(); i++) { + s = closestRefSpeeds.get(i); + // speedRatio = speed * gearRatio / s; + PolynomialSplineFunction psf = + asi.interpolate(getCurveAtRefSpeed(s).flow, getCurveAtRefSpeed(s).head); + tempHeads.add(psf.value(flow)); } - /** {@inheritDoc} */ - @Override - public double getPolytropicEfficiency(double flow, double speed) { - ArrayList closestRefSpeeds = new ArrayList(); - closestRefSpeeds = getClosestRefSpeeds(speed); - double s; - ArrayList tempEffs = new ArrayList(); - SplineInterpolator asi = new SplineInterpolator(); - - for (int i = 0; i < closestRefSpeeds.size(); i++) { - s = closestRefSpeeds.get(i); - PolynomialSplineFunction psf = asi.interpolate(getCurveAtRefSpeed(s).flow, - getCurveAtRefSpeed(s).polytropicEfficiency); - tempEffs.add(psf.value(flow)); - } - - double sum = 0.0; - for (int i = 0; i < tempEffs.size(); i++) { - sum += tempEffs.get(i); - } - return sum / tempEffs.size(); + double sum = 0.0; + for (int i = 0; i < tempHeads.size(); i++) { + sum += tempHeads.get(i); } - - /** - *

- * addSurgeCurve. - *

- * - * @param flow an array of {@link double} objects - * @param head an array of {@link double} objects - */ - public void addSurgeCurve(double[] flow, double[] head) { - surgeCurve = new SurgeCurve(flow, head); + return sum / tempHeads.size(); + } + + /** {@inheritDoc} */ + @Override + public double getPolytropicEfficiency(double flow, double speed) { + ArrayList closestRefSpeeds = new ArrayList(); + closestRefSpeeds = getClosestRefSpeeds(speed); + double s; + ArrayList tempEffs = new ArrayList(); + SplineInterpolator asi = new SplineInterpolator(); + + for (int i = 0; i < closestRefSpeeds.size(); i++) { + s = closestRefSpeeds.get(i); + PolynomialSplineFunction psf = + asi.interpolate(getCurveAtRefSpeed(s).flow, getCurveAtRefSpeed(s).polytropicEfficiency); + tempEffs.add(psf.value(flow)); } - /** - *

- * getCurveAtRefSpeed. - *

- * - * @param refSpeed a double - * @return a {@link neqsim.processSimulation.processEquipment.compressor.CompressorCurve} object - */ - public CompressorCurve getCurveAtRefSpeed(double refSpeed) { - for (int i = 0; i < chartValues.size(); i++) { - CompressorCurve c = chartValues.get(i); - if (c.speed == refSpeed) { - return c; - } - } - String msg = "Does not match any speed in the chart."; - logger.error(msg); - neqsim.util.exception.InvalidInputException e = - new neqsim.util.exception.InvalidInputException(this, "getCurveAtRefSpeed", "refSpeed", - msg); - throw new RuntimeException(e); + double sum = 0.0; + for (int i = 0; i < tempEffs.size(); i++) { + sum += tempEffs.get(i); } - - /** - *

- * Getter for the field gearRatio. - *

- * - * @return a double - */ - public double getGearRatio() { - return gearRatio; + return sum / tempEffs.size(); + } + + /** + *

+ * addSurgeCurve. + *

+ * + * @param flow an array of {@link double} objects + * @param head an array of {@link double} objects + */ + public void addSurgeCurve(double[] flow, double[] head) { + surgeCurve = new SurgeCurve(flow, head); + } + + /** + *

+ * getCurveAtRefSpeed. + *

+ * + * @param refSpeed a double + * @return a {@link neqsim.processSimulation.processEquipment.compressor.CompressorCurve} object + */ + public CompressorCurve getCurveAtRefSpeed(double refSpeed) { + for (int i = 0; i < chartValues.size(); i++) { + CompressorCurve c = chartValues.get(i); + if (c.speed == refSpeed) { + return c; + } } - - /** - *

- * Setter for the field gearRatio. - *

- * - * @param GR a double + String msg = "Does not match any speed in the chart."; + logger.error(msg); + neqsim.util.exception.InvalidInputException ex = + new neqsim.util.exception.InvalidInputException(this, "getCurveAtRefSpeed", "refSpeed", + msg); + throw new RuntimeException(ex); + } + + /** + *

+ * Getter for the field gearRatio. + *

+ * + * @return a double + */ + public double getGearRatio() { + return gearRatio; + } + + /** + *

+ * Setter for the field gearRatio. + *

+ * + * @param GR a double + */ + public void setGearRatio(double GR) { + gearRatio = GR; + } + + /** + *

+ * polytropicEfficiency. + *

+ * + * @param flow a double + * @param speed a double + * @return a double + */ + public double polytropicEfficiency(double flow, double speed) { + return 100.0; + } + + /** {@inheritDoc} */ + @Override + public int getSpeed(double flow, double head) { + int iter = 1; + double error = 1.0, derrordspeed = 1.0; + double newspeed = referenceSpeed; + double newhead = 0.0; + double oldspeed = newspeed + 1.0; + double oldhead = getPolytropicHead(flow, oldspeed); + double olderror = oldhead - head; + do { + iter++; + newhead = getPolytropicHead(flow, newspeed); + error = newhead - head; + derrordspeed = (error - olderror) / (newspeed - oldspeed); + newspeed -= error / derrordspeed; + // System.out.println("speed " + newspeed); + } while (Math.abs(error) > 1e-6 && iter < 100); + + // change speed to minimize + // Math.abs(head - reducedHeadFitterFunc.value(flow / speed) * speed * speed); + return (int) Math.round(newspeed); + } + + /** + *

+ * checkSurge1. + *

+ * + * @param flow a double + * @param head a double + * @return a boolean + */ + public boolean checkSurge1(double flow, double head) { + return false; + } + + /** + *

+ * checkSurge2. + *

+ * + * @param flow a double + * @param speed a double + * @return a boolean + */ + public boolean checkSurge2(double flow, double speed) { + return false; + } + + /** + *

+ * checkStoneWall. + *

+ * + * @param flow a double + * @param speed a double + * @return a boolean + */ + public boolean checkStoneWall(double flow, double speed) { + return false; + } + + /** {@inheritDoc} */ + @Override + public void setReferenceConditions(double refMW, double refTemperature, double refPressure, + double refZ) { + this.refMW = refMW; + this.refTemperature = refTemperature; + this.refPressure = refPressure; + this.refZ = refZ; + } + + /** {@inheritDoc} */ + @Override + public SurgeCurve getSurgeCurve() { + return surgeCurve; + } + + /** {@inheritDoc} */ + @Override + public void setSurgeCurve(SurgeCurve surgeCurve) { + this.surgeCurve = surgeCurve; + } + + /** {@inheritDoc} */ + @Override + public StoneWallCurve getStoneWallCurve() { + return stoneWallCurve; + } + + /** {@inheritDoc} */ + @Override + public void setStoneWallCurve(StoneWallCurve stoneWallCurve) { + this.stoneWallCurve = stoneWallCurve; + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + SystemInterface testFluid = new SystemSrkEos(298.15, 50.0); + + // testFluid.addComponent("methane", 1.0); + // testFluid.setMixingRule(2); + // testFluid.setTotalFlowRate(0.635, "MSm3/day"); + + testFluid.addComponent("nitrogen", 1.205); + testFluid.addComponent("CO2", 1.340); + testFluid.addComponent("methane", 87.974); + testFluid.addComponent("ethane", 5.258); + testFluid.addComponent("propane", 3.283); + testFluid.addComponent("i-butane", 0.082); + testFluid.addComponent("n-butane", 0.487); + testFluid.addComponent("i-pentane", 0.056); + testFluid.addComponent("n-pentane", 0.053); + testFluid.setMixingRule(2); + testFluid.setMultiPhaseCheck(true); + + testFluid.setTemperature(24.0, "C"); + testFluid.setPressure(48.0, "bara"); + // testFluid.setTotalFlowRate(3.635, "MSm3/day"); + testFluid.setTotalFlowRate(5.4, "MSm3/day"); + + Stream stream_1 = new Stream("Stream1", testFluid); + Compressor comp1 = new Compressor("cmp1", true); + comp1.setInletStream(stream_1); + comp1.setUsePolytropicCalc(true); + // comp1.getAntiSurge().setActive(true); + comp1.setSpeed(11918); + + double[] chartConditions = new double[] {0.3, 1.0, 1.0, 1.0}; + /* + * double[] speed = new double[] { 1000.0, 2000.0, 3000.0, 4000.0 }; double[][] flow = new + * double[][] { { 453.2, 600.0, 750.0, 800.0 }, { 453.2, 600.0, 750.0, 800.0 }, { 453.2, 600.0, + * 750.0, 800.0 }, { 453.2, 600.0, 750.0, 800.0 } }; double[][] head = new double[][] { { + * 10000.0, 9000.0, 8000.0, 7500.0 }, { 10000.0, 9000.0, 8000.0, 7500.0 }, { 10000.0, 9000.0, + * 8000.0, 7500.0 }, { 10000.0, 9000.0, 8000.0, 7500.0 } }; double[][] polyEff = new double[][] + * { { 90.0, 91.0, 89.0, 88.0 }, { 90.0, 91.0, 89.0, 88.0 }, { 90.0, 91.0, 89.0, 88.1 }, { 90.0, + * 91.0, 89.0, 88.1 } }; */ - public void setGearRatio(double GR) { - gearRatio = GR; - } - /** - *

- * polytropicEfficiency. - *

- * - * @param flow a double - * @param speed a double - * @return a double + double[] speed = new double[] {12913, 12298, 11683, 11098, 10453, 9224, 8609, 8200}; + double[][] flow = new double[][] { + {2789.1285, 3174.0375, 3689.2288, 4179.4503, 4570.2768, 4954.7728, 5246.0329, 5661.0331}, + {2571.1753, 2943.7254, 3440.2675, 3837.4448, 4253.0898, 4668.6643, 4997.1926, 5387.4952}, + {2415.3793, 2763.0706, 3141.7095, 3594.7436, 4047.6467, 4494.1889, 4853.7353, 5138.7858}, + {2247.2043, 2799.7342, 3178.3428, 3656.1551, 4102.778, 4394.1591, 4648.3224, 4840.4998}, + {2072.8397, 2463.9483, 2836.4078, 3202.5266, 3599.6333, 3978.0203, 4257.0022, 4517.345}, + {1835.9552, 2208.455, 2618.1322, 2940.8034, 3244.7852, 3530.1279, 3753.3738, 3895.9746}, + {1711.3386, 1965.8848, 2356.9431, 2685.9247, 3008.5154, 3337.2855, 3591.5092}, + {1636.5807, 2002.8708, 2338.0319, 2642.1245, 2896.4894, 3113.6264, 3274.8764, 3411.2977}}; + double[][] head = + new double[][] {{80.0375, 78.8934, 76.2142, 71.8678, 67.0062, 60.6061, 53.0499, 39.728}, + {72.2122, 71.8369, 68.9009, 65.8341, 60.7167, 54.702, 47.2749, 35.7471}, + {65.1576, 64.5253, 62.6118, 59.1619, 54.0455, 47.0059, 39.195, 31.6387}, + {58.6154, 56.9627, 54.6647, 50.4462, 44.4322, 38.4144, 32.9084, 28.8109}, + {52.3295, 51.0573, 49.5283, 46.3326, 42.3685, 37.2502, 31.4884, 25.598}, + {40.6578, 39.6416, 37.6008, 34.6603, 30.9503, 27.1116, 23.2713, 20.4546}, + {35.2705, 34.6359, 32.7228, 31.0645, 27.0985, 22.7482, 18.0113}, + {32.192, 31.1756, 29.1329, 26.833, 23.8909, 21.3324, 18.7726, 16.3403},}; + double[][] polyEff = new double[][] { + {77.2452238409573, 79.4154186459363, 80.737960012489, 80.5229826589649, 79.2210931638144, + 75.4719133864634, 69.6034181197298, 58.7322388482707}, + {77.0107837113504, 79.3069974136389, 80.8941189021135, 80.7190194665918, 79.5313242980328, + 75.5912622896367, 69.6846136362097, 60.0043057990909}, + {77.0043065299874, 79.1690958847856, 80.8038169975675, 80.6543975614197, 78.8532389102705, + 73.6664774270613, 66.2735600426727, 57.671664571658}, + {77.0716623789093, 80.4629750233093, 81.1390811169072, 79.6374242667478, 75.380928428817, + 69.5332969549779, 63.7997587622339, 58.8120614497758}, + {76.9705872525642, 79.8335492585324, 80.9468133671171, 80.5806471927835, 78.0462158225426, + 73.0403707523258, 66.5572286338589, 59.8624822515064}, + {77.5063036680357, 80.2056198362559, 81.0339108025933, 79.6085962687939, 76.3814534404405, + 70.8027503005902, 64.6437367160571, 60.5299349982342}, + {77.8175271586685, 80.065165942218, 81.0631362122632, 79.8955051771299, 76.1983240929369, + 69.289982774309, 60.8567149372229}, + {78.0924334304045, 80.9353551568667, 80.7904437766234, 78.8639325223295, 75.2170936751143, + 70.3105081673411, 65.5507568533569, 61.0391468300337}}; + + // double[] chartConditions = new double[] { 0.3, 1.0, 1.0, 1.0 }; + // double[] speed = new double[] { 13402.0 }; + // double[][] flow = new double[][] { { 1050.0, 1260.0, 1650.0, 1950.0 } }; + // double[][] head = new double[][] { { 8555.0, 8227.0, 6918.0, 5223.0 } }; + // double[][] head = new double[][] { { 85.0, 82.0, 69.0, 52.0 } }; + // double[][] polyEff = new double[][] { { 66.8, 69.0, 66.4, 55.6 } }; + comp1.getCompressorChart().setCurves(chartConditions, speed, flow, head, polyEff); + // comp1.getCompressorChart().setHeadUnit("kJ/kg"); + /* + * double[] surgeflow = new double[] { 453.2, 550.0, 700.0, 800.0 }; double[] surgehead = new + * double[] { 6000.0, 7000.0, 8000.0, 10000.0 }; + * comp1.getCompressorChart().getSurgeCurve().setCurve(chartConditions, surgeflow, surgehead); + * + * double[] stoneWallflow = new double[] { 923.2, 950.0, 980.0, 1000.0 }; double[] stoneWallHead + * = new double[] { 6000.0, 7000.0, 8000.0, 10000.0 }; + * comp1.getCompressorChart().getStoneWallCurve().setCurve(chartConditions, stoneWallflow, + * stoneWallHead); */ - public double polytropicEfficiency(double flow, double speed) { - return 100.0; + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(comp1); + operations.run(); + operations.displayResult(); + + System.out.println("power " + comp1.getPower()); + System.out + .println("fraction in anti surge line " + comp1.getAntiSurge().getCurrentSurgeFraction()); + System.out.println("Polytropic head from curve:" + comp1.getPolytropicHead()); + System.out.println("Polytropic eff from curve:" + comp1.getPolytropicEfficiency() * 100.0); + System.out.println("flow " + stream_1.getThermoSystem().getFlowRate("m3/hr")); + } + + /** {@inheritDoc} */ + @Override + public boolean isUseCompressorChart() { + return useCompressorChart; + } + + /** {@inheritDoc} */ + @Override + public void setUseCompressorChart(boolean useCompressorChart) { + this.useCompressorChart = useCompressorChart; + } + + /** {@inheritDoc} */ + @Override + public String getHeadUnit() { + return headUnit; + } + + /** {@inheritDoc} */ + @Override + public void setHeadUnit(String headUnit) { + this.headUnit = headUnit; + } + + /** {@inheritDoc} */ + @Override + public boolean useRealKappa() { + return useRealKappa; + } + + /** {@inheritDoc} */ + @Override + public void setUseRealKappa(boolean useRealKappa) { + this.useRealKappa = useRealKappa; + } + + /** + *

+ * bisect_left. + *

+ * + * @param A an array of {@link java.lang.Double} objects + * @param x a double + * @return a int + */ + public static int bisect_left(Double[] A, double x) { + return bisect_left(A, x, 0, A.length); + } + + /** + *

+ * bisect_left. + *

+ * + * @param A an array of {@link java.lang.Double} objects + * @param x a double + * @param lo a int + * @param hi a int + * @return a int + */ + public static int bisect_left(Double[] A, double x, int lo, int hi) { + int N = A.length; + if (N == 0) { + return 0; } - - /** {@inheritDoc} */ - @Override - public int getSpeed(double flow, double head) { - int iter = 1; - double error = 1.0, derrordspeed = 1.0; - double newspeed = referenceSpeed; - double newhead = 0.0; - double oldspeed = newspeed + 1.0; - double oldhead = getPolytropicHead(flow, oldspeed); - double olderror = oldhead - head; - do { - iter++; - newhead = getPolytropicHead(flow, newspeed); - error = newhead - head; - derrordspeed = (error - olderror) / (newspeed - oldspeed); - newspeed -= error / derrordspeed; - // System.out.println("speed " + newspeed); - } while (Math.abs(error) > 1e-6 && iter < 100); - - // change speed to minimize - // Math.abs(head - reducedHeadFitterFunc.value(flow / speed) * speed * speed); - return (int) Math.round(newspeed); + if (x < A[lo]) { + return lo; } - - /** - *

- * checkSurge1. - *

- * - * @param flow a double - * @param head a double - * @return a boolean - */ - public boolean checkSurge1(double flow, double head) { - return false; - } - - /** - *

- * checkSurge2. - *

- * - * @param flow a double - * @param speed a double - * @return a boolean - */ - public boolean checkSurge2(double flow, double speed) { - return false; - } - - /** - *

- * checkStoneWall. - *

- * - * @param flow a double - * @param speed a double - * @return a boolean - */ - public boolean checkStoneWall(double flow, double speed) { - return false; - } - - /** {@inheritDoc} */ - @Override - public void setReferenceConditions(double refMW, double refTemperature, double refPressure, - double refZ) { - this.refMW = refMW; - this.refTemperature = refTemperature; - this.refPressure = refPressure; - this.refZ = refZ; - } - - /** {@inheritDoc} */ - @Override - public SurgeCurve getSurgeCurve() { - return surgeCurve; - } - - /** {@inheritDoc} */ - @Override - public void setSurgeCurve(SurgeCurve surgeCurve) { - this.surgeCurve = surgeCurve; + if (x > A[hi - 1]) { + return hi; } - - /** {@inheritDoc} */ - @Override - public StoneWallCurve getStoneWallCurve() { - return stoneWallCurve; - } - - /** {@inheritDoc} */ - @Override - public void setStoneWallCurve(StoneWallCurve stoneWallCurve) { - this.stoneWallCurve = stoneWallCurve; - } - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - SystemInterface testFluid = new SystemSrkEos(298.15, 50.0); - - // testFluid.addComponent("methane", 1.0); - // testFluid.setMixingRule(2); - // testFluid.setTotalFlowRate(0.635, "MSm3/day"); - - testFluid.addComponent("nitrogen", 1.205); - testFluid.addComponent("CO2", 1.340); - testFluid.addComponent("methane", 87.974); - testFluid.addComponent("ethane", 5.258); - testFluid.addComponent("propane", 3.283); - testFluid.addComponent("i-butane", 0.082); - testFluid.addComponent("n-butane", 0.487); - testFluid.addComponent("i-pentane", 0.056); - testFluid.addComponent("n-pentane", 0.053); - testFluid.setMixingRule(2); - testFluid.setMultiPhaseCheck(true); - - testFluid.setTemperature(24.0, "C"); - testFluid.setPressure(48.0, "bara"); - // testFluid.setTotalFlowRate(3.635, "MSm3/day"); - testFluid.setTotalFlowRate(5.4, "MSm3/day"); - - Stream stream_1 = new Stream("Stream1", testFluid); - Compressor comp1 = new Compressor("cmp1", true); - comp1.setInletStream(stream_1); - comp1.setUsePolytropicCalc(true); - // comp1.getAntiSurge().setActive(true); - comp1.setSpeed(11918); - - double[] chartConditions = new double[] {0.3, 1.0, 1.0, 1.0}; - /* - * double[] speed = new double[] { 1000.0, 2000.0, 3000.0, 4000.0 }; double[][] flow = new - * double[][] { { 453.2, 600.0, 750.0, 800.0 }, { 453.2, 600.0, 750.0, 800.0 }, { 453.2, - * 600.0, 750.0, 800.0 }, { 453.2, 600.0, 750.0, 800.0 } }; double[][] head = new double[][] - * { { 10000.0, 9000.0, 8000.0, 7500.0 }, { 10000.0, 9000.0, 8000.0, 7500.0 }, { 10000.0, - * 9000.0, 8000.0, 7500.0 }, { 10000.0, 9000.0, 8000.0, 7500.0 } }; double[][] polyEff = new - * double[][] { { 90.0, 91.0, 89.0, 88.0 }, { 90.0, 91.0, 89.0, 88.0 }, { 90.0, 91.0, 89.0, - * 88.1 }, { 90.0, 91.0, 89.0, 88.1 } }; - */ - - double[] speed = new double[] {12913, 12298, 11683, 11098, 10453, 9224, 8609, 8200}; - double[][] flow = new double[][] { - {2789.1285, 3174.0375, 3689.2288, 4179.4503, 4570.2768, 4954.7728, 5246.0329, - 5661.0331}, - {2571.1753, 2943.7254, 3440.2675, 3837.4448, 4253.0898, 4668.6643, 4997.1926, - 5387.4952}, - {2415.3793, 2763.0706, 3141.7095, 3594.7436, 4047.6467, 4494.1889, 4853.7353, - 5138.7858}, - {2247.2043, 2799.7342, 3178.3428, 3656.1551, 4102.778, 4394.1591, 4648.3224, - 4840.4998}, - {2072.8397, 2463.9483, 2836.4078, 3202.5266, 3599.6333, 3978.0203, 4257.0022, - 4517.345}, - {1835.9552, 2208.455, 2618.1322, 2940.8034, 3244.7852, 3530.1279, 3753.3738, - 3895.9746}, - {1711.3386, 1965.8848, 2356.9431, 2685.9247, 3008.5154, 3337.2855, 3591.5092}, - {1636.5807, 2002.8708, 2338.0319, 2642.1245, 2896.4894, 3113.6264, 3274.8764, - 3411.2977}}; - double[][] head = new double[][] { - {80.0375, 78.8934, 76.2142, 71.8678, 67.0062, 60.6061, 53.0499, 39.728}, - {72.2122, 71.8369, 68.9009, 65.8341, 60.7167, 54.702, 47.2749, 35.7471}, - {65.1576, 64.5253, 62.6118, 59.1619, 54.0455, 47.0059, 39.195, 31.6387}, - {58.6154, 56.9627, 54.6647, 50.4462, 44.4322, 38.4144, 32.9084, 28.8109}, - {52.3295, 51.0573, 49.5283, 46.3326, 42.3685, 37.2502, 31.4884, 25.598}, - {40.6578, 39.6416, 37.6008, 34.6603, 30.9503, 27.1116, 23.2713, 20.4546}, - {35.2705, 34.6359, 32.7228, 31.0645, 27.0985, 22.7482, 18.0113}, - {32.192, 31.1756, 29.1329, 26.833, 23.8909, 21.3324, 18.7726, 16.3403},}; - double[][] polyEff = new double[][] { - {77.2452238409573, 79.4154186459363, 80.737960012489, 80.5229826589649, - 79.2210931638144, 75.4719133864634, 69.6034181197298, 58.7322388482707}, - {77.0107837113504, 79.3069974136389, 80.8941189021135, 80.7190194665918, - 79.5313242980328, 75.5912622896367, 69.6846136362097, 60.0043057990909}, - {77.0043065299874, 79.1690958847856, 80.8038169975675, 80.6543975614197, - 78.8532389102705, 73.6664774270613, 66.2735600426727, 57.671664571658}, - {77.0716623789093, 80.4629750233093, 81.1390811169072, 79.6374242667478, - 75.380928428817, 69.5332969549779, 63.7997587622339, 58.8120614497758}, - {76.9705872525642, 79.8335492585324, 80.9468133671171, 80.5806471927835, - 78.0462158225426, 73.0403707523258, 66.5572286338589, 59.8624822515064}, - {77.5063036680357, 80.2056198362559, 81.0339108025933, 79.6085962687939, - 76.3814534404405, 70.8027503005902, 64.6437367160571, 60.5299349982342}, - {77.8175271586685, 80.065165942218, 81.0631362122632, 79.8955051771299, - 76.1983240929369, 69.289982774309, 60.8567149372229}, - {78.0924334304045, 80.9353551568667, 80.7904437766234, 78.8639325223295, - 75.2170936751143, 70.3105081673411, 65.5507568533569, 61.0391468300337}}; - - // double[] chartConditions = new double[] { 0.3, 1.0, 1.0, 1.0 }; - // double[] speed = new double[] { 13402.0 }; - // double[][] flow = new double[][] { { 1050.0, 1260.0, 1650.0, 1950.0 } }; - // double[][] head = new double[][] { { 8555.0, 8227.0, 6918.0, 5223.0 } }; - // double[][] head = new double[][] { { 85.0, 82.0, 69.0, 52.0 } }; - // double[][] polyEff = new double[][] { { 66.8, 69.0, 66.4, 55.6 } }; - comp1.getCompressorChart().setCurves(chartConditions, speed, flow, head, polyEff); - // comp1.getCompressorChart().setHeadUnit("kJ/kg"); - /* - * double[] surgeflow = new double[] { 453.2, 550.0, 700.0, 800.0 }; double[] surgehead = - * new double[] { 6000.0, 7000.0, 8000.0, 10000.0 }; - * comp1.getCompressorChart().getSurgeCurve().setCurve(chartConditions, surgeflow, - * surgehead); - * - * double[] stoneWallflow = new double[] { 923.2, 950.0, 980.0, 1000.0 }; double[] - * stoneWallHead = new double[] { 6000.0, 7000.0, 8000.0, 10000.0 }; - * comp1.getCompressorChart().getStoneWallCurve().setCurve(chartConditions, stoneWallflow, - * stoneWallHead); - */ - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_1); - operations.add(comp1); - operations.run(); - operations.displayResult(); - - System.out.println("power " + comp1.getPower()); - System.out.println( - "fraction in anti surge line " + comp1.getAntiSurge().getCurrentSurgeFraction()); - System.out.println("Polytropic head from curve:" + comp1.getPolytropicHead()); - System.out.println("Polytropic eff from curve:" + comp1.getPolytropicEfficiency() * 100.0); - System.out.println("flow " + stream_1.getThermoSystem().getFlowRate("m3/hr")); - } - - /** {@inheritDoc} */ - @Override - public boolean isUseCompressorChart() { - return useCompressorChart; - } - - /** {@inheritDoc} */ - @Override - public void setUseCompressorChart(boolean useCompressorChart) { - this.useCompressorChart = useCompressorChart; - } - - /** {@inheritDoc} */ - @Override - public String getHeadUnit() { - return headUnit; - } - - /** {@inheritDoc} */ - @Override - public void setHeadUnit(String headUnit) { - this.headUnit = headUnit; - } - - /** {@inheritDoc} */ - @Override - public boolean useRealKappa() { - return useRealKappa; - } - - /** {@inheritDoc} */ - @Override - public void setUseRealKappa(boolean useRealKappa) { - this.useRealKappa = useRealKappa; - } - - /** - *

- * bisect_left. - *

- * - * @param A an array of {@link java.lang.Double} objects - * @param x a double - * @return a int - */ - public static int bisect_left(Double[] A, double x) { - return bisect_left(A, x, 0, A.length); - } - - /** - *

- * bisect_left. - *

- * - * @param A an array of {@link java.lang.Double} objects - * @param x a double - * @param lo a int - * @param hi a int - * @return a int - */ - public static int bisect_left(Double[] A, double x, int lo, int hi) { - int N = A.length; - if (N == 0) { - return 0; - } - if (x < A[lo]) { - return lo; - } - if (x > A[hi - 1]) { - return hi; - } - for (;;) { - if (lo + 1 == hi) { - return x == A[lo] ? lo : (lo + 1); - } - int mi = (hi + lo) / 2; - if (x <= A[mi]) { - hi = mi; - } else { - lo = mi; - } - } + for (;;) { + if (lo + 1 == hi) { + return x == A[lo] ? lo : (lo + 1); + } + int mi = (hi + lo) / 2; + if (x <= A[mi]) { + hi = mi; + } else { + lo = mi; + } } + } - /** {@inheritDoc} */ - @Override - public void plot() {} + /** {@inheritDoc} */ + @Override + public void plot() {} } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/distillation/SimpleTray.java b/src/main/java/neqsim/processSimulation/processEquipment/distillation/SimpleTray.java index 2c96e6454b..63ebad0b07 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/distillation/SimpleTray.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/distillation/SimpleTray.java @@ -154,7 +154,7 @@ public void run(UUID id) { } else { try { testOps.PHflash(enthalpy, 0); - } catch (Exception e) { + } catch (Exception ex) { if (!Double.isNaN(getOutTemperature())) { mixedStream.getThermoSystem().setTemperature(getOutTemperature()); } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/Fittings.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/Fittings.java index 61d72a0763..e5b5d92e02 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/Fittings.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/Fittings.java @@ -14,114 +14,112 @@ * @version $Id: $Id */ public class Fittings implements Serializable { + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(Fittings.class); + + ArrayList fittingList = new ArrayList(); + + /** + *

+ * Constructor for Fittings. + *

+ */ + public Fittings() {} + + /** + *

+ * add. + *

+ * + * @param name a {@link java.lang.String} object + * @param LdivD a double + */ + public void add(String name, double LdivD) { + fittingList.add(new Fitting(name, LdivD)); + } + + /** + *

+ * add. + *

+ * + * @param name a {@link java.lang.String} object + */ + public void add(String name) { + fittingList.add(new Fitting(name)); + } + + /** + *

+ * getFittingsList. + *

+ * + * @return a {@link java.util.ArrayList} object + */ + public ArrayList getFittingsList() { + return fittingList; + } + + public class Fitting implements Serializable { private static final long serialVersionUID = 1000; - static Logger logger = LogManager.getLogger(Fittings.class); - ArrayList fittingList = new ArrayList(); + private String fittingName = ""; + private double LtoD = 1.0; - /** - *

- * Constructor for Fittings. - *

- */ - public Fittings() {} + public Fitting(String name, double LdivD) { + this.fittingName = name; + LtoD = LdivD; + } + + public Fitting(String name) { + this.fittingName = name; + + neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); + java.sql.ResultSet dataSet = null; + try { + dataSet = database.getResultSet(("SELECT * FROM fittings WHERE name='" + name + "'")); + dataSet.next(); + LtoD = (Double.parseDouble(dataSet.getString("LtoD"))); + System.out.printf("LtoD " + LtoD); + } catch (Exception ex) { + System.out.println("error in comp"); + logger.error(ex.getMessage()); + } finally { + try { + dataSet.close(); + } catch (Exception ex) { + System.out.println("error closing database....."); + logger.error(ex.getMessage()); + } + } + } /** - *

- * add. - *

- * - * @param name a {@link java.lang.String} object - * @param LdivD a double + * @return the fittingName */ - public void add(String name, double LdivD) { - fittingList.add(new Fitting(name, LdivD)); + public String getFittingName() { + return fittingName; } /** - *

- * add. - *

- * - * @param name a {@link java.lang.String} object + * @param fittingName the fittingName to set */ - public void add(String name) { - fittingList.add(new Fitting(name)); + public void setFittingName(String fittingName) { + this.fittingName = fittingName; } /** - *

- * getFittingsList. - *

- * - * @return a {@link java.util.ArrayList} object + * @return the LtoD */ - public ArrayList getFittingsList() { - return fittingList; + public double getLtoD() { + return LtoD; } - public class Fitting implements Serializable { - private static final long serialVersionUID = 1000; - - private String fittingName = ""; - private double LtoD = 1.0; - - public Fitting(String name, double LdivD) { - this.fittingName = name; - LtoD = LdivD; - } - - public Fitting(String name) { - this.fittingName = name; - - neqsim.util.database.NeqSimDataBase database = - new neqsim.util.database.NeqSimDataBase(); - java.sql.ResultSet dataSet = null; - try { - dataSet = - database.getResultSet(("SELECT * FROM fittings WHERE name='" + name + "'")); - dataSet.next(); - LtoD = (Double.parseDouble(dataSet.getString("LtoD"))); - System.out.printf("LtoD " + LtoD); - } catch (Exception e) { - System.out.println("error in comp"); - logger.error(e.getMessage()); - } finally { - try { - dataSet.close(); - } catch (Exception e) { - System.out.println("error closing database....."); - logger.error(e.getMessage()); - } - } - } - - /** - * @return the fittingName - */ - public String getFittingName() { - return fittingName; - } - - /** - * @param fittingName the fittingName to set - */ - public void setFittingName(String fittingName) { - this.fittingName = fittingName; - } - - /** - * @return the LtoD - */ - public double getLtoD() { - return LtoD; - } - - /** - * @param LtoD the LtoD to set - */ - public void setLtoD(double LtoD) { - this.LtoD = LtoD; - } + /** + * @param LtoD the LtoD to set + */ + public void setLtoD(double LtoD) { + this.LtoD = LtoD; } + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java index 96e1b165bb..492ff3d7d3 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java @@ -718,7 +718,7 @@ public double getEntropyProduction(String unit) { if (thermoSystem.hasPhaseType("aqueous") || thermoSystem.hasPhaseType("oil")) { try { getLiquidOutStream().getThermoSystem().init(3); - } catch (Exception e) { + } catch (Exception ex) { } } if (thermoSystem.hasPhaseType("gas")) { diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/EnergyStream.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/EnergyStream.java index 832dbb167b..ba7a2abb77 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/EnergyStream.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/EnergyStream.java @@ -24,8 +24,8 @@ public EnergyStream clone() { EnergyStream clonedStream = null; try { clonedStream = (EnergyStream) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); + } catch (Exception ex) { + ex.printStackTrace(); } return clonedStream; } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/EquilibriumStream.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/EquilibriumStream.java index 438eb2df1c..8a3a00078f 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/EquilibriumStream.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/EquilibriumStream.java @@ -78,8 +78,8 @@ public EquilibriumStream clone() { try { clonedStream = (EquilibriumStream) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); + } catch (Exception ex) { + ex.printStackTrace(); } thermoSystem = thermoSystem.clone(); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/IronIonSaturationStream.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/IronIonSaturationStream.java index cc64d2fec1..c38c1121f7 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/IronIonSaturationStream.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/IronIonSaturationStream.java @@ -97,8 +97,8 @@ public IronIonSaturationStream clone() { IronIonSaturationStream clonedSystem = null; try { clonedSystem = (IronIonSaturationStream) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); + } catch (Exception ex) { + ex.printStackTrace(); } return clonedSystem; } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/NeqStream.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/NeqStream.java index bcb7604aea..381aa32c11 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/NeqStream.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/NeqStream.java @@ -89,8 +89,8 @@ public NeqStream clone() { try { clonedStream = (NeqStream) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); + } catch (Exception ex) { + ex.printStackTrace(); } thermoSystem = thermoSystem.clone(); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/ScalePotentialCheckStream.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/ScalePotentialCheckStream.java index 9cbc1b5266..84ba03f199 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/ScalePotentialCheckStream.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/ScalePotentialCheckStream.java @@ -90,8 +90,8 @@ public ScalePotentialCheckStream clone() { ScalePotentialCheckStream clonedSystem = null; try { clonedSystem = (ScalePotentialCheckStream) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); + } catch (Exception ex) { + ex.printStackTrace(); } return clonedSystem; } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java index 331cfd1c8b..2d1cd21734 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java @@ -29,7 +29,7 @@ public class Stream extends ProcessEquipmentBaseClass implements StreamInterface protected SystemInterface thermoSystem; protected int streamNumber = 0; - /** Constant numberOfStreams=0 */ + /** Constant numberOfStreams=0. */ protected static int numberOfStreams = 0; private double gasQuality = 0.5; protected StreamInterface stream = null; @@ -182,8 +182,8 @@ public Stream clone() { Stream clonedSystem = null; try { clonedSystem = (Stream) super.clone(); - } catch (Exception e) { - e.printStackTrace(System.err); + } catch (Exception ex) { + ex.printStackTrace(); } if (stream != null) { clonedSystem.setStream((Stream) stream.clone()); @@ -505,7 +505,7 @@ public double TVP(double temperature, String unit) { ThermodynamicOperations ops = new ThermodynamicOperations(localSyst); try { ops.bubblePointPressureFlash(false); - } catch (Exception e) { + } catch (Exception ex) { } return localSyst.getPressure(unit); } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/Calculator.java b/src/main/java/neqsim/processSimulation/processEquipment/util/Calculator.java index 93974db80b..e2cd16ecaa 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/Calculator.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/Calculator.java @@ -77,8 +77,8 @@ public void run(UUID id) { try { ((Stream) outputVariable).setFlowRate(sum, "kg/hr"); outputVariable.setCalculationIdentifier(id); - } catch (Exception e) { - logger.error("error", e.getMessage()); + } catch (Exception ex) { + logger.error("error", ex.getMessage()); } setCalculationIdentifier(id); } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java b/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java index 24a9747825..28fd9512f7 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java @@ -264,8 +264,8 @@ public void run(UUID id) { setDownstreamProperties(); try { enthalpy = calcMixStreamEnthalpy(); - } catch (Exception e) { - // String error = e.getMessage(); + } catch (Exception ex) { + // String error = ex.getMessage(); return; } // System.out.println("temp guess " + guessTemperature()); diff --git a/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java b/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java index 5b02f99109..15ad8433aa 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java +++ b/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java @@ -399,18 +399,18 @@ public void run(UUID id) { if (!unitOperations.get(i).getClass().getSimpleName().equals("Recycle")) { try { ((ProcessEquipmentInterface) unitOperations.get(i)).run(); - } catch (Exception e) { - // String error = e.getMessage(); - logger.error(e.getMessage()); + } catch (Exception ex) { + // String error = ex.getMessage(); + logger.error(ex.getMessage()); } } if (unitOperations.get(i).getClass().getSimpleName().equals("Recycle") && recycleController.doSolveRecycle((Recycle) unitOperations.get(i))) { try { ((ProcessEquipmentInterface) unitOperations.get(i)).run(); - } catch (Exception e) { - // String error = e.getMessage(); - logger.error(e.getMessage()); + } catch (Exception ex) { + // String error = ex.getMessage(); + logger.error(ex.getMessage()); } } } @@ -560,7 +560,7 @@ public void view() { public void displayResult() { try { thisThread.join(); - } catch (Exception e) { + } catch (Exception ex) { System.out.println("Thread did not finish"); } for (int i = 0; i < unitOperations.size(); i++) { @@ -583,7 +583,7 @@ public void displayResult() { public void reportMeasuredValues() { try { thisThread.join(); - } catch (Exception e) { + } catch (Exception ex) { System.out.println("Thread did not finish"); } for (int i = 0; i < measurementDevices.size(); i++) { @@ -608,9 +608,9 @@ public void save(String filePath) { try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(filePath, false))) { out.writeObject(this); logger.info("process file saved to: " + filePath); - } catch (Exception e) { - logger.error(e.toString()); - logger.error(e.getMessage()); + } catch (Exception ex) { + logger.error(ex.toString()); + logger.error(ex.getMessage()); } } @@ -627,9 +627,9 @@ public static ProcessSystem open(String filePath) { new ObjectInputStream(new FileInputStream(filePath))) { return (ProcessSystem) objectinputstream.readObject(); // logger.info("process file open ok: " + filePath); - } catch (Exception e) { - // logger.error(e.toString()); - logger.error(e.getMessage()); + } catch (Exception ex) { + // logger.error(ex.toString()); + logger.error(ex.getMessage()); } return null; } diff --git a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6578.java b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6578.java index 085ed1bcc3..4de02af8d3 100644 --- a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6578.java +++ b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6578.java @@ -200,8 +200,8 @@ public void calculate() { // thermoSystem.getTemperature(); try { Vi[i] = function.value(thermoSystem.getTemperature()); - } catch (Exception e) { - // logger.error(e.getMessage()); + } catch (Exception ex) { + // logger.error(ex.getMessage()); // System.out.println("volume "+ // (thermoSystem.getPhase(0).getMolarVolume())/10e4); Vi[i] = thermoSystem.getPhase(1).getMolarVolume() / 100.0; @@ -220,8 +220,8 @@ public void calculate() { thermoSystem.getTemperature()); KMcorrectionFactor2 = pcs2.value(thermoSystem.getPhase(0).getMolarMass() * 1000.0, thermoSystem.getTemperature()); - } catch (Exception e) { - /// logger.error(e.getMessage()); + } catch (Exception ex) { + /// logger.error(ex.getMessage()); KMcorrectionFactor1 = 0.0; KMcorrectionFactor2 = 0.0; } diff --git a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976.java b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976.java index 05126fb910..279f546b25 100644 --- a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976.java +++ b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976.java @@ -115,7 +115,7 @@ public Standard_ISO6976(String name, String description, SystemInterface thermoS + this.thermoSystem.getPhase(0).getComponent(i).getName() + "'")); dataSet.next(); dataSet.getString("ID"); - } catch (Exception e) { + } catch (Exception ex) { try { String compName = "inert"; String compType = this.thermoSystem.getPhase(0).getComponent(i).getComponentType(); @@ -130,8 +130,8 @@ public Standard_ISO6976(String name, String description, SystemInterface thermoS ("SELECT * FROM iso6976constants WHERE ComponentName='" + compName + "'")); M[i] = this.thermoSystem.getPhase(0).getComponent(i).getMolarMass(); dataSet.next(); - } catch (Exception ex) { - logger.error(ex.getMessage()); + } catch (Exception ex2) { + logger.error(ex2.getMessage()); } componentsNotDefinedByStandard .add("this.thermoSystem.getPhase(0).getComponent(i).getComponentName()"); @@ -158,8 +158,8 @@ public Standard_ISO6976(String name, String description, SystemInterface thermoS Hinf25[i] = Double.parseDouble(dataSet.getString("Hinfmolar25")); Hinf60F[i] = Double.parseDouble(dataSet.getString("Hinfmolar60F")); } - } catch (Exception e) { - String err = e.toString(); + } catch (Exception ex) { + String err = ex.toString(); System.out.println(err); } finally { try { diff --git a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976_2016.java b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976_2016.java index b53da2f787..0f11e9ed40 100644 --- a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976_2016.java +++ b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976_2016.java @@ -71,7 +71,7 @@ public Standard_ISO6976_2016(SystemInterface thermoSystem) { + this.thermoSystem.getPhase(0).getComponent(i).getName() + "'")); dataSet.next(); M[i] = Double.parseDouble(dataSet.getString("MolarMass")); - } catch (Exception e) { + } catch (Exception ex) { try { String compName = "inert"; String compType = this.thermoSystem.getPhase(0).getComponent(i).getComponentType(); @@ -125,8 +125,8 @@ public Standard_ISO6976_2016(SystemInterface thermoSystem) { dataSet.close(); database.getConnection().close(); - } catch (Exception e) { - String err = e.toString(); + } catch (Exception ex) { + String err = ex.toString(); logger.error(err); } } diff --git a/src/main/java/neqsim/standards/salesContract/BaseContract.java b/src/main/java/neqsim/standards/salesContract/BaseContract.java index be982bb46e..0479db807d 100644 --- a/src/main/java/neqsim/standards/salesContract/BaseContract.java +++ b/src/main/java/neqsim/standards/salesContract/BaseContract.java @@ -84,9 +84,9 @@ public BaseContract(SystemInterface system, String terminal, String country) { Double.parseDouble(dataSet.getString("ReferencePbar")), dataSet.getString("Comments")); System.out.println("specification added..." + numb); } - } catch (Exception e) { + } catch (Exception ex) { System.out.println("error in comp"); - logger.error(e.getMessage()); + logger.error(ex.getMessage()); } finally { specificationsNumber = numb; try { @@ -99,9 +99,9 @@ public BaseContract(SystemInterface system, String terminal, String country) { if (database.getConnection() != null) { database.getConnection().close(); } - } catch (Exception e) { + } catch (Exception ex) { System.out.println("error closing database....."); - logger.error(e.getMessage()); + logger.error(ex.getMessage()); } } }