Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol committed Dec 3, 2023
1 parent e48c982 commit 691867a
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,14 @@ public class Separator extends ProcessEquipmentBaseClass implements SeparatorInt
/** Inner diameter/height of separator volume. */
private double internalDiameter = 1.0;

double liquidVolume = 1.0;
double gasVolume = 18.0;


/** LiquidLevel as volume fraction of liquidvolume/(liquid + gas volume). */
private double liquidLevel = liquidVolume / (liquidVolume + gasVolume);
private double liquidLevel = 0.5;
double liquidVolume =
Math.PI * internalDiameter * internalDiameter / 4.0 * separatorLength * liquidLevel;
double gasVolume =
Math.PI * internalDiameter * internalDiameter / 4.0 * separatorLength * (1.0 - liquidLevel);
private double designLiquidLevelFraction = 0.8;
ArrayList<SeparatorSection> separatorSection = new ArrayList<SeparatorSection>();

Expand Down Expand Up @@ -243,53 +246,51 @@ public void run(UUID id) {
} else {
liquidOutStream.getFluid().init(3);
}
// liquidOutStream.setThermoSystemFromPhase(thermoSystem2, "aqueous");
if (getCalculateSteadyState()) {
thermoSystem = thermoSystem2;
} else {
try {
liquidVolume =
Math.PI * internalDiameter * internalDiameter / 4.0 * separatorLength * liquidLevel;
gasVolume = Math.PI * internalDiameter * internalDiameter / 4.0 * separatorLength
* (1.0 - liquidLevel);
thermoSystem = thermoSystem2.clone();
// thermoSystem.setTotalNumberOfMoles(1.0);
thermoSystem.init(1);
// System.out.println("number of phases " + thermoSystem.getNumberOfPhases());
double totalliquidVolume = 0.0;
thermoSystem.initPhysicalProperties("density");
thermoSystem2.initPhysicalProperties("density");
for (int j = 0; j < thermoSystem.getNumberOfPhases(); j++) {
double relFact = gasVolume / (thermoSystem2.getPhase(j).getVolume("m3"));
if (j >= 1) {
double relFact = 1.0;
if (thermoSystem.getPhase(j).getPhaseTypeName().equals("gas")) {
relFact = gasVolume / (thermoSystem2.getPhase(j).getVolume("m3"));
} else {
relFact = liquidVolume / (thermoSystem2.getPhase(j).getVolume("m3"));

totalliquidVolume += liquidVolume / thermoSystem2.getPhase(j).getMolarVolume();
}

for (int i = 0; i < thermoSystem.getPhase(j).getNumberOfComponents(); i++) {
thermoSystem.addComponent(i, Math.signum(relFact - 1.0) * relFact
thermoSystem.addComponent(i, (relFact - 1.0)
* thermoSystem2.getPhase(j).getComponent(i).getNumberOfMolesInPhase(), j);
}
}

if (thermoSystem.hasPhaseType("gas")) {
thermoSystem.setBeta(gasVolume / thermoSystem2.getPhase(0).getMolarVolume()
/ (gasVolume / thermoSystem2.getPhase(0).getMolarVolume() + totalliquidVolume));
}
thermoSystem.initBeta();
ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem);
ops.TPflash();
thermoSystem.init(3);
// System.out.println("moles in separator " + thermoSystem.getNumberOfMoles());
// double volume1 = thermoSystem.getVolume();
// System.out.println("volume1 bef " + volume1);
// System.out.println("beta " + thermoSystem.getBeta());

liquidLevel = thermoSystem.getPhase(1).getVolume("m3") / (liquidVolume + gasVolume);
liquidVolume = getLiquidLevel() * 3.14 / 4.0 * getInternalDiameter() * getInternalDiameter()
* getSeparatorLength();
thermoSystem.initPhysicalProperties("density");
thermoSystem.prettyPrint();
if (thermoSystem.hasPhaseType("oil") || thermoSystem.hasPhaseType("aqueous")) {
liquidLevel = thermoSystem.getPhase(1).getVolume("m3") / (liquidVolume + gasVolume);
liquidVolume = getLiquidLevel() * 3.14 / 4.0 * getInternalDiameter()
* getInternalDiameter() * getSeparatorLength();
} else {
liquidLevel = 0.0;
liquidVolume = 0.0;
}

gasVolume = (1.0 - getLiquidLevel()) * 3.14 / 4.0 * getInternalDiameter()
* getInternalDiameter() * getSeparatorLength();
// System.out.println("moles out" +
// liquidOutStream.getThermoSystem().getTotalNumberOfMoles());
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
}
// thermoSystem = thermoSystem2;

setCalculationIdentifier(id);
}

Expand All @@ -315,40 +316,56 @@ public void runTransient(double dt, UUID id) {
} else {
inletStreamMixer.run(id);
thermoSystem.init(3);
thermoSystem.initPhysicalProperties("density");
gasOutStream.getThermoSystem().init(3);
liquidOutStream.getThermoSystem().init(3);
double volume1 = thermoSystem.getVolume("m3");
// System.out.println("volume " + volume1);
double deltaEnergy = inletStreamMixer.getOutletStream().getThermoSystem().getEnthalpy()
- gasOutStream.getThermoSystem().getEnthalpy()
- liquidOutStream.getThermoSystem().getEnthalpy();
// System.out.println("enthalph delta " + deltaEnergy);
double newEnergy = thermoSystem.getInternalEnergy() + dt * deltaEnergy;
for (int i = 0; i < thermoSystem.getPhase(0).getNumberOfComponents(); i++) {
double dn = inletStreamMixer.getOutletStream().getThermoSystem().getPhase(0).getComponent(i)
.getNumberOfMolesInPhase()
+ inletStreamMixer.getOutletStream().getThermoSystem().getPhase(1).getComponent(i)
.getNumberOfMolesInPhase()
- gasOutStream.getThermoSystem().getPhase(0).getComponent(i).getNumberOfMolesInPhase()
- liquidOutStream.getThermoSystem().getPhase(0).getComponent(i)
.getNumberOfMolesInPhase();
// System.out.println("dn " + dn);
thermoSystem.addComponent(inletStreamMixer.getOutletStream().getThermoSystem().getPhase(0)
.getComponent(i).getComponentNumber(), dn * dt);
double dncomp = 0.0;
for (int j = 0; j < inletStreamMixer.getOutletStream().getFluid()
.getNumberOfPhases(); j++) {
dncomp += inletStreamMixer.getOutletStream().getThermoSystem().getPhase(j).getComponent(i)
.getNumberOfMolesInPhase();
}
dncomp += -gasOutStream.getThermoSystem().getComponent(i).getNumberOfmoles()
- liquidOutStream.getThermoSystem().getComponent(i).getNumberOfmoles();
thermoSystem.addComponent(i, dncomp * dt);
}
ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem);
thermoOps.VUflash(volume1, newEnergy, "m3", "J");

thermoOps.VUflash(gasVolume + liquidVolume, newEnergy, "m3", "J");
setTempPres(thermoSystem.getTemperature(), thermoSystem.getPressure());

liquidLevel = thermoSystem.getPhase(1).getVolume("m3") / (liquidVolume + gasVolume);
// System.out.println("liquid level " + liquidLevel);
thermoSystem.initPhysicalProperties("density");
liquidLevel = 0.0;
if (thermoSystem.hasPhaseType("oil") || thermoSystem.hasPhaseType("aqueous")) {
double volumeLoc = 0.0;
if (thermoSystem.hasPhaseType("oil")) {
volumeLoc += thermoSystem.getPhase("oil").getVolume("m3");
}
if (thermoSystem.hasPhaseType("aqueous")) {
volumeLoc += thermoSystem.getPhase("aqueous").getVolume("m3");
}
liquidLevel = volumeLoc / (liquidVolume + gasVolume);
}
liquidVolume = getLiquidLevel() * 3.14 / 4.0 * getInternalDiameter() * getInternalDiameter()
* getSeparatorLength();
// System.out.println("gasvol " + gasVolume + " liqvol " + liquidVolume);
gasVolume = (1.0 - getLiquidLevel()) * 3.14 / 4.0 * getInternalDiameter()
* getInternalDiameter() * getSeparatorLength();
setCalculationIdentifier(id);

if (thermoSystem.hasPhaseType("gas")) {
gasOutStream.setPressure(thermoSystem.getPressure("bara"), "bara");
gasOutStream.setTemperature(thermoSystem.getTemperature("C"), "C");
}
if (thermoSystem.hasPhaseType("oil") || thermoSystem.hasPhaseType("aqueous")) {
liquidOutStream.setPressure(thermoSystem.getPressure("bara"), "bara");
liquidOutStream.setTemperature(thermoSystem.getTemperature("C"), "C");
}
gasOutStream.run();
liquidOutStream.run();
return;
}
}

