Calculate Zero Air Void Unit Weights for Soil with

Zero Air Void Unit Weight Calculator for Soil body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f8f9fa; color: #333; line-height: 1.6; margin: 0; padding: 0; } .container { max-width: 960px; margin: 20px auto; padding: 20px; background-color: #fff; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); } h1, h2, h3 { color: #004a99; text-align: center; margin-bottom: 20px; } h1 { font-size: 2.2em; } h2 { font-size: 1.8em; margin-top: 30px; border-bottom: 2px solid #004a99; padding-bottom: 5px; } .input-group { margin-bottom: 15px; padding: 10px; border: 1px solid #e0e0e0; border-radius: 5px; background-color: #fdfdfd; } .input-group label { display: block; margin-bottom: 8px; font-weight: bold; color: #004a99; } .input-group input[type="number"], .input-group select { width: calc(100% – 20px); padding: 10px; margin-bottom: 5px; border: 1px solid #ccc; border-radius: 4px; font-size: 1em; box-sizing: border-box; } .input-group .helper-text { font-size: 0.85em; color: #6c757d; display: block; margin-top: 5px; } .input-group .error-message { color: #dc3545; font-size: 0.8em; margin-top: 5px; display: block; min-height: 1em; } .button-group { text-align: center; margin-top: 25px; margin-bottom: 30px; } button { background-color: #004a99; color: white; border: none; padding: 12px 25px; border-radius: 5px; cursor: pointer; font-size: 1.1em; margin: 0 10px; transition: background-color 0.3s ease; } button:hover { background-color: #003366; } #result { background-color: #28a745; color: white; padding: 15px; border-radius: 5px; text-align: center; font-size: 1.5em; font-weight: bold; margin-top: 20px; margin-bottom: 20px; box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2); } .intermediate-results div { background-color: #e9ecef; padding: 10px; margin-bottom: 10px; border-radius: 5px; display: flex; justify-content: space-between; font-size: 0.95em; } .intermediate-results span:first-child { font-weight: bold; color: #495057; } .intermediate-results span:last-child { color: #004a99; font-weight: bold; } .formula-explanation { font-size: 0.9em; color: #555; margin-top: 15px; padding: 10px; background-color: #f1f1f1; border-left: 4px solid #004a99; border-radius: 3px; } table { width: 100%; border-collapse: collapse; margin-top: 20px; margin-bottom: 30px; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1); } th, td { padding: 10px; text-align: left; border-bottom: 1px solid #ddd; } thead { background-color: #004a99; color: white; } th { font-weight: bold; } caption { caption-side: bottom; font-size: 0.85em; color: #6c757d; margin-top: 10px; text-align: center; } canvas { display: block; margin: 20px auto; background-color: #fff; border-radius: 5px; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1); } .article-section { margin-top: 40px; padding: 20px; background-color: #fff; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); } .article-section h2 { text-align: left; margin-bottom: 15px; border-bottom: none; } .article-section h3 { text-align: left; font-size: 1.4em; margin-top: 25px; margin-bottom: 10px; color: #0056b3; } .article-section p, .article-section ul, .article-section ol { margin-bottom: 15px; font-size: 1em; } .article-section ul { list-style-type: disc; margin-left: 20px; } .article-section ol { list-style-type: decimal; margin-left: 20px; } .article-section li { margin-bottom: 8px; } .faq-item { margin-bottom: 15px; border-left: 3px solid #004a99; padding-left: 10px; } .faq-item h3 { margin-bottom: 5px; color: #004a99; font-size: 1.1em; text-align: left; } .faq-item p { margin-top: 5px; font-size: 0.95em; color: #555; } .internal-links-section ul { list-style: none; padding: 0; } .internal-links-section li { margin-bottom: 10px; border-bottom: 1px dashed #ccc; padding-bottom: 5px; } .internal-links-section a { color: #004a99; text-decoration: none; font-weight: bold; } .internal-links-section a:hover { text-decoration: underline; } .internal-links-section span { font-size: 0.9em; color: #666; display: block; margin-top: 3px; } .highlighted-result { background-color: #007bff; color: white; padding: 15px; border-radius: 5px; text-align: center; font-size: 1.6em; font-weight: bold; margin-top: 20px; margin-bottom: 20px; box-shadow: 0 0 15px rgba(0, 123, 255, 0.5); } .info-box { background-color: #fff3cd; color: #856404; border: 1px solid #ffeeba; padding: 10px; border-radius: 4px; margin-bottom: 15px; font-size: 0.9em; } .formula-vars table { margin-top: 10px; } .formula-vars th, .formula-vars td { padding: 8px; } .formula-vars caption { caption-side: top; margin-bottom: 10px; font-weight: bold; color: #333; font-size: 1em; }

