Skip to content

Commit

Permalink
bugfix: assure correct initialization of in and outstream (#364)
Browse files Browse the repository at this point in the history
chore: added test files for SimpleAbsorber, SimpleAdsorber and HeatExchanger
  • Loading branch information
asmfstatoil authored Mar 15, 2022
1 parent f5de02b commit 63d5aaa
Show file tree
Hide file tree
Showing 9 changed files with 188 additions and 188 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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();
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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;

/**
* <p>
* HeatExchanger Test class.
* </p>
*
* @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();
}
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit 63d5aaa

Please sign in to comment.