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

Minorupgrades #303

Merged
merged 7 commits into from
Jan 26, 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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
[![Build Status](https://neqsim.visualstudio.com/neqsim_cicd/_apis/build/status/neqsim_build?branchName=master)](https://neqsim.visualstudio.com/neqsim_cicd/_build/latest?definitionId=1&branchName=master)
![Build maven](https://github.com/equinor/neqsim/workflows/Build%20maven/badge.svg?branch=master)
NeqSim is the main part of the [NeqSim project](https://equinor.github.io/neqsimhome/). NeqSim (Non-Equilibrium Simulator) is a Java library for estimation of fluid behavior and process design for oil and gas production.
The basis for NeqSim is a library of fundamental mathematical models related to phase behavior and physical properties of oil and gas. NeqSim is easilly extended with new method. NeqSim development was initiated at the [Norwegian University of Science and Technology (NTNU)](https://www.ntnu.edu/employees/even.solbraa).
The basis for NeqSim is a library of fundamental mathematical models related to phase behavior and physical properties of oil and gas. NeqSim is easilly extended with new models. NeqSim development was initiated at the [Norwegian University of Science and Technology (NTNU)](https://www.ntnu.edu/employees/even.solbraa).

## Releases

[NeqSim releases](https://github.com/equinor/neqsim/releases) are available as java packages (jar files) and as source code. NeqSim can be used in a third party application by adding NeqSim.jar to the classpath.

## Getting started as a NeqSim Java user

NeqSim can be used in a Java application by adding the NeqSim.jar found in [NeqSim releases](https://github.com/equinor/neqsim/releases) to the classpath. A demonstration of dowloading the library and running a TPflash bencmark is illustrated in this [NeqSim Colab demo](https://colab.research.google.com/drive/1XkQ_CrVj2gLTtJvXhFQMWALzXii522CL). Learn and ask questions in [Discussions for use and development of NeqSim](https://github.com/equinor/neqsim/discussions). Also see the [NeqSim JavaDoc](https://htmlpreview.github.io/?https://github.com/equinor/neqsimhome/blob/master/javadoc/site/apidocs/index.html).
NeqSim can be used in a Java application by adding the neqsim-x.x.x.jar found in [NeqSim releases](https://github.com/equinor/neqsim/releases) to the classpath. A demonstration of dowloading the library and running a TPflash bencmark is illustrated in this [NeqSim Colab demo](https://colab.research.google.com/drive/1XkQ_CrVj2gLTtJvXhFQMWALzXii522CL). Learn and ask questions in [Discussions for use and development of NeqSim](https://github.com/equinor/neqsim/discussions). Also see the [NeqSim JavaDoc](https://htmlpreview.github.io/?https://github.com/equinor/neqsimhome/blob/master/javadoc/site/apidocs/index.html).

## Getting Started as a NeqSim Java developer

Expand Down
2 changes: 0 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>1.4.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>gov.nist.math</groupId>
Expand All @@ -90,7 +89,6 @@
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.5.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.googlecode.matrix-toolkits-java</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ public void run() {
}
slimOps0.setSystem(slimTubeNodeSystem[i]);
slimOps0.TPflash();
System.out.println("node " + i + " delta volume end "
+ (slimTubeNodeSystem[i].getVolume() - standardNodeVolume) + " add moles "
+ sum);
// System.out.println("node " + i + " delta volume end "
// + (slimTubeNodeSystem[i].getVolume() - standardNodeVolume) + " add moles "
// + sum);
slimOps1.setSystem(slimTubeNodeSystem[i + 1]);
slimOps1.TPflash();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ public void initProfiles() {

// System.out.println("velocity " + pipe.getNode(i).getVelocity());
// setting pressures
System.out
.println("presbef : " + pipe.getNode(i + 1).getBulkSystem().getPressure());
// System.out
// .println("presbef : " + pipe.getNode(i + 1).getBulkSystem().getPressure());
oldPres = pipe.getNode(i + 1).getBulkSystem().getPressure();
pipe.getNode(i + 1).getBulkSystem()
.setPressure(-pipe.getNode(i).getWallFrictionFactor()
Expand All @@ -152,22 +152,21 @@ public void initProfiles() {
- pipe.getNode(i).getBulkSystem().getPressure())
/ ((pipe.getNode(i + 1).getGeometry().getNodeLength()
+ pipe.getNode(i).getGeometry().getNodeLength()) * 0.5);

System.out.println("pres : " + pipe.getNode(i + 1).getBulkSystem().getPressure());
System.out
.println("temp : " + pipe.getNode(i + 1).getBulkSystem().getTemperature());
System.out.println("velocity : " + pipe.getNode(i + 1).getVelocity());
System.out.println("dpdx : " + dpdx);
System.out
.println("JT coeff : " + pipe.getNode(i + 1).getBulkSystem().getPhases()[0]
.getJouleThomsonCoefficient());
/*
* System.out.println("pres : " + pipe.getNode(i +
* 1).getBulkSystem().getPressure()); System.out .println("temp : " + pipe.getNode(i
* + 1).getBulkSystem().getTemperature()); System.out.println("velocity : " +
* pipe.getNode(i + 1).getVelocity()); System.out.println("dpdx : " + dpdx);
* System.out .println("JT coeff : " + pipe.getNode(i +
* 1).getBulkSystem().getPhases()[0] .getJouleThomsonCoefficient());
*/
// setting velocities
pipe.getNode(i + 1).setVelocityIn(pipe.getNode(i + 1).getVelocity());
pipe.getNode(i + 1)
.setVelocity((pipe.getNode(i + 1).getVelocityIn().doubleValue()));
pipe.getNode(i + 1).init();
}
System.out.println("err: " + err);
// System.out.println("err: " + err);
} while (Math.abs(err) > 1);
initMatrix();
}
Expand Down Expand Up @@ -779,7 +778,7 @@ public void solveTDMA() {
d = TDMAsolve.solve(a, b, c, r);
sol3Matrix = new Matrix(d, 1).transpose();
diffMatrix = sol3Matrix.minus(sol3Old);
System.out.println("diff3: " + diffMatrix.norm1() / sol3Matrix.norm1());
// System.out.println("diff3: " + diffMatrix.norm1() / sol3Matrix.norm1());
initTemperature(iter);

diff = Math.abs(diffMatrix.norm1() / sol3Matrix.norm1());
Expand Down Expand Up @@ -810,7 +809,7 @@ public void solveTDMA() {
} while (diff > 1e-15 && iter < 10);
}

System.out.println("maxDiff " + maxDiff);
// System.out.println("maxDiff " + maxDiff);
} while (Math.abs(maxDiff) > 1e-10 && iterTop < 100);// diffMatrix.norm2()/sol2Matrix.norm2())>0.1);

initFinalResults();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void flowLegInit() {
}

totalNumberOfNodes = this.calcTotalNumberOfNodes();
System.out.println("total number of nodes : " + totalNumberOfNodes);
// System.out.println("total number of nodes : " + totalNumberOfNodes);
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void createSystem() {

flowNode =
new neqsim.fluidMechanics.flowNode.onePhaseNode.onePhasePipeFlowNode.onePhasePipeFlowNode[totalNumberOfNodes];
System.out.println("nodes: " + totalNumberOfNodes);
// System.out.println("nodes: " + totalNumberOfNodes);
flowNode[0] =
new neqsim.fluidMechanics.flowNode.onePhaseNode.onePhasePipeFlowNode.onePhasePipeFlowNode(
thermoSystem, this.equipmentGeometry[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public FlowSystemVisualization(int nodes, int timeSteps) {
flowNodes[i][j] = new FlowNodeVisualization();
}
}
System.out.println("nodes " + nodes);
System.out.println("times " + time);
// System.out.println("nodes " + nodes);
// System.out.println("times " + time);
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public PipeFlowVisualization(int nodes, int timeSteps) {
new neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowNodeVisualization.onePhaseFlowNodeVisualization.onePhasePipeFlowNodeVisualization.OnePhasePipeFlowNodeVisualization();
}
}
System.out.println("nodes " + nodes);
System.out.println("times " + time);
// System.out.println("nodes " + nodes);
// System.out.println("times " + time);
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public TwoPhasePipeFlowVisualization(int nodes, int timeSteps) {
flowNodes[i][j] = new TwoPhaseFlowNodeVisualization();
}
}
System.out.println("nodes " + nodes);
System.out.println("times " + time);
// System.out.println("nodes " + nodes);
// System.out.println("times " + time);
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void init(FlowSystemInterface flowSystem) {
timeSteps = new double[(timeSeries.length - 1) * numberOfTimeStepsInInterval];
times = new double[(timeSeries.length - 1) * numberOfTimeStepsInInterval];

System.out.println("times " + inletThermoSystem.length);
// System.out.println("times " + inletThermoSystem.length);
double temp = 0;
for (int k = 0; k < timeSeries.length - 1; k++) {
double stepLength = (timeSeries[k + 1] - timeSeries[k]) / numberOfTimeStepsInInterval;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ public void run() {
gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008();
hinn = gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase();
entropy = gergProps[8] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase();
densInn = getThermoSystem().getPhase(0).getDensity_GERG2008();
}

inletEnthalpy = hinn;
Expand Down Expand Up @@ -411,6 +412,7 @@ public void run() {
gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008();
actualFlowRate *= gergProps[1] / z_inlet;
kappa = gergProps[14];
z_inlet = gergProps[1];
}

double polytropEff =
Expand Down Expand Up @@ -444,8 +446,8 @@ public void run() {
// thermoSystem.getFlowRate("m3/hr")));
}
if (surgeCheck && getAntiSurge().isActive()) {
thermoSystem.setTotalNumberOfMoles(getAntiSurge().getSurgeControlFactor()
* thermoSystem.getTotalNumberOfMoles());
thermoSystem.setTotalFlowRate(getAntiSurge().getSurgeControlFactor()
* getCompressorChart().getSurgeCurve().getSurgeFlow(polytropicFluidHead), "Am3/hr");
thermoSystem.init(3);
fractionAntiSurge =
thermoSystem.getTotalNumberOfMoles() / orginalMolarFLow - 1.0;
Expand Down Expand Up @@ -804,13 +806,17 @@ public String getName() {
* @return a double
*/
public double getTotalWork() {
double multi = 1.0;
if(getAntiSurge().isActive()) {
multi=1.0+getAntiSurge().getCurrentSurgeFraction();
}
if (useGERG2008 && thermoSystem.getNumberOfPhases() == 1) {
double[] gergProps;
gergProps = getThermoSystem().getPhase(0).getProperties_GERG2008();
double enth = gergProps[7] * getThermoSystem().getPhase(0).getNumberOfMolesInPhase();
return enth - inletEnthalpy;
return (enth - inletEnthalpy)*multi;
} else
return getThermoSystem().getEnthalpy() - inletEnthalpy;
return multi*(getThermoSystem().getEnthalpy() - inletEnthalpy);
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,13 @@ public static void main(String[] args) {

testFluid.setTemperature(24.0, "C");
testFluid.setPressure(48.0, "bara");
testFluid.setTotalFlowRate(4.5, "MSm3/day");
testFluid.setTotalFlowRate(1.0, "MSm3/day");

Stream stream_1 = new Stream("Stream1", testFluid);
Compressor comp1 = new Compressor(stream_1);
comp1.setUsePolytropicCalc(true);
// comp1.getAntiSurge().setActive(true);
comp1.setSpeed(12918);
comp1.setSpeed(11918);

double[] chartConditions = new double[] {0.3, 1.0, 1.0, 1.0};
// double[] speed = new double[] { 1000.0, 2000.0, 3000.0, 4000.0 };
Expand Down Expand Up @@ -360,12 +360,19 @@ public static void main(String[] args) {
// double[][] polyEff = new double[][] { { 66.8, 69.0, 66.4, 55.6 } };
comp1.getCompressorChart().setCurves(chartConditions, speed, flow, head, polyEff);
comp1.getCompressorChart().setHeadUnit("kJ/kg");

double[] surgeflow = new double[] {2789.0, 2550.0, 2500.0, 2200.0 };
double[] surgehead =
new double[] { 80.0, 72.0, 70.0, 65.0 };
comp1.getCompressorChart().getSurgeCurve().setCurve(chartConditions, surgeflow,
surgehead);
//comp1.getAntiSurge().setActive(true);
comp1.getAntiSurge().setSurgeControlFactor(1.0);
/*
* double[] surgeflow = new double[] { 453.2, 550.0, 700.0, 800.0 }; double[] surgehead =
* new double[] { 6000.0, 7000.0, 8000.0, 10000.0 };
* comp1.getCompressorChart().getSurgeCurve().setCurve(chartConditions, surgeflow,
* surgehead);
*
* surgehead)
* double[] stoneWallflow = new double[] { 923.2, 950.0, 980.0, 1000.0 }; double[]
* stoneWallHead = new double[] { 6000.0, 7000.0, 8000.0, 10000.0 };
* comp1.getCompressorChart().getStoneWallCurve().setCurve(chartConditions, stoneWallflow,
Expand All @@ -379,6 +386,7 @@ public static void main(String[] args) {
// operations.displayResult();

System.out.println("power " + comp1.getPower());
System.out.println("is surge " + comp1.getAntiSurge().isSurge());
System.out.println(
"fraction in anti surge line " + comp1.getAntiSurge().getCurrentSurgeFraction());
System.out.println("Polytropic head from curve:" + comp1.getPolytropicHead());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void testInit() {
void testSolveSteadyState() {
testInit();
pipe.solveSteadyState(10);
pipe.print();
// pipe.print();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void testCompressorWithGERG2008() {
//System.out.println("gerg polytropic efficiency " + compressor1.getPolytropicEfficiency()*100 + " poly eff");
//System.out.println("gerg fluid head " + compressor1.getPolytropicFluidHead() + " kJ/kg");
//System.out.println("gerg power " + compressor1.getPower() + " W");
assertEquals(compressor1.getPolytropicEfficiency()*100, 89.99229675168343,
assertEquals(compressor1.getPolytropicEfficiency() * 100, 89.99367027631443,
"Test case for rigorous polytropic efficiency with GER2008 calculation should return approximate 89.992296751");
}
}
2 changes: 0 additions & 2 deletions src/test/java/neqsim/thermo/system/SystemPrEosTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ public void checkFugacityCoefficientsDn2() {
@Test
@DisplayName("calculate compressibility of gas phase")
public void checkCompressibility() {
System.out.println("gas compressibility " + testSystem.getPhase("gas").getZ());
assertEquals(testSystem.getPhase("gas").getZ(), 0.9708455641951108, 1e-5);
}

Expand All @@ -132,7 +131,6 @@ public void calcProperties() {
ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
testOps.TPflash();
testSystem.initProperties();
System.out.print("enthalpy " + testSystem.getEnthalpy("kJ/kg"));
assertEquals(testSystem.getEnthalpy("kJ/kg"), -165.60627184389855,
Math.abs(-165.60627184389855 / 1000.0));
}
Expand Down