Calculate Zero Air Void Unit Weight for Soil

Easily compute the theoretical maximum density of soil when no air is present, a critical parameter in geotechnical engineering.

Zero Air Void Unit Weight Calculator

Typically ranges from 2.60 to 2.85 for most soils.
Enter as a percentage (e.g., 15 for 15%).

Intermediate Calculations

Specific Density of Water (ρw)
Void Ratio (e)
Density of Water (ρw)
Formula Used: The zero air void unit weight (γd_max) is calculated using the formula:

γd_max = (Gs * γw) / (1 + (e * Gs) / Gs)

Where:
  • γd_max is the unit weight of soil at zero air voids (maximum dry unit weight).
  • Gs is the specific gravity of soil solids.
  • γw is the unit weight of water.
  • e is the void ratio.
*Note: Simplified to γd_max = (Gs * γw) / (1 + e) which is equivalent and more commonly used. The void ratio (e) is derived from water content (w) and Gs using e = (w * Gs) / 100.*

Zero Air Void Unit Weight vs. Water Content

Chart showing how zero air void unit weight changes with varying water content for a fixed specific gravity.

What is Zero Air Void Unit Weight?

The term "zero air void unit weight" is a fundamental concept in soil mechanics and geotechnical engineering. It represents the maximum possible dry unit weight that a soil can achieve when there is absolutely no air present in the pore spaces. This condition is also known as the saturation line or 100% saturation. Essentially, it's the theoretical density of a soil where the entire volume of the soil's pores is filled with water, and no air pockets exist.

Who Should Use It: This calculation is crucial for geotechnical engineers, civil engineers, construction professionals, and materials scientists. It's used when determining the potential maximum density of a soil for applications such as:

  • Compaction control of soil fills (e.g., in road construction, dams, and foundations).
  • Assessing the compaction characteristics of soils in laboratory tests like the Standard or Modified Proctor tests.
  • Predicting the behavior of saturated soils under load.
  • Designing earth retaining structures and foundations.

Common Misconceptions: A frequent misconception is that the zero air void unit weight is the same as the maximum dry unit weight achieved in a standard compaction test (like the Proctor test). While the Proctor test aims to achieve high density, it typically doesn't reach 100% saturation, meaning some air is still present. The zero air void unit weight is a theoretical upper limit, often higher than what can be practically achieved through field compaction. Another misconception is that it only applies to granular soils; it's a principle applicable to all soil types, though the specific gravity will vary.

Zero Air Void Unit Weight Formula and Mathematical Explanation

The calculation of the zero air void unit weight (often denoted as γd_max or ρd_max) is derived from the basic principles of soil density and saturation. At zero air voids, the soil is considered 100% saturated.

The fundamental relationship for dry unit weight (γd) is: γd = Ws / V Where:

  • Ws = Weight of soil solids
  • V = Total volume of the soil sample

We also know that the specific gravity of soil solids (Gs) is defined as: Gs = (Ws / Vs) / ρw Where:

  • Vs = Volume of soil solids
  • ρw = Density of water (approximately 1000 kg/m³ or 62.4 lb/ft³)
From this, we can express the weight of solids as: Ws = Gs * Vs * ρw.

The total volume (V) of a soil sample can be expressed as the sum of the volume of solids (Vs) and the volume of voids (Vv): V = Vs + Vv

The void ratio (e) is defined as the ratio of the volume of voids to the volume of solids: e = Vv / Vs Therefore, Vv = e * Vs. Substituting this back into the total volume equation: V = Vs + (e * Vs) = Vs * (1 + e)

Now, substitute the expressions for Ws and V back into the dry unit weight formula: γd = (Gs * Vs * ρw) / (Vs * (1 + e)) Simplifying, we get the formula for unit weight at any void ratio: γd = (Gs * ρw) / (1 + e)

