Collapse Pressure for Mud Weight Calculation

Collapse Pressure for Mud Weight Calculation | Expert Guide & Calculator body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; line-height: 1.6; color: #333; background-color: #f8f9fa; margin: 0; padding: 0; } .container { max-width: 1000px; margin: 20px auto; padding: 20px; background-color: #fff; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); border-radius: 8px; } .header { background-color: #004a99; color: white; padding: 15px 0; text-align: center; border-radius: 8px 8px 0 0; margin-bottom: 20px; } .header h1 { margin: 0; font-size: 2.2em; font-weight: 600; } .calculator-section { margin-bottom: 30px; padding: 25px; background-color: #e9ecef; border-radius: 8px; border: 1px solid #dee2e6; } .calculator-section h2 { color: #004a99; margin-top: 0; text-align: center; margin-bottom: 20px; font-size: 1.8em; } .input-group { margin-bottom: 15px; display: flex; flex-direction: column; align-items: stretch; } .input-group label { display: block; margin-bottom: 8px; font-weight: 500; color: #004a99; } .input-group input[type="number"], .input-group select { width: 100%; padding: 10px; border: 1px solid #ced4da; border-radius: 4px; box-sizing: border-box; font-size: 1em; } .input-group .helper-text { font-size: 0.85em; color: #6c757d; margin-top: 5px; } .error-message { color: #dc3545; font-size: 0.9em; margin-top: 5px; display: none; } .button-group { display: flex; justify-content: center; gap: 15px; margin-top: 20px; } button { padding: 12px 25px; border: none; border-radius: 5px; font-size: 1.1em; cursor: pointer; transition: background-color 0.3s ease, transform 0.2s ease; font-weight: 500; } .calculate-button { background-color: #004a99; color: white; } .calculate-button:hover { background-color: #003f80; transform: translateY(-1px); } .reset-button { background-color: #6c757d; color: white; } .reset-button:hover { background-color: #5a6268; transform: translateY(-1px); } .copy-button { background-color: #28a745; color: white; } .copy-button:hover { background-color: #218838; transform: translateY(-1px); } .results-section { margin-top: 30px; padding: 25px; background-color: #d4edda; border: 1px solid #c3e6cb; border-radius: 8px; text-align: center; } .results-section h3 { color: #155724; margin-top: 0; font-size: 1.6em; } .primary-result { font-size: 2.5em; font-weight: bold; color: #28a745; margin: 15px 0; padding: 15px; background-color: #ffffff; border-radius: 5px; border: 2px solid #28a745; } .intermediate-results div, .key-assumptions div { margin-bottom: 10px; font-size: 1.1em; } .intermediate-results strong, .key-assumptions strong { color: #004a99; display: inline-block; width: 200px; /* Adjust as needed for alignment */ text-align: right; margin-right: 10px; } .formula-explanation { font-size: 0.95em; color: #495057; margin-top: 15px; padding: 10px; background-color: #fff; border-left: 4px solid #004a99; } .chart-section { margin-top: 30px; padding: 25px; background-color: #f0f0f0; border-radius: 8px; border: 1px solid #ccc; } .chart-section h3 { text-align: center; color: #004a99; margin-top: 0; font-size: 1.6em; margin-bottom: 20px; } canvas { display: block; margin: 0 auto; max-width: 100%; height: 400px !important; /* Ensure canvas has a defined height */ } .table-section { margin-top: 30px; padding: 25px; background-color: #f0f0f0; border-radius: 8px; border: 1px solid #ccc; } .table-section h3 { text-align: center; color: #004a99; margin-top: 0; font-size: 1.6em; margin-bottom: 20px; } table { width: 100%; border-collapse: collapse; margin-top: 15px; } th, td { border: 1px solid #dee2e6; padding: 10px; text-align: center; } th { background-color: #004a99; color: white; font-weight: 600; } td { background-color: #fff; } tr:nth-child(even) td { background-color: #f2f2f2; } caption { font-size: 1.1em; font-weight: bold; color: #333; margin-bottom: 10px; caption-side: top; text-align: center; } .article-content { margin-top: 40px; padding: 25px; background-color: #fff; border-radius: 8px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05); } article h2 { color: #004a99; font-size: 2em; margin-bottom: 15px; border-bottom: 2px solid #eee; padding-bottom: 8px; } article h3 { color: #004a99; font-size: 1.6em; margin-top: 25px; margin-bottom: 10px; } article p, article ul, article ol { margin-bottom: 15px; font-size: 1.05em; } article ul, article ol { padding-left: 25px; } article li { margin-bottom: 8px; } .faq-question { font-weight: bold; color: #004a99; margin-top: 15px; margin-bottom: 5px; } .faq-answer { margin-left: 10px; margin-bottom: 10px; } .internal-links-section { margin-top: 30px; padding: 25px; background-color: #f0f0f0; border-radius: 8px; border: 1px solid #ccc; } .internal-links-section h3 { text-align: center; color: #004a99; margin-top: 0; font-size: 1.6em; margin-bottom: 20px; } .internal-links-list a { color: #004a99; text-decoration: none; font-weight: 500; } .internal-links-list a:hover { text-decoration: underline; } .internal-links-list p { margin-bottom: 15px; } .footer { text-align: center; margin-top: 40px; padding: 20px; font-size: 0.9em; color: #6c757d; } @media (max-width: 768px) { .container { margin: 10px; padding: 15px; } .header h1 { font-size: 1.8em; } .calculator-section, .results-section, .chart-section, .table-section, .article-content, .internal-links-section { padding: 15px; } .button-group { flex-direction: column; gap: 10px; } button { width: 100%; } .intermediate-results strong, .key-assumptions strong { display: block; width: 100%; text-align: left; margin-right: 0; margin-bottom: 5px; } }

