Skip to content

Commit

Permalink
refact: use getComponent when getting 1 comp (#1187)
Browse files Browse the repository at this point in the history
* refact: use getComponent when getting 1 comp
  • Loading branch information
asmfstatoil authored Nov 22, 2024
1 parent d3bdf14 commit da485d0
Show file tree
Hide file tree
Showing 111 changed files with 1,446 additions and 1,508 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

package neqsim.chemicalreactions;

import java.util.HashSet;
import java.util.Iterator;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import Jama.Matrix;
import neqsim.chemicalreactions.chemicalequilibrium.ChemicalEquilibrium;
import neqsim.chemicalreactions.chemicalequilibrium.LinearProgrammingChemicalEquilibrium;
import neqsim.chemicalreactions.chemicalreaction.ChemicalReactionList;
Expand All @@ -14,13 +19,6 @@
import neqsim.thermo.phase.PhaseInterface;
import neqsim.thermo.system.SystemInterface;

import java.util.HashSet;
import java.util.Iterator;

import Jama.Matrix;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
* <p>
* ChemicalReactionOperations class.
Expand Down Expand Up @@ -178,9 +176,9 @@ public void setReactiveComponents() {
String name = componentNames[j];
for (int i = 0; i < allComponentNames.length; i++) {
if (name.equals(allComponentNames[i])) {
components[k++] = system.getPhase(phase).getComponents()[j];
components[k++] = system.getPhase(phase).getComponent(j);
// System.out.println("reactive comp " +
// system.getPhases()[1].getComponents()[j].getName());
// system.getPhases()[1].getComponent(j).getName());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public void initMoleNumbers(PhaseInterface phase, ComponentInterface[] component
for (int i = 0; i < names.length; i++) {
for (int j = 0; j < components.length; j++) {
// System.out.println("names: " + names[i] + " " +
// system.getPhases()[0].getComponents()[j].getName());
// system.getPhases()[0].getComponent(j).getName());
if (this.names[i].equals(components[j].getName())) {
for (int k = 0; k < Amatrix.length; k++) {
tempAmatrix.set(k, i, Amatrix[k][j]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,14 @@ public void calcReacMatrix(PhaseInterface phase) {
while (e.hasNext()) {
reaction = e.next();
for (int j = 0; j < reaction.getNames().length; j++) {
if (phase.getComponents()[i].getName().equals(reaction.getNames()[j])) {
if (phase.getComponent(i).getName().equals(reaction.getNames()[j])) {
for (int k = 0; k < phase.getNumberOfComponents(); k++) {
for (int o = 0; o < reaction.getNames().length; o++) {
if (phase.getComponents()[k].getName().equals(reaction.getNames()[o])) {
if (phase.getComponent(k).getName().equals(reaction.getNames()[o])) {
// System.out.println("comp1 " +
// system.getPhases()[1].getComponents()[i].getComponentName() +
// system.getPhases()[1].getComponent(i).getComponentName() +
// " comp2 "
// +system.getPhases()[1].getComponents()[k].getComponentName()
// +system.getPhases()[1].getComponent(k).getComponentName()
// );
tempReacMatrix[i][k] = reaction.getRateFactor(phase);
tempStocMatrix[i][k] = -reaction.getStocCoefs()[o];
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/neqsim/fluidmechanics/flownode/FlowNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -668,27 +668,27 @@ public String[][] createTable(String name) {
FieldPosition test = new FieldPosition(0);
for (int i = 0; i < bulkSystem.getNumberOfPhases(); i++) {
for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfComponents(); j++) {
table[j + 1][0] = bulkSystem.getPhases()[0].getComponents()[j].getName();
table[j + 1][0] = bulkSystem.getPhases()[0].getComponent(j).getName();
buf = new StringBuffer();
table[j + 1][i + 1] =
nf.format(bulkSystem.getPhase(bulkSystem.getPhaseIndex(i)).getComponents()[j].getx(),
buf, test).toString();
nf.format(bulkSystem.getPhase(bulkSystem.getPhaseIndex(i)).getComponent(j).getx(), buf,
test).toString();
table[j + 1][4] = "[-] bulk";
}

for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfComponents(); j++) {
table[j + bulkSystem.getPhases()[0].getNumberOfComponents() + 2][0] =
getInterphaseSystem().getPhases()[0].getComponents()[j].getName();
getInterphaseSystem().getPhases()[0].getComponent(j).getName();
buf = new StringBuffer();
table[j + bulkSystem.getPhases()[0].getNumberOfComponents() + 2][i + 1] =
nf.format(getInterphaseSystem().getPhase(getInterphaseSystem().getPhaseIndex(i))
.getComponents()[j].getx(), buf, test).toString();
.getComponent(j).getx(), buf, test).toString();
table[j + bulkSystem.getPhases()[0].getNumberOfComponents() + 2][4] = "[-] interface";
}

for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfComponents(); j++) {
table[j + 2 * bulkSystem.getPhases()[0].getNumberOfComponents() + 3][0] =
bulkSystem.getPhases()[0].getComponents()[j].getName();
bulkSystem.getPhases()[0].getComponent(j).getName();
buf = new StringBuffer();
table[j + 2 * bulkSystem.getPhases()[0].getNumberOfComponents() + 3][i + 1] =
nf.format(getFluidBoundary().getInterphaseMolarFlux(j), buf, test).toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public void calcFluxTypeCorrectionMatrix(int phase, int k) {
temp = (i == k) ? 1.0 : 0.0;
fluxTypeCorrectionMatrixV[phase].set(i, 0, temp);
sum += fluxTypeCorrectionMatrixV[phase].get(i, 0)
* bulkSystem.getPhases()[phase].getComponents()[i].getx();
* bulkSystem.getPhases()[phase].getComponent(i).getx();
}

sum += fluxTypeCorrectionMatrixV[phase]
Expand Down Expand Up @@ -283,8 +283,8 @@ public void calcNonIdealCorrections(int phase) {
for (int j = 0; j < bulkSystem.getPhases()[phase].getNumberOfComponents() - 1; j++) {
temp = (i == j) ? 1.0 : 0.0;
nonIdealCorrections[phase].set(i, j,
temp + bulkSystem.getPhases()[phase].getComponents()[i].getx()
* bulkSystem.getPhases()[phase].getComponents()[i].getdfugdn(j)
temp + bulkSystem.getPhases()[phase].getComponent(i).getx()
* bulkSystem.getPhases()[phase].getComponent(i).getdfugdn(j)
* bulkSystem.getPhases()[phase].getNumberOfMolesInPhase());
// her må det fylles inn
}
Expand Down Expand Up @@ -440,7 +440,7 @@ public String[][] createTable(String name) {
for (int i = 0; i < bulkSystem.getNumberOfPhases(); i++) {
for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfComponents(); j++) {
table[j + 1][0] =
"eff. mass trans coef. " + bulkSystem.getPhases()[0].getComponents()[j].getName();
"eff. mass trans coef. " + bulkSystem.getPhases()[0].getComponent(j).getName();
buf = new StringBuffer();
table[j + 1][i + 1] =
nf.format(getEffectiveMassTransferCoefficient(i, j), buf, test).toString();
Expand All @@ -450,7 +450,7 @@ public String[][] createTable(String name) {
getEnhancementFactor().calcEnhancementVec(i);
for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfComponents(); j++) {
table[j + bulkSystem.getPhases()[0].getNumberOfComponents() + 2][0] =
"enhancement " + getInterphaseSystem().getPhases()[0].getComponents()[j].getName();
"enhancement " + getInterphaseSystem().getPhases()[0].getComponent(j).getName();
buf = new StringBuffer();
table[j + bulkSystem.getPhases()[0].getNumberOfComponents() + 2][i + 1] =
nf.format(getEnhancementFactor().getEnhancementVec(j), buf, test).toString();
Expand All @@ -460,7 +460,7 @@ public String[][] createTable(String name) {
getBulkSystem().getPhase(i).getPhysicalProperties().calcEffectiveDiffusionCoefficients();
for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfComponents(); j++) {
table[j + 2 * bulkSystem.getPhases()[0].getNumberOfComponents() + 3][0] =
"schmidt " + bulkSystem.getPhases()[0].getComponents()[j].getName();
"schmidt " + bulkSystem.getPhases()[0].getComponent(j).getName();
buf = new StringBuffer();
table[j + 2 * bulkSystem.getPhases()[0].getNumberOfComponents() + 3][i + 1] = nf.format(
getBulkSystem().getPhase(i).getPhysicalProperties().getEffectiveSchmidtNumber(j), buf,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,24 @@ public void initProfiles() {
for (int j = 0; j < boundary.getNode(0).getBulkSystem().getPhases()[0]
.getNumberOfComponents(); j++) {
double xbulk =
boundary.getFluidBoundary().getBulkSystem().getPhases()[1].getComponents()[j].getx();
boundary.getFluidBoundary().getBulkSystem().getPhases()[1].getComponent(j).getx();
double xinterphase =
boundary.getFluidBoundary().getInterphaseSystem().getPhases()[1].getComponents()[j]
boundary.getFluidBoundary().getInterphaseSystem().getPhases()[1].getComponent(j)
.getx();
double dx = xinterphase - xbulk;
double last = boundary.getNode(i).getBulkSystem().getPhases()[1].getComponents()[j].getx();
double last = boundary.getNode(i).getBulkSystem().getPhases()[1].getComponent(j).getx();
if (reactive) {
boundary.getNode(i + 1).getBulkSystem().getPhases()[1].getComponents()[j].setx(last - dx
boundary.getNode(i + 1).getBulkSystem().getPhases()[1].getComponent(j).setx(last - dx
- reacRates.get(j, 0)
/ boundary.getNode(i).getBulkSystem().getPhases()[1].getPhysicalProperties()
.getEffectiveDiffusionCoefficient(j)
* Math.pow(boundary.getNodeLength(), 2.0));
} else {
boundary.getNode(i + 1).getBulkSystem().getPhases()[1].getComponents()[j]
boundary.getNode(i + 1).getBulkSystem().getPhases()[1].getComponent(j)
.setx(xinterphase - dx * ((double) (i + 1) / boundary.getNumberOfNodes()));
}
System.out.println("x comp " + reactive + " "
+ boundary.getNode(i).getBulkSystem().getPhases()[1].getComponents()[j].getx());
+ boundary.getNode(i).getBulkSystem().getPhases()[1].getComponent(j).getx());
}
}
}
Expand All @@ -130,7 +130,7 @@ public void initMatrix() {
// pipe.getNode(i).init();
for (int i = 0; i < boundary.getNumberOfNodes(); i++) {
solMatrix[j].set(i, 0,
boundary.getNode(i).getBulkSystem().getPhases()[1].getComponents()[j].getx());
boundary.getNode(i).getBulkSystem().getPhases()[1].getComponent(j).getx());
}
}
}
Expand All @@ -146,7 +146,7 @@ public void initComposition(int iter) {
for (int j = 0; j < boundary.getNumberOfNodes(); j++) {
for (int p = 0; p < boundary.getNode(0).getBulkSystem().getPhases()[0]
.getNumberOfComponents(); p++) {
boundary.getNode(j).getBulkSystem().getPhases()[1].getComponents()[p]
boundary.getNode(j).getBulkSystem().getPhases()[1].getComponent(p)
.setx(solMatrix[p].get(j, 0));
}
boundary.getNode(j).getBulkSystem().getPhases()[0].normalize();
Expand Down
Loading

0 comments on commit da485d0

Please sign in to comment.