diff --git a/src/main/java/neqsim/dataPresentation/fileHandeling/createNetCDF/netCDF2D/NetCdf2D.java b/src/main/java/neqsim/dataPresentation/fileHandeling/createNetCDF/netCDF2D/NetCdf2D.java index 2c6ef30ee6..5e211c2c16 100644 --- a/src/main/java/neqsim/dataPresentation/fileHandeling/createNetCDF/netCDF2D/NetCdf2D.java +++ b/src/main/java/neqsim/dataPresentation/fileHandeling/createNetCDF/netCDF2D/NetCdf2D.java @@ -83,8 +83,7 @@ public void setYvalues(double[] y, String name, String unit) { @SuppressWarnings("deprecation") public void createFile() { try { - NetcdfFileWriter ncfile = - NetcdfFileWriter.createNew(NetcdfFileWriter.Version.netcdf3, fileName, null); + ncfile = NetcdfFileWriter.createNew(NetcdfFileWriter.Version.netcdf3, fileName, null); } catch (IOException e) { System.err.println("ERROR creating file"); } diff --git a/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/DataReader.java b/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/DataReader.java index 9719bcc342..772c5244e4 100644 --- a/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/DataReader.java +++ b/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/DataReader.java @@ -18,78 +18,77 @@ * @version $Id: $Id */ public class DataReader implements DataReaderInterface { - protected String fileName; - protected ArrayList sampleObjectList = new ArrayList(); + protected String fileName; + protected ArrayList sampleObjectList = new ArrayList(); - /** - *

- * Constructor for DataReader. - *

- */ - public DataReader() {} + /** + *

+ * Constructor for DataReader. + *

+ */ + public DataReader() {} - /** - *

- * Constructor for DataReader. - *

- * - * @param fileName a {@link java.lang.String} object - */ - public DataReader(String fileName) { - this.fileName = fileName; - readData(); - } + /** + *

+ * Constructor for DataReader. + *

+ * + * @param fileName a {@link java.lang.String} object + */ + public DataReader(String fileName) { + this.fileName = fileName; + readData(); + } - /** {@inheritDoc} */ - @Override - public void readData() { - StringTokenizer tokenizer; - String token; + /** {@inheritDoc} */ + @Override + public void readData() { + StringTokenizer tokenizer; - String path = "c:/logdata/" + this.fileName + ".log"; - System.out.println(path); + String path = "c:/logdata/" + this.fileName + ".log"; + System.out.println(path); - try (RandomAccessFile file = new RandomAccessFile(path, "r")) { - long filepointer = 0; - long length = file.length(); - for (int i = 0; i < 6; i++) { - file.readLine(); - } - do { - System.out.println("test"); - String s = file.readLine(); - tokenizer = new StringTokenizer(s); - token = tokenizer.nextToken(); + try (RandomAccessFile file = new RandomAccessFile(path, "r")) { + long filepointer = 0; + long length = file.length(); + for (int i = 0; i < 6; i++) { + file.readLine(); + } + do { + System.out.println("test"); + String s = file.readLine(); + tokenizer = new StringTokenizer(s); + tokenizer.nextToken(); - filepointer = file.getFilePointer(); - tokenizer.nextToken(); - } while (filepointer < length); - } catch (Exception e) { - String err = e.toString(); - System.out.println(err); - } + filepointer = file.getFilePointer(); + tokenizer.nextToken(); + } while (filepointer < length); + } catch (Exception e) { + String err = e.toString(); + System.out.println(err); } + } - /** - *

- * Getter for the field sampleObjectList. - *

- * - * @return a {@link java.util.ArrayList} of {@link DataObject} - */ - public ArrayList getSampleObjectList() { - return sampleObjectList; - } + /** + *

+ * Getter for the field sampleObjectList. + *

+ * + * @return a {@link java.util.ArrayList} of {@link DataObject} + */ + public ArrayList getSampleObjectList() { + return sampleObjectList; + } - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String[] args) { - DataReader reader = new DataReader("31011222"); - } + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String[] args) { + DataReader reader = new DataReader("31011222"); + } } diff --git a/src/main/java/neqsim/thermo/system/SystemThermo.java b/src/main/java/neqsim/thermo/system/SystemThermo.java index 46e4164e83..75f6e5e61b 100644 --- a/src/main/java/neqsim/thermo/system/SystemThermo.java +++ b/src/main/java/neqsim/thermo/system/SystemThermo.java @@ -750,12 +750,17 @@ public void addSalt(String componentName, double value) { @Override public void addTBPfraction(String componentName, double numberOfMoles, double molarMass, double density) { - if (density < 0.0 || molarMass < 0.0) { - String msg = "Negative input molar mass or density."; + if (density < 0.0) { + String msg = "Negative input density."; logger.error(msg); - neqsim.util.exception.InvalidInputException e = - new neqsim.util.exception.InvalidInputException(msg); - throw new RuntimeException(e); + throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, + "addTBPfraction", "density", "is negative.")); + } + if (molarMass < 0.0) { + String msg = "Negative input molar mass."; + logger.error(msg); + throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, + "addTBPfraction", "molarMass", "is negative.")); } SystemInterface refSystem = null; @@ -886,11 +891,17 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo public void addTBPfraction(String componentName, double numberOfMoles, double molarMass, double density, double criticalTemperature, double criticalPressure, double acentricFactor) { if (density < 0.0 || molarMass < 0.0) { - String msg = "Negative input molar mass or density."; + String msg = "Negative input density."; logger.error(msg); - neqsim.util.exception.InvalidInputException e = - new neqsim.util.exception.InvalidInputException(msg); - throw new RuntimeException(e); + throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, + "addTBPfraction", "density", "is negative.")); + } + + if (density < 0.0 || molarMass < 0.0) { + String msg = "Negative input molar mass."; + logger.error(msg); + throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, + "addTBPfraction", "molarMass", "is negative.")); } SystemInterface refSystem = null; @@ -1099,9 +1110,8 @@ public void addComponent(String componentName, double moles) { if (moles < 0.0) { String msg = "Negative input number of moles of component: " + componentName; logger.error(msg); - neqsim.util.exception.InvalidInputException e = - new neqsim.util.exception.InvalidInputException(msg); - throw new RuntimeException(e); + throw new RuntimeException( + new neqsim.util.exception.InvalidInputException(this, "addComponent", "moles", msg)); } setTotalNumberOfMoles(getTotalNumberOfMoles() + moles); // System.out.println("adding " + componentName); @@ -1211,7 +1221,7 @@ public void addComponent(String componentName, double moles, int phaseNumber) { String msg = "Negative input number of moles."; logger.error(msg); neqsim.util.exception.InvalidInputException e = - new neqsim.util.exception.InvalidInputException(msg); + new neqsim.util.exception.InvalidInputException(this, "addComponent", "moles", msg); throw new RuntimeException(e); } @@ -1737,8 +1747,7 @@ public void initAnalytic(int type) { } } numberOfPhases = 2; - } - else if (type == 1) { + } else if (type == 1) { for (int i = 0; i < numberOfPhases; i++) { if (IsPhase(i)) { getPhase(i).init(getTotalNumberOfMoles(), numberOfComponents, 1, phaseType[phaseIndex[i]], @@ -3813,18 +3822,19 @@ public java.lang.String getFluidName() { public void setFluidName(java.lang.String fluidName) { this.fluidName = fluidName; } - + public void addToComponentNames(java.lang.String name) { - for(int j=0;j * setLastTBPasPlus. @@ -5083,11 +5093,10 @@ public SystemProperties getProperties() { private void setMolarComposition(double[] molefractions, String type) { double totalFlow = getTotalNumberOfMoles(); if (totalFlow < 1e-100) { - String msg = "Total flow can not be 0 when setting molar composition"; + String msg = "must be larger than 0 (1e-100) when setting molar composition"; logger.error(msg); - neqsim.util.exception.InvalidInputException e = - new neqsim.util.exception.InvalidInputException(msg); - throw new RuntimeException(e); + throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, + "setMolarComposition", "totalFlow", msg)); } double sum = 0; for (double value : molefractions) { diff --git a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/hydrate/HydrateFunction.java b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/hydrate/HydrateFunction.java index d86773a33d..1864377896 100644 --- a/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/hydrate/HydrateFunction.java +++ b/src/main/java/neqsim/thermo/util/parameterFitting/pureComponentParameterFitting/hydrate/HydrateFunction.java @@ -14,72 +14,71 @@ * @version $Id: $Id */ public class HydrateFunction extends LevenbergMarquardtFunction { - static Logger logger = LogManager.getLogger(HydrateFunction.class); + static Logger logger = LogManager.getLogger(HydrateFunction.class); - /** - *

- * Constructor for HydrateFunction. - *

- */ - public HydrateFunction() { - // params = new double[3]; - } + /** + *

+ * Constructor for HydrateFunction. + *

+ */ + public HydrateFunction() { + // params = new double[3]; + } - /** {@inheritDoc} */ - @Override - public double calcValue(double[] dependentValues) { - try { - thermoOps.hydrateFormationTemperature(1); - // System.out.println("temperature " + system.getTemperature()); - } catch (Exception e) { - logger.error(e.toString()); - } - return system.getTemperature(); + /** {@inheritDoc} */ + @Override + public double calcValue(double[] dependentValues) { + try { + thermoOps.hydrateFormationTemperature(1); + // System.out.println("temperature " + system.getTemperature()); + } catch (Exception e) { + logger.error(e.toString()); } + return system.getTemperature(); + } - /** {@inheritDoc} */ - @Override - public double calcTrueValue(double val) { - return val; - } + /** {@inheritDoc} */ + @Override + public double calcTrueValue(double val) { + return val; + } - /** {@inheritDoc} */ - @Override - public void setFittingParams(int i, double value) { - int structure = 1; - params[i] = value; - // if(i==0) ((ComponentHydrate) - // system.getPhase(4).getComponent("water")).setDGfHydrate(value, structure); - // if(i==1) ((ComponentHydrate) - // system.getPhase(4).getComponent("water")).setDHfHydrate(value, structure); - // int k=0; + /** {@inheritDoc} */ + @Override + public void setFittingParams(int i, double value) { + // int structure = 1; + params[i] = value; + // if(i==0) ((ComponentHydrate) + // system.getPhase(4).getComponent("water")).setDGfHydrate(value, structure); + // if(i==1) ((ComponentHydrate) + // system.getPhase(4).getComponent("water")).setDHfHydrate(value, structure); + // int k=0; - // if(i==0) ((ComponentHydrate) - // system.getPhase(4).getComponent("water")).setEmptyHydrateVapourPressureConstant(0,0, - // value); - // if(i==1) ((ComponentHydrate) - // system.getPhase(4).getComponent("water")).setEmptyHydrateVapourPressureConstant(0,1, - // value); + // if(i==0) ((ComponentHydrate) + // system.getPhase(4).getComponent("water")).setEmptyHydrateVapourPressureConstant(0,0, + // value); + // if(i==1) ((ComponentHydrate) + // system.getPhase(4).getComponent("water")).setEmptyHydrateVapourPressureConstant(0,1, + // value); - // for(int k=0;k 0); /* * System.out.println("polytopic head " + polytropicHead); * System.out.println("polytopic efficiency " + comp1.getPolytropicEfficiency()); diff --git a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemControllerTest.java b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemControllerTest.java index eb1cbbfe72..8583b69a12 100644 --- a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemControllerTest.java +++ b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemControllerTest.java @@ -5,99 +5,101 @@ import org.junit.jupiter.api.Test; import neqsim.processSimulation.controllerDevice.ControllerDeviceBaseClass; import neqsim.processSimulation.controllerDevice.ControllerDeviceInterface; -import neqsim.processSimulation.measurementDevice.LevelTransmitter; -import neqsim.processSimulation.measurementDevice.PressureTransmitter; import neqsim.processSimulation.measurementDevice.VolumeFlowTransmitter; import neqsim.processSimulation.processEquipment.separator.Separator; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; import neqsim.thermo.system.SystemInterface; -public class ProcessSystemControllerTest extends neqsim.NeqSimTest{ - ProcessSystem p; - - @BeforeEach - public void setUp() { - p = new ProcessSystem(); - } - - @Test - public void testGetName() { - String name = "TestProsess"; - p.setName(name); - Assertions.assertEquals(name, p.getName()); - } - - @Test - void testGetTime() { - - } - - @Test - void testGetTimeStep() { - - } - - private SystemInterface getTestSystem() { - neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); - testSystem.addComponent("methane", 0.900); - testSystem.addComponent("ethane", 0.100); - testSystem.addComponent("n-heptane", 0.1); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - return testSystem; - } - - private double getRandomDistrurbanceFlowRate() { - double max = 5; - double min = -5; - double random_double = (int)Math.floor(Math.random()*(max-min+1)+min); - return random_double; - } - - @Test - public void testStaticSimulationWithController() { - neqsim.thermo.system.SystemInterface testSystem = getTestSystem(); - - Stream stream_1 = new Stream("Stream1", testSystem); - stream_1.setFlowRate(100.0+getRandomDistrurbanceFlowRate(), "kg/hr"); - stream_1.setPressure(10.0, "bara"); - - ThrottlingValve valve_1 = new ThrottlingValve("valve_1", stream_1); - valve_1.setOutletPressure(5.0); - - Separator separator_1 = new Separator("sep 1"); - separator_1.addStream(valve_1.getOutStream()); - - VolumeFlowTransmitter flowTransmitter = new VolumeFlowTransmitter(separator_1.getGasOutStream()); - flowTransmitter.setUnit("kg/hr"); - flowTransmitter.setMaximumValue(110.0); - flowTransmitter.setMinimumValue(90.0); - - ControllerDeviceInterface flowController = new ControllerDeviceBaseClass(); - flowController.setTransmitter(flowTransmitter); - flowController.setReverseActing(true); - flowController.setControllerSetPoint(65.0+getRandomDistrurbanceFlowRate()); - flowController.setControllerParameters(0.01, 0.10, 0.100); - - p.add(stream_1); - p.add(valve_1); - p.add(separator_1); - p.add(flowTransmitter); - stream_1.setController(flowController); - - p.run(); - - // transient behaviour - p.setTimeStep(1.0); - for (int i = 0; i < 25; i++) { - flowController.setControllerSetPoint(65.0+getRandomDistrurbanceFlowRate()); - p.runTransient(); - System.out.println("flow rate " + valve_1.getOutStream().getFluid().getPhase("gas").getFlowRate("kg/hr") +" controller response " + flowController.getResponse() - + " valve opening " + valve_1.getPercentValveOpening() + " pressure " - + separator_1.getGasOutStream().getPressure()); - //p.runTransient(); - } +public class ProcessSystemControllerTest extends neqsim.NeqSimTest { + ProcessSystem p; + + @BeforeEach + public void setUp() { + p = new ProcessSystem(); + } + + @Test + public void testGetName() { + String name = "TestProsess"; + p.setName(name); + Assertions.assertEquals(name, p.getName()); + } + + @Test + void testGetTime() { + + } + + @Test + void testGetTimeStep() { + + } + + private SystemInterface getTestSystem() { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); + testSystem.addComponent("methane", 0.900); + testSystem.addComponent("ethane", 0.100); + testSystem.addComponent("n-heptane", 0.1); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + return testSystem; + } + + private double getRandomDistrurbanceFlowRate() { + double max = 5; + double min = -5; + double random_double = (int) Math.floor(Math.random() * (max - min + 1) + min); + return random_double; + } + + @Test + public void testStaticSimulationWithController() { + neqsim.thermo.system.SystemInterface testSystem = getTestSystem(); + + Stream stream_1 = new Stream("Stream1", testSystem); + stream_1.setFlowRate(100.0 + getRandomDistrurbanceFlowRate(), "kg/hr"); + stream_1.setPressure(10.0, "bara"); + + ThrottlingValve valve_1 = new ThrottlingValve("valve_1", stream_1); + valve_1.setOutletPressure(5.0); + + Separator separator_1 = new Separator("sep 1"); + separator_1.addStream(valve_1.getOutStream()); + + VolumeFlowTransmitter flowTransmitter = + new VolumeFlowTransmitter(separator_1.getGasOutStream()); + flowTransmitter.setUnit("kg/hr"); + flowTransmitter.setMaximumValue(110.0); + flowTransmitter.setMinimumValue(90.0); + + ControllerDeviceInterface flowController = new ControllerDeviceBaseClass(); + flowController.setTransmitter(flowTransmitter); + flowController.setReverseActing(true); + flowController.setControllerSetPoint(65.0 + getRandomDistrurbanceFlowRate()); + flowController.setControllerParameters(0.01, 0.10, 0.100); + + p.add(stream_1); + p.add(valve_1); + p.add(separator_1); + p.add(flowTransmitter); + stream_1.setController(flowController); + + p.run(); + + // transient behaviour + p.setTimeStep(1.0); + for (int i = 0; i < 25; i++) { + flowController.setControllerSetPoint(65.0 + getRandomDistrurbanceFlowRate()); + p.runTransient(); + System.out.println( + "flow rate " + valve_1.getOutStream().getFluid().getPhase("gas").getFlowRate("kg/hr") + + " controller response " + flowController.getResponse() + " valve opening " + + valve_1.getPercentValveOpening() + " pressure " + + separator_1.getGasOutStream().getPressure()); + // p.runTransient(); } + } } diff --git a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemTest.java b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemTest.java index 22c37a6d10..6be42de0a3 100644 --- a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemTest.java +++ b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemTest.java @@ -22,535 +22,533 @@ import neqsim.processSimulation.processEquipment.util.StreamSaturatorUtil; import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; -public class ProcessSystemTest extends neqsim.NeqSimTest{ - ProcessSystem p; - String _name = "TestProcess"; - - - @BeforeEach - public void setUp() { - p = new ProcessSystem(); - p.setName(_name); - } - - @Test - void testGetName() { - Assertions.assertEquals(_name, p.getName()); - } - - @Test - public void testSetTimeStep() { - double timeStep = p.getTimeStep() * 2; - Assertions.assertEquals(timeStep / 2, p.getTimeStep()); - Assertions.assertNotEquals(timeStep, p.getTimeStep()); - - p.setTimeStep(timeStep); - Assertions.assertEquals(timeStep, p.getTimeStep()); - Assertions.assertNotEquals(timeStep / 2, p.getTimeStep()); - } - - @Test - public void testHasUnitName() { - String sepName = "TestSep"; - Assertions.assertFalse(p.hasUnitName(sepName)); - p.add(new Separator(sepName)); - Assertions.assertTrue(p.hasUnitName(sepName)); - } - - @Test - void testAdd() { - String sepName = "TestSep"; - Separator sep = new Separator("sep"); - sep.setName(sepName); - p.add(sep); - - ArrayList list = p.getUnitOperations(); - - Assertions.assertTrue(sep == p.getUnit(sepName)); - - Assertions.assertEquals(1, list.size()); - Assertions.assertEquals(1, p.size()); - - Assertions.assertTrue((Separator) list.get(0) == sep); - - p.removeUnit(sepName); - Assertions.assertNull(p.getUnit(sepName)); - Assertions.assertEquals(0, p.size()); - - list = p.getUnitOperations(); - - Assertions.assertEquals(0, list.size()); - - p.add(sep); - Assertions.assertEquals(1, p.size()); - - p.clear(); - Assertions.assertEquals(0, p.size()); - - p.add(sep); - Assertions.assertEquals(1, p.size()); - - p.clearAll(); - Assertions.assertEquals(0, p.size()); - } - - @Test - public void testAddUnitTwice() { - Separator sep = new Separator("sep"); - p.add(sep); - p.add(sep); // Won't add the copy - Assertions.assertEquals(1, p.size()); - } +public class ProcessSystemTest extends neqsim.NeqSimTest { + ProcessSystem p; + String _name = "TestProcess"; - @Test - public void testRemoveUnit() { - Separator sep = new Separator("Separator"); - p.add(sep); - Assertions.assertEquals(1, p.size()); - p.removeUnit("Separator"); - Assertions.assertEquals(0, p.size()); - } + @BeforeEach + public void setUp() { + p = new ProcessSystem(); + p.setName(_name); + } - @Test - public void testAddUnitsWithNoName() { - Separator sep = new Separator(); - p.add(sep); - sep = new Separator(); - p.add(sep); - Assertions.assertEquals(2, p.size()); - p.removeUnit("Separator2"); - Assertions.assertEquals(1, p.size()); - p.removeUnit("Separator"); - Assertions.assertEquals(0, p.size()); - } + @Test + void testGetName() { + Assertions.assertEquals(_name, p.getName()); + } - @Test - public void testGetUnitNumber() { - Separator sep = new Separator("Separator"); - p.add(sep); - Separator sep2 = new Separator("Separator2"); - p.add(sep2); + @Test + public void testSetTimeStep() { + double timeStep = p.getTimeStep() * 2; + Assertions.assertEquals(timeStep / 2, p.getTimeStep()); + Assertions.assertNotEquals(timeStep, p.getTimeStep()); - Assertions.assertEquals(0, p.getUnitNumber("Separator")); - Assertions.assertEquals(1, p.getUnitNumber("Separator2")); + p.setTimeStep(timeStep); + Assertions.assertEquals(timeStep, p.getTimeStep()); + Assertions.assertNotEquals(timeStep / 2, p.getTimeStep()); + } - p.removeUnit("Separator"); - p.add(sep); + @Test + public void testHasUnitName() { + String sepName = "TestSep"; + Assertions.assertFalse(p.hasUnitName(sepName)); + p.add(new Separator(sepName)); + Assertions.assertTrue(p.hasUnitName(sepName)); + } - Assertions.assertEquals(0, p.getUnitNumber("Separator2")); - Assertions.assertEquals(1, p.getUnitNumber("Separator")); - } + @Test + void testAdd() { + String sepName = "TestSep"; + Separator sep = new Separator("sep"); + sep.setName(sepName); + p.add(sep); - @Test - public void testSetSurroundingTemperature() { - double temp = 200; - p.setSurroundingTemperature(temp); - Assertions.assertEquals(temp, p.getSurroundingTemperature()); - } + ArrayList list = p.getUnitOperations(); - @Test - void testClear() { - p.clear(); - } + Assertions.assertTrue(sep == p.getUnit(sepName)); - @Test - void testClearAll() { - p.clearAll(); - } + Assertions.assertEquals(1, list.size()); + Assertions.assertEquals(1, p.size()); - @Test - void testCopy() { - ProcessSystem sys2 = p.copy(); - Assertions.assertTrue(p.equals(sys2)); - Assertions.assertEquals(p, sys2); - } + Assertions.assertTrue((Separator) list.get(0) == sep); - @Test - void testDisplayResult() {} + p.removeUnit(sepName); + Assertions.assertNull(p.getUnit(sepName)); + Assertions.assertEquals(0, p.size()); - @Test - void testGetAllUnitNames() { + list = p.getUnitOperations(); - } + Assertions.assertEquals(0, list.size()); - @Test - void testGetConditionMonitor() { + p.add(sep); + Assertions.assertEquals(1, p.size()); - } + p.clear(); + Assertions.assertEquals(0, p.size()); - @Test - void testGetCoolerDuty() { + p.add(sep); + Assertions.assertEquals(1, p.size()); - } + p.clearAll(); + Assertions.assertEquals(0, p.size()); + } - @Test - void testGetCostEstimator() { + @Test + public void testAddUnitTwice() { + Separator sep = new Separator("sep"); + p.add(sep); + p.add(sep); // Won't add the copy + Assertions.assertEquals(1, p.size()); + } - } + @Test + public void testRemoveUnit() { + Separator sep = new Separator("Separator"); + p.add(sep); + Assertions.assertEquals(1, p.size()); + p.removeUnit("Separator"); + Assertions.assertEquals(0, p.size()); + } - @Test - void testGetEntropyProduction() { - } + @Test + @SuppressWarnings("deprecation") + public void testAddUnitsWithNoName() { + Separator sep = new Separator(); + p.add(sep); + sep = new Separator(); + p.add(sep); + Assertions.assertEquals(2, p.size()); + p.removeUnit("Separator2"); + Assertions.assertEquals(1, p.size()); + p.removeUnit("Separator"); + Assertions.assertEquals(0, p.size()); + } - @Test - void testGetExergyChange() { + @Test + public void testGetUnitNumber() { + Separator sep = new Separator("Separator"); + p.add(sep); + Separator sep2 = new Separator("Separator2"); + p.add(sep2); - } + Assertions.assertEquals(0, p.getUnitNumber("Separator")); + Assertions.assertEquals(1, p.getUnitNumber("Separator2")); - @Test - void testGetHeaterDuty() { + p.removeUnit("Separator"); + p.add(sep); - } + Assertions.assertEquals(0, p.getUnitNumber("Separator2")); + Assertions.assertEquals(1, p.getUnitNumber("Separator")); + } - @Test - void testGetMeasurementDevice() { + @Test + public void testSetSurroundingTemperature() { + double temp = 200; + p.setSurroundingTemperature(temp); + Assertions.assertEquals(temp, p.getSurroundingTemperature()); + } - } + @Test + void testClear() { + p.clear(); + } - @Test - void testGetMechanicalWeight() { + @Test + void testClearAll() { + p.clearAll(); + } - } + @Test + void testCopy() { + ProcessSystem sys2 = p.copy(); + Assertions.assertTrue(p.equals(sys2)); + Assertions.assertEquals(p, sys2); + } + @Test + void testDisplayResult() {} + @Test + void testGetAllUnitNames() { - @Test - void testGetPower() { + } - } + @Test + void testGetConditionMonitor() { - @Test - void testGetSurroundingTemperature() { + } - } + @Test + void testGetCoolerDuty() { - @Test - void testGetSystemMechanicalDesign() { + } - } + @Test + void testGetCostEstimator() { - @Test - void testGetUnit() { + } - } + @Test + void testGetEntropyProduction() { + } - @Test - void testGetUnitOperations() { + @Test + void testGetExergyChange() { - } + } + @Test + void testGetHeaterDuty() { - @Test - void testOpen() { + } - } + @Test + void testGetMeasurementDevice() { - @Test - void testPrintLogFile() { + } - } + @Test + void testGetMechanicalWeight() { + } - @Test - void testReplaceObject() { - } - @Test - void testReportMeasuredValues() { + @Test + void testGetPower() { - } + } - @Test - void testReportResults() { + @Test + void testGetSurroundingTemperature() { - } + } - @Test - void testRun() { + @Test + void testGetSystemMechanicalDesign() { - } + } - @Test - void testRunAsThread() { + @Test + void testGetUnit() { - } + } + + + @Test + void testGetUnitOperations() { + + } + + + @Test + void testOpen() { + + } + + @Test + void testPrintLogFile() { + + } - @Test - void testSave() { - } + @Test + void testReplaceObject() { - @Test - void testSetFluid() { + } + + @Test + void testReportMeasuredValues() { + + } + + @Test + void testReportResults() { - } + } - @Test - void testSetName() {} + @Test + void testRun() { - @Test - void testSetSystemMechanicalDesign() { + } - } + @Test + void testRunAsThread() { - @Test - void testSize() { + } - } + @Test + void testSave() { - @Test - void testView() {} - - @Test - public void runTEGProcessTest() { - neqsim.thermo.system.SystemInterface feedGas = - new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 42.0, 10.00); - feedGas.addComponent("nitrogen", 1.42); - feedGas.addComponent("CO2", 0.5339); - feedGas.addComponent("methane", 95.2412); - feedGas.addComponent("ethane", 2.2029); - feedGas.addComponent("propane", 0.3231); - feedGas.addComponent("i-butane", 0.1341); - feedGas.addComponent("n-butane", 0.0827); - feedGas.addComponent("i-pentane", 0.0679); - feedGas.addComponent("n-pentane", 0.035); - feedGas.addComponent("n-hexane", 0.0176); - feedGas.addComponent("benzene", 0.0017); - feedGas.addComponent("toluene", 0.0043); - feedGas.addComponent("m-Xylene", 0.0031); - feedGas.addComponent("water", 0.0); - feedGas.addComponent("TEG", 0); - feedGas.setMixingRule(10); - feedGas.setMultiPhaseCheck(true); + } - Stream dryFeedGas = new Stream("dry feed gas", feedGas); - dryFeedGas.setFlowRate(25.32, "MSm3/day"); - dryFeedGas.setTemperature(25.0, "C"); - dryFeedGas.setPressure(87.12, "bara"); + @Test + void testSetFluid() { - StreamSaturatorUtil saturatedFeedGas = - new StreamSaturatorUtil("water saturator", dryFeedGas); + } - Stream waterSaturatedFeedGas = - new Stream("water saturated feed gas", saturatedFeedGas.getOutStream()); + @Test + void testSetName() {} - HydrateEquilibriumTemperatureAnalyser hydrateTAnalyser = - new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGas); - hydrateTAnalyser.setName("hydrate temperature analyser"); + @Test + void testSetSystemMechanicalDesign() { - neqsim.thermo.system.SystemInterface feedTEG = feedGas.clone(); - feedTEG.setMolarComposition(new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.03, 0.97}); + } - Heater feedTPsetterToAbsorber = new Heater("TP of gas to absorber", waterSaturatedFeedGas); - feedTPsetterToAbsorber.setOutPressure(87.12, "bara"); - feedTPsetterToAbsorber.setOutTemperature(27.93, "C"); + @Test + void testSize() { - Stream feedToAbsorber = - new Stream("feed to TEG absorber", feedTPsetterToAbsorber.getOutStream()); + } - Stream TEGFeed = new Stream("lean TEG to absorber", feedTEG); - TEGFeed.setFlowRate(14.68 * 1100.0, "kg/hr"); - TEGFeed.setTemperature(43.4, "C"); - TEGFeed.setPressure(87.12, "bara"); - - SimpleTEGAbsorber absorber = new SimpleTEGAbsorber("TEG absorber"); - absorber.addGasInStream(feedToAbsorber); - absorber.addSolventInStream(TEGFeed); - absorber.setNumberOfStages(5); - absorber.setStageEfficiency(0.5); - - Stream dehydratedGas = new Stream("dry gas from absorber", absorber.getGasOutStream()); - - Stream richTEG = new Stream("rich TEG from absorber", absorber.getSolventOutStream()); - /* - * WaterDewPointAnalyser waterDewPointAnalyser = new WaterDewPointAnalyser(dehydratedGas); - * waterDewPointAnalyser.setName("water dew point analyser"); - */ - HydrateEquilibriumTemperatureAnalyser waterDewPointAnalyser = - new HydrateEquilibriumTemperatureAnalyser(dehydratedGas); - waterDewPointAnalyser.setReferencePressure(70.0); - waterDewPointAnalyser.setName("water dew point analyser"); - - ThrottlingValve glycol_flash_valve = - new ThrottlingValve("Rich TEG HP flash valve", richTEG); - glycol_flash_valve.setOutletPressure(5.5); - - Heater richGLycolHeaterCondenser = - new Heater("rich TEG preheater", glycol_flash_valve.getOutStream()); - - HeatExchanger heatEx2 = new HeatExchanger("rich TEG heat exchanger 1", - richGLycolHeaterCondenser.getOutStream()); - heatEx2.setGuessOutTemperature(273.15 + 62.0); - heatEx2.setUAvalue(200.0); - - Separator flashSep = new Separator("degasing separator", heatEx2.getOutStream(0)); - - Stream flashGas = new Stream("gas from degasing separator", flashSep.getGasOutStream()); - - Stream flashLiquid = - new Stream("liquid from degasing separator", flashSep.getLiquidOutStream()); - - Filter fineFilter = new Filter("TEG fine filter", flashLiquid); - fineFilter.setDeltaP(0.05, "bara"); - - Filter carbonFilter = new Filter("activated carbon filter", fineFilter.getOutStream()); - carbonFilter.setDeltaP(0.01, "bara"); - - HeatExchanger heatEx = - new HeatExchanger("rich TEG heat exchanger 2", carbonFilter.getOutStream()); - heatEx.setGuessOutTemperature(273.15 + 130.0); - heatEx.setUAvalue(390.0); - - ThrottlingValve glycol_flash_valve2 = - new ThrottlingValve("LP flash valve", heatEx.getOutStream(0)); - glycol_flash_valve2.setName("Rich TEG LP flash valve"); - glycol_flash_valve2.setOutletPressure(1.23); - - neqsim.thermo.system.SystemInterface stripGas = feedGas.clone(); - // stripGas.setMolarComposition(new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, - // 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }); - - Stream strippingGas = new Stream("stripGas", stripGas); - strippingGas.setFlowRate(255.0, "Sm3/hr"); - strippingGas.setTemperature(80.0, "C"); - strippingGas.setPressure(1.02, "bara"); - - Stream gasToReboiler = strippingGas.clone(); - gasToReboiler.setName("gas to reboiler"); - - DistillationColumn column = new DistillationColumn(1, true, true); - column.setName("TEG regeneration column"); - column.addFeedStream(glycol_flash_valve2.getOutStream(), 0); - column.getReboiler().setOutTemperature(273.15 + 201.0); - column.getCondenser().setOutTemperature(273.15 + 92.0); - column.getReboiler().addStream(gasToReboiler); - column.setTopPressure(1.01325); - column.setBottomPressure(1.02); - - Heater coolerRegenGas = new Heater("regen gas cooler", column.getGasOutStream()); - coolerRegenGas.setOutTemperature(273.15 + 7.5); - - Separator sepregenGas = new Separator("regen gas separator", coolerRegenGas.getOutStream()); - - Stream gasToFlare = new Stream("gas to flare", sepregenGas.getGasOutStream()); - - Stream liquidToTrreatment = - new Stream("water to treatment", sepregenGas.getLiquidOutStream()); - - WaterStripperColumn stripper = new WaterStripperColumn("TEG stripper"); - stripper.addSolventInStream(column.getLiquidOutStream()); - stripper.addGasInStream(strippingGas); - stripper.setNumberOfStages(4); - stripper.setStageEfficiency(0.5); - /* - * DistillationColumn stripper = new DistillationColumn(3, false, false); - * stripper.setName("TEG stripper"); stripper.addFeedStream(column.getLiquidOutStream(), 2); - * stripper.getTray(0).addStream(strippingGas); - */ - Recycle recycleGasFromStripper = new Recycle("stripping gas recirc"); - recycleGasFromStripper.addStream(stripper.getGasOutStream()); - recycleGasFromStripper.setOutletStream(gasToReboiler); - - Heater bufferTank = new Heater("TEG buffer tank", stripper.getLiquidOutStream()); - bufferTank.setOutTemperature(273.15 + 191.0); - - Pump hotLeanTEGPump = new Pump("hot lean TEG pump", bufferTank.getOutStream());// stripper.getSolventOutStream()); - hotLeanTEGPump.setOutletPressure(5.0); - hotLeanTEGPump.setIsentropicEfficiency(0.6); - - heatEx.setFeedStream(1, hotLeanTEGPump.getOutStream()); - - heatEx2.setFeedStream(1, heatEx.getOutStream(1)); - - Heater coolerhOTteg3 = new Heater("lean TEG cooler", heatEx2.getOutStream(1)); - coolerhOTteg3.setOutTemperature(273.15 + 35.41); - - Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump", coolerhOTteg3.getOutStream()); - hotLeanTEGPump2.setOutletPressure(87.2); - hotLeanTEGPump2.setIsentropicEfficiency(0.75); - - SetPoint pumpHPPresSet = - new SetPoint("HP pump set", hotLeanTEGPump2, "pressure", feedToAbsorber); - - Stream leanTEGtoabs = new Stream("lean TEG to absorber", hotLeanTEGPump2.getOutStream()); - - neqsim.thermo.system.SystemInterface pureTEG = feedGas.clone(); - pureTEG.setMolarComposition(new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 1.0}); - - Stream makeupTEG = new Stream("makeup TEG", pureTEG); - makeupTEG.setFlowRate(1e-6, "kg/hr"); - makeupTEG.setTemperature(43.0, "C"); - makeupTEG.setPressure(52.21, "bara"); - - Calculator makeupCalculator = new Calculator("TEG makeup calculator"); - makeupCalculator.addInputVariable(dehydratedGas); - makeupCalculator.addInputVariable(flashGas); - makeupCalculator.addInputVariable(gasToFlare); - makeupCalculator.addInputVariable(liquidToTrreatment); - makeupCalculator.setOutputVariable(makeupTEG); - - StaticMixer makeupMixer = new StaticMixer("makeup mixer"); - makeupMixer.addStream(leanTEGtoabs); - makeupMixer.addStream(makeupTEG); - - Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); - resycleLeanTEG.addStream(makeupMixer.getOutStream()); - resycleLeanTEG.setOutletStream(TEGFeed); - resycleLeanTEG.setPriority(200); - resycleLeanTEG.setDownstreamProperty("flow rate"); - - richGLycolHeaterCondenser.setEnergyStream(column.getCondenser().getEnergyStream()); - // richGLycolHeater.isSetEnergyStream(); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(dryFeedGas); - operations.add(saturatedFeedGas); - operations.add(waterSaturatedFeedGas); - operations.add(hydrateTAnalyser); - operations.add(feedTPsetterToAbsorber); - operations.add(feedToAbsorber); - operations.add(TEGFeed); - operations.add(absorber); - operations.add(dehydratedGas); - operations.add(waterDewPointAnalyser); - operations.add(richTEG); - operations.add(glycol_flash_valve); - operations.add(richGLycolHeaterCondenser); - operations.add(heatEx2); - operations.add(flashSep); - operations.add(flashGas); - - operations.add(flashLiquid); - operations.add(fineFilter); - operations.add(carbonFilter); - operations.add(heatEx); - operations.add(glycol_flash_valve2); - operations.add(gasToReboiler); - operations.add(column); - operations.add(coolerRegenGas); - operations.add(sepregenGas); - operations.add(gasToFlare); - operations.add(liquidToTrreatment); - operations.add(strippingGas); - operations.add(stripper); - operations.add(recycleGasFromStripper); - operations.add(bufferTank); - operations.add(hotLeanTEGPump); - operations.add(coolerhOTteg3); - operations.add(pumpHPPresSet); - operations.add(hotLeanTEGPump2); - operations.add(leanTEGtoabs); - operations.add(makeupCalculator); - operations.add(makeupTEG); - operations.add(makeupMixer); - operations.add(resycleLeanTEG); - //operations.run(); + @Test + void testView() {} + + @Test + public void runTEGProcessTest() { + neqsim.thermo.system.SystemInterface feedGas = + new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 42.0, 10.00); + feedGas.addComponent("nitrogen", 1.42); + feedGas.addComponent("CO2", 0.5339); + feedGas.addComponent("methane", 95.2412); + feedGas.addComponent("ethane", 2.2029); + feedGas.addComponent("propane", 0.3231); + feedGas.addComponent("i-butane", 0.1341); + feedGas.addComponent("n-butane", 0.0827); + feedGas.addComponent("i-pentane", 0.0679); + feedGas.addComponent("n-pentane", 0.035); + feedGas.addComponent("n-hexane", 0.0176); + feedGas.addComponent("benzene", 0.0017); + feedGas.addComponent("toluene", 0.0043); + feedGas.addComponent("m-Xylene", 0.0031); + feedGas.addComponent("water", 0.0); + feedGas.addComponent("TEG", 0); + feedGas.setMixingRule(10); + feedGas.setMultiPhaseCheck(true); + + Stream dryFeedGas = new Stream("dry feed gas", feedGas); + dryFeedGas.setFlowRate(25.32, "MSm3/day"); + dryFeedGas.setTemperature(25.0, "C"); + dryFeedGas.setPressure(87.12, "bara"); + + StreamSaturatorUtil saturatedFeedGas = new StreamSaturatorUtil("water saturator", dryFeedGas); + + Stream waterSaturatedFeedGas = + new Stream("water saturated feed gas", saturatedFeedGas.getOutStream()); + + HydrateEquilibriumTemperatureAnalyser hydrateTAnalyser = + new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGas); + hydrateTAnalyser.setName("hydrate temperature analyser"); + + neqsim.thermo.system.SystemInterface feedTEG = feedGas.clone(); + feedTEG.setMolarComposition( + new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03, 0.97}); + + Heater feedTPsetterToAbsorber = new Heater("TP of gas to absorber", waterSaturatedFeedGas); + feedTPsetterToAbsorber.setOutPressure(87.12, "bara"); + feedTPsetterToAbsorber.setOutTemperature(27.93, "C"); + + Stream feedToAbsorber = + new Stream("feed to TEG absorber", feedTPsetterToAbsorber.getOutStream()); + + Stream TEGFeed = new Stream("lean TEG to absorber", feedTEG); + TEGFeed.setFlowRate(14.68 * 1100.0, "kg/hr"); + TEGFeed.setTemperature(43.4, "C"); + TEGFeed.setPressure(87.12, "bara"); + + SimpleTEGAbsorber absorber = new SimpleTEGAbsorber("TEG absorber"); + absorber.addGasInStream(feedToAbsorber); + absorber.addSolventInStream(TEGFeed); + absorber.setNumberOfStages(5); + absorber.setStageEfficiency(0.5); + + Stream dehydratedGas = new Stream("dry gas from absorber", absorber.getGasOutStream()); + + Stream richTEG = new Stream("rich TEG from absorber", absorber.getSolventOutStream()); + /* + * WaterDewPointAnalyser waterDewPointAnalyser = new WaterDewPointAnalyser(dehydratedGas); + * waterDewPointAnalyser.setName("water dew point analyser"); + */ + HydrateEquilibriumTemperatureAnalyser waterDewPointAnalyser = + new HydrateEquilibriumTemperatureAnalyser(dehydratedGas); + waterDewPointAnalyser.setReferencePressure(70.0); + waterDewPointAnalyser.setName("water dew point analyser"); + + ThrottlingValve glycol_flash_valve = new ThrottlingValve("Rich TEG HP flash valve", richTEG); + glycol_flash_valve.setOutletPressure(5.5); + + Heater richGLycolHeaterCondenser = + new Heater("rich TEG preheater", glycol_flash_valve.getOutStream()); + + HeatExchanger heatEx2 = + new HeatExchanger("rich TEG heat exchanger 1", richGLycolHeaterCondenser.getOutStream()); + heatEx2.setGuessOutTemperature(273.15 + 62.0); + heatEx2.setUAvalue(200.0); + + Separator flashSep = new Separator("degasing separator", heatEx2.getOutStream(0)); + + Stream flashGas = new Stream("gas from degasing separator", flashSep.getGasOutStream()); + + Stream flashLiquid = + new Stream("liquid from degasing separator", flashSep.getLiquidOutStream()); + + Filter fineFilter = new Filter("TEG fine filter", flashLiquid); + fineFilter.setDeltaP(0.05, "bara"); + + Filter carbonFilter = new Filter("activated carbon filter", fineFilter.getOutStream()); + carbonFilter.setDeltaP(0.01, "bara"); + + HeatExchanger heatEx = + new HeatExchanger("rich TEG heat exchanger 2", carbonFilter.getOutStream()); + heatEx.setGuessOutTemperature(273.15 + 130.0); + heatEx.setUAvalue(390.0); + + ThrottlingValve glycol_flash_valve2 = + new ThrottlingValve("LP flash valve", heatEx.getOutStream(0)); + glycol_flash_valve2.setName("Rich TEG LP flash valve"); + glycol_flash_valve2.setOutletPressure(1.23); + + neqsim.thermo.system.SystemInterface stripGas = feedGas.clone(); + // stripGas.setMolarComposition(new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, + // 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }); + + Stream strippingGas = new Stream("stripGas", stripGas); + strippingGas.setFlowRate(255.0, "Sm3/hr"); + strippingGas.setTemperature(80.0, "C"); + strippingGas.setPressure(1.02, "bara"); + + Stream gasToReboiler = strippingGas.clone(); + gasToReboiler.setName("gas to reboiler"); + + DistillationColumn column = new DistillationColumn(1, true, true); + column.setName("TEG regeneration column"); + column.addFeedStream(glycol_flash_valve2.getOutStream(), 0); + column.getReboiler().setOutTemperature(273.15 + 201.0); + column.getCondenser().setOutTemperature(273.15 + 92.0); + column.getReboiler().addStream(gasToReboiler); + column.setTopPressure(1.01325); + column.setBottomPressure(1.02); + + Heater coolerRegenGas = new Heater("regen gas cooler", column.getGasOutStream()); + coolerRegenGas.setOutTemperature(273.15 + 7.5); + + Separator sepregenGas = new Separator("regen gas separator", coolerRegenGas.getOutStream()); + + Stream gasToFlare = new Stream("gas to flare", sepregenGas.getGasOutStream()); + + Stream liquidToTrreatment = new Stream("water to treatment", sepregenGas.getLiquidOutStream()); + + WaterStripperColumn stripper = new WaterStripperColumn("TEG stripper"); + stripper.addSolventInStream(column.getLiquidOutStream()); + stripper.addGasInStream(strippingGas); + stripper.setNumberOfStages(4); + stripper.setStageEfficiency(0.5); + /* + * DistillationColumn stripper = new DistillationColumn(3, false, false); + * stripper.setName("TEG stripper"); stripper.addFeedStream(column.getLiquidOutStream(), 2); + * stripper.getTray(0).addStream(strippingGas); + */ + Recycle recycleGasFromStripper = new Recycle("stripping gas recirc"); + recycleGasFromStripper.addStream(stripper.getGasOutStream()); + recycleGasFromStripper.setOutletStream(gasToReboiler); + + Heater bufferTank = new Heater("TEG buffer tank", stripper.getLiquidOutStream()); + bufferTank.setOutTemperature(273.15 + 191.0); + + Pump hotLeanTEGPump = new Pump("hot lean TEG pump", bufferTank.getOutStream());// stripper.getSolventOutStream()); + hotLeanTEGPump.setOutletPressure(5.0); + hotLeanTEGPump.setIsentropicEfficiency(0.6); + + heatEx.setFeedStream(1, hotLeanTEGPump.getOutStream()); + + heatEx2.setFeedStream(1, heatEx.getOutStream(1)); + + Heater coolerhOTteg3 = new Heater("lean TEG cooler", heatEx2.getOutStream(1)); + coolerhOTteg3.setOutTemperature(273.15 + 35.41); + + Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump", coolerhOTteg3.getOutStream()); + hotLeanTEGPump2.setOutletPressure(87.2); + hotLeanTEGPump2.setIsentropicEfficiency(0.75); + + SetPoint pumpHPPresSet = + new SetPoint("HP pump set", hotLeanTEGPump2, "pressure", feedToAbsorber); + + Stream leanTEGtoabs = new Stream("lean TEG to absorber", hotLeanTEGPump2.getOutStream()); + + neqsim.thermo.system.SystemInterface pureTEG = feedGas.clone(); + pureTEG.setMolarComposition( + new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}); + + Stream makeupTEG = new Stream("makeup TEG", pureTEG); + makeupTEG.setFlowRate(1e-6, "kg/hr"); + makeupTEG.setTemperature(43.0, "C"); + makeupTEG.setPressure(52.21, "bara"); + + Calculator makeupCalculator = new Calculator("TEG makeup calculator"); + makeupCalculator.addInputVariable(dehydratedGas); + makeupCalculator.addInputVariable(flashGas); + makeupCalculator.addInputVariable(gasToFlare); + makeupCalculator.addInputVariable(liquidToTrreatment); + makeupCalculator.setOutputVariable(makeupTEG); + + StaticMixer makeupMixer = new StaticMixer("makeup mixer"); + makeupMixer.addStream(leanTEGtoabs); + makeupMixer.addStream(makeupTEG); + + Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); + resycleLeanTEG.addStream(makeupMixer.getOutStream()); + resycleLeanTEG.setOutletStream(TEGFeed); + resycleLeanTEG.setPriority(200); + resycleLeanTEG.setDownstreamProperty("flow rate"); + + richGLycolHeaterCondenser.setEnergyStream(column.getCondenser().getEnergyStream()); + // richGLycolHeater.isSetEnergyStream(); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(dryFeedGas); + operations.add(saturatedFeedGas); + operations.add(waterSaturatedFeedGas); + operations.add(hydrateTAnalyser); + operations.add(feedTPsetterToAbsorber); + operations.add(feedToAbsorber); + operations.add(TEGFeed); + operations.add(absorber); + operations.add(dehydratedGas); + operations.add(waterDewPointAnalyser); + operations.add(richTEG); + operations.add(glycol_flash_valve); + operations.add(richGLycolHeaterCondenser); + operations.add(heatEx2); + operations.add(flashSep); + operations.add(flashGas); + + operations.add(flashLiquid); + operations.add(fineFilter); + operations.add(carbonFilter); + operations.add(heatEx); + operations.add(glycol_flash_valve2); + operations.add(gasToReboiler); + operations.add(column); + operations.add(coolerRegenGas); + operations.add(sepregenGas); + operations.add(gasToFlare); + operations.add(liquidToTrreatment); + operations.add(strippingGas); + operations.add(stripper); + operations.add(recycleGasFromStripper); + operations.add(bufferTank); + operations.add(hotLeanTEGPump); + operations.add(coolerhOTteg3); + operations.add(pumpHPPresSet); + operations.add(hotLeanTEGPump2); + operations.add(leanTEGtoabs); + operations.add(makeupCalculator); + operations.add(makeupTEG); + operations.add(makeupMixer); + operations.add(resycleLeanTEG); + // operations.run(); } } diff --git a/src/test/java/neqsim/thermo/system/SystemThermoSetMolarCompositionTest.java b/src/test/java/neqsim/thermo/system/SystemThermoSetMolarCompositionTest.java index 76eec2fa4a..3530ce5a2f 100644 --- a/src/test/java/neqsim/thermo/system/SystemThermoSetMolarCompositionTest.java +++ b/src/test/java/neqsim/thermo/system/SystemThermoSetMolarCompositionTest.java @@ -57,7 +57,7 @@ void testNoFlow() { sys.setMolarComposition(new double[] { 1, 1.5, 1.75 }); }); Assertions.assertEquals( - "neqsim.util.exception.InvalidInputException: Total flow can not be 0 when setting molar composition", + "neqsim.util.exception.InvalidInputException: SystemSrkEos:setMolarComposition - Input totalFlow must be larger than 0 (1e-100) when setting molar composition", thrown.getMessage()); } @@ -69,8 +69,8 @@ void testNoFlowPlus() { sys.setMolarCompositionPlus(new double[] { 1, 1.5, 1.75 }); }); Assertions.assertEquals( - "neqsim.util.exception.InvalidInputException: Total flow can not be 0 when setting molar composition", - thrown.getMessage()); + "neqsim.util.exception.InvalidInputException: SystemSrkEos:setMolarComposition - Input totalFlow must be larger than 0 (1e-100) when setting molar composition", + thrown.getMessage()); } @Test @@ -81,7 +81,7 @@ void testNoFlowPlusFluid() { sys.setMolarCompositionOfPlusFluid(new double[] { 1, 1.5, 1.75 }); }); Assertions.assertEquals( - "neqsim.util.exception.InvalidInputException: Total flow can not be 0 when setting molar composition", - thrown.getMessage()); + "neqsim.util.exception.InvalidInputException: SystemSrkEos:setMolarComposition - Input totalFlow must be larger than 0 (1e-100) when setting molar composition", + thrown.getMessage()); } } diff --git a/src/test/java/neqsim/thermo/util/example/TestNeqSimBug.java b/src/test/java/neqsim/thermo/util/example/TestNeqSimBug.java index be3f0805c5..e63abe50bd 100644 --- a/src/test/java/neqsim/thermo/util/example/TestNeqSimBug.java +++ b/src/test/java/neqsim/thermo/util/example/TestNeqSimBug.java @@ -1,7 +1,6 @@ package neqsim.thermo.util.example; import java.util.Arrays; -import neqsim.api.ioc.CalculationResult; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -57,11 +56,7 @@ public static void main(String[] args) { double spec1 = 73.22862045673597; // grane Pressure double spec2 = -62179.7247076579; // Enthalpy - CalculationResult s = - fluidOps.propertyFlash(Arrays.asList(spec1), Arrays.asList(spec2), 3, null, null); - - // Double[][] prop = s.fluidProperties; - + fluidOps.propertyFlash(Arrays.asList(spec1), Arrays.asList(spec2), 3, null, null); /* * for (int t = 0; t < 1; t++) { fluid.setPressure(spec1[t]); fluidOps.PHflash(spec2[t],