Collapse Pressure for Mud Weight Calculation

Wellbore Integrity Calculator

Calculate the required mud weight to prevent wellbore collapse using key formation and well parameters.

Enter the pore pressure of the formation in psi.
Enter the fracture gradient in psi/1000ft or psi/ft. Ensure consistency with TVD unit.
Enter the true vertical depth in feet.
A dimensionless factor, typically between 1.05 and 1.2.

Calculation Results

Formula Used:
The collapse pressure is primarily related to the formation pore pressure at depth and the stress acting on the wellbore. To maintain wellbore integrity, the hydrostatic pressure exerted by the drilling mud must exceed the formation pore pressure, while remaining below the fracture pressure.

Collapse Pressure (Pc) Calculation:
A simplified approach to determine the target mud weight involves ensuring the mud hydrostatic pressure (P_mud) exceeds the formation pore pressure (Pp) by a safety margin, considering the stresses. A common calculation for the required mud weight (MW) to prevent collapse is derived from: P_mud = MW * TVD * 0.052 (for PPG) This must be greater than Pp. To prevent collapse, the mud pressure needs to counteract the effective stress. A practical approach often uses the formation pore pressure itself as a minimum target for mud weight, adjusted by a safety factor to account for uncertainties and effective stress.

The **Collapse Pressure (Pc)** can be approximated as the formation pore pressure (Pp) at the given TVD, representing the pressure inside the formation that tends to cause collapse.
The **Required Mud Weight (MW)** to prevent collapse is determined by setting the mud hydrostatic pressure to be slightly above the formation pore pressure, incorporating a safety factor: $P_{mud\_hydrostatic} = MW_{required} \times TVD \times 0.052$ $MW_{required} \times TVD \times 0.052 \ge Pp \times SF$ $MW_{required} \ge \frac{Pp \times SF}{TVD \times 0.052}$ The calculation here focuses on determining the target mud weight needed to balance the formation pressure.

Mud Weight vs. Depth & Pressure

This chart visualizes the relationship between formation pore pressure, the calculated required mud weight, and the fracture gradient across the True Vertical Depth.

Calculation Parameters and Limits

Input Parameters and Safety Margins
Parameter Unit Value Entered Typical Range Notes
Formation Pore Pressure (Pp) psi 3,000 – 15,000+ Internal pressure within the rock pores.
Fracture Gradient (Gf) psi/1000ft 12 – 18+ Pressure at which the formation fractures. Ensure units match TVD.
True Vertical Depth (TVD) feet 1,000 – 30,000+ Vertical distance from surface to the point of interest.
Safety Factor (SF) N/A 1.05 – 1.2 Margin to account for uncertainties and effective stress.
Required Mud Weight (MW) ppg 8.0 – 18.0+ Weight of drilling fluid needed to prevent collapse.
Collapse Pressure (Pc) psi 3,000 – 15,000+ Pressure causing the wellbore to fail inwards.

