Skip to content
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

Ref rahmat #944

Closed
wants to merge 6 commits into from
Closed
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
274 changes: 0 additions & 274 deletions src/main/java/neqsim/thermo/phase/PhasePCSAFTRahmat.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@ public PhasePCSAFTRahmat clone() {
return clonedPhase;
}

/** {@inheritDoc} */
@Override
public void addComponent(String name, double moles, double molesInPhase, int compNumber) {
super.addComponent(name, molesInPhase);
componentArray[compNumber] = new ComponentPCSAFT(name, moles, molesInPhase, compNumber);
}

/** {@inheritDoc} */
@Override
public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt,
Expand Down Expand Up @@ -206,100 +199,6 @@ public void volInit() {
+ F2dispZHCdN * dnSAFTdVdVdV;
}

/** {@inheritDoc} */
@Override
public double calcF2dispZHC() {
double temp = 1.0
+ getmSAFT() * (8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2.0))
/ Math.pow(1.0 - getNSAFT(), 4.0)
+ (1.0 - getmSAFT())
* (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2.0) + 12 * Math.pow(getNSAFT(), 3.0)
- 2 * Math.pow(getNSAFT(), 4.0))
/ Math.pow((1.0 - getNSAFT()) * (2.0 - getNSAFT()), 2.0);
return 1.0 / temp;
}

/** {@inheritDoc} */
@Override
public double calcF2dispZHCdm() {
double temp = -Math.pow(F2dispZHC, 2.0);
return temp
* ((8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2.0)) / Math.pow(1.0 - getNSAFT(), 4.0)
- (20 * getNSAFT() - 27 * Math.pow(getNSAFT(), 2.0) + 12 * Math.pow(getNSAFT(), 3.0)
- 2 * Math.pow(getNSAFT(), 4.0))
/ Math.pow((1.0 - getNSAFT()) * (2.0 - getNSAFT()), 2.0));
}

/** {@inheritDoc} */
@Override
public double calcF2dispZHCdN() {
double temp0 = -Math.pow(F2dispZHC, 2.0);
double temp1 = Math.pow((1.0 - getNSAFT()) * (2.0 - getNSAFT()), 2.0);
double temp2 = 20.0 * getNSAFT() - 27.0 * Math.pow(getNSAFT(), 2.0)
+ 12.0 * Math.pow(getNSAFT(), 3.0) - 2.0 * Math.pow(getNSAFT(), 4.0);
// ikke rett implementert
return temp0 * (getmSAFT()
* ((8.0 - 4.0 * getNSAFT()) * Math.pow(1.0 - getNSAFT(), 4.0)
- 4.0 * Math.pow(1.0 - getNSAFT(), 3.0) * (-1.0)
* (8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2.0)))
/ Math.pow(1.0 - getNSAFT(), 8.0)
+ (1.0 - getmSAFT()) * ((20.0 - (2.0 * 27.0) * getNSAFT()
+ (12.0 * 3.0) * Math.pow(getNSAFT(), 2.0) - 8.0 * Math.pow(getNSAFT(), 3.0)) * temp1
- (2.0 * (2.0 - 3.0 * getNSAFT() + Math.pow(getNSAFT(), 2.0))
* (-3.0 + 2.0 * getNSAFT())) * temp2)
/ Math.pow(temp1, 2.0));
}

