How to Calculate Wet Unit Weight of Soil

How to Calculate Wet Unit Weight of Soil – Soil Mechanics Calculator body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; line-height: 1.6; margin: 0; padding: 0; background-color: #f8f9fa; color: #333; display: flex; flex-direction: column; align-items: center; } .container { width: 95%; max-width: 1000px; margin: 20px auto; padding: 25px; background-color: #ffffff; border-radius: 8px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08); text-align: center; } h1, h2, h3 { color: #004a99; margin-bottom: 15px; } h1 { font-size: 2.5em; } h2 { font-size: 1.8em; border-bottom: 2px solid #004a99; padding-bottom: 5px; } h3 { font-size: 1.3em; } .calculator-section { margin-bottom: 30px; padding: 20px; border: 1px solid #e0e0e0; border-radius: 6px; background-color: #fdfdfd; } .calculator-section h2 { margin-top: 0; } .input-group { margin-bottom: 18px; text-align: left; display: flex; flex-direction: column; align-items: flex-start; } .input-group label { display: block; font-weight: bold; margin-bottom: 6px; color: #004a99; } .input-group input[type="number"], .input-group select { width: calc(100% – 20px); padding: 10px 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 1em; box-sizing: border-box; margin-bottom: 5px; transition: border-color 0.3s ease; } .input-group input[type="number"]:focus, .input-group select:focus { border-color: #004a99; outline: none; } .input-group .helper-text { font-size: 0.85em; color: #666; margin-top: 4px; display: block; } .error-message { color: #dc3545; font-size: 0.8em; margin-top: 5px; display: none; /* Hidden by default */ } .button-group { margin-top: 20px; display: flex; justify-content: center; gap: 15px; flex-wrap: wrap; } button { padding: 10px 20px; border: none; border-radius: 5px; font-size: 1em; font-weight: bold; cursor: pointer; transition: background-color 0.3s ease, transform 0.2s ease; margin: 5px; } .btn-calculate { background-color: #004a99; color: white; } .btn-calculate:hover { background-color: #003366; transform: translateY(-2px); } .btn-reset { background-color: #6c757d; color: white; } .btn-reset:hover { background-color: #5a6268; transform: translateY(-2px); } .btn-copy { background-color: #28a745; color: white; } .btn-copy:hover { background-color: #218838; transform: translateY(-2px); } .results-container { margin-top: 30px; padding: 20px; border: 1px solid #004a99; border-radius: 6px; background-color: #e7f3ff; text-align: left; } .results-container h3 { margin-top: 0; color: #004a99; text-align: center; } .primary-result { font-size: 2em; font-weight: bold; color: #28a745; margin-top: 10px; padding: 15px; background-color: #fff; border-radius: 5px; border: 1px dashed #28a745; display: inline-block; min-width: 60%; text-align: center; } .intermediate-results { margin-top: 20px; display: flex; flex-wrap: wrap; justify-content: space-around; gap: 15px; } .intermediate-results div { background-color: #fff; padding: 10px 15px; border-radius: 5px; border: 1px solid #ccc; text-align: center; flex: 1 1 150px; } .intermediate-results span { display: block; font-weight: bold; font-size: 1.2em; color: #004a99; } .formula-explanation { margin-top: 20px; font-size: 0.9em; color: #555; background-color: #f1f8ff; padding: 10px; border-radius: 4px; border-left: 3px solid #004a99; } .chart-container { margin-top: 30px; padding: 20px; border: 1px solid #e0e0e0; border-radius: 6px; background-color: #fdfdfd; } .chart-container h3 { margin-top: 0; } #soilChart { max-width: 100%; height: 300px; display: block; margin: 15px auto; background-color: #fff; border: 1px solid #eee; border-radius: 4px; } table { width: 100%; border-collapse: collapse; margin-top: 15px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05); } th, td { padding: 10px; text-align: left; border: 1px solid #ddd; } thead { background-color: #004a99; color: white; } tbody tr:nth-child(even) { background-color: #f2f2f2; } .article-content { text-align: left; margin-top: 30px; padding: 30px; background-color: #ffffff; border-radius: 8px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08); } .article-content h2 { font-size: 1.8em; color: #004a99; margin-top: 25px; margin-bottom: 15px; border-bottom: 2px solid #004a99; padding-bottom: 5px; } .article-content h3 { font-size: 1.3em; color: #004a99; margin-top: 20px; margin-bottom: 10px; } .article-content p { margin-bottom: 15px; color: #333; } .article-content ul, .article-content ol { margin-left: 20px; margin-bottom: 15px; } .article-content li { margin-bottom: 8px; } .article-content a { color: #004a99; text-decoration: none; font-weight: bold; } .article-content a:hover { text-decoration: underline; } .variable-table { width: 100%; border-collapse: collapse; margin-top: 15px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05); } .variable-table th, .variable-table td { padding: 10px; text-align: left; border: 1px solid #ddd; } .variable-table th { background-color: #004a99; color: white; font-weight: bold; } .variable-table tbody tr:nth-child(even) { background-color: #f2f2f2; } .faq-section { margin-top: 30px; background-color: #fdfdfd; padding: 20px; border-radius: 6px; border: 1px solid #e0e0e0; } .faq-section h3 { margin-top: 0; text-align: center; color: #004a99; border-bottom: 2px solid #004a99; padding-bottom: 5px; } .faq-item { margin-bottom: 15px; padding: 10px; background-color: #fff; border-radius: 4px; border: 1px solid #eee; } .faq-item p { margin-bottom: 5px; font-weight: bold; color: #004a99; } .faq-item span { display: block; color: #333; font-size: 0.95em; } .related-tools { margin-top: 30px; padding: 20px; background-color: #fdfdfd; border-radius: 6px; border: 1px solid #e0e0e0; } .related-tools h3 { margin-top: 0; text-align: center; color: #004a99; border-bottom: 2px solid #004a99; padding-bottom: 5px; } .related-tools ul { list-style: none; padding: 0; margin: 0; } .related-tools li { margin-bottom: 10px; } .related-tools a { font-weight: bold; color: #004a99; text-decoration: none; } .related-tools a:hover { text-decoration: underline; } footer { text-align: center; padding: 20px; margin-top: 30px; width: 100%; background-color: #004a99; color: white; font-size: 0.9em; } @media (max-width: 768px) { h1 { font-size: 2em; } h2 { font-size: 1.5em; } .container { padding: 15px; } .primary-result { font-size: 1.8em; min-width: 100%; } .button-group { flex-direction: column; align-items: center; } button { width: 80%; } .intermediate-results div { flex: 1 1 100%; } }

