Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol committed Nov 26, 2023
1 parent 71cfdb4 commit 18f7746
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -363,22 +363,26 @@ public void runProcessTEG() throws InterruptedException {
@Test
void testRunNEQSIMAPI() {
XStream xstream = new XStream();
xstream.addPermission(AnyTypePermission.ANY);
// Specify the file path to read
Path filePath = Paths.get("/workspaces/neqsim/src/test/java/neqsim/processSimulation/processSystem/my_process_TEG.xml");
String xmlContents = "";
try {
xmlContents = Files.readString(filePath);
} catch (IOException e) {
e.printStackTrace();
}

// Deserialize from xml
neqsim.processSimulation.processSystem.ProcessSystem operationsCopy =
(neqsim.processSimulation.processSystem.ProcessSystem) xstream.fromXML(xmlContents);
operationsCopy.run();
neqsim.processSimulation.processEquipment.stream.Stream makeUpTEG = (neqsim.processSimulation.processEquipment.stream.Stream) operationsCopy.getUnit("makeup TEG");
Assertions.assertEquals(makeUpTEG.getFlowRate("kg/hr"), 0.22761215378293284);
xstream.addPermission(AnyTypePermission.ANY);
// Specify the file path to read

Path filePath = Paths.get(
"/workspaces/neqsim/src/test/java/neqsim/processSimulation/processSystem/my_process_TEG.xml");
String xmlContents = "";
try {
xmlContents = new String(Files.readAllBytes(filePath));
} catch (IOException e) {
e.printStackTrace();
}

// Deserialize from xml
neqsim.processSimulation.processSystem.ProcessSystem operationsCopy =
(neqsim.processSimulation.processSystem.ProcessSystem) xstream.fromXML(xmlContents);
operationsCopy.run();
neqsim.processSimulation.processEquipment.stream.Stream makeUpTEG =
(neqsim.processSimulation.processEquipment.stream.Stream) operationsCopy
.getUnit("makeup TEG");
Assertions.assertEquals(makeUpTEG.getFlowRate("kg/hr"), 0.22761215378293284);

}

Expand Down
50 changes: 30 additions & 20 deletions src/test/java/neqsim/thermodynamicOperations/flashOps/Degasser.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,27 +192,37 @@ private int findComponentIndex(String[] componentNames, String componentName) {
@Test
void testRun2() {
XStream xstream = new XStream();
xstream.addPermission(AnyTypePermission.ANY);
// Specify the file path to read
Path filePath = Paths.get("/workspaces/neqsim/src/test/java/neqsim/thermodynamicOperations/flashOps/my_process.xml");
String xmlContents = "";
try {
xmlContents = Files.readString(filePath);
} catch (IOException e) {
e.printStackTrace();
}
xstream.addPermission(AnyTypePermission.ANY);
// Specify the file path to read
Path filePath = Paths.get(
"/workspaces/neqsim/src/test/java/neqsim/thermodynamicOperations/flashOps/my_process.xml");
String xmlContents = "";
try {
xmlContents = new String(Files.readAllBytes(filePath));
} catch (IOException e) {
e.printStackTrace();
}

// Deserialize from xml
neqsim.processSimulation.processSystem.ProcessSystem operationsCopy =
(neqsim.processSimulation.processSystem.ProcessSystem) xstream.fromXML(xmlContents);
operationsCopy.run();
neqsim.processSimulation.processEquipment.separator.Separator VD02Separator = (neqsim.processSimulation.processEquipment.separator.Separator) operationsCopy.getUnit("Separator after CFU gas");
neqsim.processSimulation.processEquipment.separator.Separator VD01Separator = (neqsim.processSimulation.processEquipment.separator.Separator) operationsCopy.getUnit("Separator after degasser gas");
neqsim.processSimulation.processEquipment.separator.Separator Degasser = (neqsim.processSimulation.processEquipment.separator.Separator) operationsCopy.getUnit("Degasser");
System.out.println("The gas flow rate should be < 200 kg/hr, the actual value is " + Degasser.getGasOutStream().getFlowRate("kg/hr"));
System.out.println("The gas flow rate should be < 200 kg/hr, the actual value is " + VD01Separator.getGasOutStream().getFlowRate("kg/hr"));
VD02Separator.getGasOutStream().run();
System.out.println("The gas flow rate should be < 200 kg/hr, the actual value is " + VD02Separator.getGasOutStream().getFlowRate("kg/hr"));
// Deserialize from xml
neqsim.processSimulation.processSystem.ProcessSystem operationsCopy =
(neqsim.processSimulation.processSystem.ProcessSystem) xstream.fromXML(xmlContents);
operationsCopy.run();
neqsim.processSimulation.processEquipment.separator.Separator VD02Separator =
(neqsim.processSimulation.processEquipment.separator.Separator) operationsCopy
.getUnit("Separator after CFU gas");
neqsim.processSimulation.processEquipment.separator.Separator VD01Separator =
(neqsim.processSimulation.processEquipment.separator.Separator) operationsCopy
.getUnit("Separator after degasser gas");
neqsim.processSimulation.processEquipment.separator.Separator Degasser =
(neqsim.processSimulation.processEquipment.separator.Separator) operationsCopy
.getUnit("Degasser");
System.out.println("The gas flow rate should be < 200 kg/hr, the actual value is "
+ Degasser.getGasOutStream().getFlowRate("kg/hr"));
System.out.println("The gas flow rate should be < 200 kg/hr, the actual value is "
+ VD01Separator.getGasOutStream().getFlowRate("kg/hr"));
VD02Separator.getGasOutStream().run();
System.out.println("The gas flow rate should be < 200 kg/hr, the actual value is "
+ VD02Separator.getGasOutStream().getFlowRate("kg/hr"));

}
}

0 comments on commit 18f7746

Please sign in to comment.