lfm-physics 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. lfm_physics-0.1.0/.github/workflows/publish.yml +29 -0
  2. lfm_physics-0.1.0/.github/workflows/test.yml +31 -0
  3. lfm_physics-0.1.0/.gitignore +207 -0
  4. lfm_physics-0.1.0/CHANGELOG.md +58 -0
  5. lfm_physics-0.1.0/CONTRIBUTING.md +72 -0
  6. lfm_physics-0.1.0/LICENSE +21 -0
  7. lfm_physics-0.1.0/PKG-INFO +116 -0
  8. lfm_physics-0.1.0/README.md +81 -0
  9. lfm_physics-0.1.0/examples/cosmic_structure_formation.py +278 -0
  10. lfm_physics-0.1.0/examples/em_from_phase.py +111 -0
  11. lfm_physics-0.1.0/examples/parametric_resonance.py +91 -0
  12. lfm_physics-0.1.0/examples/soliton_gravity.py +64 -0
  13. lfm_physics-0.1.0/lfm/__init__.py +123 -0
  14. lfm_physics-0.1.0/lfm/analysis/__init__.py +30 -0
  15. lfm_physics-0.1.0/lfm/analysis/energy.py +159 -0
  16. lfm_physics-0.1.0/lfm/analysis/metrics.py +109 -0
  17. lfm_physics-0.1.0/lfm/analysis/structure.py +165 -0
  18. lfm_physics-0.1.0/lfm/config.py +165 -0
  19. lfm_physics-0.1.0/lfm/constants.py +179 -0
  20. lfm_physics-0.1.0/lfm/core/__init__.py +5 -0
  21. lfm_physics-0.1.0/lfm/core/backends/__init__.py +78 -0
  22. lfm_physics-0.1.0/lfm/core/backends/cupy_backend.py +203 -0
  23. lfm_physics-0.1.0/lfm/core/backends/kernel_source.py +456 -0
  24. lfm_physics-0.1.0/lfm/core/backends/numpy_backend.py +242 -0
  25. lfm_physics-0.1.0/lfm/core/backends/protocol.py +113 -0
  26. lfm_physics-0.1.0/lfm/core/evolver.py +293 -0
  27. lfm_physics-0.1.0/lfm/core/integrator.py +282 -0
  28. lfm_physics-0.1.0/lfm/core/stencils.py +99 -0
  29. lfm_physics-0.1.0/lfm/fields/__init__.py +28 -0
  30. lfm_physics-0.1.0/lfm/fields/arrangements.py +143 -0
  31. lfm_physics-0.1.0/lfm/fields/equilibrium.py +142 -0
  32. lfm_physics-0.1.0/lfm/fields/random.py +70 -0
  33. lfm_physics-0.1.0/lfm/fields/soliton.py +147 -0
  34. lfm_physics-0.1.0/lfm/formulas/__init__.py +53 -0
  35. lfm_physics-0.1.0/lfm/formulas/masses.py +208 -0
  36. lfm_physics-0.1.0/lfm/formulas/predictions.py +350 -0
  37. lfm_physics-0.1.0/lfm/io/__init__.py +1 -0
  38. lfm_physics-0.1.0/lfm/py.typed +0 -0
  39. lfm_physics-0.1.0/lfm/simulation.py +385 -0
  40. lfm_physics-0.1.0/pyproject.toml +64 -0
  41. lfm_physics-0.1.0/tests/__init__.py +0 -0
  42. lfm_physics-0.1.0/tests/conftest.py +19 -0
  43. lfm_physics-0.1.0/tests/test_analysis.py +271 -0
  44. lfm_physics-0.1.0/tests/test_backends.py +214 -0
  45. lfm_physics-0.1.0/tests/test_config.py +71 -0
  46. lfm_physics-0.1.0/tests/test_constants.py +92 -0
  47. lfm_physics-0.1.0/tests/test_evolver.py +156 -0
  48. lfm_physics-0.1.0/tests/test_fields.py +301 -0
  49. lfm_physics-0.1.0/tests/test_formulas.py +207 -0
  50. lfm_physics-0.1.0/tests/test_integrator.py +109 -0
  51. lfm_physics-0.1.0/tests/test_simulation.py +386 -0
  52. lfm_physics-0.1.0/tests/test_stencils.py +67 -0