Understanding Collapse Pressure for Mud Weight Calculation

In the demanding world of oil and gas exploration, maintaining the integrity of a wellbore is paramount. One critical aspect of this is understanding and managing the **collapse pressure for mud weight calculation**. This concept directly impacts the drilling fluid's (mud) weight, which is carefully chosen to counteract the immense pressures exerted by the surrounding rock formations. Failure to select the correct mud weight can lead to wellbore instability, blowouts, or lost circulation, all of which are costly and dangerous.

What is Collapse Pressure for Mud Weight Calculation?

Collapse pressure for mud weight calculation refers to the process of determining the necessary weight of the drilling mud required to prevent the surrounding rock formation from collapsing inwards into the wellbore. This phenomenon occurs when the pressure exerted by the drilling fluid is insufficient to counteract the effective stresses acting on the wellbore wall. The formation pressure within the rock pores pushes outward, but the rock's own strength and the external pressure (from overburden and tectonic forces) create a stress regime where inward collapse is possible if not properly managed. Therefore, the mud weight must be high enough to provide an adequate counter-pressure, but not so high that it causes the formation to fracture.

Who Should Use It?

This calculation is essential for:

  • Drilling Engineers: To design and manage drilling fluid programs.
  • Wellbore Geologists: To understand formation response to drilling.
  • Completion Engineers: To ensure wellbore stability during completion operations.
  • Reservoir Engineers: To maintain communication with the reservoir without damaging it.
  • Health, Safety, and Environment (HSE) Professionals: To mitigate risks associated with wellbore instability.

Common Misconceptions

A common misconception is that collapse pressure is solely determined by the pore pressure. While pore pressure is a primary driver, the rock's mechanical properties, the magnitude of the stress field (including overburden and horizontal stresses), and the presence of natural fractures also play significant roles. Another misconception is that a higher mud weight is always better; excessively high mud weight can lead to lost circulation or formation damage, making the calculation a delicate balancing act.

Collapse Pressure for Mud Weight Calculation: Formula and Mathematical Explanation

The fundamental principle behind selecting mud weight is to balance the pressures acting on the wellbore. The goal is to maintain the wellbore in a stable state, avoiding both collapse (inward failure) and fracturing (outward failure). The **collapse pressure for mud weight calculation** aims to find the minimum required mud weight that prevents inward failure.

Step-by-Step Derivation

The pressure at any given depth due to the drilling fluid is its hydrostatic pressure. This is calculated as:

Hydrostatic Pressure (P_mud) = Mud Weight (MW) × True Vertical Depth (TVD) × Conversion Factor

In the US customary system, if MW is in pounds per gallon (ppg) and TVD is in feet, the conversion factor is approximately 0.052 to yield pressure in psi.

P_mud (psi) = MW (ppg) × TVD (ft) × 0.052

For wellbore stability against collapse, the hydrostatic pressure exerted by the mud must be sufficient to support the wellbore wall and counteract the effective stress. The effective stress is the difference between the total stress and the pore pressure. To prevent collapse, the mud pressure should ideally be equal to or slightly greater than the formation pore pressure (Pp).

However, real-world conditions involve uncertainties and stress anisotropy. Therefore, a safety factor (SF) is applied. The required mud weight (MW_required) is determined by ensuring the mud hydrostatic pressure is greater than or equal to the pore pressure multiplied by the safety factor:

P_mud ≥ Pp × SF

Substituting the hydrostatic pressure formula:

MW_required × TVD × 0.052 ≥ Pp × SF

Rearranging to solve for the required mud weight:

MW_required ≥ (Pp × SF) / (TVD × 0.052)

The **collapse pressure (Pc)** itself can be considered the pressure at which the rock matrix fails inward. This is complex and depends on the stress state. A practical proxy for the minimum pressure required to prevent collapse is often related to the pore pressure at that depth. The calculation provided by the tool focuses on finding the mud weight necessary to balance this force.

