Skip to content

Commit

Permalink
some further work to get dynamic compressor to work
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol committed Dec 8, 2023
1 parent b7cc5f8 commit 4bffb77
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -680,15 +680,15 @@ public void runTransient(double dt, UUID id) {
}

// runController(dt, id);
System.out.println("delta p compressor "
+ (outStream.getThermoSystem().getPressure() - inStream.getThermoSystem().getPressure()));

// System.out.println("delta p compressor "
// + (outStream.getThermoSystem().getPressure() - inStream.getThermoSystem().getPressure()));
inStream.getThermoSystem().initProperties();
double guessFlow = inStream.getThermoSystem().getFlowRate("m3/hr");
outStream.getThermoSystem().init(3);
inStream.getThermoSystem().init(3);
double polytropicHead = outStream.getThermoSystem().getEnthalpy("kJ/kg")
- inStream.getThermoSystem().getEnthalpy("kJ/kg");
System.out.println("polytropic head " + polytropicHead);
// System.out.println("polytropic head " + polytropicHead);
double actualFlowRateNew = 10.0;
actualFlowRateNew = getCompressorChart().getFlow(polytropicHead, getSpeed(), guessFlow);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,8 @@ public double getFlow(double head, int speed, double guessFlow) {
newhead = getPolytropicHead(newflow, speed);
error = newhead - head;
derrordspeed = (error - olderror) / (newflow - oldflow);
if (Math.abs(error) > 1e-6)
newflow -= error / derrordspeed;
System.out.println("newflow " + newflow);
newflow -= error / derrordspeed;
// System.out.println("newflow " + newflow);
} while (Math.abs(error) > 1e-6 && iter < 100);

// change speed to minimize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ public void testDynamicCalculation2() {
assertEquals(0.45, separatorLevelTransmitter.getMeasuredValue(), 0.01);
}



@Test
public void testDynamicCompressor() {
neqsim.thermo.system.SystemInterface testSystem2 =
Expand All @@ -234,7 +232,7 @@ public void testDynamicCompressor() {
testSystem2.setMixingRule(2);

Stream stream1 = new Stream("Stream1", testSystem2);
stream1.setFlowRate(100.0, "kg/hr");
stream1.setFlowRate(50.0, "kg/hr");
stream1.setPressure(100.0, "bara");
stream1.setTemperature(55.0, "C");

Expand All @@ -246,18 +244,18 @@ public void testDynamicCompressor() {
Separator separator1 = new Separator("separator_1");
separator1.addStream(valve1.getOutletStream());
separator1.setCalculateSteadyState(false);
separator1.setSeparatorLength(1.0);
separator1.setSeparatorLength(3.0);
separator1.setInternalDiameter(0.8);
separator1.setLiquidLevel(0.0);

Compressor compressor1 = new Compressor(separator1.getGasOutStream());
compressor1.setCalculateSteadyState(true);
compressor1.setCalculateSteadyState(false);
compressor1.setOutletPressure(100.0);

Separator separator2 = new Separator("separator_2");
separator2.addStream(compressor1.getOutletStream());
separator2.setCalculateSteadyState(false);
separator2.setSeparatorLength(1.0);
separator2.setSeparatorLength(3.0);
separator2.setInternalDiameter(0.8);
separator2.setLiquidLevel(0.0);

Expand All @@ -274,38 +272,46 @@ public void testDynamicCompressor() {
p.add(valve2);

p.run();

assertEquals(100.0, compressor1.getOutletStream().getPressure(), 0.01);

neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator compchartgenerator =
new neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator(
compressor1);
compressor1.setCompressorChart(compchartgenerator.generateCompressorChart("normal"));
compressor1.getCompressorChart().setUseCompressorChart(true);

p.run();
assertEquals(102.7, compressor1.getOutletStream().getPressure(), 2.01);
compressor1.setSpeed(compressor1.getSpeed() + 500);
p.run();
assertEquals(156.264, compressor1.getOutletStream().getPressure(), 2.01);

assertEquals(50.0, separator1.getGasOutStream().getPressure(), 0.01);
System.out.println("speed " + compressor1.getSpeed());
p.setTimeStep(1.0);
// p.runTransient();

assertEquals(50.0, separator1.getGasOutStream().getPressure(), 0.01);
p.runTransient();

// compressor1.setSpeed(compressor1.getSpeed() + 500);
for (int i = 0; i < 1000; i++) {
System.out.println("time " + i + " speed " + compressor1.getSpeed() + "feed flow "
+ stream1.getFlowRate("kg/hr") + " compressor flow rate "
+ compressor1.getInletStream().getFlowRate("kg/hr") + " out flow "
+ valve2.getOutletStream().getFlowRate("kg/hr") + " delta p "
+ (compressor1.getOutletStream().getPressure()
- compressor1.getInletStream().getPressure())
+ " pres inn " + compressor1.getInletStream().getPressure() + " pres out "
+ compressor1.getOutletStream().getPressure());
p.runTransient();
}

compressor1.setCalculateSteadyState(false);
compressor1.runTransient(1);
compressor1.setSpeed(compressor1.getSpeed() + 500);
compressor1.runTransient(1);
compressor1.setSpeed(compressor1.getSpeed() + 500);
compressor1.runTransient(1);
compressor1.setSpeed(compressor1.getSpeed() + 500);
compressor1.runTransient(1);
compressor1.setSpeed(compressor1.getSpeed() - 500);
compressor1.runTransient(1);
compressor1.setSpeed(compressor1.getSpeed() - 500);
compressor1.runTransient(1);
compressor1.setSpeed(compressor1.getSpeed() - 500);
compressor1.runTransient(1);
for (int i = 0; i < 2000; i++) {
System.out.println("time " + i + " speed " + compressor1.getSpeed() + "feed flow "
+ stream1.getFlowRate("kg/hr") + " compressor flow rate "
+ compressor1.getInletStream().getFlowRate("kg/hr") + " out flow "
+ valve2.getOutletStream().getFlowRate("kg/hr") + " delta p "
+ (compressor1.getOutletStream().getPressure()
- compressor1.getInletStream().getPressure())
+ " pres inn " + compressor1.getInletStream().getPressure() + " pres out "
+ compressor1.getOutletStream().getPressure());
p.runTransient();
}
}
}

0 comments on commit 4bffb77

Please sign in to comment.