How to Calculate Wet Unit Weight of Soil

An essential tool for civil engineers, geologists, and construction professionals to determine the density of soil when it is saturated with water.

Wet Unit Weight Calculator

Enter the weight of the soil sample in grams (g).
Enter the volume of the soil sample in cubic centimeters (cm³).
Typically 1.0 g/cm³ for fresh water.

Calculation Results

Saturation Ratio (Sr)
Void Ratio (e)
Moisture Content (w)
Formula: Wet Unit Weight (γ_w) = (Weight of Wet Soil Sample / Volume of Wet Soil Sample). This calculation is often represented as Weight per Unit Volume. We also derive intermediate values like Saturation Ratio, Void Ratio, and Moisture Content where applicable, assuming soil solids' specific gravity is known (defaulting to 2.65 for common soils).

Wet Unit Weight vs. Moisture Content

Visualizing how wet unit weight changes with varying moisture content for a fixed soil volume and solids density.

Assumptions for Intermediate Calculations

Parameter Assumed Value Unit
Specific Gravity of Soil Solids (Gs) 2.65 g/cm³
Specific Gravity of Water (γw) 1.0 g/cm³

Note: Intermediate values like Saturation Ratio (Sr), Void Ratio (e), and Moisture Content (w) are calculated using these assumed values, as they require additional soil properties not directly input.

What is Wet Unit Weight of Soil?

The wet unit weight of soil, often denoted by γw or γwet, is a fundamental property in geotechnical engineering. It represents the weight of a specific volume of soil when it contains a certain amount of moisture, in its natural, in-situ condition. This crucial parameter helps engineers understand the soil's density and its behavior under load, which is vital for designing foundations, retaining walls, roads, and other civil engineering structures. It's a direct measure of how heavy a cubic meter (or cubic foot) of soil is in its current state, including the soil particles, water within the pores, and any entrapped air.

