Skip to content

Commit

Permalink
Update distillation (#510)
Browse files Browse the repository at this point in the history
* update rig

* update rig

* update rig

* update rig

* update rig

* update rig

* update rig

* update

* formated document

* fix

* fixed bug in distillation solver

* added distillation test

* update

* aded test for columns without reboiler and condeser

* fixed gas to reboiler
  • Loading branch information
EvenSol authored Aug 15, 2022
1 parent 295e9d0 commit 8ee9edd
Show file tree
Hide file tree
Showing 3 changed files with 185 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"java.checkstyle.version": "10.3",
"java.checkstyle.configuration": "https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/main/resources/google_checks.xml"
"java.checkstyle.configuration": "https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/main/resources/google_checks.xml",
"java.debug.settings.hotCodeReplace": "never"
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,22 @@ public void init() {
}
}
}

if (getTray(feedTrayNumber).getFluid().getNumberOfPhases() == 1) {
getTray(feedTrayNumber).getThermoSystem().init(0);
getTray(feedTrayNumber).getThermoSystem().init(3);
}

((MixerInterface) trays.get(numberOfTrays - 1))
.addStream(trays.get(feedTrayNumber).getGasOutStream());
((Mixer) trays.get(numberOfTrays - 1)).getStream(0).getThermoSystem()
.setTotalNumberOfMoles(((Mixer) trays.get(numberOfTrays - 1)).getStream(0).getThermoSystem()
.getTotalNumberOfMoles() * (1.0e-6));
.getTotalNumberOfMoles() * (1.0));
((MixerInterface) trays.get(0)).addStream(trays.get(feedTrayNumber).getLiquidOutStream());
int streamNumbReboil = (trays.get(0)).getNumberOfInputStreams() - 1;
((Mixer) trays.get(0)).getStream(streamNumbReboil).getThermoSystem().setTotalNumberOfMoles(
((Mixer) trays.get(0)).getStream(streamNumbReboil).getThermoSystem().getTotalNumberOfMoles()
* (1.0e-6));
* (1.0));

