Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
asmfstatoil committed Nov 25, 2024
1 parent 60f5602 commit 3a114e1
Show file tree
Hide file tree
Showing 16 changed files with 108 additions and 106 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 @@ -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) {
// not implemented
return getGamma(phase, numberOfComponents, temperature, pressure, pt);
}

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
85 changes: 29 additions & 56 deletions src/main/java/neqsim/thermo/component/ComponentGeNRTL.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,68 +34,34 @@ public ComponentGeNRTL(String name, double moles, double molesInPhase, int compI

/** {@inheritDoc} */
@Override
@SuppressWarnings("unused")
public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature,
double pressure, PhaseType pt, double[][] HValpha, double[][] HVgij, double[][] intparam,
String[][] mixRule) {
double type = phase.getInitType();
double A = 0;
double B = 0;
double C = 0;
double D = 0;
double E = 0;
double F = 0;
double ny = 0;
double tau = 0;
double tau2 = 0;
double G = 0;
double G2 = 0;
double alpha = 0;
double Dij = 0;
double Djj = 0;
double Dji = 0;
double Dii = 0;
double gij = 0;
double gjj = 0;
double gji = 0;
double gii = 0;
double F2T = 0;
double tot2 = 0;
int i;
int j;
int l;
int k;
int delta = 0;
double dAdT = 0;
double dBdT = 0;
double dEdT;
double dCdT = 0;
double dFdT = 0;
double dDdT = 0;
double dtaudt = 0;
double dtau2dt = 0;
double dGdt = 0;
double dG2dt = 0;
double[][] Gmatrix = new double[numberOfComponents][numberOfComponents];
double[][] tauMatrix = new double[numberOfComponents][numberOfComponents];
dlngammadn = new double[numberOfComponents];
ComponentInterface[] comp_Array = phase.getcomponentArray();
double lngammaold = 0;
double dlngammadtold = 0;
double dA2dTetter = 0;
double dA3dTetter = 0;
double dA4dTetter = 0;
double dA5dTetter = 0;
double dA6dTetter = 0;
// for(int w=0;w<3;w++){
F = 0;
dFdT = 0;
double F = 0;
dBdT = 0;
dAdT = 0;
dDdT = 0;
A = 0;
B = 0;
dlngammadt = 0.0;
double A = 0;
double B = 0;
dA2dTetter = 0;
dA3dTetter = 0;
dA4dTetter = 0;
Expand All @@ -115,22 +81,24 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp
double dA4dT = 0;
double dA5dT = 0;
double dA6dT = 0;
for (j = 0; j < numberOfComponents; j++) {
Dij = HVgij[this.getComponentNumber()][j];
Dji = HVgij[j][this.getComponentNumber()];
double dFdT = 0.0;
for (int j = 0; j < numberOfComponents; j++) {
double Dij = HVgij[this.getComponentNumber()][j];
double Dji = HVgij[j][this.getComponentNumber()];
// gji = HVgij[j][this.getComponentNumber()];
// gjj = HVgii[j][j];
alpha = HValpha[j][this.getComponentNumber()];
double alpha = HValpha[j][this.getComponentNumber()];
tau = Dji / (temperature);
tau2 = Dij / (temperature);
dtaudt = -tau / temperature;
dtau2dt = -tau2 / temperature;
// System.out.println("method GE1" + tau);

tau2 = Dij / (temperature);
double dtaudt = -tau / temperature;

// System.out.println("error in NRTL here ......");
G = Math.exp(-alpha * tau); // comp_Array[j].getb()*Math.exp(-alpha*tau);
dGdt = dtaudt * -alpha * G;
G2 = Math.exp(-alpha * tau2); // comp_Array[this.getComponentNumber()].getb()*Math.exp(-alpha*tau2);
double dtau2dt = -tau2 / temperature;
dG2dt = dtau2dt * -alpha * G2;

A += tau * G * comp_Array[j].getx();
Expand All @@ -145,13 +113,12 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp
E = G2 * comp_Array[j].getx();
dEdT = dG2dt * comp_Array[j].getx();

C = 0;
D = 0;
dCdT = 0;
dDdT = 0;
// System.out.println("hei");
double C = 0;
double D = 0;
double dCdT = 0;
double dDdT = 0;

for (l = 0; l < numberOfComponents; l++) {
for (int l = 0; l < numberOfComponents; l++) {
Dij = HVgij[l][j];
alpha = HValpha[l][j];
tau = Dij / (temperature);
Expand Down Expand Up @@ -179,15 +146,21 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp
dtau2dt = -tau2 / temperature;

F += E / C * (tau2 - D / C);
dFdT += (dEdT / C - E / (C * C) * dCdT) * (tau2 - D / C)
+ E / C * (dtau2dt - (dDdT / C - D / (C * C) * dCdT));
/*
* dFdT += (dEdT / C - E / (C * C) * dCdT) * (tau2 - D / C) + E / C * (dtau2dt - (dDdT / C - D
* / (C * C) * dCdT));
*/
// F2T = F2T - 2*2*A/Math.pow(C,2) + 2*2*E*D/Math.pow(C,3); // A til A2;
}

lngamma = A / B + F;
double lngamma = A / B + F;
// dlngammadt = dAdT/B - A/(B*B)*dBdT + dFdT;
dlngammadt = (dAdT / B - A / (B * B) * dBdT + dA2dTetter - dA3dTetter + dA4dTetter - dA5dTetter
- dA6dTetter);

/*
* double dlngammadt = (dAdT / B - A / (B * B) * dBdT + dA2dTetter - dA3dTetter + dA4dTetter -
* dA5dTetter - dA6dTetter);
*/

/*
* if(w==0){ dlngammadtold = dlngammadt; temperature +=0.0001; }
*
Expand All @@ -205,7 +178,7 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp
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
5 changes: 3 additions & 2 deletions src/main/java/neqsim/thermo/mixingrule/EosMixingRules.java
Original file line number Diff line number Diff line change
Expand Up @@ -1322,8 +1322,6 @@ public void init(PhaseInterface phase, double temperature, double pressure, int
hwfc = -1.0 / 0.53;
}

double term = 0.0;
double dubdert = 0.0;
if (qPure == null) {
qPure = new double[numbcomp];
qPuredT = new double[numbcomp];
Expand Down Expand Up @@ -1356,6 +1354,9 @@ public void init(PhaseInterface phase, double temperature, double pressure, int

alpha_mix = 0.0;
dadt = 0.0;

double term = 0.0;
double dubdert = 0.0;
for (int i = 0; i < numbcomp; i++) {
term =
qPure[i] + hwfc * Math.log(((ComponentGEInterface) gePhase.getComponent(i)).getGamma());
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/neqsim/thermo/phase/Phase.java
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,13 @@ public PhysicalProperties getPhysicalProperties() {
return physicalPropertyHandler.getPhysicalProperties(this);
}

/** {@inheritDoc} */
/**
* {@inheritDoc}
*
* <p>
* initType used in component.init()
* </p>
*/
@Override
public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt,
double beta) {
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/neqsim/thermo/phase/PhaseCSPsrkEos.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,12 @@ public void addComponent(String name, double moles, double molesInPhase, int com
@Override
public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt,
double beta) {
double oldtemp = temperature;
double oldtemp = getTemperature();
if (initType == 0) {
refBWRSPhase.init(1.0, 1, 0, pt, 1.0);
refBWRSPhase.init(1.0, 1, 3, pt, 1.0);
} else {
refBWRSPhase.init(1.0, 1, 3, pt, 1.0);
}
refBWRSPhase.init(1.0, 1, 3, pt, 1.0);

do {
super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta);
oldtemp = refBWRSPhase.getTemperature();
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/neqsim/thermo/phase/PhaseEos.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,13 @@ public void displayInteractionCoefficients(String intType) {
mixSelect.displayInteractionCoefficients(intType, this);
}

/** {@inheritDoc} */
/**
* {@inheritDoc}
*
* <p>
* Calls component.init(initType)
* </p>
*/
@Override
public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt,
double beta) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/neqsim/thermo/phase/PhaseGEUnifacUMRPRU.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public void setMixingRule(int type) {
@Override
public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents,
double temperature, double pressure, PhaseType pt) {
double GE = 0.0;
calcCommontemp(phase, numberOfComponents, temperature, pressure, pt);
// ((ComponentGEUnifacUMRPRU) phase.getComponent(0)).commonInit(phase, numberOfComponents,
// temperature, pressure, pt);
Expand All @@ -133,6 +132,7 @@ public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents,
if (getInitType() > 2) {
initQmixdN();
}
double GE = 0.0;
for (int i = 0; i < numberOfComponents; i++) {
GE += phase.getComponent(i).getx() * Math.log(((ComponentGEUniquac) componentArray[i])
.getGamma(phase, numberOfComponents, temperature, pressure, pt));
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/neqsim/thermo/phase/PhasePCSAFT.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ public void addComponent(String name, double moles, double molesInPhase, int com
componentArray[compNumber] = new ComponentPCSAFT(name, moles, molesInPhase, compNumber);
}

/** {@inheritDoc} */
/**
* {@inheritDoc}
*
* <p>
* Calls component.Finit(initType)
* </p>
*/
@Override
public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt,
double beta) {
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/neqsim/thermo/phase/PhasePCSAFTRahmat.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public class PhasePCSAFTRahmat extends PhasePCSAFT {
* Constructor for PhasePCSAFTRahmat.
* </p>
*/
public PhasePCSAFTRahmat() {
}
public PhasePCSAFTRahmat() {}

/** {@inheritDoc} */
@Override
Expand All @@ -69,7 +68,13 @@ public void addComponent(String name, double moles, double molesInPhase, int com
componentArray[compNumber] = new ComponentPCSAFT(name, moles, molesInPhase, compNumber);
}

/** {@inheritDoc} */
/**
* {@inheritDoc}
*
* <p>
* Calls component.Finit(initType)
* </p>
*/
@Override
public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt,
double beta) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/neqsim/thermo/system/SystemInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ public default String[] getComponentNames() {
public double getGamma();

/**
* method to return heat capacity ratio calculated as Cp/(Cp-R).
* method to return heat capacity ratio calculated as Cp/(Cp-R*nMoles).
*
* @return kappa
*/
Expand Down Expand Up @@ -1694,8 +1694,6 @@ public default void init() {
*/
public void init(int number);

// public void setPressure(double newPressure, int phaseNumber);

/**
* method to calculate thermodynamic properties of the selected phase. The temperature, pressure,
* number of phases and composition of the phase will be used as basis for calculation.
Expand Down Expand Up @@ -2663,7 +2661,9 @@ public default void setPhysicalPropertyModel(int type) {
public void setForceSinglePhase(String phasetypename);

/**
* <p>isInitialized.</p>
* <p>
* isInitialized.
* </p>
*
* @return a boolean
*/
Expand Down
Loading

0 comments on commit 3a114e1

Please sign in to comment.