Skip to content

Commit

Permalink
refact: getPhases -> getPhase
Browse files Browse the repository at this point in the history
  • Loading branch information
asmfstatoil committed Nov 22, 2024
1 parent 45af5bc commit 91c40a2
Show file tree
Hide file tree
Showing 17 changed files with 243 additions and 266 deletions.
14 changes: 7 additions & 7 deletions src/main/java/neqsim/fluidmechanics/flownode/FlowNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,9 @@ public double calcNusseltNumber(double prandtlNumber, int phase) {
/** {@inheritDoc} */
@Override
public double getPrandtlNumber(int phaseNum) {
return getBulkSystem().getPhases()[phaseNum].getCp()
* getBulkSystem().getPhases()[phaseNum].getPhysicalProperties().getViscosity()
/ getBulkSystem().getPhases()[phaseNum].getPhysicalProperties().getConductivity();
return getBulkSystem().getPhase(phaseNum).getCp()
* getBulkSystem().getPhase(phaseNum).getPhysicalProperties().getViscosity()
/ getBulkSystem().getPhase(phaseNum).getPhysicalProperties().getConductivity();
}

/** {@inheritDoc} */
Expand Down Expand Up @@ -558,10 +558,10 @@ public void increaseMolarRate(double moles) {}
/** {@inheritDoc} */
@Override
public double calcTotalHeatTransferCoefficient(int phaseNum) {
double prandtlNumber = getBulkSystem().getPhases()[phaseNum].getCp()
/ getBulkSystem().getPhases()[phaseNum].getNumberOfMolesInPhase()
* getBulkSystem().getPhases()[phaseNum].getPhysicalProperties().getViscosity()
/ getBulkSystem().getPhases()[phaseNum].getPhysicalProperties().getConductivity();
double prandtlNumber = getBulkSystem().getPhase(phaseNum).getCp()
/ getBulkSystem().getPhase(phaseNum).getNumberOfMolesInPhase()
* getBulkSystem().getPhase(phaseNum).getPhysicalProperties().getViscosity()
/ getBulkSystem().getPhase(phaseNum).getPhysicalProperties().getConductivity();
double temp = 1.0 / (1.0
/ interphaseTransportCoefficient.calcWallHeatTransferCoefficient(phaseNum, prandtlNumber,
this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,28 +242,28 @@ public ThermodynamicOperations getBulkSystemOpertions() {
*/
public void calcFluxTypeCorrectionMatrix(int phaseNum, int k) {
fluxTypeCorrectionMatrixV[phaseNum] =
new Matrix(bulkSystem.getPhases()[phaseNum].getNumberOfComponents(), 1);
new Matrix(bulkSystem.getPhase(phaseNum).getNumberOfComponents(), 1);
fluxTypeCorrectionMatrix[phaseNum] =
new Matrix(bulkSystem.getPhases()[phaseNum].getNumberOfComponents() - 1, 1);
new Matrix(bulkSystem.getPhase(phaseNum).getNumberOfComponents() - 1, 1);
double temp = 0;

double sum = 0;
for (int i = 0; i < bulkSystem.getPhases()[phaseNum].getNumberOfComponents() - 1; i++) {
for (int i = 0; i < bulkSystem.getPhase(phaseNum).getNumberOfComponents() - 1; i++) {
temp = (i == k) ? 1.0 : 0.0;
fluxTypeCorrectionMatrixV[phaseNum].set(i, 0, temp);
sum += fluxTypeCorrectionMatrixV[phaseNum].get(i, 0)
* bulkSystem.getPhases()[phaseNum].getComponent(i).getx();
* bulkSystem.getPhase(phaseNum).getComponent(i).getx();
}

sum += fluxTypeCorrectionMatrixV[phaseNum]
.get(bulkSystem.getPhases()[phaseNum].getNumberOfComponents() - 1, 0)
* bulkSystem.getPhases()[phaseNum]
.getComponents()[bulkSystem.getPhases()[phaseNum].getNumberOfComponents() - 1].getx();
.get(bulkSystem.getPhase(phaseNum).getNumberOfComponents() - 1, 0)
* bulkSystem.getPhase(phaseNum)
.getComponents()[bulkSystem.getPhase(phaseNum).getNumberOfComponents() - 1].getx();

for (int i = 0; i < bulkSystem.getPhases()[phaseNum].getNumberOfComponents() - 1; i++) {
for (int i = 0; i < bulkSystem.getPhase(phaseNum).getNumberOfComponents() - 1; i++) {
fluxTypeCorrectionMatrix[phaseNum].set(i, 0,
(fluxTypeCorrectionMatrixV[phaseNum].get(i, 0) - fluxTypeCorrectionMatrixV[phaseNum]
.get(bulkSystem.getPhases()[phaseNum].getNumberOfComponents() - 1, 0)) / sum);
.get(bulkSystem.getPhase(phaseNum).getNumberOfComponents() - 1, 0)) / sum);
}
}

Expand All @@ -276,16 +276,16 @@ public void calcFluxTypeCorrectionMatrix(int phaseNum, int k) {
*/
public void calcNonIdealCorrections(int phaseNum) {
nonIdealCorrections[phaseNum] =
new Matrix(bulkSystem.getPhases()[phaseNum].getNumberOfComponents() - 1,
bulkSystem.getPhases()[phaseNum].getNumberOfComponents() - 1);
new Matrix(bulkSystem.getPhase(phaseNum).getNumberOfComponents() - 1,
bulkSystem.getPhase(phaseNum).getNumberOfComponents() - 1);
double temp = 0;
for (int i = 0; i < bulkSystem.getPhases()[phaseNum].getNumberOfComponents() - 1; i++) {
for (int j = 0; j < bulkSystem.getPhases()[phaseNum].getNumberOfComponents() - 1; j++) {
for (int i = 0; i < bulkSystem.getPhase(phaseNum).getNumberOfComponents() - 1; i++) {
for (int j = 0; j < bulkSystem.getPhase(phaseNum).getNumberOfComponents() - 1; j++) {
temp = (i == j) ? 1.0 : 0.0;
nonIdealCorrections[phaseNum].set(i, j,
temp + bulkSystem.getPhases()[phaseNum].getComponent(i).getx()
* bulkSystem.getPhases()[phaseNum].getComponent(i).getdfugdn(j)
* bulkSystem.getPhases()[phaseNum].getNumberOfMolesInPhase());
temp + bulkSystem.getPhase(phaseNum).getComponent(i).getx()
* bulkSystem.getPhase(phaseNum).getComponent(i).getdfugdn(j)
* bulkSystem.getPhase(phaseNum).getNumberOfMolesInPhase());
// her må det fylles inn
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,10 @@ public void calcMolFractionDifference() {
* @param phaseNum a int
*/
public void calcHeatTransferCoefficients(int phaseNum) {
prandtlNumber[phaseNum] = getBulkSystem().getPhases()[phaseNum].getCp()
/ getBulkSystem().getPhases()[phaseNum].getNumberOfMolesInPhase()
* getBulkSystem().getPhases()[phaseNum].getPhysicalProperties().getViscosity()
/ getBulkSystem().getPhases()[phaseNum].getPhysicalProperties().getConductivity();
prandtlNumber[phaseNum] = getBulkSystem().getPhase(phaseNum).getCp()
/ getBulkSystem().getPhase(phaseNum).getNumberOfMolesInPhase()
* getBulkSystem().getPhase(phaseNum).getPhysicalProperties().getViscosity()
/ getBulkSystem().getPhase(phaseNum).getPhysicalProperties().getConductivity();
// System.out.println("prandtlNumber " + prandtlNumber[phase] + " interface " +
// flowNode.getInterphaseTransportCoefficient().calcInterphaseHeatTransferCoefficient(phase,
// prandtlNumber[phase], flowNode));
Expand All @@ -465,8 +465,8 @@ public void calcHeatTransferCorrection(int phaseNum) {
if (Math.abs(nFlux.get(i, 0)) < 1e-20) {
temp += 0.0;
} else {
temp += nFlux.get(i, 0) * getBulkSystem().getPhases()[phaseNum].getCp()
/ getBulkSystem().getPhases()[phaseNum].getNumberOfMolesInPhase()
temp += nFlux.get(i, 0) * getBulkSystem().getPhase(phaseNum).getCp()
/ getBulkSystem().getPhase(phaseNum).getNumberOfMolesInPhase()
/ heatTransferCoefficient[phaseNum]; // bulkSystem.getPhases()[0].getComponent(i).getNumberOfMolesInPhase()*
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,17 @@ public KrishnaStandartFilmModel clone() {
* @return a double
*/
public double calcBinarySchmidtNumbers(int phaseNum) {
for (int i = 0; i < getBulkSystem().getPhases()[phaseNum].getNumberOfComponents(); i++) {
for (int j = 0; j < getBulkSystem().getPhases()[phaseNum].getNumberOfComponents(); j++) {
for (int i = 0; i < getBulkSystem().getPhase(phaseNum).getNumberOfComponents(); i++) {
for (int j = 0; j < getBulkSystem().getPhase(phaseNum).getNumberOfComponents(); j++) {
binarySchmidtNumber[phaseNum][i][j] =
getBulkSystem().getPhases()[phaseNum].getPhysicalProperties().getKinematicViscosity()
/ getBulkSystem().getPhases()[phaseNum].getPhysicalProperties()
getBulkSystem().getPhase(phaseNum).getPhysicalProperties().getKinematicViscosity()
/ getBulkSystem().getPhase(phaseNum).getPhysicalProperties()
.getDiffusionCoefficient(i, j);
// System.out.println("i j " + i +" j " + j);
// System.out.println("phase " + phase + " diff" +
// getBulkSystem().getPhases()[phaseNum].getPhysicalProperties().getDiffusionCoefficient(i,j));
// getBulkSystem().getPhase(phaseNum).getPhysicalProperties().getDiffusionCoefficient(i,j));
// System.out.println("phase " + phase + " visk" +
// getBulkSystem().getPhases()[phaseNum].getPhysicalProperties().getKinematicViscosity());
// getBulkSystem().getPhase(phaseNum).getPhysicalProperties().getKinematicViscosity());
}
}
return 1;
Expand All @@ -116,8 +116,8 @@ public double calcBinarySchmidtNumbers(int phaseNum) {
* @return a double
*/
public double calcBinaryMassTransferCoefficients(int phaseNum) {
for (int i = 0; i < getBulkSystem().getPhases()[phaseNum].getNumberOfComponents(); i++) {
for (int j = 0; j < getBulkSystem().getPhases()[phaseNum].getNumberOfComponents(); j++) {
for (int i = 0; i < getBulkSystem().getPhase(phaseNum).getNumberOfComponents(); i++) {
for (int j = 0; j < getBulkSystem().getPhase(phaseNum).getNumberOfComponents(); j++) {
binaryMassTransferCoefficient[phaseNum][i][j] =
flowNode.getInterphaseTransportCoefficient().calcInterphaseMassTransferCoefficient(
phaseNum, binarySchmidtNumber[phaseNum][i][j], flowNode);
Expand All @@ -135,24 +135,24 @@ public double calcBinaryMassTransferCoefficients(int phaseNum) {
* @return a double
*/
public double calcMassTransferCoefficients(int phaseNum) {
int n = getBulkSystem().getPhases()[phaseNum].getNumberOfComponents() - 1;
int n = getBulkSystem().getPhase(phaseNum).getNumberOfComponents() - 1;

for (int i = 0; i < getBulkSystem().getPhases()[phaseNum].getNumberOfComponents() - 1; i++) {
for (int i = 0; i < getBulkSystem().getPhase(phaseNum).getNumberOfComponents() - 1; i++) {
double tempVar = 0;
for (int j = 0; j < getBulkSystem().getPhases()[phaseNum].getNumberOfComponents(); j++) {
for (int j = 0; j < getBulkSystem().getPhase(phaseNum).getNumberOfComponents(); j++) {
if (i != j) {
tempVar += getBulkSystem().getPhases()[phaseNum].getComponent(j).getx()
tempVar += getBulkSystem().getPhase(phaseNum).getComponent(j).getx()
/ binaryMassTransferCoefficient[phaseNum][i][j];
}
if (j < n) {
massTransferCoefficientMatrix[phaseNum].set(i, j,
-getBulkSystem().getPhases()[phaseNum].getComponent(i).getx()
-getBulkSystem().getPhase(phaseNum).getComponent(i).getx()
* (1.0 / binaryMassTransferCoefficient[phaseNum][i][j]
- 1.0 / binaryMassTransferCoefficient[phaseNum][i][n]));
}
}
massTransferCoefficientMatrix[phaseNum].set(i, i,
tempVar + getBulkSystem().getPhases()[phaseNum].getComponent(i).getx()
tempVar + getBulkSystem().getPhase(phaseNum).getComponent(i).getx()
/ binaryMassTransferCoefficient[phaseNum][i][n]);
}
massTransferCoefficientMatrix[phaseNum] = massTransferCoefficientMatrix[phaseNum].inverse();
Expand All @@ -167,28 +167,28 @@ public double calcMassTransferCoefficients(int phaseNum) {
* @param phaseNum a int
*/
public void calcPhiMatrix(int phaseNum) {
int n = getBulkSystem().getPhases()[phaseNum].getNumberOfComponents() - 1;
int n = getBulkSystem().getPhase(phaseNum).getNumberOfComponents() - 1;

for (int i = 0; i < getBulkSystem().getPhases()[phaseNum].getNumberOfComponents() - 1; i++) {
for (int i = 0; i < getBulkSystem().getPhase(phaseNum).getNumberOfComponents() - 1; i++) {
double tempVar = 0;
for (int j = 0; j < getBulkSystem().getPhases()[phaseNum].getNumberOfComponents(); j++) {
for (int j = 0; j < getBulkSystem().getPhase(phaseNum).getNumberOfComponents(); j++) {
if (i != j || i == n) {
tempVar += nFlux.get(i, 0)
/ (1.0 / (getBulkSystem().getPhases()[phaseNum].getMolarVolume() * 1e-5)
tempVar +=
nFlux.get(i, 0) / (1.0 / (getBulkSystem().getPhase(phaseNum).getMolarVolume() * 1e-5)
* binaryMassTransferCoefficient[phaseNum][i][j]);
}
if (j < n) {
phiMatrix.set(i, j,
-nFlux.get(i, 0) * (1.0
/ (1.0 / (getBulkSystem().getPhases()[phaseNum].getMolarVolume() * 1e-5)
/ (1.0 / (getBulkSystem().getPhase(phaseNum).getMolarVolume() * 1e-5)
* binaryMassTransferCoefficient[phaseNum][i][j])
- 1.0 / (1.0 / (getBulkSystem().getPhases()[phaseNum].getMolarVolume() * 1e-5)
- 1.0 / (1.0 / (getBulkSystem().getPhase(phaseNum).getMolarVolume() * 1e-5)
* binaryMassTransferCoefficient[phaseNum][i][n])));
}
}
phiMatrix.set(i, i,
tempVar + nFlux.get(i, 0)
/ (1.0 / (getBulkSystem().getPhases()[phaseNum].getMolarVolume() * 1e-5)
/ (1.0 / (getBulkSystem().getPhase(phaseNum).getMolarVolume() * 1e-5)
* binaryMassTransferCoefficient[phaseNum][i][n]));
}
}
Expand All @@ -212,7 +212,7 @@ public void calcRedPhiMatrix(int phase) {
* @param phaseNum a int
*/
public void calcRedCorrectionMatrix(int phaseNum) {
for (int i = 0; i < getBulkSystem().getPhases()[phaseNum].getNumberOfComponents() - 1; i++) {
for (int i = 0; i < getBulkSystem().getPhase(phaseNum).getNumberOfComponents() - 1; i++) {
redCorrectionMatrix.set(i, 0, (redPhiMatrix.get(0, i) * Math.exp(redPhiMatrix.get(0, i)))
/ (Math.exp(redPhiMatrix.get(0, i)) - (1.0 - 1e-15)));
}
Expand All @@ -228,9 +228,9 @@ public void calcRedCorrectionMatrix(int phaseNum) {
public void calcCorrectionMatrix(int phaseNum) {
Matrix modalPhiMatrix = phiMatrix.eig().getV();
Matrix diagonalRedCorrectionMatrix =
new Matrix(getBulkSystem().getPhases()[phaseNum].getNumberOfComponents() - 1,
getBulkSystem().getPhases()[phaseNum].getNumberOfComponents() - 1);
for (int i = 0; i < getBulkSystem().getPhases()[phaseNum].getNumberOfComponents() - 1; i++) {
new Matrix(getBulkSystem().getPhase(phaseNum).getNumberOfComponents() - 1,
getBulkSystem().getPhase(phaseNum).getNumberOfComponents() - 1);
for (int i = 0; i < getBulkSystem().getPhase(phaseNum).getNumberOfComponents() - 1; i++) {
diagonalRedCorrectionMatrix.set(i, i, redCorrectionMatrix.get(i, 0));
}
rateCorrectionMatrix[phaseNum] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,9 @@ public void calcMolFractionDifference() {
/** {@inheritDoc} */
@Override
public void calcHeatTransferCoefficients(int phaseNum) {
prandtlNumber[phaseNum] = getBulkSystem().getPhases()[phaseNum].getCp()
* getBulkSystem().getPhases()[phaseNum].getPhysicalProperties().getViscosity()
/ getBulkSystem().getPhases()[phaseNum].getPhysicalProperties().getConductivity();
prandtlNumber[phaseNum] = getBulkSystem().getPhase(phaseNum).getCp()
* getBulkSystem().getPhase(phaseNum).getPhysicalProperties().getViscosity()
/ getBulkSystem().getPhase(phaseNum).getPhysicalProperties().getConductivity();
heatTransferCoefficient[phaseNum] = flowNode.getInterphaseTransportCoefficient()
.calcInterphaseHeatTransferCoefficient(phaseNum, prandtlNumber[phaseNum], flowNode);
}
Expand All @@ -423,7 +423,7 @@ public void calcHeatTransferCorrection(int phaseNum) {
double temp = 0;
for (int i = 0; i < bulkSystem.getPhases()[0].getNumberOfMolecularComponents(); i++) {
temp += bulkSystem.getPhases()[0].getComponent(i).getNumberOfMolesInPhase()
* getBulkSystem().getPhases()[phaseNum].getCp() / heatTransferCoefficient[phaseNum];
* getBulkSystem().getPhase(phaseNum).getCp() / heatTransferCoefficient[phaseNum];
}
heatTransferCorrection[phaseNum] = temp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void setEnhancementVec(double[] enhancementVec) {
* @param phaseNum a int
*/
public void setOnesVec(int phaseNum) {
for (int j = 0; j < fluidBoundary.getBulkSystem().getPhases()[phaseNum]
for (int j = 0; j < fluidBoundary.getBulkSystem().getPhase(phaseNum)
.getNumberOfComponents(); j++) {
enhancementVec[j] = 1.0;
}
Expand Down
Loading

0 comments on commit 91c40a2

Please sign in to comment.