For the *zero air void* condition, we are interested in the maximum dry unit weight, which corresponds to a specific void ratio at 100% saturation. At 100% saturation: The degree of saturation (S) = 1 (or 100%). We know the relationship: S * e = w * Gs (where w is the water content expressed as a decimal). At S=1, the void ratio (e) for zero air voids is given by: e = (w * Gs) (if w is a decimal) or e = (w_percent * Gs) / 100 (if w is a percentage).

Substituting this specific void ratio back into the general unit weight formula gives the zero air void unit weight (γd_max or ρd_max): γd_max = (Gs * ρw) / (1 + e) where e = (w_percent * Gs) / 100

Variables in the Zero Air Void Unit Weight Calculation
Variable Meaning Unit Typical Range
γd_max Zero Air Void Unit Weight (Maximum Dry Unit Weight) kN/m³ or lb/ft³ Depends on Gs and ρw; typically 18-23 kN/m³ or 115-145 lb/ft³
Gs Specific Gravity of Soil Solids Dimensionless 2.60 – 2.85 (common range)
ρw Density of Water kg/m³ or lb/ft³ 1000 kg/m³ (freshwater) or 62.4 lb/ft³ (freshwater)
γw Unit Weight of Water kN/m³ or lb/ft³ 9.81 kN/m³ or 62.4 lb/ft³
w Water Content % or decimal 0% – 50%+ (depending on soil)
e Void Ratio Dimensionless 0.1 – 2.0+ (depending on soil and compaction)

Practical Examples (Real-World Use Cases)

Understanding the zero air void unit weight is vital for many geotechnical applications. Here are two practical examples:

Example 1: Compaction Control for a Highway Embankment

Scenario: A civil engineering project requires the construction of a highway embankment using a sandy soil. The design specifications mandate that the soil in the compacted fill must achieve a density close to its theoretical maximum (zero air void condition) to ensure stability and prevent excessive settlement. The soil's specific gravity (Gs) is determined to be 2.68. The target water content for optimal compaction is specified based on laboratory tests to be 12% (as a percentage).

Calculation:

  • Specific Gravity (Gs) = 2.68
  • Water Content (w) = 12%
  • Density of Water (ρw) = 1000 kg/m³
First, calculate the void ratio (e) at zero air voids: e = (w * Gs) / 100 = (12 * 2.68) / 100 = 32.16 / 100 = 0.3216 Next, calculate the zero air void unit weight (γd_max): γd_max = (Gs * ρw) / (1 + e) = (2.68 * 1000 kg/m³) / (1 + 0.3216) γd_max = 2680 / 1.3216 ≈ 2028 kg/m³ In terms of kN/m³ (using γw = 9.81 kN/m³): e = 0.3216 γd_max = (Gs * γw) / (1 + e) = (2.68 * 9.81 kN/m³) / (1 + 0.3216) γd_max = 26.29 / 1.3216 ≈ 19.90 kN/m³

Interpretation: The theoretical maximum dry unit weight achievable for this soil at 12% water content is approximately 2028 kg/m³ or 19.90 kN/m³. Field compaction efforts will aim to reach this density by controlling the water content and applying sufficient compactive effort. If field densities fall significantly short, engineers will investigate issues like insufficient compaction or incorrect water content. This value serves as a benchmark for quality control, ensuring the structural integrity of the embankment.

Example 2: Laboratory Compaction Test Analysis

Scenario: A geotechnical lab is performing a Standard Proctor compaction test on a clayey silt. They measure the soil solids' specific gravity (Gs) to be 2.72. After compaction, they determine the maximum dry unit weight achieved in the test (which includes some air voids) and the corresponding optimum water content. However, they also want to calculate the theoretical zero air void unit weight to compare performance. Let's assume the optimum water content found in the test (which is close to the point of zero air voids for this soil) is 18%.

Calculation:

  • Specific Gravity (Gs) = 2.72
  • Water Content (w) = 18%
  • Unit Weight of Water (γw) = 9.81 kN/m³
Calculate the void ratio (e) at zero air voids: e = (w * Gs) / 100 = (18 * 2.72) / 100 = 48.96 / 100 = 0.4896 Calculate the zero air void unit weight (γd_max): γd_max = (Gs * γw) / (1 + e) = (2.72 * 9.81 kN/m³) / (1 + 0.4896) γd_max = 26.6832 / 1.4896 ≈ 17.91 kN/m³

