Skip to content

refact: use java.lang.Math.log10 #273

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

Merged
merged 1 commit into from
Jan 6, 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
32 changes: 0 additions & 32 deletions src/main/java/neqsim/MathLib/generalMath/GeneralMath.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package neqsim.fluidMechanics.flowNode.fluidBoundary.interphaseTransportCoefficient;

import neqsim.MathLib.generalMath.GeneralMath;
import neqsim.fluidMechanics.flowNode.FlowNodeInterface;

/**
Expand Down Expand Up @@ -31,7 +30,7 @@ public InterphaseTransportCoefficientBaseClass(FlowNodeInterface node) {
/** {@inheritDoc} */
@Override
public double calcWallFrictionFactor(FlowNodeInterface node) {
return calcWallFrictionFactor(0,node);
return calcWallFrictionFactor(0, node);
}

/** {@inheritDoc} */
Expand All @@ -41,7 +40,7 @@ public double calcWallFrictionFactor(int phase, FlowNodeInterface node) {
return 64.0 / node.getReynoldsNumber(phase);
} else {
return Math.pow(
(1.0 / (-1.8 * GeneralMath.log10(6.9 / node.getReynoldsNumber(phase)
(1.0 / (-1.8 * Math.log10(6.9 / node.getReynoldsNumber(phase)
+ Math.pow(node.getGeometry().getRelativeRoughnes() / 3.7, 1.11)))),
2.0);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package neqsim.fluidMechanics.flowNode.fluidBoundary.interphaseTransportCoefficient.interphaseOnePhase.interphasePipeFlow;

import neqsim.MathLib.generalMath.GeneralMath;
import neqsim.fluidMechanics.flowNode.FlowNodeInterface;
import neqsim.fluidMechanics.flowNode.fluidBoundary.interphaseTransportCoefficient.interphaseOnePhase.InterphaseOnePhase;

Expand Down Expand Up @@ -31,7 +30,7 @@ public InterphasePipeFlow(FlowNodeInterface node) {
/** {@inheritDoc} */
@Override
public double calcWallFrictionFactor(FlowNodeInterface node) {
return calcWallFrictionFactor(0,node);
return calcWallFrictionFactor(0, node);
}

/** {@inheritDoc} */
Expand All @@ -41,9 +40,7 @@ public double calcWallFrictionFactor(int phase, FlowNodeInterface node) {
return 64.0 / node.getReynoldsNumber(phase);
} else {
return Math.pow(
(1.0 / (-1.8 * GeneralMath.log10(6.9 / node.getReynoldsNumber(phase)
+ Math.pow(node.getGeometry().getRelativeRoughnes() / 3.7, 1.11)))),
2.0);
(1.0 / (-1.8 * Math.log10(6.9 / node.getReynoldsNumber(phase)+ Math.pow(node.getGeometry().getRelativeRoughnes() / 3.7, 1.11)))),2.0);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package neqsim.fluidMechanics.flowNode.fluidBoundary.interphaseTransportCoefficient.interphaseTwoPhase.interphasePipeFlow;

import neqsim.MathLib.generalMath.GeneralMath;
import neqsim.fluidMechanics.flowNode.FlowNodeInterface;

/**
Expand Down Expand Up @@ -35,7 +34,7 @@ public double calcWallFrictionFactor(int phase, FlowNodeInterface node) {
return 64.0 / node.getReynoldsNumber(phase);
} else {
return Math.pow(
(1.0 / (-1.8 * GeneralMath.log10(6.9 / node.getReynoldsNumber(phase)
(1.0 / (-1.8 * Math.log10(6.9 / node.getReynoldsNumber(phase)
+ Math.pow(node.getGeometry().getRelativeRoughnes() / 3.7, 1.11)))),
2.0);
}
Expand Down Expand Up @@ -164,7 +163,7 @@ public double calcInterphaseMassTransferCoefficient(int phase, double schmidtNum
// node.getReynoldsNumber(phase) + " COMP " + );
return massTrans;
}

// public double calcInterphaseMassTransferCoefficient(int phase, double schmidtNumber,
// FlowNodeInterface node){
// double redMassTrans=0.0, massTrans=0.0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package neqsim.fluidMechanics.flowNode.fluidBoundary.interphaseTransportCoefficient.interphaseTwoPhase.interphasePipeFlow;

import neqsim.MathLib.generalMath.GeneralMath;
import neqsim.fluidMechanics.flowNode.FlowNodeInterface;

/**
Expand Down Expand Up @@ -35,7 +34,7 @@ public double calcWallFrictionFactor(int phase, FlowNodeInterface node) {
return 64.0 / node.getReynoldsNumber(phase);
} else {
return Math.pow(
(1.0 / (-1.8 * GeneralMath.log10(6.9 / node.getReynoldsNumber(phase)
(1.0 / (-1.8 * Math.log10(6.9 / node.getReynoldsNumber(phase)
+ Math.pow(node.getGeometry().getRelativeRoughnes() / 3.7, 1.11)))),
2.0);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package neqsim.fluidMechanics.flowNode.multiPhaseNode;

import neqsim.MathLib.generalMath.GeneralMath;
import neqsim.fluidMechanics.flowNode.FlowNode;
import neqsim.fluidMechanics.flowNode.twoPhaseNode.TwoPhaseFlowNode;
import neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface;
Expand Down Expand Up @@ -181,7 +180,7 @@ public double calcReynoldNumber() {
public double calcWallFrictionFactor() {
for (int i = 0; i < 2; i++) {
wallFrictionFactor[i] = Math.pow(
(1.0 / (-1.8 * GeneralMath.log10(6.9 / getReynoldsNumber(i) * Math.pow(
(1.0 / (-1.8 * Math.log10(6.9 / getReynoldsNumber(i) * Math.pow(
pipe.getRelativeRoughnes(this.getHydraulicDiameter(i)) / 3.7, 1.11)))),
2.0);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package neqsim.fluidMechanics.flowNode.twoPhaseNode;

import neqsim.MathLib.generalMath.GeneralMath;
import neqsim.fluidMechanics.flowNode.FlowNode;
import neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.FluidBoundaryInterface;
import neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface;
Expand Down Expand Up @@ -202,7 +201,7 @@ public double calcReynoldNumber() {
public double calcWallFrictionFactor() {
for (int i = 0; i < 2; i++) {
wallFrictionFactor[i] = Math.pow(
(1.0 / (-1.8 * GeneralMath.log10(6.9 / getReynoldsNumber(i) * Math.pow(
(1.0 / (-1.8 * Math.log10(6.9 / getReynoldsNumber(i) * Math.pow(
pipe.getRelativeRoughnes(this.getHydraulicDiameter(i)) / 3.7, 1.11)))),
2.0);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package neqsim.processSimulation.processEquipment.pipeline;

import neqsim.MathLib.generalMath.GeneralMath;
import neqsim.fluidMechanics.flowSystem.FlowSystemInterface;
import neqsim.processSimulation.mechanicalDesign.pipeline.PipelineMechanicalDeisgn;
import neqsim.processSimulation.processEquipment.stream.Stream;
Expand Down Expand Up @@ -119,7 +118,7 @@ public double calcWallFrictionFactor(double reynoldsNumber) {
} else {
flowPattern = "turbulent";
return Math.pow(
(1.0 / (-1.8 * GeneralMath
(1.0 / (-1.8 * Math
.log10(6.9 / reynoldsNumber + Math.pow(relativeRoughnes / 3.7, 1.11)))),
2.0);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package neqsim.processSimulation.processEquipment.pipeline;

import neqsim.MathLib.generalMath.GeneralMath;
import neqsim.fluidMechanics.flowSystem.FlowSystemInterface;
import neqsim.processSimulation.mechanicalDesign.pipeline.PipelineMechanicalDeisgn;
import neqsim.processSimulation.processEquipment.stream.Stream;
Expand Down Expand Up @@ -128,7 +127,7 @@ public double calcWallFrictionFactor(double reynoldsNumber) {
} else {
flowPattern = "turbulent";
return Math.pow(
(1.0 / (-1.8 * GeneralMath
(1.0 / (-1.8 * Math
.log10(6.9 / reynoldsNumber + Math.pow(relativeRoughnes / 3.7, 1.11)))),
2.0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

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

import neqsim.thermo.system.SystemInterface;

/**
Expand Down Expand Up @@ -69,8 +68,7 @@ public double calcAcentricFactor(double molarMass, double density) {
double TC = calcTC(molarMass, density);
double TB = calcTB(molarMass, density);
double PC = calcPC(molarMass, density);
return 3.0 / 7.0 * neqsim.MathLib.generalMath.GeneralMath.log10(PC / 1.01325)
/ (TC / TB - 1.0) - 1.0;
return 3.0 / 7.0 * Math.log10(PC / 1.01325) / (TC / TB - 1.0) - 1.0;
}

@Override
Expand Down Expand Up @@ -273,8 +271,7 @@ public double calcAcentricFactor2(double molarMass, double density) {
double TC = calcTC(molarMass, density);
double TB = calcTB(molarMass, density);
double PC = calcPC(molarMass, density);
return 3.0 / 7.0 * neqsim.MathLib.generalMath.GeneralMath.log10(PC / 1.01325)
/ (TC / TB - 1.0) - 1.0;
return 3.0 / 7.0 * Math.log10(PC / 1.01325) / (TC / TB - 1.0) - 1.0;
}

@Override
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/neqsim/thermo/phase/Phase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1821,8 +1821,8 @@ public double getpH() {
// initPhysicalProperties();
// for(int i = 0; i<numberOfComponents; i++) {
// if(componentArray[i].getName().equals("H3O+")){
// return -
// MathLib.generalMath.GeneralMath.log10(componentArray[i].getNumberOfMolesInPhase()*getPhysicalProperties().getDensity()/(numberOfMolesInPhase*getMolarMass())*1e-3);
// return
// -Math.log10(componentArray[i].getNumberOfMolesInPhase()*getPhysicalProperties().getDensity()/(numberOfMolesInPhase*getMolarMass())*1e-3);
// }
// }
// System.out.println("no H3Oplus");
Expand All @@ -1839,11 +1839,10 @@ public double getpH() {
public double getpH_old() {
for (int i = 0; i < numberOfComponents; i++) {
if (componentArray[i].getName().equals("H3O+")) {
// return -neqsim.MathLib.generalMath.GeneralMath.log10(componentArray[i].getx()
// return -Math.log10(componentArray[i].getx()
// * getActivityCoefficient(i));
return -java.lang.Math.log10(componentArray[i].getx() * getActivityCoefficient(i)
/ (0.01802 * neqsim.thermo.util.empiric.Water.waterDensity(temperature)
/ 1000.0));
return -Math.log10(componentArray[i].getx() * getActivityCoefficient(i) / (0.01802
* neqsim.thermo.util.empiric.Water.waterDensity(temperature) / 1000.0));
}
}
logger.info("no H3Oplus");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/neqsim/thermo/system/SystemThermo.java
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo
// Math.pow((molarMass/5.805e-5*Math.pow(density,0.9371)), 1.0/2.3776);
// acs = TBPfractionModel.calcAcentricFactor(molarMass, density);
// System.out.println("acentric " + acs);
// 3.0/7.0*MathLib.generalMath.GeneralMath.log10(PC/1.01325)/(TC/TB-1.0)-1.0;
// 3.0/7.0*Math.log10(PC/1.01325)/(TC/TB-1.0)-1.0;
molarMass /= 1000.0;

for (int i = 0; i < refSystem.getNumberOfPhases(); i++) {
Expand Down