Skip to content

Commit

Permalink
first implementation of reporting of process (#986)
Browse files Browse the repository at this point in the history
* first implementation of reporting of process

* added json reporting

* fixed bug in stream

* update pom

* update doc

* fix bug

* update

* update

* update
  • Loading branch information
EvenSol authored Apr 22, 2024
1 parent bd3e118 commit 7767de1
Show file tree
Hide file tree
Showing 22 changed files with 301 additions and 9 deletions.
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
Expand Down
1 change: 0 additions & 1 deletion pomJava21.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
Expand Down
1 change: 0 additions & 1 deletion pomJava8.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,10 @@ public boolean equals(Object obj) {
&& Arrays.deepEquals(report, other.report)
&& Objects.equals(specification, other.specification);
}

/** {@inheritDoc} */
@Override
public String toJson() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,13 @@ public default SystemInterface getFluid() {
/** {@inheritDoc} */
@Override
public int hashCode();

/**
* <p>
* toJson.
* </p>
*
* @return a String
*/
public String toJson();
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,10 @@ public void setOutletStream(StreamInterface stream) {
public void setOutletTemperature(double temperature) {
this.outStream.setTemperature(temperature, "unit");
}

/** {@inheritDoc} */
@Override
public String toJson() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
import javax.swing.JTable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.google.gson.GsonBuilder;
import neqsim.processSimulation.mechanicalDesign.compressor.CompressorMechanicalDesign;
import neqsim.processSimulation.processEquipment.TwoPortEquipment;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.processSimulation.util.monitor.CompressorResponse;
import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;
Expand Down Expand Up @@ -1422,4 +1424,9 @@ public void setCompressionRatio(double compRatio) {
public double getCompressionRatio() {
return compressionRatio;
}

@Override
public String toJson() {
return new GsonBuilder().create().toJson(new CompressorResponse(this));
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package neqsim.processSimulation.processEquipment.heatExchanger;

import java.util.UUID;

import com.google.gson.GsonBuilder;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.processSimulation.util.monitor.HeaterResponse;

/**
* <p>
Expand Down Expand Up @@ -76,4 +77,10 @@ public double getEntropyProduction(String unit) {

return entrop;
}

/** {@inheritDoc} */
@Override
public String toJson() {
return new GsonBuilder().create().toJson(new HeaterResponse(this));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
package neqsim.processSimulation.processEquipment.heatExchanger;

import java.util.UUID;
import com.google.gson.GsonBuilder;
import neqsim.processSimulation.processEquipment.TwoPortEquipment;
import neqsim.processSimulation.processEquipment.stream.Stream;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.processSimulation.util.monitor.HeaterResponse;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

Expand Down Expand Up @@ -369,4 +371,10 @@ public double getExergyChange(String unit, double surroundingTemperature) {
return outStream.getThermoSystem().getExergy(surroundingTemperature, unit)
- inStream.getThermoSystem().getExergy(surroundingTemperature, unit);
}

/** {@inheritDoc} */
@Override
public String toJson() {
return new GsonBuilder().create().toJson(new HeaterResponse(this));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.UUID;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.google.gson.GsonBuilder;
import neqsim.processSimulation.mechanicalDesign.separator.SeparatorMechanicalDesign;
import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass;
import neqsim.processSimulation.processEquipment.mixer.Mixer;
Expand All @@ -21,6 +22,7 @@
import neqsim.processSimulation.processEquipment.separator.sectionType.ValveSection;
import neqsim.processSimulation.processEquipment.stream.Stream;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.processSimulation.util.monitor.SeparatorResponse;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

Expand Down Expand Up @@ -871,6 +873,12 @@ public boolean equals(Object obj) {
&& Objects.equals(waterSystem, other.waterSystem);
}

/** {@inheritDoc} */
@Override
public String toJson() {
return new GsonBuilder().create().toJson(new SeparatorResponse(this));
}

/*
* private class SeparatorReport extends Object{ public Double gasLoadFactor; SeparatorReport(){
* gasLoadFactor = getGasLoadFactor(); } }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package neqsim.processSimulation.processEquipment.separator;

import java.util.UUID;
import com.google.gson.GsonBuilder;
import neqsim.processSimulation.processEquipment.stream.Stream;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.processSimulation.util.monitor.SeparatorResponse;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

/**
Expand Down Expand Up @@ -267,4 +269,10 @@ public double getExergyChange(String unit, double surroundingTemperature) {
+ getOilOutStream().getThermoSystem().getEntropy(unit)
+ getGasOutStream().getThermoSystem().getExergy(surroundingTemperature, unit) - entrop;
}

/** {@inheritDoc} */
@Override
public String toJson() {
return new GsonBuilder().create().toJson(new SeparatorResponse(this));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@

package neqsim.processSimulation.processEquipment.stream;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.google.gson.GsonBuilder;
import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass;
import neqsim.processSimulation.util.monitor.StreamResponse;
import neqsim.standards.gasQuality.Standard_ISO6976;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;
Expand Down Expand Up @@ -436,9 +440,11 @@ public void displayResult() {
*/
@Override
public String[][] getResultTable() {
return getFluid().getResultTable();
return getFluid().calcResultTable();
}



/** {@inheritDoc} */
@Override
public void runTransient(double dt, UUID id) {
Expand Down Expand Up @@ -607,4 +613,55 @@ public SystemInterface getFluid() {
return thermoSystem;
}
}

/**
* <p>
* getReport.
* </p>
*
* @return a String object
*/
public ArrayList<String[]> getReport() {
ArrayList<String[]> report = new ArrayList<String[]>();
HashMap<String, String> gasprops = new HashMap<String, String>();
ArrayList<String> phases = new ArrayList<String>();

phases.add("Total");
if (getFluid().hasPhaseType("gas")) {
phases.add("Gas");
gasprops.put("temperature",
Double.toString(getTemperature(neqsim.util.unit.Units.getSymbol("temperature"))));
}
if (getFluid().hasPhaseType("oil")) {
phases.add("oil");
}
if (getFluid().hasPhaseType("aqueous")) {
phases.add("aqueous");
}

report.add(phases.toArray(new String[0]));

report.add(new String[] {"temperature",
Double.toString(getTemperature(neqsim.util.unit.Units.getSymbol("temperature"))),
neqsim.util.unit.Units.getSymbol("temperature")});
report.add(new String[] {"pressure",
Double.toString(getPressure(neqsim.util.unit.Units.getSymbol("pressure"))),
neqsim.util.unit.Units.getSymbol("pressure")});
report.add(new String[] {"mass flow",
Double.toString(getFlowRate(neqsim.util.unit.Units.getSymbol("mass flow"))),
neqsim.util.unit.Units.getSymbol("mass flow")});
report.add(new String[] {"molar flow",
Double.toString(getFlowRate(neqsim.util.unit.Units.getSymbol("molar flow"))),
neqsim.util.unit.Units.getSymbol("molar flow")});
report.add(new String[] {"volume flow",
Double.toString(getFlowRate(neqsim.util.unit.Units.getSymbol("volume flow"))),
neqsim.util.unit.Units.getSymbol("volume flow")});
return report;
}

/** {@inheritDoc} */
@Override
public String toJson() {
return new GsonBuilder().create().toJson(new StreamResponse(this));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import java.util.UUID;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.google.gson.GsonBuilder;
import neqsim.processSimulation.mechanicalDesign.valve.ValveMechanicalDesign;
import neqsim.processSimulation.processEquipment.TwoPortEquipment;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.processSimulation.util.monitor.ValveResponse;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

Expand Down Expand Up @@ -472,4 +474,10 @@ public ValveMechanicalDesign getMechanicalDesign() {
public void setIsCalcOutPressure(boolean isSetPres) {
isCalcPressure = isSetPres;
}

/** {@inheritDoc} */
@Override
public String toJson() {
return new GsonBuilder().create().toJson(new ValveResponse(this));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,8 @@ public ProcessModule copy() {
ProcessModule copyModule = (ProcessModule) SerializationUtils.deserialize(bytes);
return copyModule;
}

public ArrayList<String[]> getReport() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,10 @@ public String[][] getResultTable() {
public double getPressure(String unit) {
return 1.0;
}

/** {@inheritDoc} */
@Override
public String toJson() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,7 @@ public void run(UUID id) {
for (int i = 0; i < unitOperations.size(); i++) {
if (!unitOperations.get(i).getClass().getSimpleName().equals("Recycle")) {
try {
if (iter == 1
|| unitOperations.get(i).needRecalculation()) {
if (iter == 1 || unitOperations.get(i).needRecalculation()) {
unitOperations.get(i).run(id);
}
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package neqsim.processSimulation.util.monitor;

import java.util.ArrayList;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;

/**
Expand All @@ -22,16 +23,28 @@ public class StreamResponse {
public Double massflowGas;
public Double massflowOil;
public Double massflowAqueous;
public ArrayList<String[]> data = new ArrayList<String[]>();

/**
* <p>
* Constructor for StreamResponse.
* </p>
*
* @param inputStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object
* @param inputStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface}
* object
*/
public StreamResponse(StreamInterface inputStream) {

name = inputStream.getName();

data.add(new String[] {"temperature",
Double
.toString(inputStream.getTemperature(neqsim.util.unit.Units.getSymbol("temperature"))),
neqsim.util.unit.Units.getSymbol("temperature")});
data.add(new String[] {"pressure",
Double.toString(inputStream.getPressure(neqsim.util.unit.Units.getSymbol("pressure"))),
neqsim.util.unit.Units.getSymbol("pressure")});

fluid = new Fluid(inputStream.getFluid());
temperature = inputStream.getTemperature("C");
pressure = inputStream.getPressure("bara");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package neqsim.processSimulation.util.monitor;

import java.util.ArrayList;
import neqsim.processSimulation.processEquipment.valve.ValveInterface;

/**
* <p>
* StreamResponse class.
* </p>
*
* @author asmund
* @version $Id: $Id
*/
public class ValveResponse {
public String name;
public ArrayList<String[]> data = new ArrayList<String[]>();

/**
* <p>
* Constructor for StreamResponse.
* </p>
*
* @param valve a {@link neqsim.processSimulation.processEquipment.valve.ValveInterface} object
*/
public ValveResponse(ValveInterface valve) {

name = valve.getName();

data.add(new String[] {"outlet temperature",
Double.toString(valve.getOutletStream()
.getTemperature(neqsim.util.unit.Units.getSymbol("temperature"))),
neqsim.util.unit.Units.getSymbol("temperature")});
data.add(new String[] {"outlet pressure",
Double.toString(
valve.getOutletStream().getPressure(neqsim.util.unit.Units.getSymbol("pressure"))),
neqsim.util.unit.Units.getSymbol("pressure")});
}

/**
* <p>
* print.
* </p>
*/
public void print() {}
}
Loading

0 comments on commit 7767de1

Please sign in to comment.