Interpretation: The calculated zero air void unit weight is approximately 17.91 kN/m³. If the maximum dry unit weight achieved in the Standard Proctor test was, for instance, 16.5 kN/m³, this indicates that the soil sample at optimum moisture content still contained some air voids (i.e., it was not 100% saturated). The difference between 17.91 kN/m³ and 16.5 kN/m³ represents the potential for further densification if all air could be expelled. This comparison helps in understanding the limitations of field compaction and the theoretical maximum density achievable. This tool helps users understand the theoretical maximum density for different soil properties.

How to Use This Zero Air Void Unit Weight Calculator

Our calculator is designed for simplicity and accuracy. Follow these steps to determine the zero air void unit weight for your soil sample:

  1. Input Soil Specific Gravity (Gs): Enter the specific gravity of the soil solids. This value represents the ratio of the density of soil solids to the density of water. Typical values range from 2.60 to 2.85 for most mineral soils. If you don't have this value, a common assumption for many soils is 2.65.
  2. Input Water Content (w): Enter the water content of the soil as a percentage. This is the ratio of the weight of water to the weight of dry soil solids, expressed as a percentage. For example, enter '15' for 15% water content.
  3. Click 'Calculate': Once you have entered the required values, click the 'Calculate' button.

How to Read Results:

The calculator will display:

  • Primary Result: The main output, highlighted in green, is the Zero Air Void Unit Weight (γd_max) for your soil under the given conditions. This represents the theoretical maximum dry density achievable. The units will depend on the density of water used in the internal calculation (typically kN/m³ or kg/m³).
  • Intermediate Calculations: You will see the calculated Specific Density of Water (ρw), the Void Ratio (e) at zero air voids, and the Density of Water (ρw) used in the calculation. These values provide insight into the intermediate steps of the formula.
  • Formula Explanation: A brief explanation of the mathematical formula used is provided for clarity.

Decision-Making Guidance:

Compare the calculated zero air void unit weight to the actual dry unit weight achieved in the field or in laboratory compaction tests.

  • If the actual dry unit weight is significantly lower than the calculated zero air void unit weight, it indicates that the soil is not fully compacted or has entrapped air.
  • This value serves as a critical benchmark for quality control in construction projects involving soil compaction.
  • It helps engineers set targets for compaction efforts and verify that the soil meets the required engineering properties for stability and performance.
Use the 'Copy Results' button to easily transfer the calculated values for reporting or further analysis. The 'Reset' button will restore default input values for a fresh calculation.

Key Factors That Affect Zero Air Void Results

While the calculation of zero air void unit weight itself is straightforward based on inputs, several underlying soil properties and external factors influence these inputs and the practical interpretation of the results:

  • Soil Particle Characteristics (Specific Gravity – Gs): The specific gravity of soil solids is a direct input. Soils with higher specific gravity (e.g., those containing heavier minerals) will inherently have a higher theoretical maximum unit weight at zero air voids, assuming the same void ratio. Different soil types (clays, sands, gravels) have different mineral compositions, leading to variations in Gs.
  • Grain Size Distribution and Shape: While not directly in the simplified formula, the particle size distribution and shape significantly influence the achievable void ratio (e) and thus the maximum dry unit weight. Well-graded granular soils can pack more densely (lower void ratio) than poorly graded or uniformly graded soils, allowing for a higher maximum dry unit weight in practice.
  • Water Content (w): This is a critical input. The zero air void unit weight is calculated for a *specific* water content that corresponds to 100% saturation for a given Gs. If the actual water content differs, the degree of saturation will not be 100%, and the actual dry unit weight will be different. Optimal water content for compaction is often near, but not necessarily identical to, the water content for zero air voids.
  • Compactive Effort: Laboratory tests (like Proctor) simulate compactive effort. Higher compactive effort generally leads to a denser state (lower void ratio) and thus a higher maximum dry unit weight. The zero air void calculation provides the *theoretical limit*, which may be higher than what is achievable with standard field compaction methods.
  • Soil Structure and Fabric: The arrangement of soil particles (e.g., flocculated vs. dispersed structures in clays) affects the void ratio and overall density. While Gs and w are measured properties, the soil's inherent structure plays a role in how easily it can be compacted to a low void ratio.
  • Presence of Organic Matter: Organic soils typically have lower specific gravities (Gs) than mineral soils due to the lower density of organic compounds. This would result in a lower theoretical zero air void unit weight. High organic content also affects compressibility and strength.
  • Pore Water Pressure: While not a direct input for the γd_max formula, pore water pressure is crucial in the *behavior* of saturated soils. High pore water pressure can reduce the effective stress, affecting shear strength and settlement, even if the dry unit weight is high. The zero air void condition implies full saturation, where pore water pressure dynamics become very important under loading.

