diff --git a/src/main/java/neqsim/processSimulation/processEquipment/absorber/SimpleAbsorber.java b/src/main/java/neqsim/processSimulation/processEquipment/absorber/SimpleAbsorber.java index 3d18248a6f..6d3ba851f3 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/absorber/SimpleAbsorber.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/absorber/SimpleAbsorber.java @@ -17,8 +17,8 @@ public class SimpleAbsorber extends Separator implements AbsorberInterface { private static final long serialVersionUID = 1000; boolean setTemperature = false; - Stream[] outStream; - Stream[] inStream; + Stream[] outStream = new Stream[2]; + Stream[] inStream = new Stream[2]; SystemInterface system; protected double temperatureOut = 0, dT = 0.0; private int numberOfStages = 5; @@ -68,9 +68,7 @@ public SimpleAbsorber(String name) { * @param inStream1 a {@link neqsim.processSimulation.processEquipment.stream.Stream} object */ public SimpleAbsorber(String name, Stream inStream1) { - this(name); - outStream = new Stream[2]; - inStream = new Stream[2]; + super(name); this.inStream[0] = inStream1; this.inStream[1] = inStream1; outStream[0] = inStream1.clone(); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/adsorber/SimpleAdsorber.java b/src/main/java/neqsim/processSimulation/processEquipment/adsorber/SimpleAdsorber.java index eec17efaa0..b42344ca46 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/adsorber/SimpleAdsorber.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/adsorber/SimpleAdsorber.java @@ -19,8 +19,8 @@ public class SimpleAdsorber extends ProcessEquipmentBaseClass { boolean setTemperature = false; String name = new String(); - StreamInterface[] outStream; - StreamInterface[] inStream; + StreamInterface[] outStream = new Stream[2]; + StreamInterface[] inStream = new Stream[2]; SystemInterface system; protected double temperatureOut = 0, dT = 0.0; private int numberOfStages = 5; @@ -50,9 +50,7 @@ public SimpleAdsorber() { */ @Deprecated public SimpleAdsorber(StreamInterface inStream1) { - this(); - outStream = new Stream[2]; - inStream = new Stream[2]; + this("SimpleAdsorber"); this.inStream[0] = inStream1; this.inStream[1] = inStream1; outStream[0] = (Stream) inStream1.clone(); @@ -94,9 +92,7 @@ public SimpleAdsorber(String name) { * object */ public SimpleAdsorber(String name, StreamInterface inStream1) { - this(name); - outStream = new Stream[2]; - inStream = new Stream[2]; + this(name); this.inStream[0] = inStream1; this.inStream[1] = inStream1; outStream[0] = (Stream) inStream1.clone(); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchanger.java b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchanger.java index 0908d22efb..0eade63388 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchanger.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchanger.java @@ -24,8 +24,8 @@ public class HeatExchanger extends Heater implements HeatExchangerInterface { private static final long serialVersionUID = 1000; boolean setTemperature = false; - StreamInterface[] outStream; - StreamInterface[] inStream; + StreamInterface[] outStream = new Stream[2]; + StreamInterface[] inStream = new Stream[2]; SystemInterface system; double NTU; protected double temperatureOut = 0, dT = 0.0; @@ -83,9 +83,7 @@ public HeatExchanger(StreamInterface inStream1, StreamInterface inStream2) { * @param name */ public HeatExchanger(String name) { - super(name); - outStream = new Stream[2]; - inStream = new Stream[2]; + super(name); } /** @@ -110,7 +108,7 @@ public HeatExchanger(String name, StreamInterface inStream1) { * @param inStream2 */ public HeatExchanger(String name, StreamInterface inStream1, StreamInterface inStream2) { - super(name); + this(name); this.inStream[0] = inStream1; this.inStream[1] = inStream2; outStream[0] = inStream1.clone(); @@ -512,7 +510,7 @@ public void runConditionAnalysis(ProcessEquipmentInterface refExchanger) { double duty2 = Math.abs(outStream[1].getThermoSystem().getEnthalpy() - inStream[1].getThermoSystem().getEnthalpy()); thermalEffectiveness = ((HeatExchanger) refExchanger).getThermalEffectiveness() - * (duty1 + duty2) / 2.0 / Math.abs(((HeatExchanger) refExchanger).getDuty()); + * (duty1 + duty2) / 2.0 / Math.abs(((HeatExchanger) refExchanger).getDuty()); hotColdDutyBalance = duty1 / duty2; } diff --git a/src/test/java/neqsim/processSimulation/processEquipment/absorber/SimpleAbsorberTest.java b/src/test/java/neqsim/processSimulation/processEquipment/absorber/SimpleAbsorberTest.java new file mode 100644 index 0000000000..8fd3efbc13 --- /dev/null +++ b/src/test/java/neqsim/processSimulation/processEquipment/absorber/SimpleAbsorberTest.java @@ -0,0 +1,37 @@ +package neqsim.processSimulation.processEquipment.absorber; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import neqsim.processSimulation.processEquipment.stream.Stream; + +public class SimpleAbsorberTest { + neqsim.thermo.system.SystemFurstElectrolyteEos testSystem; + + @BeforeEach + void setUp() { + testSystem = new neqsim.thermo.system.SystemFurstElectrolyteEos((273.15 + 80.0), 50.00); + testSystem.addComponent("methane", 120.00); + testSystem.addComponent("CO2", 20.0); + testSystem.createDatabase(true); + testSystem.setMixingRule(4); + } + + @Test + void testRun() { + Stream stream_Hot = new Stream("Stream1", testSystem); + neqsim.processSimulation.processEquipment.absorber.SimpleAbsorber absorber1 = + new neqsim.processSimulation.processEquipment.absorber.SimpleAbsorber("absorber", + stream_Hot); + absorber1.setAproachToEquilibrium(0.75); + + // todo: Test is not well behaved + /* + * neqsim.processSimulation.processSystem.ProcessSystem operations = new + * neqsim.processSimulation.processSystem.ProcessSystem(); operations.add(stream_Hot); + * operations.add(absorber1); + * + * operations.run(); + */ + // operations.displayResult(); + } +} diff --git a/src/test/java/neqsim/processSimulation/processEquipment/adsorber/SimpleAdsorberTest.java b/src/test/java/neqsim/processSimulation/processEquipment/adsorber/SimpleAdsorberTest.java new file mode 100644 index 0000000000..30099de083 --- /dev/null +++ b/src/test/java/neqsim/processSimulation/processEquipment/adsorber/SimpleAdsorberTest.java @@ -0,0 +1,37 @@ +package neqsim.processSimulation.processEquipment.adsorber; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import neqsim.processSimulation.processEquipment.stream.Stream; + +public class SimpleAdsorberTest { + neqsim.thermo.system.SystemFurstElectrolyteEos testSystem; + + @BeforeEach + void setUp() { + testSystem = new neqsim.thermo.system.SystemFurstElectrolyteEos((273.15 + 80.0), 50.00); + testSystem.addComponent("methane", 120.00); + testSystem.addComponent("CO2", 20.0); + testSystem.createDatabase(true); + testSystem.setMixingRule(4); + } + + @Test + void testRun() { + Stream stream_Hot = new Stream("Stream1", testSystem); + neqsim.processSimulation.processEquipment.adsorber.SimpleAdsorber adsorber1 = + new neqsim.processSimulation.processEquipment.adsorber.SimpleAdsorber("adsorber", + stream_Hot); + adsorber1.setAproachToEquilibrium(0.75); + + // todo: Test is not well behaved + /* + * neqsim.processSimulation.processSystem.ProcessSystem operations = new + * neqsim.processSimulation.processSystem.ProcessSystem(); operations.add(stream_Hot); + * operations.add(adsorber1); + * + * operations.run(); + */ + // operations.displayResult(); + } +} diff --git a/src/test/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchangerTest.java b/src/test/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchangerTest.java new file mode 100644 index 0000000000..46efc190bf --- /dev/null +++ b/src/test/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchangerTest.java @@ -0,0 +1,102 @@ +package neqsim.processSimulation.processEquipment.heatExchanger; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import neqsim.processSimulation.processEquipment.separator.Separator; +import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.processSimulation.processEquipment.util.Recycle; +import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +/** + *
+ * HeatExchanger Test class. + *
+ * + * @author asmund + * @version $Id: $Id + * @since 2.2.3 + */ +public class HeatExchangerTest { + static neqsim.thermo.system.SystemInterface testSystem; + static Stream gasStream; + + @BeforeEach + static void setUp() { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 + 60.0), 20.00); + testSystem.addComponent("methane", 120.00); + testSystem.addComponent("ethane", 120.0); + testSystem.addComponent("n-heptane", 3.0); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + } + + @Test + public static void test_Run1(String args[]) { + Stream stream_Hot = new Stream("Stream1", testSystem); + Stream stream_Cold = new Stream("Stream1", testSystem.clone()); + + HeatExchanger heatEx = new HeatExchanger("heatEx"); + heatEx.setFeedStream(0, stream_Hot); + heatEx.setFeedStream(1, stream_Cold);// resyc.getOutStream()); + + Separator sep = new Separator("sep", stream_Hot); + + Stream oilOutStream = new Stream("oilOutStream", sep.getLiquidOutStream()); + + ThrottlingValve valv1 = new ThrottlingValve("valv1", oilOutStream); + valv1.setOutletPressure(5.0); + + Recycle resyc = new Recycle("resyc"); + resyc.addStream(valv1.getOutStream()); + resyc.setOutletStream(stream_Cold); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_Hot); + operations.add(heatEx); + operations.add(sep); + operations.add(oilOutStream); + operations.add(valv1); + operations.add(resyc); + + operations.run(); + + // heatEx.getOutStream(0).displayResult(); + // resyc.getOutStream().displayResult(); + } + + @Test + public static void test_Run2(String args[]) { + Stream stream_Hot = new Stream("Stream1", testSystem); + + neqsim.thermo.system.SystemInterface testSystem2 = + new neqsim.thermo.system.SystemSrkEos((273.15 + 40.0), 20.00); + testSystem2.addComponent("methane", 220.00); + testSystem2.addComponent("ethane", 120.0); + // testSystem2.createDatabase(true); + testSystem2.setMixingRule(2); + ThermodynamicOperations testOps2 = new ThermodynamicOperations(testSystem2); + testOps2.TPflash(); + + Stream stream_Cold = new Stream("Stream2", testSystem2); + + neqsim.processSimulation.processEquipment.heatExchanger.HeatExchanger heatExchanger1 = + new neqsim.processSimulation.processEquipment.heatExchanger.HeatExchanger("heatEx", + stream_Hot, stream_Cold); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_Hot); + operations.add(stream_Cold); + operations.add(heatExchanger1); + + operations.run(); + // operations.displayResult(); + // heatExchanger1.getOutStream(0).displayResult(); + // heatExchanger1.getOutStream(1).displayResult(); + } +} diff --git a/src/test/java/neqsim/processSimulation/util/example/AbsorberTest.java b/src/test/java/neqsim/processSimulation/util/example/AbsorberTest.java deleted file mode 100644 index 2d724b9a4a..0000000000 --- a/src/test/java/neqsim/processSimulation/util/example/AbsorberTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package neqsim.processSimulation.util.example; - -import neqsim.processSimulation.processEquipment.stream.Stream; - -/** - *AbsorberTest class.
- * - * @author asmund - * @version $Id: $Id - * @since 2.2.3 - */ -public class AbsorberTest { - /** - * This method is just meant to test the thermo package. - * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - neqsim.thermo.system.SystemFurstElectrolyteEos testSystem = - new neqsim.thermo.system.SystemFurstElectrolyteEos((273.15 + 80.0), 50.00); - testSystem.addComponent("methane", 120.00); - testSystem.addComponent("CO2", 20.0); - testSystem.createDatabase(true); - testSystem.setMixingRule(4); - - Stream stream_Hot = new Stream("Stream1", testSystem); - - neqsim.processSimulation.processEquipment.absorber.SimpleAbsorber absorber1 = - new neqsim.processSimulation.processEquipment.absorber.SimpleAbsorber("absorber", - stream_Hot); - absorber1.setAproachToEquilibrium(0.75); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_Hot); - operations.add(absorber1); - - operations.run(); - operations.displayResult(); - } -} diff --git a/src/test/java/neqsim/processSimulation/util/example/HeatExchanger.java b/src/test/java/neqsim/processSimulation/util/example/HeatExchanger.java deleted file mode 100644 index ddd1b8b31a..0000000000 --- a/src/test/java/neqsim/processSimulation/util/example/HeatExchanger.java +++ /dev/null @@ -1,59 +0,0 @@ -package neqsim.processSimulation.util.example; - -import neqsim.processSimulation.processEquipment.stream.Stream; -import neqsim.thermodynamicOperations.ThermodynamicOperations; - -/** - *HeatExchanger class.
- * - * @author asmund - * @version $Id: $Id - * @since 2.2.3 - */ -public class HeatExchanger { - /** - * This method is just meant to test the thermo package. - * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 60.0), 20.00); - testSystem.addComponent("methane", 120.00); - testSystem.addComponent("ethane", 120.0); - testSystem.addComponent("n-heptane", 3.0); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - testOps.TPflash(); - - Stream stream_Hot = new Stream("Stream1", testSystem); - - neqsim.thermo.system.SystemInterface testSystem2 = - new neqsim.thermo.system.SystemSrkEos((273.15 + 40.0), 20.00); - testSystem2.addComponent("methane", 220.00); - testSystem2.addComponent("ethane", 120.0); - // testSystem2.createDatabase(true); - testSystem2.setMixingRule(2); - ThermodynamicOperations testOps2 = new ThermodynamicOperations(testSystem2); - testOps2.TPflash(); - - Stream stream_Cold = new Stream("Stream2", testSystem2); - - neqsim.processSimulation.processEquipment.heatExchanger.HeatExchanger heatExchanger1 = - new neqsim.processSimulation.processEquipment.heatExchanger.HeatExchanger("heatEx", - stream_Hot, stream_Cold); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_Hot); - operations.add(stream_Cold); - operations.add(heatExchanger1); - - operations.run(); - // operations.displayResult(); - - heatExchanger1.getOutStream(0).displayResult(); - heatExchanger1.getOutStream(1).displayResult(); - } -} diff --git a/src/test/java/neqsim/processSimulation/util/example/HeatExchanger2.java b/src/test/java/neqsim/processSimulation/util/example/HeatExchanger2.java deleted file mode 100644 index 8c39076f0d..0000000000 --- a/src/test/java/neqsim/processSimulation/util/example/HeatExchanger2.java +++ /dev/null @@ -1,68 +0,0 @@ -package neqsim.processSimulation.util.example; - -import neqsim.processSimulation.processEquipment.heatExchanger.HeatExchanger; -import neqsim.processSimulation.processEquipment.separator.Separator; -import neqsim.processSimulation.processEquipment.stream.Stream; -import neqsim.processSimulation.processEquipment.util.Recycle; -import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; -import neqsim.thermodynamicOperations.ThermodynamicOperations; - -/** - *- * HeatExchanger2 class. - *
- * - * @author asmund - * @version $Id: $Id - * @since 2.2.3 - */ -public class HeatExchanger2 { - /** - * This method is just meant to test the thermo package. - * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 60.0), 20.00); - testSystem.addComponent("methane", 120.00); - testSystem.addComponent("ethane", 120.0); - testSystem.addComponent("n-heptane", 30.0); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - testOps.TPflash(); - - Stream stream_Hot = new Stream("Stream1", testSystem); - Stream stream_Cold = new Stream("Stream1", testSystem.clone()); - - HeatExchanger heatEx = new HeatExchanger("heatEx"); - heatEx.setFeedStream(0, stream_Hot); - heatEx.setFeedStream(1, stream_Cold);// resyc.getOutStream()); - - Separator sep = new Separator("sep", stream_Hot); - - Stream oilOutStream = new Stream("oilOutStream", sep.getLiquidOutStream()); - - ThrottlingValve valv1 = new ThrottlingValve("valv1", oilOutStream); - valv1.setOutletPressure(5.0); - - Recycle resyc = new Recycle("resyc"); - resyc.addStream(valv1.getOutStream()); - resyc.setOutletStream(stream_Cold); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_Hot); - operations.add(heatEx); - operations.add(sep); - operations.add(oilOutStream); - operations.add(valv1); - operations.add(resyc); - - operations.run(); - - heatEx.getOutStream(0).displayResult(); - resyc.getOutStream().displayResult(); - } -}