Who Should Use It?

Anyone involved in geotechnical investigations, soil characterization, and construction projects will find the calculation of wet unit weight of soil indispensable. This includes:

  • Civil Engineers: For structural design, foundation stability analysis, and earthwork calculations.
  • Geotechnical Engineers: To assess soil bearing capacity, settlement, and slope stability.
  • Construction Managers: To estimate material quantities, compaction requirements, and excavation volumes.
  • Geologists: To understand subsurface conditions and soil formation processes.
  • Environmental Engineers: For designing landfills or managing contaminated sites where soil density affects fluid flow.

Common Misconceptions

Several common misunderstandings surround the wet unit weight of soil:

  • Confusing it with Dry Unit Weight: Dry unit weight (γd) considers only the weight of soil solids and the volume of solids plus voids, excluding water. Wet unit weight includes the weight of the water.
  • Assuming Constant Value: The wet unit weight of a soil type can vary significantly depending on its moisture content and compaction level. It is not a fixed characteristic for a given soil type.
  • Ignoring Saturation: While wet unit weight accounts for existing moisture, it doesn't inherently specify the degree of saturation. A soil can be 'wet' but not fully saturated.

Wet Unit Weight Formula and Mathematical Explanation

The calculation for wet unit weight of soil is straightforward, representing the total weight of the soil (solids + water) divided by its total volume (solids + voids).

Step-by-Step Derivation

The most direct way to determine the wet unit weight of soil is through laboratory testing or field measurements:

  1. Obtain a Soil Sample: Collect a representative sample of the soil in its natural state.
  2. Determine its Weight: Weigh the collected soil sample accurately. This gives you the total weight of the soil including all its components (solids, water, and possibly entrapped air). Let this be Ww (Weight of Wet Soil).
  3. Determine its Volume: Measure the total volume occupied by this soil sample. This is the bulk volume, which includes the volume of soil solids and the volume of pores (filled with water and/or air). Let this be Vt (Total Volume).
  4. Calculate Wet Unit Weight: Divide the weight of the wet soil by its total volume.

The Formula

The primary formula for wet unit weight of soil is:

γw = Ww / Vt

Variable Explanations

Let's break down the variables involved:

Variable Meaning Unit Typical Range
γw (gamma_w) Wet Unit Weight kN/m³, lb/ft³, g/cm³ 15 – 22 kN/m³ (common range for many soils)
Ww (Weight_w) Weight of Wet Soil Sample Weight units (e.g., g, kg, lb) Varies based on sample size
Vt (Volume_t) Total Volume of the Soil Sample Volume units (e.g., cm³, m³, ft³) Varies based on sample size
Gs (Specific Gravity of Solids) Ratio of the density of soil solids to the density of water Dimensionless 2.60 – 2.80 (typical for most mineral soils)
Vw (Volume of Water) Volume of water in the soil pores Volume units (e.g., cm³, m³, ft³) Depends on moisture content and void ratio
Vv (Volume of Voids) Total volume of pores in the soil Volume units (e.g., cm³, m³, ft³) Depends on void ratio
w (Moisture Content) Ratio of the weight of water to the weight of solids, expressed as a percentage % or decimal 0% to saturation limit (e.g., 10% – 50%)
e (Void Ratio) Ratio of the volume of voids to the volume of solids Dimensionless 0.1 – 2.0+ (loose to dense/consolidated soils)
Sr (Saturation Ratio) Ratio of the volume of water to the volume of voids % or decimal 0% (dry) to 100% (saturated)

Note: The calculator primarily uses the direct Ww/Vt method. The other variables (Gs, Vw, Vv, w, e, Sr) are related and can be used in alternative formulas or to derive intermediate parameters, often requiring the specific gravity of soil solids (Gs) to be known or assumed. We use Gs = 2.65 and Specific Gravity of Water = 1.0 for intermediate calculations.

Practical Examples (Real-World Use Cases)

Example 1: Foundation Design for a Small Building