/** {@inheritDoc} */
@Override
public double calcF2dispZHCdNdN() {
double temp0 = 2.0 * Math.pow(F2dispZHC, 3.0);
double temp1 = Math.pow((1.0 - getNSAFT()) * (2.0 - getNSAFT()), 2.0);
double temp11 = Math.pow((1.0 - getNSAFT()) * (2.0 - getNSAFT()), 3.0);
double temp2 = 20.0 * getNSAFT() - 27.0 * Math.pow(getNSAFT(), 2.0)
+ 12.0 * Math.pow(getNSAFT(), 3.0) - 2.0 * Math.pow(getNSAFT(), 4.0);

double temp1der =
2.0 * (2.0 - 3.0 * getNSAFT() + Math.pow(getNSAFT(), 2.0)) * (-3.0 + 2.0 * getNSAFT());
double temp11der = 3.0 * Math.pow(2.0 - 3.0 * getNSAFT() + Math.pow(getNSAFT(), 2.0), 2.0)
* (-3.0 + 2.0 * getNSAFT());
// ikke rett implementert
double temp3 = (getmSAFT()
* ((8.0 - 4.0 * getNSAFT()) * Math.pow(1.0 - getNSAFT(), 4.0)
- 4.0 * Math.pow(1.0 - getNSAFT(), 3.0) * (-1.0)
* (8.0 * getNSAFT() - 2.0 * Math.pow(getNSAFT(), 2.0)))
/ Math.pow(1.0 - getNSAFT(), 8.0)
+ (1.0 - getmSAFT()) * ((20.0 - (2.0 * 27.0) * getNSAFT()
+ (12.0 * 3.0) * Math.pow(getNSAFT(), 2.0) - 8.0 * Math.pow(getNSAFT(), 3.0)) * temp1
- (2.0 * (2.0 - 3.0 * getNSAFT() + Math.pow(getNSAFT(), 2.0))
* (-3.0 + 2.0 * getNSAFT())) * temp2)
/ Math.pow(temp1, 2.0));

double temp4 = -Math.pow(F2dispZHC, 2.0);
double dZdndn = getmSAFT()
* ((-4.0 * Math.pow(1.0 - getNSAFT(), 4.0)
- 4.0 * Math.pow(1.0 - getNSAFT(), 3.0) * (-1.0) * (8.0 - 4.0 * getNSAFT()))
/ Math.pow(1.0 - getNSAFT(), 8.0)
+ ((32.0 - 16.0 * getNSAFT()) * Math.pow(1.0 - getNSAFT(), 5.0)
- 5.0 * Math.pow(1.0 - getNSAFT(), 4.0) * (-1.0)
* (32.0 * getNSAFT() - 8.0 * Math.pow(getNSAFT(), 2.0)))
/ Math.pow(1.0 - getNSAFT(), 10.0))
+ (1.0 - getmSAFT())
* (((-54.0 + 72.0 * getNSAFT() - 24.0 * Math.pow(getNSAFT(), 2.0)) * temp1
- temp1der * (20.0 - 54.0 * getNSAFT() + 36.0 * Math.pow(getNSAFT(), 2.0)
- 8.0 * Math.pow(getNSAFT(), 3.0)))
/ Math.pow(temp1, 2.0)
- ((-40.0 * Math.pow(getNSAFT(), 4.0) + 240.0 * Math.pow(getNSAFT(), 3.0)
- 3.0 * 180.0 * Math.pow(getNSAFT(), 2.0) + 242.0 * 2.0 * getNSAFT() - 120.0)
* temp11
- temp11der * (-8.0 * Math.pow(getNSAFT(), 5.0)
+ 60.0 * Math.pow(getNSAFT(), 4.0) - 180.0 * Math.pow(getNSAFT(), 3.0)
+ 242.0 * Math.pow(getNSAFT(), 2.0) - 120.0 * getNSAFT()))
/ Math.pow(temp11, 2.0));

return temp0 * Math.pow(temp3, 2.0) + temp4 * dZdndn;
}

/**
* <p>
* calcF2dispZHCdNdNdN.
Expand Down Expand Up @@ -457,37 +356,6 @@ public double calcdF2dispZHCdT() {
return temp0 * (temp1 + temp2);
}

/** {@inheritDoc} */
@Override
public double calcmSAFT() {
double temp2 = 0.0;
for (int i = 0; i < numberOfComponents; i++) {
temp2 += getComponent(i).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi()
/ getNumberOfMolesInPhase();
}

return temp2;
}

