diff --git a/.gradle/3.1/taskArtifacts/cache.properties.lock b/.gradle/3.1/taskArtifacts/cache.properties.lock index 234623a..7baecfd 100644 Binary files a/.gradle/3.1/taskArtifacts/cache.properties.lock and b/.gradle/3.1/taskArtifacts/cache.properties.lock differ diff --git a/.gradle/3.1/taskArtifacts/fileHashes.bin b/.gradle/3.1/taskArtifacts/fileHashes.bin index 0b7885d..4fc2fd0 100644 Binary files a/.gradle/3.1/taskArtifacts/fileHashes.bin and b/.gradle/3.1/taskArtifacts/fileHashes.bin differ diff --git a/.gradle/3.1/taskArtifacts/fileSnapshots.bin b/.gradle/3.1/taskArtifacts/fileSnapshots.bin index 356c0bb..5d192c8 100644 Binary files a/.gradle/3.1/taskArtifacts/fileSnapshots.bin and b/.gradle/3.1/taskArtifacts/fileSnapshots.bin differ diff --git a/.gradle/3.1/taskArtifacts/taskArtifacts.bin b/.gradle/3.1/taskArtifacts/taskArtifacts.bin index 79a834e..5acea28 100644 Binary files a/.gradle/3.1/taskArtifacts/taskArtifacts.bin and b/.gradle/3.1/taskArtifacts/taskArtifacts.bin differ diff --git a/.gradletasknamecache b/.gradletasknamecache new file mode 100644 index 0000000..8dba709 --- /dev/null +++ b/.gradletasknamecache @@ -0,0 +1,79 @@ +assemble +build +buildDependents +buildNeeded +classes +compileJava +processResources +clean +jar +testClasses +compileTestJava +processTestResources +init +wrapper +javadoc +buildEnvironment +components +dependencies +dependencyInsight +help +model +projects +properties +tasks +cleanIdea +cleanIdeaModule +cleanIdeaProject +idea +ideaModule +ideaProject +ideaWorkspace +check +test +cleanIdeaWorkspace +deploy +fatJar +install +runRemote +Pattern: +Pattern: +Pattern: +assemble +build +buildDependents +buildNeeded +classes +compileJava +processResources +clean +jar +testClasses +compileTestJava +processTestResources +init +wrapper +javadoc +buildEnvironment +components +dependencies +dependencyInsight +help +model +projects +properties +tasks +cleanIdea +cleanIdeaModule +cleanIdeaProject +idea +ideaModule +ideaProject +ideaWorkspace +check +test +cleanIdeaWorkspace +deploy +fatJar +install +runRemote diff --git a/.idea/workspace.xml b/.idea/workspace.xml index ba583f5..6287e4d 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,17 +2,18 @@ - - - - - - + + + + + + + + - - - + + + + + @@ -531,37 +561,37 @@ - + - + - - - - - - - - - - - - + + + + + + + + + + + + - + + - - - - - - + + + + + + - - + @@ -583,33 +613,50 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -618,7 +665,15 @@ - + + + + + + + + + @@ -628,12 +683,12 @@ - - - - - - + + + + + + @@ -661,33 +716,50 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -697,33 +769,50 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -855,7 +944,7 @@ - + @@ -872,16 +961,6 @@ - - - - - - - - - - @@ -890,73 +969,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -965,13 +977,238 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No facets are configured + + + + + + + + + + + + + + + 1.8 + + + + + + + + poc-java + + + + + + + + Maven: com.googlecode.json-simple:json-simple:1.1.1 + + + + + + \ No newline at end of file diff --git a/wellSetup.json b/barneyWell.json similarity index 100% rename from wellSetup.json rename to barneyWell.json diff --git a/build.gradle b/build.gradle index c816908..4fc34d0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ apply plugin: 'java' apply plugin: 'maven' +apply plugin: 'idea' group = 'com.henrypump.poc' @@ -43,9 +44,9 @@ remotes { //create a single Jar with all dependencies task fatJar(type: Jar) { manifest { - attributes 'Implementation-Title': 'Gradle Jar File Example', + attributes 'Implementation-Title': 'POC Jar File', 'Implementation-Version': version, - 'Main-Class': 'com.mkyong.DateUtils' + 'Main-Class': 'com.henrypump.poc.POC' } baseName = project.name + '-all' from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } @@ -63,7 +64,7 @@ task deploy << { task runRemote << { ssh.run { session(remotes.edison) { - execute 'java -cp .:/usr/lib/java/*:poc-java-all-1.0-SNAPSHOT.jar com.henrypump.poc.POC viceroyWell.json card_72599_surface.csv' + execute 'java -cp .:/usr/lib/java/*:poc-java-all-1.0-SNAPSHOT.jar com.henrypump.poc.POC kiesha7265Well.json kiesha7265_card_147_surface.csv' } } } \ No newline at end of file diff --git a/kiesha7265Well.json b/kiesha7265Well.json new file mode 100644 index 0000000..d10fbd6 --- /dev/null +++ b/kiesha7265Well.json @@ -0,0 +1,31 @@ +{ + "deltaT": 0.1, + "pumpDiameter": 2.0, + "fluidGradient": 0.45, + "tubingID": 2.441, + "tubingOD": 2.875, + "tubingAnchorDepth": 5963.0, + "structuralRating": 320000.0, + "stuffingBoxFriction": 100.0, + "tubingHeadPressure": 100.0, + "tapers": [ + { + "length": 4097.0, + "diameter": 1.225, + "material": "fiberglass", + "dampingFactor": 0.8 + }, + { + "length": 1550.0, + "diameter": 1.0, + "material": "steel", + "dampingFactor": 0.8 + }, + { + "length": 250.0, + "diameter": 1.5, + "material": "steel", + "dampingFactor": 0.8 + } + ] +} diff --git a/kiesha7265_card_147_surface.csv b/kiesha7265_card_147_surface.csv new file mode 100644 index 0000000..1e0fbbe --- /dev/null +++ b/kiesha7265_card_147_surface.csv @@ -0,0 +1,72 @@ +108.61,5568.25 +105.89,5513.06 +103.39,5434.58 +100.19,5293.22 +97,5167.38 +93.23,5048.32 +89.59,4983.5 +85.37,4931.5 +81.26,4880.43 +76.69,4835.59 +71.99,4831.69 +66.99,4830.27 +61.54,4882.61 +56.15,4948.93 +50.87,5011.63 +45.22,5069.05 +39.76,5143.23 +34.34,5191.4 +29.14,5219.3 +24.14,5202.72 +19.01,5058.44 +15.06,4815.65 +11.41,4658.12 +8.19,4573.74 +5.29,4535.83 +3.33,4512.9 +2.01,4517.67 +1.43,4533.9 +1.43,4639.57 +1.82,4847.4 +2.82,5032.86 +4.93,5180.57 +7.1,5294.55 +9.51,5371.81 +12.18,5503.77 +15.85,5724.93 +19.83,5995.5 +24.05,6268.74 +28.64,6516.94 +32.95,6699.54 +37.7,6823.33 +42.63,6966.71 +48.11,7056.78 +53.1,7075.33 +58.13,6976.73 +63.06,6838.9 +68.49,6633.76 +73.6,6459.24 +78.99,6251.46 +83.75,5989.22 +88.35,5712.01 +93.03,5423.94 +97.34,5218.33 +101.14,5082.52 +104.61,4993.43 +107.9,4934.21 +110.81,4865.85 +113.08,4871.49 +114.92,4941.21 +116.56,5049.92 +117.64,5164.69 +118.34,5255.13 +118.37,5277.04 +118.42,5281.13 +118,5298.63 +117.13,5503.39 +115.98,5618.52 +114.41,5666.09 +112.48,5647.89 +110.44,5618.84 +108.28,5572.79 +108.61,5568.25 \ No newline at end of file diff --git a/kiesha7265_card_3_surface.csv b/kiesha7265_card_3_surface.csv new file mode 100644 index 0000000..c9b93ea --- /dev/null +++ b/kiesha7265_card_3_surface.csv @@ -0,0 +1,71 @@ +106.56,5559.16 +103.69,5476.74 +100.91,5347.85 +97.7,5202.76 +94.04,5081.64 +90.16,4969.94 +86.1,4907.14 +81.93,4857.86 +77.56,4848.6 +73.5,4836.39 +68.53,4840.4 +63.35,4882.71 +57.48,4962.65 +52.21,5048 +46.41,5112.74 +41.07,5174.13 +35.3,5239.02 +30.07,5266.9 +24.81,5229.27 +20.09,5038.89 +15.87,4771.81 +12.18,4605.68 +8.96,4507.07 +6.12,4457.05 +3.98,4431.96 +2.35,4423.11 +1.21,4416.8 +1.24,4555.69 +1.46,4774.43 +2.41,4975.61 +4.3,5141.43 +6.46,5271.44 +8.87,5371.92 +11.87,5480.33 +15.38,5622.74 +18.95,5886.1 +23.29,6185.17 +27.42,6498.76 +32.06,6699.7 +36.8,6844.66 +41.54,6979.34 +46.22,7073 +51.75,7119.29 +57.21,7094.23 +62.41,6933.75 +67.48,6728.46 +72.67,6509.91 +77.51,6254.98 +82.08,6006.73 +87.12,5749.58 +92.03,5454.61 +96.37,5194.45 +100.34,5008.54 +104.03,4899.88 +107.43,4841.2 +109.94,4824.88 +112.65,4809.43 +114.67,4838.17 +116.34,4928.36 +117.31,5077.75 +117.73,5192.38 +118.43,5257 +118.63,5265.33 +118.38,5320.02 +117.54,5469.46 +116.15,5617.94 +114.93,5682.86 +113.03,5696.01 +111.28,5676.49 +109.07,5614.65 +106.56,5559.16 \ No newline at end of file diff --git a/poc-java.iml b/poc-java.iml index cbe8276..35d2624 100644 --- a/poc-java.iml +++ b/poc-java.iml @@ -1,6 +1,6 @@ - + diff --git a/src/main/java/com/henrypump/poc/Database.java b/src/main/java/com/henrypump/poc/Database.java index 464ddaf..c5d39d5 100644 --- a/src/main/java/com/henrypump/poc/Database.java +++ b/src/main/java/com/henrypump/poc/Database.java @@ -14,6 +14,7 @@ import org.bson.Document; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.time.Instant; import java.util.Arrays; import com.mongodb.client.MongoCursor; @@ -82,22 +83,21 @@ public class Database { } public long newMeasurement(Measurement inpMeasurement){ -// String df = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new Date()); -// MongoCollection collection = database.getCollection("wellData"); -// Document doc = new Document("tagname", inpMeasurement.getTagName()) -//// .append("currentValue", inpMeasurement.getCurrentValue()) -//// .append("maxDailyValue", inpMeasurement.getDailyMax()) -//// .append("minDailyValue", inpMeasurement.getDailyMin()) -//// .append("dailyAverage", inpMeasurement.getAverage()) -//// .append("dailyTotal", inpMeasurement.getTotal()) -// .append("timestamp", df); -// collection.insertOne(doc); -// return collection.count(); - return 1; + String df = Date.from(Instant.now()).toString(); + MongoCollection collection = database.getCollection("wellData"); + Document doc = new Document("tagname", inpMeasurement.getTagName()) + .append("currentValue", inpMeasurement.getCurrentValue()) + .append("maxDailyValue", inpMeasurement.getDailyMax()) + .append("minDailyValue", inpMeasurement.getDailyMin()) + .append("dailyAverage", inpMeasurement.getAverage()) + .append("dailyTotal", inpMeasurement.getTotal()) + .append("timestamp", df); + collection.insertOne(doc); + return collection.count(); } public long newDailyTotal(Measurement inpMeasurement){ - String df = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new Date()); + String df = Date.from(Instant.now()).toString(); MongoCollection collection = database.getCollection("gaugeOffData"); Document doc = new Document("tagname", inpMeasurement.getTagName()) .append("currentValue", inpMeasurement.getCurrentValue()) @@ -111,4 +111,67 @@ public class Database { } + public double getPreviousDailyTotal(Date inpDateTime){ + String isoInpDateTime = inpDateTime.toString(); + MongoCollection wellTestCollection = database.getCollection("gaugeOffData"); + MongoCursor cursor = wellTestCollection.find(and(eq("tagname", "Fluid Produced"), lte("timestamp", isoInpDateTime))) + .sort(Sorts.descending("timestamp")).limit(1).iterator(); + double lastTotal = -1.0; + try { + while (cursor.hasNext()) { + lastTotal = cursor.next().getDouble("dailyTotal"); + } + } finally { + cursor.close(); + } + return lastTotal; + }; + + public long newWellTest(WellTest inp){ + String df = Date.from(Instant.now()).toString(); + MongoCollection collection = database.getCollection("wellTestData"); + Document doc = new Document("testStartTime", df) + .append("testHours", inp.getTestHours()) + .append("testTotalBBL", inp.getTotalFluidBBL()) + .append("testOilBBL", inp.getTestOilBBL()) + .append("testWaterBBL", inp.getTestWaterBBL()) + .append("testGasMCF", inp.getTestGasMCF()) + .append("kFactor", inp.getkFactor()) + .append("oilRatio", inp.getOilRatio()) + .append("waterRatio", inp.getWaterRatio()) + .append("gasMCFRatio", inp.getGasMCFRatio()); + collection.insertOne(doc); + return collection.count(); + } + + public Document getPreviousWellTest(Date inpDateTime){ + String isoInpDateTime = inpDateTime.toString(); + MongoCollection wellTestCollection = database.getCollection("wellTestData"); + MongoCursor cursor = wellTestCollection.find(lte("testStartTime", isoInpDateTime)) + .sort(Sorts.descending("testStartTime")).limit(1).iterator(); + Document lastTest = new Document("kFactor", (Double) 1.0); + try { + while (cursor.hasNext()) { + lastTest = cursor.next(); + } + } finally { + cursor.close(); + } + return lastTest; + }; + + public double getLatestKFactor(){ + MongoCollection wellTestCollection = database.getCollection("wellTestData"); + MongoCursor cursor = wellTestCollection.find().sort(Sorts.descending("testStartTime")).limit(1).iterator(); + double kFactor = 1.0; + try { + while (cursor.hasNext()) { + kFactor = cursor.next().getDouble("kFactor"); + } + } finally { + cursor.close(); + } + return kFactor; + } + } diff --git a/src/main/java/com/henrypump/poc/POC.java b/src/main/java/com/henrypump/poc/POC.java index 683d578..078c5ea 100644 --- a/src/main/java/com/henrypump/poc/POC.java +++ b/src/main/java/com/henrypump/poc/POC.java @@ -7,6 +7,8 @@ package com.henrypump.poc; */ import java.awt.*; import java.awt.event.*; +import java.time.Instant; +import java.util.Date; public class POC implements Runnable{ protected Well thisWell; @@ -91,8 +93,9 @@ public class POC implements Runnable{ public void run(){ int loopCounter = 0, loopLimit = simLoops, led2out, led3out, led4out,led5out; double pos; + boolean newWellTest = true; long sleepMilliseconds = (long) (thisWell.getDt() * 1000); - thisWell.setupFluidRatio(0.25, 0.75, 1.12); + thisWell.setupFluidRatio(0.50, 0.50, 1.12); thisWell.checkSafeties(); while (true) { while (loopCounter < loopLimit && (thisWell.getRunStatus() == Well.RUNSTATUS_RUNNING || thisWell.getRunStatus() == Well.RUNSTATUS_STARTING)) { @@ -123,6 +126,20 @@ public class POC implements Runnable{ loopCounter++; } + if (newWellTest){ + System.out.println("Previous kFactor = " + thisWell.db.getLatestKFactor()); + Date nowDate = Date.from(Instant.now()); + thisWell.wellTest = new WellTest(nowDate, 24.0, .35, .20, .15, 1.25, thisWell); + thisWell.db.newWellTest(thisWell.wellTest); + System.out.println("Well Test @ " + nowDate.toString()); + System.out.println("kFactor: " + thisWell.wellTest.getkFactor()); + System.out.println("oilRatio: " + thisWell.wellTest.getOilRatio()); + System.out.println("waterRatio: " + thisWell.wellTest.getWaterRatio()); + System.out.println("gasRatio: " + thisWell.wellTest.getGasMCFRatio()); + newWellTest = false; + System.out.println("Last kFactor = " + thisWell.db.getLatestKFactor()); + } + if (startBtn.read() == 1) thisWell.start("startbutton"); if (stopBtn.read() == 1) thisWell.stop("stopbutton"); diff --git a/src/main/java/com/henrypump/poc/Well.java b/src/main/java/com/henrypump/poc/Well.java index 020a9b4..6c77a35 100644 --- a/src/main/java/com/henrypump/poc/Well.java +++ b/src/main/java/com/henrypump/poc/Well.java @@ -18,6 +18,7 @@ import static java.lang.Math.sqrt; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; +import java.time.LocalDate; /** * Created by patrickjmcd on 1/31/17. @@ -26,6 +27,7 @@ public class Well { private String wellName; protected Simulation sim; protected Database db; + protected WellTest wellTest; /* IO */ AnalogIn inclinometer; @@ -138,25 +140,35 @@ public class Well { private double fluidWaterRatio; // BBL of water per 1 BBL fluid private double fluidGasRatio; // MCF of gas per 1 BBL fluid + // DATE & TIME PARAMETERS + private LocalDate lastCheckedDate = null; + + private boolean isNewDay(){ + LocalDate today = LocalDate.now(); + boolean ret = lastCheckedDate == null || today.isAfter(lastCheckedDate); + lastCheckedDate = today; + return ret; + } + // Measurements - private Measurement strokeSpeed = new Measurement("Stroke Speed", true, db, 0.5, 600); - private Measurement downholeGrossStroke = new Measurement("Downhole Gross Stroke", true, db, 0.5, 600); - private Measurement downholeNetStroke = new Measurement("Downhole Net Stroke", true, db, 0.5, 600); - private Measurement fluidLevel = new Measurement("Fluid Level", true, db, 10, 600); - private Measurement fluidLoad = new Measurement("Fluid Load", true, db, 20, 600); - private Measurement inflowRate = new Measurement("Inflow Rate", true, db, 0.5, 600); - private Measurement peakPolishedRodLoad = new Measurement("Peak PRL", true, db, 50, 600); - private Measurement minPolishedRodLoad = new Measurement("Min PRL", true, db, 50, 600); - private Measurement percentRun = new Measurement("Percent Run", true, db, 1.0, 600); - private Measurement polishedRodHP = new Measurement("Polished Rod HP", true, db, 0.25, 600); - private Measurement pumpHP = new Measurement("Pump HP", true, db, 0.25, 600); - private Measurement fluidProduced = new Measurement("Fluid Produced", true, db, 1.0, 600); - private Measurement oilProduced = new Measurement("Oil Produced", true, db, 1.0, 600); - private Measurement waterProduced = new Measurement("Water Produced", true, db, 1.0, 600); - private Measurement gasProduced = new Measurement("Gas Produced", true, db, 1.0, 600); - private Measurement pumpIntakePressure = new Measurement("Pump Intake Pressure", true, db, 5.0, 600); - private Measurement surfaceStrokeLength = new Measurement("Surface Stroke", true, db, 0.5, 1800); - private Measurement tubingMovement = new Measurement("Tubing Movement", true, db, 0.5, 600); + private Measurement strokeSpeed; + private Measurement downholeGrossStroke; + private Measurement downholeNetStroke; + private Measurement fluidLevel; + private Measurement fluidLoad; + private Measurement inflowRate; + private Measurement peakPolishedRodLoad; + private Measurement minPolishedRodLoad; + private Measurement percentRun; + private Measurement polishedRodHP; + private Measurement pumpHP; + private Measurement fluidProduced; + private Measurement oilProduced; + private Measurement waterProduced; + private Measurement gasProduced; + private Measurement pumpIntakePressure; + private Measurement surfaceStrokeLength; + private Measurement tubingMovement; Well(String wellName, int inclinometerChannel, int loadCellChannel, int runCommandChannel){ this.wellName = wellName; @@ -166,6 +178,25 @@ public class Well { inclinometer = new AnalogIn(inclinometerChannel, 0, 100, 0, 100); loadCell = new AnalogIn(loadCellChannel, 0, 50000, 0, 50000); runCommand = new DigitalOut(runCommandChannel, 0); + + strokeSpeed = new Measurement("Stroke Speed", true, db, 0.5, 600); + downholeGrossStroke = new Measurement("Downhole Gross Stroke", true, db, 0.5, 600); + downholeNetStroke = new Measurement("Downhole Net Stroke", true, db, 0.5, 600); + fluidLevel = new Measurement("Fluid Level", true, db, 10, 600); + fluidLoad = new Measurement("Fluid Load", true, db, 20, 600); + inflowRate = new Measurement("Inflow Rate", true, db, 0.5, 600); + peakPolishedRodLoad = new Measurement("Peak PRL", true, db, 50, 600); + minPolishedRodLoad = new Measurement("Min PRL", true, db, 50, 600); + percentRun = new Measurement("Percent Run", true, db, 1.0, 600); + polishedRodHP = new Measurement("Polished Rod HP", true, db, 0.25, 600); + pumpHP = new Measurement("Pump HP", true, db, 0.25, 600); + fluidProduced = new Measurement("Fluid Produced", true, db, 1.0, 600); + oilProduced = new Measurement("Oil Produced", true, db, 1.0, 600); + waterProduced = new Measurement("Water Produced", true, db, 1.0, 600); + gasProduced = new Measurement("Gas Produced", true, db, 1.0, 600); + pumpIntakePressure = new Measurement("Pump Intake Pressure", true, db, 5.0, 600); + surfaceStrokeLength = new Measurement("Surface Stroke", true, db, 0.5, 1800); + tubingMovement = new Measurement("Tubing Movement", true, db, 0.5, 600); } Well(String wellName, String simFileName, int inclinometerChannel, int loadCellChannel, int runCommandChannel){ @@ -177,6 +208,25 @@ public class Well { inclinometer = new AnalogIn(inclinometerChannel, 0, 100, 0, 100); loadCell = new AnalogIn(loadCellChannel, 0, 50000, 0, 50000); runCommand = new DigitalOut(runCommandChannel, 0); + + strokeSpeed = new Measurement("Stroke Speed", true, db, 0.5, 600); + downholeGrossStroke = new Measurement("Downhole Gross Stroke", true, db, 0.5, 600); + downholeNetStroke = new Measurement("Downhole Net Stroke", true, db, 0.5, 600); + fluidLevel = new Measurement("Fluid Level", true, db, 10, 600); + fluidLoad = new Measurement("Fluid Load", true, db, 20, 600); + inflowRate = new Measurement("Inflow Rate", true, db, 0.5, 600); + peakPolishedRodLoad = new Measurement("Peak PRL", true, db, 50, 600); + minPolishedRodLoad = new Measurement("Min PRL", true, db, 50, 600); + percentRun = new Measurement("Percent Run", true, db, 1.0, 600); + polishedRodHP = new Measurement("Polished Rod HP", true, db, 0.25, 600); + pumpHP = new Measurement("Pump HP", true, db, 0.25, 600); + fluidProduced = new Measurement("Fluid Produced", true, db, 1.0, 600); + oilProduced = new Measurement("Oil Produced", true, db, 1.0, 600); + waterProduced = new Measurement("Water Produced", true, db, 1.0, 600); + gasProduced = new Measurement("Gas Produced", true, db, 1.0, 600); + pumpIntakePressure = new Measurement("Pump Intake Pressure", true, db, 5.0, 600); + surfaceStrokeLength = new Measurement("Surface Stroke", true, db, 0.5, 1800); + tubingMovement = new Measurement("Tubing Movement", true, db, 0.5, 600); } public double getDt() { @@ -370,6 +420,18 @@ public class Well { return direction; } + public double getFluidOilRatio() { + return fluidOilRatio; + } + + public double getFluidWaterRatio() { + return fluidWaterRatio; + } + + public double getFluidGasRatio() { + return fluidGasRatio; + } + public void setupFluidRatio(double oilRatio, double waterRatio, double gasRatio){ fluidOilRatio = oilRatio; fluidWaterRatio = waterRatio; @@ -571,6 +633,7 @@ public class Well { taperTable.addRow("Rod Depth", rodDepth[i]); taperTable.addRow("Rod Weight in Air", rodWeightAir[i]); taperTable.addRow("Rod Weight in Fluid", rodWeightFluid[i]); + taperTable.addRule(); rend.setTheme(V2_E_TableThemes.UTF_LIGHT.get()); rend.setWidth(new WidthAbsoluteEven(50)); rt = rend.render(taperTable); @@ -820,6 +883,66 @@ public class Well { return downholeValues; }; + 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("csv", 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()); + + currentCard = new Card(strokesLifetime); + pointCounter = -1; + if (strokesSinceStart > startupStrokes){ + runStatus = RUNSTATUS_RUNNING; + } + if(isNewDay()){ + strokeSpeed.endOfDay(); + downholeGrossStroke.endOfDay(); + downholeNetStroke.endOfDay(); + fluidLevel.endOfDay(); + fluidLoad.endOfDay(); + inflowRate.endOfDay(); + peakPolishedRodLoad.endOfDay(); + minPolishedRodLoad.endOfDay(); + percentRun.endOfDay(); + polishedRodHP.endOfDay(); + pumpHP.endOfDay(); + fluidProduced.endOfDay(); + oilProduced.endOfDay(); + waterProduced.endOfDay(); + gasProduced.endOfDay(); + pumpIntakePressure.endOfDay(); + surfaceStrokeLength.endOfDay(); + tubingMovement.endOfDay(); + } + + } + public void eval(){ checkSafeties(); currentSurfacePosition = inclinometer.readScaled(); @@ -853,6 +976,24 @@ public class Well { 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()); + currentCard = new Card(strokesLifetime); pointCounter = -1; if (strokesSinceStart > startupStrokes) { @@ -862,49 +1003,29 @@ public class Well { lastDirection = direction; pointCounter++; } + if(isNewDay()){ + strokeSpeed.endOfDay(); + downholeGrossStroke.endOfDay(); + downholeNetStroke.endOfDay(); + fluidLevel.endOfDay(); + fluidLoad.endOfDay(); + inflowRate.endOfDay(); + peakPolishedRodLoad.endOfDay(); + minPolishedRodLoad.endOfDay(); + percentRun.endOfDay(); + polishedRodHP.endOfDay(); + pumpHP.endOfDay(); + fluidProduced.endOfDay(); + oilProduced.endOfDay(); + waterProduced.endOfDay(); + gasProduced.endOfDay(); + pumpIntakePressure.endOfDay(); + surfaceStrokeLength.endOfDay(); + tubingMovement.endOfDay(); + } } - 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("csv", 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(); diff --git a/src/main/java/com/henrypump/poc/WellTest.java b/src/main/java/com/henrypump/poc/WellTest.java new file mode 100644 index 0000000..15e7e4f --- /dev/null +++ b/src/main/java/com/henrypump/poc/WellTest.java @@ -0,0 +1,78 @@ +package com.henrypump.poc; + +import org.bson.Document; +import java.util.Date; + +/** + * Created by patrickjmcd on 2/7/17. + */ +public class WellTest { + private double testHours; + private Date testStart; + + private double totalFluidBBL, testOilBBL, testWaterBBL, testGasMCF; + private double kFactor, oilRatio, waterRatio, gasMCFRatio; + + + public WellTest(Date testStart, double testHours, double totalFluidBBL, double testOilBBL, double testWaterBBL, double testGasMCF, Well well) { + this.testStart = testStart; + this.testHours = testHours; + this.totalFluidBBL = totalFluidBBL; + this.testOilBBL = testOilBBL; + this.testWaterBBL = testWaterBBL; + this.testGasMCF = testGasMCF; + + this.oilRatio = this.testOilBBL / this.totalFluidBBL; + this.waterRatio = this.testWaterBBL / this.totalFluidBBL; + this.gasMCFRatio = this.testGasMCF / this.totalFluidBBL; + + this.kFactor = 1.0; + double lastProductionMeasured = well.db.getPreviousDailyTotal(this.testStart); + if(lastProductionMeasured != -1.0){; + this.kFactor = this.totalFluidBBL / lastProductionMeasured; + } else { + System.out.println("No production data in db"); + } + } + + public double getTestHours() { + return testHours; + } + + public Date getTestStart() { + return testStart; + } + + public double getTotalFluidBBL() { + return totalFluidBBL; + } + + public double getTestOilBBL() { + return testOilBBL; + } + + public double getTestWaterBBL() { + return testWaterBBL; + } + + public double getTestGasMCF() { + return testGasMCF; + } + + public double getkFactor() { + return kFactor; + } + + public double getOilRatio() { + return oilRatio; + } + + public double getWaterRatio() { + return waterRatio; + } + + public double getGasMCFRatio() { + return gasMCFRatio; + } + +}