Skip to main content
Glama
IBM

Physics MCP Server

by IBM

calculate_damped_oscillation

Compute position and velocity of a damped harmonic oscillator at a given time, and classify the damping regime as underdamped, critically damped, or overdamped.

Instructions

Calculate damped oscillation with friction/resistance.

Real oscillators lose energy over time due to damping (air resistance,
friction). Three regimes: underdamped, critically damped, overdamped.

Args:
    mass: Mass in kg
    spring_constant: k in N/m
    damping_coefficient: b in kg/s (damping strength)
    time: Time t in seconds
    initial_position: Initial position in meters (default 1.0)
    initial_velocity: Initial velocity in m/s (default 0.0)

Returns:
    Dict containing:
        - position: x(t) in meters
        - velocity: v(t) in m/s
        - damping_ratio: ζ (zeta) = b/(2√(mk))
        - regime: "underdamped", "critically_damped", or "overdamped"

Damping regimes:
    - ζ < 1: Underdamped (oscillates, gradually decays)
    - ζ = 1: Critically damped (returns fastest without oscillating)
    - ζ > 1: Overdamped (slow return, no oscillation)

Example - Car suspension:
    result = await calculate_damped_oscillation(
        mass=300,  # kg (quarter car mass)
        spring_constant=20000,  # N/m
        damping_coefficient=2000,  # kg/s
        time=1.0
    )
    # Should be slightly underdamped for comfort

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
massYes
spring_constantYes
damping_coefficientYes
timeYes
initial_positionNo
initial_velocityNo

