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

fix: some cases where display methods failed #923

Merged
merged 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,7 @@ public double step() {
double[] n_omega = new double[NSPEC];
double[] chem_pot_omega = new double[NSPEC];
double[] chem_pot = new double[NSPEC];
double G_1;

double G_0;
check = 0;
step = 1;

Expand All @@ -262,8 +260,8 @@ public double step() {
}
}

G_1 = 0;

double G_0;
double G_1 = 0;
for (i = 0; i < NSPEC; i++) {
G_1 += chem_pot_omega[i] * d_n[i];
}
Expand Down
22 changes: 16 additions & 6 deletions src/main/java/neqsim/fluidMechanics/flowNode/FlowNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -590,10 +590,12 @@ public void display(String name) {
JTable Jtab = new JTable(table, names);
JScrollPane scrollpane = new JScrollPane(Jtab);
dialogContentPane.add(scrollpane);
Jtab.setRowHeight(dialog.getHeight() / table.length);
Jtab.setFont(new Font("Serif", Font.PLAIN,
dialog.getHeight() / table.length - dialog.getHeight() / table.length / 10));
// dialog.pack();
if (table.length > 0) {
Jtab.setRowHeight(dialog.getHeight() / table.length);
Jtab.setFont(new Font("Serif", Font.PLAIN,
dialog.getHeight() / table.length - dialog.getHeight() / table.length / 10));
// dialog.pack();
}
dialog.setVisible(true);
}

Expand Down Expand Up @@ -643,11 +645,19 @@ public void setFlowDirection(int flowDirection, int i) {
* @return an array of {@link java.lang.String} objects
*/
public String[][] createTable(String name) {
int rows = 0;
if (bulkSystem == null) {
String[][] table = new String[0][5];
return table;
}

rows = bulkSystem.getPhases()[0].getNumberOfComponents() * 10;
String[][] table = new String[rows][5];

DecimalFormat nf = new DecimalFormat();
nf.setMaximumFractionDigits(5);
nf.applyPattern("#.#####E0");

String[][] table = new String[bulkSystem.getPhases()[0].getNumberOfComponents() * 10][5];
table[0][0] = "";
table[0][1] = "";
table[0][2] = "";
Expand Down Expand Up @@ -689,7 +699,6 @@ public String[][] createTable(String name) {
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 5][4] = "[-]";

// Double.longValue(system.getPhase(phaseIndex[i]).getBeta());

buf = new StringBuffer();
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 6][0] = "Velocity";
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 6][i + 1] =
Expand Down Expand Up @@ -739,6 +748,7 @@ public String[][] createTable(String name) {
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 13][i + 1] = name;
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 13][4] = "-";
}

