Skip to content

Commit

Permalink
refact: remove deprecation, simplify init
Browse files Browse the repository at this point in the history
  • Loading branch information
asmfstatoil committed Feb 22, 2024
1 parent 5abf345 commit 20d3327
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 32 deletions.
27 changes: 8 additions & 19 deletions src/main/java/neqsim/thermo/system/SystemInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -614,18 +614,6 @@ public default void removeMoles() {
*/
public double[] getMolarRate();

/**
* Returns true if phase exists and is not null.
*
* @param i Phase number
* @return True if phase exists, false if not.
* @deprecated use {@link #isPhase(int i)} instead
*/
@Deprecated
public default boolean IsPhase(int i) {
return isPhase(i);
}

/**
* Returns true if phase exists and is not null.
*
Expand Down Expand Up @@ -1109,28 +1097,29 @@ public default boolean hasSolidPhase() {
public void addComponent(ComponentInterface inComponent);

/**
* add a component to a fluid. If component already exists, the moles will be added to the
* existing component.
* add a component to a fluid with no moles.
*
* @param name Name of the component to add. See NeqSim database for component in the database.
*/
public void addComponent(String name);
public default void addComponent(String name) {
addComponent(name, 0);
}

/**
* add a component to a fluid. If component already exists, the moles will be added to the
* existing component.
*
* @param moles number of moles (per second) of the component to be added to the fluid
* @param name Name of the component to add. See NeqSim database for component in the database.
* @param moles number of moles (per second) of the component to be added to the fluid
*/
public void addComponent(String name, double moles);

/**
* add a component to a fluid. If component already exists, the moles will be added to the
* add a component to a fluid. If component already exists, the amount will be added to the
* existing component.
*
* @param name Name of the component to add. See NeqSim database for component in the database.
* @param value The amount
* @param value The amount.
* @param unitName the unit of rate (sported units are kg/sec, mol/sec, Nlitre/min, kg/hr,
* Sm^3/hr, Sm^3/day, MSm^3/day ..
*/
Expand Down Expand Up @@ -1811,7 +1800,7 @@ public double calcBeta()

/**
* method to return molar volume of the fluid: eventual volume correction included.
*
*
* @param unit Supported units are m3/mol, litre/mol
*
* @return molar volume volume in unit
Expand Down
17 changes: 4 additions & 13 deletions src/main/java/neqsim/thermo/system/SystemThermo.java
Original file line number Diff line number Diff line change
Expand Up @@ -1121,12 +1121,6 @@ public void addComponent(ComponentInterface inComponent) {
}
}

/** {@inheritDoc} */
@Override
public void addComponent(String name) {
addComponent(name, 0.0);
}

/** {@inheritDoc} */
@Override
public void addComponent(String componentName, double moles) {
Expand Down Expand Up @@ -1201,6 +1195,7 @@ public void addComponent(String componentName, double value, String unitName) {
stddens = Double.parseDouble(dataSet.getString("stddens"));
boilp = Double.parseDouble(dataSet.getString("normboil"));
} catch (Exception ex) {
// todo: mole amount may be not set. should not be caught?
logger.error("failed ", ex);
}
neqsim.util.unit.Unit unit =
Expand Down Expand Up @@ -1799,7 +1794,7 @@ public void reset() {
/** {@inheritDoc} */
@Override
public void init(int type) {
if (!isInitialized) {
if (!this.isInitialized) {
initBeta();
init_x_y();
}
Expand All @@ -1808,6 +1803,7 @@ public void init(int type) {
} else {
initAnalytic(type);
}
this.isInitialized = true;
}

/** {@inheritDoc} */
Expand Down Expand Up @@ -3415,10 +3411,6 @@ public void normalizeBeta() {
/** {@inheritDoc} */
@Override
public String[][] createTable(String name) {

if (!isInitialized) {
init_x_y();
}
initProperties();

java.text.DecimalFormat nf = new java.text.DecimalFormat();
Expand Down Expand Up @@ -3622,8 +3614,8 @@ public String[][] createTable(String name) {
table[getPhases()[0].getNumberOfComponents() + 25][i + 2] = name;
table[getPhases()[0].getNumberOfComponents() + 25][6] = "-";
}
resultTable = table;

resultTable = table;
return table;
}

Expand All @@ -3636,7 +3628,6 @@ public void display() {
/** {@inheritDoc} */
@Override
public void display(String name) {

javax.swing.JFrame dialog = new javax.swing.JFrame("System-Report");
java.awt.Dimension screenDimension = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
java.awt.Container dialogContentPane = dialog.getContentPane();
Expand Down

0 comments on commit 20d3327

Please sign in to comment.