Skip to content

QuackFrog/TensorDerive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TensorDerive

An automated mechanics derivation tool for tensor analysis — coupling LLM reasoning with Computer Algebra Systems (CAS) for journal-quality tensor theory derivation.

License: MIT Version Python CAS Status


Overview

TensorDerive is a specialized skill for AI coding assistants that enables automated symbolic derivation of solid mechanics, computational mechanics, and continuum mechanics theories at a level suitable for top-tier journals (JMPS, CMAME, IJSS, IJP).

The core insight: LLMs handle strategy (choosing tensor identities, constructing constitutive assumptions, designing variational frameworks), while CAS handles symbolic execution (tensor algebra, differentiation, index simplification, automatic differentiation). The two interact through a structured agent team with MCP protocol integration.

What It Derives

Domain Examples
Tensor Calculus Index notation, covariant/contravariant, Christoffel symbols, Riemann curvature
Continuum Mechanics Kinematics, stress/strain measures, balance laws, constitutive theory
Solid Mechanics Elasticity, plasticity, viscoelasticity, damage mechanics
Computational Mechanics Weak forms, FEM formulations, variational principles
Hyperelasticity Strain energy functions, stress derivation, tangent moduli

Quick Start

Minimal command (paste into your AI assistant with this skill loaded):

Derive the tangent stiffness tensor for NeoHookean hyperelastic material,
assuming near-incompressibility.

Tensor derivation:

Derive the components of the Riemann curvature tensor in spherical coordinates.
Write out the Ricci tensor and scalar curvature.

Constitutive derivation:

Derive the Cauchy stress tensor for the Arruda-Boyce 8-chain model,
and give the closed-form expression for the material tangent moduli.

Variational derivation:

Derive the weak form of the nonlinear elasticity problem in
Total Lagrangian description, and give the Newton-Raphson tangent stiffness.

Execution Flow

  1. Formalize — Convert natural language into symbolic math form (variables, tensor orders, assumptions)
  2. Strategize — Plan the derivation path, select CAS tools and operation sequences
  3. Execute — Perform tensor algebra, differentiation, simplification via CAS
  4. Verify — Cross-validate with alternative CAS paths + numerical instantiation
  5. Compile — Generate LaTeX derivation document + reproducible CAS code

Architecture

flowchart TD
    subgraph Input[" "]
        User["User Input<br/>(natural language / LaTeX)"]
    end

    subgraph Strategy["Strategy Layer (LLM Agents)"]
        A1["Identity selection"]
        A2["Decomposition"]
        A3["Hypothesis formation"]
    end

    subgraph Symbolic["Symbolic Layer (CAS Backends)"]
        B1["sympy-mcp"]
        B2["tensorgrad"]
        B3["FElupe AD"]
        B4["Wolfram Engine"]
    end

    subgraph Verification["Verification Layer"]
        C1["Cross-validation<br/>(alternative CAS)"]
        C2["Numerical validation<br/>(FElupe/numpy)"]
        C3["Dimensional analysis"]
        C4["Symmetry checks"]
    end

    subgraph Compilation["Compilation Layer"]
        D1["LaTeX derivation<br/>document"]
        D2["Reproducible CAS<br/>code archive"]
    end

    User --> Strategy
    User --> Symbolic
    Strategy --> Symbolic
    Strategy --> Verification
    Symbolic --> Verification
    Verification --> Compilation
    D1 --> Paper["academic-paper skill"]
    D2 --> Paper
Loading

Agent Team (6 Agents)

# Agent Role Phase
1 derivation-architect Strategy planning: decomposes problems into symbolic operation sequences 0
2 tensor-specialist Tensor algebra: index operations, covariant/contravariant, contractions 1
3 mechanics-specialist Solid mechanics: constitutive derivation, FElupe/FEniCS integration 1
4 verification Cross-validation, numerical instantiation, dimensional analysis 2
5 derivation-compiler Compilation: LaTeX document, CAS log, reproducible code package 3
6 cas-orchestrator CAS orchestration: manages sympy-mcp / Wolfram-MCP / FElupe sessions All

