Skip to main content
Glama
gabrielserrao

pyResToolbox MCP Server

gas_sg_from_composition

Calculate gas specific gravity from hydrocarbon molecular weight and non-hydrocarbon mole fractions using molecular weight weighted average method for compositional gas characterization.

Instructions

Calculate gas specific gravity from composition.

COMPOSITIONAL GAS CHARACTERIZATION - Computes gas specific gravity from hydrocarbon molecular weight and non-hydrocarbon mole fractions. Uses molecular weight weighted average method. Essential when gas composition is known but SG measurement is unavailable or unreliable.

Parameters:

  • hc_mw (float, required): Hydrocarbon molecular weight in lb/lbmol. Valid: 10-200. Typical: 16-50. Example: 18.5 for typical natural gas.

  • co2 (float, optional, default=0.0): CO2 mole fraction (0-1). Typical: 0-0.20. Example: 0.05 for 5% CO2.

  • h2s (float, optional, default=0.0): H2S mole fraction (0-1). Typical: 0-0.05. Example: 0.02 for 2% H2S (sour gas).

  • n2 (float, optional, default=0.0): N2 mole fraction (0-1). Typical: 0-0.10. Example: 0.01 for 1% N2.

  • h2 (float, optional, default=0.0): H2 mole fraction (0-1). Typical: 0-0.01. Example: 0.0 (rare in natural gas).

Calculation Method: Weighted average based on molecular weights:

  • HC fraction: User-provided MW (hc_mw)

  • CO2: MW = 44.01 lb/lbmol

  • H2S: MW = 34.08 lb/lbmol

  • N2: MW = 28.01 lb/lbmol

  • H2: MW = 2.02 lb/lbmol

  • Air: MW = 28.97 lb/lbmol (reference for SG)

Formula: MW_avg = hc_fraction × hc_mw + co2 × 44.01 + h2s × 34.08 + n2 × 28.01 + h2 × 2.02 SG = MW_avg / 28.97

Typical Hydrocarbon MW:

  • Pure methane: 16.04

  • Dry gas (C1-C2): 16-18

  • Associated gas (C1-C4): 18-25

  • Wet gas (C1-C6): 25-35

  • Condensate gas: 35-50

Applications:

  • Compositional Simulation: Convert composition to SG for black oil models

  • Gas Plant Feed: Characterize feed gas from composition analysis

  • Sales Gas Specs: Calculate SG for pipeline specifications

  • Contaminated Gas: Analyze gas with high non-hydrocarbon content

  • Laboratory Data: Convert GC analysis to SG

Non-Hydrocarbon Effects:

  • CO2 increases SG (MW=44.01 > air MW=28.97)

  • H2S increases SG (MW=34.08 > air MW=28.97)

  • N2 slightly decreases SG (MW=28.01 ≈ air MW=28.97)

  • H2 significantly decreases SG (MW=2.02 << air MW=28.97)

Returns: Dictionary with:

  • gas_specific_gravity (float): Gas SG (dimensionless, air=1)

  • composition (dict): Detailed composition breakdown

    • hydrocarbon_fraction: Mole fraction of hydrocarbons

    • hydrocarbon_mw: Provided hydrocarbon MW

    • co2_fraction: CO2 mole fraction

    • h2s_fraction: H2S mole fraction

    • n2_fraction: N2 mole fraction

    • h2_fraction: H2 mole fraction

  • method (str): "Molecular weight weighted average"

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

  • inputs (dict): Echo of input parameters

Common Mistakes:

  • Using weight fraction instead of mole fraction

  • Incorrect hydrocarbon MW (must be average MW of HC fraction)

  • Mole fractions don't sum to 1.0 (should sum to 1.0)

  • Using component MW instead of mixture MW for hydrocarbons

  • Not accounting for all non-hydrocarbon components

Example Usage:

{
    "hc_mw": 18.5,
    "co2": 0.05,
    "h2s": 0.0,
    "n2": 0.01,
    "h2": 0.0
}

Result: SG ≈ 0.65-0.70 (typical natural gas with 5% CO2, 1% N2).

Note: Mole fractions must sum to 1.0. If only HC fraction is provided, ensure hc_fraction = 1.0 - (co2 + h2s + n2 + h2). Hydrocarbon MW should be the average MW of the hydrocarbon fraction, not individual component MW.

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 fully discloses behavioral traits. It explains the calculation method in detail, includes typical values and ranges, describes non-hydrocarbon effects on SG, specifies the return structure, and warns about common mistakes and constraints (e.g., 'Mole fractions must sum to 1.0').

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

Conciseness3/5

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

The description is well-structured with clear sections but is overly verbose for a tool description. While all content is valuable, it includes extensive details like the full formula, typical hydrocarbon MW ranges, and multiple application examples that could be condensed. It's front-loaded with purpose, but later sections add bulk.

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 complexity of the calculation, no annotations, and an output schema (implied by the 'Returns' section), the description is highly complete. It covers purpose, usage, parameters, method, outputs, examples, and pitfalls, leaving no gaps for an AI agent to understand and invoke the tool correctly.

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, which it does excellently. It provides detailed parameter semantics: purpose, units, valid ranges, typical values, examples, and contextual meaning (e.g., 'hc_mw' as 'average MW of the hydrocarbon fraction, not individual component MW'). This goes far beyond what a bare schema would offer.

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 composition' using a specific method ('molecular weight weighted average'). It distinguishes from siblings like 'gas_sg_from_gradient' and 'weighted_average_gas_sg' by emphasizing compositional input rather than gradient or averaging of multiple SG values.

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 when gas composition is known but SG measurement is unavailable or unreliable.' It also lists specific applications (e.g., 'Compositional Simulation,' 'Gas Plant Feed') and provides guidance on when not to use it via 'Common Mistakes' (e.g., 'Using weight fraction instead of mole fraction').

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