diff --git a/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceBaseClass.java b/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceBaseClass.java index 685eb70533..1486f94d3c 100644 --- a/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceBaseClass.java +++ b/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceBaseClass.java @@ -43,7 +43,9 @@ public class ControllerDeviceBaseClass extends NamedBaseClass implements Control private double TintValue = 0.0; /** - *
Constructor for ControllerDeviceBaseClass.
+ *+ * Constructor for ControllerDeviceBaseClass. + *
*/ public ControllerDeviceBaseClass() { super("controller"); @@ -75,7 +77,8 @@ public void runTransient(double initResponse, double dt, UUID id) { transmitter.getMeasuredPercentValue() - (controllerSetPoint - transmitter.getMinimumValue()) / (transmitter.getMaximumValue() - transmitter.getMinimumValue()) * 100; - TintValue += Kp / Ti * error * dt; + if (Ti > 0) + TintValue += Kp / Ti * error * dt; double TderivValue = Kp * Td * (error - oldError) / dt; response = initResponse + propConstant * (Kp * error + TintValue + TderivValue); // System.out.println("error " + error + " %"); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java index e3ababd76a..d55243358b 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java @@ -244,47 +244,52 @@ public void run(UUID id) { liquidOutStream.getFluid().init(3); } // liquidOutStream.setThermoSystemFromPhase(thermoSystem2, "aqueous"); - try { - thermoSystem = thermoSystem2.clone(); - thermoSystem.setTotalNumberOfMoles(1.0e-10); - thermoSystem.init(1); - // System.out.println("number of phases " + thermoSystem.getNumberOfPhases()); - double totalliquidVolume = 0.0; - for (int j = 0; j < thermoSystem.getNumberOfPhases(); j++) { - double relFact = gasVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); - if (j >= 1) { - relFact = liquidVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); - - totalliquidVolume += liquidVolume / thermoSystem2.getPhase(j).getMolarVolume(); - } - for (int i = 0; i < thermoSystem.getPhase(j).getNumberOfComponents(); i++) { - thermoSystem.addComponent(thermoSystem.getPhase(j).getComponent(i).getComponentNumber(), - relFact * thermoSystem2.getPhase(j).getComponent(i).getNumberOfMolesInPhase(), j); + if (getCalculateSteadyState()) { + thermoSystem = thermoSystem2; + } else { + try { + thermoSystem = thermoSystem2.clone(); + // thermoSystem.setTotalNumberOfMoles(1.0); + thermoSystem.init(1); + // System.out.println("number of phases " + thermoSystem.getNumberOfPhases()); + double totalliquidVolume = 0.0; + for (int j = 0; j < thermoSystem.getNumberOfPhases(); j++) { + double relFact = gasVolume / (thermoSystem2.getPhase(j).getVolume("m3")); + if (j >= 1) { + 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 + * thermoSystem2.getPhase(j).getComponent(i).getNumberOfMolesInPhase(), j); + } } - } - if (thermoSystem.hasPhaseType("gas")) { - thermoSystem.setBeta(gasVolume / thermoSystem2.getPhase(0).getMolarVolume() - / (gasVolume / thermoSystem2.getPhase(0).getMolarVolume() + totalliquidVolume)); + if (thermoSystem.hasPhaseType("gas")) { + thermoSystem.setBeta(gasVolume / thermoSystem2.getPhase(0).getMolarVolume() + / (gasVolume / thermoSystem2.getPhase(0).getMolarVolume() + totalliquidVolume)); + } + thermoSystem.initBeta(); + 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(); + 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.initBeta(); - 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() * 1e-5 / (liquidVolume + gasVolume); - liquidVolume = getLiquidLevel() * 3.14 / 4.0 * getInternalDiameter() * getInternalDiameter() - * getSeparatorLength(); - 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; + // thermoSystem = thermoSystem2; setCalculationIdentifier(id); } @@ -307,49 +312,44 @@ public void runTransient(double dt, UUID id) { run(id); increaseTime(dt); return; - } + } else { + inletStreamMixer.run(id); + thermoSystem.init(3); + 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); + } + ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); + thermoOps.VUflash(volume1, newEnergy, "m3", "J"); - inletStreamMixer.run(id); + setTempPres(thermoSystem.getTemperature(), thermoSystem.getPressure()); - // System.out.println("moles out" + - // liquidOutStream.getThermoSystem().getTotalNumberOfMoles()); - // double inMoles = - // inletStreamMixer.getOutStream().getThermoSystem().getTotalNumberOfMoles(); - // double gasoutMoles = gasOutStream.getThermoSystem().getNumberOfMoles(); - // double liqoutMoles = liquidOutStream.getThermoSystem().getNumberOfMoles(); - thermoSystem.init(3); - gasOutStream.getThermoSystem().init(3); - liquidOutStream.getThermoSystem().init(3); - double volume1 = thermoSystem.getVolume(); - // System.out.println("volume1 " + 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); + liquidLevel = thermoSystem.getPhase(1).getVolume("m3") / (liquidVolume + gasVolume); + // System.out.println("liquid level " + liquidLevel); + 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); } - ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); - thermoOps.VUflash(volume1, newEnergy); - - setTempPres(thermoSystem.getTemperature(), thermoSystem.getPressure()); - - liquidLevel = thermoSystem.getPhase(1).getVolume() * 1e-5 / (liquidVolume + gasVolume); - // System.out.println("liquid level " + liquidLevel); - liquidVolume = getLiquidLevel() * 3.14 / 4.0 * getInternalDiameter() * getInternalDiameter() - * getSeparatorLength(); - gasVolume = (1.0 - getLiquidLevel()) * 3.14 / 4.0 * getInternalDiameter() - * getInternalDiameter() * getSeparatorLength(); - setCalculationIdentifier(id); } /** @@ -499,7 +499,7 @@ public void setInternalDiameter(double diameter) { * @return a double */ public double getGasSuperficialVelocity() { - return thermoSystem.getPhase(0).getTotalVolume() / 1e5 + return thermoSystem.getPhase(0).getVolume("m3") / (neqsim.thermo.ThermodynamicConstantsInterface.pi * getInternalDiameter() * getInternalDiameter() / 4.0); } @@ -554,7 +554,7 @@ public double getDeRatedGasLoadFactor() { if (surfaceTension < 10.0e-3) { derating = 1.0 - 0.5 * (10.0e-3 - surfaceTension) / 10.0e-3; } - System.out.println("derating " + derating); + // System.out.println("derating " + derating); double term1 = (thermoSystem.getPhase(1).getPhysicalProperties().getDensity() - thermoSystem.getPhase(0).getPhysicalProperties().getDensity()) / thermoSystem.getPhase(0).getPhysicalProperties().getDensity(); @@ -577,7 +577,7 @@ public double getDeRatedGasLoadFactor(int phase) { if (surfaceTension < 10.0e-3) { derating = 1.0 - 0.5 * (10.0e-3 - surfaceTension) / 10.0e-3; } - System.out.println("derating " + derating); + // System.out.println("derating " + derating); double term1 = (thermoSystem.getPhase(phase).getPhysicalProperties().getDensity() - thermoSystem.getPhase(0).getPhysicalProperties().getDensity()) / thermoSystem.getPhase(0).getPhysicalProperties().getDensity(); @@ -658,7 +658,7 @@ public SeparatorSection getSeparatorSection(String name) { return sec; } } - System.out.println("no section with name: " + name + " found....."); + // System.out.println("no section with name: " + name + " found....."); return null; } diff --git a/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java b/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java index c32529e658..c63a5a38f9 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java +++ b/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java @@ -33,7 +33,7 @@ public class ProcessSystem extends SimulationBaseClass { static Logger logger = LogManager.getLogger(ProcessSystem.class); transient Thread thisThread; - String[][] signalDB = new String[1000][100]; + String[][] signalDB = new String[10000][100]; private double surroundingTemperature = 288.15; private int timeStepNumber = 0; private ArrayList