Skip to content

Commit

Permalink
refact: getPhases()[k] -> getPhase(k)
Browse files Browse the repository at this point in the history
  • Loading branch information
asmfstatoil committed Nov 24, 2024
1 parent ad0eed9 commit 2a66106
Show file tree
Hide file tree
Showing 110 changed files with 2,240 additions and 2,317 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public void setReactiveComponents() {
if (name.equals(allComponentNames[i])) {
components[k++] = system.getPhase(phase).getComponent(j);
// System.out.println("reactive comp " +
// system.getPhases()[1].getComponent(j).getName());
// system.getPhase(1).getComponent(j).getName());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,10 @@ public double step() {
return step;
} else {
// chem_pot_omega[i] = R*T*(chem_ref[i]+ Math.log(n_omega[i]/n_t) +
// Math.log(system.getPhases()[1].getComponents()[components[i].getComponentNumber()].getFugacityCoefficient()
// Math.log(system.getPhase(1).getComponents()[components[i].getComponentNumber()].getFugacityCoefficient()
// / chem_pot_pure[i]));
// chem_pot[i] = R*T*(chem_ref[i] + Math.log(n_mol[i]/n_t)+
// Math.log(system.getPhases()[1].getComponents()[components[i].getComponentNumber()].getFugacityCoefficient()
// Math.log(system.getPhase(1).getComponents()[components[i].getComponentNumber()].getFugacityCoefficient()
// / chem_pot_pure[i]));

if (system.getPhase(phasenumb).getComponents()[components[i].getComponentNumber()]
Expand All @@ -426,7 +426,7 @@ public double step() {
- Math.log(n_t) + logactivityVec[i]);
// system.getPhase(phasenumb).getActivityCoefficient(components[i].getComponentNumber(),components[waterNumb].getComponentNumber())));
// System.out.println("solvent activ: "+ i + " " +
// system.getPhases()[1].getComponents()[components[i].getComponentNumber()].getFugacityCoefficient()
// system.getPhase(1).getComponents()[components[i].getComponentNumber()].getFugacityCoefficient()
// / chem_pot_pure[i]);
} else {
chem_pot[i] = R * system.getPhase(phasenumb).getTemperature()
Expand All @@ -436,7 +436,7 @@ public double step() {
- Math.log(n_t) + logactivityVec[i]);
// system.getPhase(phasenumb).getActivityCoefficient(components[i].getComponentNumber(),components[waterNumb].getComponentNumber())));
// System.out.println("solute activ : " + i + " " +
// system.getPhases()[1].getComponents()[components[i].getComponentNumber()].getFugacityCoefficient()
// system.getPhase(1).getComponents()[components[i].getComponentNumber()].getFugacityCoefficient()
// / chem_pot_dilute[i]);
}
chem_pot_omega[i] = R * system.getPhase(phasenumb).getTemperature()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public void changePrimaryComponents() {
*
* double[] nEts = new double[atemp.getColumnDimension()]; double totm=0.0; for(int
* k=0;k<atemp.getColumnDimension();k++){ nEts[k] = xEts[k]*moles;
* //system.getPhases()[1].getNumberOfMolesInPhase(); totm += nEts[k];
* //system.getPhase(1).getNumberOfMolesInPhase(); totm += nEts[k];
* //System.out.println("N check: " + " comp " + components[k].getComponentName() + " " +
* nEts[k]); } //System.out.println("tot moles : " + system.getPhase(1).getNumberOfMolesInPhase()
* + " tot " +totm);
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].getComponent(j).getName());
// system.getPhase(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 Expand Up @@ -348,7 +348,7 @@ public void checkK(SystemInterface system) {
// double cK=Math.log(getK(system.getTemperature()));
// for(int i=0;i<names.length;i++){
// // cK -=
// Math.log(moles[i]/system.getPhases()[0].getNumberOfMolesInPhase())*stocCoefs[i];
// Math.log(moles[i]/system.getPhase(0).getNumberOfMolesInPhase())*stocCoefs[i];
// }
// System.out.println("ck: " +cK);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,9 @@ public void calcReacMatrix(PhaseInterface phase) {
for (int o = 0; o < reaction.getNames().length; o++) {
if (phase.getComponent(k).getName().equals(reaction.getNames()[o])) {
// System.out.println("comp1 " +
// system.getPhases()[1].getComponent(i).getComponentName() +
// system.getPhase(1).getComponent(i).getComponentName() +
// " comp2 "
// +system.getPhases()[1].getComponent(k).getComponentName()
// +system.getPhase(1).getComponent(k).getComponentName()
// );
tempReacMatrix[i][k] = reaction.getRateFactor(phase);
tempStocMatrix[i][k] = -reaction.getStocCoefs()[o];
Expand Down Expand Up @@ -404,12 +404,12 @@ public double[][] getStocMatrix() {
*/
public Matrix calcReacRates(PhaseInterface phase, ComponentInterface[] components) {
Matrix modReacMatrix = new Matrix(reacMatrix).copy();
// System.out.println(" vol " + system.getPhases()[1].getMolarVolume());
// System.out.println(" vol " + system.getPhase(1).getMolarVolume());

for (int i = 0; i < chemicalReactionList.size(); i++) {
for (int j = 0; j < components.length; j++) {
// System.out.println("mol cons " +
// components[j].getx()/system.getPhases()[1].getMolarMass());
// components[j].getx()/system.getPhase(1).getMolarMass());
modReacMatrix.set(i, j,
Math.pow(components[j].getx() * phase.getDensity() / phase.getMolarMass(),
Math.abs(reacMatrix[i][j])));
Expand Down
82 changes: 40 additions & 42 deletions src/main/java/neqsim/fluidmechanics/flownode/FlowNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ public String[][] createTable(String name) {
return table;
}

rows = bulkSystem.getPhases()[0].getNumberOfComponents() * 10;
rows = bulkSystem.getPhase(0).getNumberOfComponents() * 10;
String[][] table = new String[rows][5];

DecimalFormat nf = new DecimalFormat();
Expand All @@ -668,88 +668,86 @@ public String[][] createTable(String name) {
StringBuffer buf = new StringBuffer();
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].getComponent(j).getName();
for (int j = 0; j < bulkSystem.getPhase(0).getNumberOfComponents(); j++) {
table[j + 1][0] = bulkSystem.getPhase(0).getComponent(j).getName();
buf = new StringBuffer();
table[j + 1][i + 1] =
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].getComponent(j).getName();
for (int j = 0; j < bulkSystem.getPhase(0).getNumberOfComponents(); j++) {
table[j + bulkSystem.getPhase(0).getNumberOfComponents() + 2][0] =
getInterphaseSystem().getPhase(0).getComponent(j).getName();
buf = new StringBuffer();
table[j + bulkSystem.getPhases()[0].getNumberOfComponents() + 2][i + 1] =
table[j + bulkSystem.getPhase(0).getNumberOfComponents() + 2][i + 1] =
nf.format(getInterphaseSystem().getPhase(getInterphaseSystem().getPhaseIndex(i))
.getComponent(j).getx(), buf, test).toString();
table[j + bulkSystem.getPhases()[0].getNumberOfComponents() + 2][4] = "[-] interface";
table[j + bulkSystem.getPhase(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].getComponent(j).getName();
for (int j = 0; j < bulkSystem.getPhase(0).getNumberOfComponents(); j++) {
table[j + 2 * bulkSystem.getPhase(0).getNumberOfComponents() + 3][0] =
bulkSystem.getPhase(0).getComponent(j).getName();
buf = new StringBuffer();
table[j + 2 * bulkSystem.getPhases()[0].getNumberOfComponents() + 3][i + 1] =
table[j + 2 * bulkSystem.getPhase(0).getNumberOfComponents() + 3][i + 1] =
nf.format(getFluidBoundary().getInterphaseMolarFlux(j), buf, test).toString();
table[j + 2 * bulkSystem.getPhases()[0].getNumberOfComponents() + 3][4] = "[mol/sec*m^2]";
table[j + 2 * bulkSystem.getPhase(0).getNumberOfComponents() + 3][4] = "[mol/sec*m^2]";
}
buf = new StringBuffer();
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 5][0] = "Reynolds Number";
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 5][i + 1] =
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 5][0] = "Reynolds Number";
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 5][i + 1] =
nf.format(reynoldsNumber[i], buf, test).toString();
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 5][4] = "[-]";
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 5][4] = "[-]";

// Double.longValue(system.getPhase(phaseIndex[i]).getBeta());
buf = new StringBuffer();
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 6][0] = "Velocity";
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 6][i + 1] =
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 6][0] = "Velocity";
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 6][i + 1] =
nf.format(velocity[i], buf, test).toString();
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 6][4] = "[m/sec]";
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 6][4] = "[m/sec]";

