Skip to main content
Glama
gabrielserrao

pyResToolbox MCP Server

gas_sg_from_gradient

Calculate gas specific gravity from measured pressure gradient using Newton-Raphson solver for formation fluid identification and gas property verification when only gradient data is available.

Instructions

Calculate gas specific gravity from pressure gradient.

DIAGNOSTIC TOOL - Determines gas specific gravity from measured pressure gradient in a gas column. Uses standalone Newton-Raphson solver (fixed implementation) to solve the inverse problem. Essential for formation fluid identification and gas property verification when only gradient data is available.

Parameters:

  • gradient (float, required): Pressure gradient in psi/ft. Must be > 0. Typical: 0.05-0.15 psi/ft. Example: 0.1 psi/ft.

  • degf (float, required): Temperature in °F at measurement depth. Valid: -460 to 1000. Typical: 100-400°F. Example: 180.0.

  • p (float, required): Pressure in psia at measurement depth. Must be > 0. Example: 3500.0.

  • method (str, optional, default="DAK"): Z-factor method for calculation. Options: "DAK", "HY", "WYW", "BUR". DAK recommended.

Gradient Principle: Gas gradient = dP/dh = (ρg × g) / 144 = (P × MW) / (Z × R × T × 144)

Where:

  • ρg = gas density (lb/cuft)

  • MW = molecular weight = sg × 28.97 lb/lbmol

  • Z = gas compressibility factor

  • R = gas constant = 10.732 psia·ft³/(lbmol·°R)

  • T = temperature (°R = °F + 460)

Applications:

  • Formation Fluid ID: Identify gas vs oil vs water from gradient

  • Gas Density Verification: Check measured gas gravity against gradient

  • Completion Fluid Design: Design mud weight based on gas gradient

  • Wellbore Pressure Modeling: Calculate pressure profiles in gas columns

Typical Gradients:

  • Dry gas (sg=0.6): ~0.08 psi/ft

  • Associated gas (sg=0.8): ~0.11 psi/ft

  • Heavy gas (sg=1.0): ~0.14 psi/ft

Solution Method: Uses Newton-Raphson iterative solver to find sg that yields the specified gradient. This is a standalone fixed implementation that avoids upstream library bugs.

Returns: Dictionary with:

  • value (float): Gas specific gravity (dimensionless, air=1)

  • method (str): "Gradient correlation (Newton-Raphson)"

  • units (str): "dimensionless (air=1)"

  • inputs (dict): Echo of input parameters

Common Mistakes:

  • Using separator temperature instead of reservoir temperature

  • Pressure in barg/psig instead of psia (must be absolute)

  • Not accounting for non-hydrocarbon fractions (affects MW and Z)

  • Using wrong gradient units (must be psi/ft, not psi/100ft)

  • Temperature in Celsius instead of Fahrenheit

Example Usage:

{
    "gradient": 0.1,
    "degf": 180.0,
    "p": 3500.0,
    "method": "DAK"
}

Result: Gas SG ≈ 0.7-0.8 for typical natural gas gradient.

Note: This tool uses a standalone fixed implementation to avoid upstream bugs. Always use reservoir conditions (pressure and temperature at measurement depth). Gradient is sensitive to temperature - use correct temperature for accurate results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
requestYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It thoroughly explains the tool's behavior: it uses a 'Newton-Raphson iterative solver,' is a 'standalone fixed implementation' to avoid bugs, returns a dictionary with specific keys, and details sensitivity to inputs like temperature. It also covers constraints (e.g., gradient must be > 0) and typical use cases.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with sections like 'Parameters,' 'Gradient Principle,' and 'Applications,' making it easy to navigate. It is appropriately sized for a complex tool, but some sections (e.g., 'Gradient Principle' formula) are detailed and could be slightly condensed without losing clarity. Overall, it's efficient and front-loaded with key information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity, no annotations, and an output schema (implied by 'Returns' section), the description is highly complete. It covers purpose, usage, parameters, behavioral details, applications, examples, and common mistakes. The output schema is described in the 'Returns' section, ensuring the agent understands the response format without redundancy.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, so the description must compensate. It provides detailed parameter semantics: 'gradient' as pressure gradient in psi/ft with typical ranges, 'degf' as temperature in °F with valid ranges, 'p' as pressure in psia, and 'method' as Z-factor method with options and recommendations. This adds significant meaning beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Calculate gas specific gravity from pressure gradient.' It specifies the verb 'calculate' and the resource 'gas specific gravity' from 'pressure gradient,' and distinguishes it from sibling tools like 'gas_sg_from_composition' by focusing on gradient-based calculation rather than compositional analysis.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states when to use this tool: 'Essential for formation fluid identification and gas property verification when only gradient data is available.' It also provides context in the 'Applications' section, such as 'Formation Fluid ID' and 'Gas Density Verification,' and warns against common mistakes like using wrong units or temperatures, guiding proper usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gabrielserrao/pyrestoolbox-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server