Skip to content

Commit 87f5c4a

Browse files
authored
improve json properties (#990)
* inproved properties * further updates * update barrels/day * add wt fraction * updated method
1 parent 1a922be commit 87f5c4a

File tree

9 files changed

+329
-136
lines changed

9 files changed

+329
-136
lines changed

src/main/java/neqsim/processSimulation/processEquipment/ProcessEquipmentBaseClass.java

+9-17
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ public SystemInterface getThermoSystem() {
5959

6060
/** {@inheritDoc} */
6161
@Override
62-
public void displayResult() {
63-
}
62+
public void displayResult() {}
6463

6564
/**
6665
* Create deep copy.
@@ -89,8 +88,7 @@ public Object getProperty(String propertyName) {
8988

9089
/** {@inheritDoc} */
9190
@Override
92-
public void setRegulatorOutSignal(double signal) {
93-
}
91+
public void setRegulatorOutSignal(double signal) {}
9492

9593
/** {@inheritDoc} */
9694
@Override
@@ -104,9 +102,8 @@ public void setController(ControllerDeviceInterface controller) {
104102
* Setter for the field <code>flowValveController</code>.
105103
* </p>
106104
*
107-
* @param controller a
108-
* {@link neqsim.processSimulation.controllerDevice.ControllerDeviceInterface}
109-
* object
105+
* @param controller a {@link neqsim.processSimulation.controllerDevice.ControllerDeviceInterface}
106+
* object
110107
*/
111108
public void setFlowValveController(ControllerDeviceInterface controller) {
112109
this.flowValveController = controller;
@@ -126,8 +123,7 @@ public MechanicalDesign getMechanicalDesign() {
126123

127124
/** {@inheritDoc} */
128125
@Override
129-
public void initMechanicalDesign() {
130-
}
126+
public void initMechanicalDesign() {}
131127

132128
/** {@inheritDoc} */
133129
@Override
@@ -158,9 +154,7 @@ public boolean solved() {
158154
* Getter for the field <code>energyStream</code>.
159155
* </p>
160156
*
161-
* @return a
162-
* {@link neqsim.processSimulation.processEquipment.stream.EnergyStream}
163-
* object
157+
* @return a {@link neqsim.processSimulation.processEquipment.stream.EnergyStream} object
164158
*/
165159
public EnergyStream getEnergyStream() {
166160
return energyStream;
@@ -171,9 +165,8 @@ public EnergyStream getEnergyStream() {
171165
* Setter for the field <code>energyStream</code>.
172166
* </p>
173167
*
174-
* @param energyStream a
175-
* {@link neqsim.processSimulation.processEquipment.stream.EnergyStream}
176-
* object
168+
* @param energyStream a {@link neqsim.processSimulation.processEquipment.stream.EnergyStream}
169+
* object
177170
*/
178171
public void setEnergyStream(EnergyStream energyStream) {
179172
setEnergyStream(true);
@@ -240,8 +233,7 @@ public double getExergyChange(String unit, double surroundingTemperature) {
240233

241234
/** {@inheritDoc} */
242235
@Override
243-
public void runConditionAnalysis(ProcessEquipmentInterface refExchanger) {
244-
}
236+
public void runConditionAnalysis(ProcessEquipmentInterface refExchanger) {}
245237

246238
public String conditionAnalysisMessage = "";
247239

src/main/java/neqsim/processSimulation/util/monitor/StreamResponse.java

+141-11
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,156 @@ public class StreamResponse {
2323
public Double massflowGas;
2424
public Double massflowOil;
2525
public Double massflowAqueous;
26-
public HashMap<String, Value> data = new HashMap<String, Value>();
26+
public HashMap<String, HashMap<String, Value>> properties =
27+
new HashMap<String, HashMap<String, Value>>();
28+
public HashMap<String, HashMap<String, Value>> conditions =
29+
new HashMap<String, HashMap<String, Value>>();
30+
public HashMap<String, HashMap<String, Value>> composition =
31+
new HashMap<String, HashMap<String, Value>>();
2732

2833
/**
2934
* <p>
3035
* Constructor for StreamResponse.
3136
* </p>
3237
*
33-
* @param inputStream a
34-
* {@link neqsim.processSimulation.processEquipment.stream.StreamInterface}
35-
* object
38+
* @param inputStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface}
39+
* object
3640
*/
3741
public StreamResponse(StreamInterface inputStream) {
3842

3943
name = inputStream.getName();
4044

41-
data.put("temperature",
42-
new Value(Double.toString(inputStream.getTemperature(neqsim.util.unit.Units.getSymbol("temperature"))),
45+
HashMap<String, Value> newdata = new HashMap<String, Value>();
46+
newdata.put("temperature",
47+
new Value(
48+
Double.toString(
49+
inputStream.getTemperature(neqsim.util.unit.Units.getSymbol("temperature"))),
4350
neqsim.util.unit.Units.getSymbol("temperature")));
44-
data.put("pressure",
45-
new Value(Double.toString(inputStream.getPressure(neqsim.util.unit.Units.getSymbol("pressure"))),
51+
newdata.put("pressure",
52+
new Value(
53+
Double.toString(inputStream.getPressure(neqsim.util.unit.Units.getSymbol("pressure"))),
4654
neqsim.util.unit.Units.getSymbol("pressure")));
55+
newdata.put("molar flow",
56+
new Value(
57+
Double
58+
.toString(inputStream.getFlowRate(neqsim.util.unit.Units.getSymbol("molar flow"))),
59+
neqsim.util.unit.Units.getSymbol("molar flow")));
60+
newdata.put("mass flow",
61+
new Value(
62+
Double.toString(inputStream.getFlowRate(neqsim.util.unit.Units.getSymbol("mass flow"))),
63+
neqsim.util.unit.Units.getSymbol("mass flow")));
64+
newdata.put("fluid model", new Value(inputStream.getFluid().getModelName(), ""));
65+
newdata.put("enthalpy",
66+
new Value(
67+
Double.toString(
68+
inputStream.getFluid().getEnthalpy(neqsim.util.unit.Units.getSymbol("enthalpy"))),
69+
neqsim.util.unit.Units.getSymbol("enthalpy")));
70+
conditions.put(name, newdata);
71+
72+
for (int i = 0; i < inputStream.getFluid().getNumberOfPhases(); i++) {
73+
String name = inputStream.getFluid().getPhase(i).getPhaseTypeName();
74+
newdata = new HashMap<String, Value>();
75+
newdata.put("temperature",
76+
new Value(
77+
Double.toString(inputStream.getFluid().getPhase(name)
78+
.getTemperature(neqsim.util.unit.Units.getSymbol("temperature"))),
79+
neqsim.util.unit.Units.getSymbol("temperature")));
80+
newdata.put("pressure",
81+
new Value(
82+
Double.toString(inputStream.getFluid().getPhase(name)
83+
.getPressure(neqsim.util.unit.Units.getSymbol("pressure"))),
84+
neqsim.util.unit.Units.getSymbol("pressure")));
85+
newdata.put("molar flow",
86+
new Value(
87+
Double.toString(inputStream.getFluid().getPhase(name)
88+
.getFlowRate(neqsim.util.unit.Units.getSymbol("molar flow"))),
89+
neqsim.util.unit.Units.getSymbol("molar flow")));
90+
newdata.put("mass flow",
91+
new Value(
92+
Double.toString(inputStream.getFluid().getPhase(name)
93+
.getFlowRate(neqsim.util.unit.Units.getSymbol("mass flow"))),
94+
neqsim.util.unit.Units.getSymbol("mass flow")));
95+
newdata.put("fluid model", new Value(inputStream.getFluid().getModelName(), ""));
96+
newdata.put("enthalpy",
97+
new Value(
98+
Double.toString(inputStream.getFluid().getPhase(name)
99+
.getEnthalpy(neqsim.util.unit.Units.getSymbol("enthalpy"))),
100+
neqsim.util.unit.Units.getSymbol("enthalpy")));
101+
conditions.put(name, newdata);
102+
}
103+
104+
105+
newdata = new HashMap<String, Value>();
106+
for (int i = 0; i < inputStream.getFluid().getNumberOfComponents(); i++) {
107+
newdata.put(inputStream.getFluid().getComponent(i).getComponentName(), new Value(
108+
Double.toString(inputStream.getFluid().getComponent(i).getz()), "mole fraction"));
109+
}
110+
composition.put(name, newdata);
111+
for (int j = 0; j < inputStream.getFluid().getNumberOfPhases(); j++) {
112+
newdata = new HashMap<String, Value>();
113+
for (int i = 0; i < inputStream.getFluid().getNumberOfComponents(); i++) {
114+
newdata.put(inputStream.getFluid().getPhase(j).getComponent(i).getComponentName(),
115+
new Value(Double.toString(inputStream.getFluid().getPhase(j).getComponent(i).getx()),
116+
"mole fraction"));
117+
newdata.put(inputStream.getFluid().getPhase(j).getComponent(i).getComponentName(),
118+
new Value(Double.toString(inputStream.getFluid().getPhase(j).getWtFrac(i)),
119+
"weight fraction"));
120+
composition.put(inputStream.getFluid().getPhase(j).getPhaseTypeName(), newdata);
121+
122+
}
123+
}
124+
125+
126+
127+
newdata = new HashMap<String, Value>();
128+
129+
newdata.put("density",
130+
new Value(
131+
Double.toString(
132+
inputStream.getFluid().getDensity(neqsim.util.unit.Units.getSymbol("density"))),
133+
neqsim.util.unit.Units.getSymbol("density")));
134+
135+
newdata.put("molar mass", new Value(
136+
Double.toString(
137+
inputStream.getFluid().getMolarMass(neqsim.util.unit.Units.getSymbol("Molar Mass"))),
138+
neqsim.util.unit.Units.getSymbol("Molar Mass")));
139+
properties.put(inputStream.getName(), newdata);
140+
141+
newdata.put("flow rate", new Value(
142+
Double.toString(
143+
inputStream.getFluid().getFlowRate(neqsim.util.unit.Units.getSymbol("volume flow"))),
144+
neqsim.util.unit.Units.getSymbol("volume flow")));
145+
properties.put(inputStream.getName(), newdata);
146+
147+
148+
properties.put(inputStream.getName(), newdata);
149+
150+
newdata = new HashMap<String, Value>();
151+
for (
152+
153+
int i = 0; i < inputStream.getFluid().getNumberOfPhases(); i++) {
154+
String name = inputStream.getFluid().getPhase(i).getPhaseTypeName();
155+
newdata.put("density",
156+
new Value(
157+
Double.toString(inputStream.getFluid().getPhase(name)
158+
.getDensity(neqsim.util.unit.Units.getSymbol("density"))),
159+
neqsim.util.unit.Units.getSymbol("density")));
160+
161+
newdata.put("molar mass",
162+
new Value(
163+
Double.toString(inputStream.getFluid().getPhase(name)
164+
.getMolarMass(neqsim.util.unit.Units.getSymbol("Molar Mass"))),
165+
neqsim.util.unit.Units.getSymbol("Molar Mass")));
166+
167+
newdata.put("flow rate",
168+
new Value(
169+
Double.toString(inputStream.getFluid().getPhase(name)
170+
.getFlowRate(neqsim.util.unit.Units.getSymbol("volume flow"))),
171+
neqsim.util.unit.Units.getSymbol("volume flow")));
172+
properties.put(inputStream.getName(), newdata);
173+
174+
properties.put(name, newdata);
175+
}
47176

48177
fluid = new Fluid(inputStream.getFluid());
49178
temperature = inputStream.getTemperature("C");
@@ -53,7 +182,9 @@ public StreamResponse(StreamInterface inputStream) {
53182
massflow = inputStream.getFluid().getFlowRate("kg/hr");
54183
volumeFlow = inputStream.getFluid().getFlowRate("m3/hr");
55184

56-
if (inputStream.getFluid().hasPhaseType("gas")) {
185+
if (inputStream.getFluid().hasPhaseType("gas"))
186+
187+
{
57188
massflowGas = inputStream.getFluid().getPhase("gas").getFlowRate("kg/hr");
58189
} else {
59190
massflowGas = 0.0;
@@ -75,6 +206,5 @@ public StreamResponse(StreamInterface inputStream) {
75206
* print.
76207
* </p>
77208
*/
78-
public void print() {
79-
}
209+
public void print() {}
80210
}

src/main/java/neqsim/processSimulation/util/report/Report.java

+14-9
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
* @version $Id: $Id
2020
*/
2121
public class Report {
22-
public static HashMap<String, List<String[]>> reports = new HashMap<>();
23-
public static HashMap<String, String> json_reports = new HashMap<>();
22+
private HashMap<String, List<String[]>> reports = new HashMap<>();
23+
private HashMap<String, String> json_reports = new HashMap<>();
2424
Gson gson = new Gson();
25-
ProcessSystem process;
26-
ProcessEquipmentBaseClass processEquipment;
25+
ProcessSystem process = null;
26+
ProcessEquipmentBaseClass processEquipment = null;
2727

2828
public Report(ProcessSystem process) {
2929
this.process = process;
@@ -38,12 +38,17 @@ public Report(ProcessModule processModule) {
3838
}
3939

4040
public Report(ProcessModuleBaseClass processModuleBaseClass) {
41-
//TODO Auto-generated constructor stub
42-
}
41+
// TODO Auto-generated constructor stub
42+
}
4343

44-
public String json() {
45-
for (ProcessEquipmentInterface unit : process.getUnitOperations()) {
46-
json_reports.put(unit.getName(), unit.toJson());
44+
public String json() {
45+
if (process != null) {
46+
for (ProcessEquipmentInterface unit : process.getUnitOperations()) {
47+
json_reports.put(unit.getName(), unit.toJson());
48+
}
49+
}
50+
if (processEquipment != null) {
51+
json_reports.put(processEquipment.getName(), processEquipment.toJson());
4752
}
4853
return new GsonBuilder().setPrettyPrinting().create().toJson(json_reports);
4954
}

src/main/java/neqsim/thermo/phase/Phase.java

+13
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public abstract class Phase implements PhaseInterface {
5353
* not known to the phase.
5454
*/
5555
double beta = 1.0;
56+
5657
/**
5758
* Number of moles in phase. <code>numberOfMolesInPhase = numberOfMolesInSystem*beta</code>. NB!
5859
* numberOfMolesInSystem is not known to the phase.
@@ -2265,6 +2266,12 @@ public double getFlowRate(String flowunit) {
22652266
return numberOfMolesInPhase * 3600.0 * 24.0 * ThermodynamicConstantsInterface.R
22662267
* ThermodynamicConstantsInterface.standardStateTemperature
22672268
/ ThermodynamicConstantsInterface.atm / 1.0e6;
2269+
} else if (flowunit.equals("lbmole/hr")) {
2270+
return numberOfMolesInPhase * 3600.0 / 1000.0 * 2.205;
2271+
} else if (flowunit.equals("lb/hr")) {
2272+
return numberOfMolesInPhase * getMolarMass() * 60.0 * 2.20462262;
2273+
} else if (flowunit.equals("barrel/day")) {
2274+
return numberOfMolesInPhase * getMolarMass() * 60.0 * 2.20462262 * 0.068;
22682275
} else {
22692276
throw new RuntimeException("failed.. unit: " + flowunit + " not supported");
22702277
}
@@ -2304,4 +2311,10 @@ public double getIsothermalCompressibility() {
23042311
public double getIsobaricThermalExpansivity() {
23052312
return getIsothermalCompressibility() * getdPdTVn();
23062313
}
2314+
2315+
/** {@inheritDoc} */
2316+
@Override
2317+
public String getModelName() {
2318+
return thermoPropertyModelName;
2319+
}
23072320
}

0 commit comments

Comments
 (0)