Frequently Asked Questions (FAQ)

Q1: What is the difference between zero air void unit weight and maximum dry unit weight from a Proctor test?

The maximum dry unit weight from a Proctor test represents the highest dry density achievable under specific laboratory compaction conditions (Standard or Modified). It typically still contains some air voids. The zero air void unit weight is a theoretical maximum density where no air is present in the voids; it's usually higher than the Proctor maximum dry unit weight.

Q2: Can the zero air void unit weight be achieved in the field?

It is extremely difficult, and often impractical, to achieve true zero air voids in field compaction. Field conditions, equipment limitations, and variations in soil moisture make it challenging to reach this theoretical maximum. However, engineers aim to compact soil fills to a high percentage of the zero air void unit weight for optimal performance.

Q3: What are typical values for soil specific gravity (Gs)?

For most common mineral soils (sands, silts, clays), the specific gravity of solids (Gs) typically ranges from 2.60 to 2.85. Quartz (a common mineral) has a Gs of about 2.65. Heavier minerals can increase this value. Organic soils generally have lower Gs values.

Q4: Does the unit weight of water (γw or ρw) change significantly?

The unit weight of water is relatively constant but does vary slightly with temperature and dissolved solids. For most geotechnical calculations, standard values are used: approximately 9.81 kN/m³ (or 1000 kg/m³, or 62.4 lb/ft³) for freshwater at typical ambient temperatures.

Q5: How does water content affect the zero air void unit weight calculation?

The formula *uses* a specific water content that corresponds to 100% saturation for a given Gs to calculate the zero air void condition. It doesn't mean the soil *must* have that water content to exist, but rather that this water content defines the void ratio at which zero air voids occur. A higher water content, while still allowing for zero air voids, would imply a potentially higher void ratio (less dense state) unless Gs also changes significantly.

Q6: Is this calculator useful for all soil types?

Yes, the principle applies to all soil types (cohesive and cohesionless). However, the specific input values (especially Gs and the achievable void ratio 'e') will vary significantly depending on whether the soil is clay, silt, sand, or gravel. The calculator provides the theoretical maximum based on the inputs provided.

Q7: What if my soil has a very low specific gravity (e.g., peat)?

Organic soils like peat have significantly lower specific gravities (Gs) than mineral soils, often below 2.0. Using a low Gs value in the calculator will result in a proportionally lower zero air void unit weight, reflecting the lighter nature of the soil solids.

Q8: How do I convert between kN/m³ and lb/ft³?

Use the conversion factor: 1 kN/m³ ≈ 6.366 lb/ft³. Or, if using densities, 1 kg/m³ ≈ 0.0624 lb/ft³. Ensure consistency in units when performing engineering calculations. Our calculator typically defaults to metric units internally but the concept is universal.

Related Tools and Internal Resources

© 2023 Your Company Name. All rights reserved.

