Skip to content

refactor: Compressors have a single inlet and a single outlet and are twoports #426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package neqsim.processSimulation.processEquipment;

import neqsim.processSimulation.processEquipment.stream.StreamInterface;

public abstract class TwoPortEquipment extends ProcessEquipmentBaseClass implements TwoPortInterface {
protected StreamInterface inStream;
protected StreamInterface outStream;

/**
* Constructor for TwoPortEquipment
*
* @param name Name of TwoPortEquipment
*/
public TwoPortEquipment(String name) {
super(name);
}

/**
* Constructor for TwoPortEquipment
*
* @param name Name of TwoPortEquipment
* @param stream Stream to set as inlet Stream. A clone of stream is set as
* outlet stream.
*/
public TwoPortEquipment(String name, StreamInterface stream) {
this(name);
this.inStream = stream;
this.outStream = stream.clone();
}

/** {@inheritDoc} */
@Override
public double getInletPressure() {
return getInletStream().getPressure();
}

/** {@inheritDoc} */
@Override
public StreamInterface getInletStream() {
return inStream;
}

/** {@inheritDoc} */
@Override
public double getInletTemperature() {
return getInletStream().getTemperature();
}

/** {@inheritDoc} */
@Override
public double getOutletPressure() {
return getOutletStream().getPressure();
}

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

/** {@inheritDoc} */
@Override
public double getOutletTemperature() {
return getOutletStream().getTemperature();
}

/** {@inheritDoc} */
@Override
public void setInletPressure(double pressure) {
this.inStream.setPressure(pressure);
}

/** {@inheritDoc} */
@Override
public void setInletStream(StreamInterface stream) {
this.inStream = stream;
}

/** {@inheritDoc} */
@Override
public void setInletTemperature(double temperature) {
this.inStream.setTemperature(temperature, "unit");
}

/** {@inheritDoc} */
@Override
public void setOutletPressure(double pressure) {
this.outStream.setPressure(pressure);
}

/** {@inheritDoc} */
@Override
public void setOutletStream(StreamInterface stream) {
this.outStream = stream;
}

/** {@inheritDoc} */
@Override
public void setOutletTemperature(double temperature) {
this.outStream.setTemperature(temperature, "unit");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package neqsim.processSimulation.processEquipment;

import neqsim.processSimulation.processEquipment.stream.StreamInterface;

public interface TwoPortInterface {
/**
* Get inlet pressure of twoport.
*
* @return inlet pressure of TwoPortEquipment in unit bara
*/
public double getInletPressure();

/**
* Get inlet Stream of twoport.
*
* @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object
*/
@Deprecated
default public StreamInterface getInStream() {
return getInletStream();
}

/**
* Get inlet Stream of twoport.
*
* @return inlet Stream of TwoPortEquipment
*/
public StreamInterface getInletStream();

/**
* Get inlet temperature of twoport.
*
* @return inlet temperature of TwoPortEquipment in unit kelvin
*/
public double getInletTemperature();

/**
* Get outlet pressure of twoport.
*
* @return outlet pressure of TwoPortEquipment in unit bara
*/
public double getOutletPressure();

/**
* Get outlet Stream of twoport.
*
* @deprecated use {@link #getOutletStream()} instead
* @return outlet Stream of TwoPortEquipment
*/
@Deprecated
default public StreamInterface getOutStream() {
return getOutletStream();
}

/**
* Get outlet Stream of twoport.
*
* @return outlet Stream of TwoPortEquipment
*/
public StreamInterface getOutletStream();

/**
* Get outlet temperature of twoport.
*
* @return outlet temperature of TwoPortEquipment in unit kelvin
*/
public double getOutletTemperature();

/**
* Set inlet pressure of twoport.
*
* @param pressure value to set in unit bara
*/
public void setInletPressure(double pressure);

/**
* Set inlet Stream of twoport.
*
* @param inletStream value to set
*/
public void setInletStream(StreamInterface inletStream);

/**
* Set inlet temperature of twoport.
*
* @param temperature value to set in unit kelvin
*/
public void setInletTemperature(double temperature);

/**
* Set outlet pressure of twoport.
*
* @param pressure value to set in unit bara
*/
public void setOutletPressure(double pressure);

/**
* Set outlet Stream of twoport.
*
* @param stream value to set
*/
public void setOutletStream(StreamInterface stream);

/**
* Set outlet temperature of twoport.
*
* @param temperature value to set in kelvin
*/
public void setOutletTemperature(double temperature);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@
import java.text.DecimalFormat;
import java.text.FieldPosition;
import java.util.Objects;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import neqsim.processSimulation.mechanicalDesign.compressor.CompressorMechanicalDesign;
import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass;
import neqsim.processSimulation.processEquipment.TwoPortEquipment;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.thermo.ThermodynamicConstantsInterface;
import neqsim.thermo.system.SystemInterface;
Expand All @@ -29,12 +26,10 @@
* @author esol
* @version $Id: $Id
*/
public class Compressor extends ProcessEquipmentBaseClass implements CompressorInterface {
public class Compressor extends TwoPortEquipment implements CompressorInterface {
private static final long serialVersionUID = 1000;
static Logger logger = LogManager.getLogger(Compressor.class);
public SystemInterface thermoSystem;
public StreamInterface inletStream;
public StreamInterface outStream;
private double outTemperature = 298.15;
private boolean useOutTemperature = false;
private CompressorPropertyProfile propertyProfile = new CompressorPropertyProfile();
Expand Down Expand Up @@ -149,7 +144,7 @@ public Compressor copy() {
/** {@inheritDoc} */
@Override
public void setInletStream(StreamInterface inletStream) {
this.inletStream = inletStream;
this.inStream = inletStream;
try {
this.outStream = inletStream.clone();
} catch (Exception e) {
Expand Down Expand Up @@ -245,23 +240,6 @@ public void setPower(double p) {
dH = p;
}

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

/**
* <p>
* getInStream.
* </p>
*
* @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object
*/
public StreamInterface getInStream() {
return inletStream;
}

/**
* Calculates polytropic or isentropic efficiency
*
Expand Down Expand Up @@ -331,7 +309,7 @@ public double findOutPressure(double hinn, double hout, double polytropicEfficie
/** {@inheritDoc} */
@Override
public void run() {
thermoSystem = inletStream.getThermoSystem().clone();
thermoSystem = inStream.getThermoSystem().clone();
ThermodynamicOperations thermoOps = new ThermodynamicOperations(getThermoSystem());
thermoOps = new ThermodynamicOperations(getThermoSystem());
getThermoSystem().init(3);
Expand Down Expand Up @@ -1165,14 +1143,14 @@ public void setPressure(double pressure, String unit) {
@Override
public double getEntropyProduction(String unit) {
return outStream.getThermoSystem().getEntropy(unit)
- inletStream.getThermoSystem().getEntropy(unit);
- inStream.getThermoSystem().getEntropy(unit);
}

/** {@inheritDoc} */
@Override
public double getExergyChange(String unit, double surroundingTemperature) {
return outStream.getThermoSystem().getExergy(surroundingTemperature, unit)
- inletStream.getThermoSystem().getExergy(surroundingTemperature, unit);
- inStream.getThermoSystem().getExergy(surroundingTemperature, unit);
}

/**
Expand Down Expand Up @@ -1228,8 +1206,8 @@ public void setPropertyProfile(CompressorPropertyProfile propertyProfile) {
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + Objects.hash(antiSurge, compressorChart, dH, inletEnthalpy,
inletStream, isentropicEfficiency, numberOfCompressorCalcSteps, outStream, outTemperature,
result = prime * result + Objects.hash(antiSurge, compressorChart, dH, inletEnthalpy, inStream,
isentropicEfficiency, numberOfCompressorCalcSteps, outStream, outTemperature,
polytropicEfficiency, polytropicExponent, polytropicFluidHead, polytropicHead,
polytropicHeadMeter, polytropicMethod, powerSet, pressure, pressureUnit, speed,
thermoSystem, useGERG2008, useOutTemperature, usePolytropicCalc,
Expand All @@ -1251,7 +1229,7 @@ public boolean equals(Object obj) {
&& Objects.equals(compressorChart, other.compressorChart)
&& Double.doubleToLongBits(dH) == Double.doubleToLongBits(other.dH)
&& Double.doubleToLongBits(inletEnthalpy) == Double.doubleToLongBits(other.inletEnthalpy)
&& Objects.equals(inletStream, other.inletStream)
&& Objects.equals(inStream, other.inStream)
&& Double.doubleToLongBits(isentropicEfficiency) == Double
.doubleToLongBits(other.isentropicEfficiency)
&& numberOfCompressorCalcSteps == other.numberOfCompressorCalcSteps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package neqsim.processSimulation.processEquipment.compressor;

import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.processSimulation.processEquipment.TwoPortInterface;

/**
* <p>
Expand All @@ -16,27 +16,7 @@
* @author esol
* @version $Id: $Id
*/
public interface CompressorInterface extends ProcessEquipmentInterface {

/**
* <p>
* setOutletPressure.
* </p>
*
* @param pressure a double
*/
public void setOutletPressure(double pressure);

/**
* <p>
* setInletStream.
* </p>
*
* @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface}
* object
*/
public void setInletStream(StreamInterface inletStream);

public interface CompressorInterface extends ProcessEquipmentInterface, TwoPortInterface {
/**
* <p>
* getEnergy.
Expand All @@ -46,16 +26,6 @@ public interface CompressorInterface extends ProcessEquipmentInterface {
*/
public double getEnergy();


/**
* <p>
* getOutStream.
* </p>
*
* @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object
*/
public StreamInterface getOutStream();

/**
* <p>
* getIsentropicEfficiency.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Expander(String name, StreamInterface inletStream) {
@Override
public void run() {
// System.out.println("expander running..");
thermoSystem = inletStream.getThermoSystem().clone();
thermoSystem = inStream.getThermoSystem().clone();
ThermodynamicOperations thermoOps = new ThermodynamicOperations(getThermoSystem());
thermoOps = new ThermodynamicOperations(thermoSystem);
thermoSystem.init(3);
Expand Down
Loading