Skip to content

Feat serialization of process models #321

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 18 commits into from
Feb 16, 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
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
.classpath
.factorypath

# BAckup of java files
# Backup of java files
*.java~

# Log file
Expand Down Expand Up @@ -72,4 +72,7 @@ src/main/java/neqsim/util/database/NeqSimDataBase2.java

neqsim.iml

.DS_Store
.DS_Store

# Test output - Serialized files
test_*.ser
7 changes: 7 additions & 0 deletions eclipse_dictionary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
exergy
kelvin
enthalpy
reboiler
polytropic
rpm
kappa
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,12 @@ public interface ControllerDeviceInterface extends java.io.Serializable {
* @param Td a double
*/
public void setControllerParameters(double Ksp, double Ti, double Td);

/** {@inheritDoc} */
@Override
public boolean equals(Object o);

/** {@inheritDoc} */
@Override
public int hashCode();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package neqsim.processSimulation.costEstimation;

import java.util.ArrayList;
import java.util.Objects;

import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface;
import neqsim.processSimulation.processSystem.ProcessSystem;

Expand All @@ -15,25 +17,29 @@
public class CostEstimateBaseClass implements java.io.Serializable {
private static final long serialVersionUID = 1000;

ProcessSystem procesSystem = null;
private ProcessSystem processSystem;
private double CAPEXperWeight = 1000.0; // KNOK/tones

/**
* <p>
* Constructor for CostEstimateBaseClass.
* </p>
*
* @param process a {@link neqsim.processSimulation.processSystem.ProcessSystem}
* object
*/
public CostEstimateBaseClass() {}
public CostEstimateBaseClass(ProcessSystem process) {
this.processSystem = process;
}

/**
* <p>
* Constructor for CostEstimateBaseClass.
* </p>
*
* @param procesSystem a {@link neqsim.processSimulation.processSystem.ProcessSystem} object
*
* @param process
* @param costFactor
*/
public CostEstimateBaseClass(ProcessSystem procesSystem) {
this.procesSystem = procesSystem;
public CostEstimateBaseClass(ProcessSystem process, double costFactor) {
this(process);
this.CAPEXperWeight = costFactor;
}

/**
Expand All @@ -44,7 +50,7 @@ public CostEstimateBaseClass(ProcessSystem procesSystem) {
* @return a double
*/
public double getWeightBasedCAPEXEstimate() {
return procesSystem.getSystemMechanicalDesign().getTotalWeight() * CAPEXperWeight;
return this.processSystem.getSystemMechanicalDesign().getTotalWeight() * CAPEXperWeight;
}

/**
Expand All @@ -56,11 +62,11 @@ public double getWeightBasedCAPEXEstimate() {
*/
public double getCAPEXestimate() {
double cost = 0;
ArrayList<String> names = procesSystem.getAllUnitNames();
ArrayList<String> names = this.processSystem.getAllUnitNames();
for (int i = 0; i < names.size(); i++) {
try {
if (!((ProcessEquipmentInterface) procesSystem.getUnit(names.get(i)) == null)) {
cost += ((ProcessEquipmentInterface) procesSystem.getUnit(names.get(i)))
if (!((ProcessEquipmentInterface) this.processSystem.getUnit(names.get(i)) == null)) {
cost += ((ProcessEquipmentInterface) this.processSystem.getUnit(names.get(i)))
.getMechanicalDesign().getCostEstimate().getTotaltCost();
}
} catch (Exception e) {
Expand All @@ -70,14 +76,23 @@ public double getCAPEXestimate() {
return cost;
}

/**
* <p>
* getCAPEXperWeight.
* </p>
*
* @return the CAPEXperWeight
*/
public double getCAPEXperWeight() {
return CAPEXperWeight;
/** {@inheritDoc} */
@Override
public int hashCode() {
return Objects.hash(CAPEXperWeight);
}

/** {@inheritDoc} */
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
CostEstimateBaseClass other = (CostEstimateBaseClass) obj;
return Double.doubleToLongBits(CAPEXperWeight) == Double
.doubleToLongBits(other.CAPEXperWeight);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package neqsim.processSimulation.costEstimation;

import java.util.Objects;

import neqsim.processSimulation.mechanicalDesign.MechanicalDesign;

/**
Expand Down Expand Up @@ -45,4 +47,25 @@ public UnitCostEstimateBaseClass(MechanicalDesign mechanicalEquipment) {
public double getTotaltCost() {
return this.mechanicalEquipment.getWeightTotal() * costPerWeightUnit;
}

/** {@inheritDoc} */
@Override
public int hashCode() {
return Objects.hash(costPerWeightUnit, mechanicalEquipment);
}

/** {@inheritDoc} */
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
UnitCostEstimateBaseClass other = (UnitCostEstimateBaseClass) obj;
return Double.doubleToLongBits(costPerWeightUnit) == Double
.doubleToLongBits(other.costPerWeightUnit)
&& Objects.equals(mechanicalEquipment, other.mechanicalEquipment);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,12 @@ public interface MeasurementDeviceInterface extends java.io.Serializable {
* @return a boolean
*/
public boolean isOnlineSignal();

/** {@inheritDoc} */
@Override
public boolean equals(Object o);

/** {@inheritDoc} */
@Override
public int hashCode();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
import java.awt.BorderLayout;
import java.awt.Container;
import java.util.Hashtable;
import java.util.Objects;

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

import neqsim.processSimulation.costEstimation.UnitCostEstimateBaseClass;
import neqsim.processSimulation.mechanicalDesign.designStandards.AdsorptionDehydrationDesignStandard;
import neqsim.processSimulation.mechanicalDesign.designStandards.CompressorDesignStandard;
Expand Down Expand Up @@ -1071,4 +1074,91 @@ public void setHasSetCompanySpecificDesignStandards(
public UnitCostEstimateBaseClass getCostEstimate() {
return costEstimate;
}

/** {@inheritDoc} */
@Override
public int hashCode() {
return Objects.hash(companySpecificDesignStandards, construtionMaterial, corrosionAllowanse,
costEstimate, designStandard, hasSetCompanySpecificDesignStandards, innerDiameter,
jointEfficiency, materialPipeDesignStandard, materialPlateDesignStandard,
maxDesignGassVolumeFlow, maxDesignOilVolumeFlow, maxDesignVolumeFlow,
maxDesignWaterVolumeFlow, maxOperationPressure, maxOperationTemperature,
minDesignGassVolumeFLow, minDesignOilFLow, minDesignVolumeFLow, minDesignWaterVolumeFLow,
minOperationPressure, minOperationTemperature, moduleHeight, moduleLength, moduleWidth,
outerDiameter, pressureMarginFactor, processEquipment, tantanLength, tensileStrength,
volumeTotal, wallThickness, weightElectroInstrument, weightNozzle, weightPiping,
weightStructualSteel, weightTotal, weightVessel, weigthInternals, weigthVesselShell);
}

/** {@inheritDoc} */
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
MechanicalDesign other = (MechanicalDesign) obj;
return Objects.equals(companySpecificDesignStandards, other.companySpecificDesignStandards)
&& Objects.equals(construtionMaterial, other.construtionMaterial)
&& Double.doubleToLongBits(corrosionAllowanse) == Double
.doubleToLongBits(other.corrosionAllowanse)
&& Objects.equals(costEstimate, other.costEstimate)
&& Objects.equals(designStandard, other.designStandard)
&& hasSetCompanySpecificDesignStandards == other.hasSetCompanySpecificDesignStandards
&& Double.doubleToLongBits(innerDiameter) == Double.doubleToLongBits(other.innerDiameter)
&& Double.doubleToLongBits(jointEfficiency) == Double
.doubleToLongBits(other.jointEfficiency)
&& Objects.equals(materialPipeDesignStandard, other.materialPipeDesignStandard)
&& Objects.equals(materialPlateDesignStandard, other.materialPlateDesignStandard)
&& Double.doubleToLongBits(maxDesignGassVolumeFlow) == Double
.doubleToLongBits(other.maxDesignGassVolumeFlow)
&& Double.doubleToLongBits(maxDesignOilVolumeFlow) == Double
.doubleToLongBits(other.maxDesignOilVolumeFlow)
&& Double.doubleToLongBits(maxDesignVolumeFlow) == Double
.doubleToLongBits(other.maxDesignVolumeFlow)
&& Double.doubleToLongBits(maxDesignWaterVolumeFlow) == Double
.doubleToLongBits(other.maxDesignWaterVolumeFlow)
&& Double.doubleToLongBits(maxOperationPressure) == Double
.doubleToLongBits(other.maxOperationPressure)
&& Double.doubleToLongBits(maxOperationTemperature) == Double
.doubleToLongBits(other.maxOperationTemperature)
&& Double.doubleToLongBits(minDesignGassVolumeFLow) == Double
.doubleToLongBits(other.minDesignGassVolumeFLow)
&& Double.doubleToLongBits(minDesignOilFLow) == Double
.doubleToLongBits(other.minDesignOilFLow)
&& Double.doubleToLongBits(minDesignVolumeFLow) == Double
.doubleToLongBits(other.minDesignVolumeFLow)
&& Double.doubleToLongBits(minDesignWaterVolumeFLow) == Double
.doubleToLongBits(other.minDesignWaterVolumeFLow)
&& Double.doubleToLongBits(minOperationPressure) == Double
.doubleToLongBits(other.minOperationPressure)
&& Double.doubleToLongBits(minOperationTemperature) == Double
.doubleToLongBits(other.minOperationTemperature)
&& Double.doubleToLongBits(moduleHeight) == Double.doubleToLongBits(other.moduleHeight)
&& Double.doubleToLongBits(moduleLength) == Double.doubleToLongBits(other.moduleLength)
&& Double.doubleToLongBits(moduleWidth) == Double.doubleToLongBits(other.moduleWidth)
&& Double.doubleToLongBits(outerDiameter) == Double.doubleToLongBits(other.outerDiameter)
&& Double.doubleToLongBits(pressureMarginFactor) == Double
.doubleToLongBits(other.pressureMarginFactor)
&& Objects.equals(processEquipment, other.processEquipment)
&& Double.doubleToLongBits(tantanLength) == Double.doubleToLongBits(other.tantanLength)
&& Double.doubleToLongBits(tensileStrength) == Double
.doubleToLongBits(other.tensileStrength)
&& Double.doubleToLongBits(volumeTotal) == Double.doubleToLongBits(other.volumeTotal)
&& Double.doubleToLongBits(wallThickness) == Double.doubleToLongBits(other.wallThickness)
&& Double.doubleToLongBits(weightElectroInstrument) == Double
.doubleToLongBits(other.weightElectroInstrument)
&& Double.doubleToLongBits(weightNozzle) == Double.doubleToLongBits(other.weightNozzle)
&& Double.doubleToLongBits(weightPiping) == Double.doubleToLongBits(other.weightPiping)
&& Double.doubleToLongBits(weightStructualSteel) == Double
.doubleToLongBits(other.weightStructualSteel)
&& Double.doubleToLongBits(weightTotal) == Double.doubleToLongBits(other.weightTotal)
&& Double.doubleToLongBits(weightVessel) == Double.doubleToLongBits(other.weightVessel)
&& Double.doubleToLongBits(weigthInternals) == Double
.doubleToLongBits(other.weigthInternals)
&& Double.doubleToLongBits(weigthVesselShell) == Double
.doubleToLongBits(other.weigthVesselShell);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package neqsim.processSimulation.mechanicalDesign;

import java.util.ArrayList;
import java.util.Objects;

import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface;
import neqsim.processSimulation.processSystem.ProcessSystem;

Expand Down Expand Up @@ -38,8 +40,8 @@ public SystemMechanicalDesign(ProcessSystem processSystem) {
* @param name a {@link java.lang.String} object
*/
public void setCompanySpecificDesignStandards(String name) {
for (int i = 0; i < processSystem.getUnitOperations().size(); i++) {
processSystem.getUnitOperations().get(i).getMechanicalDesign()
for (int i = 0; i < this.processSystem.getUnitOperations().size(); i++) {
this.processSystem.getUnitOperations().get(i).getMechanicalDesign()
.setCompanySpecificDesignStandards(name);
}
}
Expand All @@ -50,19 +52,19 @@ public void setCompanySpecificDesignStandards(String name) {
* </p>
*/
public void runDesignCalculation() {
ArrayList<String> names = processSystem.getAllUnitNames();
ArrayList<String> names = this.processSystem.getAllUnitNames();
for (int i = 0; i < names.size(); i++) {
try {
if (!((ProcessEquipmentInterface) processSystem.getUnit(names.get(i)) == null)) {
((ProcessEquipmentInterface) processSystem.getUnit(names.get(i)))
if (!((ProcessEquipmentInterface) this.processSystem.getUnit(names.get(i)) == null)) {
((ProcessEquipmentInterface) this.processSystem.getUnit(names.get(i)))
.getMechanicalDesign().calcDesign();
totalPlotSpace += ((ProcessEquipmentInterface) processSystem
totalPlotSpace += ((ProcessEquipmentInterface) this.processSystem
.getUnit(names.get(i))).getMechanicalDesign().getModuleHeight()
* ((ProcessEquipmentInterface) processSystem.getUnit(names.get(i)))
* ((ProcessEquipmentInterface) this.processSystem.getUnit(names.get(i)))
.getMechanicalDesign().getModuleLength();
totalVolume += ((ProcessEquipmentInterface) processSystem.getUnit(names.get(i)))
totalVolume += ((ProcessEquipmentInterface) this.processSystem.getUnit(names.get(i)))
.getMechanicalDesign().getVolumeTotal();
totalWeight += ((ProcessEquipmentInterface) processSystem.getUnit(names.get(i)))
totalWeight += ((ProcessEquipmentInterface) this.processSystem.getUnit(names.get(i)))
.getMechanicalDesign().getWeightTotal();
numberOfModules++;
}
Expand All @@ -78,8 +80,8 @@ public void runDesignCalculation() {
* </p>
*/
public void setDesign() {
for (int i = 0; i < processSystem.getUnitOperations().size(); i++) {
processSystem.getUnitOperations().get(i).getMechanicalDesign().setDesign();
for (int i = 0; i < this.processSystem.getUnitOperations().size(); i++) {
this.processSystem.getUnitOperations().get(i).getMechanicalDesign().setDesign();
}
}

Expand Down Expand Up @@ -126,4 +128,27 @@ public double getTotalWeight() {
public int getTotalNumberOfModules() {
return numberOfModules;
}

/** {@inheritDoc} */
@Override
public int hashCode() {
return Objects.hash(numberOfModules, processSystem, totalPlotSpace, totalVolume, totalWeight);
}

/** {@inheritDoc} */
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SystemMechanicalDesign other = (SystemMechanicalDesign) obj;
return numberOfModules == other.numberOfModules
&& Objects.equals(processSystem, other.processSystem)
&& Double.doubleToLongBits(totalPlotSpace) == Double.doubleToLongBits(other.totalPlotSpace)
&& Double.doubleToLongBits(totalVolume) == Double.doubleToLongBits(other.totalVolume)
&& Double.doubleToLongBits(totalWeight) == Double.doubleToLongBits(other.totalWeight);
}
}
Loading