return table;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,15 @@ public String[][] createTable(String name) {
nf.setMaximumFractionDigits(5);
nf.applyPattern("#.#####E0");

String[][] table = new String[bulkSystem.getPhases()[0].getNumberOfComponents() * 10][5];
int rows = 0;
if (bulkSystem == null) {
String[][] table = new String[0][5];
return table;
}

rows = bulkSystem.getPhases()[0].getNumberOfComponents() * 10;
String[][] table = new String[rows][5];

// String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"};
table[0][0] = "";
table[0][1] = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public Viscosity clone() {
public double calcViscosity() {
double tempVar = 0;
double tempVar2 = 0;
double viscosity = 0;
this.calcPureComponentViscosity();

// method og Grunberg and Nissan [87]
Expand All @@ -85,7 +84,7 @@ public double calcViscosity() {
// liquidPhase.getPhase().getComponents()[i].getx()*liquidPhase.getPhase().getComponents()[j].getx()*liquidPhase.getMixingRule().getViscosityGij(i,j);
}
}
viscosity = Math.exp(tempVar + tempVar2) / 1.0e3; // N-sek/m2
double viscosity = Math.exp(tempVar + tempVar2) / 1.0e3; // N-sek/m2
return viscosity;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,13 @@ public HydrateEquilibriumTemperatureAnalyser(String name, StreamInterface stream
/** {@inheritDoc} */
@Override
public void displayResult() {
try {
// System.out.println("total water production [kg/dag]" +
// stream.getThermoSystem().getPhase(0).getComponent("water").getNumberOfmoles() *
// stream.getThermoSystem().getPhase(0).getComponent("water").getMolarMass()*3600*24);
// System.out.println("water in phase 1 (ppm) " +
// stream.getThermoSystem().getPhase(0).getComponent("water").getx()*1e6);
} finally {
}
/*
* try { // System.out.println("total water production [kg/dag]" + //
* stream.getThermoSystem().getPhase(0).getComponent("water").getNumberOfmoles() * //
* stream.getThermoSystem().getPhase(0).getComponent("water").getMolarMass()*3600*24); //
* System.out.println("water in phase 1 (ppm) " + //
* stream.getThermoSystem().getPhase(0).getComponent("water").getx()*1e6); } finally { }
*/
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1025,11 +1025,11 @@ public void displayResults() {
Container dialogContentPane = dialog.getContentPane();
dialogContentPane.setLayout(new BorderLayout());

String[] names = {"", "Volume", "Weight"};
String[][] table = new String[3][3]; // createTable(getProcessEquipment().getName());
table[1][0] = getProcessEquipment().getName();
table[1][1] = Double.toString(getWeightTotal());
table[1][2] = Double.toString(getVolumeTotal());
String[] names = {"", "Volume", "Weight"};
JTable Jtab = new JTable(table, names);
JScrollPane scrollpane = new JScrollPane(Jtab);
dialogContentPane.add(scrollpane);
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/neqsim/standards/Standard.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,19 @@ public void setStandardDescription(String standardDescription) {
/** {@inheritDoc} */
@Override
public String[][] createTable(String name) {
if (thermoSystem == null) {
String[][] table = new String[0][6];
return table;
}
thermoSystem.setNumberOfPhases(1);

thermoSystem.createTable(name);

DecimalFormat nf = new DecimalFormat();
nf.setMaximumFractionDigits(5);
nf.applyPattern("#.#####E0");
String[][] table = new String[thermoSystem.getPhases()[0].getNumberOfComponents() + 30][6];

int rows = thermoSystem.getPhases()[0].getNumberOfComponents() + 30;
String[][] table = new String[rows][6];
// String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"};
table[0][0] = ""; // getPhases()[0].getType(); //"";

Expand Down
11 changes: 10 additions & 1 deletion src/main/java/neqsim/standards/gasQuality/Draft_GERG2004.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,16 @@ public String[][] createTable(String name) {
DecimalFormat nf = new DecimalFormat();
nf.setMaximumFractionDigits(5);
nf.applyPattern("#.#####E0");
String[][] table = new String[thermoSystem.getPhases()[0].getNumberOfComponents() + 30][6];

int rows = 0;
if (thermoSystem == null) {
String[][] table = new String[0][6];
return table;
}

rows = thermoSystem.getPhases()[0].getNumberOfComponents() + 30;
String[][] table = new String[rows][6];

// String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"};
table[0][0] = ""; // getPhases()[0].getType(); //"";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,16 @@ public String[][] createTable(String name) {
DecimalFormat nf = new DecimalFormat();
nf.setMaximumFractionDigits(5);
nf.applyPattern("#.#####E0");
String[][] table = new String[thermoSystem.getPhases()[0].getNumberOfComponents() + 30][6];

int rows = 0;
if (thermoSystem == null) {
String[][] table = new String[0][6];
return table;
}

rows = thermoSystem.getPhases()[0].getNumberOfComponents() + 30;
String[][] table = new String[rows][6];

// String[] names = { "", "Phase 1", "Phase 2", "Phase 3", "Unit" };
table[0][0] = ""; // getPhases()[0].getType(); //"";

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/neqsim/thermo/system/SystemThermo.java
Original file line number Diff line number Diff line change
Expand Up @@ -3622,6 +3622,9 @@ public String[][] createTable(String name) {
/** {@inheritDoc} */
@Override
public void display(String name) {
if (this.getNumberOfComponents() == 0) {
return;
}
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
Original file line number Diff line number Diff line change
Expand Up @@ -1794,6 +1794,10 @@ public void setResultTable(String[][] resultTable) {
* </p>
*/
public void display() {
if (resultTable == null) {
return;
}

JFrame dialog = new JFrame("System-Report");
Container dialogContentPane = dialog.getContentPane();
dialogContentPane.setLayout(new BorderLayout());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package neqsim.fluidMechanics.flowNode.twoPhaseNode.twoPhasePipeFlowNode;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData;
import neqsim.thermo.phase.PhaseType;
Expand Down Expand Up @@ -127,15 +128,10 @@ void testInit2() {
// "flux methane " + test3.getFluidBoundary().getInterphaseMolarFlux(0) + " [mol/m2*sec]");
// System.out.println(
// "flux nC10 " + test3.getFluidBoundary().getInterphaseMolarFlux(1) + " [mol/m2*sec]");


}



@Test
void testInit3() {

SystemInterface[] gasPhases = new SystemInterface[10];
SystemInterface[] oilPhases = new SystemInterface[10];
StratifiedFlowNode[] nodes = new StratifiedFlowNode[10];
Expand Down Expand Up @@ -165,7 +161,6 @@ void testInit3() {
}

for (int time = 0; time < 100; time++) {

for (int i = 0; i < 9; i++) {
fluids[i] = new SystemSrkEos(278.3, 100.01325);
fluids[i].addFluid(gasPhases[i], 0);
Expand Down Expand Up @@ -212,7 +207,6 @@ void testInit3() {
}

for (int time = 0; time < 20; time++) {

for (int i = 0; i < 9; i++) {
fluids[i] = new SystemSrkEos(278.3, 100.01325);
fluids[i].addFluid(gasPhases[i], 0);
Expand Down Expand Up @@ -256,7 +250,12 @@ void testInit3() {
// + " liquid "
// + nodes[0].getBulkSystem().getPhase(1).getComponent(1).getNumberOfMolesInPhase());
}

}

@Test
@Disabled
void testDisplay() {
StratifiedFlowNode node = new StratifiedFlowNode();
node.display();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,6 @@ void testCopy() {
Assertions.assertEquals(p, sys2);
}

@Test
void testDisplayResult() {}

@Test
void testGetAllUnitNames() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;
Expand Down Expand Up @@ -55,4 +56,14 @@ void testGetValue() {
void testIsOnSpec() {
assertEquals(true, ISO15403.isOnSpec());
}

@Test
@Disabled
void testDisplay() {
Standard_ISO15403 s = new Standard_ISO15403(null);
s.display("test");

s = new Standard_ISO15403(testSystem);
s.display("test");
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
package neqsim.standards.gasQuality;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;

public class Standard_ISO6578Test extends neqsim.NeqSimTest {
SystemInterface testSystem;

@BeforeEach
void setUp() {
testSystem = new SystemSrkEos(273.15 - 160.0, 1.0);
testSystem.addComponent("nitrogen", 0.006538);
testSystem.addComponent("methane", 0.91863);
testSystem.addComponent("ethane", 0.058382);
testSystem.addComponent("propane", 0.011993);
// testSystem.addComponent("i-butane", 0.00);
testSystem.addComponent("n-butane", 0.003255);
testSystem.addComponent("i-pentane", 0.000657);
testSystem.addComponent("n-pentane", 0.000545);
}

@Test
void testCalculate() {
SystemInterface testSystem = new SystemSrkEos(273.15 - 160.0, 1.0);
Expand Down Expand Up @@ -34,4 +51,14 @@ void testCalculate() {
Assertions.assertEquals(0.30930700620842033, standard.getCorrFactor1());
// testSystem.display();
}

@Test
@Disabled
void testDisplay() {
Standard_ISO6578 s = new Standard_ISO6578(null);
s.display("test");

s = new Standard_ISO6578(testSystem);
s.display("test");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;
Expand Down Expand Up @@ -166,4 +167,11 @@ void testCalculate2() {
* 150.0));
*/
}

@Test
@Disabled
void testDisplay() {
Standard_ISO6976 s = new Standard_ISO6976(testSystem);
s.display("test");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;
Expand Down Expand Up @@ -131,4 +132,11 @@ void testCalculate2() {
* 150.0));
*/
}

@Test
@Disabled
void testDisplay() {
Standard_ISO6976_2016 s = new Standard_ISO6976_2016(testSystem);
s.display("test");
}
}
Loading
Loading