Implementation Reference

  • Core implementation of the damped oscillation calculator. Takes a DampedOscillationRequest, computes position and velocity for three regimes (underdamped, critically_damped, overdamped) based on damping ratio ζ = b/(2√(mk)), and returns a DampedOscillationResponse.
    def calculate_damped_oscillation(request: DampedOscillationRequest) -> DampedOscillationResponse:
        """Calculate damped oscillation with damping coefficient.
    
        Damping ratio: ζ = b / (2√(mk))
        - ζ < 1: Underdamped (oscillates)
        - ζ = 1: Critically damped (returns to equilibrium fastest)
        - ζ > 1: Overdamped (slow return, no oscillation)
    
        Args:
            request: Damped oscillation request
    
        Returns:
            Position, velocity, damping ratio, and regime
        """
        m = request.mass
        k = request.spring_constant
        b = request.damping_coefficient
        x0 = request.initial_position
        v0 = request.initial_velocity
        t = request.time
    
        omega0 = math.sqrt(k / m)  # Natural frequency
        zeta = b / (2.0 * math.sqrt(m * k))  # Damping ratio
    
        # Determine regime
        if zeta < 1.0:
            regime: Literal["underdamped", "critically_damped", "overdamped"] = "underdamped"
            omega_d = omega0 * math.sqrt(1.0 - zeta * zeta)  # Damped frequency
            exp_term = math.exp(-zeta * omega0 * t)
            x = exp_term * (
                x0 * math.cos(omega_d * t)
                + ((v0 + zeta * omega0 * x0) / omega_d) * math.sin(omega_d * t)
            )
            v = -exp_term * (
                (zeta * omega0 * x0 + omega_d * (v0 + zeta * omega0 * x0) / omega_d)
                * math.cos(omega_d * t)
                - omega_d * x0 * math.sin(omega_d * t)
            )
        elif abs(zeta - 1.0) < 1e-6:
            regime = "critically_damped"
            exp_term = math.exp(-omega0 * t)
            x = exp_term * (x0 + (v0 + omega0 * x0) * t)
            v = exp_term * (v0 - omega0 * (x0 + (v0 + omega0 * x0) * t) + (v0 + omega0 * x0))
        else:  # zeta > 1
            regime = "overdamped"
            r1 = -omega0 * (zeta + math.sqrt(zeta * zeta - 1.0))
            r2 = -omega0 * (zeta - math.sqrt(zeta * zeta - 1.0))
            c1 = (v0 - r2 * x0) / (r1 - r2)
            c2 = x0 - c1
            x = c1 * math.exp(r1 * t) + c2 * math.exp(r2 * t)
            v = c1 * r1 * math.exp(r1 * t) + c2 * r2 * math.exp(r2 * t)
    
        return DampedOscillationResponse(position=x, velocity=v, damping_ratio=zeta, regime=regime)
  • Pydantic model DampedOscillationRequest: mass, spring_constant, damping_coefficient, initial_position, initial_velocity, time.
    class DampedOscillationRequest(BaseModel):
        """Request for damped oscillation calculation."""
    
        mass: float = Field(..., description="Mass in kg", gt=0.0)
        spring_constant: float = Field(..., description="Spring constant k in N/m", gt=0.0)
        damping_coefficient: float = Field(..., description="Damping coefficient b in kg/s", ge=0.0)
        initial_position: float = Field(default=1.0, description="Initial position in meters")
        initial_velocity: float = Field(default=0.0, description="Initial velocity in m/s")
        time: float = Field(..., description="Time t in seconds", ge=0.0)
  • Pydantic model DampedOscillationResponse: position, velocity, damping_ratio, regime (underdamped/critically_damped/overdamped).
    class DampedOscillationResponse(BaseModel):
        """Response for damped oscillation calculation."""
    
        position: float = Field(..., description="Position x(t) in meters")
        velocity: float = Field(..., description="Velocity v(t) in m/s")
        damping_ratio: float = Field(..., description="Damping ratio ζ (zeta)")
        regime: Literal["underdamped", "critically_damped", "overdamped"] = Field(
            ..., description="Damping regime"
        )
  • MCP tool wrapper for calculate_damped_oscillation. Decorated with @tool, accepts individual float arguments, constructs a DampedOscillationRequest, calls the core function, and returns the response dict.
    @tool  # type: ignore[arg-type]
    async def calculate_damped_oscillation(
        mass: float,
        spring_constant: float,
        damping_coefficient: float,
        time: float,
        initial_position: float = 1.0,
        initial_velocity: float = 0.0,
    ) -> dict:
        """Calculate damped oscillation with friction/resistance.
    
        Real oscillators lose energy over time due to damping (air resistance,
        friction). Three regimes: underdamped, critically damped, overdamped.
    
        Args:
            mass: Mass in kg
            spring_constant: k in N/m
            damping_coefficient: b in kg/s (damping strength)
            time: Time t in seconds
            initial_position: Initial position in meters (default 1.0)
            initial_velocity: Initial velocity in m/s (default 0.0)
    
        Returns:
            Dict containing:
                - position: x(t) in meters
                - velocity: v(t) in m/s
                - damping_ratio: ζ (zeta) = b/(2√(mk))
                - regime: "underdamped", "critically_damped", or "overdamped"
    
        Damping regimes:
            - ζ < 1: Underdamped (oscillates, gradually decays)
            - ζ = 1: Critically damped (returns fastest without oscillating)
            - ζ > 1: Overdamped (slow return, no oscillation)
    
        Example - Car suspension:
            result = await calculate_damped_oscillation(
                mass=300,  # kg (quarter car mass)
                spring_constant=20000,  # N/m
                damping_coefficient=2000,  # kg/s
                time=1.0
            )
            # Should be slightly underdamped for comfort
        """
        from ..oscillations import DampedOscillationRequest, calculate_damped_oscillation as calc_damped
    
        request = DampedOscillationRequest(
            mass=mass,
            spring_constant=spring_constant,
            damping_coefficient=damping_coefficient,
            initial_position=initial_position,
            initial_velocity=initial_velocity,
            time=time,
        )
        response = calc_damped(request)
        return response.model_dump()
  • Registration of the damped oscillation tool via the @tool decorator (from chuk_mcp_server).
    @tool  # type: ignore[arg-type]
Behavior4/5

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

With no annotations, the description fully describes the tool's behavior: it returns position, velocity, damping ratio, and regime, and explains the three damping regimes. It does not mention side effects or performance, but for a calculation tool this is sufficient.

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 sections for Args, Returns, Damping regimes, and an Example. It is slightly verbose but every sentence adds value. Front-loaded with core purpose. Could be more concise by merging some explanations.

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

Completeness5/5

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

Given the tool's complexity (physics of damped oscillations) and the absence of an output schema, the description is complete. It explains all output fields, the damping ratio calculation, and the three regimes. The example further clarifies usage.

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

Parameters5/5

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

The input schema has no descriptions (0% coverage), but the description thoroughly explains each parameter with units and default values. It adds critical meaning beyond the schema, such as 'mass in kg' and 'damping_coefficient: damping strength', making it very helpful.

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 calculates damped oscillation with friction/resistance, defines three damping regimes, and provides an example. It distinguishes itself from siblings like calculate_simple_harmonic_motion by focusing on damping.

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

Usage Guidelines3/5

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

The description does not explicitly state when to use this tool versus alternatives like calculate_simple_harmonic_motion or calculate_projectile_with_drag. However, its detailed explanation of damping regimes implies the specific context of damped oscillators.

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/IBM/chuk-mcp-physics'

If you have feedback or need assistance with the MCP directory API, please join our Discord server