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

Test150920221236 #517

Merged
merged 9 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "java -version",
"postCreateCommand": "mvn package",

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
//"remoteUser": "vscode",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,19 @@ public void run(UUID id) {
mixedStream.getThermoSystem().reInitPhaseType();
mixStream();
ThermodynamicOperations testOps = new ThermodynamicOperations(mixedStream.getThermoSystem());
testOps.PHflash(enthalpy, 0);
try {
if (Double.isNaN(enthalpy)) {
logger.error("error in StaticMixer calc0 - enthalpy NaN");
testOps.TPflash();
}
else {
testOps.PHflash(enthalpy, 0);
}
//System.out.println("enthalp ok " + enthalpy);
}
catch (Exception e) {
logger.error("error", e);
}
// System.out.println("temp " + mixedStream.getThermoSystem().getTemperature());
mixedStream.getThermoSystem().init(3);
setCalculationIdentifier(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,22 @@ public void run(UUID id) {
}
} else {
for (int i = 0; i < inputVariable.size(); i++) {
sum += inputVariable.get(i).getFluid().getPhase(0).getComponent("TEG").getFlowRate("kg/hr");
sum += inputVariable.get(i).getFluid().getComponent("TEG").getFlowRate("kg/hr");
}
}

// System.out.println("make up MEG " + sum);
outputVariable.getFluid().setTotalFlowRate(sum, "kg/hr");
//System.out.println("make up TEG " + sum);
//((Stream) outputVariable).setFlowRate(sum, "kg/hr");
try {
((Stream) outputVariable).setFlowRate(sum, "kg/hr");
if (sum < 1e-10) {
sum = 1e-10;
}
((Stream) outputVariable).setFlowRate(sum, "kg/hr");
outputVariable.run();
outputVariable.setCalculationIdentifier(id);
} catch (Exception ex) {
logger.error("error", ex.getMessage());
logger.info("flow rate error " + sum);
logger.error("error in calculator");//, ex.getMessage());
}
setCalculationIdentifier(id);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/neqsim/thermo/phase/PhaseSrkCPA.java
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ public boolean solveX() {
try {
hessianInvers = hessianMatrix.invert();
} catch (Exception ex) {
logger.error("error", ex);
logger.error("error PhaseSrkCPA");//, ex);
return false;
}
if (solvedX) {
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/neqsim/thermo/system/SystemThermo.java
Original file line number Diff line number Diff line change
Expand Up @@ -670,9 +670,11 @@ public void setTotalFlowRate(double flowRate, String flowunit) {
if (flowRate < 1e-100) {
setEmptyFluid();
} else if (totalNumberOfMolesLocal > 1e-100) {
addComponent(i,
SIval / totalNumberOfMolesLocal * getPhase(0).getComponent(i).getNumberOfmoles()
- getPhase(0).getComponent(i).getNumberOfmoles());
double change = SIval / totalNumberOfMolesLocal * getPhase(0).getComponent(i).getNumberOfmoles()
- getPhase(0).getComponent(i).getNumberOfmoles();
if (Math.abs(change) > 1e-12) {
addComponent(i, change);
}
} else {
addComponent(i, SIval);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import neqsim.processSimulation.measurementDevice.HydrateEquilibriumTemperatureAnalyser;
import neqsim.processSimulation.measurementDevice.WaterDewPointAnalyser;
import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface;
import neqsim.processSimulation.processEquipment.absorber.SimpleTEGAbsorber;
import neqsim.processSimulation.processEquipment.absorber.WaterStripperColumn;
Expand Down Expand Up @@ -319,7 +320,7 @@ public void runTEGProcessTest() {
feedGas.addComponent("water", 0.0);
feedGas.addComponent("TEG", 0);
feedGas.setMixingRule(10);
feedGas.setMultiPhaseCheck(true);
feedGas.setMultiPhaseCheck(false);

Stream dryFeedGas = new Stream("dry feed gas", feedGas);
dryFeedGas.setFlowRate(25.32, "MSm3/day");
Expand Down Expand Up @@ -417,10 +418,10 @@ public void runTEGProcessTest() {

DistillationColumn column = new DistillationColumn(1, true, true);
column.setName("TEG regeneration column");
column.addFeedStream(glycol_flash_valve2.getOutletStream(), 0);
column.addFeedStream(glycol_flash_valve2.getOutletStream(), 1);
column.getReboiler().setOutTemperature(273.15 + 201.0);
column.getCondenser().setOutTemperature(273.15 + 92.0);
column.getReboiler().addStream(gasToReboiler);
column.getTray(1).addStream(gasToReboiler);
column.setTopPressure(1.01325);
column.setBottomPressure(1.02);

Expand Down Expand Up @@ -542,6 +543,247 @@ public void runTEGProcessTest() {
operations.add(makeupTEG);
operations.add(makeupMixer);
operations.add(resycleLeanTEG);
// operations.run();
operations.run();
}

@Test
public void runTEGProcessTest2(){
neqsim.thermo.system.SystemInterface feedGasTrainB = new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 42.0,
10.00);
feedGasTrainB.addComponent("nitrogen", 0.00258);
feedGasTrainB.addComponent("CO2", 0.035499);
feedGasTrainB.addComponent("methane", 0.8947);
feedGasTrainB.addComponent("ethane", 0.06244);
feedGasTrainB.addComponent("propane", 0.0028639);
feedGasTrainB.addComponent("i-butane", 0.00038631);
feedGasTrainB.addComponent("n-butane", 0.0008039);
feedGasTrainB.addComponent("i-pentane", 0.0001482);
feedGasTrainB.addComponent("n-pentane", 0.001733);
feedGasTrainB.addComponent("n-hexane", 6.2645e-5);
feedGasTrainB.addComponent("benzene", 1.044e-5);
feedGasTrainB.addComponent("water", 0.0002626);
feedGasTrainB.addComponent("TEG", 0);
feedGasTrainB.setMixingRule(10);
feedGasTrainB.setMultiPhaseCheck(false);
feedGasTrainB.init(0);


Stream satGasTrainB = new Stream("Saturated gas train B", feedGasTrainB);
satGasTrainB.setFlowRate(309292.3538, "kg/hr");
satGasTrainB.setTemperature(20, "C");
satGasTrainB.setPressure(40, "bara");

Heater feedTPsetterToAbsorber = new Heater("TP of gas to absorber", satGasTrainB);
feedTPsetterToAbsorber.setOutPressure(44.44, "bara");
feedTPsetterToAbsorber.setOutTemperature(16.365, "C");

Stream feedToAbsorber = new Stream("feed to TEG absorber", feedTPsetterToAbsorber.getOutletStream());

HydrateEquilibriumTemperatureAnalyser hydrateTAnalyser2 = new HydrateEquilibriumTemperatureAnalyser(feedToAbsorber);
hydrateTAnalyser2.setName("hydrate temperature gas to absorber");

neqsim.thermo.system.SystemInterface feedTEG = (neqsim.thermo.system.SystemInterface) feedGasTrainB.clone();
feedTEG.setMolarComposition(new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.01, 0.99 });

Stream TEGFeed = new Stream("lean TEG to absorber", feedTEG);
TEGFeed.setFlowRate(8922.476, "kg/hr");
TEGFeed.setTemperature(35, "C");
TEGFeed.setPressure(44.44, "bara");

SimpleTEGAbsorber absorber = new SimpleTEGAbsorber("TEG absorber");
absorber.addGasInStream(feedToAbsorber);
absorber.addSolventInStream(TEGFeed);
absorber.setNumberOfStages(4);
absorber.setStageEfficiency(0.75);
absorber.setInternalDiameter(3.65);

Stream dehydratedGas = new Stream("dry gas from absorber", absorber.getGasOutStream());

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

HydrateEquilibriumTemperatureAnalyser waterDewPointAnalyser = new HydrateEquilibriumTemperatureAnalyser(
dehydratedGas);
waterDewPointAnalyser.setReferencePressure(70.0);
waterDewPointAnalyser.setName("hydrate dew point analyser");

WaterDewPointAnalyser waterDewPointAnalyser2 = new WaterDewPointAnalyser(dehydratedGas);
waterDewPointAnalyser2.setReferencePressure(70.0);
waterDewPointAnalyser2.setName("water dew point analyser");

Heater condHeat = new Heater("Condenser heat exchanger", richTEG);

ThrottlingValve glycol_flash_valve = new ThrottlingValve("Flash valve", condHeat.getOutletStream());
glycol_flash_valve.setName("Rich TEG HP flash valve");
glycol_flash_valve.setOutletPressure(7.013);

HeatExchanger heatEx2 = new HeatExchanger("rich TEG heat exchanger 1", glycol_flash_valve.getOutletStream());
heatEx2.setGuessOutTemperature(273.15 + 90);
heatEx2.setUAvalue(1450);

neqsim.thermo.system.SystemInterface feedWater = (neqsim.thermo.system.SystemInterface) feedGasTrainB.clone();
feedWater.setMolarComposition(new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 });

Stream waterFeed = new Stream("lean TEG to absorber", feedWater);
waterFeed.setFlowRate(0, "kg/hr");
waterFeed.setTemperature(90, "C");
waterFeed.setPressure(7.013, "bara");

Separator flashSep = new Separator("degasing separator", heatEx2.getOutStream(0));
flashSep.setInternalDiameter(1.2);

Stream flashGas = new Stream("gas from degasing separator", flashSep.getGasOutStream());

Stream flashLiquid = new Stream("liquid from degasing separator", flashSep.getLiquidOutStream());

Filter filter = new Filter("TEG fine filter",flashLiquid);
filter.setDeltaP(0, "bara");

HeatExchanger heatEx = new HeatExchanger("lean/rich TEG heat-exchanger", filter.getOutletStream());
heatEx.setGuessOutTemperature(273.15 + 105);
heatEx.setUAvalue(9140);

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

neqsim.thermo.system.SystemInterface stripGas = (neqsim.thermo.system.SystemInterface) feedGasTrainB.clone();
stripGas.setMolarComposition(new double[] { 0, 1, 0, 0,
0, 0, 0, 0.0, 0.0, 0.0, 0.0, 1e-6, 0.0 });

Stream strippingGas = new Stream("stripGas", stripGas);
strippingGas.setFlowRate(153, "kg/hr");
strippingGas.setTemperature(18.8918, "C");
strippingGas.setPressure(1, "bara");

StreamSaturatorUtil saturatedStrippingGas = new StreamSaturatorUtil("water saturator Stripping gas",strippingGas);

Heater strippingGasTPsetter = new Heater("TP of stripping gas", saturatedStrippingGas.getOutletStream());
strippingGasTPsetter.setOutPressure(1.2096, "bara");
strippingGasTPsetter.setOutTemperature(193.46, "C");

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

DistillationColumn column = new DistillationColumn(1, true, true);
column.setName("TEG regeneration column");
column.addFeedStream(glycol_flash_valve2.getOutletStream(), 1);
column.getReboiler().setOutTemperature(273.15 + 204.269);
column.getCondenser().setOutTemperature(273.15 + 102.79);
//column.getReboiler().addStream(gasToReboiler);
column.getTray(0).addStream(gasToReboiler);
column.setTopPressure(1.1963);
column.setBottomPressure(1.2096);
column.setInternalDiameter(0.56);

Heater coolerRegenGas = new Heater("regen gas cooler", column.getGasOutStream());
coolerRegenGas.setOutTemperature(273.15 + 18.8918);

Separator sepregenGas = new Separator("regen gas separator",coolerRegenGas.getOutletStream());

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

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

WaterStripperColumn stripper = new WaterStripperColumn("TEG stripper");
stripper.addSolventInStream(column.getLiquidOutStream());
stripper.addGasInStream(strippingGasTPsetter.getOutletStream());
stripper.setNumberOfStages(3);
stripper.setStageEfficiency(0.8);

Recycle recycleGasFromStripper = new Recycle("stripping gas recirc");
recycleGasFromStripper.addStream(stripper.getGasOutStream());
recycleGasFromStripper.setOutletStream(gasToReboiler);

neqsim.thermo.system.SystemInterface pureTEG = (neqsim.thermo.system.SystemInterface) feedGasTrainB.clone();
pureTEG.setMolarComposition(new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 });

Stream makeupTEG = new Stream("makeup TEG", pureTEG);
makeupTEG.setFlowRate(1e-5, "kg/hr");
makeupTEG.setTemperature(20.46, "C");
makeupTEG.setPressure(1.2096, "bara");

Calculator makeupCalculator = new Calculator("TEG makeup calculator");
makeupCalculator.addInputVariable(dehydratedGas);
makeupCalculator.addInputVariable(flashGas);
makeupCalculator.addInputVariable(gasToFlare);
makeupCalculator.addInputVariable(liquidToTrreatment);
makeupCalculator.setOutputVariable(makeupTEG);

StaticMixer makeupMixer = new StaticMixer("makeup mixer");
makeupMixer.addStream(stripper.getLiquidOutStream());
makeupMixer.addStream(makeupTEG);

heatEx.setFeedStream(1, makeupMixer.getOutletStream());
heatEx2.setFeedStream(1, heatEx.getOutStream(1));


Pump hotLeanTEGPump = new Pump("lean TEG LP pump", heatEx2.getOutStream(1));
hotLeanTEGPump.setOutletPressure(44.44);
hotLeanTEGPump.setIsentropicEfficiency(1);

Heater coolerhOTteg3 = new Heater("lean TEG cooler", hotLeanTEGPump.getOutletStream());
coolerhOTteg3.setOutTemperature(273.15 + 35);

condHeat.setEnergyStream(column.getCondenser().getEnergyStream());

Stream leanTEGtoabs = new Stream("lean TEG to absorber", coolerhOTteg3.getOutletStream());

Recycle resycleLeanTEG = new Recycle("lean TEG resycle");
resycleLeanTEG.addStream(leanTEGtoabs);
resycleLeanTEG.setOutletStream(TEGFeed);
resycleLeanTEG.setPriority(200);
resycleLeanTEG.setDownstreamProperty("flow rate");


neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem();
operations.add(satGasTrainB);
operations.add(feedTPsetterToAbsorber);
operations.add(feedToAbsorber);
operations.add(hydrateTAnalyser2);
operations.add(TEGFeed);
operations.add(absorber);
operations.add(dehydratedGas);
operations.add(richTEG);
operations.add(waterDewPointAnalyser);
operations.add(waterDewPointAnalyser2);

operations.add(condHeat);

operations.add(glycol_flash_valve);
operations.add(heatEx2);
operations.add(waterFeed);
operations.add(flashSep);
operations.add(flashGas);
operations.add(flashLiquid);

operations.add(filter);
operations.add(heatEx);
operations.add(glycol_flash_valve2);
operations.add(strippingGas);
operations.add(saturatedStrippingGas);
operations.add(strippingGasTPsetter);


operations.add(gasToReboiler);
operations.add(column);

operations.add(coolerRegenGas);
operations.add(sepregenGas);
operations.add(gasToFlare);
operations.add(liquidToTrreatment);

operations.add(stripper);
operations.add(recycleGasFromStripper);


operations.add(makeupTEG);
operations.add(makeupCalculator);
operations.add(makeupMixer);
operations.add(hotLeanTEGPump);
operations.add(coolerhOTteg3);
operations.add(leanTEGtoabs);
operations.add(resycleLeanTEG);
operations.run();
}
}