Skip to main content
Glama

pyResToolbox MCP Server

flow_fractions_from_lorenz

Generate idealized flow distributions from Lorenz coefficients to model reservoir heterogeneity for simulation, waterflood prediction, and sweep efficiency analysis.

Instructions

Generate flow fractions from Lorenz coefficient.

SYNTHETIC FLOW PROFILE - Creates idealized flow distribution matching a specified Lorenz coefficient. Generates a Lorenz curve (cumulative flow vs cumulative capacity) that honors the target heterogeneity level.

Parameters:

  • value (float, required): Target Lorenz coefficient (0-1). Must be 0 ≤ L ≤ 1. Typical: 0.2-0.7. Example: 0.5 for moderate heterogeneity.

Lorenz Curve Generation: Creates a curve showing:

  • X-axis: Cumulative storage capacity (kh fraction)

  • Y-axis: Cumulative flow capacity (flow fraction)

  • Curve shape: Determined by Lorenz coefficient

  • Points: 20 points along the curve for visualization

Curve Behavior:

  • L = 0: Straight diagonal line (perfect conformance)

  • L > 0: Curved line below diagonal (flow imbalance)

  • Higher L: More curvature, greater flow imbalance

Applications:

  • Reservoir Simulation: Generate layer properties for simulation models

  • Waterflood Prediction: Predict sweep efficiency from heterogeneity

  • Sweep Efficiency Estimation: Estimate vertical sweep from Lorenz

  • Sensitivity Analysis: Test impact of heterogeneity on performance

  • Conceptual Models: Create idealized reservoir models for studies

  • Visualization: Plot Lorenz curve to visualize heterogeneity

Returns: Dictionary with:

  • cumulative_flow_capacity (list): Y-axis values (cumulative flow fractions)

  • cumulative_storage_capacity (list): X-axis values (cumulative kh fractions)

  • lorenz_coefficient (float): Target Lorenz coefficient

  • method (str): "Generated Lorenz curve"

  • note (str): Visualization guidance

  • inputs (dict): Echo of input parameters

Common Mistakes:

  • Lorenz coefficient outside valid range (must be 0-1)

  • Confusing cumulative fractions with incremental fractions

  • Not understanding that curve represents idealized distribution

  • Using curve for non-log-normal distributions (may be inaccurate)

Example Usage:

{ "value": 0.5 }

Result: Lorenz curve with 20 points showing cumulative flow vs cumulative capacity. Curve is below diagonal, indicating flow imbalance (high-k layers produce more than their capacity fraction).

Note: This generates an idealized Lorenz curve. For actual reservoirs, use lorenz_from_flow_fractions with measured production data. The curve assumes log-normal permeability distribution. Plot cumulative flow vs cumulative storage to visualize heterogeneity.

Input Schema

NameRequiredDescriptionDefault
requestYes

Input Schema (JSON Schema)

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

