@@ -38,7 +38,9 @@ public class Compressor extends TwoPortEquipment implements CompressorInterface
38
38
public double dH = 0.0 ;
39
39
public double inletEnthalpy = 0 ;
40
40
public double pressure = 0.0 ;
41
- private int speed = 3000 ;
41
+ private double speed = 3000 ;
42
+ private double maxspeed = 30000 ;
43
+ private double minspeed = 0 ;
42
44
public double isentropicEfficiency = 1.0 ;
43
45
public double polytropicEfficiency = 1.0 ;
44
46
public boolean usePolytropicCalc = false ;
@@ -670,6 +672,50 @@ public void run(UUID id) {
670
672
setCalculationIdentifier (id );
671
673
}
672
674
675
+ /** {@inheritDoc} */
676
+ @ Override
677
+ public void runTransient (double dt , UUID id ) {
678
+ if (getCalculateSteadyState ()) {
679
+ run (id );
680
+ increaseTime (dt );
681
+ return ;
682
+ }
683
+ runController (dt , id );
684
+
685
+ inStream .getThermoSystem ().init (3 );
686
+ outStream .getThermoSystem ().init (3 );
687
+ double head = (outStream .getThermoSystem ().getEnthalpy ("kJ/kg" )
688
+ - inStream .getThermoSystem ().getEnthalpy ("kJ/kg" ));
689
+ double guessFlow = inStream .getFluid ().getFlowRate ("m3/hr" );
690
+ double actualFlowRateNew = getCompressorChart ().getFlow (head , getSpeed (), guessFlow );
691
+ if (actualFlowRateNew < 0.0 || Double .isNaN (actualFlowRateNew )) {
692
+ logger .error (
693
+ "actual flow rate is negative or NaN and would lead to failure of calculation: actual flow rate "
694
+ + actualFlowRateNew );
695
+ }
696
+ inStream .setFlowRate (actualFlowRateNew , "Am3/hr" );
697
+
698
+ inStream .getThermoSystem ().init (3 );
699
+ inStream .getThermoSystem ().initPhysicalProperties ("density" );
700
+ inStream .run (id );
701
+ inStream .getThermoSystem ().init (3 );
702
+
703
+ outStream .setFlowRate (inStream .getFlowRate ("kg/hr" ), "kg/hr" );
704
+ outStream .run ();
705
+ outStream .getThermoSystem ().init (3 );
706
+
707
+ inletEnthalpy = inStream .getFluid ().getEnthalpy ();
708
+ thermoSystem = outStream .getThermoSystem ().clone ();
709
+ thermoSystem .initPhysicalProperties ("density" );
710
+
711
+ polytropicEfficiency =
712
+ compressorChart .getPolytropicEfficiency (inStream .getFlowRate ("m3/hr" ), speed ) / 100.0 ;
713
+ polytropicFluidHead = head * polytropicEfficiency ;
714
+ dH = polytropicFluidHead * 1000.0 * thermoSystem .getMolarMass () / getPolytropicEfficiency ()
715
+ * inStream .getThermoSystem ().getTotalNumberOfMoles ();
716
+ setCalculationIdentifier (id );
717
+ }
718
+
673
719
/**
674
720
* <p>
675
721
* generateCompressorCurves.
@@ -955,6 +1001,12 @@ public boolean isSurge(double flow, double head) {
955
1001
return getAntiSurge ().isSurge ();
956
1002
}
957
1003
1004
+ public double getDistanceToSurge () {
1005
+ return (getInletStream ().getFlowRate ("m3/hr" )
1006
+ - getCompressorChart ().getSurgeCurve ().getSurgeFlow (getPolytropicFluidHead ()))
1007
+ / getCompressorChart ().getSurgeCurve ().getSurgeFlow (getPolytropicFluidHead ());
1008
+ }
1009
+
958
1010
/**
959
1011
* <p>
960
1012
* isStoneWall.
@@ -985,9 +1037,9 @@ public void setAntiSurge(AntiSurge antiSurge) {
985
1037
* Getter for the field <code>speed</code>.
986
1038
* </p>
987
1039
*
988
- * @return a int
1040
+ * @return a double
989
1041
*/
990
- public int getSpeed () {
1042
+ public double getSpeed () {
991
1043
return speed ;
992
1044
}
993
1045
@@ -998,7 +1050,7 @@ public int getSpeed() {
998
1050
*
999
1051
* @param speed a int
1000
1052
*/
1001
- public void setSpeed (int speed ) {
1053
+ public void setSpeed (double speed ) {
1002
1054
this .speed = speed ;
1003
1055
}
1004
1056
@@ -1256,6 +1308,29 @@ public void setPropertyProfile(CompressorPropertyProfile propertyProfile) {
1256
1308
this .propertyProfile = propertyProfile ;
1257
1309
}
1258
1310
1311
+ /**
1312
+ * <p>
1313
+ * runController.
1314
+ * </p>
1315
+ *
1316
+ * @param dt a double
1317
+ * @param id Calculation identifier
1318
+ */
1319
+ public void runController (double dt , UUID id ) {
1320
+ if (hasController && getController ().isActive ()) {
1321
+ getController ().runTransient (this .speed , dt , id );
1322
+ this .speed = getController ().getResponse ();
1323
+ if (this .speed > maxspeed ) {
1324
+ this .speed = maxspeed ;
1325
+ }
1326
+ if (this .speed < minspeed ) {
1327
+ this .speed = minspeed ;
1328
+ }
1329
+ // System.out.println("valve opening " + this.percentValveOpening + " %");
1330
+ }
1331
+ setCalculationIdentifier (id );
1332
+ }
1333
+
1259
1334
/** {@inheritDoc} */
1260
1335
@ Override
1261
1336
public int hashCode () {
@@ -1310,4 +1385,20 @@ public boolean equals(Object obj) {
1310
1385
&& usePolytropicCalc == other .usePolytropicCalc
1311
1386
&& useRigorousPolytropicMethod == other .useRigorousPolytropicMethod ;
1312
1387
}
1388
+
1389
+ public void setMaximumSpeed (double maxSpeed ) {
1390
+ this .maxspeed = maxSpeed ;
1391
+ }
1392
+
1393
+ public void setMinimumSpeed (double minspeed ) {
1394
+ this .minspeed = minspeed ;
1395
+ }
1396
+
1397
+ public double getMaximumSpeed () {
1398
+ return maxspeed ;
1399
+ }
1400
+
1401
+ public double getMinimumSpeed () {
1402
+ return minspeed ;
1403
+ }
1313
1404
}
0 commit comments