Skip to content

Commit

Permalink
refact: reuse twoport methods
Browse files Browse the repository at this point in the history
  • Loading branch information
asmfstatoil committed Jan 28, 2025
1 parent 0ca1dc7 commit 9042a78
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
22 changes: 6 additions & 16 deletions src/main/java/neqsim/process/equipment/diffpressure/Orifice.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

public class Orifice extends TwoPortEquipment {
private static final long serialVersionUID = 1L;
private String name;
private StreamInterface inputstream;
private StreamInterface outputstream;
private Double dp;
Expand All @@ -33,15 +32,6 @@ public Orifice(String name, double diameter, double orificeDiameter, double pres
this.dischargeCoefficient = dischargeCoefficient;
}

public void setInputStream(StreamInterface stream) {
this.inputstream = stream;
this.outputstream = (StreamInterface) stream.clone();
}

public StreamInterface getOutputStream() {
return outputstream;
}

public void setOrificeParameters(Double diameter, Double diameter_outer, Double C) {
this.diameter = diameter;
this.diameter_outer = diameter_outer;
Expand All @@ -65,7 +55,7 @@ public Double calc_dp() {

/**
* Calculates the orifice discharge coefficient using the Reader-Harris Gallagher method.
*
*
* @param D Upstream internal pipe diameter, in meters.
* @param Do Diameter of orifice at flow conditions, in meters.
* @param rho Density of fluid at P1, in kg/m^3.
Expand All @@ -84,7 +74,8 @@ public static double calculateDischargeCoefficient(double D, double Do, double r
double beta4 = beta2 * beta2;
double beta8 = beta4 * beta4;

double L1, L2_prime;
double L1;
double L2_prime;
if ("corner".equalsIgnoreCase(taps)) {
L1 = 0.0;
L2_prime = 0.0;
Expand Down Expand Up @@ -114,7 +105,7 @@ public static double calculateDischargeCoefficient(double D, double Do, double r

/**
* Calculates the expansibility factor for orifice plate calculations.
*
*
* @param D Upstream internal pipe diameter, in meters.
* @param Do Diameter of orifice at flow conditions, in meters.
* @param P1 Static pressure of fluid upstream, in Pa.
Expand All @@ -130,7 +121,7 @@ public static double calculateExpansibility(double D, double Do, double P1, doub

/**
* Calculates the non-recoverable pressure drop across the orifice plate.
*
*
* @param D Upstream internal pipe diameter, in meters.
* @param Do Diameter of orifice at flow conditions, in meters.
* @param P1 Static pressure of fluid upstream, in Pa.
Expand All @@ -150,7 +141,7 @@ public static double calculatePressureDrop(double D, double Do, double P1, doubl

/**
* Calculates the diameter ratio (beta) of the orifice plate.
*
*
* @param D Upstream internal pipe diameter, in meters.
* @param Do Diameter of orifice at flow conditions, in meters.
* @return Diameter ratio (beta).
Expand All @@ -169,5 +160,4 @@ public void run(UUID uuid) {
outStream.run();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ void testCalc_dp() {

// Step 3: Define and set up the orifice unit operation
Orifice orif1 = new Orifice("orifice 1");
orif1.setInputStream(stream1);
orif1.setInletStream(stream1);
orif1.setOrificeParameters(0.07366, 0.05, 0.61); // Diameter, outer diameter, and discharge
// coefficient

// Step 4: Define the output stream after the orifice
Stream stream2 = new Stream("stream 2", orif1.getOutputStream());
Stream stream2 = new Stream("stream 2", orif1.getOutletStream());

// Step 5: Set up and run the process system
ProcessSystem oilProcess = new ProcessSystem();
Expand All @@ -37,6 +37,5 @@ void testCalc_dp() {

// Output the pressure after the orifice
System.out.println("Pressure out of orifice: " + stream2.getPressure("bara") + " bara");

}
}

0 comments on commit 9042a78

Please sign in to comment.