buf = new StringBuffer();
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 7][0] = "Gas Heat Flux";
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 7][i + 1] =
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 7][0] = "Gas Heat Flux";
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 7][i + 1] =
nf.format(getFluidBoundary().getInterphaseHeatFlux(0), buf, test).toString();
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 7][4] = "[J/sec*m^2]";
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 7][4] = "[J/sec*m^2]";

buf = new StringBuffer();
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 8][0] = "Pressure";
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 8][i + 1] =
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 8][0] = "Pressure";
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 8][i + 1] =
Double.toString(bulkSystem.getPhase(bulkSystem.getPhaseIndex(i)).getPressure());
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 8][4] = "[bar]";
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 8][4] = "[bar]";

buf = new StringBuffer();
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 9][0] = "Bulk Temperature";
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 9][i + 1] =
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 9][0] = "Bulk Temperature";
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 9][i + 1] =
Double.toString(bulkSystem.getPhase(bulkSystem.getPhaseIndex(i)).getTemperature());
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 9][4] = "[K]";
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 9][4] = "[K]";

buf = new StringBuffer();
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 10][0] =
"Interface Temperature";
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 10][i + 1] = Double
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 10][0] = "Interface Temperature";
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 10][i + 1] = Double
.toString(getInterphaseSystem().getPhase(bulkSystem.getPhaseIndex(i)).getTemperature());
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 10][4] = "[K]";
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 10][4] = "[K]";

