Skip to main content

Resonant Fractal Nature Theory (TNFR) - Computational engine for modeling coherent patterns through resonance dynamics

Project description

TNFR: Resonant Fractal Nature Theory

DOI PyPI version Python 3.10+ License: MIT

A mathematical framework for modeling coherent patterns in complex systems through resonance-based dynamics.

pip install tnfr

Core Ideas

All systems evolve via the nodal equation:

$$\frac{\partial \text{EPI}}{\partial t} = \nu_f \cdot \Delta\text{NFR}(t)$$

Structural changes occur exclusively through 13 canonical operators (AL, EN, IL, OZ, UM, RA, SHA, VAL, NUL, THOL, ZHIR, NAV, REMESH) governed by unified grammar rules U1-U6.

System state is characterized by four structural fields — the Universal Tetrahedral Correspondence:

Constant Field Meaning
φ Φ_s Structural potential (global stability)
γ |∇φ| Phase gradient (local stress)
π K_φ Phase curvature (geometric confinement)
e ξ_C Coherence length (spatial correlations)

Complete theory: AGENTS.md


Quick Start

from tnfr.sdk import TNFR

# Create, connect, evolve
net = TNFR.create(20).ring().evolve(5)
print(net.results().summary())
# -> C=0.987, Si=0.912, N=20, E=20, rho=0.105
# Structural Field Tetrad — four canonical fields
tetrad = net.tetrad()
print(tetrad.summary())
# -> Phi_s=0.0312, |grad_phi|=0.0841, |K_phi|=0.1523, xi_C=2.3147 (N=20)
print(tetrad.is_safe())  # canonical threshold checks
# Conservation laws — Noether charge, Lyapunov stability
cons = net.conservation()
print(cons.summary())
# -> Q=1.2340, E=0.5678, dE/dt=-0.0012 (STABLE), quality=0.998
# One-shot comprehensive analysis
analysis = TNFR.analyze(net)
# Returns: coherence, tetrad, conservation, tensor_invariants,
#          emergent_fields, integrity, features
# Grammar-aware evolution (proactive U1-U6 enforcement)
net.evolve_grammar_aware(steps=10)
# Direct operator usage
import networkx as nx
from tnfr.operators.definitions import Emission, Coherence, Silence
from tnfr.metrics.coherence import compute_coherence

G = nx.erdos_renyi_graph(20, 0.2)
for node in G.nodes():
    Emission().apply(G, node)
    Coherence().apply(G, node)
    Silence().apply(G, node)

print(f"Coherence: {compute_coherence(G):.3f}")

Installation

pip install tnfr                       # stable release
pip install -e ".[dev-minimal]"        # development
pip install -e ".[test-all]"           # full test suite
pip install -e ".[compute-jax]"        # JAX backend
pip install -e ".[compute-torch]"      # PyTorch backend

Project Structure

src/tnfr/
├── operators/         # 13 canonical operators + grammar validation (56 modules)
├── physics/           # Structural fields, conservation, integrity (26 modules)
├── engines/           # Self-optimization, pattern discovery, GPU/FFT (7 modules)
├── dynamics/          # Nodal equation integration
├── riemann/           # TNFR-Riemann program (14 modules)
├── sdk/               # Simplified & Fluent API (7 modules)
│   └── simple.py      # Tetrad, conservation, grammar-aware dynamics, integrity
├── mathematics/       # Number theory, backends
├── constants/         # Canonical constants (mpmath 35-digit precision)
├── metrics/           # Coherence, Si, phase sync, telemetry
├── validation/        # Structural health monitoring
└── factorization/     # Spectral factorization workflow

examples/              # 33 sequential tutorials (01-30 + extras)
tests/                 # 1,634+ tests
theory/                # Theoretical derivations
benchmarks/            # Performance validation (14 suites)

Documentation

Resource Description
AGENTS.md Primary reference — complete TNFR theory, operators, grammar, fields
theory/UNIFIED_GRAMMAR_RULES.md U1-U6 grammar derivations from physics
theory/FUNDAMENTAL_THEORY.md Universal Tetrahedral Correspondence
docs/STRUCTURAL_FIELDS_TETRAD.md Field implementation specifications
theory/TNFR_RIEMANN_RESEARCH_NOTES.md TNFR-Riemann program
theory/GLOSSARY.md Terminology and definitions
examples/ Sequential tutorials
ARCHITECTURE.md System design
CONTRIBUTING.md Development guidelines

Testing

pytest                             # all tests (1,634+)
pytest tests/sdk/                  # SDK tests (tetrad, conservation, grammar)
pytest tests/unit/                 # unit tests
.\make.cmd smoke-tests             # smoke tests (Windows)
make smoke-tests                   # smoke tests (Unix)

Citation

@software{tnfr_python_engine,
  author = {Martinez Gamo, F. F.},
  title = {TNFR-Python-Engine: Resonant Fractal Nature Theory Implementation},
  year = {2025},
  version = {0.0.3.1},
  doi = {10.5281/zenodo.18883589},
  url = {https://github.com/fermga/TNFR-Python-Engine}
}

License

MIT — see LICENSE.md.

Links

PyPI · Issues · Discussions · Documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tnfr-0.0.3.1.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tnfr-0.0.3.1-py3-none-any.whl (1.4 MB view details)

Uploaded Python 3

File details

Details for the file tnfr-0.0.3.1.tar.gz.

File metadata

  • Download URL: tnfr-0.0.3.1.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.6

File hashes

Hashes for tnfr-0.0.3.1.tar.gz
Algorithm Hash digest
SHA256 5a2e11907fd96f8d2060152c6456edff4dbc1fa28d4048449bb26a0c5ed53173
MD5 d2a95f39c979b4da9f358806a22f1f3b
BLAKE2b-256 812c7008fc5e8ddae4c130b43cd045abd6735bb8789e4db9cbe79f8b7cbe43ce

See more details on using hashes here.

File details

Details for the file tnfr-0.0.3.1-py3-none-any.whl.

File metadata

  • Download URL: tnfr-0.0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.6

File hashes

Hashes for tnfr-0.0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 792089799f571c9e3555b5b390fc7e8d4247f29e30d96b974706ac73426900a3
MD5 44c40c8ef725f9d23471ffd735b2ee4e
BLAKE2b-256 e93008b2d2ccf99010cb92fda6e6ec4a21812363ced768fd25c892d91431322e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page