Skip to content

Commit

Permalink
refact: remove unused function input compnumber from removecomponent (#…
Browse files Browse the repository at this point in the history
…940)

* feat: simplify removeComponent
* refact: reorder methods
* docfix
  • Loading branch information
asmfstatoil authored Mar 7, 2024
1 parent e7a90fb commit 3a4b21e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 41 deletions.
51 changes: 26 additions & 25 deletions src/main/java/neqsim/thermo/component/ComponentGeDuanSun.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,32 @@ public ComponentGeDuanSun(String name, double moles, double molesInPhase, int co
super(name, moles, molesInPhase, compIndex);
}

/**
* <p>
* getGamma.
* </p>
*
* @param phase a {@link neqsim.thermo.phase.PhaseInterface} object
* @param numberOfComponents a int
* @param temperature a double
* @param pressure a double
* @param pt the PhaseType of the phase.
* @param HValpha an array of {@link double} objects
* @param HVgij an array of {@link double} objects
* @return a double
*/
public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature,
double pressure, PhaseType pt, double[][] HValpha, double[][] HVgij) {
if (componentName.equals("CO2")) {
return 0.9;
} else if (componentName.equals("water")) {
return 1.0;
} else {
return 1.0;
}
}


/** {@inheritDoc} */
@Override
public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature,
Expand Down Expand Up @@ -262,31 +288,6 @@ public double getGammaNRTL(PhaseInterface phase, int numberOfComponents, double
return gamma;
}

/**
* <p>
* getGamma.
* </p>
*
* @param phase a {@link neqsim.thermo.phase.PhaseInterface} object
* @param numberOfComponents a int
* @param temperature a double
* @param pressure a double
* @param pt the PhaseType of the phase.
* @param HValpha an array of {@link double} objects
* @param HVgij an array of {@link double} objects
* @return a double
*/
public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature,
double pressure, PhaseType pt, double[][] HValpha, double[][] HVgij) {
if (componentName.equals("CO2")) {
return 0.9;
} else if (componentName.equals("water")) {
return 1.0;
} else {
return 1.0;
}
}

/*
* public double getHenryCoef(double temperature) { // System.out.println("henry " + //
* Math.exp(henryCoefParameter[0]+henryCoefParameter[1]/temperature+
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/neqsim/thermo/component/ComponentHydrate.java
Original file line number Diff line number Diff line change
Expand Up @@ -507,25 +507,25 @@ public void setDGfHydrate(double dGfHydrate, int i) {

/**
* <p>
* Setter for the field <code>dHfHydrate</code>.
* Getter for the field <code>dHfHydrate</code>.
* </p>
*
* @param dHfHydrate a double
* @param i a int
* @return an array of {@link double} objects
*/
public void setDHfHydrate(double dHfHydrate, int i) {
this.dHfHydrate[i] = dHfHydrate;
public double[] getDHfHydrate() {
return dHfHydrate;
}

/**
* <p>
* Getter for the field <code>dHfHydrate</code>.
* Setter for the field <code>dHfHydrate</code>.
* </p>
*
* @return an array of {@link double} objects
* @param dHfHydrate a double
* @param i a int
*/
public double[] getDHfHydrate() {
return dHfHydrate;
public void setDHfHydrate(double dHfHydrate, int i) {
this.dHfHydrate[i] = dHfHydrate;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/neqsim/thermo/phase/Phase.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void addComponent(String name, double moles) {

/** {@inheritDoc} */
@Override
public void removeComponent(String name, double moles, double molesInPhase, int compNumber) {
public void removeComponent(String name, double moles, double molesInPhase) {
name = ComponentInterface.getComponentNameFromAlias(name);

ArrayList<ComponentInterface> temp = new ArrayList<ComponentInterface>();
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/neqsim/thermo/phase/PhaseInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -418,15 +418,14 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int initType

/**
* <p>
* removeComponent.
* Remove component from Phase.
* </p>
*
* @param name Name of component.
* @param moles Total number of moles of component.
* @param molesInPhase Number of moles in phase.
* @param compNumber Index number of component in phase object component array.
*/
public void removeComponent(String name, double moles, double molesInPhase, int compNumber);
public void removeComponent(String name, double moles, double molesInPhase);

/**
* <p>
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/neqsim/thermo/system/SystemThermo.java
Original file line number Diff line number Diff line change
Expand Up @@ -1360,12 +1360,10 @@ public void removeComponent(String name) {
getTotalNumberOfMoles() - phaseArray[0].getComponent(name).getNumberOfmoles());
for (int i = 0; i < getMaxNumberOfPhases(); i++) {
getPhase(i).removeComponent(name, getTotalNumberOfMoles(),
phaseArray[phaseIndex[i]].getComponent(name).getNumberOfMolesInPhase(),
phaseArray[phaseIndex[i]].getComponent(name).getComponentNumber());
getPhase(i).getComponent(name).getNumberOfMolesInPhase());
}

componentNames.remove(name);
// System.out.println("removing " + componentNames.toString());
numberOfComponents--;
}

Expand Down

0 comments on commit 3a4b21e

Please sign in to comment.