CAS Backends

Backend Scope Setup
sympy-mcp Symbolic algebra, tensor calculus (Ricci/Einstein/Weyl), vector calculus git clone https://github.com/sdiehl/sympy-mcp.git
Wolfram-MCP Arbitrary Wolfram Language, analytic/numeric integration, FullSimplify git clone https://github.com/paraporoco/Wolfram-MCP.git
FElupe Continuum mechanics FEM, constitutive AD pip install felupe[all]
tensorgrad Symbolic tensor network, auto chain rule, PyTorch codegen pip install tensorgrad

Operating Modes

Mode Trigger Output Use Case
full "derive" Full derivation doc + reproducible CAS package Clear derivation target
guided "guide my derivation" Step-by-step + Socratic discussion Uncertain derivation path
verify "verify derivation" Verification report + correction suggestions Existing derivation needs validation
quick "compute symbolically" CAS output + LaTeX only Fast symbolic computation
explore "explore constitutive" Multi-model comparison Constitutive model selection
journal "journal quality" Journal-quality derivation document Publication-ready

Directory Structure

tensorderive/
├── README.md                         # This file
├── LICENSE                           # MIT License
├── CHANGELOG.md                      # Version history
├── CONTRIBUTING.md                   # Contribution guide
├── SKILL.md                          # Main skill definition
├── agents/                           # Agent role definitions
│   ├── derivation-architect.md
│   ├── tensor-specialist.md
│   ├── mechanics-specialist.md
│   ├── verification.md
│   ├── derivation-compiler.md
│   └── cas-orchestrator.md
├── references/                       # Technical reference guides
│   ├── cas-mcp-tools.md
│   ├── felupe-integration.md
│   ├── derivation-patterns.md
│   └── sympy-tensor-guide.md
├── scripts/                          # Python bridge modules
│   ├── felupe-symbolic-bridge.py
│   └── sympy-tensor-bridge.py
├── examples/                         # Worked derivation examples
│   ├── neo-hookean-tangent.md
│   ├── mooney-rivlin-tangent.md
│   └── mcc-log-strain-tangent.md
└── docs/                             # Additional documentation
    └── architecture.md

Journal-Quality Standards

Derivations produced by this system aim to meet the standards of:

  • Journal of the Mechanics and Physics of Solids (JMPS)
  • Computer Methods in Applied Mechanics and Engineering (CMAME)
  • International Journal of Solids and Structures (IJSS)
  • International Journal of Plasticity (IJP)
  • Journal of Applied Mechanics (JAM)

Output documents satisfy:

  1. All tensor fields explicitly define their order, symmetry, and domain
  2. Constitutive derivations clearly state thermodynamic constraints (irreversibility, convexity, material objectivity)
  3. Every derivation step is reproducible line-by-line (CAS output as evidence chain)
  4. Limiting cases degenerate to classical results (e.g., finite deformation → small strain)

Prerequisites

  • Python 3.10+
  • pip install sympy felupe[all] tensorgrad hyperelastic matadi numpy
  • Optional: Wolfram Mathematica / Wolfram Engine for Wolfram-MCP
  • Optional: git clone https://github.com/sdiehl/sympy-mcp.git for sympy-mcp server

Related Skills

This skill integrates with the broader academic research pipeline:

  • academic-paper — LaTeX paper generation from derivation outputs
  • deep-research — systematic literature search and theory background
  • academic-pipeline — end-to-end research-to-publication orchestration

Contributing

See CONTRIBUTING.md. Derivations in new mechanics domains, additional CAS backend integrations, and verification pattern contributions are welcome.

License

MIT — see LICENSE for details.

About

An automated mechanics derivation tool for tensor analysis — coupling LLM reasoning with Computer Algebra Systems (CAS) for journal-quality tensor theory derivation.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages