Skip to content

Commit

Permalink
refact: Heaters are twoports (#433)
Browse files Browse the repository at this point in the history
* refact: Heaters are twoports
* refact: rm redundant method
  • Loading branch information
asmfstatoil authored Jun 4, 2022
1 parent 62f1568 commit 109057a
Show file tree
Hide file tree
Showing 32 changed files with 136 additions and 158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ public double getEntropyProduction(String unit) {

inStream.run();
inStream.getFluid().init(3);
getOutStream().run();
getOutStream().getFluid().init(3);
getOutletStream().run();
getOutletStream().getFluid().init(3);

double heatTransferEntropyProd = coolingMediumTemperature * getDuty();
System.out.println("heat entropy " + heatTransferEntropyProd);
entrop += getOutStream().getThermoSystem().getEntropy(unit)
entrop += getOutletStream().getThermoSystem().getEntropy(unit)
- inStream.getThermoSystem().getEntropy(unit);

return entrop;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
package neqsim.processSimulation.processEquipment.heatExchanger;

import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass;
import neqsim.processSimulation.processEquipment.TwoPortEquipment;
import neqsim.processSimulation.processEquipment.stream.Stream;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.thermo.system.SystemInterface;
Expand All @@ -19,12 +19,10 @@
* @author Even Solbraa
* @version $Id: $Id
*/
public class Heater extends ProcessEquipmentBaseClass implements HeaterInterface {
public class Heater extends TwoPortEquipment implements HeaterInterface {
private static final long serialVersionUID = 1000;

boolean setTemperature = false, setOutPressure = false;
private StreamInterface outStream;
StreamInterface inStream;
SystemInterface system;
protected double temperatureOut = 0, dT = 0.0, pressureOut = 0;
private boolean setEnergyInput = false;
Expand Down Expand Up @@ -82,34 +80,12 @@ public Heater(String name, StreamInterface inStream) {
outStream = new Stream("outStream", system);
}

/**
* <p>
* Getter for the field <code>inStream</code>.
* </p>
*
* @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object
*/
public StreamInterface getInStream() {
return inStream;
}

/** {@inheritDoc} */
@Override
public void setdT(double dT) {
this.dT = dT;
}

/**
* <p>
* Getter for the field <code>outStream</code>.
* </p>
*
* @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object
*/
public StreamInterface getOutStream() {
return outStream;
}

/**
* <p>
* setOutPressure.
Expand Down Expand Up @@ -178,10 +154,10 @@ public void run() {
}
ThermodynamicOperations testOps = new ThermodynamicOperations(system);
if (getSpecification().equals("out stream")) {
getOutStream().setFlowRate(getInStream().getFlowRate("kg/sec"), "kg/sec");
getOutStream().run();
temperatureOut = getOutStream().getTemperature();
system = getOutStream().getThermoSystem().clone();
getOutletStream().setFlowRate(getInletStream().getFlowRate("kg/sec"), "kg/sec");
getOutletStream().run();
temperatureOut = getOutletStream().getTemperature();
system = getOutletStream().getThermoSystem().clone();
} else if (setTemperature) {
system.setTemperature(temperatureOut, temperatureUnit);
testOps.TPflash();
Expand All @@ -203,14 +179,14 @@ public void run() {
// system.setTemperature(temperatureOut);
// testOps.TPflash();
// system.setTemperature(temperatureOut);
getOutStream().setThermoSystem(system);
getOutletStream().setThermoSystem(system);
}

/** {@inheritDoc} */
@Override
public void displayResult() {
// System.out.println("heater dH: " + energyInput);
getOutStream().displayResult();
getOutletStream().displayResult();
}

/**
Expand Down Expand Up @@ -310,8 +286,9 @@ public void setPressureDrop(double pressureDrop) {
*
* @param outStream the outStream to set
*/
@Deprecated
public void setOutStream(StreamInterface outStream) {
this.outStream = outStream;
setOutletStream(outStream);
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
public class NeqHeater extends Heater {
private static final long serialVersionUID = 1000;

StreamInterface outStream;
StreamInterface inStream;
SystemInterface system;
double dH = 0.0;

Expand Down Expand Up @@ -61,12 +59,6 @@ public NeqHeater(String name, StreamInterface inStream) {
super(name, inStream);
}

/** {@inheritDoc} */
@Override
public StreamInterface getOutStream() {
return outStream;
}

/** {@inheritDoc} */
@Override
public void setOutTemperature(double temperature) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,17 @@ public void run() {
locHeater.setEnergyInput(heatOfCombustion);
locHeater.run();

locHeater.getOutStream().getFluid().addComponent("CO2", moleMethane);
locHeater.getOutStream().getFluid().addComponent("water", moleMethane * 2.0);
locHeater.getOutStream().getFluid().addComponent("methane", -moleMethane);
locHeater.getOutStream().getFluid().addComponent("oxygen", -moleMethane * 2.0);
locHeater.getOutletStream().getFluid().addComponent("CO2", moleMethane);
locHeater.getOutletStream().getFluid().addComponent("water", moleMethane * 2.0);
locHeater.getOutletStream().getFluid().addComponent("methane", -moleMethane);
locHeater.getOutletStream().getFluid().addComponent("oxygen", -moleMethane * 2.0);

// todo: Init fails because there is less than moleMethane of oxygen
locHeater.getOutStream().getFluid().init(3);
locHeater.getOutletStream().getFluid().init(3);
// locHeater.getOutStream().run();
locHeater.displayResult();

Expander expander = new Expander("expander", locHeater.getOutStream());
Expander expander = new Expander("expander", locHeater.getOutletStream());
expander.setOutletPressure(1.01325);
expander.run();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void initializeModule() {
heatExchanger1.setOutTemperature(273.15 - 21.0);
// heatExchanger1.addInStream(feedStream2);

expander = new Expander("expander", heatExchanger2.getOutStream());
expander = new Expander("expander", heatExchanger2.getOutletStream());
expander.setOutletPressure(46.0);

LTseparator = new Separator("LTseparator", expander.getOutletStream());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ public void initializeModule() {

strippingGas.setTemperature(reboilerTemperature, "K");
strippingGas.setPressure(regenerationPressure, "bara");
stripperColumn = new Separator("stripperColumn", reboiler.getOutStream());
stripperColumn = new Separator("stripperColumn", reboiler.getOutletStream());
stripperColumn.addStream(strippingGas);

heatExchanger1 = new Cooler("heatExchanger1", stripperColumn.getLiquidOutStream());
heatExchanger1.setOutTemperature(100.0);

HPpump = new Pump("HP lean TEG pump", heatExchanger1.getOutStream());
HPpump = new Pump("HP lean TEG pump", heatExchanger1.getOutletStream());
HPpump.setOutletPressure(gasStreamToAbsorber.getPressure());

heatExchanger2 = new Cooler("heatExchanger2", HPpump.getOutStream());
Expand All @@ -199,7 +199,7 @@ public void initializeModule() {
heatExchanger3 = new Cooler("heatExchanger3", stripperColumn.getGasOutStream());
heatExchanger3.setOutTemperature(273.15 + 30.0);

waterSeparator = new Separator("watersep", heatExchanger3.getOutStream());
waterSeparator = new Separator("watersep", heatExchanger3.getOutletStream());

// leanTEGStreamToAbsorber = heatExchanger2.getOutStream();
// getOperations().add(gasStreamToAbsorber);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void initializeModule() {
// MEGrecircHeater.setEnergyInput(5000.0);
MEGrecircHeater.setOutTemperature(273 + 68.9);

recircValve = new ThrottlingValve("recircValve", MEGrecircHeater.getOutStream());
recircValve = new ThrottlingValve("recircValve", MEGrecircHeater.getOutletStream());
recircValve.setOutletPressure(reclaimerPressure);
recircValve.setIsoThermal(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void initializeModule() {
Cooler inletCooler = new Cooler("inlet well stream cooler", feedStream);
inletCooler.setOutTemperature(inletSepTemperature + 273.15);

inletSeparator = new Separator("Inlet separator", inletCooler.getOutStream());
inletSeparator = new Separator("Inlet separator", inletCooler.getOutletStream());

Cooler gasCooler = new Cooler("separator gas cooler", inletSeparator.getGasOutStream());
gasCooler.setOutTemperature(gasScrubberTemperature + 273.15);
Expand All @@ -86,7 +86,7 @@ public void initializeModule() {
oilPump.setOutletPressure(liquidPumpPressure);

Separator gasScrubber =
new Separator("HC dew point control scrubber", gasCooler.getOutStream());
new Separator("HC dew point control scrubber", gasCooler.getOutletStream());

Recycle HPliquidRecycle = new Recycle("Resycle");
double tolerance = 1e-2;
Expand All @@ -109,7 +109,7 @@ public void initializeModule() {
mixerAfterCooler.setOutTemperature(glycolScrubberTemperature + 273.15);

glycolScrubber =
new Separator("Water dew point control scrubber", mixerAfterCooler.getOutStream());
new Separator("Water dew point control scrubber", mixerAfterCooler.getOutletStream());

secondStageCompressor =
new Compressor("2nd stage compressor", glycolScrubber.getGasOutStream());
Expand Down Expand Up @@ -147,7 +147,7 @@ public void run() {
}
getOperations().run();

gasExitStream = secondStageAfterCooler.getOutStream();
gasExitStream = secondStageAfterCooler.getOutletStream();
oilExitStream = oilPump.getOutStream();
glycolExitStream = glycolScrubber.getLiquidOutStream();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void initializeModule() {
cooler.setPressureDrop(0.35);
cooler.setSpecification("out stream");

Stream stream_2 = new Stream("stream_2", cooler.getOutStream());
Stream stream_2 = new Stream("stream_2", cooler.getOutletStream());
stream_2.setSpecification("dewT");
stream_2.getThermoSystem().setTemperature(vaporizerTemperature);
stream_2.run();
Expand Down Expand Up @@ -186,18 +186,18 @@ public static void main(String[] args) {
.getEnergyInput();
double evaporatorPressure =
((Cooler) propaneModule.getOperations().getUnit("propane evaporator"))
.getOutStream().getPressure();
.getOutletStream().getPressure();
double evaporatorTemperature =
((Cooler) propaneModule.getOperations().getUnit("propane evaporator"))
.getOutStream().getTemperature();
.getOutletStream().getTemperature();

double condenserDuty = ((Heater) propaneModule.getOperations().getUnit("propane condenser"))
.getEnergyInput();
double condenserPressure =
((Heater) propaneModule.getOperations().getUnit("propane condenser")).getOutStream()
((Heater) propaneModule.getOperations().getUnit("propane condenser")).getOutletStream()
.getPressure();
double condenserTemperature =
((Heater) propaneModule.getOperations().getUnit("propane condenser")).getOutStream()
((Heater) propaneModule.getOperations().getUnit("propane condenser")).getOutletStream()
.getTemperature();

System.out.println("Compressor work " + compressorWork + " W");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void run() {
getOperations().run();

gasExitStream = gasInletScrubber.getGasOutStream();
oilExitStream = oilCooler.getOutStream();
oilExitStream = oilCooler.getOutletStream();
}

/** {@inheritDoc} */
Expand All @@ -84,7 +84,7 @@ public void initializeModule() {
liquidOutHeater.setOutTemperature(heatedOilTemperature);

ThreePhaseSeparator firstStageSeparator =
new ThreePhaseSeparator("1st stage separator", liquidOutHeater.getOutStream());
new ThreePhaseSeparator("1st stage separator", liquidOutHeater.getOutletStream());

ThrottlingValve valve1 =
new ThrottlingValve("1stTo2ndStageOilValve", firstStageSeparator.getOilOutStream());
Expand Down Expand Up @@ -112,7 +112,7 @@ public void initializeModule() {
thirdSstageCoooler.setOutTemperature(firstStageCompressorAfterCoolerTemperature);

Mixer thirdStageMixer = new Mixer("1st and 2nd stage gas mixer");
thirdStageMixer.addStream(thirdSstageCoooler.getOutStream());
thirdStageMixer.addStream(thirdSstageCoooler.getOutletStream());
thirdStageMixer.addStream(secondStageSeparator.getGasOutStream());

Separator thirdStageScrubber =
Expand All @@ -131,7 +131,7 @@ public void initializeModule() {
Cooler inletGasCooler = new Cooler("HP gas cooler", HPgasMixer.getOutStream());
inletGasCooler.setOutTemperature(exitGasScrubberTemperature);

gasInletScrubber = new Separator("HP gas scrubber", inletGasCooler.getOutStream());
gasInletScrubber = new Separator("HP gas scrubber", inletGasCooler.getOutletStream());

Recycle HPliquidRecycle = new Recycle("Resycle");
double tolerance = 1e-10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void run() {
getOperations().run();

gasExitStream = gasInletScrubber.getGasOutStream();
oilExitStream = oilCooler.getOutStream();
oilExitStream = oilCooler.getOutletStream();
}

/** {@inheritDoc} */
Expand All @@ -84,7 +84,7 @@ public void initializeModule() {
liquidOutHeater.setOutTemperature(heatedOilTemperature);

ThreePhaseSeparator firstStageSeparator =
new ThreePhaseSeparator("1st stage separator", liquidOutHeater.getOutStream());
new ThreePhaseSeparator("1st stage separator", liquidOutHeater.getOutletStream());

ThrottlingValve valve1 =
new ThrottlingValve("1stTo2ndStageOilValve", firstStageSeparator.getOilOutStream());
Expand Down Expand Up @@ -112,7 +112,7 @@ public void initializeModule() {
thirdSstageCoooler.setOutTemperature(firstStageCompressorAfterCoolerTemperature);

Mixer thirdStageMixer = new Mixer("1st and 2nd stage gas mixer");
thirdStageMixer.addStream(thirdSstageCoooler.getOutStream());
thirdStageMixer.addStream(thirdSstageCoooler.getOutletStream());
thirdStageMixer.addStream(secondStageSeparator.getGasOutStream());

Separator thirdStageScrubber =
Expand All @@ -131,7 +131,7 @@ public void initializeModule() {
Cooler inletGasCooler = new Cooler("HP gas cooler", HPgasMixer.getOutStream());
inletGasCooler.setOutTemperature(exitGasScrubberTemperature);

gasInletScrubber = new Separator("HP gas scrubber", inletGasCooler.getOutStream());
gasInletScrubber = new Separator("HP gas scrubber", inletGasCooler.getOutletStream());

Recycle HPliquidRecycle = new Recycle("Resycle");
double tolerance = 1e-10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void run() {
// ((Heater) getOperations().getUnit("gas heater")).displayResult();

Stream gasStream =
(Stream) ((Heater) getOperations().getUnit("gas heater")).getOutStream().clone();
(Stream) ((Heater) getOperations().getUnit("gas heater")).getOutletStream().clone();
gasStream.getThermoSystem().setPressure(inletPressure);
Stream oilStream =
(Stream) ((ThreePhaseSeparator) getOperations().getUnit("3rd stage Separator"))
Expand Down Expand Up @@ -104,7 +104,7 @@ public void initializeModule() {
liquidOutHeater.setOutTemperature(separationTemperature);

ThreePhaseSeparator firstStageSeparator =
new ThreePhaseSeparator("1st stage separator", liquidOutHeater.getOutStream());
new ThreePhaseSeparator("1st stage separator", liquidOutHeater.getOutletStream());

ThrottlingValve valve1 =
new ThrottlingValve("1stTo2ndStageOilValve", firstStageSeparator.getOilOutStream());
Expand All @@ -114,7 +114,7 @@ public void initializeModule() {
liquidOutHeater2.setOutTemperature(separationTemperature);

ThreePhaseSeparator secondStageSeparator =
new ThreePhaseSeparator("2nd stage Separator", liquidOutHeater2.getOutStream());
new ThreePhaseSeparator("2nd stage Separator", liquidOutHeater2.getOutletStream());

ThrottlingValve thirdStageValve =
new ThrottlingValve("2-3stageOilValve", secondStageSeparator.getLiquidOutStream());
Expand All @@ -125,7 +125,7 @@ public void initializeModule() {
liquidOutHeater3.setOutTemperature(separationTemperature);

ThreePhaseSeparator thirdStageSeparator =
new ThreePhaseSeparator("3rd stage Separator", liquidOutHeater3.getOutStream());
new ThreePhaseSeparator("3rd stage Separator", liquidOutHeater3.getOutletStream());

Mixer gasMixer = new Mixer("gas mixer");

Expand All @@ -139,7 +139,7 @@ public void initializeModule() {

Mixer wellStreamMixer = new Mixer("well mixer");
wellStreamMixer.addStream(thirdStageSeparator.getOilOutStream());
wellStreamMixer.addStream(gasHeater.getOutStream());
wellStreamMixer.addStream(gasHeater.getOutletStream());

getOperations().add(inletSeparator);
getOperations().add(liquidOutHeater);
Expand Down
Loading

0 comments on commit 109057a

Please sign in to comment.