function updateDensity() {
var select = document.getElementById('materialSelect');
var input = document.getElementById('densityInput');
if (select.value !== 'custom') {
input.value = select.value;
} else {
input.value = ";
}
}
function calculateCorrosion() {
// Get Inputs
var wInitial = parseFloat(document.getElementById('initialWeight').value);
var wFinal = parseFloat(document.getElementById('finalWeight').value);
var area = parseFloat(document.getElementById('surfaceArea').value);
var time = parseFloat(document.getElementById('exposureTime').value);
var density = parseFloat(document.getElementById('densityInput').value);
var errorDiv = document.getElementById('errorMessage');
var resultsDiv = document.getElementById('resultsArea');
// Reset display
errorDiv.style.display = 'none';
resultsDiv.style.display = 'none';
// Validation
if (isNaN(wInitial) || isNaN(wFinal) || isNaN(area) || isNaN(time) || isNaN(density)) {
errorDiv.textContent = "Please fill in all fields with valid numbers.";
errorDiv.style.display = 'block';
return;
}
if (area <= 0 || time <= 0 || density wInitial) {
errorDiv.textContent = "Final weight cannot be greater than Initial weight (Mass Gain indicates plating or error, not corrosion loss).";
errorDiv.style.display = 'block';
return;
}
// Calculations
var weightLossGrams = wInitial – wFinal;
var weightLossMg = weightLossGrams * 1000; // Convert g to mg
// Constants based on ASTM G31
// Formula: CR = (K * W) / (A * T * D)
// Where W is mass loss in grams? No, usually K is adjusted.
// Let's use standard constant K = 87.6 for mm/y where W is mg, A is cm², T is hours, D is g/cm³
// Let's use standard constant K = 3.45 x 10^6 for mpy where W is g??
// Correct Constants for W in mg, A in cm², T in hours, D in g/cm³:
// K = 87.6 for mm/y
// K = 3450 for mpy (mils per year)
var rateMmy = (87.6 * weightLossMg) / (area * time * density);
var rateMpy = (3450 * weightLossMg) / (area * time * density);
// Display Results
document.getElementById('resWeightLoss').textContent = weightLossGrams.toFixed(4) + " g";
document.getElementById('resMmy').textContent = rateMmy.toFixed(4) + " mm/y";
document.getElementById('resMpy').textContent = rateMpy.toFixed(2) + " mpy";
resultsDiv.style.display = 'block';
}
How to Calculate Corrosion Rate by Weight Loss
The weight loss method is one of the most widely used and simplest non-electrochemical techniques for determining the corrosion rate of metals. It involves exposing a clean, weighed specimen of metal to a corrosive environment for a specific period, cleaning it to remove corrosion products, and weighing it again to determine the mass lost.
The Corrosion Rate Formula (ASTM G31)
The corrosion rate is calculated using the following equation defined by ASTM G31:
CR = (K × W) / (A × T × D)
Where:
CR = Corrosion Rate
K = A constant defining the units of the corrosion rate
W = Weight loss in milligrams (mg)
A = Surface area in square centimeters (cm²)
T = Time of exposure in hours (h)
D = Density of the material in grams per cubic centimeter (g/cm³)
Understanding the K Constant
The value of K changes depending on the desired unit of output. In our calculator, we use the standard inputs of Area in cm², Time in hours, and Weight in mg:
For mm/y (millimeters per year): K = 87.6
For mpy (mils per year): K = 3,450
Note: 1 mil = 0.001 inches.
Interpreting Corrosion Rates
Is your corrosion rate acceptable? While specific industry standards vary, the following general guide is often used for carbon steel systems:
Corrosion Rate (mpy)
Corrosion Rate (mm/y)
Classification
< 1 mpy
< 0.02 mm/y
Outstanding
1 – 5 mpy
0.02 – 0.13 mm/y
Excellent
5 – 20 mpy
0.13 – 0.50 mm/y
Good
20 – 50 mpy
0.50 – 1.27 mm/y
Fair
> 50 mpy
> 1.27 mm/y
Poor / Unacceptable
Common Material Densities
Accurate density is crucial for calculation. Here are standard densities for common engineering materials:
Carbon Steel: 7.86 g/cm³
Stainless Steel (300 series): ~7.90 – 8.00 g/cm³
Aluminum: 2.70 g/cm³
Copper: 8.96 g/cm³
Titanium: 4.50 g/cm³
Steps to Perform the Test
Preparation: Clean the coupon (sample) and measure its surface area and initial weight ($W_i$).
Exposure: Place the coupon in the environment for a set duration ($T$).
Cleaning: Remove the coupon and chemically or mechanically clean it to remove corrosion byproducts without removing base metal.
Measurement: Weigh the coupon again to find the final weight ($W_f$).
Calculation: Input the values into the calculator above to determine the rate.