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

add text output for ops #823

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,15 @@ public boolean equals(Object obj) {
&& Arrays.deepEquals(report, other.report)
&& Objects.equals(specification, other.specification);
}

/** {@inheritDoc} */
public String[][] createTable(String name) {

String[][] table = new String[50][3];
String[] names = {"Property", "Value", "Unit"};
table[0][0] = "";
table[0][1] = "";
table[0][2] = "";
return table;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,14 @@ public default SystemInterface getFluid() {
/** {@inheritDoc} */
@Override
public int hashCode();

/**
* Prints the fluid in a visually appealing way.
*
*/
public default void prettyPrint() {
neqsim.thermo.util.readwrite.TablePrinter.printTable(createTable(getName()));
}

public String[][] createTable(String name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ public Pump() {
super("Pump");
}

/**
* <p>
* Return head
* </p>
*
* @param unit unit can be or kJ/kg
*/
public double getHead(String unit) {
if (unit.equals("meter")) {
return (getOutletStream().getPressure("bara") - getInletStream().getPressure("bara"))
/ (1000.0 * ThermodynamicConstantsInterface.gravity / 1.0E5);
} else if (unit.equals("kJ/kg")) {
return getPower("kW") / getInletStream().getFlowRate("kg/sec");
} else
return getPower("kW") / getInletStream().getFlowRate("kg/sec");
}

/**
* <p>
* Constructor for Pump.
Expand Down Expand Up @@ -225,6 +242,38 @@ public void run(UUID id) {
// outStream.run(id);
}

/** {@inheritDoc} */
@Override
public String[][] createTable(String name) {
DecimalFormat nf = new DecimalFormat();
nf.setMaximumFractionDigits(5);
nf.applyPattern("#.#####E0");

String[][] table = new String[4][3];
String[] names = {"Property", "Value", "Unit"};
table[0][0] = "";
table[0][1] = "";
table[0][2] = "";
StringBuffer buf = new StringBuffer();
FieldPosition test = new FieldPosition(0);

table[1][0] = "Inlet pressure";
buf = new StringBuffer();
table[1][1] = nf.format(inStream.getPressure("bara"), buf, test).toString();
table[1][2] = "bara";

table[2][0] = "Outlet pressure";
buf = new StringBuffer();
table[2][1] = nf.format(outStream.getPressure("bara"), buf, test).toString();
table[2][2] = "bara";

table[3][0] = "Head";
buf = new StringBuffer();
table[3][1] = nf.format(getHead("meter"), buf, test).toString();
table[3][2] = "meter";
return table;
}

/** {@inheritDoc} */
@Override
public void displayResult() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,15 @@ public String[][] getResultTable() {
public double getPressure(String unit) {
return 1.0;
}

/** {@inheritDoc} */
public String[][] createTable(String name) {

String[][] table = new String[50][3];
String[] names = {"Property", "Value", "Unit"};
table[0][0] = "";
table[0][1] = "";
table[0][2] = "";
return table;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ void testSimplePumpCurve() {
pump1.setSpeed(500);
pump1.run();

pump1.prettyPrint();

Assertions.assertEquals(7.274237081101, pump1.getOutletPressure(), 1e-5);

}
Expand Down
Loading