body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
line-height: 1.6;
color: #333;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #f9f9f9;
}
h1 {
color: #2c3e50;
text-align: center;
margin-bottom: 30px;
}
h2 {
color: #34495e;
border-bottom: 2px solid #ddd;
padding-bottom: 10px;
margin-top: 40px;
}
.calculator-box {
background: #ffffff;
padding: 30px;
border-radius: 8px;
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
margin-bottom: 40px;
border: 1px solid #e0e0e0;
}
.input-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
font-weight: 600;
color: #555;
}
input[type="number"] {
width: 100%;
padding: 12px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
font-size: 16px;
}
.btn-calc {
width: 100%;
padding: 15px;
background-color: #d35400; /* Rust color for corrosion theme */
color: white;
border: none;
border-radius: 4px;
font-size: 18px;
font-weight: bold;
cursor: pointer;
transition: background 0.3s;
}
.btn-calc:hover {
background-color: #a04000;
}
#results {
margin-top: 25px;
padding: 20px;
background-color: #fcece4;
border-radius: 4px;
display: none;
border-left: 5px solid #d35400;
}
.result-row {
display: flex;
justify-content: space-between;
margin-bottom: 10px;
font-size: 16px;
}
.result-value {
font-weight: bold;
color: #c0392b;
}
.result-label {
color: #555;
}
.article-content {
background: #fff;
padding: 30px;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.formula-box {
background: #f1f8ff;
padding: 15px;
border-left: 4px solid #3498db;
font-family: monospace;
margin: 20px 0;
overflow-x: auto;
}
.warning {
font-size: 14px;
color: #7f8c8d;
margin-top: 10px;
font-style: italic;
}
@media (max-width: 600px) {
.calculator-box, .article-content {
padding: 15px;
}
}
function calculateCorrosion() {
// Get Input Values
var P_total = parseFloat(document.getElementById('sysPressure').value);
var CO2_pct = parseFloat(document.getElementById('co2Percent').value);
var T_celsius = parseFloat(document.getElementById('sysTemp').value);
// Validation
if (isNaN(P_total) || isNaN(CO2_pct) || isNaN(T_celsius)) {
alert("Please enter valid numerical values for all fields.");
return;
}
if (P_total < 0 || CO2_pct 100) {
alert("Please ensure pressure is positive and CO2 percentage is between 0 and 100.");
return;
}
// Logic Implementation: de Waard-Milliams Equation
// 1. Calculate Partial Pressure of CO2 (pCO2) in bar
// pCO2 = (Mole % / 100) * Total Pressure
var pCO2 = (CO2_pct / 100) * P_total;
// Handle case where pCO2 is 0 to avoid log error
if (pCO2 <= 0) {
document.getElementById('results').style.display = 'block';
document.getElementById('resPCO2').innerText = "0 bar";
document.getElementById('resMMY').innerText = "0 mm/year";
document.getElementById('resMPY').innerText = "0 mpy";
return;
}
// 2. Temperature in Kelvin
var T_kelvin = T_celsius + 273.15;
// 3. Calculate Log(Vcor)
// Formula: Log(Vcor) = 5.8 – (1710 / T_kelvin) + 0.67 * Log10(pCO2)
var log_Vcor = 5.8 – (1710 / T_kelvin) + (0.67 * Math.log10(pCO2));
// 4. Calculate Vcor (mm/year)
var Vcor_mm = Math.pow(10, log_Vcor);
// 5. Convert to mpy (mils per year)
// 1 mm = 39.3701 mils
var Vcor_mpy = Vcor_mm * 39.3701;
// Display Results
document.getElementById('results').style.display = 'block';
// Format numbers
document.getElementById('resPCO2').innerText = pCO2.toFixed(4) + " bar";
document.getElementById('resMMY').innerText = Vcor_mm.toFixed(4) + " mm/year";
document.getElementById('resMPY').innerText = Vcor_mpy.toFixed(2) + " mpy";
}
Understanding CO2 Corrosion in Pipelines
Carbon Dioxide (CO2) corrosion, often referred to as "sweet corrosion" in the oil and gas industry, is a common failure mechanism in carbon steel pipelines and production equipment. It occurs when dry CO2 gas dissolves in an aqueous phase (water) to form carbonic acid ($H_2CO_3$), which is corrosive to steel.
The rate at which this corrosion occurs depends heavily on environmental factors such as the partial pressure of CO2, temperature, and the presence of protective scaling. Engineers use predictive models to estimate the lifespan of pipelines and determine the need for corrosion inhibitors or corrosion-resistant alloys (CRAs).
The de Waard-Milliams Equation
This calculator utilizes the fundamental de Waard-Milliams nomogram equation, widely regarded as the industry standard for estimating "worst-case" uninhibited corrosion rates in carbon steel. The formula establishes a relationship between temperature and partial pressure.
log(Vcor) = 5.8 – (1710 / TK) + 0.67 × log(pCO2)
Where:
- Vcor: Corrosion rate in mm/year
- TK: Temperature in Kelvin (°C + 273.15)
- pCO2: Partial pressure of CO2 in bar
Key Factors Influencing Corrosion Rates
1. Partial Pressure of CO2 ($pCO_2$)
The partial pressure is a function of the total system pressure and the molar percentage of CO2. Higher partial pressures lead to a higher concentration of carbonic acid in the water phase, accelerating the corrosion reaction. It is calculated as:
pCO2 = (CO2 Mole % / 100) × Total Pressure
2. Temperature
Temperature has a complex effect on CO2 corrosion. Generally, reaction kinetics increase with temperature, leading to higher corrosion rates. However, at very high temperatures (typically > 80°C), the formation of protective iron carbonate ($FeCO_3$) scales can form on the steel surface, potentially reducing the corrosion rate. This basic calculator provides the uninhibited rate and does not account for scale formation.
Interpreting the Results
The output is provided in two standard units:
- mm/year: Millimeters per year, common in metric engineering standards.
- mpy: Mils per year (thousandths of an inch per year), standard in US oilfield operations.
General Industry Guidelines for Carbon Steel:
- < 1-2 mpy: Generally acceptable / Low corrosion.
- 2-10 mpy: Moderate corrosion; monitoring or inhibition may be required.
- > 10 mpy: High corrosion; typically requires continuous inhibition or material upgrades (e.g., to 13Cr stainless steel).
Limitations of this Calculator
This tool provides a baseline estimation for pure CO2 corrosion on bare steel. Real-world rates may vary due to:
- pH: Higher pH (presence of bicarbonates) reduces corrosion.
- Flow Velocity: High turbulence can strip protective films (Erosion-Corrosion).
- H2S: Presence of Hydrogen Sulfide changes the mechanism to "sour corrosion."
- Glycol/Methanol: Presence of hydrates inhibitors affects water wetting.
Always consult with a corrosion engineer for critical infrastructure design.