Electrochemical Modeling of Magnesium Alloy Dissolution: A Physics-Informed Machine Learning Approach
This project explores the intersection of electrochemical theory and data-driven modeling to predict the dissolution rate of magnesium-based alloys in brine solutions. By combining first-principles physics with statistical learning, the model provides interpretable predictions for material degradation in high-salinity, high-temperature environments.
Magnesium-based dissolvable alloys are used in oil & gas operations for temporary downhole tools such as frac plugs, bridge plugs, and flow control devices. These components must maintain structural integrity during operation, then dissolve completely in brine to eliminate costly retrieval operations. Predicting dissolution rates is critical for designing tools with precise operational lifetimes.
This project develops a predictive model combining physics-based electrochemistry with statistical learning:
- Faraday's Law of electrochemical dissolution
- Butler-Volmer equation for reaction kinetics
- Arrhenius-type temperature dependence
- Empirical salt concentration effects
- Statistical analysis of experimental dissolution data
The model is calibrated using experimental data from dissolution tests conducted at various temperatures (90-135°C) and brine concentrations, making it applicable to real-world downhole conditions.
- Electrochemical modeling based on first principles
- Temperature-dependent dissolution predictions (90°C - 135°C)
- Salt concentration effects (NaCl and NaBr)
- Statistical analysis of dissolution rates with confidence intervals
- Visualization of dissolution kinetics over time
- Material formulation comparison (Alloy-A, B, C, D)
Note: Alloy identifiers are anonymized for confidentiality.
Alloy_dissolution_rate_ML/
├── src/
│ ├── __init__.py # Package initialization
│ ├── rod_calculation.py # Main dissolution rate calculations
│ └── basic_analysis.py # Statistical analysis and visualization
├── docs/
│ └── Data_assisted-Electrochemical_Model.pdf # Theoretical model documentation
├── README.md # This file
├── QUICKSTART.md # Quick start guide
├── ANONYMIZATION_GUIDE.md # Data anonymization documentation
├── requirements.txt # Python dependencies
├── .gitignore # Git ignore rules
└── LICENSE # MIT License
The dissolution rate is modeled using the combined equation:
Rate = (wt_Mg/100) × (M/nF) × A × exp(-Ea/RT) × C^γ × exp(αFη/RT) × 3600
Where:
wt_Mg: Magnesium weight fraction in the alloy (%)M: Molar mass of magnesium (24.3 g/mol)n: Number of electrons transferred (2 for Mg → Mg²⁺)F: Faraday constant (96,485 C/mol)A: Pre-exponential factor (fitting parameter)Ea: Activation energy (J/mol)R: Gas constant (8.314 J/mol·K)T: Temperature (K)C: Salt concentration (weight fraction)γ: Concentration sensitivity exponentα: Charge transfer coefficient (~0.5)η: Overpotential (V)
The model is calibrated using experimental measurements including:
- Weight loss measurements over time
- Dimensional changes (length and outer diameter)
- Temperature range: 90°C to 135°C
- Salt concentrations: Various NaCl and NaBr solutions (0.25 - 12.4 ppg)
- Multiple material batches: LOT #304, #306, #309, #312
Key metrics calculated:
- Dissolution rate: mg/cm²/hr and mm/hr
- 95% confidence intervals for steady-state behavior
- Coefficient of variation for reproducibility
- Outlier detection using modified Z-score method
- Correlation analysis between temperature, concentration, and dissolution
- Strong positive correlation between temperature and dissolution rate
- Dissolution accelerates significantly at higher temperatures (130-135°C)
- Arrhenius-type behavior confirms thermally-activated process
- NaCl concentration: Positive correlation with dissolution rate
- Alloy-C: +0.33 mg/cm²/hr per gram NaCl (R² = 0.784)
- Alloy-D: +0.49 mg/cm²/hr per gram NaCl (R² = 0.942)
- NaBr solutions: Empirical correction factor applied for different halide effects
- Alloy-B: Lowest dissolution rates (~0.9 - 23.5 mg/cm²/hr at 135°C)
- Alloy-C: Moderate to high rates (~43.1 mg/cm²/hr predicted, 20-164 mg/cm²/hr observed)
- Alloy-D: High dissolution rates (~50.3 mg/cm²/hr)
- Alloy-specific calibration required for accurate predictions
- Initial transient period identified in first 1-2 hours
- Steady-state dissolution achieved after initial surface conditioning
- Lower variability in steady-state region (CV < 15%)
- Python 3.7+
- pip package manager
- Clone the repository:
git clone https://github.com/feebsssz/physics-informed-dissolution-mg-alloy.git
cd - (Optional) Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install required packages:
pip install -r requirements.txtRun the main calculation script to process experimental data and compute dissolution rates:
python src/rod_calculation.pyThis script will:
- Load experimental weight loss and dimensional measurements
- Calculate surface areas and time differences
- Compute dissolution rates (mg/cm²/hr)
- Generate accumulated time plots
- Output statistical summaries
Run the comprehensive analysis script to examine correlations and trends:
python src/basic_analysis.pyThis script will:
- Load the complete test dataset
- Generate correlation matrices
- Create scatter plots for key relationships
- Analyze NaCl concentration effects
- Perform regression analysis
- Compare material formulations (Alloy-A, B, C, D)
import pandas as pd
import numpy as np
# Sample data
data = {
"Time (hours)": [0, 2.3, 3.88],
"Weight (g)": [9.05, 6.44, 4.47],
"Length (mm)": [25.02, 24.11, 22.22],
"OD (mm)": [15.94, 14.70, 12.81]
}
df = pd.DataFrame(data)
# Calculate surface area
df["Surface Area (cm²)"] = (
2 * np.pi * (df["OD (mm)"] / 20) * (df["Length (mm)"] / 10) +
2 * np.pi * ((df["OD (mm)"] / 20)**2)
)
# Calculate dissolution rate
for i in range(1, len(df)):
weight_diff = (df["Weight (g)"].iloc[i-1] - df["Weight (g)"].iloc[i]) * 1000
avg_area = (df["Surface Area (cm²)"].iloc[i-1] + df["Surface Area (cm²)"].iloc[i]) / 2
time_diff = df["Time (hours)"].iloc[i] - df["Time (hours)"].iloc[i-1]
rate = weight_diff / (avg_area * time_diff)
print(f"Rate at {df['Time (hours)'].iloc[i]} hrs: {rate:.2f} mg/cm²/hr")For detailed theoretical background, model derivation, and implementation details, see:
This document includes:
- Complete derivation of the electrochemical model
- Butler-Volmer equation application
- Calibration methodology
- Model assumptions and limitations
- References to electrochemical literature
- pandas
- numpy
- matplotlib
- seaborn
- scipy
- statsmodels
- jupyter
- Oil & Gas Downhole Tools: Predicting dissolution of frac plugs, bridge plugs, and flow control devices
- Material Design: Comparing alloy formulations for specific operational lifetimes
- Process Optimization: Designing controlled dissolution timelines for completion operations
- Quality Control: Validating material batch consistency and performance
- Physics-Informed Machine Learning: Combining electrochemical theory with data-driven predictions
- Corrosion Science: Understanding dissolution mechanisms in high-salinity environments
- Material Science: Studying temperature and concentration effects on alloy degradation
- Predictive Modeling: Developing hybrid models that balance physical interpretability with predictive accuracy
- Model assumes surface-reaction controlled dissolution (no mass transport limitations)
- Constant overpotential assumed across all conditions
- Predictions outside calibrated ranges (T: 90-135°C, C: 0-12.4 ppg) should be validated
- Surface film effects not explicitly modeled
- Limited to magnesium-based alloys
- Expand calibration dataset with more temperature points (experimental)
- Include mixed salt systems (NaCl + NaBr)
- Incorporate surface film resistance effects
- Develop time-dependent overpotential model
- Machine learning enhancement for batch prediction
- Real-time monitoring integration
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss proposed changes.
This project is licensed under the MIT License - see the LICENSE file for details.
Yao Zhang
- Electrochemical theory based on Bard & Faulkner (2001) and Newman & Thomas-Alyea (2012)
- Experimental data collected from controlled dissolution tests
- Statistical methods following standard analytical chemistry practices
If you use this work, please cite:
Zhang, Y. (2025). Electrochemical Modeling of Metal Alloy Dissolution in Brine Solutions.
GitHub repository: https://github.com/feebsssz/physics-informed-dissolution-mg-alloy
- A. J. Bard and L. R. Faulkner, Electrochemical Methods: Fundamentals and Applications, Wiley, 2001.
- J. Newman and K. E. Thomas-Alyea, Electrochemical Systems, Wiley-Interscience, 2012.
- D. D. Macdonald, "The Point Defect Model for the Passive State," Journal of The Electrochemical Society, vol. 139, no. 12, pp. 3434–3449, 1992.
Note: This project is for research and educational purposes. Predictions should be validated experimentally before use in critical applications.