@@ -45,6 +45,7 @@ public class ThrottlingValve extends TwoPortEquipment implements ValveInterface
45
45
boolean isCalcPressure = false ;
46
46
private boolean gasValve = true ;
47
47
private double Fp = 1.0 ;
48
+ private double deltaPressure = 0.0 ;
48
49
49
50
/**
50
51
* * Constructor for ThrottlingValve.
@@ -415,12 +416,20 @@ public double calcPercentValveOpening(double Pus, double Pds, double rhous, doub
415
416
public void run (UUID id ) {
416
417
// System.out.println("valve running..");
417
418
// outStream.setSpecification(inletStream.getSpecification());
418
- thermoSystem = getInletStream ().getThermoSystem ().clone ();
419
+ if (getInletStream ().getThermoSystem () != null ) {
420
+ thermoSystem = getInletStream ().getThermoSystem ().clone ();
421
+ } else {
422
+ logger .error ("Inlet stream thermo system is null" );
423
+ return ;
424
+ }
419
425
ThermodynamicOperations thermoOps = new ThermodynamicOperations (thermoSystem );
420
426
thermoSystem .init (3 );
421
427
double enthalpy = thermoSystem .getEnthalpy ();
422
428
inStream .getThermoSystem ().initPhysicalProperties (PhysicalPropertyType .MASS_DENSITY );
423
429
double outp = 0.0 ;
430
+ if (pressure == 0 ) {
431
+ pressure = inStream .getThermoSystem ().getPressure ();
432
+ }
424
433
425
434
if (inStream .getThermoSystem ().hasPhaseType (PhaseType .GAS )
426
435
&& inStream .getThermoSystem ().getVolumeFraction (0 ) > 0.9 ) {
@@ -441,6 +450,12 @@ public void run(UUID id) {
441
450
}
442
451
setOutletPressure (outp );
443
452
}
453
+ if (deltaPressure != 0 ) {
454
+ thermoSystem .setPressure (thermoSystem .getPressure (pressureUnit ) - deltaPressure ,
455
+ pressureUnit );
456
+ setOutletPressure (thermoSystem .getPressure ());
457
+
458
+ }
444
459
445
460
if ((thermoSystem .getPressure (pressureUnit ) - pressure ) < 0 ) {
446
461
if (isAcceptNegativeDP ()) {
@@ -456,14 +471,15 @@ public void run(UUID id) {
456
471
// System.out.println("enthalpy inn.." + enthalpy);
457
472
// thermoOps.PHflash(enthalpy, 0);
458
473
if (isIsoThermal () || Math .abs (pressure - inStream .getThermoSystem ().getPressure ()) < 1e-6
459
- || thermoSystem .getNumberOfMoles () < 1e-12 ) {
474
+ || thermoSystem .getNumberOfMoles () < 1e-12 || pressure == 0 ) {
460
475
thermoOps .TPflash ();
461
476
} else {
462
477
thermoOps .PHflash (enthalpy , 0 );
463
478
}
464
479
outStream .setThermoSystem (thermoSystem );
465
480
// System.out.println("Total volume flow " +
466
- // outStream.getThermoSystem().getVolume());
481
+ // Uncomment the line below to get the volume of the outlet stream's thermodynamic system
482
+ // System.out.println("Total volume flow " + outStream.getThermoSystem().getVolume());
467
483
// System.out.println("density valve " +
468
484
// inletStream.getThermoSystem().getDensity());
469
485
@@ -522,7 +538,9 @@ public void run(UUID id) {
522
538
}
523
539
524
540
/** {@inheritDoc} */
525
- @ Override
541
+ /**
542
+ * This annotation is used to exclude the method from Jacoco code coverage reports.
543
+ */
526
544
@ ExcludeFromJacocoGeneratedReport
527
545
public void displayResult () {
528
546
thermoSystem .display (getName ());
@@ -813,4 +831,13 @@ public double getFp() {
813
831
public void setFp (double fp ) {
814
832
Fp = fp ;
815
833
}
834
+
835
+ public double getDeltaPressure () {
836
+ return deltaPressure ;
837
+ }
838
+
839
+ public void setDeltaPressure (double deltaPressure , String unit ) {
840
+ this .deltaPressure = deltaPressure ;
841
+ this .pressureUnit = unit ;
842
+ }
816
843
}
0 commit comments