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

refact: system addcomponent and display #922

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
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
31 changes: 11 additions & 20 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 @@ -1567,7 +1556,9 @@ public default void initThermoProperties() {
* display.
* </p>
*/
public void display();
public default void display() {
display(this.getFluidName());
}

/**
* <p>
Expand Down Expand Up @@ -1811,7 +1802,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
23 changes: 4 additions & 19 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,21 +3614,14 @@ 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;
}

/** {@inheritDoc} */
@Override
public void display() {
display(this.getFluidName());
}

/** {@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
Loading