Variable Explanations

Variables in Collapse Pressure for Mud Weight Calculation
Variable Meaning Unit Typical Range
Pp Formation Pore Pressure psi 3,000 – 15,000+
Gf Fracture Gradient psi/1000ft or psi/ft 12 – 18+ (equivalent mud weight)
TVD True Vertical Depth feet 1,000 – 30,000+
SF Safety Factor Dimensionless 1.05 – 1.2
MW_required Required Mud Weight ppg 8.0 – 18.0+
P_mud Mud Hydrostatic Pressure psi Varies with MW and TVD
Pc Collapse Pressure psi Approximated by Pp, influenced by stress state

Practical Examples

Let's explore a couple of scenarios for **collapse pressure for mud weight calculation**.

Example 1: Standard Drilling Scenario

Consider a well being drilled to a True Vertical Depth (TVD) of 10,000 feet. The formation pore pressure (Pp) is measured to be 7,000 psi. The estimated fracture gradient (Gf) is 15,000 psi/1000ft (equivalent to 15 ppg). We want to maintain a safety factor (SF) of 1.1.

Inputs:

  • TVD = 10,000 ft
  • Pp = 7,000 psi
  • Gf = 15 ppg (equivalent mud weight)
  • SF = 1.1

Calculation:

Required Mud Weight (MW_required) = (Pp × SF) / (TVD × 0.052)

MW_required = (7,000 psi × 1.1) / (10,000 ft × 0.052)

MW_required = 7,700 psi / 520 psi/ppg

MW_required ≈ 14.81 ppg

The calculated collapse pressure is approximately 7,000 psi. The required mud weight is 14.81 ppg.

Interpretation: The drilling mud must weigh approximately 14.81 pounds per gallon to prevent the formation from collapsing at 10,000 ft. This is well below the fracture gradient of 15 ppg, indicating a stable operating window. This calculation is a key part of our collapse pressure for mud weight calculation.

Example 2: High Pressure Formation

A deep exploration well is planned to reach a TVD of 15,000 feet. Early logs indicate a high pore pressure of 12,000 psi. The fracture gradient is estimated at 17,000 psi/1000ft (17 ppg). A safety factor of 1.15 is deemed necessary due to formation uncertainties.

Inputs:

  • TVD = 15,000 ft
  • Pp = 12,000 psi
  • Gf = 17 ppg
  • SF = 1.15

Calculation:

MW_required = (Pp × SF) / (TVD × 0.052)

MW_required = (12,000 psi × 1.15) / (15,000 ft × 0.052)

MW_required = 13,800 psi / 780 psi/ppg

MW_required ≈ 17.69 ppg

The calculated collapse pressure is approximately 12,000 psi. The required mud weight is 17.69 ppg.

Interpretation: In this high-pressure scenario, the required mud weight is very high (17.69 ppg). This value is close to the fracture gradient of 17 ppg. This indicates a very narrow drilling window, requiring careful management of mud properties and drilling parameters to avoid fracturing the formation. This highlights the importance of accurate **collapse pressure for mud weight calculation** in such challenging environments. For more on managing pressures, consider our wellbore stability analysis guide.

How to Use This Collapse Pressure for Mud Weight Calculator

Our collapse pressure for mud weight calculator simplifies the process of ensuring wellbore integrity. Follow these steps:

  1. Input Formation Pore Pressure (Pp): Enter the known or estimated pore pressure of the formation at the depth of interest in psi.
  2. Input Fracture Gradient (Gf): Enter the fracture gradient, typically expressed in psi per 1000 feet (e.g., 15.0 for 15,000 psi/1000ft). This represents the pressure limit before fracturing occurs.
  3. Input True Vertical Depth (TVD): Enter the vertical depth of the section being drilled in feet.
  4. Input Safety Factor (SF): Select an appropriate safety factor (e.g., 1.1) to account for uncertainties and ensure a buffer against collapse.
  5. Click 'Calculate': The tool will compute the estimated collapse pressure and the minimum required mud weight in pounds per gallon (ppg).
  6. Review Results: Check the primary result (Required Mud Weight) and intermediate values (Collapse Pressure, Pore Pressure at TVD). Ensure the required mud weight is below the fracture gradient.
  7. Interpret the Data: The results provide a critical target for your drilling fluid program. Compare the required mud weight to your planned mud weight.
  8. Use the 'Copy Results' Button: Easily copy all calculated values and key assumptions for your reports.
  9. Reset as Needed: Use the 'Reset' button to clear inputs and start over with new parameters.

