Skip to content

Commit

Permalink
Init stuff (#1193)
Browse files Browse the repository at this point in the history
refact: simplify
test: exclude main functions from jacoco
  • Loading branch information
asmfstatoil authored Nov 25, 2024
1 parent 60f5602 commit 148a643
Show file tree
Hide file tree
Showing 191 changed files with 2,543 additions and 2,207 deletions.
5 changes: 1 addition & 4 deletions src/main/java/neqsim/fluidmechanics/flownode/FlowNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,7 @@ public FlowNode clone() {
/** {@inheritDoc} */
@Override
public void init() {
bulkSystem.initBeta();
bulkSystem.init_x_y();
bulkSystem.init(3);
bulkSystem.initPhysicalProperties();
initBulkSystem();
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ public interface FlowNodeInterface extends Cloneable {
*/
public void init();

/**
* <p>
* initBulkSystem.
* </p>
*/
public void initBulkSystem();

/**
* <p>
* getVelocity.
Expand Down Expand Up @@ -700,13 +707,6 @@ public default void setVelocityIn(DoubleCloneable vel) {
// public double calcdVoiddz();
// public double[] calcdxdz();

/**
* <p>
* initBulkSystem.
* </p>
*/
public void initBulkSystem();

/**
* <p>
* display.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void initHeatTransferCalc() {}

/**
* <p>
* init.
* init. Calls interphaseSystem.init(3)
* </p>
*/
public void init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public FlowNodeInterface getNextNode() {
* @param args an array of {@link java.lang.String} objects
*/
@SuppressWarnings("unused")
@ExcludeFromJacocoGeneratedReport
public static void mainOld(String[] args) {
SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 11.0, 60.0);
// SystemInterface testSystem = new SystemSrkCPAstatoil(275.3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,20 @@ public void setSolidMaterial(String solidM) {
public void calcAdsorption(int phaseNum) {
SystemInterface tempSystem = system.clone();
tempSystem.init(3);
double[] bulkFug = new double[system.getPhase(phaseNum).getNumberOfComponents()];
double[] corrx = new double[system.getPhase(phaseNum).getNumberOfComponents()];
surfaceExcess = new double[system.getPhase(phaseNum).getNumberOfComponents()];
surfaceExcessMolFraction = new double[system.getPhase(phaseNum).getNumberOfComponents()];
int numComp = system.getPhase(phaseNum).getNumberOfComponents();

eps0 = new double[system.getPhase(phaseNum).getNumberOfComponents()];
z0 = new double[system.getPhase(phaseNum).getNumberOfComponents()];
beta = new double[system.getPhase(phaseNum).getNumberOfComponents()];
surfaceExcess = new double[numComp];
surfaceExcessMolFraction = new double[numComp];

eps0 = new double[numComp];
z0 = new double[numComp];
beta = new double[numComp];

readDBParameters();

for (int comp = 0; comp < system.getPhase(phaseNum).getNumberOfComponents(); comp++) {
double[] bulkFug = new double[numComp];
double[] corrx = new double[numComp];
for (int comp = 0; comp < numComp; comp++) {
bulkFug[comp] = system.getPhase(phaseNum).getComponent(comp).getx()
* system.getPhase(phaseNum).getComponent(comp).getFugacityCoefficient()
* system.getPhase(phaseNum).getPressure();
Expand All @@ -98,7 +100,7 @@ public void calcAdsorption(int phaseNum) {
iter++;
sumx = 0.0;
pressure = 0.0;
for (int comp = 0; comp < system.getPhase(phaseNum).getNumberOfComponents(); comp++) {
for (int comp = 0; comp < numComp; comp++) {
double correction =
Math.exp(epsField[comp][i] / R / system.getPhase(phaseNum).getTemperature());
fugacityField[comp][i] = correction * bulkFug[comp];
Expand All @@ -108,7 +110,7 @@ public void calcAdsorption(int phaseNum) {
pressure += fugacityField[comp][i]
/ tempSystem.getPhase(phaseNum).getComponent(comp).getFugacityCoefficient();
}
for (int comp = 0; comp < system.getPhase(phaseNum).getNumberOfComponents(); comp++) {
for (int comp = 0; comp < numComp; comp++) {
tempSystem.getPhase(phaseNum).getComponent(comp).setx(corrx[comp]);
sumx += corrx[comp];
}
Expand All @@ -120,7 +122,7 @@ public void calcAdsorption(int phaseNum) {
// Math.abs(sumx - 1.0));
} while (Math.abs(sumx - 1.0) > 1e-12 && iter < 100);

for (int comp = 0; comp < system.getPhase(phaseNum).getNumberOfComponents(); comp++) {
for (int comp = 0; comp < numComp; comp++) {
surfaceExcess[comp] +=
deltaz[comp] * (1.0e5 / tempSystem.getPhase(phaseNum).getMolarVolume()
* tempSystem.getPhase(phaseNum).getComponent(comp).getx()
Expand All @@ -130,10 +132,10 @@ public void calcAdsorption(int phaseNum) {
}

totalSurfaceExcess = 0.0;
for (int comp = 0; comp < system.getPhase(phaseNum).getNumberOfComponents(); comp++) {
for (int comp = 0; comp < numComp; comp++) {
totalSurfaceExcess += surfaceExcess[comp];
}
for (int comp = 0; comp < system.getPhase(phaseNum).getNumberOfComponents(); comp++) {
for (int comp = 0; comp < numComp; comp++) {
surfaceExcessMolFraction[comp] = surfaceExcess[comp] / totalSurfaceExcess;
// logger.info("surface excess molfrac " + surfaceExcessMolFraction[comp] + "
// mol/kg adsorbent " + surfaceExcess[comp]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ public double calcSurfaceTension(int interface1, int interface2) {
}
del_den_interface_old[i] = 0;
}
double interact = 1.0;
double err = 1.0;
int iterations = 0;
while (err > 1e-15 && iterations < 1200) {
Expand Down Expand Up @@ -277,6 +276,7 @@ public double calcSurfaceTension(int interface1, int interface2) {
double kappa = 0.0;
double kappai = 0.0;
double kappak = 0.0;
double interact = 1.0;
for (int i = 0; i < localSystem.getPhase(0).getNumberOfComponents(); i++) {
double infli = influenceParam[i];
// localSystem.getPhase(0).getComponent(i).getSurfaceTenisionInfluenceParameter(localSystem.getPhase(0).getTemperature());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;
import neqsim.util.ExcludeFromJacocoGeneratedReport;

/**
* <p>
Expand Down Expand Up @@ -91,6 +92,7 @@ public void run() {
*
* @param args an array of {@link java.lang.String} objects
*/
@ExcludeFromJacocoGeneratedReport
public static void main(String[] args) {
// SystemInterface tempSystem = new SystemSrkCPAstatoil(273.15 + 120, 100.0);
SystemInterface tempSystem = new SystemSrkEos(273.15 + 120, 100.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;
import neqsim.util.ExcludeFromJacocoGeneratedReport;

/**
* <p>
Expand Down Expand Up @@ -81,6 +82,7 @@ public void run() {
*
* @param args an array of {@link java.lang.String} objects
*/
@ExcludeFromJacocoGeneratedReport
public static void main(String[] args) {
SystemInterface tempSystem = new SystemSrkEos(273.15 + 20, 60.0);
tempSystem.addComponent("nitrogen", 0.34);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;
import neqsim.util.ExcludeFromJacocoGeneratedReport;

/**
* <p>
Expand Down Expand Up @@ -100,6 +101,7 @@ && getThermoSystem().getPhase(0).getType() == PhaseType.GAS) {
*
* @param args an array of {@link java.lang.String} objects
*/
@ExcludeFromJacocoGeneratedReport
public static void main(String[] args) {
SystemInterface tempSystem = new SystemSrkEos(298.0, 300.0);
tempSystem.addComponent("nitrogen", 0.64);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/neqsim/thermo/component/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public abstract class Component implements ComponentInterface {
protected double bCPA = 0.0;
protected double mCPA = 0.0;
protected double srkacentricFactor = 0.0;
// TODO: what are the available options here?
// TODO: what are the available options here? Can also see solute
protected String referenceStateType = "solvent";
protected String associationScheme = "0";
protected String antoineLiqVapPresType = null;
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/neqsim/thermo/component/ComponentBWRS.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ public ComponentBWRS(String name, double moles, double molesInPhase, int compInd
* Constructor for ComponentBWRS.
* </p>
*
* @param number a int
* @param TC a double
* @param PC a double
* @param M a double
* @param a a double
* @param moles a double
* @param number a int. Not used.
* @param TC Critical temperature
* @param PC Critical pressure
* @param M Molar mass
* @param a Acentric factor
* @param moles Total number of moles of component.
*/
public ComponentBWRS(int number, double TC, double PC, double M, double a, double moles) {
super(number, TC, PC, M, a, moles);
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/neqsim/thermo/component/ComponentCSPsrk.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public ComponentCSPsrk(String name, double moles, double molesInPhase, int compI
* Constructor for ComponentCSPsrk.
* </p>
*
* @param number a int
* @param TC a double
* @param PC a double
* @param M a double
* @param a a double
* @param moles a double
* @param number a int. Not used.
* @param TC Critical temperature
* @param PC Critical pressure
* @param M Molar mass
* @param a Acentric factor
* @param moles Total number of moles of component.
*/
public ComponentCSPsrk(int number, double TC, double PC, double M, double a, double moles) {
super(number, TC, PC, M, a, moles);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public ComponentDesmukhMather(String name, double moles, double molesInPhase, in
public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature,
double pressure, PhaseType pt, double[][] HValpha, double[][] HVgij, double[][] intparam,
String[][] mixRule) {
// todo: not actually implemented
return getGamma(phase, numberOfComponents, temperature, pressure, pt);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public ComponentElectrolyteCPA(String name, double moles, double molesInPhase, i
* Constructor for ComponentElectrolyteCPA.
* </p>
*
* @param number a int
* @param TC a double
* @param PC a double
* @param M a double
* @param a a double
* @param moles a double
* @param number a int. Not used.
* @param TC Critical temperature
* @param PC Critical pressure
* @param M Molar mass
* @param a Acentric factor
* @param moles Total number of moles of component.
*/
public ComponentElectrolyteCPA(int number, double TC, double PC, double M, double a,
double moles) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ public ComponentElectrolyteCPAOld(String name, double moles, double molesInPhase
* Constructor for ComponentElectrolyteCPAOld.
* </p>
*
* @param number a int
* @param TC a double
* @param PC a double
* @param M a double
* @param a a double
* @param moles a double
* @param number a int. Not used.
* @param TC Critical temperature
* @param PC Critical pressure
* @param M Molar mass
* @param a Acentric factor
* @param moles Total number of moles of component.
*/
public ComponentElectrolyteCPAOld(int number, double TC, double PC, double M, double a,
double moles) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public ComponentElectrolyteCPAstatoil(String name, double moles, double molesInP
* Constructor for ComponentElectrolyteCPAstatoil.
* </p>
*
* @param number a int
* @param TC a double
* @param PC a double
* @param M a double
* @param a a double
* @param moles a double
* @param number a int. Not used.
* @param TC Critical temperature
* @param PC Critical pressure
* @param M Molar mass
* @param a Acentric factor
* @param moles Total number of moles of component.
*/
public ComponentElectrolyteCPAstatoil(int number, double TC, double PC, double M, double a,
double moles) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/neqsim/thermo/component/ComponentEos.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ public ComponentEos(String name, double moles, double molesInPhase, int compInde
* Constructor for ComponentEos.
* </p>
*
* @param number a int
* @param number a int. Not used.
* @param TC Critical temperature
* @param PC Critical pressure
* @param M Molar mass
* @param a Acentric factor
* @param moles Number of moles
* @param moles Total number of moles of component.
*/
public ComponentEos(int number, double TC, double PC, double M, double a, double moles) {
super(number, TC, PC, M, a, moles);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/neqsim/thermo/component/ComponentGERG2004.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ public ComponentGERG2004(String name, double moles, double molesInPhase, int com
* Constructor for ComponentGERG2004.
* </p>
*
* @param number a int
* @param number a int. Not used.
* @param TC Critical temperature
* @param PC Critical pressure
* @param M Molar mass
* @param a Acentric factor
* @param moles Number of moles
* @param moles Total number of moles of component.
*/
public ComponentGERG2004(int number, double TC, double PC, double M, double a, double moles) {
super(number, TC, PC, M, a, moles);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp
*/
public double getGammaNRTL(PhaseInterface phase, int numberOfComponents, double temperature,
double pressure, PhaseType pt, double[][] HValpha, double[][] HVgij) {
double type = phase.getInitType();
// double ny = 0, Djj = 0, Dii = 0, gij = 0, gjj = 0, gji = 0, gii = 0, F2T = 0, tot2 = 0;
double A = 0;
double B = 0;
Expand Down Expand Up @@ -237,7 +236,7 @@ public double getGammaNRTL(PhaseInterface phase, int numberOfComponents, double
gamma = Math.exp(lngamma);
// System.out.println("gamma " +gamma);
// if derivates....
if (type == 3) {
if (phase.getInitType() == 3) {
double dAdn = 0;
double dBdn = 0;
double Etemp = 0;
Expand Down
Loading

0 comments on commit 148a643

Please sign in to comment.