Daily Totals storing, with max min average total
This commit is contained in:
@@ -23,17 +23,6 @@ public class AnalogIn {
|
||||
private double euMax;
|
||||
private double[] history = new double[100];
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("mraajava");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println(
|
||||
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
|
||||
e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
AnalogIn(int channel, double rawMin, double rawMax, double euMin, double euMax){
|
||||
this.channel = channel;
|
||||
if (channel != 99) {
|
||||
|
||||
@@ -48,12 +48,14 @@ public class Card {
|
||||
private double tubingMovement;
|
||||
private double strokeSpeed;
|
||||
|
||||
private double plungerTravel;
|
||||
private double dailyProduction;
|
||||
private double structuralLoading;
|
||||
|
||||
private double polishedRodHorsepower;
|
||||
private double pumpHorsepower;
|
||||
private double fluidBBLMoved;
|
||||
private double waterBBLMoved;
|
||||
private double oilBBLMoved;
|
||||
private double gasMCFMoved;
|
||||
|
||||
private long strokeStartTime;
|
||||
|
||||
@@ -138,18 +140,62 @@ public class Card {
|
||||
return tubingMovement;
|
||||
}
|
||||
|
||||
public double getPlungerTravel() {
|
||||
return plungerTravel;
|
||||
}
|
||||
|
||||
public double getDailyProduction() {
|
||||
return dailyProduction;
|
||||
}
|
||||
|
||||
public double getStructuralLoading() {
|
||||
return structuralLoading;
|
||||
}
|
||||
|
||||
public double getPumpIntakePressure() {
|
||||
return pumpIntakePressure;
|
||||
}
|
||||
|
||||
public double getFluidLevel() {
|
||||
return fluidLevel;
|
||||
}
|
||||
|
||||
public double getStrokeSpeed() {
|
||||
return strokeSpeed;
|
||||
}
|
||||
|
||||
public double getPolishedRodHorsepower() {
|
||||
return polishedRodHorsepower;
|
||||
}
|
||||
|
||||
public double getPumpHorsepower() {
|
||||
return pumpHorsepower;
|
||||
}
|
||||
|
||||
public LPPair getSurfaceLoadMax() {
|
||||
return surfaceLoadMax;
|
||||
}
|
||||
|
||||
public LPPair getSurfaceLoadMin() {
|
||||
return surfaceLoadMin;
|
||||
}
|
||||
|
||||
public LPPair getDownholeLoadMax() {
|
||||
return downholeLoadMax;
|
||||
}
|
||||
|
||||
public LPPair getDownholeLoadMin() {
|
||||
return downholeLoadMin;
|
||||
}
|
||||
|
||||
public double getFluidBBLMoved() {
|
||||
return fluidBBLMoved;
|
||||
}
|
||||
|
||||
public double getWaterBBLMoved() {
|
||||
return waterBBLMoved;
|
||||
}
|
||||
|
||||
public double getOilBBLMoved() {
|
||||
return oilBBLMoved;
|
||||
}
|
||||
|
||||
public double getGasMCFMoved() {
|
||||
return gasMCFMoved;
|
||||
}
|
||||
|
||||
public int getNumPointsUsed() {
|
||||
return numPointsUsed;
|
||||
}
|
||||
@@ -227,7 +273,8 @@ public class Card {
|
||||
};
|
||||
|
||||
void calcStrokeData(int numSlices, double fluidGradient, double rodDepth, double anchorDepth, double tubingCSA,
|
||||
double pumpArea, double frictionEstimate, double structuralRating)
|
||||
double pumpArea, double frictionEstimate, double structuralRating,
|
||||
double waterBBLRatio, double oilBBLRatio, double gasMCFRatio)
|
||||
{
|
||||
calculateSPM();
|
||||
surfacePositionMax = positionMax(surfacePosition, surfaceLoad, numPointsUsed);
|
||||
@@ -303,6 +350,11 @@ public class Card {
|
||||
downholeNetStrokeLength = bottomCorner.getPosition() - downholePositionMin.getPosition();
|
||||
fillageCalculated = (downholeNetStrokeLength / downholeAdjustedGrossStrokeLength) * 100.0;
|
||||
fillageEstimated =(downholeNetStrokeLength / downholeGrossStrokeLength) * 100.0;
|
||||
fluidBBLMoved = downholeNetStrokeLength * pumpArea * 0.00010307;
|
||||
oilBBLMoved = fluidBBLMoved * oilBBLRatio;
|
||||
waterBBLMoved = fluidBBLMoved * waterBBLRatio;
|
||||
gasMCFMoved = fluidBBLMoved * gasMCFRatio;
|
||||
|
||||
|
||||
if (fillageEstimated > 100)
|
||||
fillageEstimated = 100.0;
|
||||
|
||||
@@ -50,16 +50,20 @@ public class Database {
|
||||
public long newCard(Card inpCard){
|
||||
MongoCollection<Document> collection = database.getCollection("cards");
|
||||
List<Double> s_p = new ArrayList<Double>();
|
||||
for(Double pt: inpCard.getSurfacePosition()) { s_p.add(pt);}
|
||||
|
||||
List<Double> s_l = new ArrayList<Double>();
|
||||
for(Double pt: inpCard.getSurfaceLoad()) { s_l.add(pt);}
|
||||
|
||||
List<Double> d_p = new ArrayList<Double>();
|
||||
for(Double pt: inpCard.getDownholePosition()) { d_p.add(pt);}
|
||||
|
||||
List<Double> d_l = new ArrayList<Double>();
|
||||
for(Double pt: inpCard.getDownholeLoad()) { d_l.add(pt);}
|
||||
int numPointsScan = inpCard.getNumPointsUsed();
|
||||
double[] sp = inpCard.getSurfacePosition();
|
||||
double[] sl = inpCard.getSurfaceLoad();
|
||||
double[] dp = inpCard.getDownholePosition();
|
||||
double[] dl = inpCard.getDownholeLoad();
|
||||
for(int i = 0; i < numPointsScan; i++ ) {
|
||||
s_p.add(sp[i]);
|
||||
s_l.add(sl[i]);
|
||||
d_p.add(dp[i]);
|
||||
d_l.add(dl[i]);
|
||||
}
|
||||
|
||||
Document doc = new Document("strokeNumber", inpCard.getStrokeNumber())
|
||||
.append("surface_position", s_p)
|
||||
|
||||
@@ -33,7 +33,9 @@ public class DigitalIn {
|
||||
}
|
||||
|
||||
public int read(){
|
||||
lastValue = gpioPin.read();
|
||||
if (channel != 99 ) {
|
||||
lastValue = gpioPin.read();
|
||||
}
|
||||
return lastValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,17 +17,6 @@ public class DigitalOut {
|
||||
private Gpio gpioPin;
|
||||
private int value;
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("mraajava");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println(
|
||||
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
|
||||
e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
DigitalOut(int channel, int startupValue){
|
||||
this.channel = channel;
|
||||
if (channel != 99) {
|
||||
|
||||
68
src/main/java/com/henrypump/poc/GUI.java
Normal file
68
src/main/java/com/henrypump/poc/GUI.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package com.henrypump.poc;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* Created by patrickjmcd on 2/3/17.
|
||||
*/
|
||||
public class GUI extends Frame {
|
||||
private TextField txtRunStatus;
|
||||
private TextField txtSurfacePosition, txtSurfaceLoad, txtDownholePosition, txtDownholeLoad;
|
||||
private final POC attachedPOC;
|
||||
|
||||
GUI(POC attachedPOC){
|
||||
this.attachedPOC = attachedPOC;
|
||||
//create components
|
||||
txtRunStatus=new TextField();
|
||||
txtRunStatus.setBounds(60,50,100,20);
|
||||
txtRunStatus.setText(Integer.toString(attachedPOC.thisWell.getRunStatus()));
|
||||
|
||||
txtSurfacePosition = new TextField();
|
||||
txtSurfacePosition.setBounds(30,80,100,20);
|
||||
|
||||
txtSurfaceLoad = new TextField();
|
||||
txtSurfaceLoad.setBounds(150,80,100,20);
|
||||
|
||||
txtDownholePosition = new TextField();
|
||||
txtDownholePosition.setBounds(30,110,100,20);
|
||||
|
||||
txtDownholeLoad = new TextField();
|
||||
txtDownholeLoad.setBounds(150,110,100,20);
|
||||
|
||||
|
||||
Button startButton = new Button("START");
|
||||
startButton.setBounds(100,150,80,30);
|
||||
|
||||
Button stopButton = new Button("STOP");
|
||||
stopButton.setBounds(100,200,80,30);
|
||||
|
||||
//register listener
|
||||
// startButton.addActionListener(new ActionListener(){
|
||||
// public void actionPerformed(ActionEvent e){
|
||||
// this.attachedPOC.thisWell.start("guibutton");
|
||||
// txtRunStatus.setText(Integer.toString(thisWell.getRunStatus()));
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// stopButton.addActionListener(new ActionListener(){
|
||||
// public void actionPerformed(ActionEvent e){
|
||||
// thisWell.stop("guibutton");
|
||||
// txtRunStatus.setText(Integer.toString(thisWell.getRunStatus()));
|
||||
// }
|
||||
// });
|
||||
|
||||
//add components and set size, layout and visibility
|
||||
add(startButton);
|
||||
add(stopButton);
|
||||
add(txtRunStatus);
|
||||
add(txtSurfacePosition);
|
||||
add(txtSurfaceLoad);
|
||||
add(txtDownholePosition);
|
||||
add(txtDownholeLoad);
|
||||
setSize(300,300);
|
||||
setLayout(null);
|
||||
setVisible(true);
|
||||
}
|
||||
};
|
||||
75
src/main/java/com/henrypump/poc/Measurement.java
Normal file
75
src/main/java/com/henrypump/poc/Measurement.java
Normal file
@@ -0,0 +1,75 @@
|
||||
package com.henrypump.poc;
|
||||
|
||||
/**
|
||||
* Created by patrickjmcd on 2/3/17.
|
||||
*/
|
||||
public class Measurement {
|
||||
private double currentValue;
|
||||
private double lastValue;
|
||||
private double average;
|
||||
private double total;
|
||||
private double max;
|
||||
private double min;
|
||||
private double[] totalHistory = new double[30];
|
||||
private double[] averageHistory = new double[30];
|
||||
private long numMeasurements;
|
||||
|
||||
Measurement(){
|
||||
average = 0;
|
||||
total = 0;
|
||||
numMeasurements = 0;
|
||||
max = Double.MIN_VALUE;
|
||||
min = Double.MAX_VALUE;
|
||||
}
|
||||
|
||||
public double getCurrentValue() {
|
||||
return currentValue;
|
||||
}
|
||||
|
||||
public double getLastValue() {
|
||||
return lastValue;
|
||||
}
|
||||
|
||||
public double getAverage() {
|
||||
return average;
|
||||
}
|
||||
|
||||
public double getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public long getNumMeasurements() {
|
||||
return numMeasurements;
|
||||
}
|
||||
|
||||
public void update(double value)
|
||||
{
|
||||
lastValue = currentValue;
|
||||
currentValue = value;
|
||||
|
||||
numMeasurements = numMeasurements + 1;
|
||||
average = average * (((float)numMeasurements - 1)/(float)numMeasurements) + (currentValue / (float)numMeasurements);
|
||||
total = total + value;
|
||||
|
||||
max = Math.max(max, currentValue);
|
||||
min = Math.min(min, currentValue);
|
||||
};
|
||||
|
||||
public void endOfDay(){
|
||||
for(int i = 28; i >= 0; i--){
|
||||
totalHistory[i] = totalHistory[i+1];
|
||||
averageHistory[i] = averageHistory[i+1];
|
||||
}
|
||||
|
||||
totalHistory[0] = total;
|
||||
averageHistory[0] = average;
|
||||
|
||||
total = 0;
|
||||
average = 0;
|
||||
max = Double.MIN_VALUE;
|
||||
min = Double.MAX_VALUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -2,34 +2,80 @@ package com.henrypump.poc;
|
||||
|
||||
/**
|
||||
* Created by patrickjmcd on 2/1/17.
|
||||
* POC Class
|
||||
*
|
||||
*/
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class POC implements Runnable{
|
||||
private Well thisWell;
|
||||
protected Well thisWell;
|
||||
private int simLoops;
|
||||
private double tubingMovement;
|
||||
private double pumpIntakePressure;
|
||||
private double fluidLoad;
|
||||
private double fluidLevel;
|
||||
private Thread t;
|
||||
private DigitalIn startBtn = new DigitalIn(8);
|
||||
private DigitalIn stopBtn = new DigitalIn(9);
|
||||
private DigitalOut led2 = new DigitalOut(2, 0);
|
||||
private DigitalOut led3 = new DigitalOut(3, 0);
|
||||
private DigitalOut led4 = new DigitalOut(4, 0);
|
||||
private DigitalOut led5 = new DigitalOut(5, 0);
|
||||
private DigitalOut runIndicator = new DigitalOut(6,0);
|
||||
private DigitalIn startBtn, stopBtn;
|
||||
private DigitalOut led2, led3, led4, led5;
|
||||
private DigitalOut runIndicator;
|
||||
|
||||
private boolean ioEnabled;
|
||||
private boolean guiEnabled;
|
||||
|
||||
|
||||
|
||||
POC(String wellName, String wellSetupJsonFile, int simLoops){
|
||||
thisWell = new Well(wellName);
|
||||
ioEnabled = true;
|
||||
guiEnabled = false;
|
||||
thisWell = new Well(wellName, 99, 99, 7);
|
||||
thisWell.parseJSONFile(wellSetupJsonFile);
|
||||
thisWell.printTapers();
|
||||
this.simLoops = simLoops;
|
||||
|
||||
// IO
|
||||
startBtn = new DigitalIn(8);
|
||||
stopBtn = new DigitalIn(9);
|
||||
led2 = new DigitalOut(2, 0);
|
||||
led3 = new DigitalOut(3, 0);
|
||||
led4 = new DigitalOut(4, 0);
|
||||
led5 = new DigitalOut(5, 0);
|
||||
runIndicator = new DigitalOut(6,0);
|
||||
|
||||
|
||||
String headlessProp = !guiEnabled ? "true" : "false";
|
||||
System.setProperty("java.awt.headless", headlessProp);
|
||||
System.out.println(java.awt.GraphicsEnvironment.isHeadless());
|
||||
}
|
||||
|
||||
POC(String wellName, String wellSetupJsonFile, String simFileName, int simLoops){
|
||||
thisWell = new Well(wellName, simFileName);
|
||||
POC(String wellName, String wellSetupJsonFile, String simFileName, boolean ioEnabled, int simLoops){
|
||||
this.ioEnabled = ioEnabled;
|
||||
if (this.ioEnabled) {
|
||||
guiEnabled = false;
|
||||
thisWell = new Well(wellName, simFileName,99, 99, 7);
|
||||
|
||||
// IO
|
||||
startBtn = new DigitalIn(8);
|
||||
stopBtn = new DigitalIn(9);
|
||||
led2 = new DigitalOut(2, 0);
|
||||
led3 = new DigitalOut(3, 0);
|
||||
led4 = new DigitalOut(4, 0);
|
||||
led5 = new DigitalOut(5, 0);
|
||||
runIndicator = new DigitalOut(6,0);
|
||||
|
||||
} else {
|
||||
thisWell = new Well(wellName, simFileName,99, 99, 99);
|
||||
guiEnabled = true;
|
||||
// IO
|
||||
startBtn = new DigitalIn(99);
|
||||
stopBtn = new DigitalIn(99);
|
||||
led2 = new DigitalOut(99, 0);
|
||||
led3 = new DigitalOut(99, 0);
|
||||
led4 = new DigitalOut(99, 0);
|
||||
led5 = new DigitalOut(99, 0);
|
||||
runIndicator = new DigitalOut(99,0);
|
||||
}
|
||||
|
||||
String headlessProp = !guiEnabled ? "true" : "false";
|
||||
System.setProperty("java.awt.headless", headlessProp);
|
||||
System.out.println(java.awt.GraphicsEnvironment.isHeadless());
|
||||
|
||||
thisWell.parseJSONFile(wellSetupJsonFile);
|
||||
thisWell.printTapers();
|
||||
this.simLoops = simLoops;
|
||||
@@ -46,7 +92,7 @@ public class POC implements Runnable{
|
||||
int loopCounter = 0, loopLimit = simLoops, led2out, led3out, led4out,led5out;
|
||||
double pos;
|
||||
long sleepMilliseconds = (long) (thisWell.getDt() * 1000);
|
||||
|
||||
thisWell.setupFluidRatio(0.25, 0.75, 1.12);
|
||||
thisWell.checkSafeties();
|
||||
while (true) {
|
||||
while (loopCounter < loopLimit && (thisWell.getRunStatus() == Well.RUNSTATUS_RUNNING || thisWell.getRunStatus() == Well.RUNSTATUS_STARTING)) {
|
||||
@@ -60,8 +106,7 @@ public class POC implements Runnable{
|
||||
|
||||
thisWell.eval(i);
|
||||
|
||||
pos = thisWell.getCurrentPosition();
|
||||
|
||||
pos = thisWell.getCurrentSurfacePosition();
|
||||
led2.write(pos > 20.0 ? 1 : 0);
|
||||
led3.write(pos > 40.0 ? 1 : 0);
|
||||
led4.write(pos > 60.0 ? 1 : 0);
|
||||
@@ -77,7 +122,8 @@ public class POC implements Runnable{
|
||||
}
|
||||
loopCounter++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (startBtn.read() == 1) thisWell.start("startbutton");
|
||||
if (stopBtn.read() == 1) thisWell.stop("stopbutton");
|
||||
if (startBtn.read() == 1 && stopBtn.read() == 1) {
|
||||
@@ -101,9 +147,11 @@ public class POC implements Runnable{
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
final POC thisPOC = new POC("Barney", args[0], args[1], 100);
|
||||
final POC thisPOC = new POC("Barney", args[0], args[1], true, 100);
|
||||
thisPOC.start();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,11 +28,13 @@ public class Well {
|
||||
protected Database db;
|
||||
|
||||
// IO
|
||||
AnalogIn inclinometer = new AnalogIn(99, 0, 100, 0, 100);
|
||||
AnalogIn loadCell = new AnalogIn(99, 0, 50000, 0, 50000);
|
||||
DigitalOut runCommand = new DigitalOut(7, 0);
|
||||
private double currentPosition;
|
||||
private double currentLoad;
|
||||
AnalogIn inclinometer;
|
||||
AnalogIn loadCell;
|
||||
DigitalOut runCommand;
|
||||
private double currentSurfacePosition;
|
||||
private double currentSurfaceLoad;
|
||||
private double currentDownholePosition;
|
||||
private double currentDownholeLoad;
|
||||
|
||||
// CARDS
|
||||
private Card currentCard;
|
||||
@@ -131,19 +133,50 @@ public class Well {
|
||||
private int[] count = new int[11];
|
||||
private double sPositionPrevious;
|
||||
|
||||
Well(String wellName){
|
||||
// Fluid Makeup
|
||||
private double fluidOilRatio; // BBL of oil per 1 BBL fluid
|
||||
private double fluidWaterRatio; // BBL of water per 1 BBL fluid
|
||||
private double fluidGasRatio; // MCF of gas per 1 BBL fluid
|
||||
|
||||
// Measurements
|
||||
private Measurement strokeSpeed = new Measurement();
|
||||
private Measurement downholeGrossStroke = new Measurement();
|
||||
private Measurement downholeNetStroke = new Measurement();
|
||||
private Measurement fluidLevel = new Measurement();
|
||||
private Measurement fluidLoad = new Measurement();
|
||||
private Measurement inflowRate = new Measurement();
|
||||
private Measurement peakPolishedRodLoad = new Measurement();
|
||||
private Measurement minPolishedRodLoad = new Measurement();
|
||||
private Measurement percentRun = new Measurement();
|
||||
private Measurement polishedRodHP = new Measurement();
|
||||
private Measurement pumpHP = new Measurement();
|
||||
private Measurement fluidProduced = new Measurement();
|
||||
private Measurement oilProduced = new Measurement();
|
||||
private Measurement waterProduced = new Measurement();
|
||||
private Measurement gasProduced = new Measurement();
|
||||
private Measurement pumpIntakePressure = new Measurement();
|
||||
private Measurement surfaceStrokeLength = new Measurement();
|
||||
private Measurement tubingMovement = new Measurement();
|
||||
|
||||
Well(String wellName, int inclinometerChannel, int loadCellChannel, int runCommandChannel){
|
||||
this.wellName = wellName;
|
||||
db = new Database();
|
||||
strokesLifetime = db.getLastStrokeNum() + 1;
|
||||
currentCard = new Card(strokesLifetime);
|
||||
inclinometer = new AnalogIn(inclinometerChannel, 0, 100, 0, 100);
|
||||
loadCell = new AnalogIn(loadCellChannel, 0, 50000, 0, 50000);
|
||||
runCommand = new DigitalOut(runCommandChannel, 0);
|
||||
}
|
||||
|
||||
Well(String wellName, String simFileName){
|
||||
Well(String wellName, String simFileName, int inclinometerChannel, int loadCellChannel, int runCommandChannel){
|
||||
this.wellName = wellName;
|
||||
sim = new Simulation(simFileName);
|
||||
db = new Database();
|
||||
strokesLifetime = db.getLastStrokeNum() + 1;
|
||||
currentCard = new Card(strokesLifetime);
|
||||
inclinometer = new AnalogIn(inclinometerChannel, 0, 100, 0, 100);
|
||||
loadCell = new AnalogIn(loadCellChannel, 0, 50000, 0, 50000);
|
||||
runCommand = new DigitalOut(runCommandChannel, 0);
|
||||
}
|
||||
|
||||
public double getDt() {
|
||||
@@ -297,12 +330,20 @@ public class Well {
|
||||
return runMode;
|
||||
}
|
||||
|
||||
public double getCurrentPosition() {
|
||||
return currentPosition;
|
||||
public double getCurrentSurfacePosition() {
|
||||
return currentSurfacePosition;
|
||||
}
|
||||
|
||||
public double getCurrentLoad() {
|
||||
return currentLoad;
|
||||
public double getCurrentSurfaceLoad() {
|
||||
return currentSurfaceLoad;
|
||||
}
|
||||
|
||||
public double getCurrentDownholePosition() {
|
||||
return currentDownholePosition;
|
||||
}
|
||||
|
||||
public double getCurrentDownholeLoad() {
|
||||
return currentDownholeLoad;
|
||||
}
|
||||
|
||||
public long getStartupStrokes() {
|
||||
@@ -329,6 +370,12 @@ public class Well {
|
||||
return direction;
|
||||
}
|
||||
|
||||
public void setupFluidRatio(double oilRatio, double waterRatio, double gasRatio){
|
||||
fluidOilRatio = oilRatio;
|
||||
fluidWaterRatio = waterRatio;
|
||||
fluidGasRatio = gasRatio;
|
||||
}
|
||||
|
||||
// WELL COMMAND FUNCTIONS
|
||||
public void start(String initiator){
|
||||
if (runStatus == RUNSTATUS_STOPPED && permissiveOK){
|
||||
@@ -707,7 +754,7 @@ public class Well {
|
||||
{
|
||||
topLoadArray[1][lengthRequired[1]] = loadMult * (sLoad - rodWeightFluidTotal) + sbfriction;
|
||||
}
|
||||
|
||||
sPositionPrevious = sPosition;
|
||||
int j = 1;
|
||||
while (j <= tapersAllowed)
|
||||
{
|
||||
@@ -752,13 +799,13 @@ public class Well {
|
||||
|
||||
public void eval(){
|
||||
checkSafeties();
|
||||
currentPosition = inclinometer.readScaled();
|
||||
currentLoad = loadCell.readScaled();
|
||||
LPStatus lastPoint = calc(currentPosition, currentLoad);
|
||||
currentSurfacePosition = inclinometer.readScaled();
|
||||
currentSurfaceLoad = loadCell.readScaled();
|
||||
LPStatus lastPoint = calc(currentSurfacePosition, currentSurfaceLoad);
|
||||
if(runStatus == RUNSTATUS_STARTING || runStatus == RUNSTATUS_RUNNING) {
|
||||
if (lastPoint.getStatus() == GOOD_STATUS) {
|
||||
currentCard.setSurfacePosition(pointCounter, currentPosition);
|
||||
currentCard.setSurfaceLoad(pointCounter, currentLoad);
|
||||
currentCard.setSurfacePosition(pointCounter, currentSurfacePosition);
|
||||
currentCard.setSurfaceLoad(pointCounter, currentSurfaceLoad);
|
||||
currentCard.setDownholePosition(pointCounter, lastPoint.getPosition());
|
||||
currentCard.setDownholeLoad(pointCounter, lastPoint.getLoad());
|
||||
}
|
||||
@@ -773,7 +820,7 @@ public class Well {
|
||||
currentCard.calcStrokeData(150, fluidGradient,
|
||||
rodDepthTotal, tubingAnchorDepth,
|
||||
tubingCrossSectionalArea, pumpArea,
|
||||
frictionEstimate, structuralRating);
|
||||
frictionEstimate, structuralRating, fluidWaterRatio, fluidOilRatio, fluidGasRatio);
|
||||
for (int j = 98; j >= 0; j--) {
|
||||
cardStorage[j + 1] = cardStorage[j];
|
||||
}
|
||||
@@ -794,17 +841,64 @@ public class Well {
|
||||
}
|
||||
}
|
||||
|
||||
public void endOfStroke(){
|
||||
currentCard.setNumPointsUsed(pointCounter + 1);
|
||||
currentCard.calcStrokeData(150, fluidGradient,
|
||||
rodDepthTotal, tubingAnchorDepth,
|
||||
tubingCrossSectionalArea, pumpArea,
|
||||
frictionEstimate, structuralRating, fluidWaterRatio, fluidOilRatio, fluidGasRatio);
|
||||
for (int j = 98; j >= 0; j--) {
|
||||
cardStorage[j + 1] = cardStorage[j];
|
||||
}
|
||||
cardStorage[0] = currentCard;
|
||||
currentCard.printCard("none", true);
|
||||
strokesSinceStart++;
|
||||
strokesToday++;
|
||||
strokesLifetime++;
|
||||
|
||||
strokeSpeed.update(currentCard.getStrokeSpeed());
|
||||
downholeGrossStroke.update(currentCard.getDownholeGrossStrokeLength());
|
||||
downholeNetStroke.update(currentCard.getDownholeNetStrokeLength());
|
||||
fluidLevel.update(currentCard.getFluidLevel());
|
||||
fluidLoad.update(currentCard.getFluidLoad());
|
||||
peakPolishedRodLoad.update(currentCard.getSurfaceLoadMax().getLoad());
|
||||
minPolishedRodLoad.update(currentCard.getSurfaceLoadMin().getLoad());
|
||||
polishedRodHP.update(currentCard.getPolishedRodHorsepower());
|
||||
pumpHP.update(currentCard.getPumpHorsepower());
|
||||
fluidProduced.update(currentCard.getFluidBBLMoved());
|
||||
oilProduced.update(currentCard.getOilBBLMoved());
|
||||
waterProduced.update(currentCard.getWaterBBLMoved());
|
||||
gasProduced.update(currentCard.getGasMCFMoved());
|
||||
pumpIntakePressure.update(currentCard.getPumpIntakePressure());
|
||||
surfaceStrokeLength.update(currentCard.getSurfaceStrokeLength());
|
||||
tubingMovement.update(currentCard.getTubingMovement());
|
||||
|
||||
printTotals();
|
||||
|
||||
currentCard = new Card(strokesLifetime);
|
||||
pointCounter = -1;
|
||||
if (strokesSinceStart > startupStrokes){
|
||||
runStatus = RUNSTATUS_RUNNING;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void eval(int simPoint){
|
||||
checkSafeties();
|
||||
currentPosition = inclinometer.readScaledSim(sim.getPositionAtIndex(simPoint));
|
||||
currentLoad = loadCell.readScaledSim(sim.getLoadAtIndex(simPoint));
|
||||
LPStatus lastPoint = calc(currentPosition, currentLoad);
|
||||
currentSurfacePosition = inclinometer.readScaledSim(sim.getPositionAtIndex(simPoint));
|
||||
currentSurfaceLoad = loadCell.readScaledSim(sim.getLoadAtIndex(simPoint));
|
||||
|
||||
LPStatus lastPoint = calc(currentSurfacePosition, currentSurfaceLoad);
|
||||
if (lastPoint.getStatus() == GOOD_STATUS){
|
||||
currentDownholePosition = lastPoint.getPosition();
|
||||
currentDownholeLoad = lastPoint.getLoad();
|
||||
}
|
||||
if(runStatus == RUNSTATUS_STARTING || runStatus == RUNSTATUS_RUNNING) {
|
||||
if (lastPoint.getStatus() == GOOD_STATUS) {
|
||||
currentCard.setSurfacePosition(pointCounter, currentPosition);
|
||||
currentCard.setSurfaceLoad(pointCounter, currentLoad);
|
||||
currentCard.setDownholePosition(pointCounter, lastPoint.getPosition());
|
||||
currentCard.setDownholeLoad(pointCounter, lastPoint.getLoad());
|
||||
currentCard.setSurfacePosition(pointCounter, currentSurfacePosition);
|
||||
currentCard.setSurfaceLoad(pointCounter, currentSurfaceLoad);
|
||||
currentCard.setDownholePosition(pointCounter, currentDownholePosition);
|
||||
currentCard.setDownholeLoad(pointCounter, currentDownholeLoad);
|
||||
}
|
||||
|
||||
if (inclinometer.getHistory(0) > inclinometer.getHistory(1))
|
||||
@@ -813,25 +907,7 @@ public class Well {
|
||||
direction = DIRECTION_DOWN;
|
||||
|
||||
if (direction == DIRECTION_UP && lastDirection == DIRECTION_DOWN && pointCounter > 0) {
|
||||
currentCard.setNumPointsUsed(pointCounter + 1);
|
||||
currentCard.calcStrokeData(150, fluidGradient,
|
||||
rodDepthTotal, tubingAnchorDepth,
|
||||
tubingCrossSectionalArea, pumpArea,
|
||||
frictionEstimate, structuralRating);
|
||||
for (int j = 98; j >= 0; j--) {
|
||||
cardStorage[j + 1] = cardStorage[j];
|
||||
}
|
||||
cardStorage[0] = currentCard;
|
||||
currentCard.printCard("none", true);
|
||||
System.out.println("Cards in DB: " + db.newCard(currentCard));
|
||||
strokesSinceStart++;
|
||||
strokesToday++;
|
||||
strokesLifetime++;
|
||||
currentCard = new Card(strokesLifetime);
|
||||
pointCounter = -1;
|
||||
if (strokesSinceStart > startupStrokes){
|
||||
runStatus = RUNSTATUS_RUNNING;
|
||||
}
|
||||
endOfStroke();
|
||||
}
|
||||
lastDirection = direction;
|
||||
pointCounter++;
|
||||
@@ -843,15 +919,44 @@ public class Well {
|
||||
runCommand.write(0);
|
||||
}
|
||||
}
|
||||
public void printTotals(){
|
||||
|
||||
V2_AsciiTable taperTable = new V2_AsciiTable();
|
||||
taperTable.addRule();
|
||||
taperTable.addRow("Measuremnt", "Average", "Total");
|
||||
taperTable.addStrongRule();
|
||||
taperTable.addRow("Stroke Speed", strokeSpeed.getAverage(), strokeSpeed.getTotal());
|
||||
taperTable.addRow("DH Gross Stroke", downholeGrossStroke.getAverage(), downholeGrossStroke.getTotal());
|
||||
taperTable.addRow("DH Net Stroke", downholeNetStroke.getAverage(), downholeNetStroke.getTotal());
|
||||
taperTable.addRow("Fluid Level", fluidLevel.getAverage(), fluidLevel.getTotal());
|
||||
taperTable.addRow("Fluid Load", fluidLoad.getAverage(), fluidLoad.getTotal());
|
||||
taperTable.addRow("Peak PR Load", peakPolishedRodLoad.getAverage(), peakPolishedRodLoad.getTotal());
|
||||
taperTable.addRow("Min PR Load", minPolishedRodLoad.getAverage(), minPolishedRodLoad.getTotal());
|
||||
taperTable.addRow("PR HP", polishedRodHP.getAverage(), polishedRodHP.getTotal());
|
||||
taperTable.addRow("Pump HP", pumpHP.getAverage(), pumpHP.getTotal());
|
||||
taperTable.addRow("Fluid Produced", fluidProduced.getAverage(), fluidProduced.getTotal());
|
||||
taperTable.addRow("Oil Produced", oilProduced.getAverage(), oilProduced.getTotal());
|
||||
taperTable.addRow("Water Produced", waterProduced.getAverage(), waterProduced.getTotal());
|
||||
taperTable.addRow("Gas Produced", gasProduced.getAverage(), gasProduced.getTotal());
|
||||
taperTable.addRow("Pump Intake Pressure", pumpIntakePressure.getAverage(), pumpIntakePressure.getTotal());
|
||||
taperTable.addRow("Surf Stroke Length", surfaceStrokeLength.getAverage(), surfaceStrokeLength.getTotal());
|
||||
taperTable.addRow("Tubing Movement", tubingMovement.getAverage(), tubingMovement.getTotal());
|
||||
taperTable.addRule();
|
||||
V2_AsciiTableRenderer rend = new V2_AsciiTableRenderer();
|
||||
rend.setTheme(V2_E_TableThemes.UTF_LIGHT.get());
|
||||
rend.setWidth(new WidthAbsoluteEven(100));
|
||||
RenderedTable rt = rend.render(taperTable);
|
||||
System.out.println(rt);
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
public void allOutputsOff(){
|
||||
runCommand.write(0, true);
|
||||
}
|
||||
|
||||
public static void main( String[] args ){
|
||||
Well thisWell = new Well("Barney");
|
||||
Well thisWell = new Well("Barney", args[1], 99, 99, 99);
|
||||
thisWell.parseJSONFile(args[0]);
|
||||
// thisWell.parseJSONFile("/Users/patrickjmcd/Henry_Pump/poc-java/wellSetup.json");
|
||||
thisWell.printTapers();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user