stock_tank_gas_sg
Calculate specific gravity of gas liberated from oil at atmospheric conditions for sales quality, emissions estimation, and safety assessments.
Instructions
Calculate stock tank gas specific gravity.
Computes the specific gravity of gas liberated at stock tank conditions. This is the gas that comes out of solution when oil reaches atmospheric pressure and temperature.
Stock tank gas properties are needed for:
Sales gas quality specifications
Flare gas calculations
VOC emissions estimation
Safety assessments
Returns dimensionless specific gravity (air = 1.0).
Args: request: Stock tank gas parameters including oil properties and separator conditions
Returns: Dictionary with stock tank gas SG value(s), units, and inputs
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| request | Yes |
Implementation Reference
- The handler function decorated with @mcp.tool() that implements the core logic for calculating stock tank gas specific gravity using pyrestoolbox.oil.sg_st_gas with hardcoded estimates for separator GOR and temperature.@mcp.tool() def stock_tank_gas_sg(request: EvolvedGasSGRequest) -> dict: """Calculate stock tank gas specific gravity. Computes the specific gravity of gas liberated at stock tank conditions. This is the gas that comes out of solution when oil reaches atmospheric pressure and temperature. Stock tank gas properties are needed for: - Sales gas quality specifications - Flare gas calculations - VOC emissions estimation - Safety assessments Returns dimensionless specific gravity (air = 1.0). Args: request: Stock tank gas parameters including oil properties and separator conditions Returns: Dictionary with stock tank gas SG value(s), units, and inputs """ # Calculate stock tank gas SG # Estimate separator GOR as 90% of total rsp = 800.0 * 0.9 sg_st = oil.sg_st_gas( psp=request.psep, rsp=rsp, api=request.api, sg_sp=request.sg_g, degf_sp=100.0, # Typical separator temp ) # Convert numpy array to list for JSON serialization if isinstance(sg_st, np.ndarray): value = sg_st.tolist() else: value = float(sg_st) return { "value": value, "method": "McCain correlation", "units": "dimensionless (air=1)", "inputs": request.model_dump(), }
- Pydantic BaseModel defining the input schema (parameters and validation) for the stock_tank_gas_sg tool.class EvolvedGasSGRequest(BaseModel): """Request model for evolved gas specific gravity calculation.""" api: float = Field(..., gt=0, le=100, description="Oil API gravity (degrees)") degf: float = Field( ..., gt=-460, lt=1000, description="Temperature (degrees Fahrenheit)") sg_g: float = Field( ..., ge=0, le=3, description="Separator gas specific gravity") p: Union[float, List[float]] = Field( ..., description="Pressure (psia) - scalar or array") psep: float = Field(100.0, gt=0, description="Separator pressure (psia)") @field_validator("p") @classmethod def validate_pressure(cls, v): if isinstance(v, list): if not all(p > 0 for p in v): raise ValueError("All pressure values must be positive") else: if v <= 0: raise ValueError("Pressure must be positive") return v
- src/pyrestoolbox_mcp/tools/oil_tools.py:27-28 (registration)The registration function that defines and registers all oil tools including stock_tank_gas_sg via nested @mcp.tool() decorators.def register_oil_tools(mcp: FastMCP) -> None: """Register all oil-related tools with the MCP server."""