Expand Down Expand Up @@ -441,6 +458,16 @@ public void setGasCarryunderFraction(double gasCarryunderFraction) {
this.gasCarryunderFraction = gasCarryunderFraction;
}

/**
* <p>
* Setter for the field <code>gasCarryunderFraction</code>.
* </p>
*
**/
public void setLiquidLevel(double liquidlev) {
liquidLevel = liquidlev;
}

/**
* <p>
* Getter for the field <code>liquidLevel</code>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ public interface SeparatorInterface extends SimulationInterface {
* @param diam a double
*/
public void setInternalDiameter(double diam);

public void setLiquidLevel(double liquidlev);
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public void testDynamicCalculation2() {
separator1.setCalculateSteadyState(false);
separator1.setSeparatorLength(3.0);
separator1.setInternalDiameter(0.8);
separator1.setLiquidLevel(0.5);

ThrottlingValve valve2 = new ThrottlingValve("valve_2", separator1.getLiquidOutStream());
valve2.setOutletPressure(1.0);
Expand All @@ -158,14 +159,14 @@ public void testDynamicCalculation2() {

LevelTransmitter separatorLevelTransmitter = new LevelTransmitter(separator1);
separatorLevelTransmitter.setName("separatorLevelTransmitter1");
separatorLevelTransmitter.setMaximumValue(0.5);
separatorLevelTransmitter.setMaximumValue(0.8);
separatorLevelTransmitter.setMinimumValue(0.2);

ControllerDeviceInterface separatorLevelController = new ControllerDeviceBaseClass();
separatorLevelController.setReverseActing(false);
separatorLevelController.setTransmitter(separatorLevelTransmitter);
separatorLevelController.setControllerSetPoint(0.3);
separatorLevelController.setControllerParameters(0.510, 200.0, 0.0);
separatorLevelController.setControllerSetPoint(0.45);
separatorLevelController.setControllerParameters(0.0510, 200.0, 0.0);

PressureTransmitter separatorPressureTransmitter =
new PressureTransmitter(separator1.getGasOutStream());
Expand All @@ -177,7 +178,7 @@ public void testDynamicCalculation2() {
separatorPressureController.setTransmitter(separatorPressureTransmitter);
separatorPressureController.setReverseActing(false);
separatorPressureController.setControllerSetPoint(7.0);
separatorPressureController.setControllerParameters(1.5, .0, 0.0);
separatorPressureController.setControllerParameters(0.05, 0.0, 0.0);

p.add(stream1);
p.add(streamPurge);
Expand All @@ -201,7 +202,7 @@ public void testDynamicCalculation2() {

// p.displayResult();
p.setTimeStep(1.0);
for (int i = 0; i < 9000; i++) {
for (int i = 0; i < 900; i++) {
System.out.println("pressure " + separator1.getGasOutStream().getPressure() + " flow "
+ separator1.getGasOutStream().getFlowRate("kg/hr") + " sepr height "
+ separatorLevelTransmitter.getMeasuredValue() + "valve2 opening "
Expand Down

0 comments on commit 691867a

Please sign in to comment.