CorroSim Analysis - Open Source Corrosion Software
CorroSim Analysis
Enterprise Corrosion Simulation Suite
📌 What is CorroSim Analysis?
CorroSim Analysis is a production-ready PyQt6 desktop application for electrochemical corrosion analysis. It provides a complete workflow from raw data import through Tafel analysis, lifetime prediction, sample comparison, and professional data export.
Target Users
- Materials Scientists studying alloy corrosion behavior
- Chemical Engineers designing protective systems
- Quality Control Labs performing routine corrosion testing
- Researchers publishing electrochemical data
- Python Developers building scientific desktop applications
Key Metrics
- 10,000+ rows import in <2 seconds
- Tafel analysis in <1 second
- EIS fitting in <3 seconds
- PDF report generation in <5 seconds
- 1,000+ analyses query in <100ms
Architecture
Modular package following MVC principles with separation of concerns:
corrosim/
├── corrosim/ # Main package
│ ├── main.py # Entry point
│ ├── app.py # Main window controller
│ ├── theme.py # UI styling & theme
│ ├── database.py # SQLite database (CRUD)
│ ├── tafel_engine.py # Tafel analysis engine
│ ├── splash_screen.py # Splash screen
│ ├── tabs/ # Tab modules (MVC)
│ │ ├── import_tab.py # Data import
│ │ ├── tafel_tab.py # Tafel analysis
│ │ ├── prediction_tab.py # Lifetime prediction
│ │ └── comparison_tab.py # Sample comparison
│ └── utils/
│ └── constants.py # Physical constants
├── tests/
│ └── test_tafel.py # Validation tests
├── requirements.txt
├── setup.py
└── run.py
Data Import
Excel (.xlsx/.xls), CSV, TXT with auto-detection of instrument formats (Bio-Logic, Gamry, Autolab, Solartron)
Tafel Analysis
Automatic Ecorr detection, Tafel region scanning with R² > 0.995 validation, corrosion rate calculation
EIS Fitting
Equivalent circuit fitting (Randles, Warburg, Two Time Constants) via Levenberg-Marquardt
Lifetime Prediction
Linear, Power Law, and Arrhenius models with 95% confidence intervals
Multi-Sample Comparison
Overlay plots, sortable comparison tables
PDF Reporting
Professional reports with embedded 300 DPI plots, QR codes, ASTM references
Database
SQLite with SQLAlchemy ORM, SHA-256 checksums for data integrity
Settings
JSON-based configuration with validation
⚡ Electrochemical Corrosion Basics
Corrosion is an electrochemical process involving anodic (oxidation) and cathodic (reduction) half-reactions:
M → Mⁿ⁺ + ne⁻
Cathodic Reactions:
Acidic: 2H⁺ + 2e⁻ → H₂
Neutral: O₂ + 2H₂O + 4e⁻ → 4OH⁻
📐 Tafel Analysis Theory
The Tafel equation describes the relationship between overpotential (η) and current density (i):
Where:
η = overpotential (V) = E - Ecorr
β = Tafel slope (V/decade)
i = current density (A/cm²)
i₀ = exchange current density (A/cm²)
Corrosion Rate (Faraday's Law):
📊 EIS (Electrochemical Impedance Spectroscopy)
Randles Circuit Impedance:
📈 Prediction Models
Power Law: CR(t) = CR₀ · tⁿ
Arrhenius Model: CR(T) = A · exp(-Ea / (R · T))
📋 System Requirements
| Requirement | Minimum | Recommended |
|---|---|---|
| Python | 3.10 | 3.13 |
| RAM | 4 GB | 8 GB |
| Disk | 500 MB | 2 GB |
| Display | 1280×720 | 1920×1080 |
🐍 Dependencies
🚀 Installation Commands
# Clone repository
git clone https://github.com/khadev/CorroSim.git
cd CorroSim
# Create virtual environment (optional)
python -m venv venv
source venv/bin/activate # Linux/Mac
# or: venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Run application
python run.py
#if you installed from PyPI:
pip install corrosim
pip install --upgrade corrosim
corrosim
📦 Standalone Executable (PyInstaller)
pip install pyinstaller
# Generate spec file
pyi-makespec --windowed --onefile --name CorroSim run.py
# Build executable
pyinstaller CorroSim.spec
# Output: dist/CorroSim.exe (Windows)
# dist/CorroSim (Linux/Mac)
🔧 TafelEngine API
class TafelEngine:
def detect_ecorr(potential, current) -> float
def detect_tafel_regions(potential, current, ecorr) -> Tuple
def calculate_parameters(anodic, cathodic, area, density, eq_weight) -> Dict
def run_analysis(potential, current) -> Dict
| Key | Description | Unit |
|---|---|---|
| ecorr | Corrosion potential | V |
| icorr | Corrosion current density | μA/cm² |
| beta_a | Anodic Tafel slope | mV/dec |
| beta_c | Cathodic Tafel slope | mV/dec |
| corrosion_rate | Corrosion rate | mm/year |
⚡ EISEngine API
class EISEngine:
def z_randles(f, Rs, Rct, Qdl, ndl) -> complex
def z_randles_warburg(f, Rs, Rct, Qdl, ndl, W) -> complex
def fit_circuit(freq, z_real, z_imag, circuit_type='R(RQ)') -> Tuple[Dict, np.ndarray]
🗄️ Database Schema (SQLite)
┌──────────────────────────────────────────────────────────────────┐
│ samples │
├──────────────────────────────────────────────────────────────────┤
│ id TEXT PRIMARY KEY - UUID (e.g., "a1b2c3d4") │
│ name TEXT - Sample identifier │
│ test_type TEXT - Potentiodynamic / EIS │
│ date TEXT - Import timestamp │
│ data TEXT - Raw CSV data (stored as CSV) │
│ ecorr REAL - Corrosion potential (V) │
│ icorr REAL - Current density (μA/cm²) │
│ cr REAL - Corrosion rate (mm/yr) │
│ ba REAL - Anodic Tafel slope (mV/dec)│
│ bc REAL - Cathodic Tafel slope │
└──────────────────────────────────────────────────────────────────┘
Storage Notes:
• Raw experimental data stored as CSV text in 'data' column
• Tafel results populated after analysis (initially NULL)
• All results in a single flat table for simplicity
• SQLite database file: corrosion.db
🤝 Contribution Guidelines
- Fork the repository
- Create a feature branch (git checkout -b feature/amazing-feature)
- Commit changes (git commit -m 'Add amazing feature')
- Push to branch (git push origin feature/amazing-feature)
- Open a Pull Request
📝 Code Style
- Follow PEP 8 with 120 character line length
- Use type hints for all function signatures
- Add docstrings to all public methods (Google style)
- Maintain test coverage > 80%
📧 Commit Message Format
Types: feat, fix, docs, style, refactor, test, chore
Example:
feat(tafel): add automatic outlier detection

Post a Comment