// ((Runnable) trays.get(numberOfTrays - 1)).run();
((Runnable) trays.get(0)).run();
Expand Down Expand Up @@ -392,10 +398,11 @@ public boolean massBalanceCheck() {
double[] massInput = new double[numberOfTrays];
double[] massOutput = new double[numberOfTrays];
double[] massBalance = new double[numberOfTrays];
System.out.println("water in feed "
+ feedStream.getFluid().getPhase(0).getComponent("water").getNumberOfmoles());
System.out.println("water in strip gas feed " + trays.get(0).getStream(0).getFluid().getPhase(0)
.getComponent("water").getNumberOfmoles());
// System.out.println("water in feed "
// + feedStream.getFluid().getPhase(0).getComponent("water").getNumberOfmoles());
// System.out.println("water in strip gas feed " +
// trays.get(0).getStream(0).getFluid().getPhase(0)
// .getComponent("water").getNumberOfmoles());

for (int i = 0; i < numberOfTrays; i++) {
int numberOfInputStreams = trays.get(i).getNumberOfInputStreams();
Expand All @@ -411,7 +418,7 @@ public boolean massBalanceCheck() {
+ " liquidout " + trays.get(i).getLiquidOutStream().getFlowRate("kg/hr") + " pressure "
+ trays.get(i).getGasOutStream().getPressure() + " temperature "
+ trays.get(i).getGasOutStream().getTemperature("C"));

/*
System.out.println(
"tray " + i + " number of input streams " + numberOfInputStreams + " water in gasout "
+ trays.get(i).getGasOutStream().getFluid().getPhase(0).getComponent("water")
Expand All @@ -421,6 +428,7 @@ public boolean massBalanceCheck() {
.getNumberOfmoles()
+ " pressure " + trays.get(i).getGasOutStream().getPressure() + " temperature "
+ trays.get(i).getGasOutStream().getTemperature("C"));
*/
}

double massError = 0.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public void runTEGProcessTest() {
column.addFeedStream(TEGtoRegenerator, 1);
column.getReboiler().setOutTemperature(273.15 + 209.0);
column.getCondenser().setOutTemperature(273.15 + 104.0);
column.getReboiler().addStream(gasToReboiler);
// column.getTray(1).addStream(gasToReboiler); //this does not work at the moment
column.getTray(1).addStream(gasToReboiler);
//column.getReboiler().addStream(gasToReboiler);
column.setTopPressure(0.1 + 1.01325);
column.setBottomPressure(0.2 + 1.01325);

Expand Down Expand Up @@ -177,4 +177,170 @@ public void runTEGProcessTest() {
System.out.println("stripping gas rate " + strippingGas.getFlowRate("kg/hr"));
Assertions.assertEquals(0.0, waterBalanceColumn, 1e-3);
}

@Test
public void runDistillationProcessTest() {
neqsim.thermo.system.SystemInterface feed =
new neqsim.thermo.system.SystemSrkEos(273.15 + 10.0, 2.01325);
feed.addComponent("methane", 0.1);
feed.addComponent("propane", 0.3);
feed.addComponent("n-hexane", 0.6);
feed.setMixingRule("classic");

Stream feedToRegenerator = new Stream("feed", feed);
feedToRegenerator.setName("feed to regenerator");
feedToRegenerator.setFlowRate(400.0, "kg/hr");
feedToRegenerator.setTemperature(20.0, "C");
feedToRegenerator.setPressure(2.01325, "barg");

DistillationColumn column = new DistillationColumn(1, true, true);
column.setName("distillation column");
column.addFeedStream(feedToRegenerator, 1);
column.getReboiler().setOutTemperature(273.15 + 70.0);
column.getCondenser().setOutTemperature(273.15 - 10.0);
column.setTopPressure(1.0 + 1.01325);
column.setBottomPressure(1.0 + 1.01325);

neqsim.processSimulation.processSystem.ProcessSystem operations =
new neqsim.processSimulation.processSystem.ProcessSystem();
operations.add(feedToRegenerator);
operations.add(column);

operations.run();
/*
System.out.println("wt n-hexane from column "
+ column.getLiquidOutStream().getFluid().getPhase("oil").getWtFrac("n-hexane") * 100.0);
System.out.println("wt methane from column "
+ column.getLiquidOutStream().getFluid().getPhase("oil").getWtFrac("methane") * 100.0);
System.out.println("wt propane from column "
+ column.getLiquidOutStream().getFluid().getPhase("oil").getWtFrac("propane") * 100.0);
System.out.println("wt n-hexane from gas column "
+ column.getGasOutStream().getFluid().getPhase("gas").getWtFrac("n-hexane") * 100.0);
System.out.println("wt methane from gas column "
+ column.getGasOutStream().getFluid().getPhase("gas").getWtFrac("methane") * 100.0);
System.out.println("wt propane from gas column "
+ column.getGasOutStream().getFluid().getPhase("gas").getWtFrac("propane") * 100.0);
*/
}

@Test
public void runDistillationProcessTest2() {
neqsim.thermo.system.SystemInterface feed =
new neqsim.thermo.system.SystemSrkEos(273.15 + 40.0, 5.01325);
feed.addComponent("propane", 0.3);
feed.addComponent("n-hexane", 0.6);
feed.setMixingRule("classic");

Stream feedToRegenerator = new Stream("feed", feed);
feedToRegenerator.setName("feed to regenerator");
feedToRegenerator.setFlowRate(400.0, "kg/hr");
feedToRegenerator.setTemperature(80.0, "C");
feedToRegenerator.setPressure(5.0, "barg");

DistillationColumn column = new DistillationColumn(1, true, true);
column.setName("distillation column");
column.addFeedStream(feedToRegenerator, 1);
column.getReboiler().setOutTemperature(273.15 + 100.0);
column.getCondenser().setOutTemperature(273.15 + 50.0);
column.setTopPressure(1.0 + 5.01325);
column.setBottomPressure(1.0 + 5.01325);

neqsim.processSimulation.processSystem.ProcessSystem operations =
new neqsim.processSimulation.processSystem.ProcessSystem();
operations.add(feedToRegenerator);
operations.add(column);

operations.run();
/*
* System.out.println("wt n-hexane from column " +
* column.getLiquidOutStream().getFluid().getPhase("oil").getWtFrac("n-hexane") * 100.0);
*
* System.out.println("wt propane from column " +
* column.getLiquidOutStream().getFluid().getPhase("oil").getWtFrac("propane") * 100.0);
*
*
* System.out.println("wt n-hexane from gas column " +
* column.getGasOutStream().getFluid().getPhase("gas").getWtFrac("n-hexane") * 100.0);
*
* System.out.println("wt propane from gas column " +
* column.getGasOutStream().getFluid().getPhase("gas").getWtFrac("propane") * 100.0);
*/
}

@Test
public void runDistillationProcessTest3() {
neqsim.thermo.system.SystemInterface feed =
new neqsim.thermo.system.SystemSrkEos(273.15 + 40.0, 2.01325);
feed.addComponent("ethane", 0.01);
feed.addComponent("n-hexane", 0.99);
feed.setMixingRule("classic");

neqsim.thermo.system.SystemInterface feed2 =
new neqsim.thermo.system.SystemSrkEos(273.15 + 40.0, 2.01325);
feed2.addComponent("ethane", 0.99);
feed2.addComponent("n-hexane", 0.01);
feed2.setMixingRule("classic");

Stream feedToRegenerator = new Stream("feed", feed);
feedToRegenerator.setName("feed to regenerator");
feedToRegenerator.setFlowRate(400.0, "kg/hr");
feedToRegenerator.setTemperature(40.0, "C");
feedToRegenerator.setPressure(2.0, "barg");

Stream feedToRegenerator2 = new Stream("feed2", feed2);
feedToRegenerator2.setName("feed2 to regenerator");
feedToRegenerator2.setFlowRate(400.0, "kg/hr");
feedToRegenerator2.setTemperature(80.0, "C");
feedToRegenerator2.setPressure(2.0, "barg");

DistillationColumn column = new DistillationColumn(2, false, false);
column.setName("distillation column");

column.addFeedStream(feedToRegenerator2, 0);
column.addFeedStream(feedToRegenerator, 1);

neqsim.processSimulation.processSystem.ProcessSystem operations =
new neqsim.processSimulation.processSystem.ProcessSystem();
operations.add(feedToRegenerator);
operations.add(feedToRegenerator2);
operations.add(column);

operations.run();
operations.run();
operations.run();

/*
* System.out.println("wt n-hexane from column " +
* column.getLiquidOutStream().getFluid().getPhase("oil").getWtFrac("n-hexane") * 100.0);
*
* System.out.println("wt ethane from column " +
* column.getLiquidOutStream().getFluid().getPhase("oil").getWtFrac("ethane") * 100.0);
*
*
* System.out.println("wt n-hexane from gas column " +
* column.getGasOutStream().getFluid().getPhase("gas").getWtFrac("n-hexane") * 100.0);
*
* System.out.println("wt ethane from gas column " +
* column.getGasOutStream().getFluid().getPhase("gas").getWtFrac("ethane") * 100.0);
*
* System.out.println("flow rate gas " +
* column.getGasOutStream().getFluid().getPhase("gas").getFlowRate("kg/hr") + " kg/hr");
*
* System.out.println("flow rate oil " +
* column.getLiquidOutStream().getFluid().getPhase("oil").getFlowRate("kg/hr") + " kg/hr");
*
* System.out .println("flow rate oil " + feedToRegenerator.getFluid().getFlowRate("kg/hr") +
* " kg/hr");
*
* System.out .println("flow rate gas " + feedToRegenerator2.getFluid().getFlowRate("kg/hr") +
* " kg/hr"); column.massBalanceCheck();
*
*/
}
}

0 comments on commit 8ee9edd

Please sign in to comment.