This calculator assists in making informed decisions about mud weight selection, directly impacting the safety and efficiency of drilling operations. Understanding the nuances of **collapse pressure for mud weight calculation** is vital for preventing costly wellbore issues.

Key Factors That Affect Collapse Pressure for Mud Weight Calculation Results

Several factors influence the accuracy and application of **collapse pressure for mud weight calculation**. Understanding these is crucial for effective wellbore management:

  • Formation Pore Pressure (Pp): This is the primary driver for collapse. Accurate measurement or estimation of pore pressure using seismic data, offset well logs, or mud logging is fundamental. Higher pore pressure means higher inward forces on the wellbore.
  • Stress State (Rock Mechanics): The total stress on the rock, including overburden pressure (vertical stress) and horizontal stresses, significantly impacts collapse. In formations with high horizontal stresses, the required mud weight to prevent collapse might increase. This is a complex area often requiring detailed geomechanical analysis.
  • Rock Strength and Lithology: The inherent strength of the rock (e.g., shale vs. sandstone) and its properties (e.g., clay content, permeability) affect its susceptibility to collapse. Weak or reactive formations require more careful mud weight management.
  • True Vertical Depth (TVD): As depth increases, the hydrostatic pressure from the mud column becomes more significant. However, pore pressures and stresses also generally increase with depth, making the calculation critical at deeper levels.
  • Safety Factor (SF): Choosing an appropriate safety factor is vital. A higher SF provides a larger margin against collapse but can increase the risk of fracturing or lost circulation. It should be adjusted based on geological uncertainty, drilling fluid properties, and operational risks. This relates directly to our drilling fluid optimization strategies.
  • Mud Properties (Rheology and Density): While this calculator focuses on weight (density), the rheological properties (viscosity) of the mud also play a role in hole cleaning and pressure transmission, indirectly affecting wellbore stability. Accurate density control is paramount.
  • Temperature Effects: Temperature can affect fluid density and rock mechanical properties, which can indirectly influence collapse pressure. While not explicitly in this simplified calculator, it's a consideration in advanced wellbore stability modeling.
  • Drilling Practices: The rate of penetration, hole cleaning efficiency, and wellbore trajectory can all influence the effective stresses and pressures experienced by the wellbore, impacting stability. Efficient directional drilling is important.

Frequently Asked Questions (FAQ)

What is the primary goal when calculating mud weight for collapse pressure?

The primary goal is to select a mud weight that is heavy enough to counteract the formation's tendency to collapse into the wellbore, but not so heavy that it causes the formation to fracture.

How does pore pressure affect collapse pressure?

Higher pore pressure exerts more outward force from the formation, increasing the tendency for collapse. Therefore, a higher mud weight is generally required to counteract higher pore pressures.

What is the typical range for a safety factor in mud weight calculations?

A typical safety factor ranges from 1.05 to 1.2. The exact value depends on the geological certainty, the complexity of the formation, and the operator's risk tolerance. Higher uncertainty may warrant a higher safety factor.

Can a mud weight that prevents collapse also cause formation damage?

Yes. If the mud weight is too high, it can exceed the fracture gradient, leading to lost circulation (mud escaping into the formation) and potential formation damage. The calculation aims to find a balance within the safe drilling window.

How is the fracture gradient typically determined?

The fracture gradient is often estimated from well logs (e.g., leak-off tests, sonic logs), offset well data, or regional geological studies. It represents the pressure at which new fractures can be opened or existing ones enlarged.

Does the wellbore trajectory affect the collapse pressure calculation?

While this calculator uses True Vertical Depth (TVD) for hydrostatic pressure, complex wellbore trajectories (horizontal, highly deviated) can introduce additional stresses and affect wellbore stability. Advanced analysis is needed for these cases.

