Skip to content
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

refact: clean up, processequipment and stream creation #1116

Merged
merged 1 commit into from
Sep 26, 2024
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
Expand Up @@ -20,7 +20,9 @@
*/
public class PropaneCoolingModule extends ProcessModuleBaseClass {
/**
* <p>Constructor for PropaneCoolingModule.</p>
* <p>
* Constructor for PropaneCoolingModule.
* </p>
*
* @param name a {@link java.lang.String} object
*/
Expand Down Expand Up @@ -82,11 +84,11 @@ public StreamInterface getOutputStream(String streamName) {
/** {@inheritDoc} */
@Override
public void initializeModule() {
UUID id = UUID.randomUUID();
isInitializedModule = true;

refrigerantStream.getThermoSystem().setTemperature(condenserTemperature);
((Stream) refrigerantStream).setSpecification("bubT");
UUID id = UUID.randomUUID();
refrigerantStream.run(id);

ThrottlingValve JTvalve = new ThrottlingValve("JTvalve", refrigerantStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ void testGetMeasuredValueString() {
sep1.addStream(stream_2);

Stream stream_gasExp = new Stream("gasexp", sep1.getGasOutStream());

Stream stream_oilExp = new Stream("oilexp", sep1.getLiquidOutStream());

WellAllocator wellAlloc = new WellAllocator("alloc", stream_1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ static void createProcess() {
ThrottlingValve valve2 = new ThrottlingValve("valve2", seprator2ndStage.getLiquidOutStream());
valve2.setOutletPressure(2.7);

StreamInterface recircstream1 = valve2.getOutletStream().clone();
recircstream1.setName("oilRecirc1");
StreamInterface recircstream1 = valve2.getOutletStream().clone("oilRecirc1");
recircstream1.setFlowRate(1e-6, "kg/hr");

neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator seprator3rdStage =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ void testRun1() {
heatEx.setUAvalue(1000);

Separator sep = new Separator("sep", stream_Hot);

Stream oilOutStream = new Stream("oilOutStream", sep.getLiquidOutStream());

ThrottlingValve valv1 = new ThrottlingValve("valv1", oilOutStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,28 @@ void testMain() {
// mimic MPM

double gor_sm3gas_sm3oil = stream_2.getFluid().getPhase("gas").getFlowRate("Sm3/hr")
/ stream_2.getFluid().getPhase("oil").getFlowRate("Sm3/hr");
/ stream_2.getFluid().getPhase("oil").getFlowRate("Sm3/hr");

double gor_sm3gas_sm3oil_corrected = stream_2.getFluid().getPhase("gas").getCorrectedVolume()
/ stream_2.getFluid().getPhase("oil").getCorrectedVolume();

System.out.println("Stream 2 (results outside MPM) " + " GOR sm3/sm3 " + gor_sm3gas_sm3oil + " GOR Corrected by volume "
+ gor_sm3gas_sm3oil_corrected);
System.out.println("Stream 2 (results outside MPM) " + " GOR sm3/sm3 " + gor_sm3gas_sm3oil
+ " GOR Corrected by volume " + gor_sm3gas_sm3oil_corrected);

System.out.println("Stream 2 (results outside MPM) getPhase(gas).getCorrectedVolume() "
+ stream_2.getFluid().getPhase("gas").getCorrectedVolume());
System.out.println("Stream 2 (results outside MPM) getPhase(oil).getCorrectedVolume() "
+ stream_2.getFluid().getPhase("oil").getCorrectedVolume());

//Assertions.assertEquals(51.3073530232923, multiPhaseMeter.getMeasuredValue("GOR", ""), 1e-12);
// Assertions.assertEquals(3106.7708277963447, multiPhaseMeter.getMeasuredValue("GOR_std", ""),
// 1e-12);
// Assertions.assertEquals(51.3073530232923, multiPhaseMeter.getMeasuredValue("GOR", ""),
// 1e-12);
// Assertions.assertEquals(3106.7708277963447, multiPhaseMeter.getMeasuredValue("GOR_std", ""),
// 1e-12);
Assertions.assertEquals(10.099999999999769, multiPhaseMeter2.getMeasuredValue("GOR", ""),
1e-12);
Assertions.assertEquals(682.1045749623208, multiPhaseMeter2.getMeasuredValue("GOR_std", ""),
1e-10); // the value of GOR sm3/sm3 3.48551599242607 is quite far if we take by flow getStandardFlow
1e-10); // the value of GOR sm3/sm3 3.48551599242607 is quite far if we take by flow
// getStandardFlow
Assertions.assertEquals(1000000.0, stream_2.getFlowRate("kg/hr"), 1e-12);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ public void testProcess() {
ThrottlingValve valve1 = new ThrottlingValve("valve oil", oilHeater.getOutletStream());
valve1.setOutletPressure(10.0, "bara");

StreamInterface recycleScrubberStream = new Stream("Recycle stream", feedStream.clone());
StreamInterface recycleScrubberStream = feedStream.clone("Recycle stream");
recycleScrubberStream.setFlowRate(1.0, "kg/hr");

ThreePhaseSeparator secondStageSeparator =
new ThreePhaseSeparator("2nd stage separator", valve1.getOutletStream());
secondStageSeparator.addStream(recycleScrubberStream);

StreamInterface gasRecycleStream = new Stream("gas recycle stream", feedStream.clone());
StreamInterface gasRecycleStream = feedStream.clone("gas recycle stream");
gasRecycleStream.setFlowRate(1.0, "kg/hr");

Mixer gasmixer = new Mixer("gas recycle mixer");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ public void runProcessTEG() throws InterruptedException {
strippingGas.setTemperature(185.4402968739743, "C");
strippingGas.setPressure(1.1714901511485545, "bara");

Stream gasToReboiler = (Stream) (strippingGas).clone();
gasToReboiler.setName("gas to reboiler");
Stream gasToReboiler = strippingGas.clone("gas to reboiler");

DistillationColumn column = new DistillationColumn("TEG regeneration column", 2, true, true);
column.addFeedStream(glycol_flash_valve2.getOutStream(), 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ public void runTEGProcessTest() {
strippingGas.setTemperature(55.0, "C");
strippingGas.setPressure(0.2, "barg");

Stream gasToReboiler = strippingGas.clone();
gasToReboiler.setName("gas to reboiler");
Stream gasToReboiler = strippingGas.clone("gas to reboiler");

Stream TEGtoRegenerator = new Stream("\"TEG to regenerator\"", feedTEG);
TEGtoRegenerator.setFlowRate(400.0, "kg/hr");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ public void runProcess() throws InterruptedException {
ThrottlingValve valve2 = new ThrottlingValve("valve2", seprator2ndStage.getLiquidOutStream());
valve2.setOutletPressure(2.7);

StreamInterface recircstream1 = valve2.getOutletStream().clone();
recircstream1.setName("oilRecirc1");
StreamInterface recircstream1 = valve2.getOutletStream().clone("oilRecirc1");
recircstream1.setFlowRate(1e-6, "kg/hr");

neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator seprator3rdStage =
Expand Down Expand Up @@ -148,7 +147,7 @@ public void runAntiSurgeProcess() throws InterruptedException {
gas_from_separator.setFlowRate(7.0, "MSm3/day");
gas_from_separator.run();

Stream recyclegasstream = new Stream("recycle gas stream", gas_from_separator.clone());
Stream recyclegasstream = gas_from_separator.clone("recycle gas stream");
recyclegasstream.setFlowRate(1e-10, "MSm3/day");
recyclegasstream.run();

Expand Down Expand Up @@ -262,7 +261,7 @@ public void runAntiSurgeProcess2() throws InterruptedException {
gas_from_separator.setTemperature(30.0, "C");
gas_from_separator.setFlowRate(7.0, "MSm3/day");

Stream recyclegasstream = new Stream("Recycle gas", gas_from_separator.clone());
Stream recyclegasstream = gas_from_separator.clone("Recycle gas");
recyclegasstream.setFlowRate(1e-10, "MSm3/day");

Mixer gasmixer = new Mixer("gas mixer");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ public void testAntiSurgeControl() {
valve1.setPercentValveOpening(20);
valve1.setCalculateSteadyState(false);

Stream resycstream = new Stream("recycle stream", stream1.clone());
Stream resycstream = stream1.clone("recycle stream");
resycstream.setFlowRate(0.01, "kg/hr");

Separator separator1 = new Separator("separator_1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ public void runTEGProcessTest2() {
strippingGas.setTemperature(180.0, "C");
strippingGas.setPressure(feedPressureStripGas, "bara");

Stream gasToReboiler = (Stream) strippingGas.clone();
gasToReboiler.setName("gas to reboiler");
Stream gasToReboiler = strippingGas.clone("gas to reboiler");

DistillationColumn column = new DistillationColumn("TEG regeneration column", 1, true, true);
column.addFeedStream(glycol_flash_valve2.getOutletStream(), 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ public static void main(String[] args) {
heatEx.setUAvalue(600.0);

ThrottlingValve glycol_flash_valve2 =
new ThrottlingValve("LP flash valve", heatEx.getOutStream(0));
glycol_flash_valve2.setName("Rich TEG LP flash valve");
new ThrottlingValve("Rich TEG LP flash valve", heatEx.getOutStream(0));
glycol_flash_valve2.setOutletPressure(1.23);

neqsim.thermo.system.SystemInterface stripGas = feedGas.clone();
Expand All @@ -120,8 +119,7 @@ public static void main(String[] args) {
strippingGas.setTemperature(80.0, "C");
strippingGas.setPressure(1.23, "bara");

Stream gasToReboiler = strippingGas.clone();
gasToReboiler.setName("gas to reboiler");
Stream gasToReboiler = strippingGas.clone("gas to reboiler");

DistillationColumn column = new DistillationColumn("TEG regeneration column", 1, true, true);
column.addFeedStream(glycol_flash_valve2.getOutletStream(), 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ public static void main(String[] args) {
strippingGas.setTemperature(80.0, "C");
strippingGas.setPressure(1.23, "bara");

Stream gasToReboiler = strippingGas.clone();
gasToReboiler.setName("gas to reboiler");
Stream gasToReboiler = strippingGas.clone("gas to reboiler");

DistillationColumn column = new DistillationColumn("TEG regeneration column", 1, true, true);
column.addFeedStream(richGLycolHeater2.getOutletStream(), 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public static neqsim.processSimulation.processSystem.ProcessSystem getProcess()
new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream());

HydrateEquilibriumTemperatureAnalyser hydrateTAnalyser =
new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGas);
hydrateTAnalyser.setName("hydrate temperature analyser");
new HydrateEquilibriumTemperatureAnalyser("hydrate temperature analyser",
waterSaturatedFeedGas);

neqsim.thermo.system.SystemInterface feedTEG = feedGas.clone();
feedTEG.setMolarComposition(
Expand Down Expand Up @@ -97,13 +97,12 @@ public static neqsim.processSimulation.processSystem.ProcessSystem getProcess()

Stream richTEG = new Stream("rich TEG from absorber", absorber.getSolventOutStream());
/*
* WaterDewPointAnalyser waterDewPointAnalyser = new WaterDewPointAnalyser(dehydratedGas);
* waterDewPointAnalyser.setName("water dew point analyser");
* WaterDewPointAnalyser waterDewPointAnalyser = new
* WaterDewPointAnalyser("water dew point analyser", dehydratedGas);
*/
HydrateEquilibriumTemperatureAnalyser waterDewPointAnalyser =
new HydrateEquilibriumTemperatureAnalyser(dehydratedGas);
new HydrateEquilibriumTemperatureAnalyser("water dew point analyser", dehydratedGas);
waterDewPointAnalyser.setReferencePressure(70.0);
waterDewPointAnalyser.setName("water dew point analyser");

ThrottlingValve glycol_flash_valve = new ThrottlingValve("Rich TEG HP flash valve", richTEG);
glycol_flash_valve.setOutletPressure(5.5);
Expand Down Expand Up @@ -135,8 +134,7 @@ public static neqsim.processSimulation.processSystem.ProcessSystem getProcess()
heatEx.setUAvalue(390.0);

ThrottlingValve glycol_flash_valve2 =
new ThrottlingValve("LP flash valve", heatEx.getOutStream(0));
glycol_flash_valve2.setName("Rich TEG LP flash valve");
new ThrottlingValve("Rich TEG LP flash valve", heatEx.getOutStream(0));
glycol_flash_valve2.setOutletPressure(1.23);

neqsim.thermo.system.SystemInterface stripGas = feedGas.clone();
Expand All @@ -148,8 +146,7 @@ public static neqsim.processSimulation.processSystem.ProcessSystem getProcess()
strippingGas.setTemperature(80.0, "C");
strippingGas.setPressure(1.02, "bara");

Stream gasToReboiler = strippingGas.clone();
gasToReboiler.setName("gas to reboiler");
Stream gasToReboiler = strippingGas.clone("gas to reboiler");

DistillationColumn column = new DistillationColumn("TEG regeneration column", 1, true, true);
column.addFeedStream(glycol_flash_valve2.getOutletStream(), 0);
Expand All @@ -174,8 +171,8 @@ public static neqsim.processSimulation.processSystem.ProcessSystem getProcess()
stripper.setNumberOfStages(4);
stripper.setStageEfficiency(0.5);
/*
* DistillationColumn stripper = new DistillationColumn(3, false, false);
* stripper.setName("TEG stripper"); stripper.addFeedStream(column.getLiquidOutStream(), 2);
* DistillationColumn stripper = new DistillationColumn("TEG stripper",3, false, false);
* stripper.addFeedStream(column.getLiquidOutStream(), 2);
* stripper.getTray(0).addStream(strippingGas);
*/
Recycle recycleGasFromStripper = new Recycle("stripping gas recirc");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() {
new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream());

HydrateEquilibriumTemperatureAnalyser hydrateTAnalyser =
new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGas);
hydrateTAnalyser.setName("hydrate temperature analyser");
new HydrateEquilibriumTemperatureAnalyser("hydrate temperature analyser",
waterSaturatedFeedGas);

neqsim.thermo.system.SystemInterface feedTEG = feedGas.clone();
feedTEG.setMolarComposition(
Expand Down Expand Up @@ -224,15 +224,13 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() {

Stream richTEG = new Stream("rich TEG from absorber", absorber.getSolventOutStream());

WaterDewPointAnalyser waterDewPointAnalyser2 = new WaterDewPointAnalyser(dehydratedGas);
waterDewPointAnalyser2.setName("water dew point analyser2");
WaterDewPointAnalyser waterDewPointAnalyser2 =
new WaterDewPointAnalyser("water dew point analyser2", dehydratedGas);

HydrateEquilibriumTemperatureAnalyser waterDewPointAnalyser =
new HydrateEquilibriumTemperatureAnalyser(dehydratedGas);
waterDewPointAnalyser.setName("water dew point analyser");
new HydrateEquilibriumTemperatureAnalyser("water dew point analyser", dehydratedGas);

ThrottlingValve glycol_flash_valve = new ThrottlingValve("Flash valve", richTEG);
glycol_flash_valve.setName("Rich TEG HP flash valve");
ThrottlingValve glycol_flash_valve = new ThrottlingValve("Rich TEG HP flash valve", richTEG);
glycol_flash_valve.setOutletPressure(flashDrumPressure);

Heater richGLycolHeaterCondenser =
Expand All @@ -257,8 +255,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() {
heatEx.setUAvalue(UAvalueRichTEGHeatExchanger_2);

ThrottlingValve glycol_flash_valve2 =
new ThrottlingValve("LP flash valve", heatEx.getOutStream(0));
glycol_flash_valve2.setName("Rich TEG LP flash valve");
new ThrottlingValve("Rich TEG LP flash valve", heatEx.getOutStream(0));
glycol_flash_valve2.setOutletPressure(reboilerPressure);

neqsim.thermo.system.SystemInterface stripGas = feedGas.clone();
Expand All @@ -268,8 +265,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() {
strippingGas.setTemperature(strippingGasFeedTemperature, "C");
strippingGas.setPressure(reboilerPressure, "bara");

Stream gasToReboiler = strippingGas.clone();
gasToReboiler.setName("gas to reboiler");
Stream gasToReboiler = strippingGas.clone("gas to reboiler");

DistillationColumn column = new DistillationColumn("TEG regeneration column", 3, true, true);
column.addFeedStream(glycol_flash_valve2.getOutletStream(), 1);
Expand All @@ -286,7 +282,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() {

Stream gasToFlare = new Stream("gas to flare", sepregenGas.getGasOutStream());

Stream liquidToTrreatment = new Stream("water to treatment", sepregenGas.getLiquidOutStream());
Stream liquidToTreatment = new Stream("water to treatment", sepregenGas.getLiquidOutStream());

WaterStripperColumn stripper = new WaterStripperColumn("TEG stripper");
stripper.addSolventInStream(column.getLiquidOutStream());
Expand Down Expand Up @@ -334,7 +330,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() {
makeupCalculator.addInputVariable(dehydratedGas);
makeupCalculator.addInputVariable(flashGas);
makeupCalculator.addInputVariable(gasToFlare);
makeupCalculator.addInputVariable(liquidToTrreatment);
makeupCalculator.addInputVariable(liquidToTreatment);
makeupCalculator.setOutputVariable(makeupTEG);

StaticMixer makeupMixer = new StaticMixer("makeup mixer");
Expand Down Expand Up @@ -378,7 +374,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() {
operations.add(coolerRegenGas);
operations.add(sepregenGas);
operations.add(gasToFlare);
operations.add(liquidToTrreatment);
operations.add(liquidToTreatment);
operations.add(strippingGas);
operations.add(stripper);
operations.add(recycleGasFromStripper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() {
new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream());

HydrateEquilibriumTemperatureAnalyser hydrateTAnalyser =
new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGas);
hydrateTAnalyser.setName("hydrate temperature analyser");
new HydrateEquilibriumTemperatureAnalyser("hydrate temperature analyser",
waterSaturatedFeedGas);

neqsim.thermo.system.SystemInterface feedTEG = feedGas.clone();
feedTEG.setMolarComposition(
Expand Down Expand Up @@ -230,10 +230,8 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() {
Stream richTEG = new Stream("rich TEG from absorber", absorber.getSolventOutStream());

HydrateEquilibriumTemperatureAnalyser waterDewPointAnalyser =
new HydrateEquilibriumTemperatureAnalyser(dehydratedGas);
waterDewPointAnalyser.setName("water dew point analyser");
ThrottlingValve glycol_flash_valve = new ThrottlingValve("Flash valve", richTEG);
glycol_flash_valve.setName("Rich TEG HP flash valve");
new HydrateEquilibriumTemperatureAnalyser("water dew point analyser", dehydratedGas);
ThrottlingValve glycol_flash_valve = new ThrottlingValve("Rich TEG HP flash valve", richTEG);
glycol_flash_valve.setOutletPressure(flashDrumPressure);

Heater richGLycolHeaterCondenser =
Expand Down Expand Up @@ -263,8 +261,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() {
heatEx.setUAvalue(UAvalueRichTEGHeatExchanger_2);

ThrottlingValve glycol_flash_valve2 =
new ThrottlingValve("LP flash valve", heatEx.getOutStream(0));
glycol_flash_valve2.setName("Rich TEG LP flash valve");
new ThrottlingValve("Rich TEG LP flash valve", heatEx.getOutStream(0));
glycol_flash_valve2.setOutletPressure(reboilerPressure);

neqsim.thermo.system.SystemInterface stripGas = feedGas.clone();
Expand All @@ -274,8 +271,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() {
strippingGas.setTemperature(strippingGasFeedTemperature, "C");
strippingGas.setPressure(reboilerPressure, "bara");

Stream gasToReboiler = strippingGas.clone();
gasToReboiler.setName("gas to reboiler");
Stream gasToReboiler = strippingGas.clone("gas to reboiler");

DistillationColumn column = new DistillationColumn("TEG regeneration column", 1, true, true);
column.addFeedStream(glycol_flash_valve2.getOutletStream(), 0);
Expand Down