diff --git a/src/main/java/com/henrypump/poc/CLScanner.java b/src/main/java/com/henrypump/poc/CLScanner.java index 66dacf6..546dd78 100644 --- a/src/main/java/com/henrypump/poc/CLScanner.java +++ b/src/main/java/com/henrypump/poc/CLScanner.java @@ -54,6 +54,12 @@ class CLScanner implements Runnable { System.out.println("showtotals -- Gets the current totals and averages"); System.out.println("exit -- Quits the program"); System.out.println(""); + System.out.println("TO ADD A NEW WELL TEST:"); + System.out.println("welltest "); + System.out.println(""); + System.out.println("TO ADD A NEW FLUID SHOT:"); + System.out.println("fluidshot "); + System.out.println(""); } @@ -99,6 +105,13 @@ class CLScanner implements Runnable { ); poc.thisWell.db.newWellTest(poc.thisWell.wellTest); poc.thisWell.wellTest.print(); + } else if(input.startsWith("fluidshot")){ + String[] shotParams = input.split(" "); + FluidShot fs = new FluidShot(Double.parseDouble(shotParams[1]), poc.thisWell.getFluidGradient(), + poc.thisWell.cardStorage[0].getDownholeLoadSpan(), poc.thisWell.getRodDepthTotal(), + poc.thisWell.getPumpArea()); + poc.thisWell.db.newFluidShot(fs); + poc.thisWell.setFrictionEstimate(fs.getFrictionEstimate()); } else { help(); } diff --git a/src/main/java/com/henrypump/poc/Database.java b/src/main/java/com/henrypump/poc/Database.java index d64f206..9dc22f9 100644 --- a/src/main/java/com/henrypump/poc/Database.java +++ b/src/main/java/com/henrypump/poc/Database.java @@ -110,7 +110,7 @@ public class Database { public long newDailyTotal(Measurement inpMeasurement){ String df = ZonedDateTime.now().toString(); - MongoCollection collection = database.getCollection("gaugeOffData"); + MongoCollection collection = database.getCollection("gaugeOff"); Document doc = new Document("tagname", inpMeasurement.getTagName()) .append("currentValue", inpMeasurement.getCurrentValue()) .append("maxDailyValue", inpMeasurement.getDailyMax()) @@ -125,7 +125,7 @@ public class Database { public double getPreviousDailyTotal(ZonedDateTime inpDateTime){ String isoInpDateTime = inpDateTime.toString(); - MongoCollection wellTestCollection = database.getCollection("gaugeOffData"); + MongoCollection wellTestCollection = database.getCollection("gaugeOff"); MongoCursor cursor = wellTestCollection.find(and(eq("tagname", "Fluid Produced"), lte("timestamp", isoInpDateTime))) .sort(Sorts.descending("timestamp")).limit(1).iterator(); double lastTotal = -1.0; @@ -141,7 +141,7 @@ public class Database { public long newWellTest(WellTest inp){ String df = ZonedDateTime.now().toString(); - MongoCollection collection = database.getCollection("wellTestData"); + MongoCollection collection = database.getCollection("wellTests"); Document doc = new Document("testStartTime", df) .append("testHours", inp.getTestHours()) .append("testTotalBBL", inp.getTotalFluidBBL()) @@ -158,7 +158,7 @@ public class Database { public Document getPreviousWellTest(ZonedDateTime inpDateTime){ String isoInpDateTime = inpDateTime.toString(); - MongoCollection wellTestCollection = database.getCollection("wellTestData"); + MongoCollection wellTestCollection = database.getCollection("wellTests"); MongoCursor cursor = wellTestCollection.find(lte("testStartTime", isoInpDateTime)) .sort(Sorts.descending("testStartTime")).limit(1).iterator(); Document lastTest = new Document("kFactor", (Double) 1.0); @@ -173,7 +173,7 @@ public class Database { }; public double getLatestKFactor(){ - MongoCollection wellTestCollection = database.getCollection("wellTestData"); + MongoCollection wellTestCollection = database.getCollection("wellTests"); MongoCursor cursor = wellTestCollection.find().sort(Sorts.descending("testStartTime")).limit(1).iterator(); double kFactor = 1.0; try { @@ -186,4 +186,28 @@ public class Database { return kFactor; } + public long newFluidShot(FluidShot inp){ + String df = ZonedDateTime.now().toString(); + MongoCollection collection = database.getCollection("fluidShots"); + Document doc = new Document("timestamp", df) + .append("fluidLevel", inp.getFluidLevel()) + .append("pumpIntakePressure", inp.getPumpIntakePressure()) + .append("frictionEstimate", inp.getFrictionEstimate()); + collection.insertOne(doc); + return collection.count(); + } + + public double getLatestFrictionEstimate(){ + MongoCollection wellTestCollection = database.getCollection("fluidShots"); + MongoCursor cursor = wellTestCollection.find().sort(Sorts.descending("timestamp")).limit(1).iterator(); + double frictionEstimate = -1; + try { + while (cursor.hasNext()) { + frictionEstimate = cursor.next().getDouble("frictionEstimate"); + } + } finally { + cursor.close(); + } + return frictionEstimate; + } } diff --git a/src/main/java/com/henrypump/poc/FluidShot.java b/src/main/java/com/henrypump/poc/FluidShot.java index 31ff8e7..5bb81b5 100644 --- a/src/main/java/com/henrypump/poc/FluidShot.java +++ b/src/main/java/com/henrypump/poc/FluidShot.java @@ -7,9 +7,30 @@ public class FluidShot { private double fluidLevel; private double frictionEstimate; private double pumpIntakePressure; + private double fluidGradient = 0.45; // Default value + public double getFrictionEstimate(){ + return frictionEstimate; + } + + public double getFluidLevel() { + return fluidLevel; + } + + public double getPumpIntakePressure() { + return pumpIntakePressure; + } + + FluidShot(double fluidLevel, double fluidGradient, double downholeLoadSpan, double totalDepth, double pumpArea){ + this.fluidLevel = fluidLevel; + pumpIntakePressure = fluidLevel / fluidGradient; + + frictionEstimate = downholeLoadSpan - (fluidGradient * totalDepth - pumpIntakePressure) * pumpArea; - FluidShot(double fluidLevel){ } + + + + } diff --git a/src/main/java/com/henrypump/poc/Well.java b/src/main/java/com/henrypump/poc/Well.java index ba86842..582ffcf 100644 --- a/src/main/java/com/henrypump/poc/Well.java +++ b/src/main/java/com/henrypump/poc/Well.java @@ -40,7 +40,7 @@ public class Well { /* CARDS */ private Card currentCard; - private Card[] cardStorage = new Card[100]; + public Card[] cardStorage = new Card[100]; // CONSTANTS private static double YM_STEEL = 30.5; @@ -333,6 +333,10 @@ public class Well { return frictionEstimate; } + public void setFrictionEstimate(double frictionEstimate) { + this.frictionEstimate = frictionEstimate; + } + public double getRodDepthTotal() { return rodDepthTotal; }