Skip to content

Commit

Permalink
refact: introduce MixingRulesInterface, getName()
Browse files Browse the repository at this point in the history
  • Loading branch information
asmfstatoil committed Jan 9, 2025
1 parent 0b06ba1 commit 381a968
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 44 deletions.
45 changes: 37 additions & 8 deletions src/main/java/neqsim/thermo/mixingrule/CPAMixingRules.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public class CPAMixingRules implements Cloneable, ThermodynamicConstantsInterfac
/** Logger object for class. */
static Logger logger = LogManager.getLogger(CPAMixingRules.class);

/** Name of mixing rule. */
private String mixingRuleName = "CPA_Radoch";

int[][] assosSchemeType = null; // 0- ER - 1 - CR1
double[][] cpaBetaCross = null;
double[][] cpaEpsCross = null;
Expand Down Expand Up @@ -73,48 +76,56 @@ public double calcXi(int siteNumber, int compnumb, PhaseInterface phase, double
return 1.0;
}

/** {@inheritdoc} */
@Override
public double calcXi(int[][][] assosScheme, int[][][][] assosScheme2, int siteNumber,
int compnumb, PhaseInterface phase, double temperature, double pressure, int numbcomp) {
return 1.0;
}

/** {@inheritdoc} */
@Override
public double calcDelta(int siteNumber1, int siteNumber2, int compnumb1, int compnumb2,
PhaseInterface phase, double temperature, double pressure, int numbcomp) {
return 1.0;
}

/** {@inheritdoc} */
@Override
public double calcDeltaNog(int siteNumber1, int siteNumber2, int compnumb1, int compnumb2,
PhaseInterface phase, double temperature, double pressure, int numbcomp) {
return 1.0;
}

/** {@inheritdoc} */
@Override
public double calcDeltadN(int derivativeComp, int siteNumber1, int siteNumber2, int compnumb1,
int compnumb2, PhaseInterface phase, double temperature, double pressure, int numbcomp) {
return 1.0;
}

/** {@inheritdoc} */
@Override
public double calcDeltadT(int siteNumber1, int siteNumber2, int compnumb1, int compnumb2,
PhaseInterface phase, double temperature, double pressure, int numbcomp) {
return 1.0;
}

/** {@inheritdoc} */
@Override
public double calcDeltadV(int siteNumber1, int siteNumber2, int compnumb1, int compnumb2,
PhaseInterface phase, double temperature, double pressure, int numbcomp) {
return 1.0;
}

/** {@inheritdoc} */
@Override
public double calcDeltadTdT(int siteNumber1, int siteNumber2, int compnumb1, int compnumb2,
PhaseInterface phase, double temperature, double pressure, int numbcomp) {
return 1.0;
}