A civil engineer is designing the foundation for a small commercial building. They take a soil sample from the proposed foundation depth and measure its properties in the lab.

  • Input:
    • Weight of Wet Soil Sample (Ww): 1500 g
    • Volume of Wet Soil Sample (Vt): 750 cm³
  • Calculation:
    • Wet Unit Weight (γw) = Ww / Vt = 1500 g / 750 cm³ = 2.0 g/cm³
  • Intermediate Calculations (Assuming Gs = 2.65, Water = 1.0):
    • Dry Unit Weight (γd) = γw / (1 + w) = 2.0 / (1 + w) — requires knowing 'w'
    • If we know 'w' = 20% (0.20) and Gs = 2.65:
      • Void Ratio (e) = (Gs * γw / γd) – 1 = (2.65 * 2.0 / (2.0 / (1 + 0.20))) – 1 = (5.3 / 1.667) – 1 = 3.18 – 1 = 2.18 (This is very high, indicating a loose soil or error in input/assumptions)
      • Saturation Ratio (Sr) = w * Gs / e = 0.20 * 2.65 / 2.18 = 0.53 / 2.18 = 0.24 or 24% (This suggests the soil is not fully saturated)
  • Interpretation: A wet unit weight of 2.0 g/cm³ (which is equivalent to 19.62 kN/m³) is within a reasonable range for many soils. However, the high void ratio derived suggests the soil might be very loose or the moisture content value used was for a different scenario. The engineer must confirm these properties or use the direct wet unit weight for bearing capacity calculations, considering the soil's condition.
  • Example 2: Road Embankment Compaction

    A construction crew is building a road embankment and needs to ensure the soil is compacted to a desired density. They take a sample from the freshly placed fill.

    • Input:
      • Weight of Wet Soil Sample (Ww): 1850 g
      • Volume of Wet Soil Sample (Vt): 800 cm³
    • Calculation:
      • Wet Unit Weight (γw) = Ww / Vt = 1850 g / 800 cm³ = 2.31 g/cm³
    • Intermediate Calculations (Assuming Gs = 2.70, Water = 1.0):
      • If the target dry unit weight (γd) for compaction is 2.0 g/cm³ (19.62 kN/m³):
        • Required Moisture Content (w) = (γw / γd) – 1 = (2.31 / 2.0) – 1 = 1.155 – 1 = 0.155 or 15.5%
        • Void Ratio (e) = (Gs * γw / γd) – 1 = (2.70 * 2.31 / 2.0) – 1 = (6.237 / 2.0) – 1 = 3.1185 – 1 = 2.1185 (Again, high void ratio potentially due to high moisture)
        • Saturation Ratio (Sr) = w * Gs / e = 0.155 * 2.70 / 2.1185 = 0.4185 / 2.1185 = 0.197 or 19.7%
  • Interpretation: The measured wet unit weight of soil is 2.31 g/cm³. If the project specification requires a dry unit weight of 2.0 g/cm³, the crew needs to adjust the moisture content to approximately 15.5% during compaction. The current saturation is low (around 20%), indicating there's ample pore space for water if needed for optimal compaction.
  • How to Use This Wet Unit Weight Calculator

    Our calculator simplifies the process of determining the wet unit weight of soil and understanding related parameters. Follow these simple steps:

    1. Input Soil Properties:
      • Weight of Wet Soil Sample: Enter the measured weight of your soil sample in grams (g).
      • Volume of Wet Soil Sample: Enter the total volume this sample occupies in cubic centimeters (cm³).
      • Specific Gravity of Water: This is usually 1.0 g/cm³ for typical conditions. Adjust only if dealing with significantly different water types (e.g., saltwater).
    2. Optional – Adjust Assumptions: For intermediate calculations (like Saturation Ratio, Void Ratio, Moisture Content), the calculator assumes a Specific Gravity of Soil Solids (Gs) of 2.65. You can adjust this value in the "Assumptions" table if you have specific data for your soil type.
    3. Calculate: Click the "Calculate" button. The calculator will immediately display:
      • The primary result: Wet Unit Weight (in g/cm³).
      • Key intermediate values: Saturation Ratio (Sr), Void Ratio (e), and Moisture Content (w), calculated using the assumed Gs.
    4. Interpret Results: The results provide a quantitative measure of the soil's density. High wet unit weight generally implies denser soil. The intermediate values offer deeper insights into the soil's state of saturation and pore structure.
    5. Reset or Copy:
      • Click "Reset Defaults" to return all input fields to their initial standard values.
      • Click "Copy Results" to copy the primary result, intermediate values, and key assumptions to your clipboard for use elsewhere.

    This tool is designed for quick estimations and educational purposes. For critical engineering applications, always rely on comprehensive field and laboratory testing protocols.

    Key Factors That Affect Wet Unit Weight Results

    Several factors significantly influence the wet unit weight of soil. Understanding these is crucial for accurate interpretation:

    1. Moisture Content: This is the most direct influence. As water content increases (up to saturation), the total weight of the sample increases, directly increasing the wet unit weight, assuming the volume remains constant. This is why soils become heavier when wet.
    2. Soil Compaction / Density: The degree to which soil particles are packed together (related to dry unit weight and void ratio) is critical. Denser soils (lower void ratio) generally have higher unit weights, both dry and wet. Compaction effort during construction directly impacts this.
    3. Soil Type (Mineralogy & Particle Size): Different soil minerals have different inherent densities (specific gravities). For example, soils rich in heavy minerals will have a higher unit weight than those composed of lighter materials. Particle shape and gradation also affect how densely particles can pack.
    4. Degree of Saturation: While related to moisture content, saturation specifically refers to how much of the pore volume is filled with water. In a dry soil (Sr=0%), only solids contribute to weight. In a fully saturated soil (Sr=100%), both solids and water contribute to the weight within the total volume.
    5. Presence of Entrapped Air: In partially saturated soils, air occupies some pore space. This air is weightless, so its presence (compared to water filling the same volume) will result in a lower wet unit weight.
    6. Overburden Pressure: In natural soil deposits, the weight of the soil above a particular layer (overburden pressure) compacts the lower layers, increasing their density and thus their unit weight.
    7. Organic Content: Soils with high organic content (like peat) tend to be less dense and have lower unit weights compared to mineral soils due to the lighter nature of organic matter.

    Frequently Asked Questions (FAQ)

    Common Questions About Wet Unit Weight

    Q: What is the difference between wet unit weight and dry unit weight?

    A: Wet unit weight (γw) is the total weight of soil (solids + water) per unit volume. Dry unit weight (γd) is the weight of soil solids only per unit volume. γw = γd + unit weight of water in pores.

    Q: What is a typical range for wet unit weight of soil?

    A: For many common mineral soils, the wet unit weight typically ranges from 15 kN/m³ to 22 kN/m³ (approximately 1.5 to 2.2 g/cm³), depending heavily on moisture content and compaction.

    Q: Does the calculator account for different soil types?

    A: The primary calculation (Weight/Volume) is universal. However, intermediate values (like void ratio, moisture content) rely on the assumed Specific Gravity of Soil Solids (Gs), which varies slightly by soil type. The default Gs is 2.65, typical for many soils. For specific analyses, you should input the actual Gs if known.

    Q: How is wet unit weight measured in the field?

    A: Field methods include the core cutter method (for cohesive soils) and the sand cone method (for granular soils), both involving determining the volume and weight of a excavated soil sample. Nuclear density gauges are also commonly used.

    Q: Can wet unit weight be negative?

    A: No, wet unit weight cannot be negative. Weight and volume are always positive quantities.

    Q: What units does the calculator use?

    A: The calculator accepts input in grams (g) for weight and cubic centimeters (cm³) for volume, providing the primary result in g/cm³. Intermediate results are dimensionless or percentages.

    Q: Why is specific gravity of water important?

    A: Specific gravity of water (usually ~1.0 g/cm³) is used as a reference density. It's crucial for calculations involving other unit weights (like dry unit weight) and derived properties like void ratio and saturation ratio, where density relationships are key.

    Q: How does high moisture content affect stability?

    A: While increasing wet unit weight, excessively high moisture content can significantly reduce the effective stresses within the soil, lowering its shear strength and potentially compromising the stability of structures built upon it, especially in fine-grained soils.

    Related Tools and Internal Resources

    © 2023 Your Company Name. All rights reserved.

    var chartInstance = null; // Global variable to hold chart instance function isValidNumber(value) { return !isNaN(parseFloat(value)) && isFinite(value); } function showError(elementId, message) { var errorElement = document.getElementById(elementId); if (errorElement) { errorElement.innerText = message; errorElement.style.display = 'block'; } } function hideError(elementId) { var errorElement = document.getElementById(elementId); if (errorElement) { errorElement.innerText = "; errorElement.style.display = 'none'; } } function getInputValue(id) { var element = document.getElementById(id); return element ? parseFloat(element.value) : NaN; } function setOutput(id, value, unit = ") { var element = document.getElementById(id); if (element) { if (isNaN(value)) { element.innerText = '–'; } else { element.innerText = value.toFixed(3) + unit; } } } function calculateWetUnitWeight() { // Clear previous errors hideError('sampleWeightError'); hideError('sampleVolumeError'); hideError('waterSpecificGravityError'); // Get input values var sampleWeight = getInputValue('sampleWeight'); var sampleVolume = getInputValue('sampleVolume'); var waterSpecificGravity = getInputValue('waterSpecificGravity'); // Validation if (isNaN(sampleWeight) || sampleWeight <= 0) { showError('sampleWeightError', 'Please enter a valid positive weight.'); return; } if (isNaN(sampleVolume) || sampleVolume <= 0) { showError('sampleVolumeError', 'Please enter a valid positive volume.'); return; } if (isNaN(waterSpecificGravity) || waterSpecificGravity Sr * γ_w_water. If γ_w is very low, it might fail. if (wetUnitWeight > assumedSr * assumedWaterDensity) { voidRatio = (assumedGs * assumedWaterDensity – wetUnitWeight) / (wetUnitWeight – assumedSr * assumedWaterDensity); saturationRatio = assumedSr; moistureContent = (voidRatio * saturationRatio) / assumedGs; // w = Sr * e / Gs } else { // If the soil is not saturated (Sr γ_d = γ_w / (1 + w) var derivedDryUnitWeight = wetUnitWeight / (1 + moistureContent); // γ_d = Gs * γ_w_water / (1 + e) => e = (Gs * γ_w_water / γ_d) – 1 voidRatio = (assumedGs * assumedWaterDensity / derivedDryUnitWeight) – 1; // S_r * e = w * Gs => S_r = (w * Gs) / e saturationRatio = (moistureContent * assumedGs) / voidRatio; } // Update UI setOutput('primaryResult', wetUnitWeight, ' g/cm³'); if (saturationRatio !== '–') setOutput('saturationRatio', saturationRatio * 100, '%'); else setOutput('saturationRatio', '–'); if (voidRatio !== '–') setOutput('voidRatio', voidRatio); else setOutput('voidRatio', '–'); if (moistureContent !== '–') setOutput('moistureContent', moistureContent * 100, '%'); else setOutput('moistureContent', '–'); // Update assumed values display document.getElementById('assumedGs').innerText = assumedGs; document.getElementById('assumedGw').innerText = assumedWaterDensity; // Update Chart updateChart(wetUnitWeight, moistureContent); } function resetCalculator() { document.getElementById('sampleWeight').value = '1000'; document.getElementById('sampleVolume').value = '500'; document.getElementById('waterSpecificGravity').value = '1.0'; // Reset errors hideError('sampleWeightError'); hideError('sampleVolumeError'); hideError('waterSpecificGravityError'); // Recalculate with defaults calculateWetUnitWeight(); } function copyResults() { var primaryResultEl = document.getElementById('primaryResult'); var saturationRatioEl = document.getElementById('saturationRatio'); var voidRatioEl = document.getElementById('voidRatio'); var moistureContentEl = document.getElementById('moistureContent'); var assumedGsEl = document.getElementById('assumedGs'); var assumedGwEl = document.getElementById('assumedGw'); var primaryResult = primaryResultEl ? primaryResultEl.innerText : 'N/A'; var saturationRatio = saturationRatioEl ? saturationRatioEl.innerText : 'N/A'; var voidRatio = voidRatioEl ? voidRatioEl.innerText : 'N/A'; var moistureContent = moistureContentEl ? moistureContentEl.innerText : 'N/A'; var assumedGs = assumedGsEl ? assumedGsEl.innerText : 'N/A'; var assumedGw = assumedGwEl ? assumedGwEl.innerText : 'N/A'; var resultText = "Wet Unit Weight Calculation Results:\n\n"; resultText += "Primary Result:\n" + primaryResult + "\n\n"; resultText += "Intermediate Values:\n"; resultText += "- Saturation Ratio (Sr): " + saturationRatio + "\n"; resultText += "- Void Ratio (e): " + voidRatio + "\n"; resultText += "- Moisture Content (w): " + moistureContent + "\n\n"; resultText += "Key Assumptions:\n"; resultText += "- Specific Gravity of Soil Solids (Gs): " + assumedGs + "\n"; resultText += "- Specific Gravity of Water: " + assumedGw + "\n"; // Use temporary textarea for copying var textArea = document.createElement("textarea"); textArea.value = resultText; textArea.style.position = "fixed"; textArea.style.left = "-9999px"; document.body.appendChild(textArea); textArea.focus(); textArea.select(); try { var successful = document.execCommand('copy'); var msg = successful ? 'Results copied!' : 'Copy failed!'; console.log(msg); // Optional: show feedback to user } catch (err) { console.error('Copying failed: ', err); // Optional: show feedback to user } document.body.removeChild(textArea); } // — Chart Logic — function updateChart(currentWetUnitWeight, currentMoistureContentDecimal) { var ctx = document.getElementById('soilChart').getContext('2d'); // Sample data points for the chart var chartDataPoints = []; var assumedGs = parseFloat(document.getElementById('assumedGs').innerText); var assumedWaterDensity = parseFloat(document.getElementById('assumedGw').innerText); var baseMoistureContent = currentMoistureContentDecimal !== '–' ? currentMoistureContentDecimal : 0.10; // Use current or default var baseWetUnitWeight = currentWetUnitWeight !== '–' ? currentWetUnitWeight : 1.8; // Generate points for a range of moisture contents around the current value for (var i = 0; i 1.0) derivedSaturation = 1.0; // Cap at 100% saturation chartDataPoints.push({ moistureContent: w * 100, wetUnitWeight: derivedWetUnitWeight, saturation: derivedSaturation * 100 }); } // Destroy previous chart instance if it exists if (chartInstance) { chartInstance.destroy(); } // Create new chart chartInstance = new Chart(ctx, { type: 'line', data: { labels: chartDataPoints.map(point => point.moistureContent.toFixed(1) + '%'), // Moisture Content % datasets: [ { label: 'Wet Unit Weight (g/cm³)', data: chartDataPoints.map(point => point.wetUnitWeight), borderColor: '#004a99', backgroundColor: 'rgba(0, 74, 153, 0.1)', fill: false, tension: 0.1, yAxisID: 'y-axis-weight' }, { label: 'Saturation (%)', data: chartDataPoints.map(point => point.saturation), borderColor: '#28a745', backgroundColor: 'rgba(40, 167, 69, 0.1)', fill: false, tension: 0.1, yAxisID: 'y-axis-saturation' } ] }, options: { responsive: true, maintainAspectRatio: false, scales: { x: { title: { display: true, text: 'Moisture Content (%)' } }, 'y-axis-weight': { type: 'linear', position: 'left', title: { display: true, text: 'Wet Unit Weight (g/cm³)' }, ticks: { beginAtZero: true } }, 'y-axis-saturation': { type: 'linear', position: 'right', title: { display: true, text: 'Saturation Ratio (%)' }, ticks: { beginAtZero: true, max: 100 // Saturation is capped at 100% }, grid: { drawOnChartArea: false, // only want the grid lines for one dimension of the y axis } } }, plugins: { tooltip: { callbacks: { label: function(context) { var label = context.dataset.label || "; if (label) { label += ': '; } if (context.parsed.y !== null) { if (context.dataset.label.includes('Weight')) { label += context.parsed.y.toFixed(3) + ' g/cm³'; } else if (context.dataset.label.includes('Saturation')) { label += context.parsed.y.toFixed(1) + '%'; } } return label; } } } } } }); } // Initial calculation on page load document.addEventListener('DOMContentLoaded', function() { calculateWetUnitWeight(); });

    Leave a Comment