Skip to main content
Glama

solve_navier_stokes_2d

Solve 2D incompressible Navier-Stokes with periodic boundaries via FFT spectral method and RK2. Input initial vorticity, viscosity, grid, and time span.

Instructions

Solve 2D incompressible Navier-Stokes on [0, 2*pi]^2 with periodic boundaries.

Vorticity-streamfunction form: ``omega_t + u*omega_x + v*omega_y =
nu*laplacian(omega)``, with ``laplacian(psi) = -omega``, ``u = psi_y``,
``v = -psi_x``.  The Poisson solve and all spatial derivatives use FFT
(Fourier spectral method); time integration is explicit RK2 (midpoint).
``initial_vorticity`` is a sympy expression in x and y (no Python eval).

The grid is periodic with ``nx`` x ``ny`` points and spacing
``2*pi/nx``, ``2*pi/ny``.  Before stepping, the tool requires
``nu*dt/dx^2 <= 0.5`` and ``max|u|*dt/dx <= 0.5`` (``dx`` = smaller
spacing, ``dt = t_end/nt``); otherwise it returns ``err`` and asks for a
larger ``nt``.  ``nx``/``ny`` are limited to 8..256 with
``nx*ny <= 65536``, and ``nt <= 100000``.

The full (t, y, x) vorticity history, grid and energy/enstrophy series are
saved to .npz.  Returned arrays are downsampled to at most 50 x 50 spatial
points and 20 time levels.  This is not a general CFD solver.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ntNo
nuYes
nxNo
nyNo
t_endNo
initial_vorticityNo-2*sin(x)*sin(y)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.6/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so well: it discloses the numerical method (FFT spectral Poisson solve, explicit RK2), the stability constraints (nu*dt/dx^2 <= 0.5, max|u|*dt/dx <= 0.5), the error behavior (returns err and asks for larger nt), and hard limits (nx/ny 8..256, nx*ny<=65536, nt<=100000).

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 core purpose is front-loaded in the first sentence, followed by method, constraints, and output details. The embedded PDE/FFT math is relevant to correct invocation, though the block is dense and slightly longer than strictly necessary.

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?

There is no output schema, yet the description covers return behavior thoroughly: the full (t, y, x) vorticity history plus grid and energy/enstrophy series saved to .npz, with returned arrays downsampled to at most 50x50 spatial points and 20 time levels. For a 6-parameter solver with no annotations, this is complete.

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, and it largely does: it explains initial_vorticity as a sympy expression in x and y (no Python eval), the grid spacing 2*pi/nx and 2*pi/ny, dt = t_end/nt, and the nx/ny/nt ranges. nu and t_end are only implied by the equation rather than stated directly, leaving a minor gap.

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?

States a specific verb and resource: solving 2D incompressible Navier-Stokes on a periodic [0, 2*pi]^2 domain. It clearly distinguishes itself from sibling PDE solvers (solve_heat_1d, solve_wave_1d, solve_burgers_1d, solve_laplace_2d) by naming the equation and boundary type.

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?

It specifies the applicable regime (2D incompressible, periodic boundaries) and explicitly bounds scope with 'This is not a general CFD solver.' It does not name a specific alternative sibling to use instead, so it stops short of full when/when-not routing, but the applicable conditions are clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.