/** {@inheritdoc} */
@Override
public double calcDeltadTdV(int siteNumber1, int siteNumber2, int compnumb1, int compnumb2,
PhaseInterface phase, double temperature, double pressure, int numbcomp) {
Expand All @@ -126,6 +137,12 @@ public class CPA_Radoch extends CPA_Radoch_base {
/** Serialization version UID. */
private static final long serialVersionUID = 1000;

/** {@inheritdoc} */
@Override
public String getName() {
return mixingRuleName;
}

public double getCrossAssociationEnergy(int compnumb1, int compnumb2, PhaseInterface phase,
double temperature, double pressure, int numbcomp) {
if (Math.abs(cpaEpsCross[compnumb1][compnumb2]) > 1e-10) {
Expand Down Expand Up @@ -154,6 +171,7 @@ public double getCrossAssociationVolume(int compnumb1, int compnumb2, PhaseInter
* phase.getComponent(compnumb2).getAssociationVolume());
}

/** {@inheritdoc} */
@Override
public double calcDelta(int siteNumber1, int siteNumber2, int compnumb1, int compnumb2,
PhaseInterface phase, double temperature, double pressure, int numbcomp) {
Expand Down Expand Up @@ -230,6 +248,7 @@ public double calcDelta(int compnumb1, int compnumb2, PhaseInterface phase, doub
* ((PhaseCPAInterface) phase).getGcpa();
}

/** {@inheritdoc} */
@Override
public double calcDeltaNog(int siteNumber1, int siteNumber2, int compnumb1, int compnumb2,
PhaseInterface phase, double temperature, double pressure, int numbcomp) {
Expand Down Expand Up @@ -266,6 +285,7 @@ public double calcDeltaNog(int siteNumber1, int siteNumber2, int compnumb1, int
* getCrossAssociationVolume(compnumb1, compnumb2, phase, temperature, pressure, numbcomp);
}

/** {@inheritdoc} */
@Override
public double calcDeltadN(int derivativeComp, int siteNumber1, int siteNumber2, int compnumb1,
int compnumb2, PhaseInterface phase, double temperature, double pressure, int numbcomp) {
Expand All @@ -275,6 +295,7 @@ public double calcDeltadN(int derivativeComp, int siteNumber1, int siteNumber2,
* ((ComponentSrkCPA) phase.getComponent(derivativeComp)).calc_lngi(phase);
}

/** {@inheritdoc} */
@Override
public double calcDeltadT(int siteNumber1, int siteNumber2, int compnumb1, int compnumb2,
PhaseInterface phase, double temperature, double pressure, int numbcomp) {
Expand Down Expand Up @@ -337,6 +358,7 @@ public double calcDeltadT(int siteNumber1, int siteNumber2, int compnumb1, int c
* ((PhaseCPAInterface) phase).getGcpa();
}

/** {@inheritdoc} */
@Override
public double calcDeltadV(int siteNumber1, int siteNumber2, int compnumb1, int compnumb2,
PhaseInterface phase, double temperature, double pressure, int numbcomp) {
Expand All @@ -346,6 +368,7 @@ public double calcDeltadV(int siteNumber1, int siteNumber2, int compnumb1, int c
* ((PhaseCPAInterface) phase).getGcpav();
}

/** {@inheritdoc} */
@Override
public double calcDeltadTdV(int siteNumber1, int siteNumber2, int compnumb1, int compnumb2,
PhaseInterface phase, double temperature, double pressure, int numbcomp) {
Expand Down Expand Up @@ -380,6 +403,7 @@ public double calcDeltadTdV(int siteNumber1, int siteNumber2, int compnumb1, int
* ((PhaseCPAInterface) phase).getGcpa() * ((PhaseCPAInterface) phase).getGcpav();
}

/** {@inheritdoc} */
@Override
public double calcDeltadTdT(int siteNumber1, int siteNumber2, int compnumb1, int compnumb2,
PhaseInterface phase, double temperature, double pressure, int numbcomp) {
Expand Down Expand Up @@ -561,6 +585,7 @@ public double getCrossAssociationVolume(int siteNumber1, int siteNumber2, int co
* phase.getComponent(compnumb2).getAssociationVolumeSAFT()) * extrwterm;
}

/** {@inheritdoc} */
@Override
public double calcDelta(int siteNumber1, int siteNumber2, int compnumb1, int compnumb2,
PhaseInterface phase, double temperature, double pressure, int numbcomp) {
Expand All @@ -585,17 +610,21 @@ public double calcDelta(int siteNumber1, int siteNumber2, int compnumb1, int com
* getMixingRule.
* </p>
*
* @param i a int
* @param mr a int
* @return a {@link neqsim.thermo.mixingrule.CPAMixingRulesInterface} object
*/
public CPAMixingRulesInterface getMixingRule(int i) {
if (i == 1) {
public CPAMixingRulesInterface getMixingRule(int mr) {
if (mr == 1) {
mixingRuleName = "CPA_Radoch";
return new CPA_Radoch();
} else if (i == 2) {
} else if (mr == 2) {
mixingRuleName = "CPA_Radoch";
return new CPA_Radoch();
} else if (i == 3) {
} else if (mr == 3) {
mixingRuleName = "PCSAFTa_Radoch";
return new PCSAFTa_Radoch();
} else {
mixingRuleName = "CPA_Radoch";
return new CPA_Radoch();
}
}
Expand All @@ -605,11 +634,11 @@ public CPAMixingRulesInterface getMixingRule(int i) {
* getMixingRule.
* </p>
*
* @param i a int
* @param mr a int
* @param phase a {@link neqsim.thermo.phase.PhaseInterface} object
* @return a {@link neqsim.thermo.mixingrule.CPAMixingRulesInterface} object
*/
public CPAMixingRulesInterface getMixingRule(int i, PhaseInterface phase) {
public CPAMixingRulesInterface getMixingRule(int mr, PhaseInterface phase) {
assosSchemeType = new int[phase.getNumberOfComponents()][phase.getNumberOfComponents()];
cpaBetaCross = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()];
cpaEpsCross = new double[phase.getNumberOfComponents()][phase.getNumberOfComponents()];
Expand Down Expand Up @@ -656,7 +685,7 @@ public CPAMixingRulesInterface getMixingRule(int i, PhaseInterface phase) {
}
}

return getMixingRule(i);
return getMixingRule(mr);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @author Even Solbraa
* @version $Id: $Id
*/
public interface CPAMixingRulesInterface extends java.io.Serializable {
public interface CPAMixingRulesInterface extends MixingRulesInterface {
// public double calcXi(int siteNumber, int compnumb, PhaseInterface phase,
// double temperature, double pressure, int numbcomp);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @author Even Solbraa
* @version $Id: $Id
*/
public interface ElectrolyteMixingRulesInterface extends java.io.Serializable {
public interface ElectrolyteMixingRulesInterface extends MixingRulesInterface {
/**
* <p>
* calcWij.
Expand Down
Loading

0 comments on commit 381a968

Please sign in to comment.