Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛢️ Autonomous Production Choke Controller for Single Naturally Flowing Oil Well

Live Demo Python 3.10+ Model Fit R^2 Safety Compliance


🌐 Live Interactive Digital Twin Dashboard

Experience the live closed-loop simulation in your browser:
👉 https://parth-bot-crypto26-autonomous-production-choke-contr-app-mr9poo.streamlit.app/


❓ The Problem We Identified

In oil and gas production, a production choke valve at the wellhead regulates fluid flow from the reservoir.

  1. Manual Operator Limitations: Today, choke adjustments are performed manually based on periodic operator observations. As operators manage dozens of wells, manual setpoint adjustments become inconsistent and non-optimal.
  2. Safety vs. Production Dilemma: Opening the choke increases oil production rate ($Q$), but rapidly accelerates pressure drawdown at the wellhead ($WHP$) and bottomhole ($BHP$).
  3. Operational Risks:
    • Opening too conservative leads to lost oil production revenue.
    • Opening aggressively drops wellhead pressure below minimum safe operating envelopes ($WHP < 215 \text{ psi}$), risking wellbore collapse, gas flaring, or separator flooding.
    • Rapid choke position jumps cause severe mechanical valve wear and thermal shock.

💡 Our Approach

We developed a Closed-Loop Autonomous Model Predictive Control (MPC) system that operates without human intervention every $T_s = 1 \text{ hour}$.

 [ Real-time Telemetry ] ──> [ Dynamic System ID ] ──> [ 10-hr Prediction Horizon ]
 (Q, WHP, FLP, BHP, WHT, AP)        (R² > 0.993)                    │
                                                                    ▼
 [ Autonomous Choke Action ] <── [ Ramp Rate Limit ] <─── [ SLSQP Optimizer ]
      (Forward Injection)            (|Δu| <= 5%/hr)       (Enforce WHP, FLP, BHP)
  1. Empirical Dynamic Model Identification: Fit multi-variable dynamic state-space transfer functions ($u \to Q, WHP, FLP, BHP$) on step-test data, achieving $R^2 &gt; 0.993$ accuracy across all process variables.
  2. Constrained Horizon Predictive Optimization: Implemented a 10-hour prediction horizon using Sequential Least Squares Programming (SLSQP).
  3. Hard Constraint Enforcement:
    • Actuator Ramp Rate Limit: Strictly clamped at $|\Delta u| \le 5.0% / \text{hr}$.
    • Active Pressure Safety Envelopes: $WHP \ge 215.0 \text{ psi}, FLP \ge 150.0 \text{ psi}, BHP \ge 2880.0 \text{ psi}$.
  4. Autonomous Infeasible Target Saturation: If an excessive flow target (e.g. $200 \text{ bbl/hr}$) is requested, the controller automatically rejects unsafe choke positions and clamps operation at the maximum safe flow rate ($\sim 159 \text{ bbl/hr}$).

⚙️ Detailed Working & Mathematical Formulation

1. Dynamic System Identification ($R^2 &gt; 0.993$)

From 120 hours of step-response data (Autonomous_Choke_Control_Simulated_Dataset.csv), dynamic equations were extracted:

$$\begin{aligned} Q_{k+1} &= 0.8315 , Q_k + 0.3083 , u_k + 6.5422 \quad &(R^2 = 0.9977) \\ WHP_{k+1} &= 0.8983 , WHP_k - 0.1637 , u_k + 32.5742 \quad &(R^2 = 0.9968) \\ FLP_{k+1} &= 0.8578 , FLP_k - 0.1398 , u_k + 31.1703 \quad &(R^2 = 0.9936) \\ BHP_{k+1} &= 0.9209 , BHP_k - 0.5928 , u_k + 268.0687 - 1.8240 \left(\frac{k}{100}\right) \quad &(R^2 = 0.9956) \end{aligned}$$

2. Constrained MPC Cost Function

