calculate_pressure_at_depth
Calculate total and gauge pressure at a given depth in a fluid, accounting for fluid density and atmospheric pressure. Useful for scuba diving, underwater engineering, and fluid statics problems.
Instructions
Calculate pressure at depth: P = P_atm + ρgh.
Hydrostatic pressure increases with depth.
Args:
depth: Depth below surface in meters
fluid_density: Fluid density in kg/m³ (water=1000, seawater=1025)
atmospheric_pressure: Pressure at surface in Pascals (default 101325)
gravity: Gravitational acceleration in m/s² (default 9.81)
Returns:
Dict containing:
- total_pressure: Total pressure in Pascals
- gauge_pressure: Pressure above atmospheric in Pascals
- pressure_atmospheres: Pressure in atmospheres (1 atm = 101325 Pa)
Example - Scuba diving at 30m:
result = await calculate_pressure_at_depth(
depth=30, # meters
fluid_density=1025, # seawater
atmospheric_pressure=101325
)
# Result: ~4 atmospheresInput Schema
| Name | Required | Description | Default |
|---|---|---|---|
| depth | Yes | ||
| fluid_density | Yes | ||
| atmospheric_pressure | No | ||
| gravity | No |
Implementation Reference
- MCP tool handler: 'calculate_pressure_at_depth' - async function decorated with @tool that receives parameters (depth, fluid_density, atmospheric_pressure, gravity) and delegates to the core calculation function.
@tool # type: ignore[arg-type] async def calculate_pressure_at_depth( depth: float, fluid_density: float, atmospheric_pressure: float = 101325.0, gravity: float = 9.81, ) -> dict: """Calculate pressure at depth: P = P_atm + ρgh. Hydrostatic pressure increases with depth. Args: depth: Depth below surface in meters fluid_density: Fluid density in kg/m³ (water=1000, seawater=1025) atmospheric_pressure: Pressure at surface in Pascals (default 101325) gravity: Gravitational acceleration in m/s² (default 9.81) Returns: Dict containing: - total_pressure: Total pressure in Pascals - gauge_pressure: Pressure above atmospheric in Pascals - pressure_atmospheres: Pressure in atmospheres (1 atm = 101325 Pa) Example - Scuba diving at 30m: result = await calculate_pressure_at_depth( depth=30, # meters fluid_density=1025, # seawater atmospheric_pressure=101325 ) # Result: ~4 atmospheres """ from ..fluid_advanced import ( PressureAtDepthRequest, calculate_pressure_at_depth as calc_pressure, ) request = PressureAtDepthRequest( depth=depth, fluid_density=fluid_density, atmospheric_pressure=atmospheric_pressure, gravity=gravity, ) response = calc_pressure(request) return response.model_dump() - Request schema: PressureAtDepthRequest (depth, fluid_density, atmospheric_pressure, gravity) and Response schema: PressureAtDepthResponse (total_pressure, gauge_pressure, pressure_atmospheres)
class PressureAtDepthRequest(BaseModel): """Request for pressure at depth calculation.""" depth: float = Field(..., description="Depth below surface in meters", ge=0.0) fluid_density: float = Field( default=1000.0, description="Fluid density in kg/m³ (water=1000)", gt=0.0 ) atmospheric_pressure: float = Field( default=101325.0, description="Atmospheric pressure in Pascals" ) gravity: float = Field(default=9.81, description="Gravitational acceleration in m/s²", gt=0.0) class PressureAtDepthResponse(BaseModel): """Response for pressure at depth.""" total_pressure: float = Field(..., description="Total pressure at depth in Pascals") gauge_pressure: float = Field(..., description="Gauge pressure (above atmospheric) in Pascals") pressure_atmospheres: float = Field(..., description="Pressure in atmospheres (atm)") - src/chuk_mcp_physics/tools/fluid.py:408-451 (registration)Registration via @tool decorator on the async function in tools/fluid.py (line 408)
@tool # type: ignore[arg-type] async def calculate_pressure_at_depth( depth: float, fluid_density: float, atmospheric_pressure: float = 101325.0, gravity: float = 9.81, ) -> dict: """Calculate pressure at depth: P = P_atm + ρgh. Hydrostatic pressure increases with depth. Args: depth: Depth below surface in meters fluid_density: Fluid density in kg/m³ (water=1000, seawater=1025) atmospheric_pressure: Pressure at surface in Pascals (default 101325) gravity: Gravitational acceleration in m/s² (default 9.81) Returns: Dict containing: - total_pressure: Total pressure in Pascals - gauge_pressure: Pressure above atmospheric in Pascals - pressure_atmospheres: Pressure in atmospheres (1 atm = 101325 Pa) Example - Scuba diving at 30m: result = await calculate_pressure_at_depth( depth=30, # meters fluid_density=1025, # seawater atmospheric_pressure=101325 ) # Result: ~4 atmospheres """ from ..fluid_advanced import ( PressureAtDepthRequest, calculate_pressure_at_depth as calc_pressure, ) request = PressureAtDepthRequest( depth=depth, fluid_density=fluid_density, atmospheric_pressure=atmospheric_pressure, gravity=gravity, ) response = calc_pressure(request) return response.model_dump() - Core calculation function: P_gauge = ρ*g*h, P_total = P_atm + P_gauge, returns PressureAtDepthResponse with total_pressure, gauge_pressure, and pressure_atmospheres
def calculate_pressure_at_depth(request: PressureAtDepthRequest) -> PressureAtDepthResponse: """Calculate pressure at depth: P = P_atm + ρgh. Args: request: Pressure at depth request Returns: Total and gauge pressure """ rho = request.fluid_density g = request.gravity h = request.depth P_atm = request.atmospheric_pressure # Gauge pressure (pressure due to fluid column) P_gauge = rho * g * h # Total pressure P_total = P_atm + P_gauge # Convert to atmospheres P_atmospheres = P_total / 101325.0 return PressureAtDepthResponse( total_pressure=P_total, gauge_pressure=P_gauge, pressure_atmospheres=P_atmospheres, ) - Imports '@tool' decorator from chuk_mcp_server for registering MCP tools
from chuk_mcp_server import tool