buf = new StringBuffer();
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 11][0] = "Interface Area";
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 11][i + 1] =
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 11][0] = "Interface Area";
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 11][i + 1] =
nf.format(getInterphaseContactArea());
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 11][4] = "[m^2]";
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 11][4] = "[m^2]";

buf = new StringBuffer();
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 12][0] =
"Inner wall temperature";
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 12][i + 1] =
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 12][0] = "Inner wall temperature";
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 12][i + 1] =
Double.toString(pipe.getInnerWallTemperature());
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 12][4] = "K";
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 12][4] = "K";

buf = new StringBuffer();
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 13][0] = "Node";
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 13][i + 1] = name;
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 13][4] = "-";
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 13][0] = "Node";
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 13][i + 1] = name;
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 13][4] = "-";
}

return table;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public FluidBoundary(SystemInterface system) {
rateCorrectionMatrix = new Matrix[2];
totalMassTransferCoefficientMatrix = new Matrix[2];
massTransferCoefficientMatrix = new Matrix[2];
jFlux = new Matrix(system.getPhases()[0].getNumberOfComponents() - 1, 1);
nFlux = new Matrix(system.getPhases()[0].getNumberOfComponents(), 1);
jFlux = new Matrix(system.getPhase(0).getNumberOfComponents() - 1, 1);
nFlux = new Matrix(system.getPhase(0).getNumberOfComponents(), 1);
nFlux.set(0, 0, 0.0);
nFlux.set(1, 0, 0.0);
heatTransferCoefficient = new double[2];
Expand Down Expand Up @@ -427,7 +427,7 @@ public String[][] createTable(String name) {
return table;
}

rows = bulkSystem.getPhases()[0].getNumberOfComponents() * 10;
rows = bulkSystem.getPhase(0).getNumberOfComponents() * 10;
String[][] table = new String[rows][5];

// String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"};
Expand All @@ -438,41 +438,41 @@ public String[][] createTable(String name) {
StringBuffer buf = new StringBuffer();
FieldPosition test = new FieldPosition(0);
for (int i = 0; i < bulkSystem.getNumberOfPhases(); i++) {
for (int j = 0; j < bulkSystem.getPhases()[0].getNumberOfComponents(); j++) {
for (int j = 0; j < bulkSystem.getPhase(0).getNumberOfComponents(); j++) {
table[j + 1][0] =
"eff. mass trans coef. " + bulkSystem.getPhases()[0].getComponent(j).getName();
"eff. mass trans coef. " + bulkSystem.getPhase(0).getComponent(j).getName();
buf = new StringBuffer();
table[j + 1][i + 1] =
nf.format(getEffectiveMassTransferCoefficient(i, j), buf, test).toString();
table[j + 1][4] = "[-] bulkcoef";
}
if (getBulkSystem().isChemicalSystem()) {
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].getComponent(j).getName();
for (int j = 0; j < bulkSystem.getPhase(0).getNumberOfComponents(); j++) {
table[j + bulkSystem.getPhase(0).getNumberOfComponents() + 2][0] =
"enhancement " + getInterphaseSystem().getPhase(0).getComponent(j).getName();
buf = new StringBuffer();
table[j + bulkSystem.getPhases()[0].getNumberOfComponents() + 2][i + 1] =
table[j + bulkSystem.getPhase(0).getNumberOfComponents() + 2][i + 1] =
nf.format(getEnhancementFactor().getEnhancementVec(j), buf, test).toString();
table[j + bulkSystem.getPhases()[0].getNumberOfComponents() + 2][4] = "[-] interfacecoef";
table[j + bulkSystem.getPhase(0).getNumberOfComponents() + 2][4] = "[-] interfacecoef";
}
}
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].getComponent(j).getName();
for (int j = 0; j < bulkSystem.getPhase(0).getNumberOfComponents(); j++) {
table[j + 2 * bulkSystem.getPhase(0).getNumberOfComponents() + 3][0] =
"schmidt " + bulkSystem.getPhase(0).getComponent(j).getName();
buf = new StringBuffer();
table[j + 2 * bulkSystem.getPhases()[0].getNumberOfComponents() + 3][i + 1] = nf.format(
table[j + 2 * bulkSystem.getPhase(0).getNumberOfComponents() + 3][i + 1] = nf.format(
getBulkSystem().getPhase(i).getPhysicalProperties().getEffectiveSchmidtNumber(j), buf,
test).toString();
table[j + 2 * bulkSystem.getPhases()[0].getNumberOfComponents() + 3][4] =
table[j + 2 * bulkSystem.getPhase(0).getNumberOfComponents() + 3][4] =
"[-] fluidboundarycoef";
}

buf = new StringBuffer();
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 11][0] = "Node";
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 11][i + 1] = name;
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 11][4] = "-";
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 11][0] = "Node";
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 11][i + 1] = name;
table[3 * bulkSystem.getPhase(0).getNumberOfComponents() + 11][4] = "-";
}
return table;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void solve() {
/** {@inheritDoc} */
@Override
public double[] calcFluxes() {
for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfComponents(); i++) {
for (int i = 0; i < bulkSystem.getPhase(0).getNumberOfComponents(); i++) {
nFlux.set(i, 0, 0);
}
return nFlux.getArray()[0];
Expand Down
Loading

0 comments on commit 2a66106

Please sign in to comment.