Skip to main content
Glama

pyResToolbox MCP Server

weighted_average_gas_sg

Calculate weighted average gas specific gravity from separator stages using separator and stock tank gas properties weighted by gas-oil ratios for surface facility design and material balance.

Instructions

Calculate weighted average gas specific gravity from separator stages.

SURFACE FACILITIES CALCULATION - Combines gas gravities from separator and stock tank weighted by GORs.

Use Cases:

  • Multi-stage separation optimization

  • Surface facility design

  • Gas sales allocation

  • Material balance

Formula: sg_avg = (sg_sp * rsp + sg_st * rst) / (rsp + rst)

Returns weighted average gas SG (dimensionless, air=1).

Args: request: Separator and stock tank gas properties

Returns: Dictionary with weighted average SG and breakdown

Input Schema

NameRequiredDescriptionDefault
requestYes

Input Schema (JSON Schema)

{ "properties": { "request": { "$ref": "#/$defs/WeightedAverageGasSGRequest" } }, "required": [ "request" ], "type": "object" }

Implementation Reference

  • The core handler function for the 'weighted_average_gas_sg' tool. It uses the @mcp.tool() decorator for registration and calls pyrestoolbox.oil.sgg_wt_avg to compute the weighted average gas specific gravity based on separator and stock tank data.
    @mcp.tool() def weighted_average_gas_sg(request: WeightedAverageGasSGRequest) -> dict: """Calculate weighted average gas specific gravity from separator stages. **SURFACE FACILITIES CALCULATION** - Combines gas gravities from separator and stock tank weighted by GORs. **Use Cases:** - Multi-stage separation optimization - Surface facility design - Gas sales allocation - Material balance **Formula:** sg_avg = (sg_sp * rsp + sg_st * rst) / (rsp + rst) Returns weighted average gas SG (dimensionless, air=1). Args: request: Separator and stock tank gas properties Returns: Dictionary with weighted average SG and breakdown """ sg_avg = oil.sgg_wt_avg( sg_sp=request.sg_sp, rsp=request.rsp, sg_st=request.sg_st, rst=request.rst ) return { "weighted_average_sg": float(sg_avg), "separator_contribution": float(request.sg_sp * request.rsp / (request.rsp + request.rst)), "stock_tank_contribution": float(request.sg_st * request.rst / (request.rsp + request.rst)), "total_gor_scf_stb": float(request.rsp + request.rst), "method": "Weighted average by GOR", "units": "dimensionless (air=1)", "inputs": request.model_dump(), }
  • Pydantic model defining the input schema (parameters and validation) for the weighted_average_gas_sg tool.
    class WeightedAverageGasSGRequest(BaseModel): """Request model for weighted average gas SG calculation.""" sg_sp: float = Field(..., gt=0, description="Separator gas specific gravity") rsp: float = Field(..., ge=0, description="Separator GOR (scf/stb)") sg_st: float = Field(..., gt=0, description="Stock tank gas specific gravity") rst: float = Field(..., ge=0, description="Stock tank GOR (scf/stb)")
  • The server.py file imports register_oil_tools and calls it with the MCP instance to register all oil tools, including weighted_average_gas_sg.
    from .tools.oil_tools import register_oil_tools from .tools.gas_tools import register_gas_tools from .tools.inflow_tools import register_inflow_tools from .tools.simtools_tools import register_simtools_tools from .tools.brine_tools import register_brine_tools from .tools.layer_tools import register_layer_tools from .tools.library_tools import register_library_tools register_oil_tools(mcp)
  • The register_oil_tools function defines and registers the tool using the @mcp.tool() decorator.
    def register_oil_tools(mcp: FastMCP) -> None: """Register all oil-related tools with the MCP server.""" @mcp.tool()

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