/** {@inheritDoc} */
@Override
public double calcF1dispSumTerm() {
double temp1 = 0.0;

for (int i = 0; i < numberOfComponents; i++) {
for (int j = 0; j < numberOfComponents; j++) {
temp1 +=
getComponent(i).getNumberOfMolesInPhase() * getComponent(j).getNumberOfMolesInPhase()
* getComponent(i).getmSAFTi() * getComponent(j).getmSAFTi()
* Math.sqrt(getComponent(i).getEpsikSAFT() / temperature
* getComponent(j).getEpsikSAFT() / temperature)
* (1.0 - mixRule.getBinaryInteractionParameter(i, j)) * Math.pow(
0.5 * (getComponent(i).getSigmaSAFTi() + getComponent(j).getSigmaSAFTi()), 3.0);
}
}
return temp1 / Math.pow(getNumberOfMolesInPhase(), 2.0);
}

// added by rahmat
/**
* <p>
Expand Down Expand Up @@ -539,43 +407,6 @@ public double calcdF2dispSumTermdT() {
return temp1 / Math.pow(getNumberOfMolesInPhase(), 2.0);
}

/** {@inheritDoc} */
@Override
public double calcF2dispSumTerm() {
double temp1 = 0.0;
for (int i = 0; i < numberOfComponents; i++) {
for (int j = 0; j < numberOfComponents; j++) {
temp1 += getComponent(i).getNumberOfMolesInPhase()
* getComponent(j).getNumberOfMolesInPhase() * getComponent(i).getmSAFTi()
* getComponent(j).getmSAFTi() * getComponent(i).getEpsikSAFT() / temperature
* getComponent(j).getEpsikSAFT() / temperature
* Math.pow((1.0 - mixRule.getBinaryInteractionParameter(i, j)), 2.0) * Math.pow(
0.5 * (getComponent(i).getSigmaSAFTi() + getComponent(j).getSigmaSAFTi()), 3.0);
}
}
return temp1 / Math.pow(getNumberOfMolesInPhase(), 2.0);
}

/** {@inheritDoc} */
@Override
public double calcF1dispI1dN() {
double temp1 = 0.0;
for (int i = 1; i < 7; i++) {
temp1 += i * getaSAFT(i, getmSAFT(), aConstSAFT) * Math.pow(getNSAFT(), i - 1.0);
}
return temp1;
}

/** {@inheritDoc} */
@Override
public double calcF1dispI1dNdN() {
double temp1 = 0.0;
for (int i = 2; i < 7; i++) {
temp1 += (i - 1.0) * i * getaSAFT(i, getmSAFT(), aConstSAFT) * Math.pow(getNSAFT(), i - 2.0);
}
return temp1;
}

// added by Rahmat
/**
* <p>
Expand All @@ -593,16 +424,6 @@ public double calcF1dispI1dNdNdN() {
return temp1;
}

/** {@inheritDoc} */
@Override
public double calcF1dispI1dm() {
double temp1 = 0.0;
for (int i = 0; i < 7; i++) {
temp1 += getaSAFTdm(i, getmSAFT(), aConstSAFT) * Math.pow(getNSAFT(), i);
}
return temp1;
}

