From 8dbc110a93d339bda5c4572f1d1a7e5b37c3c01b Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Wed, 16 Aug 2023 21:04:16 +0000 Subject: [PATCH 1/4] added units and runtime exception --- src/main/java/neqsim/thermo/phase/Phase.java | 55 +-- .../neqsim/thermo/phase/PhaseInterface.java | 2 +- .../neqsim/thermo/system/SystemInterface.java | 398 +++++++++++------- .../neqsim/thermo/system/SystemThermo.java | 294 +++++++------ 4 files changed, 412 insertions(+), 337 deletions(-) diff --git a/src/main/java/neqsim/thermo/phase/Phase.java b/src/main/java/neqsim/thermo/phase/Phase.java index 8b5d875ad..5409e05ef 100644 --- a/src/main/java/neqsim/thermo/phase/Phase.java +++ b/src/main/java/neqsim/thermo/phase/Phase.java @@ -46,12 +46,14 @@ abstract class Phase implements PhaseInterface { /** * Mole fraction of this phase of system. - * beta = numberOfMolesInPhase/numberOfMolesInSystem. NB! numberOfMolesInSystem is + * beta = numberOfMolesInPhase/numberOfMolesInSystem. NB! + * numberOfMolesInSystem is * not known to the phase. */ double beta = 1.0; /** - * Number of moles in phase. numberOfMolesInPhase = numberOfMolesInSystem*beta. NB! + * Number of moles in phase. + * numberOfMolesInPhase = numberOfMolesInSystem*beta. NB! * numberOfMolesInSystem is not known to the phase. */ public double numberOfMolesInPhase = 0; @@ -101,7 +103,7 @@ public Phase clone() { * addcomponent. Increase number of components and add moles to phase. *

* - * @param name Name of component to add. + * @param name Name of component to add. * @param moles Number of moles of component to add to phase. */ public void addComponent(String name, double moles) { @@ -118,7 +120,8 @@ public void addComponent(String name, double moles) { } if (this.hasComponent(name)) { - // should use addMoles/addMolesChemreac if adding/subtracting moles for component. + // should use addMoles/addMolesChemreac if adding/subtracting moles for + // component. throw new RuntimeException("Component already exists in phase"); } @@ -176,8 +179,8 @@ public void addMoles(int component, double dn) { public void addMolesChemReac(int component, double dn, double totdn) { if ((numberOfMolesInPhase + dn) / numberOfMolesInPhase < -1e-10) { String msg = "will lead to negative number of moles in phase." + (numberOfMolesInPhase + dn); - neqsim.util.exception.InvalidInputException ex = - new neqsim.util.exception.InvalidInputException(this, "addMolesChemReac", "dn", msg); + neqsim.util.exception.InvalidInputException ex = new neqsim.util.exception.InvalidInputException(this, + "addMolesChemReac", "dn", msg); throw new RuntimeException(ex); } numberOfMolesInPhase += dn; @@ -284,8 +287,7 @@ public double getPressure() { /** {@inheritDoc} */ @Override public final double getPressure(String unit) { - neqsim.util.unit.PressureUnit presConversion = - new neqsim.util.unit.PressureUnit(getPressure(), "bara"); + neqsim.util.unit.PressureUnit presConversion = new neqsim.util.unit.PressureUnit(getPressure(), "bara"); return presConversion.getValue(unit); } @@ -494,11 +496,11 @@ public double calcA(PhaseInterface phase, double temperature, double pressure, i * calcA. *

* - * @param comp a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param comp a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object * @param temperature a double - * @param pressure a double - * @param numbcomp a int + * @param pressure a double + * @param numbcomp a int * @return a double */ public double calcA(int comp, PhaseInterface phase, double temperature, double pressure, @@ -1025,6 +1027,7 @@ public double getEnthalpy(String unit) { case "J": conversionFactor = 1.0; break; + case "kJ/kmol": case "J/mol": conversionFactor = 1.0 / getNumberOfMolesInPhase(); break; @@ -1035,7 +1038,7 @@ public double getEnthalpy(String unit) { conversionFactor = 1.0 / getNumberOfMolesInPhase() / getMolarMass() / 1000.0; break; default: - break; + throw new RuntimeException("unit not supported " + unit); } return refEnthalpy * conversionFactor; } @@ -1121,7 +1124,7 @@ public double getEntropy(String unit) { conversionFactor = 1.0 / getNumberOfMolesInPhase() / getMolarMass() / 1000.0; break; default: - break; + throw new RuntimeException("unit not supported " + unit); } return refEntropy * conversionFactor; } @@ -1157,7 +1160,7 @@ public double getViscosity(String unit) { conversionFactor = 1.0e3; break; default: - throw new RuntimeException(); + throw new RuntimeException("unit not supported " + unit); } return refViscosity * conversionFactor; } @@ -1181,7 +1184,7 @@ public double getThermalConductivity(String unit) { conversionFactor = 0.01; break; default: - throw new RuntimeException(); + throw new RuntimeException("unit not supported " + unit); } return refConductivity * conversionFactor; } @@ -1207,7 +1210,7 @@ public double getConductivity(String unit) { conversionFactor = 0.01; break; default: - throw new RuntimeException(); + throw new RuntimeException("unit not supported " + unit); } return refConductivity * conversionFactor; } @@ -1226,7 +1229,7 @@ public void initRefPhases(boolean onlyPure) { *

* * @param onlyPure a boolean - * @param name a {@link String} object + * @param name a {@link String} object */ public void initRefPhases(boolean onlyPure, String name) { refPhase = new PhaseInterface[numberOfComponents]; @@ -1280,7 +1283,7 @@ public void initRefPhases(boolean onlyPure, String name) { * getLogPureComponentFugacity. *

* - * @param k a int + * @param k a int * @param pure a boolean * @return a double */ @@ -1552,7 +1555,7 @@ public double getJouleThomsonCoefficient(String unit) { conversionFactor = 1.0; break; default: - break; + throw new RuntimeException("unit not supported " + unit); } return JTcoef * conversionFactor; } @@ -1585,8 +1588,7 @@ public double getDensity(String unit) { conversionFactor = 0.0624279606; break; default: - throw new RuntimeException( - "Could not create conversion factor because molar mass is NULL or 0"); + throw new RuntimeException("unit not supported " + unit); } return refDensity * conversionFactor; } @@ -1823,7 +1825,8 @@ public void setPhysicalPropertyType(int physicalPropertyType) { /** {@inheritDoc} */ @Override public void setParams(PhaseInterface phase, double[][] alpha, double[][] Dij, double[][] DijT, - String[][] mixRule, double[][] intparam) {} + String[][] mixRule, double[][] intparam) { + } /** {@inheritDoc} */ @Override @@ -1919,7 +1922,8 @@ public final void setBeta(double b) { /** {@inheritDoc} */ @Override - public void setMixingRuleGEModel(String name) {} + public void setMixingRuleGEModel(String name) { + } /** {@inheritDoc} */ @Override @@ -2106,8 +2110,7 @@ public double[] getProperties_GERG2008() { /** {@inheritDoc} */ @Override public double getDensity_AGA8() { - neqsim.thermo.util.GERG.NeqSimAGA8Detail test = - new neqsim.thermo.util.GERG.NeqSimAGA8Detail(this); + neqsim.thermo.util.GERG.NeqSimAGA8Detail test = new neqsim.thermo.util.GERG.NeqSimAGA8Detail(this); return test.getDensity(); } diff --git a/src/main/java/neqsim/thermo/phase/PhaseInterface.java b/src/main/java/neqsim/thermo/phase/PhaseInterface.java index 01c9147c1..0977cc466 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseInterface.java +++ b/src/main/java/neqsim/thermo/phase/PhaseInterface.java @@ -1081,7 +1081,7 @@ public default void addMolesChemReac(int component, double dn) { /** * method to return phase enthalpy in a specified unit. * - * @param unit Supported units are J, J/mol, J/kg and kJ/kg + * @param unit Supported units are J, J/mol, kJ/kmol, J/kg and kJ/kg * @return enthalpy in specified unit */ public double getEnthalpy(String unit); diff --git a/src/main/java/neqsim/thermo/system/SystemInterface.java b/src/main/java/neqsim/thermo/system/SystemInterface.java index 3825a6a00..7a4351c7d 100644 --- a/src/main/java/neqsim/thermo/system/SystemInterface.java +++ b/src/main/java/neqsim/thermo/system/SystemInterface.java @@ -5,7 +5,7 @@ import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.characterization.WaxModelInterface; import neqsim.thermo.component.ComponentInterface; -import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseInterface;g import neqsim.thermo.phase.PhaseType; /** @@ -31,7 +31,7 @@ public interface SystemInterface extends Cloneable, java.io.Serializable { * saveFluid. *

* - * @param id a int + * @param id a int * @param text a {@link java.lang.String} object */ public void saveFluid(int id, String text); @@ -68,10 +68,10 @@ public interface SystemInterface extends Cloneable, java.io.Serializable { * addPhaseFractionToPhase. *

* - * @param fraction a double + * @param fraction a double * @param specification a {@link java.lang.String} object * @param fromPhaseName a {@link java.lang.String} object - * @param toPhaseName a {@link java.lang.String} object + * @param toPhaseName a {@link java.lang.String} object */ public void addPhaseFractionToPhase(double fraction, String specification, String fromPhaseName, String toPhaseName); @@ -81,20 +81,22 @@ public void addPhaseFractionToPhase(double fraction, String specification, Strin * addPhaseFractionToPhase. *

* - * @param fraction a double - * @param specification a {@link java.lang.String} object + * @param fraction a double + * @param specification a {@link java.lang.String} object * @param specifiedStream a {@link java.lang.String} object - * @param fromPhaseName a {@link java.lang.String} object - * @param toPhaseName a {@link java.lang.String} object + * @param fromPhaseName a {@link java.lang.String} object + * @param toPhaseName a {@link java.lang.String} object */ public void addPhaseFractionToPhase(double fraction, String specification, String specifiedStream, String fromPhaseName, String toPhaseName); /** - * Add named components to a System. Does nothing if components already exist in System. + * Add named components to a System. Does nothing if components already exist in + * System. * - * @param names Names of the components to be added. See NeqSim database for available components - * in the database. + * @param names Names of the components to be added. See NeqSim database for + * available components + * in the database. */ public default void addComponents(String[] names) { for (int i = 0; i < names.length; i++) { @@ -103,11 +105,13 @@ public default void addComponents(String[] names) { } /** - * Add named components to a System with a number of moles. If component already exists, the moles + * Add named components to a System with a number of moles. If component already + * exists, the moles * will be added to the component. * - * @param names Names of the components to be added. See NeqSim database for available components - * in the database. + * @param names Names of the components to be added. See NeqSim database for + * available components + * in the database. * @param moles Number of moles to add per component. */ public default void addComponents(String[] names, double[] moles) { @@ -164,21 +168,27 @@ public default String[][] calcResultTable() { public int getNumberOfComponents(); /** - * This method is used to set the total molar composition of a plus fluid. The total flow rate + * This method is used to set the total molar composition of a plus fluid. The + * total flow rate * will be kept constant. The input mole fractions will be normalized. * - * @param molefractions is a double array taking the molar fraction of the components in the - * fluid. THe last molfraction is the mole fraction of the plus component + * @param molefractions is a double array taking the molar fraction of the + * components in the + * fluid. THe last molfraction is the mole fraction of the + * plus component */ public void setMolarCompositionPlus(double[] molefractions); /** - * This method is used to set the total molar composition of a characterized fluid. The total flow + * This method is used to set the total molar composition of a characterized + * fluid. The total flow * rate will be kept constant. The input mole fractions will be normalized. * - * @param molefractions is a double array taking the molar fraction of the components in the - * fluid. THe last fraction in the array is the total molefraction of the characterized - * components. + * @param molefractions is a double array taking the molar fraction of the + * components in the + * fluid. THe last fraction in the array is the total + * molefraction of the characterized + * components. */ public void setMolarCompositionOfPlusFluid(double[] molefractions); @@ -194,13 +204,14 @@ public default String[][] calcResultTable() { * method to return exergy in a specified unit. * * @param temperatureOfSurroundings in Kelvin - * @param exergyUnit a {@link java.lang.String} object + * @param exergyUnit a {@link java.lang.String} object * @return exergy in specified unit */ public double getExergy(double temperatureOfSurroundings, String exergyUnit); /** - * method to get the Joule Thomson Coefficient of a system. Based on a phase mole fraction basis + * method to get the Joule Thomson Coefficient of a system. Based on a phase + * mole fraction basis * average * * @return Joule Thomson coefficient in K/bar @@ -208,7 +219,8 @@ public default String[][] calcResultTable() { public double getJouleThomsonCoefficient(); /** - * method to get the Joule Thomson Coefficient of a system. Based on a phase mole fraction basis + * method to get the Joule Thomson Coefficient of a system. Based on a phase + * mole fraction basis * average. * * @param unit Supported units are K/bar, C/bar @@ -226,7 +238,8 @@ public default String[][] calcResultTable() { /** *

- * Get sum of mole fractions for all components. NB! init(0) must be called first. + * Get sum of mole fractions for all components. NB! init(0) must be called + * first. *

* * @return a double @@ -234,7 +247,8 @@ public default String[][] calcResultTable() { public double getMoleFractionsSum(); /** - * method to get the speed of sound of a system. The sound speed is implemented based on a molar + * method to get the speed of sound of a system. The sound speed is implemented + * based on a molar * average over the phases * * @param unit Supported units are m/s, km/h @@ -243,7 +257,8 @@ public default String[][] calcResultTable() { public double getSoundSpeed(String unit); /** - * method to get the speed of sound of a system. The sound speed is implemented based on a molar + * method to get the speed of sound of a system. The sound speed is implemented + * based on a molar * average over the phases * * @return speed of sound in m/s @@ -272,7 +287,8 @@ public default String[][] calcResultTable() { public void initPhysicalProperties(String propertyName); /** - * Calculates thermodynamic and physical properties of a fluid using initThermoProperties() and + * Calculates thermodynamic and physical properties of a fluid using + * initThermoProperties() and * initPhysicalProperties(). */ public void initProperties(); @@ -290,13 +306,15 @@ public static SystemInterface addFluids(SystemInterface addFluid1, SystemInterfa return newFluid; } - /** * method to return interfacial tension between two phases. * - * @param phase1 phase type of phase1 as string (valid phases are gas, oil, aqueous) - * @param phase2 phase type of phase2 as string (valid phases are gas, oil, aqueous) - * @return interfacial tension with unit N/m. If one or both phases does not exist - the method + * @param phase1 phase type of phase1 as string (valid phases are gas, oil, + * aqueous) + * @param phase2 phase type of phase2 as string (valid phases are gas, oil, + * aqueous) + * @return interfacial tension with unit N/m. If one or both phases does not + * exist - the method * will return NaN */ public double getInterfacialTension(String phase1, String phase2); @@ -317,7 +335,7 @@ public static SystemInterface addFluids(SystemInterface addFluid1, SystemInterfa * * @param phase1 phase number of phase1 * @param phase2 phase number of phase2 - * @param unit a {@link java.lang.String} object + * @param unit a {@link java.lang.String} object * @return interfacial tension with specified unit */ public double getInterfacialTension(int phase1, int phase2, String unit); @@ -356,8 +374,10 @@ public default double getGamma2() { /** * method to return flow rate of fluid. * - * @param flowunit Supported units are kg/sec, kg/min, kg/hr, kg/day, m3/sec, m3/min, m3/hr, - * idSm3/hr, Sm3/sec, Sm3/hr, Sm3/day, MSm3/day, mole/sec, mole/min, mole/hr + * @param flowunit Supported units are kg/sec, kg/min, kg/hr, kg/day, m3/sec, + * m3/min, m3/hr, + * idSm3/hr, Sm3/sec, Sm3/hr, Sm3/day, MSm3/day, mole/sec, + * mole/min, mole/hr * @return flow rate in specified unit */ public double getFlowRate(String flowunit); @@ -373,7 +393,7 @@ public default double getGamma2() { * method to set the pressure of a fluid (same pressure for all phases). * * @param newPressure in specified unit - * @param unit unit can be bar, bara, barg or atm + * @param unit unit can be bar, bara, barg or atm */ public void setPressure(double newPressure, String unit); @@ -392,7 +412,7 @@ public default double getGamma2() { *

* * @param newTemperature a double - * @param phaseNumber a int + * @param phaseNumber a int */ public void setTemperature(double newTemperature, int phaseNumber); @@ -400,12 +420,13 @@ public default double getGamma2() { * method to set the temperature of a fluid (same temperature for all phases). * * @param newTemperature in specified unit - * @param unit unit can be C or K (Celsius or Kelvin) + * @param unit unit can be C or K (Celsius or Kelvin) */ public void setTemperature(double newTemperature, String unit); /** - * method to return the volume fraction of a phase note: without Peneloux volume correction. + * method to return the volume fraction of a phase note: without Peneloux volume + * correction. * * @param phaseNumber number of the phase to get volume fraction for * @return volume fraction @@ -413,7 +434,8 @@ public default double getGamma2() { public double getVolumeFraction(int phaseNumber); /** - * method to return the volume fraction of a phase note: with Peneloux volume correction. + * method to return the volume fraction of a phase note: with Peneloux volume + * correction. * * @param phaseNumber number of the phase to get volume fraction for * @return volume fraction @@ -507,7 +529,7 @@ public default void removeMoles() { * saveObjectToFile. *

* - * @param filePath a {@link java.lang.String} object + * @param filePath a {@link java.lang.String} object * @param fluidName a {@link java.lang.String} object */ public void saveObjectToFile(String filePath, String fluidName); @@ -517,7 +539,7 @@ public default void removeMoles() { * readObjectFromFile. *

* - * @param filePath a {@link java.lang.String} object + * @param filePath a {@link java.lang.String} object * @param fluidName a {@link java.lang.String} object * @return a {@link neqsim.thermo.system.SystemInterface} object */ @@ -585,7 +607,7 @@ public default void removeMoles() { * changeComponentName. *

* - * @param name a {@link java.lang.String} object + * @param name a {@link java.lang.String} object * @param newName a {@link java.lang.String} object */ public void changeComponentName(String name, String newName); @@ -697,8 +719,10 @@ public default boolean IsPhase(int i) { *

* * @param flowRate a double - * @param flowunit a {@link java.lang.String} object. flow units are: kg/sec, kg/min, kg/hr - * m3/sec, m3/min, m3/hr, mole/sec, mole/min, mole/hr, Sm3/hr, Sm3/day, idSm3/hr, idSm3/day + * @param flowunit a {@link java.lang.String} object. flow units are: kg/sec, + * kg/min, kg/hr + * m3/sec, m3/min, m3/hr, mole/sec, mole/min, mole/hr, Sm3/hr, + * Sm3/day, idSm3/hr, idSm3/day */ public void setTotalFlowRate(double flowRate, String flowunit); @@ -850,7 +874,7 @@ public default boolean IsPhase(int i) { * saveObject. *

* - * @param ID a int + * @param ID a int * @param text a {@link java.lang.String} object */ public void saveObject(int ID, String text); @@ -933,7 +957,8 @@ public default boolean IsPhase(int i) { /** *

- * This method is used to set the total molar composition of a fluid. The total flow rate will be + * This method is used to set the total molar composition of a fluid. The total + * flow rate will be * kept constant. The input mole fractions will be normalized. *

* @@ -942,10 +967,12 @@ public default boolean IsPhase(int i) { public void setMolarComposition(double[] moles); /** - * return the phase of to specified type if the phase does not exist, the method will return null. + * return the phase of to specified type if the phase does not exist, the method + * will return null. * - * @param phaseTypeName the phase type to be returned (gas, oil, aqueous, wax, hydrate are - * supported) + * @param phaseTypeName the phase type to be returned (gas, oil, aqueous, wax, + * hydrate are + * supported) * @return a {@link neqsim.thermo.phase.PhaseInterface} object */ public PhaseInterface getPhaseOfType(String phaseTypeName); @@ -964,8 +991,8 @@ public default boolean IsPhase(int i) { * * @param componentName selected name of the component to be added * @param numberOfMoles number of moles to be added - * @param molarMass molar mass of the component in kg/mol - * @param density density of the component in g/cm3 + * @param molarMass molar mass of the component in kg/mol + * @param density density of the component in g/cm3 */ public void addTBPfraction(String componentName, double numberOfMoles, double molarMass, double density); @@ -975,13 +1002,13 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo * addTBPfraction. *

* - * @param componentName a {@link java.lang.String} object - * @param numberOfMoles a double - * @param molarMass a double - * @param density a double + * @param componentName a {@link java.lang.String} object + * @param numberOfMoles a double + * @param molarMass a double + * @param density a double * @param criticalTemperature a double - * @param criticalPressure a double - * @param acentricFactor a double + * @param criticalPressure a double + * @param acentricFactor a double */ public void addTBPfraction(String componentName, double numberOfMoles, double molarMass, double density, double criticalTemperature, double criticalPressure, double acentricFactor); @@ -993,8 +1020,8 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo * * @param componentName a {@link java.lang.String} object * @param numberOfMoles a double - * @param molarMass a double - * @param density a double + * @param molarMass a double + * @param density a double */ public void addPlusFraction(String componentName, double numberOfMoles, double molarMass, double density); @@ -1005,7 +1032,7 @@ public void addPlusFraction(String componentName, double numberOfMoles, double m *

* * @param componentName a {@link java.lang.String} object - * @param value a double + * @param value a double */ public void addSalt(String componentName, double value); @@ -1096,13 +1123,14 @@ public default boolean hasSolidPhase() { *

* * @param model a {@link java.lang.String} object - * @param val a double + * @param val a double * @param phase a int */ public void tuneModel(String model, double val, int phase); /** - * add a component to a fluid. If component already exists, the moles will be added to the + * add a component to a fluid. If component already exists, the moles will be + * added to the * existing component. * * @param inComponent Component object to add. @@ -1110,30 +1138,38 @@ public default boolean hasSolidPhase() { public void addComponent(ComponentInterface inComponent); /** - * add a component to a fluid. If component already exists, the moles will be added to the + * add a component to a fluid. If component already exists, the moles will be + * added to the * existing component. * - * @param name Name of the component to add. See NeqSim database for component in the database. + * @param name Name of the component to add. See NeqSim database for component + * in the database. */ public void addComponent(String name); /** - * add a component to a fluid. If component already exists, the moles will be added to the + * add a component to a fluid. If component already exists, the moles will be + * added to the * existing component. * - * @param moles number of moles (per second) of the component to be added to the fluid - * @param name Name of the component to add. See NeqSim database for component in the database. + * @param moles number of moles (per second) of the component to be added to the + * fluid + * @param name Name of the component to add. See NeqSim database for component + * in the database. */ public void addComponent(String name, double moles); /** - * add a component to a fluid. If component already exists, the moles will be added to the + * add a component to a fluid. If component already exists, the moles will be + * added to the * existing component. * - * @param name Name of the component to add. See NeqSim database for component in the database. - * @param value The amount - * @param unitName the unit of rate (sported units are kg/sec, mol/sec, Nlitre/min, kg/hr, - * Sm^3/hr, Sm^3/day, MSm^3/day .. + * @param name Name of the component to add. See NeqSim database for + * component in the database. + * @param value The amount + * @param unitName the unit of rate (sported units are kg/sec, mol/sec, + * Nlitre/min, kg/hr, + * Sm^3/hr, Sm^3/day, MSm^3/day .. */ public void addComponent(String name, double value, String unitName); @@ -1142,30 +1178,37 @@ public default boolean hasSolidPhase() { * addComponent. *

* - * @param name Name of the component to add. See NeqSim database for component in the database. - * @param moles number of moles (per second) of the component to be added to the fluid - * @param TC Critical temperature - * @param PC Critical pressure - * @param acs a double + * @param name Name of the component to add. See NeqSim database for component + * in the database. + * @param moles number of moles (per second) of the component to be added to the + * fluid + * @param TC Critical temperature + * @param PC Critical pressure + * @param acs a double */ public void addComponent(String name, double moles, double TC, double PC, double acs); /** - * add a component to a fluid. If component already exists, the moles will be added to the + * add a component to a fluid. If component already exists, the moles will be + * added to the * existing component. * - * @param name Name of the component to add. See NeqSim database for component in the database. - * @param moles number of moles (per second) of the component to be added to the fluid + * @param name Name of the component to add. See NeqSim database for + * component in the database. + * @param moles number of moles (per second) of the component to be added + * to the fluid * @param phaseNumber Number of the phase to add the component to */ public void addComponent(String name, double moles, int phaseNumber); /** - * add a component to a fluid. I component already exists, it will be added to the component + * add a component to a fluid. I component already exists, it will be added to + * the component * - * @param name Name of the component to add. See NeqSim database for component in the database. - * @param value rate of the component to add to the fluid - * @param unitName the unit of the flow rate (eg. mol/sec, kg/sec, etc.) + * @param name Name of the component to add. See NeqSim database for + * component in the database. + * @param value rate of the component to add to the fluid + * @param unitName the unit of the flow rate (eg. mol/sec, kg/sec, etc.) * @param phaseNumber Number of the phase to add the component to */ public void addComponent(String name, double value, String unitName, int phaseNumber); @@ -1176,7 +1219,8 @@ public default boolean hasSolidPhase() { *

* * @param index Component number to add - * @param moles number of moles (per second) of the component to be added to the fluid + * @param moles number of moles (per second) of the component to be added to the + * fluid */ public void addComponent(int index, double moles); @@ -1185,8 +1229,9 @@ public default boolean hasSolidPhase() { * addComponent. *

* - * @param index Component number to add - * @param moles number of moles (per second) of the component to be added to the fluid + * @param index Component number to add + * @param moles number of moles (per second) of the component to be added + * to the fluid * @param phaseNumber Number of the phase to add the component to */ public void addComponent(int index, double moles, int phaseNumber); @@ -1196,7 +1241,8 @@ public default boolean hasSolidPhase() { * removeComponent. *

* - * @param name Name of the component to remove. See NeqSim database for component in the database. + * @param name Name of the component to remove. See NeqSim database for + * component in the database. */ public void removeComponent(String name); @@ -1223,7 +1269,8 @@ public default boolean hasSolidPhase() { /** *

- * Setter for property beta. NB! Sets beta = b for first phase and 1-b for second + * Setter for property beta. NB! Sets beta = b for first phase and + * 1-b for second * phase, not for multiphase systems. *

* @@ -1237,7 +1284,7 @@ public default boolean hasSolidPhase() { *

* * @param phase Phase number to set beta for. - * @param b Beta value to set. + * @param b Beta value to set. */ public void setBeta(int phase, double b); @@ -1263,13 +1310,19 @@ public default boolean hasSolidPhase() { /** * method to set mixing rule used for the fluid. * - * @param type The type of mixing rule to be used for the fluid. 1 - classic mixing rule with all - * kij set to zero 2 -classic mixing rule with kij from NeqSim database 3- classic mixing - * rule with temperature dependent kij 4- Huron Vidal mixing rule with parameters from - * NeqSim database 7 -classic mixing rule with kij of CPA from NeqSim Database 9 - * -classicmixing rule with temperature dependent kij of CPA from NeqSim database - * 10-classic mixing rule with temperature and composition dependent kij of CPA from NeqSim - * database + * @param type The type of mixing rule to be used for the fluid. 1 - classic + * mixing rule with all + * kij set to zero 2 -classic mixing rule with kij from NeqSim + * database 3- classic mixing + * rule with temperature dependent kij 4- Huron Vidal mixing rule + * with parameters from + * NeqSim database 7 -classic mixing rule with kij of CPA from + * NeqSim Database 9 + * -classicmixing rule with temperature dependent kij of CPA from + * NeqSim database + * 10-classic mixing rule with temperature and composition dependent + * kij of CPA from NeqSim + * database */ public void setMixingRule(int type); @@ -1286,7 +1339,7 @@ public default boolean hasSolidPhase() { *

* * @param typename a {@link java.lang.String} object - * @param GEmodel a {@link java.lang.String} object + * @param GEmodel a {@link java.lang.String} object */ public void setMixingRule(String typename, String GEmodel); @@ -1379,9 +1432,9 @@ public default boolean hasSolidPhase() { * write. *

* - * @param name a {@link java.lang.String} object + * @param name a {@link java.lang.String} object * @param filename a {@link java.lang.String} object - * @param newfile a boolean + * @param newfile a boolean */ public void write(String name, String filename, boolean newfile); @@ -1436,14 +1489,15 @@ public default boolean hasSolidPhase() { * this.phaseIndex[index] = phaseIndex; *

* - * @param index a int + * @param index a int * @param phaseIndex a int */ public void setPhaseIndex(int index, int phaseIndex); /** *

- * Set phaseArray[phaseIndex] = phase. NB! Transfers the pressure and temperature + * Set phaseArray[phaseIndex] = phase. NB! Transfers the pressure + * and temperature * from the currently existing phase object at index numb *

* @@ -1453,17 +1507,26 @@ public default boolean hasSolidPhase() { public void setPhase(PhaseInterface phase, int index); /** - * method to read pure component and interaction parameters from the NeqSim database and create + * method to read pure component and interaction parameters from the NeqSim + * database and create * temporary tables with parameters for active fluid. * - * @param reset If reset is set to true, new temporary tables with parameters for the added - * components will be created. When parameters are needed (eg. when adding components or - * when setting a mixing rule) it will try to find them in the temporary tables first eg. - * COMPTEMP (for pure component parameters) and INTERTEMP (for interaction parameters). If - * reset is set to false it will not create new temporary tables. If a fluid is created - * with the same components many times, performance improvements will be obtained, if - * temporary tables are created the first time (reset=true), and then the same tables is - * used when creating new fluids with the same temporary tables (reset=false) + * @param reset If reset is set to true, new temporary tables with parameters + * for the added + * components will be created. When parameters are needed (eg. when + * adding components or + * when setting a mixing rule) it will try to find them in the + * temporary tables first eg. + * COMPTEMP (for pure component parameters) and INTERTEMP (for + * interaction parameters). If + * reset is set to false it will not create new temporary tables. + * If a fluid is created + * with the same components many times, performance improvements + * will be obtained, if + * temporary tables are created the first time (reset=true), and + * then the same tables is + * used when creating new fluids with the same temporary tables + * (reset=false) */ public void createDatabase(boolean reset); @@ -1511,16 +1574,21 @@ public default boolean hasSolidPhase() { public boolean doMultiPhaseCheck(); /** - * method to specify if calculations should check for more than two fluid phases. + * method to specify if calculations should check for more than two fluid + * phases. * - * @param doMultiPhaseCheck Specify if the calculations should check for more than two fluid - * phases. Default is two fluid phases (gas and liquid). If set to true the program will - * check for gas and multiple liquid phases (eg. gas-oil-aqueous). + * @param doMultiPhaseCheck Specify if the calculations should check for more + * than two fluid + * phases. Default is two fluid phases (gas and + * liquid). If set to true the program will + * check for gas and multiple liquid phases (eg. + * gas-oil-aqueous). */ public void setMultiPhaseCheck(boolean doMultiPhaseCheck); /** - * Calculate thermodynamic properties of the fluid using the init type set in fluid. + * Calculate thermodynamic properties of the fluid using the init type set in + * fluid. * * @see getInitType */ @@ -1529,25 +1597,34 @@ public default void init() { } /** - * method to calculate thermodynamic properties of the fluid. The temperature, pressure, number of + * method to calculate thermodynamic properties of the fluid. The temperature, + * pressure, number of * phases and composition of the phases will be used as basis for calculation. * - * @param number - The number can be 0, 1, 2 or 3. 0: Set feed composition for all phases. 1: - * Calculation of density, fugacities and Z-factor 2: 1 + calculation of enthalpy, entropy, - * Cp, Cv, and most other thermodynamic properties 3: 1+2 + Calculation of composition - * derivatives of fugacity coefficients. + * @param number - The number can be 0, 1, 2 or 3. 0: Set feed composition for + * all phases. 1: + * Calculation of density, fugacities and Z-factor 2: 1 + + * calculation of enthalpy, entropy, + * Cp, Cv, and most other thermodynamic properties 3: 1+2 + + * Calculation of composition + * derivatives of fugacity coefficients. */ public void init(int number); /** - * method to calculate thermodynamic properties of the selected phase. The temperature, pressure, - * number of phases and composition of the phase will be used as basis for calculation. + * method to calculate thermodynamic properties of the selected phase. The + * temperature, pressure, + * number of phases and composition of the phase will be used as basis for + * calculation. * - * @param number - The number can be 0, 1, 2 or 3. 0: Set feed composition. 1: Calculation of - * density, fugacities and Z-factor 2: 1 + calculation of enthalpy, entropy, Cp, Cv, and - * most other thermodynamic properties 3: 1+2 + Calculation of composition derivatives of - * fugacity coefficients. - * @param phase a int + * @param number - The number can be 0, 1, 2 or 3. 0: Set feed composition. 1: + * Calculation of + * density, fugacities and Z-factor 2: 1 + calculation of + * enthalpy, entropy, Cp, Cv, and + * most other thermodynamic properties 3: 1+2 + Calculation of + * composition derivatives of + * fugacity coefficients. + * @param phase a int */ public void init(int number, int phase); @@ -1603,7 +1680,7 @@ public default void prettyPrint() { *

* * @param addSystem a {@link neqsim.thermo.system.SystemInterface} object - * @param phase phase number of phase to add fluid to + * @param phase phase number of phase to add fluid to * @return SystemInterface */ public SystemInterface addFluid(SystemInterface addSystem, int phase); @@ -1651,8 +1728,9 @@ public default void prettyPrint() { * calcBeta. For simple gas liquid systems. *

* - * @return Beta Mole fraction contained in the heaviest phase, i.e., liquid phase. - * @throws neqsim.util.exception.IsNaNException if any. + * @return Beta Mole fraction contained in the heaviest phase, i.e., liquid + * phase. + * @throws neqsim.util.exception.IsNaNException if any. * @throws neqsim.util.exception.TooManyIterationsException if any. */ public double calcBeta() @@ -1804,7 +1882,8 @@ public double calcBeta() public void isChemicalSystem(boolean temp); /** - * method to return molar volume of the fluid note: without Peneloux volume correction. + * method to return molar volume of the fluid note: without Peneloux volume + * correction. * * @return molar volume volume in unit m3/mol*1e5 */ @@ -1835,7 +1914,7 @@ public double calcBeta() /** * method to return total enthalpy in a specified unit. * - * @param unit Supported units are 'J', 'J/mol', 'J/kg' and 'kJ/kg' + * @param unit Supported units are 'J', 'J/mol', 'kJ/kmol', 'J/kg' and 'kJ/kg' * @return enthalpy in specified unit */ public double getEnthalpy(String unit); @@ -1852,14 +1931,16 @@ public double calcBeta() * getInterphaseProperties. *

* - * @return a {@link neqsim.physicalProperties.interfaceProperties.InterphasePropertiesInterface} + * @return a + * {@link neqsim.physicalProperties.interfaceProperties.InterphasePropertiesInterface} * object */ public InterphasePropertiesInterface getInterphaseProperties(); /** *

- * Calculate system beta values using Phase.getNumberOfMolesInPhase and getTotalNumberOfMoles. + * Calculate system beta values using Phase.getNumberOfMolesInPhase and + * getTotalNumberOfMoles. *

*/ public void initBeta(); @@ -1924,7 +2005,7 @@ public double calcBeta() * Change the phase type of a given phase. * * @param phaseToChange the phase number of the phase to set phase type - * @param newPhaseType the phasetype number to set + * @param newPhaseType the phasetype number to set * @deprecated Replaced by {@link setPhaseType} */ @Deprecated @@ -1946,14 +2027,14 @@ public default void setPhaseType(int phaseToChange, String phaseTypeName) { * Change the phase type of a given phase. * * @param phaseToChange the phase number of the phase to set phase type - * @param pt PhaseType to set + * @param pt PhaseType to set */ public void setPhaseType(int phaseToChange, PhaseType pt); /** * Set phase type of all phases. * - * @param phases Set to "all" to set all phases, else nothing happens. + * @param phases Set to "all" to set all phases, else nothing happens. * @param newPhaseType the phasetype number to set * @deprecated Replaced by {@link setAllPhaseType} */ @@ -2177,7 +2258,8 @@ public default ComponentInterface getComponent(int i) { public PhaseInterface getLiquidPhase(); /** - * method to return compressibility factor of a fluid compressibility factor is defined in EoS + * method to return compressibility factor of a fluid compressibility factor is + * defined in EoS * from PV=ZnRT where V is total volume of fluid. * * @return compressibility factor Z @@ -2194,7 +2276,7 @@ public default ComponentInterface getComponent(int i) { /** * method to return viscosity in a specified unit. * - * @param unit Supported units are kg/msec, cP (centipoise) + * @param unit Supported units are kg/msec, cP (centipoise), Pas (Pascal*second) * @return viscosity in specified unit */ public double getViscosity(String unit); @@ -2280,7 +2362,7 @@ public default ComponentInterface getComponent(int i) { * method to return phase fraction of selected phase. * * @param phaseTypeName gas/oil/aqueous - * @param unit mole/volume/weight + * @param unit mole/volume/weight * @return phase: fraction in specified unit */ public double getPhaseFraction(String phaseTypeName, String unit); @@ -2290,9 +2372,9 @@ public default ComponentInterface getComponent(int i) { * getProperty. *

* - * @param prop a {@link java.lang.String} object + * @param prop a {@link java.lang.String} object * @param compName a {@link java.lang.String} object - * @param phase a int + * @param phase a int * @return a double */ public double getProperty(String prop, String compName, int phase); @@ -2302,7 +2384,7 @@ public default ComponentInterface getComponent(int i) { * getProperty. *

* - * @param prop a {@link java.lang.String} object + * @param prop a {@link java.lang.String} object * @param phase a int * @return a double */ @@ -2582,10 +2664,10 @@ public void setImplementedCompositionDeriativesofFugacity( * addCharacterized. *

* - * @param charNames an array of {@link java.lang.String} objects - * @param charFlowrate an array of {@link double} objects - * @param molarMass an array of {@link double} objects - * @param relativedensity an array of {@link double} objects + * @param charNames an array of {@link java.lang.String} objects + * @param charFlowrate an array of {@link double} objects + * @param molarMass an array of {@link double} objects + * @param relativedensity an array of {@link double} objects * @param lastIsPlusFraction True if last fraction is a Plus fraction */ public void addOilFractions(String[] charNames, double[] charFlowrate, double[] molarMass, @@ -2596,12 +2678,12 @@ public void addOilFractions(String[] charNames, double[] charFlowrate, double[] * addCharacterized. *

* - * @param charNames an array of {@link java.lang.String} objects - * @param charFlowrate an array of {@link double} objects - * @param molarMass an array of {@link double} objects - * @param relativedensity an array of {@link double} objects - * @param lastIsPlusFraction True if last fraction is a Plus fraction - * @param lumpComponents True if component should be lumped + * @param charNames an array of {@link java.lang.String} objects + * @param charFlowrate an array of {@link double} objects + * @param molarMass an array of {@link double} objects + * @param relativedensity an array of {@link double} objects + * @param lastIsPlusFraction True if last fraction is a Plus fraction + * @param lumpComponents True if component should be lumped * @param numberOfPseudoComponents number of pseudo components */ public void addOilFractions(String[] charNames, double[] charFlowrate, double[] molarMass, @@ -2613,9 +2695,9 @@ public void addOilFractions(String[] charNames, double[] charFlowrate, double[] * addCharacterized. *

* - * @param charNames an array of {@link java.lang.String} objects - * @param charFlowrate an array of {@link double} objects - * @param molarMass an array of {@link double} objects + * @param charNames an array of {@link java.lang.String} objects + * @param charFlowrate an array of {@link double} objects + * @param molarMass an array of {@link double} objects * @param relativedensity an array of {@link double} objects */ public void addCharacterized(String[] charNames, double[] charFlowrate, double[] molarMass, diff --git a/src/main/java/neqsim/thermo/system/SystemThermo.java b/src/main/java/neqsim/thermo/system/SystemThermo.java index 58fa393a1..b4ea48097 100644 --- a/src/main/java/neqsim/thermo/system/SystemThermo.java +++ b/src/main/java/neqsim/thermo/system/SystemThermo.java @@ -72,8 +72,10 @@ abstract class SystemThermo implements SystemInterface { protected double criticalPressure = 0; private double totalNumberOfMoles = 0; - // TODO: componentNameTag is not working yet, a kind of alias-postfix for Components from this - // system that will be passed on to other systems. used to find originator of specific components + // TODO: componentNameTag is not working yet, a kind of alias-postfix for + // Components from this + // system that will be passed on to other systems. used to find originator of + // specific components // or public String componentNameTag = ""; protected neqsim.thermo.characterization.WaxCharacterise waxCharacterisation = null; @@ -84,7 +86,7 @@ abstract class SystemThermo implements SystemInterface { protected int numberOfComponents = 0; // protected ArrayList resultArray1 = new ArrayList(); - protected String[] CapeOpenProperties11 = {"molecularWeight", "speedOfSound", + protected String[] CapeOpenProperties11 = { "molecularWeight", "speedOfSound", "jouleThomsonCoefficient", "internalEnergy", "internalEnergy.Dtemperature", "gibbsEnergy", "helmholtzEnergy", "fugacityCoefficient", "logFugacityCoefficient", "logFugacityCoefficient.Dtemperature", "logFugacityCoefficient.Dpressure", @@ -93,8 +95,8 @@ abstract class SystemThermo implements SystemInterface { "entropy.Dmoles", "heatCapacityCp", "heatCapacityCv", "density", "density.Dtemperature", "density.Dpressure", "density.Dmoles", "volume", "volume.Dpressure", "volume.Dtemperature", "molecularWeight.Dtemperature", "molecularWeight.Dpressure", "molecularWeight.Dmoles", - "compressibilityFactor"}; - protected String[] CapeOpenProperties10 = {"molecularWeight", "speedOfSound", + "compressibilityFactor" }; + protected String[] CapeOpenProperties10 = { "molecularWeight", "speedOfSound", "jouleThomsonCoefficient", "energy", "energy.Dtemperature", "gibbsFreeEnergy", "helmholtzFreeEnergy", "fugacityCoefficient", "logFugacityCoefficient", "logFugacityCoefficient.Dtemperature", "logFugacityCoefficient.Dpressure", @@ -103,7 +105,7 @@ abstract class SystemThermo implements SystemInterface { "entropy.Dmoles", "heatCapacity", "heatCapacityCv", "density", "density.Dtemperature", "density.Dpressure", "density.Dmoles", "volume", "volume.Dpressure", "volume.Dtemperature", "molecularWeight.Dtemperature", "molecularWeight.Dpressure", "molecularWeight.Dmoles", - "compressibilityFactor"}; + "compressibilityFactor" }; protected int attractiveTermNumber = 0; /** Number of phases in use/existing. */ @@ -111,12 +113,14 @@ abstract class SystemThermo implements SystemInterface { /** Maximum allowed number of phases . */ public int maxNumberOfPhases = 2; /** - * Array of indexes to phaseArray keeping track of the creation order of the phases where 0 is the + * Array of indexes to phaseArray keeping track of the creation order of the + * phases where 0 is the * first created phase and the lowest number is the phase created last. */ protected int[] phaseIndex; /** - * Array containing all phases of System. NB! Phases are reorered according to density, use + * Array containing all phases of System. NB! Phases are reorered according to + * density, use * phaseIndex to keep track of the creation order. */ protected PhaseInterface[] phaseArray = new PhaseInterface[MAX_PHASES]; @@ -163,16 +167,16 @@ public SystemThermo() { public SystemThermo(double T, double P) { this(); if (T < 0.0) { - neqsim.util.exception.InvalidInputException ex = - new neqsim.util.exception.InvalidInputException(this.getClass().getSimpleName(), - "SystemThermo", "T", "is negative"); + neqsim.util.exception.InvalidInputException ex = new neqsim.util.exception.InvalidInputException( + this.getClass().getSimpleName(), + "SystemThermo", "T", "is negative"); throw new RuntimeException(ex); } if (P < 0.0) { - neqsim.util.exception.InvalidInputException ex = - new neqsim.util.exception.InvalidInputException(this.getClass().getSimpleName(), - "SystemThermo", "P", "is negative"); + neqsim.util.exception.InvalidInputException ex = new neqsim.util.exception.InvalidInputException( + this.getClass().getSimpleName(), + "SystemThermo", "P", "is negative"); throw new RuntimeException(ex); } } @@ -277,19 +281,24 @@ public SystemInterface addFluid(SystemInterface addSystem, int phase) { @Override public void addPhase() { /* - * if (maxNumberOfPhases < 6 && !hydrateCheck) { ArrayList phaseList = new ArrayList(0); for - * (int i = 0; i < numberOfPhases; i++) { phaseList.add(phaseArray[i]); } // add the new phase - * phaseList.add(phaseArray[0].clone()); beta[phaseList.size() - 1] = 1.0e-8; // beta[1] -= + * if (maxNumberOfPhases < 6 && !hydrateCheck) { ArrayList phaseList = new + * ArrayList(0); for + * (int i = 0; i < numberOfPhases; i++) { phaseList.add(phaseArray[i]); } // add + * the new phase + * phaseList.add(phaseArray[0].clone()); beta[phaseList.size() - 1] = 1.0e-8; // + * beta[1] -= * beta[1]/1.0e5; * * PhaseInterface[] phaseArray2 = new PhaseInterface[numberOfPhases + 1]; * - * for (int i = 0; i < numberOfPhases + 1; i++) { phaseArray2[i] = (PhaseInterface) + * for (int i = 0; i < numberOfPhases + 1; i++) { phaseArray2[i] = + * (PhaseInterface) * phaseList.get(i); } * * phaseArray = phaseArray2; * - * System.out.println("number of phases " + numberOfPhases); if (maxNumberOfPhases < + * System.out.println("number of phases " + numberOfPhases); if + * (maxNumberOfPhases < * numberOfPhases) { maxNumberOfPhases = numberOfPhases; } } */ numberOfPhases++; @@ -691,8 +700,7 @@ public void setTotalFlowRate(double flowRate, String flowunit) { if (flowunit.equals("idSm3/hr")) { density = getIdealLiquidDensity("kg/m3"); } - neqsim.util.unit.Unit unit = - new neqsim.util.unit.RateUnit(flowRate, flowunit, getMolarMass(), density, 0); + neqsim.util.unit.Unit unit = new neqsim.util.unit.RateUnit(flowRate, flowunit, getMolarMass(), density, 0); double SIval = unit.getSIvalue(); double totalNumberOfMolesLocal = totalNumberOfMoles; for (int i = 0; i < numberOfComponents; i++) { @@ -700,9 +708,8 @@ public void setTotalFlowRate(double flowRate, String flowunit) { setEmptyFluid(); } else if (totalNumberOfMolesLocal > 1e-100) { // (SIval / totalNumberOfMolesLocal - 1) * ... - double change = - SIval / totalNumberOfMolesLocal * getPhase(0).getComponent(i).getNumberOfmoles() - - getPhase(0).getComponent(i).getNumberOfmoles(); + double change = SIval / totalNumberOfMolesLocal * getPhase(0).getComponent(i).getNumberOfmoles() + - getPhase(0).getComponent(i).getNumberOfmoles(); if (Math.abs(change) > 1e-12) { addComponent(i, change); } @@ -964,7 +971,8 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo // characterization.getTBPModel().calcPC(molarMass, density); PC = criticalPressure; m = characterization.getTBPModel().calcm(molarMass, density); - // acentracentrcharacterization.getTBPModel().calcAcentricFactor(molarMass, density); + // acentracentrcharacterization.getTBPModel().calcAcentricFactor(molarMass, + // density); acs = acentricFactor; TB = characterization.getTBPModel().calcTB(molarMass, density); molarMass /= 1000.0; @@ -1017,7 +1025,8 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo double Kwatson = Math.pow(TB * 1.8, 1.0 / 3.0) / density; // System.out.println("watson " + Kwatson); double CF = Math.pow((12.8 - Kwatson) * (10.0 - Kwatson) / (10.0 * acs), 2.0); - // characterization.getTBPModel().calcAcentricFactorKeslerLee(molarMass*1000.0, density); + // characterization.getTBPModel().calcAcentricFactorKeslerLee(molarMass*1000.0, + // density); double acsKeslerLee = acs; double cpa = (-0.33886 + 0.02827 * Kwatson - 0.26105 * CF + 0.59332 * acsKeslerLee * CF) * 4.18682 * molarMass * 1e3; @@ -1195,8 +1204,7 @@ public void addComponent(String componentName, double value, String unitName) { double stddens = 0.0; double boilp = 0.0; try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); - java.sql.ResultSet dataSet = - database.getResultSet(("SELECT * FROM comp WHERE name='" + componentName + "'"))) { + java.sql.ResultSet dataSet = database.getResultSet(("SELECT * FROM comp WHERE name='" + componentName + "'"))) { dataSet.next(); molarmass = Double.parseDouble(dataSet.getString("molarmass")) / 1000.0; stddens = Double.parseDouble(dataSet.getString("stddens")); @@ -1204,8 +1212,7 @@ public void addComponent(String componentName, double value, String unitName) { } catch (Exception ex) { logger.error("failed ", ex); } - neqsim.util.unit.Unit unit = - new neqsim.util.unit.RateUnit(value, unitName, molarmass, stddens, boilp); + neqsim.util.unit.Unit unit = new neqsim.util.unit.RateUnit(value, unitName, molarmass, stddens, boilp); double SIval = unit.getSIvalue(); // System.out.println("number of moles " + SIval); this.addComponent(componentName, SIval); @@ -1255,8 +1262,8 @@ public void addComponent(String componentName, double moles, int phaseNumber) { // Add new component if (moles < 0.0) { String msg = "Negative input number of moles."; - neqsim.util.exception.InvalidInputException ex = - new neqsim.util.exception.InvalidInputException(this, "addComponent", "moles", msg); + neqsim.util.exception.InvalidInputException ex = new neqsim.util.exception.InvalidInputException(this, + "addComponent", "moles", msg); throw new RuntimeException(ex); } @@ -1289,8 +1296,7 @@ public void addComponent(String componentName, double value, String name, int ph double stddens = 0.0; double boilp = 0.0; try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); - java.sql.ResultSet dataSet = - database.getResultSet(("SELECT * FROM comp WHERE name='" + componentName + "'"))) { + java.sql.ResultSet dataSet = database.getResultSet(("SELECT * FROM comp WHERE name='" + componentName + "'"))) { dataSet.next(); molarmass = Double.parseDouble(dataSet.getString("molarmass")) / 1000.0; stddens = Double.parseDouble(dataSet.getString("stddens")); @@ -1299,8 +1305,7 @@ public void addComponent(String componentName, double value, String name, int ph logger.error("failed ", ex); throw new RuntimeException(ex); } - neqsim.util.unit.Unit unit = - new neqsim.util.unit.RateUnit(value, name, molarmass, stddens, boilp); + neqsim.util.unit.Unit unit = new neqsim.util.unit.RateUnit(value, name, molarmass, stddens, boilp); double SIval = unit.getSIvalue(); // System.out.println("number of moles " + SIval); this.addComponent(componentName, SIval, phase); @@ -1566,7 +1571,8 @@ public final double calcBeta() throws neqsim.util.exception.IsNaNException, } /* - * if ((nybeta > maxBeta) || (nybeta < minBeta)) { // nybeta = 0.5 * (maxBeta + minBeta); + * if ((nybeta > maxBeta) || (nybeta < minBeta)) { // nybeta = 0.5 * (maxBeta + + * minBeta); * gbeta = 1.0; } */ } else { @@ -1597,7 +1603,8 @@ public final double calcBeta() throws neqsim.util.exception.IsNaNException, } /* - * if ((betal > maxBeta) || (betal < minBeta)) { gbeta = 1.0; { betal = 0.5 * (maxBeta + + * if ((betal > maxBeta) || (betal < minBeta)) { gbeta = 1.0; { betal = 0.5 * + * (maxBeta + * minBeta); } } */ nybeta = 1.0 - betal; @@ -1627,7 +1634,8 @@ public final double calcBeta() throws neqsim.util.exception.IsNaNException, } if (Double.isNaN(beta[1])) { /* - * for (i = 0; i < numberOfComponents; i++) { System.out.println("K " + compArray[i].getK()); + * for (i = 0; i < numberOfComponents; i++) { System.out.println("K " + + * compArray[i].getK()); * System.out.println("z " + compArray[i].getz()); } */ throw new neqsim.util.exception.IsNaNException(this, "calcBeta", "beta"); @@ -1826,8 +1834,10 @@ public void init(int type, int phase) { * initAnalytic. *

* - * @param type a int. 0 to initialize and 1 to reset, 2 to calculate T and P derivatives, 3 to - * calculate all derivatives and 4 to calculate all derivatives numerically + * @param type a int. 0 to initialize and 1 to reset, 2 to calculate T and P + * derivatives, 3 to + * calculate all derivatives and 4 to calculate all derivatives + * numerically */ public void initAnalytic(int type) { @@ -1926,7 +1936,7 @@ public void initAnalytic(int type) { * initAnalytic. *

* - * @param type a int + * @param type a int * @param phase a int */ public void initAnalytic(int type, int phase) { @@ -1992,7 +2002,7 @@ public void initNumeric(int type) { * initNumeric. *

* - * @param type a int + * @param type a int * @param phasen a int */ public void initNumeric(int type, int phasen) { @@ -2062,8 +2072,7 @@ public void initNumeric(int type, int phasen) { init(1); for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - liqfug[0][i] = - Math.log(getPhases()[phase].getComponents()[i].getFugacityCoefficient()); + liqfug[0][i] = Math.log(getPhases()[phase].getComponents()[i].getFugacityCoefficient()); } addComponent(k, -2.0 * dn, phase); @@ -2074,8 +2083,7 @@ public void initNumeric(int type, int phasen) { for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { // gasfug[1][i] = // Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); - liqfug[1][i] = - Math.log(getPhases()[phase].getComponents()[i].getFugacityCoefficient()); + liqfug[1][i] = Math.log(getPhases()[phase].getComponents()[i].getFugacityCoefficient()); } addComponent(k, dn, phase); init_x_y(); @@ -2621,6 +2629,7 @@ public double getEnthalpy(String unit) { case "J": conversionFactor = 1.0; break; + case "kJ/kmol": case "J/mol": conversionFactor = 1.0 / getTotalNumberOfMoles(); break; @@ -2631,7 +2640,7 @@ public double getEnthalpy(String unit) { conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; break; default: - break; + throw new RuntimeException("unit not supported " + unit); } return refEnthalpy * conversionFactor; } @@ -2658,8 +2667,11 @@ public double getViscosity(String unit) { case "cP": conversionFactor = 1.0e3; break; + case "Pas": + conversionFactor = 1.0; + break; default: - throw new RuntimeException(); + throw new RuntimeException("unit not supported " + unit); } return refViscosity * conversionFactor; } @@ -2674,7 +2686,7 @@ public double getKinematicViscosity(String unit) { conversionFactor = 1.0; break; default: - throw new RuntimeException(); + throw new RuntimeException("unit not supported " + unit); } return refViscosity * conversionFactor; } @@ -2710,7 +2722,7 @@ public double getConductivity(String unit) { conversionFactor = 0.01; break; default: - throw new RuntimeException(); + throw new RuntimeException("unit not supported " + unit); } return refConductivity * conversionFactor; } @@ -2738,7 +2750,7 @@ public double getThermalConductivity(String unit) { conversionFactor = 0.01; break; default: - throw new RuntimeException(); + throw new RuntimeException("unit not supported " + unit); } return refConductivity * conversionFactor; } @@ -2772,7 +2784,7 @@ public double getInternalEnergy(String unit) { conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; break; default: - break; + throw new RuntimeException("unit not supported " + unit); } return refEnthalpy * conversionFactor; } @@ -2816,7 +2828,7 @@ public double getEntropy(String unit) { conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; break; default: - break; + throw new RuntimeException("unit not supported " + unit); } return refEntropy * conversionFactor; } @@ -2836,8 +2848,7 @@ public double getMolarVolume() { public double getDensity() { double density = 0; for (int i = 0; i < numberOfPhases; i++) { - density += - 1.0e5 * (getPhase(i).getMolarMass() * beta[phaseIndex[i]] / getPhase(i).getMolarVolume()); + density += 1.0e5 * (getPhase(i).getMolarMass() * beta[phaseIndex[i]] / getPhase(i).getMolarVolume()); } return density; } @@ -2847,8 +2858,7 @@ public double getDensity() { public double getDensity(String unit) { double density = 0; for (int i = 0; i < getNumberOfPhases(); i++) { - density += - getPhase(i).getVolume() / getVolume() * getPhase(i).getPhysicalProperties().getDensity(); + density += getPhase(i).getVolume() / getVolume() * getPhase(i).getPhysicalProperties().getDensity(); } double refDensity = density; // density in kg/m3 double conversionFactor = 1.0; @@ -2866,7 +2876,7 @@ public double getDensity(String unit) { conversionFactor = 1.0 / getMolarMass(); break; default: - throw new RuntimeException(); + throw new RuntimeException("unit not supported " + unit); } return refDensity * conversionFactor; } @@ -2896,8 +2906,7 @@ public double getMoleFractionsSum() { public double getMolarMass() { double tempVar = 0; for (int i = 0; i < phaseArray[0].getNumberOfComponents(); i++) { - tempVar += - phaseArray[0].getComponents()[i].getz() * phaseArray[0].getComponents()[i].getMolarMass(); + tempVar += phaseArray[0].getComponents()[i].getz() * phaseArray[0].getComponents()[i].getMolarMass(); } return tempVar; } @@ -2915,7 +2924,7 @@ public double getMolarMass(String unit) { conversionFactor = 1000.0; break; default: - throw new RuntimeException(); + throw new RuntimeException("unit not supported " + unit); } return refMolarMass * conversionFactor; } @@ -2943,7 +2952,7 @@ public void setTemperature(double newTemperature, String unit) { } else if (unit.equals("C")) { getPhases()[i].setTemperature(newTemperature + 273.15); } else { - throw new RuntimeException(); + throw new RuntimeException("unit not supported " + unit); } } } @@ -3025,7 +3034,8 @@ public void reInitPhaseType() { } /** - * Re-initialize phasetype, beta and phaseindex arrays, same initialization which is used in + * Re-initialize phasetype, beta and phaseindex arrays, same initialization + * which is used in * constructor. */ public void reInitPhaseInformation() { @@ -3037,7 +3047,7 @@ public void reInitPhaseInformation() { beta[i] = 1.0; } - phaseIndex = new int[] {0, 1, 2, 3, 4, 5}; + phaseIndex = new int[] { 0, 1, 2, 3, 4, 5 }; } /** {@inheritDoc} */ @@ -3057,8 +3067,7 @@ public final void setPressure(double newPressure) { /** {@inheritDoc} */ @Override public final void setPressure(double newPressure, String unit) { - neqsim.util.unit.PressureUnit presConversion = - new neqsim.util.unit.PressureUnit(newPressure, unit); + neqsim.util.unit.PressureUnit presConversion = new neqsim.util.unit.PressureUnit(newPressure, unit); setPressure(presConversion.getValue("bara")); } @@ -3071,8 +3080,7 @@ public final double getTemperature() { /** {@inheritDoc} */ @Override public final double getTemperature(String unit) { - neqsim.util.unit.TemperatureUnit tempConversion = - new neqsim.util.unit.TemperatureUnit(getTemperature(), "K"); + neqsim.util.unit.TemperatureUnit tempConversion = new neqsim.util.unit.TemperatureUnit(getTemperature(), "K"); return tempConversion.getValue(unit); } @@ -3091,8 +3099,7 @@ public final double getPressure() { /** {@inheritDoc} */ @Override public final double getPressure(String unit) { - neqsim.util.unit.PressureUnit presConversion = - new neqsim.util.unit.PressureUnit(getPressure(), "bara"); + neqsim.util.unit.PressureUnit presConversion = new neqsim.util.unit.PressureUnit(getPressure(), "bara"); return presConversion.getValue(unit); } @@ -3189,7 +3196,7 @@ public double getVolume(String unit) { conversionFactor = 1.0 / getTotalNumberOfMoles(); break; default: - break; + throw new RuntimeException("unit not supported " + unit); } return conversionFactor * getVolume() / 1.0e5; } @@ -3210,7 +3217,7 @@ public double getMass(String unit) { conversionFactor = 1.0e-3; break; default: - break; + throw new RuntimeException("unit not supported " + unit); } return conversionFactor * getTotalNumberOfMoles() * getMolarMass(); } @@ -3300,7 +3307,7 @@ public double getCp(String unit) { conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; break; default: - break; + throw new RuntimeException("unit not supported " + unit); } return refCp * conversionFactor; } @@ -3334,7 +3341,7 @@ public double getCv(String unit) { conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; break; default: - break; + throw new RuntimeException("unit not supported " + unit); } return refCv * conversionFactor; } @@ -3440,49 +3447,45 @@ public String[][] createTable(String name) { table[j + 1][1] = nf.format(getPhase(0).getComponents()[j].getz(), buf, test).toString(); } buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 4][1] = - nf.format(getMolarMass() * 1000, buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 4][1] = nf.format(getMolarMass() * 1000, buf, test).toString(); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 9][1] = - nf.format(getEnthalpy() / (getTotalNumberOfMoles() * getMolarMass() * 1000), buf, test) - .toString(); + table[getPhases()[0].getNumberOfComponents() + 9][1] = nf + .format(getEnthalpy() / (getTotalNumberOfMoles() * getMolarMass() * 1000), buf, test) + .toString(); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 10][1] = - nf.format(getEntropy() / (getTotalNumberOfMoles() * getMolarMass() * 1000), buf, test) - .toString(); + table[getPhases()[0].getNumberOfComponents() + 10][1] = nf + .format(getEntropy() / (getTotalNumberOfMoles() * getMolarMass() * 1000), buf, test) + .toString(); for (int i = 0; i < numberOfPhases; i++) { for (int j = 0; j < getPhases()[0].getNumberOfComponents(); j++) { table[j + 1][0] = getPhases()[0].getComponents()[j].getName(); buf = new StringBuffer(); - table[j + 1][i + 2] = - nf.format(getPhase(i).getComponents()[j].getx(), buf, test).toString(); + table[j + 1][i + 2] = nf.format(getPhase(i).getComponents()[j].getx(), buf, test).toString(); table[j + 1][6] = "[mole fraction]"; } buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 2][0] = "Density"; - table[getPhases()[0].getNumberOfComponents() + 2][i + 2] = - nf.format(getPhase(i).getPhysicalProperties().getDensity(), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 2][i + 2] = nf + .format(getPhase(i).getPhysicalProperties().getDensity(), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 2][6] = "[kg/m^3]"; // Double.longValue(system.getPhase(i).getBeta()); buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 3][0] = "PhaseFraction"; - table[getPhases()[0].getNumberOfComponents() + 3][i + 2] = - nf.format(getPhase(i).getBeta(), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 3][i + 2] = nf.format(getPhase(i).getBeta(), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 3][6] = "[mole fraction]"; buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 4][0] = "MolarMass"; - table[getPhases()[0].getNumberOfComponents() + 4][i + 2] = - nf.format(getPhase(i).getMolarMass() * 1000, buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 4][i + 2] = nf.format(getPhase(i).getMolarMass() * 1000, buf, test) + .toString(); table[getPhases()[0].getNumberOfComponents() + 4][6] = "[kg/kmol]"; buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 5][0] = "Z factor"; - table[getPhases()[0].getNumberOfComponents() + 5][i + 2] = - nf.format(getPhase(i).getZ(), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 5][i + 2] = nf.format(getPhase(i).getZ(), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 5][6] = "[-]"; buf = new StringBuffer(); @@ -3503,8 +3506,8 @@ public String[][] createTable(String name) { buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 8][0] = "Speed of Sound"; - table[getPhases()[0].getNumberOfComponents() + 8][i + 2] = - nf.format((getPhase(i).getSoundSpeed()), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 8][i + 2] = nf.format((getPhase(i).getSoundSpeed()), buf, test) + .toString(); table[getPhases()[0].getNumberOfComponents() + 8][6] = "[m/sec]"; buf = new StringBuffer(); @@ -3525,47 +3528,47 @@ public String[][] createTable(String name) { buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 11][0] = "JT coefficient"; - table[getPhases()[0].getNumberOfComponents() + 11][i + 2] = - nf.format((getPhase(i).getJouleThomsonCoefficient()), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 11][i + 2] = nf + .format((getPhase(i).getJouleThomsonCoefficient()), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 11][6] = "[K/bar]"; buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 13][0] = "Viscosity"; - table[getPhases()[0].getNumberOfComponents() + 13][i + 2] = - nf.format((getPhase(i).getPhysicalProperties().getViscosity()), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 13][i + 2] = nf + .format((getPhase(i).getPhysicalProperties().getViscosity()), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 13][6] = "[kg/m*sec]"; buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 14][0] = "Conductivity"; - table[getPhases()[0].getNumberOfComponents() + 14][i + 2] = - nf.format(getPhase(i).getPhysicalProperties().getConductivity(), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 14][i + 2] = nf + .format(getPhase(i).getPhysicalProperties().getConductivity(), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 14][6] = "[W/m*K]"; buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 15][0] = "SurfaceTension"; try { if (i < numberOfPhases - 1) { - table[getPhases()[0].getNumberOfComponents() + 15][2] = - nf.format(getInterphaseProperties().getSurfaceTension(0, 1), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 15][2] = nf + .format(getInterphaseProperties().getSurfaceTension(0, 1), buf, test).toString(); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 15][3] = - nf.format(getInterphaseProperties().getSurfaceTension(0, 1), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 15][3] = nf + .format(getInterphaseProperties().getSurfaceTension(0, 1), buf, test).toString(); buf = new StringBuffer(); if (i == 1) { - table[getPhases()[0].getNumberOfComponents() + 17][2] = - nf.format(getInterphaseProperties().getSurfaceTension(0, 2), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 17][2] = nf + .format(getInterphaseProperties().getSurfaceTension(0, 2), buf, test).toString(); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 17][4] = - nf.format(getInterphaseProperties().getSurfaceTension(0, 2), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 17][4] = nf + .format(getInterphaseProperties().getSurfaceTension(0, 2), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 17][6] = "[N/m]"; } if (i == 1) { buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 16][3] = - nf.format(getInterphaseProperties().getSurfaceTension(1, 2), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 16][3] = nf + .format(getInterphaseProperties().getSurfaceTension(1, 2), buf, test).toString(); buf = new StringBuffer(); - table[getPhases()[0].getNumberOfComponents() + 16][4] = - nf.format(getInterphaseProperties().getSurfaceTension(1, 2), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 16][4] = nf + .format(getInterphaseProperties().getSurfaceTension(1, 2), buf, test).toString(); table[getPhases()[0].getNumberOfComponents() + 16][6] = "[N/m]"; } } @@ -3576,14 +3579,12 @@ public String[][] createTable(String name) { buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 19][0] = "Pressure"; - table[getPhases()[0].getNumberOfComponents() + 19][i + 2] = - Double.toString(getPhase(i).getPressure()); + table[getPhases()[0].getNumberOfComponents() + 19][i + 2] = Double.toString(getPhase(i).getPressure()); table[getPhases()[0].getNumberOfComponents() + 19][6] = "[bar]"; buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 20][0] = "Temperature"; - table[getPhases()[0].getNumberOfComponents() + 20][i + 2] = - Double.toString(getPhase(i).getTemperature()); + table[getPhases()[0].getNumberOfComponents() + 20][i + 2] = Double.toString(getPhase(i).getTemperature()); table[getPhases()[0].getNumberOfComponents() + 20][6] = "[K]"; Double.toString(getPhase(i).getTemperature()); @@ -3595,8 +3596,8 @@ public String[][] createTable(String name) { buf = new StringBuffer(); table[getPhases()[0].getNumberOfComponents() + 23][0] = "Mixing Rule"; try { - table[getPhases()[0].getNumberOfComponents() + 23][i + 2] = - ((PhaseEosInterface) getPhase(i)).getMixingRuleName(); + table[getPhases()[0].getNumberOfComponents() + 23][i + 2] = ((PhaseEosInterface) getPhase(i)) + .getMixingRuleName(); } catch (Exception ex) { table[getPhases()[0].getNumberOfComponents() + 23][i + 2] = "?"; // logger.error(ex.getMessage(),e); @@ -3627,7 +3628,7 @@ public void display(String name) { Container dialogContentPane = dialog.getContentPane(); dialogContentPane.setLayout(new BorderLayout()); - String[] names = {"", "Feed", "Phase 1", "Phase 2", "Phase 3", "Phase 4", "Unit"}; + String[] names = { "", "Feed", "Phase 1", "Phase 2", "Phase 3", "Phase 4", "Unit" }; String[][] table = createTable(name); JTable Jtab = new JTable(table, names); JScrollPane scrollpane = new JScrollPane(Jtab); @@ -3659,8 +3660,7 @@ public String write() { @Override public void write(String name, String filename, boolean newfile) { String[][] table = createTable(name); - neqsim.dataPresentation.fileHandeling.createTextFile.TextFile file = - new neqsim.dataPresentation.fileHandeling.createTextFile.TextFile(); + neqsim.dataPresentation.fileHandeling.createTextFile.TextFile file = new neqsim.dataPresentation.fileHandeling.createTextFile.TextFile(); if (newfile) { file.newFile(filename); } @@ -3725,7 +3725,6 @@ public void createDatabase(boolean reset) { public void setSolidPhaseCheck(boolean solidPhaseCheck) { this.solidPhaseCheck = solidPhaseCheck; - final int oldphase = numberOfPhases; if (solidPhaseCheck && !this.hasSolidPhase()) { addSolidPhase(); @@ -3862,8 +3861,7 @@ public void save(String name) { public SystemInterface readObject(int ID) { ResultSet rs = null; SystemThermo tempSystem = null; - neqsim.util.database.NeqSimBlobDatabase database = - new neqsim.util.database.NeqSimBlobDatabase(); + neqsim.util.database.NeqSimBlobDatabase database = new neqsim.util.database.NeqSimBlobDatabase(); try { java.sql.Connection con = database.openConnection(); String sqlStr = "SELECT FLUID FROM fluid_blobdb WHERE ID=" + Integer.toString(ID); @@ -3871,8 +3869,7 @@ public SystemInterface readObject(int ID) { rs = ps.executeQuery(); if (rs.next()) { - try (ObjectInputStream ins = - new ObjectInputStream(new ByteArrayInputStream(rs.getBytes("FLUID")))) { + try (ObjectInputStream ins = new ObjectInputStream(new ByteArrayInputStream(rs.getBytes("FLUID")))) { tempSystem = (SystemThermo) ins.readObject(); } } @@ -3918,21 +3915,20 @@ public void saveObject(int ID, String text) { byte[] byteObject = fout.toByteArray(); ByteArrayInputStream inpStream = new ByteArrayInputStream(byteObject); - neqsim.util.database.NeqSimBlobDatabase database = - new neqsim.util.database.NeqSimBlobDatabase(); + neqsim.util.database.NeqSimBlobDatabase database = new neqsim.util.database.NeqSimBlobDatabase(); try { java.sql.Connection con = database.openConnection(); - java.sql.PreparedStatement ps = - con.prepareStatement("REPLACE INTO fluid_blobdb (ID, FLUID) VALUES (?,?)"); + java.sql.PreparedStatement ps = con.prepareStatement("REPLACE INTO fluid_blobdb (ID, FLUID) VALUES (?,?)"); ps.setInt(1, ID); ps.setBlob(2, inpStream); ps.executeUpdate(); /* * if (!text.isEmpty()) { ps = con.prepareStatement( - * "REPLACE INTO fluidinfo (ID, TEXT) VALUES (?,?)"); ps.setInt(1, ID); ps.setString(2, text); + * "REPLACE INTO fluidinfo (ID, TEXT) VALUES (?,?)"); ps.setInt(1, ID); + * ps.setString(2, text); * } * * ps.executeUpdate(); @@ -3969,8 +3965,7 @@ public void saveObjectToFile(String filePath, String fluidName) { @Override public SystemInterface readObjectFromFile(String filePath, String fluidName) { SystemThermo tempSystem = null; - try (ObjectInputStream objectinputstream = - new ObjectInputStream(new FileInputStream(filePath))) { + try (ObjectInputStream objectinputstream = new ObjectInputStream(new FileInputStream(filePath))) { tempSystem = (SystemThermo) objectinputstream.readObject(); } catch (Exception ex) { logger.error(ex.getMessage(), ex); @@ -4016,8 +4011,7 @@ public void setFluidName(String fluidName) { * @return a boolean */ public boolean setLastTBPasPlus() { - neqsim.thermo.characterization.PlusCharacterize temp = - new neqsim.thermo.characterization.PlusCharacterize(this); + neqsim.thermo.characterization.PlusCharacterize temp = new neqsim.thermo.characterization.PlusCharacterize(this); if (temp.hasPlusFraction()) { return false; } else { @@ -4141,9 +4135,8 @@ public void saveToDataBase() { database.execute("delete FROM systemreport"); int i = 0; for (; i < numberOfComponents; i++) { - String sqlString = - "'" + Integer.toString(i + 1) + "', '" + getPhase(0).getComponent(i).getName() + "', " - + "'molfrac[-] ', '" + Double.toString(getPhase(0).getComponent(i).getz()) + "'"; + String sqlString = "'" + Integer.toString(i + 1) + "', '" + getPhase(0).getComponent(i).getName() + "', " + + "'molfrac[-] ', '" + Double.toString(getPhase(0).getComponent(i).getz()) + "'"; int j = 0; for (; j < numberOfPhases; j++) { @@ -4292,8 +4285,7 @@ public double getHeatOfVaporization() { public void readFluid(String fluidName) { this.fluidName = fluidName; try { - neqsim.util.database.NeqSimFluidDataBase database = - new neqsim.util.database.NeqSimFluidDataBase(); + neqsim.util.database.NeqSimFluidDataBase database = new neqsim.util.database.NeqSimFluidDataBase(); java.sql.ResultSet dataSet = null; dataSet = database.getResultSet("SELECT * FROM " + fluidName); @@ -4356,15 +4348,13 @@ public SystemInterface setModel(String model) { tempModel = new SystemSrkSchwartzentruberEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); } else if (model.equals("Electrolyte-ScRK-EOS")) { - tempModel = - new SystemFurstElectrolyteEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); + tempModel = new SystemFurstElectrolyteEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); } else if (model.equals("GERG-water-EOS")) { tempModel = new SystemGERGwaterEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); } else if (model.equals("CPAs-SRK-EOS")) { tempModel = new SystemSrkCPAs(getPhase(0).getTemperature(), getPhase(0).getPressure()); } else if (model.equals("CPAs-SRK-EOS-statoil")) { - tempModel = - new SystemSrkCPAstatoil(getPhase(0).getTemperature(), getPhase(0).getPressure()); + tempModel = new SystemSrkCPAstatoil(getPhase(0).getTemperature(), getPhase(0).getPressure()); } else if (model.equals("Electrolyte-CPA-EOS-statoil") || model.equals("Electrolyte-CPA-EOS")) { tempModel = new SystemElectrolyteCPAstatoil(getPhase(0).getTemperature(), @@ -4376,11 +4366,9 @@ public SystemInterface setModel(String model) { } else if (model.equals("GERG-2008-EoS")) { tempModel = new SystemGERG2004Eos(getPhase(0).getTemperature(), getPhase(0).getPressure()); } else if (model.equals("SRK-TwuCoon-Statoil-EOS") || model.equals("SRK-TwuCoon-EOS")) { - tempModel = - new SystemSrkTwuCoonStatoilEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); + tempModel = new SystemSrkTwuCoonStatoilEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); } else if (model.equals("SRK-TwuCoon-Param-EOS")) { - tempModel = - new SystemSrkTwuCoonParamEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); + tempModel = new SystemSrkTwuCoonParamEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); } else if (model.equals("Duan-Sun")) { tempModel = new SystemDuanSun(getPhase(0).getTemperature(), getPhase(0).getPressure()); } else { @@ -4629,7 +4617,8 @@ public double getTotalNumberOfMoles() { public void setTotalNumberOfMoles(double totalNumberOfMoles) { if (totalNumberOfMoles < 0) { /* - * throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, + * throw new RuntimeException(new + * neqsim.util.exception.InvalidInputException(this, * "setTotalNumberOfMoles", "totalNumberOfMoles", "can not be less than 0.")); */ totalNumberOfMoles = 0; @@ -5093,10 +5082,11 @@ public SystemProperties getProperties() { } /** - * Wrapper function for addComponent to set fluid type and specify mole fractions. + * Wrapper function for addComponent to set fluid type and specify mole + * fractions. * * @param molefractions Component mole fraction of each component. - * @param type Type of fluid. Supports "PlusFluid", "Plus" and default. + * @param type Type of fluid. Supports "PlusFluid", "Plus" and default. */ private void setMolarFractions(double[] molefractions, String type) { double totalFlow = getTotalNumberOfMoles(); From 954cde5abe1f28f731a463ed371978dce325c905 Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Wed, 16 Aug 2023 21:07:22 +0000 Subject: [PATCH 2/4] bug fix --- src/main/java/neqsim/thermo/phase/Phase.java | 1 + src/main/java/neqsim/thermo/phase/PhaseInterface.java | 2 +- src/main/java/neqsim/thermo/system/SystemInterface.java | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/neqsim/thermo/phase/Phase.java b/src/main/java/neqsim/thermo/phase/Phase.java index 5409e05ef..9d67c2ace 100644 --- a/src/main/java/neqsim/thermo/phase/Phase.java +++ b/src/main/java/neqsim/thermo/phase/Phase.java @@ -1153,6 +1153,7 @@ public double getViscosity(String unit) { double refViscosity = getViscosity(); // viscosity in kg/msec double conversionFactor = 1.0; switch (unit) { + case "Pas": case "kg/msec": conversionFactor = 1.0; break; diff --git a/src/main/java/neqsim/thermo/phase/PhaseInterface.java b/src/main/java/neqsim/thermo/phase/PhaseInterface.java index 0977cc466..a1d22bba7 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseInterface.java +++ b/src/main/java/neqsim/thermo/phase/PhaseInterface.java @@ -1111,7 +1111,7 @@ public default void addMolesChemReac(int component, double dn) { /** * method to return viscosity og the phase in a specified unit. * - * @param unit Supported units are kg/msec, cP (centipoise) + * @param unit Supported units are kg/msec, Pas, cP (centipoise) * @return viscosity in specified unit */ public double getViscosity(String unit); diff --git a/src/main/java/neqsim/thermo/system/SystemInterface.java b/src/main/java/neqsim/thermo/system/SystemInterface.java index 7a4351c7d..75063b82b 100644 --- a/src/main/java/neqsim/thermo/system/SystemInterface.java +++ b/src/main/java/neqsim/thermo/system/SystemInterface.java @@ -5,7 +5,7 @@ import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.characterization.WaxModelInterface; import neqsim.thermo.component.ComponentInterface; -import neqsim.thermo.phase.PhaseInterface;g +import neqsim.thermo.phase.PhaseInterface; import neqsim.thermo.phase.PhaseType; /** From 642c69e69eef34faa5edc625f29b7ab7e282c84f Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Wed, 16 Aug 2023 21:13:20 +0000 Subject: [PATCH 3/4] spelling error --- .../neqsim/thermo/phase/PhaseInterface.java | 227 ++++++++++-------- 1 file changed, 127 insertions(+), 100 deletions(-) diff --git a/src/main/java/neqsim/thermo/phase/PhaseInterface.java b/src/main/java/neqsim/thermo/phase/PhaseInterface.java index a1d22bba7..5df1940cc 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseInterface.java +++ b/src/main/java/neqsim/thermo/phase/PhaseInterface.java @@ -24,10 +24,10 @@ public interface PhaseInterface extends ThermodynamicConstantsInterface, Cloneab * addcomponent. *

* - * @param name Name of component. - * @param moles a double + * @param name Name of component. + * @param moles a double * @param molesInPhase a double - * @param compNumber a int + * @param compNumber a int */ public void addComponent(String name, double moles, double molesInPhase, int compNumber); @@ -36,10 +36,10 @@ public interface PhaseInterface extends ThermodynamicConstantsInterface, Cloneab * addcomponent. *

* - * @param name Name of component. - * @param moles a double + * @param name Name of component. + * @param moles a double * @param molesInPhase a double - * @param compNumber a int + * @param compNumber a int * @deprecated Replaced by {@link addComponent} */ @Deprecated @@ -67,10 +67,12 @@ public default void addcomponent(String name, double moles, double molesInPhase, /** *

- * Returns the composition vector in unit molefraction/wtfraction/molespersec/volumefraction. + * Returns the composition vector in unit + * molefraction/wtfraction/molespersec/volumefraction. *

* - * @param unit Supported units are molefraction, wtfraction, molespersec, volumefraction + * @param unit Supported units are molefraction, wtfraction, molespersec, + * volumefraction * @return composition array with unit */ public double[] getComposition(String unit); @@ -136,7 +138,8 @@ public default void addcomponent(String name, double moles, double molesInPhase, public double getVolume(String unit); /** - * method to return heat capacity ratio/adiabatic index/Poisson constant. The method calculates it + * method to return heat capacity ratio/adiabatic index/Poisson constant. The + * method calculates it * as Cp (real) /Cv (real). * * @return gamma @@ -144,7 +147,8 @@ public default void addcomponent(String name, double moles, double molesInPhase, public double getGamma(); /** - * method to return heat capacity ratio calculated as Cp/(Cp-R*getNumberOfMolesInPhase). + * method to return heat capacity ratio calculated as + * Cp/(Cp-R*getNumberOfMolesInPhase). * * @return kappa */ @@ -239,8 +243,8 @@ public default double getGamma2() { * * @param totalNumberOfMoles Total number of moles in all phases of Stream. * @param numberOfComponents Number of components in system. - * @param type a int. Use 0 to init, and 1 to reset. - * @param beta Mole fraction of this phase in system. + * @param type a int. Use 0 to init, and 1 to reset. + * @param beta Mole fraction of this phase in system. */ public default void init(double totalNumberOfMoles, int numberOfComponents, int type, double beta) { @@ -254,9 +258,9 @@ public default void init(double totalNumberOfMoles, int numberOfComponents, int * * @param totalNumberOfMoles Total number of moles in all phases of Stream. * @param numberOfComponents Number of components in system. - * @param type a int. Use 0 to init, and 1 to reset. - * @param pt Type of phase. - * @param beta Mole fraction of this phase in system. + * @param type a int. Use 0 to init, and 1 to reset. + * @param pt Type of phase. + * @param beta Mole fraction of this phase in system. */ public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType pt, double beta); @@ -268,9 +272,9 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph * * @param totalNumberOfMoles Total number of moles in system. * @param numberOfComponents Number of components in system. - * @param type a int. Use 0 to init, and 1 to reset. - * @param ptNumber Phase type index. - * @param beta Mole fraction of this phase in system. + * @param type a int. Use 0 to init, and 1 to reset. + * @param ptNumber Phase type index. + * @param beta Mole fraction of this phase in system. * @deprecated Replace with init-function using PhaseType input. */ @Deprecated @@ -363,7 +367,8 @@ public default void init(double totalNumberOfMoles, int numberOfComponents, int * getcomponentArray. *

* - * @return an array of {@link neqsim.thermo.component.ComponentInterface} objects + * @return an array of {@link neqsim.thermo.component.ComponentInterface} + * objects */ public ComponentInterface[] getcomponentArray(); @@ -387,7 +392,8 @@ public default void init(double totalNumberOfMoles, int numberOfComponents, int public double getWtFraction(SystemInterface system); /** - * method to return molar volume of the phase note: without Peneloux volume correction. + * method to return molar volume of the phase note: without Peneloux volume + * correction. * * @return molar volume volume in unit m3/mol*1e5 */ @@ -396,8 +402,9 @@ public default void init(double totalNumberOfMoles, int numberOfComponents, int /** * method to return flow rate of a phase. * - * @param flowunit Supported units are kg/sec, kg/min, kg/hr, m3/sec, m3/min, m3/hr, ft3/sec, - * mole/sec, mole/min, mole/hr + * @param flowunit Supported units are kg/sec, kg/min, kg/hr, m3/sec, m3/min, + * m3/hr, ft3/sec, + * mole/sec, mole/min, mole/hr * @return flow rate in specified unit */ public double getFlowRate(String flowunit); @@ -407,7 +414,8 @@ public default void init(double totalNumberOfMoles, int numberOfComponents, int * setComponentArray. *

* - * @param components an array of {@link neqsim.thermo.component.ComponentInterface} objects + * @param components an array of + * {@link neqsim.thermo.component.ComponentInterface} objects */ public void setComponentArray(ComponentInterface[] components); @@ -428,7 +436,8 @@ public default void init(double totalNumberOfMoles, int numberOfComponents, int public double[] getProperties_GERG2008(); /** - * method to get density of a phase note: does not use Peneloux volume correction. + * method to get density of a phase note: does not use Peneloux volume + * correction. * * @return density with unit kg/m3 */ @@ -447,10 +456,10 @@ public default void init(double totalNumberOfMoles, int numberOfComponents, int * removeComponent. *

* - * @param name a {@link String} object - * @param moles a double + * @param name a {@link String} object + * @param moles a double * @param molesInPhase a double - * @param compNumber a int + * @param compNumber a int */ public void removeComponent(String name, double moles, double molesInPhase, int compNumber); @@ -619,7 +628,8 @@ public default double getExessGibbsEnergySymetric() { /** *

- * Getter for property beta. Beta is the mole fraction of a phase of all the moles of + * Getter for property beta. Beta is the mole fraction of a phase + * of all the moles of * a system. *

* @@ -629,7 +639,8 @@ public default double getExessGibbsEnergySymetric() { /** *

- * Setter for property beta. Beta is the mole fraction of a phase of all the moles of + * Setter for property beta. Beta is the mole fraction of a phase + * of all the moles of * a system. *

* @@ -757,7 +768,7 @@ public default double getExessGibbsEnergySymetric() { * getPureComponentFugacity. *

* - * @param k a int + * @param k a int * @param pure a boolean * @return a double */ @@ -765,15 +776,18 @@ public default double getExessGibbsEnergySymetric() { /** *

- * Change the number of moles of component of phase,i.e., numberOfMolesInPhase but do + * Change the number of moles of component of phase,i.e., + * numberOfMolesInPhase but do * not change the total number of moles of component in system. * - * NB! Phase fraction beta is not updated by this method. Must be done separately to - * keep consistency between phase and component calculation of of total number of moles in system. + * NB! Phase fraction beta is not updated by this method. Must be + * done separately to + * keep consistency between phase and component calculation of of total number + * of moles in system. *

* * @param component Component number to change - * @param dn Number of moles of component added to phase + * @param dn Number of moles of component added to phase */ public default void addMoles(int component, double dn) { addMolesChemReac(component, dn, 0); @@ -781,16 +795,20 @@ public default void addMoles(int component, double dn) { /** *

- * Change the number of moles of component of phase, i.e., numberOfMolesInPhase, and - * total number of moles of component in system, i.e., numberOfMoles with the same + * Change the number of moles of component of phase, i.e., + * numberOfMolesInPhase, and + * total number of moles of component in system, i.e., + * numberOfMoles with the same * amount. * - * NB! Phase fraction beta is not updated by this method. Must be done separately to - * keep consistency between phase and component calculation of of total number of moles in system. + * NB! Phase fraction beta is not updated by this method. Must be + * done separately to + * keep consistency between phase and component calculation of of total number + * of moles in system. *

* * @param component Component number to change - * @param dn Number of moles of component added to phase and system + * @param dn Number of moles of component added to phase and system */ public default void addMolesChemReac(int component, double dn) { addMolesChemReac(component, dn, dn); @@ -798,18 +816,23 @@ public default void addMolesChemReac(int component, double dn) { /** *

- * Change the number of moles of component of phase, i.e., numberOfMolesInPhase and - * Component properties for the number of moles of component of phase, i.e., - * numberOfMolesInPhase, and total number of moles of component in system, i.e., + * Change the number of moles of component of phase, i.e., + * numberOfMolesInPhase and + * Component properties for the number of moles of component of + * phase, i.e., + * numberOfMolesInPhase, and total number of moles of component in + * system, i.e., * numberOfMoles with separate amounts. * - * NB! Phase fraction beta is not updated by this method. Must be done separately to - * keep consistency between phase and component calculation of of total number of moles in system. + * NB! Phase fraction beta is not updated by this method. Must be + * done separately to + * keep consistency between phase and component calculation of of total number + * of moles in system. *

* * @param component Component number to change - * @param dn Number of moles of component to add to phase - * @param totdn Number of moles of component to add to system + * @param dn Number of moles of component to add to phase + * @param totdn Number of moles of component to add to system */ public void addMolesChemReac(int component, double dn, double totdn); @@ -875,7 +898,8 @@ public default void addMolesChemReac(int component, double dn) { * getPhysicalProperties. *

* - * @return a {@link neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface} + * @return a + * {@link neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface} * object */ public neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterface getPhysicalProperties(); @@ -885,13 +909,13 @@ public default void addMolesChemReac(int component, double dn) { * molarVolume. *

* - * @param pressure a double + * @param pressure a double * @param temperature a double - * @param A a double - * @param B a double - * @param phase a int + * @param A a double + * @param B a double + * @param phase a int * @return a double - * @throws neqsim.util.exception.IsNaNException if any. + * @throws neqsim.util.exception.IsNaNException if any. * @throws neqsim.util.exception.TooManyIterationsException if any. */ double molarVolume(double pressure, double temperature, double A, double B, int phase) @@ -902,10 +926,10 @@ public default void addMolesChemReac(int component, double dn) { * geta. *

* - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object * @param temperature a double - * @param pressure a double - * @param numbcomp a int + * @param pressure a double + * @param numbcomp a int * @return a double */ public double geta(PhaseInterface phase, double temperature, double pressure, int numbcomp); @@ -915,10 +939,10 @@ public default void addMolesChemReac(int component, double dn) { * getb. *

* - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object * @param temperature a double - * @param pressure a double - * @param numbcomp a int + * @param pressure a double + * @param numbcomp a int * @return a double */ public double getb(PhaseInterface phase, double temperature, double pressure, int numbcomp); @@ -938,10 +962,10 @@ public default void addMolesChemReac(int component, double dn) { * calcA. *

* - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object * @param temperature a double - * @param pressure a double - * @param numbcomp a int + * @param pressure a double + * @param numbcomp a int * @return a double */ double calcA(PhaseInterface phase, double temperature, double pressure, int numbcomp); @@ -951,10 +975,10 @@ public default void addMolesChemReac(int component, double dn) { * calcB. *

* - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object * @param temperature a double - * @param pressure a double - * @param numbcomp a int + * @param pressure a double + * @param numbcomp a int * @return a double */ double calcB(PhaseInterface phase, double temperature, double pressure, int numbcomp); @@ -964,11 +988,11 @@ public default void addMolesChemReac(int component, double dn) { * calcAi. *

* - * @param compNumb a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param compNumb a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object * @param temperature a double - * @param pressure a double - * @param numbcomp a int + * @param pressure a double + * @param numbcomp a int * @return a double */ double calcAi(int compNumb, PhaseInterface phase, double temperature, double pressure, @@ -979,11 +1003,11 @@ public default void addMolesChemReac(int component, double dn) { * calcAiT. *

* - * @param compNumb a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param compNumb a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object * @param temperature a double - * @param pressure a double - * @param numbcomp a int + * @param pressure a double + * @param numbcomp a int * @return a double */ double calcAiT(int compNumb, PhaseInterface phase, double temperature, double pressure, @@ -994,12 +1018,12 @@ public default void addMolesChemReac(int component, double dn) { * calcAij. *

* - * @param compNumb a int - * @param j a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param compNumb a int + * @param j a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object * @param temperature a double - * @param pressure a double - * @param numbcomp a int + * @param pressure a double + * @param numbcomp a int * @return a double */ double calcAij(int compNumb, int j, PhaseInterface phase, double temperature, double pressure, @@ -1010,12 +1034,12 @@ public default void addMolesChemReac(int component, double dn) { * calcBij. *

* - * @param compNumb a int - * @param j a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param compNumb a int + * @param j a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object * @param temperature a double - * @param pressure a double - * @param numbcomp a int + * @param pressure a double + * @param numbcomp a int * @return a double */ double calcBij(int compNumb, int j, PhaseInterface phase, double temperature, double pressure, @@ -1026,11 +1050,11 @@ public default void addMolesChemReac(int component, double dn) { * calcAT. *

* - * @param compNumb a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param compNumb a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object * @param temperature a double - * @param pressure a double - * @param numbcomp a int + * @param pressure a double + * @param numbcomp a int * @return a double */ double calcAT(int compNumb, PhaseInterface phase, double temperature, double pressure, @@ -1041,11 +1065,11 @@ public default void addMolesChemReac(int component, double dn) { * calcBi. *

* - * @param compNumb a int - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param compNumb a int + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object * @param temperature a double - * @param pressure a double - * @param numbcomp a int + * @param pressure a double + * @param numbcomp a int * @return a double */ double calcBi(int compNumb, PhaseInterface phase, double temperature, double pressure, @@ -1109,7 +1133,7 @@ public default void addMolesChemReac(int component, double dn) { public double getViscosity(); /** - * method to return viscosity og the phase in a specified unit. + * method to return viscosity of the phase in a specified unit. * * @param unit Supported units are kg/msec, Pas, cP (centipoise) * @return viscosity in specified unit @@ -1199,7 +1223,8 @@ public default void addMolesChemReac(int component, double dn) { public double getCv(String unit); /** - * method to return real gas isentropic exponent (kappa = - Cp/Cv*(v/p)*dp/dv method to return + * method to return real gas isentropic exponent (kappa = - Cp/Cv*(v/p)*dp/dv + * method to return * heat capacity ratio/adiabatic index/Poisson constant. * * @return kappa @@ -1283,7 +1308,8 @@ public default void addMolesChemReac(int component, double dn) { * getComponents. *

* - * @return an array of {@link neqsim.thermo.component.ComponentInterface} objects + * @return an array of {@link neqsim.thermo.component.ComponentInterface} + * objects */ ComponentInterface[] getComponents(); @@ -1852,7 +1878,7 @@ public default void addMolesChemReac(int component, double dn) { * Indexed setter for property refPhase. *

* - * @param index a int + * @param index a int * @param refPhase a {@link neqsim.thermo.phase.PhaseInterface} object */ public void setRefPhase(int index, neqsim.thermo.phase.PhaseInterface refPhase); @@ -1862,7 +1888,8 @@ public default void addMolesChemReac(int component, double dn) { * Setter for property refPhase. *

* - * @param refPhase an array of {@link neqsim.thermo.phase.PhaseInterface} objects + * @param refPhase an array of {@link neqsim.thermo.phase.PhaseInterface} + * objects */ public void setRefPhase(neqsim.thermo.phase.PhaseInterface[] refPhase); @@ -1889,11 +1916,11 @@ public default void addMolesChemReac(int component, double dn) { * setParams. *

* - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param alpha an array of {@link double} objects - * @param Dij an array of {@link double} objects - * @param DijT an array of {@link double} objects - * @param mixRule an array of {@link String} objects + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param alpha an array of {@link double} objects + * @param Dij an array of {@link double} objects + * @param DijT an array of {@link double} objects + * @param mixRule an array of {@link String} objects * @param intparam an array of {@link double} objects */ public void setParams(PhaseInterface phase, double[][] alpha, double[][] Dij, double[][] DijT, From e15d4078b6fd350f2cd244f0526355caa4ed09c8 Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Wed, 16 Aug 2023 21:21:31 +0000 Subject: [PATCH 4/4] fixed bug --- .../valve/ValveMechanicalDesign.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/valve/ValveMechanicalDesign.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/valve/ValveMechanicalDesign.java index 248bdb2b2..4a53efcec 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/valve/ValveMechanicalDesign.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/valve/ValveMechanicalDesign.java @@ -33,8 +33,9 @@ public class ValveMechanicalDesign extends MechanicalDesign { * Constructor for ValveMechanicalDesign. *

* - * @param equipment a {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} - * object + * @param equipment a + * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} + * object */ public ValveMechanicalDesign(ProcessEquipmentInterface equipment) { super(equipment); @@ -49,8 +50,7 @@ public void readDesignSpecifications() { if (getDesignStandard().containsKey("valve design codes")) { System.out.println("valve code standard: " + getDesignStandard().get("valve design codes").getStandardName()); - valveCvMax = - ((ValveDesignStandard) getDesignStandard().get("valve design codes")).getValveCvMax(); + valveCvMax = ((ValveDesignStandard) getDesignStandard().get("valve design codes")).getValveCvMax(); } else { System.out.println("no valve code standard specified......using default"); } @@ -65,7 +65,7 @@ public void calcDesign() { outletPressure = valve1.getOutletPressure(); dP = inletPressure - outletPressure; - valveCvMax = valve1.getThermoSystem().getVolume("m3/hr") + valveCvMax = valve1.getThermoSystem().getFlowRate("m3/hr") * Math.sqrt(valve1.getThermoSystem().getDensity("kg/m3") / 1000.0 / dP); valveWeight = valveCvMax * 100.0; setWeightTotal(valveWeight); @@ -78,7 +78,7 @@ public void displayResults() { Container dialogContentPane = dialog.getContentPane(); dialogContentPane.setLayout(new BorderLayout()); - String[] names = {"Name", "Value", "Unit"}; + String[] names = { "Name", "Value", "Unit" }; String[][] table = new String[16][3]; // createTable(getProcessEquipment().getName());