Skip to content

Commit

Permalink
Add eos (#409)
Browse files Browse the repository at this point in the history
* Delete .classpath

* Delete .factorypath

* update git ignore

* Added new atractive term

AtractiveTermMatCopPRUMRNew added

* added new alpha term for UMR

* disabled test

* changed to use NeqSim MSAccessDB

* rm invalid doc

* pipe friction update

* update

* Update AtractiveTermMatCopPRUMRNew.java

* Update ComponentEos.java

* Update NeqSimDataBase.java

* updates

* update

* updated UMR Matchias Copeman terms

* update

* update

* further updates

* small change in test

* updated attr.term

* updated vol.translation

* just added simle PR for testing a calculation

* attractive term for nitrogen

* just added simper models to test some calculations

* set volume correction to fals

* updated devcontainer file (#410) (#411)

* updated devcontainer file (#410) (#412)

* added molar volume of two phases

* arbitrary value for translation and tests

* modified componentPRvolcor to make zero the outer get volume correction

* several changes needed to be discussed

* completion of the derivatives of small g and small f with regards to model B,C,V parameters

* loc_C,getc,getC definitions..needing to be connected to translation definition 9with calcCi or omething)

* numerous

* Completion of the dF derivatives-needing changes in the way that all translation elements should be expressed e.g.Ci,cij etc

* changes in volcor and some tests

* Ci change

* some more changes

* more changes..(needing assitance to some printouts for all the F functions in order to compare with mine)

* more

* updates

* chenges in tests

* test to be checked by professor

* I think I fixed the systemtest(see microsoft teams for details)

* fetching also the rest of the derivative tests with the fixed setup

* some changes

* Added UMRCPA

* modified component UMRCPA to not use the fixed a,b,c values of the CPA scheme!

* use of attractive term via the PR EoS

* some modifications that I did to test the volcor functions in mixtures

* setting up the CPA version of my code into Neqsim through overriding the createComponent class+super.method+changing the Tc,Pc,w,ε,β parameters

* ...

* printouts for fugacities

* print outs of fugacity

* ...

* added in CPA an enthalpy printout

* added Hres+Cv

* TESTING...

* ...

* fixed the bug

* further sychronisation of my CPA with Neqsim CPA

* crossscheck of new mc5 attractive term with my code

* fixed radial g in PhaseSRKCPA

* fixed componentSRKCPA original and simplified

* several changes...

* now all fug derivative tests are run for all phases

* crosscheck of arbitrary PR_MC5_CPA EoS with my code-->on the road of fitting

* small correction in dn derivative test

* fugacities test fix

* further correction

* further fix

Co-authored-by: Åsmund Våge Fannemel <ASMF@equinor.com>
Co-authored-by: Åsmund Våge Fannemel <34712686+asmfstatoil@users.noreply.github.com>
Co-authored-by: GeorgeT <47523587+akisTas@users.noreply.github.com>
  • Loading branch information
4 people committed Jul 7, 2022
1 parent 4cfdbb9 commit 4632e45
Show file tree
Hide file tree
Showing 20 changed files with 7,575 additions and 3,664 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ nbdist/
src/main/java/neqsim/util/database/NeqSimDataBase2.java

neqsim.iml
.classpath

.DS_Store

# Test output - Serialized files
test_*.ser

.dccache

#Intellij IDEA
.idea
.idea
729 changes: 367 additions & 362 deletions src/main/java/neqsim/thermo/ThermodynamicModelTest.java

Large diffs are not rendered by default.

4,503 changes: 2,244 additions & 2,259 deletions src/main/java/neqsim/thermo/component/Component.java

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions src/main/java/neqsim/thermo/component/ComponentEos.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import neqsim.thermo.component.attractiveEosTerm.AtractiveTermMatCopPRUMRNew;
import neqsim.thermo.component.attractiveEosTerm.AttractiveTermCPAstatoil;
import neqsim.thermo.component.attractiveEosTerm.AttractiveTermGERG;
import neqsim.thermo.component.attractiveEosTerm.AttractiveTermInterface;
Expand Down Expand Up @@ -176,6 +177,9 @@ public void setAttractiveTerm(int i) {
} else {
setAttractiveParameter(new AttractiveTermSrk(this));
}
} else if (i == 19) {
setAttractiveParameter(
new AtractiveTermMatCopPRUMRNew(this, getMatiascopemanParamsUMRPRU()));
} else {
logger.error("error selecting an alpha formultaion term");
logger.info("ok setting alpha function");
Expand Down Expand Up @@ -225,23 +229,19 @@ public double dFdN(PhaseInterface phase, int numberOfComponents, double temperat

/** {@inheritDoc} */
@Override
public double dFdNdT(PhaseInterface phase, int numberOfComponents, double temperature,
double pressure) {
return (phase.FBT() + phase.FBD() * phase.getAT()) * getBi() + phase.FDT() * getAi()
+ phase.FD() * getAiT();
public double dFdNdT(PhaseInterface phase, int numberOfComponents, double temperature, double pressure) {
return (phase.FBT() + phase.FBD() * phase.getAT()) * getBi() + phase.FDT() * getAi() + phase.FD() * getAiT();
}

/** {@inheritDoc} */
@Override
public double dFdNdV(PhaseInterface phase, int numberOfComponents, double temperature,
double pressure) {
public double dFdNdV(PhaseInterface phase, int numberOfComponents, double temperature, double pressure) {
return phase.FnV() + phase.FBV() * getBi() + phase.FDV() * getAi();
}

/** {@inheritDoc} */
@Override
public double dFdNdN(int j, PhaseInterface phase, int numberOfComponents, double temperature,
double pressure) {
public double dFdNdN(int j, PhaseInterface phase, int numberOfComponents, double temperature, double pressure) {
ComponentEosInterface[] comp_Array = (ComponentEosInterface[]) phase.getcomponentArray();
return phase.FnB() * (getBi() + comp_Array[j].getBi())
+ phase.FBD() * (getBi() * comp_Array[j].getAi() + comp_Array[j].getBi() * getAi())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2208,6 +2208,7 @@ static public LinkedHashMap<String, String> getComponentMap() {
c.put("nC7", "n-heptane");
c.put("nC8", "n-octane");
c.put("nC9", "n-nonane");
c.put("O2", "oxygen");
return c;
}
}
191 changes: 191 additions & 0 deletions src/main/java/neqsim/thermo/component/ComponentPRvolcor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
/*
* System_SRK_EOS.java
*
* Created on 8. april 2000, 23:14
*/
package neqsim.thermo.component;

import neqsim.thermo.phase.PhaseInterface;
import neqsim.thermo.phase.PhasePrEosvolcor;

/**
*
* @author Even Solbraa
* @version
*/
public class ComponentPRvolcor extends ComponentPR {

private static final long serialVersionUID = 1000;
private double c;
// private double calcc;
public double[] Cij = new double[MAX_NUMBER_OF_COMPONENTS];
public double Ci = 0;
public ComponentPRvolcor(int number, double TC, double PC, double M, double a, double moles) {
super(number, TC, PC, M, a, moles);
}

/// ** {@inheritDoc} */
// @Override
public double calcc() {
return (0.1154 - 0.4406 * (0.29056 - 0.08775 * getAcentricFactor())) * R * criticalTemperature
/ criticalPressure;
}

// derivative of translation with regards to temperature
public double calccT() {
return 0.;
}

// second derivative of translation with regards to temperature*temperature
public double calccTT() {
return 0.;
}


public ComponentPRvolcor(String component_name, double moles, double molesInPhase,
int compnumber) {
super(component_name, moles, molesInPhase, compnumber);
c = (0.1154 - 0.4406 * (0.29056 - 0.08775 * getAcentricFactor())) * R * criticalTemperature
/ criticalPressure;

}

/** {@inheritDoc} */
@Override
public void init(double temp, double pres, double totMoles, double beta, int type) {
super.init(temp, pres, totMoles, beta, type);
c = calcc();
}


/** {@inheritDoc} */
// @Override
public double getc() {
return c;
}

public double getcT() {
return 0;
}

// derivative of C with regards to mole fraction
/** {@inheritDoc} */
@Override
public void Finit(PhaseInterface phase, double temp, double pres, double totMoles, double beta,
int numberOfComponents, int type)
{
super.Finit(phase, temp, pres, totMoles, beta, numberOfComponents, type);
Ci = ((PhasePrEosvolcor) phase).calcCi(componentNumber, phase, temp, pres, numberOfComponents);
if (type >= 2) {
((PhasePrEosvolcor) phase).calcCiT(componentNumber, phase, temp, pres,
numberOfComponents);
}

if (type >= 3) {
for (int j = 0; j < numberOfComponents; j++) {
Cij[j] = ((PhasePrEosvolcor) phase).calcCij(componentNumber, j, phase, temp, pres,
numberOfComponents);
}
}
}


public double getCi() {
return Ci;
}


public double getCij(int j) {
return Cij[j];
}

// depending on the type of the volume translation (T-dependent or not) these sould be properly
// modified


// second derivative of C with regards to mole fraction and temperature
public double getCiT() {
return 0;
}

public double getcTT() {
return 0;
}



/// ** {@inheritDoc} */ do I need this inheritDoc thing?
@Override
public double dFdN(PhaseInterface phase, int numberOfComponents, double temperature,
double pressure) {
return phase.Fn() + phase.FB() * getBi() + phase.FD() * getAi()
+ ((PhasePrEosvolcor) phase).FC() * getCi();
}

public double getFC(PhaseInterface phase, int numberOfComponents, double temperature,
double pressure) {
return ((PhasePrEosvolcor) phase).FC();
}


/** {@inheritDoc} */
@Override
public double dFdNdT(PhaseInterface phase, int numberOfComponents, double temperature,
double pressure) {
double loc_CT = ((PhasePrEosvolcor) phase).getCT();
double loc_FnC = ((PhasePrEosvolcor) phase).FnC();
double loc_FBC = ((PhasePrEosvolcor) phase).FBC();
double loc_FCD = ((PhasePrEosvolcor) phase).FCD();
double loc_FC = ((PhasePrEosvolcor) phase).FC();
double loc_FCT = ((PhasePrEosvolcor) phase).FTC();
double loc_FCC = ((PhasePrEosvolcor) phase).FCC();

return loc_FnC * loc_CT
+ (phase.FBT() + phase.FBD() * phase.getAT() + loc_FBC * loc_CT) * getBi()
+ (loc_FCD * loc_CT + phase.FDT()) * getAi()
+ (loc_FCT + loc_FCC * loc_CT + loc_FCD * phase.getAT()) * getCi() + phase.FD() * getAiT()
+ loc_FC * getCiT();
}

/** {@inheritDoc} */
@Override
public double dFdNdN(int j, PhaseInterface phase, int numberOfComponents, double temperature,
double pressure) {
double loc_FnC = ((PhasePrEosvolcor) phase).FnC();
double loc_FBC = ((PhasePrEosvolcor) phase).FBC();
double loc_FCD = ((PhasePrEosvolcor) phase).FCD();
double loc_FC = ((PhasePrEosvolcor) phase).FC();
double loc_FCC = ((PhasePrEosvolcor) phase).FCC();
ComponentEosInterface[] comp_Array = (ComponentEosInterface[]) phase.getcomponentArray();
// return phase.FnB() * (getBi() + comp_Array[j].getBi())
// + phase.FBD() * (getBi() * comp_Array[j].getAi() + comp_Array[j].getBi() * getAi())
// + phase.FB() * getBij(j) + phase.FBB() * getBi() * comp_Array[j].getBi()
// + phase.FD() * getAij(j);
double loc_Cj = ((ComponentPRvolcor) comp_Array[j]).getCi();
// double loc_Ci= ((ComponentPRvolcor))component.getCi();
return phase.FnB() * comp_Array[j].getBi() + loc_FnC * loc_Cj
+ (phase.FnB() + phase.FBB() * comp_Array[j].getBi() + loc_FBC * loc_Cj
+ phase.FBD() * comp_Array[j].getAi()) * getBi()
+ phase.FB() * getBij(j)
+ (loc_FnC + loc_FCC * loc_Cj + loc_FBC * comp_Array[j].getBi()
+ loc_FCD * comp_Array[j].getAi()) * getCi()
+ loc_FC * getCij(j) + (loc_FCD * loc_Cj + phase.FBD() * comp_Array[j].getBi()) * getAi()
+ phase.FD() * getAij(j);
}


/** {@inheritDoc} */
@Override
public double dFdNdV(PhaseInterface phase, int numberOfComponents, double temperature,
double pressure) {
double loc_FCV = ((PhasePrEosvolcor) phase).FCV();
return phase.FnV() + phase.FBV() * getBi() + phase.FDV() * getAi() + loc_FCV * getCi();
}



// Remember this trick above that professor showed to you...you can call whichever new F
// expression
// you need by first specifying the type "PhasePrEosvolcor"

}

0 comments on commit 4632e45

Please sign in to comment.