Skip to main content
Glama
gabrielserrao

pyResToolbox MCP Server

oil_twu_critical_properties

Calculate critical temperature, pressure, and volume for petroleum fractions using the Twu correlation for EOS fluid characterization and phase behavior modeling.

Instructions

Calculate critical properties using Twu (1984) correlation.

CRITICAL PROPERTIES ESTIMATION - Most widely used method for estimating Tc, Pc, Vc for petroleum fractions and plus fractions.

Twu Method:

  • More accurate than older correlations (Riazi-Daubert, Kesler-Lee)

  • Uses molecular weight and specific gravity

  • Optional boiling point for improved accuracy

  • Damping factor for heavy ends

Returns:

  • Tc: Critical temperature (°R)

  • Pc: Critical pressure (psia)

  • Vc: Critical volume (cuft/lbmol)

  • Also returns: SG, Tb (if not provided)

Critical for:

  • EOS (PR, SRK) fluid characterization

  • Plus fraction splitting

  • Compositional simulation

  • Phase behavior modeling

Args: request: Molecular weight, specific gravity, optional boiling point, damping

Returns: Dictionary with all critical properties

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
requestYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function implementing the oil_twu_critical_properties tool logic. It uses the Twu correlation via pyrestoolbox.oil.oil_twu_props to compute critical properties from molecular weight, specific gravity, and damping factor.
    def oil_twu_critical_properties(request: TwuPropertiesRequest) -> dict:
        """Calculate critical properties using Twu (1984) correlation.
    
        **CRITICAL PROPERTIES ESTIMATION** - Most widely used method for
        estimating Tc, Pc, Vc for petroleum fractions and plus fractions.
    
        **Twu Method:**
        - More accurate than older correlations (Riazi-Daubert, Kesler-Lee)
        - Uses molecular weight and specific gravity
        - Optional boiling point for improved accuracy
        - Damping factor for heavy ends
    
        **Returns:**
        - Tc: Critical temperature (°R)
        - Pc: Critical pressure (psia)
        - Vc: Critical volume (cuft/lbmol)
        - Also returns: SG, Tb (if not provided)
    
        **Critical for:**
        - EOS (PR, SRK) fluid characterization
        - Plus fraction splitting
        - Compositional simulation
        - Phase behavior modeling
    
        Args:
            request: Molecular weight, specific gravity, optional boiling point, damping
    
        Returns:
            Dictionary with all critical properties
        """
        # oil_twu_props doesn't take tb as input, it calculates it
        result = oil.oil_twu_props(
            mw=request.mw,
            sg=request.sg,
            damp=request.damp
        )
    
        # result is tuple: (sg, tb, tc, pc, vc)
        return {
            "specific_gravity": float(result[0]) if not isinstance(result[0], np.ndarray) else result[0].tolist(),
            "boiling_point_degR": float(result[1]) if not isinstance(result[1], np.ndarray) else result[1].tolist(),
            "critical_temperature_degR": float(result[2]) if not isinstance(result[2], np.ndarray) else result[2].tolist(),
            "critical_pressure_psia": float(result[3]) if not isinstance(result[3], np.ndarray) else result[3].tolist(),
            "critical_volume_cuft_lbmol": float(result[4]) if not isinstance(result[4], np.ndarray) else result[4].tolist(),
            "method": "Twu (1984) correlation",
            "inputs": request.model_dump(),
            "note": "Use for plus fraction characterization and EOS modeling"
        }
  • Pydantic BaseModel defining the input schema (parameters with validation and descriptions) for the tool.
    class TwuPropertiesRequest(BaseModel):
        """Request model for Twu critical properties calculation."""
    
        mw: Union[float, List[float]] = Field(
            ..., gt=0, description="Molecular weight (lb/lbmol) - scalar or array"
        )
        sg: Union[float, List[float]] = Field(
            ..., gt=0, description="Specific gravity - scalar or array"
        )
        tb: Optional[Union[float, List[float]]] = Field(
            None, description="Boiling point (degR) - optional"
        )
        damp: float = Field(
            0.0, ge=0, le=1, description="Damping factor (0-1)"
        )
  • Registration call in the main server.py file that invokes register_oil_tools(mcp), which defines and registers the oil_twu_critical_properties tool using @mcp.tool() decorator.
    register_oil_tools(mcp)
  • The @mcp.tool() decorator immediately before the handler definition, which registers the function as an MCP tool.
    @mcp.tool()
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses that the tool performs calculations (not destructive), returns specific properties, and mentions accuracy improvements with optional boiling point and damping factor. However, it lacks details on error handling, performance characteristics, or rate limits, which would be helpful for a computational tool.

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 bold headers and bullet points, making it easy to scan. It's appropriately sized for a specialized tool, though some sections like 'Critical for:' could be more concise. Every sentence adds value, but minor trimming could improve efficiency.

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

Completeness4/5

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

Given the tool's complexity (critical property estimation), no annotations, and an output schema present, the description is fairly complete. It covers purpose, method, parameters, returns, and applications. However, it could benefit from more behavioral details (e.g., computational limits) since annotations are absent, and the output schema handles return values.

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

Parameters4/5

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

Schema description coverage is 0%, so the description must compensate. It adds meaningful context: parameters are 'Molecular weight, specific gravity, optional boiling point, damping' and explains their roles ('Uses molecular weight and specific gravity', 'Optional boiling point for improved accuracy', 'Damping factor for heavy ends'). This clarifies beyond the schema's technical definitions, though it doesn't detail array handling or default values.

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 critical properties using Twu (1984) correlation.' It specifies the exact method (Twu 1984), the properties calculated (Tc, Pc, Vc), and distinguishes it from siblings like 'gas_critical_properties' by focusing on petroleum fractions and plus fractions with the Twu method.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool: 'Most widely used method for estimating Tc, Pc, Vc for petroleum fractions and plus fractions' and 'Critical for: EOS (PR, SRK) fluid characterization, Plus fraction splitting, Compositional simulation, Phase behavior modeling.' It doesn't explicitly state when not to use it or name alternatives, but the context is sufficient for informed selection.

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