Implementation Reference

  • The handler function decorated with @mcp.tool() that implements the tool logic. It generates points on the Lorenz curve by calling pyrestoolbox.layer.lorenz_2_flow_frac for 20 evenly spaced cumulative storage capacity values and returns the cumulative flow and storage capacities.
    @mcp.tool() def flow_fractions_from_lorenz(request: LorenzRequest) -> dict: """Generate flow fractions from Lorenz coefficient. **SYNTHETIC FLOW PROFILE** - Creates idealized flow distribution matching a specified Lorenz coefficient. Generates a Lorenz curve (cumulative flow vs cumulative capacity) that honors the target heterogeneity level. **Parameters:** - **value** (float, required): Target Lorenz coefficient (0-1). Must be 0 ≤ L ≤ 1. Typical: 0.2-0.7. Example: 0.5 for moderate heterogeneity. **Lorenz Curve Generation:** Creates a curve showing: - X-axis: Cumulative storage capacity (kh fraction) - Y-axis: Cumulative flow capacity (flow fraction) - Curve shape: Determined by Lorenz coefficient - Points: 20 points along the curve for visualization **Curve Behavior:** - L = 0: Straight diagonal line (perfect conformance) - L > 0: Curved line below diagonal (flow imbalance) - Higher L: More curvature, greater flow imbalance **Applications:** - **Reservoir Simulation:** Generate layer properties for simulation models - **Waterflood Prediction:** Predict sweep efficiency from heterogeneity - **Sweep Efficiency Estimation:** Estimate vertical sweep from Lorenz - **Sensitivity Analysis:** Test impact of heterogeneity on performance - **Conceptual Models:** Create idealized reservoir models for studies - **Visualization:** Plot Lorenz curve to visualize heterogeneity **Returns:** Dictionary with: - **cumulative_flow_capacity** (list): Y-axis values (cumulative flow fractions) - **cumulative_storage_capacity** (list): X-axis values (cumulative kh fractions) - **lorenz_coefficient** (float): Target Lorenz coefficient - **method** (str): "Generated Lorenz curve" - **note** (str): Visualization guidance - **inputs** (dict): Echo of input parameters **Common Mistakes:** - Lorenz coefficient outside valid range (must be 0-1) - Confusing cumulative fractions with incremental fractions - Not understanding that curve represents idealized distribution - Using curve for non-log-normal distributions (may be inaccurate) **Example Usage:** ```python { "value": 0.5 } ``` Result: Lorenz curve with 20 points showing cumulative flow vs cumulative capacity. Curve is below diagonal, indicating flow imbalance (high-k layers produce more than their capacity fraction). **Note:** This generates an idealized Lorenz curve. For actual reservoirs, use `lorenz_from_flow_fractions` with measured production data. The curve assumes log-normal permeability distribution. Plot cumulative flow vs cumulative storage to visualize heterogeneity. """ # lorenz_2_flow_frac returns a scalar flow fraction, not arrays # We need to generate a full curve, so we'll call it multiple times phih_values = np.linspace(0, 1, 20) flow_values = [layer.lorenz_2_flow_frac(lorenz=request.value, phih_frac=phi) for phi in phih_values] # Convert to lists flow_capacity = flow_values storage_capacity = phih_values.tolist() return { "cumulative_flow_capacity": flow_capacity, "cumulative_storage_capacity": storage_capacity, "lorenz_coefficient": request.value, "method": "Generated Lorenz curve", "note": "Plot cumulative flow vs storage to visualize heterogeneity", "inputs": request.model_dump(), }
  • Pydantic BaseModel defining the input schema for the tool: a single 'value' field (float, 0-1) representing the Lorenz coefficient.
    class LorenzRequest(BaseModel): """Request model for Lorenz coefficient calculation.""" value: float = Field(..., ge=0, le=1, description="Lorenz or beta value")
  • Imports the register_layer_tools function and calls it to register all layer tools (including flow_fractions_from_lorenz) with the FastMCP server instance.
    from .tools.layer_tools import register_layer_tools from .tools.library_tools import register_library_tools register_oil_tools(mcp) register_gas_tools(mcp) register_inflow_tools(mcp) register_simtools_tools(mcp) register_brine_tools(mcp) register_layer_tools(mcp)
  • The @mcp.tool() decorator registers this function as an MCP tool within the register_layer_tools context.
    @mcp.tool() def flow_fractions_from_lorenz(request: LorenzRequest) -> dict:
  • Core computation using pyrestoolbox.layer.lorenz_2_flow_frac to generate the flow fractions along the Lorenz curve.
    phih_values = np.linspace(0, 1, 20) flow_values = [layer.lorenz_2_flow_frac(lorenz=request.value, phih_frac=phi) for phi in phih_values] # Convert to lists flow_capacity = flow_values storage_capacity = phih_values.tolist() return { "cumulative_flow_capacity": flow_capacity, "cumulative_storage_capacity": storage_capacity, "lorenz_coefficient": request.value, "method": "Generated Lorenz curve", "note": "Plot cumulative flow vs storage to visualize heterogeneity", "inputs": request.model_dump(), }

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