// Constants for water properties var DENSITY_WATER_KG_M3 = 1000; // kg/m³ var UNIT_WEIGHT_WATER_KN_M3 = 9.81; // kN/m³ (approx. gravity * density) function validateInput(id, min, max, errorId, unitLabel) { var input = document.getElementById(id); var errorElement = document.getElementById(errorId); var value = parseFloat(input.value); var isValid = true; errorElement.textContent = "; // Clear previous error if (isNaN(value)) { errorElement.textContent = 'Please enter a valid number.'; isValid = false; } else if (value max) { errorElement.textContent = 'Value cannot exceed ' + max + '.'; isValid = false; } return isValid ? value : null; } function calculateZeroAirVoid() { var Gs = validateInput('specificGravity', 0, 5, 'specificGravityError', 'Specific Gravity'); var w_percent = validateInput('waterContent', 0, 100, 'waterContentError', 'Water Content (%)'); if (Gs === null || w_percent === null) { document.getElementById('result').innerHTML = 'Please correct the errors.'; return; } var w_decimal = w_percent / 100; // Intermediate Calculations var e = (w_decimal * Gs); // Void ratio at zero air voids var density_water = DENSITY_WATER_KG_M3; // Using kg/m³ for density consistency var unit_weight_water = UNIT_WEIGHT_WATER_KN_M3; // Using kN/m³ for unit weight // Calculate Zero Air Void Unit Weight (using unit weight of water) var gamma_d_max = (Gs * unit_weight_water) / (1 + e); // Display intermediate results document.getElementById('specificDensityValue').textContent = Gs.toFixed(3); // Showing Gs again for clarity in intermediate results document.getElementById('voidRatioValue').textContent = e.toFixed(3); document.getElementById('densityWaterValue').textContent = density_water.toFixed(1) + ' kg/m³'; // Display primary result document.getElementById('zeroAirVoidWeight').textContent = gamma_d_max.toFixed(2) + ' kN/m³'; document.getElementById('result').style.backgroundColor = '#28a745'; // Success color updateChart(Gs); } function resetCalculator() { document.getElementById('specificGravity').value = '2.65'; document.getElementById('waterContent').value = '15'; document.getElementById('specificGravityError').textContent = "; document.getElementById('waterContentError').textContent = "; document.getElementById('zeroAirVoidWeight').textContent = "; document.getElementById('specificDensityValue').textContent = "; document.getElementById('voidRatioValue').textContent = "; document.getElementById('densityWaterValue').textContent = "; document.getElementById('result').style.backgroundColor = '#28a745'; // Reset to default // Clear canvas and reset chart data if needed var ctx = document.getElementById('za-chart').getContext('2d'); ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); } function copyResults() { var mainResult = document.getElementById('zeroAirVoidWeight').textContent; var gsVal = document.getElementById('specificDensityValue').textContent; var eVal = document.getElementById('voidRatioValue').textContent; var waterDensityVal = document.getElementById('densityWaterValue').textContent; var formula = "γd_max = (Gs * γw) / (1 + e)"; var assumptions = "Gs = " + gsVal + ", w = " + document.getElementById('waterContent').value + "%, γw = " + UNIT_WEIGHT_WATER_KN_M3 + " kN/m³"; var textToCopy = "Zero Air Void Unit Weight Calculation Results:\n\n"; textToCopy += "Primary Result:\n" + mainResult + "\n\n"; textToCopy += "Intermediate Calculations:\n"; textToCopy += " Specific Gravity (Gs): " + gsVal + "\n"; textToCopy += " Void Ratio (e): " + eVal + "\n"; textToCopy += " Density of Water (ρw): " + waterDensityVal + "\n\n"; textToCopy += "Formula Used: " + formula + "\n"; textToCopy += "Assumptions/Inputs: " + assumptions + "\n"; // Use a temporary textarea to copy text var textArea = document.createElement("textarea"); textArea.value = textToCopy; textArea.style.position = "fixed"; // Avoid scrolling to bottom of page textArea.style.opacity = 0; document.body.appendChild(textArea); textArea.focus(); textArea.select(); try { var successful = document.execCommand('copy'); var msg = successful ? 'Results copied to clipboard!' : 'Copying text command was unsuccessful'; console.log(msg); // Optionally show a temporary message to the user var tempMessage = document.createElement('div'); tempMessage.textContent = msg; tempMessage.style.position = 'fixed'; tempMessage.style.bottom = '10px'; tempMessage.style.left = '50%'; tempMessage.style.transform = 'translateX(-50%)'; tempMessage.style.backgroundColor = '#004a99'; tempMessage.style.color = 'white'; tempMessage.style.padding = '5px 10px'; tempMessage.style.borderRadius = '3px'; document.body.appendChild(tempMessage); setTimeout(function(){ document.body.removeChild(tempMessage); }, 2000); } catch (err) { console.error('Fallback: Oops, unable to copy', err); // Optionally show an error message } document.body.removeChild(textArea); } function updateChart(fixedGs) { var canvas = document.getElementById('za-chart'); var ctx = canvas.getContext('2d'); canvas.width = canvas.parentElement.clientWidth * 0.9; // Responsive width canvas.height = 300; // Fixed height var waterContents = []; var zeroAirVoidWeights = []; var maxW = 30; // Max water content to plot var step = maxW / 20; // Number of points for (var w_percent = 0; w_percent <= maxW; w_percent += step) { waterContents.push(w_percent); var w_decimal = w_percent / 100; var e = (w_decimal * fixedGs); var gamma_d_max = (fixedGs * UNIT_WEIGHT_WATER_KN_M3) / (1 + e); zeroAirVoidWeights.push(gamma_d_max); } // Clear previous chart ctx.clearRect(0, 0, canvas.width, canvas.height); // Charting logic (Simplified pure canvas) var chartAreaWidth = canvas.width * 0.85; var chartAreaHeight = canvas.height * 0.75; var padding = { top: 30, right: 20, bottom: 40, left: 50 }; var dataPoints = zeroAirVoidWeights.length; var xStep = chartAreaWidth / (dataPoints – 1); // Find max value for Y-axis scaling var maxY = Math.max(…zeroAirVoidWeights); var yAxisMax = Math.ceil(maxY * 1.1 / 10) * 10; // Round up to nearest 10 // Draw Axes ctx.strokeStyle = '#6c757d'; ctx.lineWidth = 1; // Y-axis ctx.beginPath(); ctx.moveTo(padding.left, padding.top); ctx.lineTo(padding.left, padding.top + chartAreaHeight); ctx.stroke(); // X-axis ctx.beginPath(); ctx.moveTo(padding.left, padding.top + chartAreaHeight); ctx.lineTo(padding.left + chartAreaWidth, padding.top + chartAreaHeight); ctx.stroke(); // Y-axis Labels and Ticks ctx.fillStyle = '#333'; ctx.textAlign = 'right'; ctx.textBaseline = 'middle'; var yTickCount = 5; for (var i = 0; i <= yTickCount; i++) { var yValue = yAxisMax – (i * (yAxisMax / yTickCount)); var yPos = padding.top + chartAreaHeight – (i * chartAreaHeight / yTickCount); ctx.fillText(yValue.toFixed(0), padding.left – 10, yPos); ctx.beginPath(); ctx.moveTo(padding.left – 5, yPos); ctx.lineTo(padding.left, yPos); ctx.stroke(); } // X-axis Labels and Ticks ctx.textAlign = 'center'; ctx.textBaseline = 'top'; for (var i = 0; i < dataPoints; i++) { var xPos = padding.left + i * xStep; var wLabel = waterContents[i].toFixed(0) + '%'; ctx.fillText(wLabel, xPos, padding.top + chartAreaHeight + 10); ctx.beginPath(); ctx.moveTo(xPos, padding.top + chartAreaHeight); ctx.lineTo(xPos, padding.top + chartAreaHeight + 5); ctx.stroke(); } // Chart Title ctx.fillStyle = '#004a99'; ctx.font = 'bold 14px Segoe UI'; ctx.textAlign = 'center'; ctx.fillText('Zero Air Void Unit Weight (kN/m³)', canvas.width / 2, padding.top / 2); // Draw Data Series 1: Zero Air Void Unit Weight ctx.strokeStyle = '#007bff'; // Blue for ZAV ctx.lineWidth = 2; ctx.beginPath(); for (var i = 0; i 0) { updateChart(currentGs); } // Perform calculation if both inputs are valid var Gs = validateInput('specificGravity', 0, 5, 'specificGravityError', 'Specific Gravity'); var w_percent = validateInput('waterContent', 0, 100, 'waterContentError', 'Water Content (%)'); if (Gs !== null && w_percent !== null) { calculateZeroAirVoid(); } }); document.getElementById('waterContent').addEventListener('input', function() { // Perform calculation if both inputs are valid var Gs = validateInput('specificGravity', 0, 5, 'specificGravityError', 'Specific Gravity'); var w_percent = validateInput('waterContent', 0, 100, 'waterContentError', 'Water Content (%)'); if (Gs !== null && w_percent !== null) { calculateZeroAirVoid(); } }); });

Leave a Comment