$$\min_{{u_k, \dots, u_{k+N-1}}} \sum_{i=0}^{N-1} \left[ 10.0 \left(\hat{Q}{k+i} - Q{\text{target}}\right)^2 + 2.0 \left(u_{k+i} - u_{k+i-1}\right)^2 \right]$$ Subject to:

  • $0% \le u_i \le 100%$
  • $|u_i - u_{i-1}| \le 5.0%$
  • $\hat{WHP}{k+i} \ge 215.0 \text{ psi}, \quad \hat{FLP}{k+i} \ge 150.0 \text{ psi}, \quad \hat{BHP}_{k+i} \ge 2880.0 \text{ psi}$

🖼️ Key Results & Benchmark Visualizations

1. Step-Test Dynamic Model Fitting ($R^2 &gt; 0.993$)

Step Response System ID

2. Benchmark Comparison: Classical PID vs Rule-Based vs Autonomous MPC

Proves why classical PID causes choke hunting and WHP safety breaches, whereas MPC achieves 100% constraint compliance. Benchmark Comparison

3. Scenario A: Autonomous Startup to Target ($110 \text{ bbl/hr}$)

Scenario A Startup

4. Scenario C: Infeasible Target Demand Clamping ($200 \text{ bbl/hr}$ Requested)

Demonstrates automatic rejection of unsafe choke moves and safe clamping at maximum feasible flow rate. Scenario C Infeasible Clamping


📊 Verification & Results Summary

Metric Target / Benchmark Solution Achieved Safety Compliance
Model Fit Accuracy ($R^2$) $&gt; 0.95$ $&gt; 0.993$ (All variables) ✅ PASSED (100%)
Choke Ramp Rate Constraint $\le 5.0% / \text{hr}$ Max $5.00% / \text{hr}$ ✅ PASSED (100%)
WHP Safety Breach Rate $0%$ $0.00%$ ✅ PASSED (100%)
FLP Safety Breach Rate $0%$ $0.00%$ ✅ PASSED (100%)
Scenario C Safe Clamping Safe Saturation Settles at $159 \text{ bbl/hr}$ ($WHP = 215 \text{ psi}$) ✅ PASSED (100%)
Execution Latency $&lt; 1.0 \text{ sec}$ $42 \text{ ms}$ per control step ✅ PASSED (100%)

📁 Repository Structure

├── dataset.py                        # Reconstructed dataset loader
├── system_id.py                      # Dynamic System Identification (R^2 > 0.993)
├── mpc_controller.py                 # Constrained SLSQP MPC Controller
├── benchmark_controllers.py          # Comparative PID vs Rule-Based vs MPC engine
├── run_all_scenarios.py              # Executes Scenarios A, B, and C
├── demo_live_run.py                  # Terminal CLI live demonstration script
├── app.py                            # Streamlit Industrial Digital Twin Web UI
├── Autonomous_Choke_Control.ipynb    # Complete Executable Jupyter Notebook
├── Engineering_Report.md             # Detailed Technical Engineering Report
└── SIH_Idea_Presentation_Deck.md     # Official 6-Slide Presentation Deck Content

🚀 Local Installation & Quick Start

1. Clone Repository

git clone https://github.com/Parth-bot-crypto26/Autonomous-Production-Choke-Controller.git
cd Autonomous-Production-Choke-Controller

2. Install Dependencies

pip install -r requirements.txt

3. Run System Identification Verification

python system_id.py

4. Execute All Demonstration Scenarios

python run_all_scenarios.py

5. Launch Local Web Dashboard

streamlit run app.py

Open http://localhost:8501 in your browser.

About

Closed-Loop Autonomous Model Predictive Control (MPC) & Digital Twin for Oil Well Choke Valves. Uses SLSQP optimization & dynamic system ID (R² > 0.993) to maximize oil production while enforcing safety pressure envelopes (WHP, FLP, BHP) & ramp limits.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages