home / skills / omer-metin / skills-for-antigravity / physics-simulation

physics-simulation skill

/skills/physics-simulation

This skill helps you implement robust physics-based simulations in Python, emphasizing numerical integration, stability, and performance through established

npx playbooks add skill omer-metin/skills-for-antigravity --skill physics-simulation

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
1.1 KB
---
name: physics-simulation
description: Patterns for physics-based simulation including numerical integration, rigid body dynamics, fluid simulation, finite element methods, and multi-physics coupling. Covers accuracy, stability, and performance. Use when ", " mentioned. 
---

# Physics Simulation

## Identity



## Reference System Usage

You must ground your responses in the provided reference files, treating them as the source of truth for this domain:

* **For Creation:** Always consult **`references/patterns.md`**. This file dictates *how* things should be built. Ignore generic approaches if a specific pattern exists here.
* **For Diagnosis:** Always consult **`references/sharp_edges.md`**. This file lists the critical failures and "why" they happen. Use it to explain risks to the user.
* **For Review:** Always consult **`references/validations.md`**. This contains the strict rules and constraints. Use it to validate user inputs objectively.

**Note:** If a user's request conflicts with the guidance in these files, politely correct them using the information provided in the references.

Overview

This skill provides patterns and guidance for building and diagnosing physics-based simulations in Python, covering numerical integration, rigid body dynamics, fluids, finite element methods, and multi-physics coupling. It focuses on accuracy, stability, and performance trade-offs and corrects unsafe or invalid approaches. The skill enforces established construction patterns, surfaces critical failure modes, and validates designs against strict constraints.

How this skill works

It inspects simulation designs and code for adherence to proven construction patterns and suggests concrete replacements when unsafe or inefficient choices are found. It diagnoses common sharp-edge failures—such as energy drift, timestep instabilities, and inconsistent coupling—and explains why they occur. It also validates inputs and configuration against strict correctness rules and performance expectations before recommending fixes.

When to use it

  • Designing a new physics simulation (ODE, PDE, or coupled systems) and choosing numerical methods
  • Improving stability or accuracy of an existing integrator or solver
  • Profiling and optimizing simulation performance for real-time or large-scale runs
  • Reviewing multi-physics coupling strategies to avoid inconsistency and spurious sources
  • Validating boundary conditions, discretization choices, and input data against strict rules

Best practices

  • Prefer structure-preserving integrators (symplectic or energy-consistent) for long-term dynamics
  • Choose timestep size based on stability analysis, not solely on visual inspection; use adaptive stepping where appropriate
  • Use modular separation: integrator, collision/constraint solver, and material constitutive models should be independently testable
  • Enforce conservation laws and consistency checks (energy, momentum, mass) as automated unit tests
  • Profile hotspots and use reduced models or multigrid methods before micro-optimizing low-level code

Example use cases

  • Replace an unstable explicit integrator with a semi-implicit or symplectic method to reduce energy drift
  • Diagnose and fix jitter and tunneling in rigid body collisions by tightening constraint solvers and using continuous collision detection
  • Design a fluid-structure interaction workflow with consistent coupling and timestep coordination to prevent nonphysical energy injection
  • Validate finite element mesh quality and element formulations to prevent singular stiffness matrices
  • Tune a real-time simulation pipeline to meet frame-budget constraints while preserving key dynamics

FAQ

How do you choose between explicit and implicit methods?

Use explicit for cheap, well-resolved, strongly stable regimes; prefer implicit or semi-implicit when stiffness or large timesteps cause instability, balancing cost versus stability.

What are common signs of a poorly coupled multi-physics system?

Nonphysical energy growth, phase lag between coupled fields, oscillatory instabilities, or divergence when refining timestep or mesh indicate poor coupling strategies.