Skip to content

Commit

Permalink
added error pressure (#1160)
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol authored Nov 3, 2024
1 parent f9f5788 commit df5659e
Showing 1 changed file with 72 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ public class Recycle extends ProcessEquipmentBaseClass implements MixerInterface
private double errorComposition = 1e10;
private double errorFlow = 1e10;
private double errorTemperature = 1e10;
private double errorPressure = 1e10;
private double flowTolerance = 1e-2;
private double compositionTolerance = 1e-2;
private double temperatureTolerance = 1e-2;
private double pressureTolerance = 1e-2;

/**
* <p>
Expand Down Expand Up @@ -181,7 +183,9 @@ public void addStream(StreamInterface newStream) {
* </p>
*
* @param i a int
* @return a {@link neqsim.processsimulation.processequipment.stream.StreamInterface} object
* @return a
* {@link neqsim.processsimulation.processequipment.stream.StreamInterface}
* object
*/
public StreamInterface getStream(int i) {
return streams.get(i);
Expand All @@ -200,22 +204,19 @@ public void mixStream() {
for (int i = 0; i < streams.get(k).getThermoSystem().getPhase(0)
.getNumberOfComponents(); i++) {
boolean gotComponent = false;
String componentName =
streams.get(k).getThermoSystem().getPhase(0).getComponent(i).getName();
String componentName = streams.get(k).getThermoSystem().getPhase(0).getComponent(i).getName();
// logger.info("adding: " + componentName);
// int numberOfPhases = streams.get(k).getThermoSystem().getNumberOfPhases();

double moles =
streams.get(k).getThermoSystem().getPhase(0).getComponent(i).getNumberOfmoles();
double moles = streams.get(k).getThermoSystem().getPhase(0).getComponent(i).getNumberOfmoles();
// logger.info("moles: " + moles + " " +
// mixedStream.getThermoSystem().getPhase(0).getNumberOfComponents());
for (int p = 0; p < mixedStream.getThermoSystem().getPhase(0)
.getNumberOfComponents(); p++) {
if (mixedStream.getThermoSystem().getPhase(0).getComponent(p).getName()
.equals(componentName)) {
gotComponent = true;
index =
streams.get(0).getThermoSystem().getPhase(0).getComponent(p).getComponentNumber();
index = streams.get(0).getThermoSystem().getPhase(0).getComponent(p).getComponentNumber();
// compName = streams.get(0).getThermoSystem().getPhase(0).getComponent(p)
// .getComponentName();
}
Expand Down Expand Up @@ -285,8 +286,9 @@ public StreamInterface getOutStream() {
* initiateDownstreamProperties.
* </p>
*
* @param outstream a {@link neqsim.processsimulation.processequipment.stream.StreamInterface}
* object
* @param outstream a
* {@link neqsim.processsimulation.processequipment.stream.StreamInterface}
* object
*/
public void initiateDownstreamProperties(StreamInterface outstream) {
lastIterationStream = outstream.clone();
Expand Down Expand Up @@ -349,6 +351,7 @@ public void run(UUID id) {
setErrorCompositon(compositionBalanceCheck());
setErrorFlow(flowBalanceCheck());
setErrorTemperature(temperatureBalanceCheck());
setErrorPressure(pressureBalanceCheck());
lastIterationStream = mixedStream.clone();
outletStream.setThermoSystem(mixedStream.getThermoSystem());
outletStream.setCalculationIdentifier(id);
Expand All @@ -374,12 +377,10 @@ public void run(UUID id) {
public double flowBalanceCheck() {
double abs_sum_errorFlow = 0.0;
if (mixedStream.getFlowRate("kg/sec") < 1.0) {
abs_sum_errorFlow +=
Math.abs(mixedStream.getFlowRate("kg/sec") - lastIterationStream.getFlowRate("kg/sec"));
abs_sum_errorFlow += Math.abs(mixedStream.getFlowRate("kg/sec") - lastIterationStream.getFlowRate("kg/sec"));
} else {
abs_sum_errorFlow +=
Math.abs(mixedStream.getFlowRate("kg/sec") - lastIterationStream.getFlowRate("kg/sec"))
/ mixedStream.getFlowRate("kg/sec") * 100.0;
abs_sum_errorFlow += Math.abs(mixedStream.getFlowRate("kg/sec") - lastIterationStream.getFlowRate("kg/sec"))
/ mixedStream.getFlowRate("kg/sec") * 100.0;
}
return abs_sum_errorFlow;
}
Expand All @@ -406,7 +407,6 @@ public double compositionBalanceCheck() {
return abs_sum_error;
}


/**
* <p>
* temperatureBalanceCheck.
Expand All @@ -424,9 +424,27 @@ public double temperatureBalanceCheck() {
return error;
}

/**
* <p>
* pressureBalanceCheck.
* </p>
*
* @return a double
*/
public double pressureBalanceCheck() {
double error = 0.0;
for (int i = 0; i < mixedStream.getThermoSystem().getNumberOfPhases(); i++) {
error += Math.abs((mixedStream.getThermoSystem().getPhase(i).getPressure()
- lastIterationStream.getThermoSystem().getPhase(i).getPressure())
/ lastIterationStream.getThermoSystem().getPhase(i).getPressure()) * 100.0;
}
return error;
}

/** {@inheritDoc} */
@Override
public void displayResult() {}
public void displayResult() {
}

/** {@inheritDoc} */
@Override
Expand Down Expand Up @@ -476,6 +494,17 @@ public void setErrorTemperature(double errorTemperature) {
this.errorTemperature = errorTemperature;
}

/**
* <p>
* Setter for the field <code>errorPressure</code>.
* </p>
*
* @param errorPressure the errorPressure to set
*/
public void setErrorPressure(double errorPressure) {
this.errorPressure = errorPressure;
}

/**
* <p>
* Setter for the field <code>errorFlow</code>.
Expand All @@ -498,6 +527,28 @@ public double getErrorFlow() {
return errorFlow;
}

/**
* <p>
* Getter for the field <code>errorTemperature</code>.
* </p>
*
* @return a double
*/
public double getErrorTemperature() {
return errorTemperature;
}

/**
* <p>
* Getter for the field <code>errorPressure</code>.
* </p>
*
* @return a double
*/
public double getErrorPressure() {
return errorPressure;
}

/**
* <p>
* Setter for the field <code>errorComposition</code>.
Expand Down Expand Up @@ -547,7 +598,8 @@ public void setPriority(int priority) {
public boolean solved() {
if (Math.abs(this.errorComposition) < compositionTolerance
&& Math.abs(this.errorFlow) < flowTolerance
&& Math.abs(this.errorTemperature) < temperatureTolerance && iterations > 1) {
&& Math.abs(this.errorTemperature) < temperatureTolerance
&& Math.abs(this.errorPressure) < pressureTolerance && iterations > 1) {
return true;
} else {
return false;
Expand Down Expand Up @@ -576,8 +628,9 @@ public StreamInterface getOutletStream() {
* Setter for the field <code>outletStream</code>.
* </p>
*
* @param outletStream a {@link neqsim.processsimulation.processequipment.stream.StreamInterface}
* object
* @param outletStream a
* {@link neqsim.processsimulation.processequipment.stream.StreamInterface}
* object
*/
public void setOutletStream(StreamInterface outletStream) {
this.outletStream = outletStream;
Expand Down

0 comments on commit df5659e

Please sign in to comment.