{"componentChunkName":"component---src-templates-mdproject-jsx","path":"/projects/bkv_plunger_optimization","result":{"data":{"allGithubFile":{"nodes":[{"base":"bkv_plunger_optimization.md","relativeDirectory":"projects","childMarkdownRemark":{"id":"5aabbeb8-a71c-58d8-a50f-bba6822a9d9c","html":"<h1>Plunger Optimization App - BKV Corporation</h1>\n<p>Data Scientist/Developer: Manuel Solalinde <a href=\"mailto:manolosolalinde@gmail.com\">(manolosolalinde@gmail.com)</a></p>\n<p>Plunger lift cycles a mechanical plunger through the production tubing to lift accumulated liquids and keep marginal and declining gas wells flowing — but at fleet scale, knowing <em>which</em> wells to act on, and <em>why</em>, is the hard part. This production data-analytics platform turns raw 15-second SCADA data into fleet-scale insight that lets reservoir and production engineers act with confidence: it <strong>surfaces optimization opportunities</strong>, <strong>detects mechanical and reservoir problems early</strong>, <strong>validates database records against real operating behaviour</strong>, and <strong>checks compliance with manufacturer specifications</strong> — across the entire well portfolio rather than one well at a time.</p>\n<h2>Applications</h2>\n<ul>\n<li><strong>Plunger Optimization Plots</strong> — interactive well-analysis interface. Search and filter wells by name, route, operator or ID; plot any plunger cycle-statistic over time with automatic aggregation (daily for long ranges, cycle-level for short ones); browse pre-configured metric templates (pressures, differentials, gas rates, durations); and overlay multiple cycles in <strong>stacked-cycle plots</strong> synchronized on valve closure to spot patterns and anomalies. Includes outlier detection, trend/correlation analysis and CSV export.</li>\n<li><strong>Simple Plunger Fall Calculator</strong> — a per-well design tool that pulls the last 30 days of gas/water production, applies the selected plunger brand/type specs, and computes the shut-in fall time (<code class=\"language-text\">BumperSpringDepth / ShutinFallRate</code>) with manual override.</li>\n<li><strong>Reports</strong> — an automated diagnostic report suite (below).</li>\n</ul>\n<h2>Diagnostic Report Suite</h2>\n<ul>\n<li><strong>PCS — Plunger Cycle Statistics:</strong> High Flow Rate Close (HFRC), LF Min, Time-to-Load-Factor 0.40 (TTLF 040) and LF Reliability.</li>\n<li><strong>SI — Sustained Increase (pressure monitoring):</strong> casing–tubing differential, casing pressure, casing–line differential and line-pressure surge.</li>\n<li><strong>Advanced diagnostics:</strong> Casing Sway, Data Quality, ML-based <strong>Continuous vs Conventional</strong> classification (validates DB records against actual operating mode), and Plunger Operating Range Compliance (POCR).</li>\n</ul>\n<p>Reports run daily across the entire well portfolio, with multi-level aggregation (cycle → daily → date range), graceful handling of missing/shut-in data, confidence scoring and moving-average trend detection.</p>\n<h2>Hard problems solved</h2>\n<p>Extracting trustworthy diagnostics from noisy, high-frequency field data required solving several non-trivial signal-processing problems:</p>\n<ul>\n<li><strong>Plunger-arrival detection</strong> from the <strong>maximum of the cumulative tubing-pressure slope</strong> — a robust way to pinpoint the arrival event without relying on fragile per-sample thresholds.</li>\n<li><strong>PTTrips-based cycle identification</strong> using actual plunger trip timestamps for accurate valve open/close and plunger-arrival detection, eliminating pressure-slope estimation error.</li>\n<li><strong>Load Factor</strong>, the key effectiveness metric — <code class=\"language-text\">LF = (Casing Pressure − Tubing Pressure) / (Casing Pressure − Line Pressure)</code> — normalized so well effectiveness is comparable across differing pressure regimes.</li>\n<li><strong>Sustained-increase metrics</strong> computed on 5-minute resampled series with Savitzky-Golay smoothing and moving-average (14/7/5/2-day) comparisons.</li>\n<li><strong>Daily fleet-scale report generation</strong> with multi-level aggregation (cycle → daily → date range) and graceful handling of missing and shut-in data, so a single run yields consistent diagnostics across the entire portfolio.</li>\n</ul>\n<h2>Design decisions &#x26; trade-offs</h2>\n<ul>\n<li><strong>Cycle identification from SCADA ground truth, not estimation.</strong> Used PTTrips actual plunger trip timestamps to define each cycle rather than estimating valve open/close from pressure-slope behaviour — chosen to eliminate estimation error by anchoring on what the controller actually recorded.</li>\n<li><strong>Smoothing for clarity over raw resolution.</strong> Applied Savitzky-Golay smoothing on 5-minute-resampled series instead of analysing raw 15-second data — a deliberate clarity-vs-compute trade-off that suppresses sensor noise and keeps fleet-wide report runs tractable while preserving the trends that matter.</li>\n<li><strong>ML classification instead of fixed thresholds.</strong> Classified <strong>Continuous vs Conventional</strong> operating mode with a trained model rather than hard-coded thresholds — this validates the database's recorded operating mode against observed behaviour and adapts across wells that fixed rules would mislabel.</li>\n</ul>\n<h2>Architecture</h2>\n<p>Python + <strong>Streamlit</strong> web app with <strong>Plotly</strong> visualization, backed by data in <strong>AWS S3</strong> (parquet). The interactive app runs on <strong>ECS Fargate</strong>; daily report generation runs on an <strong>EC2 batch runner</strong> and on-demand <strong>Lambda</strong> functions, scheduled via <strong>CloudWatch Events</strong>. Images are published through <strong>ECR</strong>, infrastructure is managed as code with <strong>Pulumi</strong>, and CI/CD runs on <strong>GitHub Actions</strong>.</p>\n<blockquote>\n<p><em>Note: Screenshots and architecture diagrams are omitted, as they display proprietary client data and systems. Available on request, subject to client approval.</em></p>\n</blockquote>","frontmatter":{"title":"Plunger Optimization App","image_url":"./images/covers/plunger.png","description":"Analytics platform to optimize and diagnose plunger-lift gas wells.","technologies":"Python, Streamlit, Pandas, NumPy, SciPy, Scikit-learn (ML classification), Plotly, Signal Processing (Savitzky-Golay), AWS (S3, ECS Fargate, Lambda, ECR, CloudWatch), Pulumi, Docker, GitHub Actions, Parquet, MkDocs.","date":"2025-01-30T00:00:00.000Z"}},"user":"manolosolalinde","repository":"cv"}]},"site":{"siteMetadata":{"title":"Manuel Solalinde's Portfolio","description":"Manuel Solalinde's Portfolio and Featured Projects","author":"Manuel Solalinde"}}},"pageContext":{"uid":"bkv_plunger_optimization.md","rootQuery":"\n    query mdProjectQuery($uid: String) {\n        allGithubFile(filter: {base: {eq: $uid}, relativeDirectory: {eq: \"projects\"}}) {\n            nodes {\n              base\n              relativeDirectory\n              childMarkdownRemark {\n                id\n                html\n                frontmatter {\n                  title\n                  image_url\n                  description\n                  technologies\n                  date\n                }\n              }\n              user\n              repository\n            }\n        }\n        site {\n            siteMetadata {\n                title\n                description\n                author\n            }\n        }\n    }\n"}},"staticQueryHashes":["3649515864"]}