/** {@inheritDoc} */
@Override
public double calcF2dispI2dN() {
Expand Down Expand Up @@ -639,26 +460,6 @@ public double calcF2dispI2dNdNdN() {
return temp1;
}

/** {@inheritDoc} */
@Override
public double calcF2dispI2dm() {
double temp1 = 0.0;
for (int i = 0; i < 7; i++) {
temp1 += getaSAFTdm(i, getmSAFT(), bConstSAFT) * Math.pow(getNSAFT(), i);
}
return temp1;
}

/** {@inheritDoc} */
@Override
public double calcF1dispI1() {
double temp1 = 0.0;
for (int i = 0; i < 7; i++) {
temp1 += getaSAFT(i, getmSAFT(), aConstSAFT) * Math.pow(getNSAFT(), i);
}
return temp1;
}

// added by rahmat
/**
* <p>
Expand Down Expand Up @@ -846,15 +647,6 @@ public double F_DISP1_SAFT() {
* getF1dispVolTerm() * getF1dispSumTerm() * getF1dispI1()); // (ThermodynamicConstantsInterface.R*temperature);
}

/** {@inheritDoc} */
@Override
public double dF_DISP1_SAFTdV() {
return getNumberOfMolesInPhase() * (-2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTermdV
* getF1dispSumTerm() * getF1dispI1()
- 2.0 * ThermodynamicConstantsInterface.pi * F1dispVolTerm * getF1dispSumTerm()
* F1dispI1dV); // (ThermodynamicConstantsInterface.R*temperature);
}

/** {@inheritDoc} */
@Override
public double dF_DISP1_SAFTdVdV() {
Expand Down Expand Up @@ -933,40 +725,6 @@ public double F_DISP2_SAFT() {
// (ThermodynamicConstantsInterface.R*temperature);
}

/** {@inheritDoc} */
@Override
public double dF_DISP2_SAFTdV() {
return getNumberOfMolesInPhase() * (-ThermodynamicConstantsInterface.pi * getmSAFT()
* F1dispVolTermdV * getF2dispSumTerm() * getF2dispI2() * getF2dispZHC()
- ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm()
* F2dispI2dV * getF2dispZHC()
- ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm()
* getF2dispI2() * F2dispZHCdV); // (ThermodynamicConstantsInterface.R*temperature);
}

/** {@inheritDoc} */
@Override
public double dF_DISP2_SAFTdVdV() {
return getNumberOfMolesInPhase() * ((-ThermodynamicConstantsInterface.pi * getmSAFT()
* F1dispVolTermdVdV * getF2dispSumTerm() * getF2dispI2() * getF2dispZHC())
- (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm()
* getF2dispZHC() * F2dispI2dV)
- (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm()
* getF2dispI2() * F2dispZHCdV)
- ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm()
* F2dispI2dV * getF2dispZHC()
- ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm()
* F2dispI2dVdV * getF2dispZHC()
- ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm()
* F2dispI2dV * F2dispZHCdV
- (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTermdV * getF2dispSumTerm()
* getF2dispI2() * F2dispZHCdV)
- (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm()
* F2dispI2dV * F2dispZHCdV)
- (ThermodynamicConstantsInterface.pi * getmSAFT() * F1dispVolTerm * getF2dispSumTerm()
* getF2dispI2() * F2dispZHCdVdV));
}

/**
* <p>
* dF_DISP2_SAFTdVdVdV.
Expand Down Expand Up @@ -1049,37 +807,6 @@ public double dF_DISP2_SAFTdVdVdV() {
* getF2dispI2() * F2dispZHCdVdVdV));
}

/** {@inheritDoc} */
@Override
public double getF() {
// System.out.println("F-HC " + useHS*F_HC_SAFT());

// System.out.println("F-DISP1 " + useDISP1*F_DISP1_SAFT());

// System.out.println("F-DISP2 " + useDISP2*F_DISP2_SAFT());
return useHS * F_HC_SAFT() + useDISP1 * F_DISP1_SAFT() + useDISP2 * F_DISP2_SAFT();
}

/** {@inheritDoc} */
@Override
public double dFdV() {
// System.out.println("N-saft " + getNSAFT());
// System.out.println("F-HC " + useHS*F_HC_SAFT());
// System.out.println("F-DISP1 " + useDISP1*F_DISP1_SAFT());

// System.out.println("F-DISP2 " + useDISP2*F_DISP2_SAFT());

return (useHS * dF_HC_SAFTdV() + useDISP1 * dF_DISP1_SAFTdV() + useDISP2 * dF_DISP2_SAFTdV())
* 1.0e-5;
}

/** {@inheritDoc} */
@Override
public double dFdVdV() {
return (useHS * dF_HC_SAFTdVdV() + useDISP1 * dF_DISP1_SAFTdVdV()
+ useDISP2 * dF_DISP2_SAFTdVdV()) * 1.0e-10;
}

/** {@inheritDoc} */
@Override
public double dFdVdVdV() {
Expand Down Expand Up @@ -1138,7 +865,6 @@ public double molarVolume(double pressure, double temperature, double A, double
setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase);
int iterations = 0;
double oldMolarVolume = 0.0;
// System.out.println("volume " + getVolume());
do {
iterations++;
this.volInit();
Expand Down
Loading