What happens if the required mud weight equals the fracture gradient?

If the required mud weight is equal to or very close to the fracture gradient, the drilling window is extremely narrow. This poses a high risk of fracturing the formation. In such situations, operators may consider techniques like underbalanced drilling or advanced mud systems.

Is collapse pressure the same as pore pressure?

Collapse pressure is related to the effective stress state of the rock, which is influenced by pore pressure, overburden stress, and horizontal stresses. Pore pressure is a critical component, but not the sole determinant of collapse pressure. For simplified calculations, pore pressure is often used as a basis for determining the minimum required mud weight.

How often should mud weight be reviewed during drilling?

Mud weight should be reviewed frequently, especially when drilling through formations with varying pressures, encountering suspected kicks, or experiencing losses. Real-time monitoring and adjustments are crucial, informed by continuous drilling fluid monitoring.

© 2023 Your Company Name. All rights reserved.

Disclaimer: This calculator and information are for educational and estimation purposes only. Consult with qualified professionals for actual drilling operations.

var formationPressureInput = document.getElementById('formationPressure'); var fracturePressureInput = document.getElementById('fracturePressure'); var tvdInput = document.getElementById('tvd'); var safetyFactorInput = document.getElementById('safetyFactor'); var primaryResultDiv = document.getElementById('primaryResult'); var requiredMudWeightDiv = document.getElementById('requiredMudWeight'); var collapsePressureDiv = document.getElementById('collapsePressure'); var porePressureAtTvdDiv = document.getElementById('porePressureAtTVD'); var assumptionTvdDiv = document.getElementById('assumptionTvd'); var assumptionSafetyFactorDiv = document.getElementById('assumptionSafetyFactor'); var resultsSection = document.getElementById('resultsSection'); // Table elements var tablePpValue = document.getElementById('tablePpValue'); var tableGfValue = document.getElementById('tableGfValue'); var tableTvdValue = document.getElementById('tableTvdValue'); var tableSfValue = document.getElementById('tableSfValue'); var tableMwValue = document.getElementById('tableMwValue'); var tablePcValue = document.getElementById('tablePcValue'); // Chart elements var ctx = document.getElementById('mudWeightChart').getContext('2d'); var mudWeightChart; // Declare chart variable // Error message elements var formationPressureError = document.getElementById('formationPressureError'); var fracturePressureError = document.getElementById('fracturePressureError'); var tvdError = document.getElementById('tvdError'); var safetyFactorError = document.getElementById('safetyFactorError'); var defaultValues = { formationPressure: 6500, fracturePressure: 14000, // This represents equivalent mud weight in ppg for comparison tvd: 10000, safetyFactor: 1.1 }; function validateInput(value, id, errorElement, minValue, maxValue, label, unit) { var errorMsg = "; if (value === null || value === ") { errorMsg = 'This field is required.'; } else { var numValue = parseFloat(value); if (isNaN(numValue)) { errorMsg = 'Please enter a valid number.'; } else { if (minValue !== null && numValue maxValue) { errorMsg = label + ' cannot be greater than ' + maxValue + ' ' + unit + '.'; } } } if (errorElement) { errorElement.textContent = errorMsg; errorElement.style.display = errorMsg ? 'block' : 'none'; } return !errorMsg; // Return true if valid, false otherwise } function calculateCollapsePressure() { var pp = parseFloat(formationPressureInput.value); var gf_psi_per_1000ft = parseFloat(fracturePressureInput.value); // Assuming input is psi/1000ft var tvd = parseFloat(tvdInput.value); var sf = parseFloat(safetyFactorInput.value); var isValid = true; isValid &= validateInput(formationPressureInput.value, 'formationPressure', formationPressureError, 0, null, 'Formation Pore Pressure', 'psi'); // For fracture gradient, let's assume a reasonable range for psi/1000ft, e.g., 8 to 20 isValid &= validateInput(fracturePressureInput.value, 'fracturePressure', fracturePressureError, 8, 20, 'Fracture Gradient', 'psi/1000ft'); isValid &= validateInput(tvdInput.value, 'tvd', tvdError, 1, null, 'True Vertical Depth', 'ft'); isValid &= validateInput(safetyFactorInput.value, 'safetyFactor', safetyFactorError, 1.0, 2.0, 'Safety Factor', "); if (!isValid) { resultsSection.style.display = 'none'; return; } // Calculations var collapsePressurePsi = pp; // Simplified: Collapse pressure is approximated by pore pressure // Convert fracture gradient to equivalent mud weight in ppg if it was given in psi/1000ft var fractureMudWeightPpg = gf_psi_per_1000ft; // Assuming input was already ppg equivalent // Calculate required mud weight var requiredMudWeightPpg = (pp * sf) / (tvd * 0.052); // Check against fracture gradient var wellboreStable = requiredMudWeightPpg <= fractureMudWeightPpg; // Display Results primaryResultDiv.innerHTML = "Required Mud Weight: " + requiredMudWeightPpg.toFixed(2) + " ppg"; requiredMudWeightDiv.innerHTML = "Required MW: " + requiredMudWeightPpg.toFixed(2) + " ppg"; collapsePressureDiv.innerHTML = "Collapse Pressure (Approx.): " + collapsePressurePsi.toFixed(0) + " psi"; porePressureAtTvdDiv.innerHTML = "Formation Pore Pressure: " + pp.toFixed(0) + " psi"; assumptionTvdDiv.innerHTML = "Key Assumption: TVD = " + tvd.toFixed(0) + " ft"; assumptionSafetyFactorDiv.innerHTML = "Key Assumption: Safety Factor = " + sf.toFixed(1); // Update table tablePpValue.textContent = pp.toFixed(0); tableGfValue.textContent = gf_psi_per_1000ft.toFixed(1); // Display input as is tableTvdValue.textContent = tvd.toFixed(0); tableSfValue.textContent = sf.toFixed(1); tableMwValue.textContent = requiredMudWeightPpg.toFixed(2); tablePcValue.textContent = collapsePressurePsi.toFixed(0); resultsSection.style.display = 'block'; updateChart(tvd, pp, fractureMudWeightPpg, requiredMudWeightPpg); } function resetCalculator() { formationPressureInput.value = defaultValues.formationPressure; fracturePressureInput.value = defaultValues.fracturePressure; tvdInput.value = defaultValues.tvd; safetyFactorInput.value = defaultValues.safetyFactor; // Clear errors formationPressureError.textContent = "; fracturePressureError.textContent = "; tvdError.textContent = "; safetyFactorError.textContent = "; formationPressureError.style.display = 'none'; fracturePressureError.style.display = 'none'; tvdError.style.display = 'none'; safetyFactorError.style.display = 'none'; resultsSection.style.display = 'none'; if (mudWeightChart) { mudWeightChart.destroy(); // Destroy existing chart if it exists } } function copyResults() { var textToCopy = "Collapse Pressure Calculation Results:\n\n"; textToCopy += "Primary Result:\n" + primaryResultDiv.innerText + "\n\n"; textToCopy += "Intermediate Values:\n" + requiredMudWeightDiv.innerText + "\n" + collapsePressureDiv.innerText + "\n" + porePressureAtTvdDiv.innerText + "\n\n"; textToCopy += "Key Assumptions:\n" + assumptionTvdDiv.innerText + "\n" + assumptionSafetyFactorDiv.innerText + "\n\n"; textToCopy += "Formula Used: The hydrostatic pressure of the mud must exceed the formation pore pressure multiplied by a safety factor to prevent wellbore collapse. This calculator determines the required mud weight (MW) using: MW = (Pp * SF) / (TVD * 0.052)."; navigator.clipboard.writeText(textToCopy).then(function() { // Optionally show a confirmation message var tempAlert = document.createElement('div'); tempAlert.style.position = 'fixed'; tempAlert.style.bottom = '20px'; tempAlert.style.left = '50%'; tempAlert.style.transform = 'translateX(-50%)'; tempAlert.style.backgroundColor = '#28a745'; tempAlert.style.color = 'white'; tempAlert.style.padding = '10px 20px'; tempAlert.style.borderRadius = '5px'; tempAlert.style.zIndex = '10000'; tempAlert.innerText = 'Results copied successfully!'; document.body.appendChild(tempAlert); setTimeout(function() { tempAlert.remove(); }, 2000); }).catch(function(err) { console.error('Failed to copy text: ', err); // Optionally show an error message }); } function updateChart(tvd, pp, gf_ppg, mw_req) { // Destroy previous chart instance if it exists if (mudWeightChart) { mudWeightChart.destroy(); } // Define relevant depths for the chart. Let's use TVD and a point slightly shallower. var depth1 = tvd; var depth2 = tvd * 0.8; // Example: 80% of TVD var porePressureAtDepth1 = pp; var porePressureAtDepth2 = pp * (depth2 / tvd); // Assume linear pressure increase with depth // We use the calculated required mud weight and fracture gradient at TVD var requiredMwAtDepth1 = mw_req; var requiredMwAtDepth2 = mw_req * (depth2 / tvd); // Assume linear MW requirement with depth var fractureMwAtDepth1 = gf_ppg; var fractureMwAtDepth2 = gf_ppg * (depth2 / tvd); // Assume linear fracture gradient with depth mudWeightChart = new Chart(ctx, { type: 'line', data: { labels: ['Depth (ft)', 'Depth (ft)'], // Labels for the two data points datasets: [ { label: 'Formation Pore Pressure (psi)', data: [ { x: depth2, y: porePressureAtDepth2 }, { x: depth1, y: porePressureAtDepth1 } ], borderColor: '#004a99', // Primary blue backgroundColor: 'rgba(0, 74, 153, 0.1)', fill: false, tension: 0.1, pointRadius: 5 }, { label: 'Required Mud Weight (ppg)', data: [ { x: depth2, y: requiredMwAtDepth2 }, { x: depth1, y: requiredMwAtDepth1 } ], borderColor: '#28a745', // Success green backgroundColor: 'rgba(40, 167, 69, 0.1)', fill: false, tension: 0.1, pointRadius: 5 }, { label: 'Fracture Gradient (ppg)', data: [ { x: depth2, y: fractureMwAtDepth2 }, { x: depth1, y: fractureMwAtDepth1 } ], borderColor: '#dc3545', // Danger red backgroundColor: 'rgba(220, 53, 69, 0.1)', fill: false, tension: 0.1, pointRadius: 5 } ] }, options: { responsive: true, maintainAspectRatio: false, scales: { x: { type: 'linear', position: 'bottom', title: { display: true, text: 'True Vertical Depth (ft)', color: '#004a99', font: { size: 14 } }, ticks: { callback: function(value, index, ticks) { // Format depth for better readability if needed, here simple display return value.toLocaleString(); } }, min: 0, // Start x-axis from 0 depth max: tvd * 1.1 // Extend slightly beyond TVD }, y: { title: { display: true, text: 'Pressure (psi) / Mud Weight (ppg)', color: '#004a99', font: { size: 14 } }, ticks: { callback: function(value, index, ticks) { // Combine psi and ppg for clarity, though direct comparison is based on ppg eq. // For simplicity, we'll display what's plotted. Note: Pore pressure is psi, others are ppg. // A more sophisticated chart would use dual axes or convert units. // Here, we rely on labels and context. return value.toFixed(1); } }, min: 0, // Start y-axis from 0 // Dynamically set max based on highest value for better visualization max: Math.max(pp * 1.2, gf_ppg * 1.2, mw_req * 1.2) } }, plugins: { legend: { position: 'top', }, title: { display: true, text: 'Wellbore Pressure Profile vs. Depth', font: { size: 18 }, color: '#004a99' }, tooltip: { callbacks: { label: function(context) { var label = context.dataset.label || "; if (label) { label += ': '; } if (context.parsed.y !== null) { // Distinguish based on unit (psi vs ppg) implicitly by dataset label label += context.parsed.y.toFixed(2); if (context.dataset.label.includes('Pore Pressure')) { label += ' psi'; } else { label += ' ppg'; } } return label; } } } } } }); } // Initial calculation on load (optional, or after user interaction) document.addEventListener('DOMContentLoaded', function() { calculateCollapsePressure(); // Perform initial calculation with default values });

Leave a Comment