stock_tank_gas_sg
Calculate specific gravity of gas liberated from oil at atmospheric conditions for sales gas quality, flare calculations, 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 |
Input Schema (JSON Schema)
Implementation Reference
- The handler function decorated with @mcp.tool(), implementing the stock_tank_gas_sg tool logic using the oil.sg_st_gas function.@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 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:939-939 (registration)The @mcp.tool() decorator registers the stock_tank_gas_sg function as an MCP tool.@mcp.tool()