@@ -0,0 +1,29 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ id-token: write # Required for trusted publishing
13
+
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: "3.12"
21
+
22
+ - name: Install build tools
23
+ run: pip install build
24
+
25
+ - name: Build package
26
+ run: python -m build
27
+
28
+ - name: Publish to PyPI
29
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,31 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.10", "3.11", "3.12"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install package with dev dependencies
25
+ run: pip install -e ".[dev]"
26
+
27
+ - name: Lint with ruff
28
+ run: ruff check lfm/ tests/
29
+
30
+ - name: Run tests
31
+ run: pytest --cov=lfm --cov-report=term-missing
@@ -0,0 +1,207 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
@@ -0,0 +1,58 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/).
6
+
7
+ ## [0.1.0] - 2026-03-18
8
+
9
+ ### Added
10
+
11
+ **M0 — Project scaffolding**
12
+ - Package structure with `pyproject.toml` (hatchling)
13
+ - CI/CD: GitHub Actions for testing (Python 3.10-3.12) and PyPI publishing
14
+ - MIT license, `.gitignore`, `py.typed` marker
15
+
16
+ **M1 — Constants & Config**
17
+ - `lfm.constants` — All LFM fundamental constants derived from chi_0 = 19
18
+ - `lfm.config` — `SimulationConfig` dataclass with CFL validation
19
+ - `FieldLevel` and `BoundaryType` enums
20
+
21
+ **M2 — Core numerics**
22
+ - `lfm.core.stencils` — 7-point and 19-point isotropic Laplacian operators
23
+ - `lfm.core.integrator` — Leapfrog time integration (GOV-01 + GOV-02)
24
+ - Supports REAL, COMPLEX, and COLOR field levels
25
+
26
+ **M3 — Backend system**
27
+ - `lfm.core.backends.protocol` — Backend Protocol (runtime-checkable)
28
+ - `lfm.core.backends.numpy_backend` — CPU backend (NumPy)
29
+ - `lfm.core.backends.cupy_backend` — GPU backend (CuPy + CUDA kernels)
30
+ - Auto-detect GPU with graceful CPU fallback
31
+
32
+ **M4 — Evolver & Fields**
33
+ - `lfm.core.evolver` — Double-buffered evolution loop
34
+ - `lfm.fields.soliton` — Gaussian soliton placement with phase
35
+ - `lfm.fields.equilibrium` — FFT Poisson equilibration (GOV-04)
36
+ - `lfm.fields.random` — Random noise seeding
37
+ - `lfm.fields.arrangements` — Spatial distribution helpers
38
+
39
+ **M5 — Analysis**
40
+ - `lfm.analysis.energy` — 3-component energy decomposition (kinetic, gradient, potential)
41
+ - `lfm.analysis.structure` — Well/void fraction, cluster counting, interior mask
42
+ - `lfm.analysis.metrics` — All-in-one snapshot telemetry
43
+
44
+ **M6 — Formulas**
45
+ - `lfm.formulas.predictions` — 41+ physics predictions from chi_0 = 19
46
+ - `lfm.formulas.masses` — Complete particle mass table (leptons, quarks, bosons)
47
+
48
+ **M7 — Simulation facade**
49
+ - `lfm.Simulation` — High-level API: place_soliton, equilibrate, run, metrics
50
+ - Callback support for monitoring long runs
51
+ - Metric history recording
52
+ - Checkpoint save/load for resumable simulations
53
+
54
+ **Examples**
55
+ - `examples/cosmic_structure_formation.py` — 256^3 universe simulation
56
+ - `examples/soliton_gravity.py` — Single soliton in a chi well
57
+ - `examples/em_from_phase.py` — Coulomb force from wave phase interference
58
+ - `examples/parametric_resonance.py` — Matter creation from oscillating chi
@@ -0,0 +1,72 @@
1
+ # Contributing to lfm-physics
2
+
3
+ Thanks for your interest! Here's how to get started.
4
+
5
+ ## Development Setup
6
+
7
+ ```bash
8
+ git clone https://github.com/gpartin/lfm-physics.git
9
+ cd lfm-physics
10
+ pip install -e ".[dev]"
11
+ ```
12
+
13
+ ## Running Tests
14
+
15
+ ```bash
16
+ pytest # full suite
17
+ pytest tests/test_config.py # single module
18
+ pytest -x # stop on first failure
19
+ ```
20
+
21
+ ## Code Style
22
+
23
+ We use [Ruff](https://docs.astral.sh/ruff/) for linting:
24
+
25
+ ```bash
26
+ ruff check lfm/ tests/
27
+ ruff format lfm/ tests/ # auto-format
28
+ ```
29
+
30
+ - Line length: 100 characters
31
+ - Target: Python 3.10+
32
+ - All public functions need type hints and docstrings
33
+
34
+ ## Pull Requests
35
+
36
+ 1. Fork the repo and create a feature branch
37
+ 2. Add tests for any new functionality
38
+ 3. Ensure `pytest` and `ruff check` pass
39
+ 4. Open a PR against `main`
40
+
41
+ ## Physics Guidelines
42
+
43
+ - **GOV-01 and GOV-02 are the only governing equations** — never inject external physics
44
+ - All constants must derive from `CHI0 = 19` (see `lfm/constants.py`)
45
+ - New predictions go in `lfm/formulas/predictions.py` with measured values and error percentages
46
+ - Use the 19-point stencil for Laplacians (not 7-point) unless benchmarking
47
+
48
+ ## Project Structure
49
+
50
+ ```
51
+ lfm/
52
+ constants.py # Fundamental constants from chi_0 = 19
53
+ config.py # SimulationConfig dataclass
54
+ simulation.py # High-level Simulation facade
55
+ core/
56
+ backends/ # CPU (NumPy) and GPU (CuPy) implementations
57
+ evolver.py # Double-buffered evolution loop
58
+ integrator.py # Leapfrog GOV-01 + GOV-02
59
+ stencils.py # 19-point isotropic Laplacian
60
+ fields/ # Soliton placement, equilibration, noise
61
+ formulas/ # Analytic predictions and mass tables
62
+ analysis/ # Energy, structure detection, metrics
63
+ examples/ # Runnable demo scripts
64
+ tests/ # pytest test suite
65
+ ```
66
+
67
+ ## Reporting Issues
68
+
69
+ Open a [GitHub issue](https://github.com/gpartin/lfm-physics/issues) with:
70
+ - What you expected vs what happened
71
+ - Minimal reproduction code
72
+ - Python version and OS
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Greg Partin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,116 @@
1
+ Metadata-Version: 2.4
2
+ Name: lfm-physics
3
+ Version: 0.1.0
4
+ Summary: Lattice Field Medium physics simulation library
5
+ Project-URL: Homepage, https://github.com/gpartin/lfm-physics
6
+ Project-URL: Repository, https://github.com/gpartin/lfm-physics
7
+ Project-URL: Issues, https://github.com/gpartin/lfm-physics/issues
8
+ Author-email: Greg Partin <greg@lfmphysics.org>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: field-theory,klein-gordon,lattice,physics,simulation
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Scientific/Engineering :: Physics
20
+ Requires-Python: >=3.10
21
+ Requires-Dist: numpy>=1.24
22
+ Requires-Dist: scipy>=1.10
23
+ Provides-Extra: all
24
+ Requires-Dist: cupy-cuda12x>=12.0; extra == 'all'
25
+ Requires-Dist: matplotlib>=3.7; extra == 'all'
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
28
+ Requires-Dist: pytest>=7.0; extra == 'dev'
29
+ Requires-Dist: ruff>=0.4; extra == 'dev'
30
+ Provides-Extra: gpu
31
+ Requires-Dist: cupy-cuda12x>=12.0; extra == 'gpu'
32
+ Provides-Extra: viz
33
+ Requires-Dist: matplotlib>=3.7; extra == 'viz'
34
+ Description-Content-Type: text/markdown
35
+
36
+ # lfm-physics
37
+
38
+ [![Tests](https://github.com/gpartin/lfm-physics/actions/workflows/test.yml/badge.svg)](https://github.com/gpartin/lfm-physics/actions/workflows/test.yml)
39
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue)](https://www.python.org/)
40
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
41
+
42
+ **Lattice Field Medium** — a physics simulation library implementing the LFM framework.
43
+
44
+ Two governing equations. One integer (χ₀ = 19). All of physics.
45
+
46
+ ## Install
47
+
48
+ ```bash
49
+ pip install lfm-physics
50
+ ```
51
+
52
+ For GPU acceleration (NVIDIA):
53
+ ```bash
54
+ pip install lfm-physics[gpu]
55
+ ```
56
+
57
+ ## Quick Start
58
+
59
+ ```python
60
+ import lfm
61
+
62
+ # Fundamental constants derived from χ₀ = 19
63
+ print(f"χ₀ = {lfm.CHI0}") # 19.0
64
+ print(f"κ = {lfm.KAPPA}") # 0.015873...
65
+ print(f"α = {lfm.ALPHA_EM}") # 0.007299... ≈ 1/137.088
66
+
67
+ # Create and run a simulation
68
+ config = lfm.SimulationConfig(grid_size=64, report_interval=500)
69
+ sim = lfm.Simulation(config)
70
+ sim.place_soliton((32, 32, 32), amplitude=6.0, sigma=5.0)
71
+ sim.equilibrate()
72
+ sim.run(steps=1000)
73
+
74
+ # Analyze
75
+ m = sim.metrics()
76
+ print(f"χ_min = {m['chi_min']:.2f}")
77
+ print(f"Wells = {m['well_fraction']*100:.1f}%")
78
+
79
+ # 41+ predictions from one integer
80
+ catalog = lfm.predict_all()
81
+ for name, entry in list(catalog.items())[:5]:
82
+ print(f" {name}: predicted={entry['predicted']:.6f}, "
83
+ f"measured={entry['measured']:.6f}, error={entry['error_pct']:.2f}%")
84
+ ```
85
+
86
+ ## Examples
87
+
88
+ See [`examples/`](examples/) for full working scripts:
89
+
90
+ - **[cosmic_structure_formation.py](examples/cosmic_structure_formation.py)** —
91
+ 256³ universe simulation showing spontaneous gravitational structure
92
+ (wells + voids) from GOV-01 + GOV-02 alone. Includes cosmic time
93
+ conversion, periodic snapshots, and milestone tracking.
94
+ Set `GRID_SIZE = 64` for a quick CPU test.
95
+
96
+ ## What is LFM?
97
+
98
+ The Lattice Field Medium framework derives all physics from two coupled wave equations
99
+ on a discrete 3D cubic lattice:
100
+
101
+ - **GOV-01** (Wave Equation): `∂²Ψ/∂t² = c²∇²Ψ − χ²Ψ`
102
+ - **GOV-02** (Field Equation): `∂²χ/∂t² = c²∇²χ − κ(|Ψ|² − E₀²) − 4λ_H·χ(χ² − χ₀²)`
103
+
104
+ From these two equations and χ₀ = 19 (derived from 3D lattice geometry: 1+6+12=19),
105
+ the framework predicts 41+ fundamental constants within 2% of measured values.
106
+
107
+ ## Documentation
108
+
109
+ - [API Reference](https://github.com/gpartin/lfm-physics/wiki)
110
+ - [LFM Physics Papers](https://zenodo.org/communities/lfm-physics)
111
+ - [Constants & Predictions](https://github.com/gpartin/lfm-physics/blob/main/lfm/constants.py)
112
+ - [Contributing](CONTRIBUTING.md)
113
+
114
+ ## License
115
+
116
+ MIT
@@ -0,0 +1,81 @@
1
+ # lfm-physics
2
+
3
+ [![Tests](https://github.com/gpartin/lfm-physics/actions/workflows/test.yml/badge.svg)](https://github.com/gpartin/lfm-physics/actions/workflows/test.yml)
4
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue)](https://www.python.org/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
+
7
+ **Lattice Field Medium** — a physics simulation library implementing the LFM framework.
8
+
9
+ Two governing equations. One integer (χ₀ = 19). All of physics.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ pip install lfm-physics
15
+ ```
16
+
17
+ For GPU acceleration (NVIDIA):
18
+ ```bash
19
+ pip install lfm-physics[gpu]
20
+ ```
21
+
22
+ ## Quick Start
23
+
24
+ ```python
25
+ import lfm
26
+
27
+ # Fundamental constants derived from χ₀ = 19
28
+ print(f"χ₀ = {lfm.CHI0}") # 19.0
29
+ print(f"κ = {lfm.KAPPA}") # 0.015873...
30
+ print(f"α = {lfm.ALPHA_EM}") # 0.007299... ≈ 1/137.088
31
+
32
+ # Create and run a simulation
33
+ config = lfm.SimulationConfig(grid_size=64, report_interval=500)
34
+ sim = lfm.Simulation(config)
35
+ sim.place_soliton((32, 32, 32), amplitude=6.0, sigma=5.0)
36
+ sim.equilibrate()
37
+ sim.run(steps=1000)
38
+
39
+ # Analyze
40
+ m = sim.metrics()
41
+ print(f"χ_min = {m['chi_min']:.2f}")
42
+ print(f"Wells = {m['well_fraction']*100:.1f}%")
43
+
44
+ # 41+ predictions from one integer
45
+ catalog = lfm.predict_all()
46
+ for name, entry in list(catalog.items())[:5]:
47
+ print(f" {name}: predicted={entry['predicted']:.6f}, "
48
+ f"measured={entry['measured']:.6f}, error={entry['error_pct']:.2f}%")
49
+ ```
50
+
51
+ ## Examples
52
+
53
+ See [`examples/`](examples/) for full working scripts:
54
+
55
+ - **[cosmic_structure_formation.py](examples/cosmic_structure_formation.py)** —
56
+ 256³ universe simulation showing spontaneous gravitational structure
57
+ (wells + voids) from GOV-01 + GOV-02 alone. Includes cosmic time
58
+ conversion, periodic snapshots, and milestone tracking.
59
+ Set `GRID_SIZE = 64` for a quick CPU test.
60
+
61
+ ## What is LFM?
62
+
63
+ The Lattice Field Medium framework derives all physics from two coupled wave equations
64
+ on a discrete 3D cubic lattice:
65
+
66
+ - **GOV-01** (Wave Equation): `∂²Ψ/∂t² = c²∇²Ψ − χ²Ψ`
67
+ - **GOV-02** (Field Equation): `∂²χ/∂t² = c²∇²χ − κ(|Ψ|² − E₀²) − 4λ_H·χ(χ² − χ₀²)`
68
+
69
+ From these two equations and χ₀ = 19 (derived from 3D lattice geometry: 1+6+12=19),
70
+ the framework predicts 41+ fundamental constants within 2% of measured values.
71
+
72
+ ## Documentation
73
+
74
+ - [API Reference](https://github.com/gpartin/lfm-physics/wiki)
75
+ - [LFM Physics Papers](https://zenodo.org/communities/lfm-physics)
76
+ - [Constants & Predictions](https://github.com/gpartin/lfm-physics/blob/main/lfm/constants.py)
77
+ - [Contributing](CONTRIBUTING.md)
78
+
79
+ ## License
80
+
81
+ MIT