Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests and replaced calls to deprecated functions #302

Merged
merged 3 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,97 +107,4 @@ public void solveTransient(int solverType) {
display.setNextData(this, this.getTimeSeries().getTime(i));
}
}

/**
* <p>
* main.
* </p>
*
* @param args an array of {@link java.lang.String} objects
*/
public static void main(String[] args) {
System.out.println("Starting.....");

SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos(285.15, 200.0);
testSystem.addComponent("methane", 0.9);
testSystem.addComponent("ethane", 0.1);
testSystem.createDatabase(true);
testSystem.init(0);
testSystem.init(3);
testSystem.initPhysicalProperties();
testSystem.setTotalFlowRate(60.0, "MSm3/day");
neqsim.fluidMechanics.flowSystem.FlowSystemInterface pipe = new PipeFlowSystem();

double[] height = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
double[] diameter = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
double[] roughness = {1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5,
1.0e-5, 1.0e-5, 1.0e-5};
double[] outHeatCoef = {5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0};
double[] wallHeacCoef = {15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0};

double[] length =
{0, 10000, 50000, 150000, 200000, 400000, 500000, 600000, 650000, 700000, 750000};
double[] outerTemperature =
{278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0};

neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface[] pipeGeometry =
new neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData[10];

for (int i = 0; i < pipeGeometry.length; i++) {
pipeGeometry[i] = new neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData();
pipeGeometry[i].setDiameter(diameter[i]);
pipeGeometry[i].setInnerSurfaceRoughness(roughness[i]);
}
pipe.setInletThermoSystem(testSystem);
pipe.setNumberOfLegs(10);
pipe.setNumberOfNodesInLeg(20);
pipe.setEquipmentGeometry(pipeGeometry);
pipe.setLegHeights(height);
pipe.setLegPositions(length);
pipe.setLegOuterTemperatures(outerTemperature);
pipe.setLegWallHeatTransferCoefficients(wallHeacCoef);
pipe.setLegOuterHeatTransferCoefficients(outHeatCoef);

pipe.createSystem();
pipe.init();
pipe.solveSteadyState(10);
pipe.print();

// transient solver
double[] times = {0, 10000, 20000};// , 30000, 40000, 50000};//, 60000, 70000, 80000,
// 90000};
pipe.getTimeSeries().setTimes(times);

SystemInterface testSystem2 = new neqsim.thermo.system.SystemSrkEos(285.15, 200.0);
testSystem2.addComponent("methane", 29000.0);
testSystem2.addComponent("ethane", 1221.10);

testSystem2 = new neqsim.thermo.system.SystemSrkEos(315.15, 200.0);
testSystem2.addComponent("methane", 26000.0);
testSystem2.addComponent("ethane", 1.10);
testSystem2.init(0);
testSystem2.init(3);
testSystem2.initPhysicalProperties();

SystemInterface testSystem3 = new neqsim.thermo.system.SystemSrkEos(285.15, 200.0);
testSystem.addComponent("methane", 29000.0);
testSystem.addComponent("ethane", 1221.10);
testSystem3.init(0);

SystemInterface[] systems = {testSystem, testSystem2, testSystem2};// , testSystem2,
// testSystem2,
// testSystem2};//,testSystem2,testSystem2,testSystem2,testSystem2,testSystem2};
pipe.getTimeSeries().setInletThermoSystems(systems);
pipe.getTimeSeries().setNumberOfTimeStepsInInterval(10);
// double[] outletFlowRates = {0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01,
// 0.01, 0.01, 0.01};
// pipe.getTimeSeries().setOutletMolarFlowRate(outletFlowRates);

// pipe.solveTransient(20);
// pipe.getDisplay().displayResult("composition");
// pipe.getDisplay().displayResult("pressure");
// pipe.getDisplay().displayResult("composition");
// pipe.getDisplay().createNetCdfFile("c:/temp5.nc");
// pipe.getDisplay(1).displayResult();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public GTSurfaceTensionFullGT(SystemInterface flashedSystem, int phase1, int pha
this.sys.setNumberOfPhases(1);
this.sys.getPhase(0).setTotalVolume(1.0);
this.sys.useVolumeCorrection(false);
this.sys.removeMoles();
this.sys.setEmptyFluid();
double nv[] = new double[this.ncomp];
for (i = 0; i < ncomp; i++) {
nv[i] = this.rho_ph1[i] * Pa;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public Well getGasProducer(int i) {
public Well getOilProducer(int i) {
return oilProducer.get(i);
}

/**
* <p>
* Getter for the field <code>waterInjector</code>.
Expand All @@ -246,7 +246,7 @@ public Well getOilProducer(int i) {
public Well getWaterInjector(int i) {
return waterInjector.get(i);
}

/**
* <p>
* Getter for the field <code>gasInjector</code>.
Expand Down Expand Up @@ -298,7 +298,7 @@ public void setReservoirFluid(SystemInterface thermoSystem, double gasVolume, do
// thermoSystem.display();
SystemInterface thermoSystem2 = thermoSystem.clone();

thermoSystem.removeMoles();// (1.0e-10);
thermoSystem.setEmptyFluid();// (1.0e-10);
// thermoSystem.init(1);
// thermoSystem.display();
// System.out.println("number of phases " + thermoSystem.getNumberOfPhases());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void run() {
} else {
outThermoSystem = inletStream.getFluid().clone();
}
outThermoSystem.removeMoles();
outThermoSystem.setEmptyFluid();

// SystemInterface fluid1 = outletStream.getFluid();
// SystemInterface fluid2 = inletStream.getFluid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public void clear() {
* @param addNewComponents a boolean
*/
public void setFluid(SystemInterface fluid1, SystemInterface fluid2, boolean addNewComponents) {
fluid1.removeMoles();
fluid1.setEmptyFluid();
boolean addedComps = false;
for (int i = 0; i < fluid2.getNumberOfComponents(); i++) {
if (fluid1.getPhase(0).hasComponent(fluid2.getComponent(i).getName())) {
Expand Down Expand Up @@ -327,7 +327,7 @@ public void setFluid(SystemInterface fluid1, SystemInterface fluid2, boolean add
* @param fluid2 a {@link neqsim.thermo.system.SystemInterface} object
*/
public void setFluid(SystemInterface fluid1, SystemInterface fluid2) {
fluid1.removeMoles();
fluid1.setEmptyFluid();
boolean addedComps = false;
for (int i = 0; i < fluid2.getNumberOfComponents(); i++) {
if (fluid1.getPhase(0).hasComponent(fluid2.getComponent(i).getName())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void initializeStreams() {
this.leanTEGStreamToAbsorber = this.gasStreamToAbsorber.clone();
this.leanTEGStreamToAbsorber.setName("lean TEG to absorber");

this.leanTEGStreamToAbsorber.getThermoSystem().removeMoles();
this.leanTEGStreamToAbsorber.getThermoSystem().setEmptyFluid();
this.leanTEGStreamToAbsorber.getThermoSystem().addComponent("water",
leanGlycolMolarFlowRate * (1.0 - leanGlycolMolarFraction));
this.leanTEGStreamToAbsorber.getThermoSystem().addComponent("TEG",
Expand Down Expand Up @@ -394,7 +394,7 @@ public void calcDesign() {
* absorbtionColumn.getMechanicalDesign().setMaxOperationPressure(
* maxAbsorberDesignPressure); absorbtionColumn.getMechanicalDesign().calcDesign();
*/
this.leanTEGStreamToAbsorber.getThermoSystem().removeMoles();
this.leanTEGStreamToAbsorber.getThermoSystem().setEmptyFluid();
this.leanTEGStreamToAbsorber.getThermoSystem().addComponent("methane", 1e-15);
this.leanTEGStreamToAbsorber.getThermoSystem().addComponent("water",
leanGlycolMolarFlowRate * (1.0 - leanGlycolMolarFraction));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package neqsim.fluidMechanics.flowSystem.onePhaseFlowSystem.pipeFlowSystem;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import neqsim.fluidMechanics.flowSystem.FlowSystemInterface;
import neqsim.thermo.system.SystemInterface;

public class PipeFlowSystemTest {
FlowSystemInterface pipe;

@BeforeEach
void setUp() {
pipe = new PipeFlowSystem();

SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos(285.15, 200.0);
testSystem.addComponent("methane", 0.9);
testSystem.addComponent("ethane", 0.1);
testSystem.createDatabase(true);
testSystem.init(0);
testSystem.init(3);
testSystem.initPhysicalProperties();
testSystem.setTotalFlowRate(60.0, "MSm3/day");

double[] height = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
double[] diameter = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
double[] roughness = {1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5,
1.0e-5, 1.0e-5, 1.0e-5};
double[] outHeatCoef = {5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0};
double[] wallHeacCoef = {15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0};

double[] length =
{0, 10000, 50000, 150000, 200000, 400000, 500000, 600000, 650000, 700000, 750000};
double[] outerTemperature =
{278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0, 278.0};

neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface[] pipeGeometry =
new neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData[10];

for (int i = 0; i < pipeGeometry.length; i++) {
pipeGeometry[i] = new neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData();
pipeGeometry[i].setDiameter(diameter[i]);
pipeGeometry[i].setInnerSurfaceRoughness(roughness[i]);
}
pipe.setInletThermoSystem(testSystem);
pipe.setNumberOfLegs(10);
pipe.setNumberOfNodesInLeg(20);
pipe.setEquipmentGeometry(pipeGeometry);
pipe.setLegHeights(height);
pipe.setLegPositions(length);
pipe.setLegOuterTemperatures(outerTemperature);
pipe.setLegWallHeatTransferCoefficients(wallHeacCoef);
pipe.setLegOuterHeatTransferCoefficients(outHeatCoef);
}


@Test
void testCreateSystem() {

pipe.createSystem();
}

@Test
void testInit() {
testCreateSystem();
pipe.init();
}

@Test
void testSolveSteadyState() {
testInit();
pipe.solveSteadyState(10);
pipe.print();
}

@Test
void testSolveTransient() {
testInit();
// transient solver
double[] times = {0, 10000, 20000};// , 30000, 40000, 50000};//, 60000, 70000, 80000,
// 90000};
pipe.getTimeSeries().setTimes(times);

SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos(285.15, 200.0);
testSystem.addComponent("methane", 0.9);
testSystem.addComponent("ethane", 0.1);

SystemInterface testSystem2 = new neqsim.thermo.system.SystemSrkEos(315.15, 200.0);
testSystem2.addComponent("methane", 26000.0);
testSystem2.addComponent("ethane", 1.10);
testSystem2.init(0);
testSystem2.init(3);
testSystem2.initPhysicalProperties();

SystemInterface testSystem3 = new neqsim.thermo.system.SystemSrkEos(285.15, 200.0);
testSystem3.addComponent("methane", 29000.0);
testSystem3.addComponent("ethane", 1221.10);
testSystem3.init(0);

SystemInterface[] systems = {testSystem, testSystem2, testSystem2};// , testSystem2,
// testSystem2,
// testSystem2};//,testSystem2,testSystem2,testSystem2,testSystem2,testSystem2};
pipe.getTimeSeries().setInletThermoSystems(systems);
pipe.getTimeSeries().setNumberOfTimeStepsInInterval(10);
// double[] outletFlowRates = {0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01,
// 0.01, 0.01, 0.01};
// pipe.getTimeSeries().setOutletMolarFlowRate(outletFlowRates);

// pipe.solveTransient(20);
// pipe.getDisplay().displayResult("composition");
// pipe.getDisplay().displayResult("pressure");
// pipe.getDisplay().displayResult("composition");
// pipe.getDisplay().createNetCdfFile("c:/temp5.nc");
// pipe.getDisplay(1).displayResult();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ public void testGetName() {

@Test
public void testSetTimeStep() {
double timeStep = 10;
double timeStep = p.getTimeStep() * 2;
Assertions.assertEquals(p.getTimeStep(), timeStep / 2);
Assertions.assertNotEquals(p.getTimeStep(), timeStep);

p.setTimeStep(timeStep);
Assertions.assertEquals(p.getTimeStep(), timeStep);
Assertions.assertNotEquals(p.getTimeStep(), timeStep / 2);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public static void main(String[] args) {
neqsim.thermo.system.SystemInterface coolingWaterSYstm = fluid3.clone();
// coolingWaterSYstm.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 });
coolingWaterSYstm.removeMoles();
coolingWaterSYstm.setEmptyFluid();
coolingWaterSYstm.addComponent("water", 1.0);

/*
Expand Down