lfm-physics 0.2.1__tar.gz → 0.2.2__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 (88) hide show
  1. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/CHANGELOG.md +19 -0
  2. lfm_physics-0.2.2/PKG-INFO +280 -0
  3. lfm_physics-0.2.2/README.md +238 -0
  4. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/__init__.py +1 -1
  5. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/pyproject.toml +1 -1
  6. lfm_physics-0.2.1/PKG-INFO +0 -181
  7. lfm_physics-0.2.1/README.md +0 -139
  8. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/.github/workflows/publish.yml +0 -0
  9. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/.github/workflows/test.yml +0 -0
  10. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/.gitignore +0 -0
  11. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/.readthedocs.yaml +0 -0
  12. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/CONTRIBUTING.md +0 -0
  13. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/LICENSE +0 -0
  14. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/benchmarks/README.md +0 -0
  15. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/benchmarks/bench_evolver.py +0 -0
  16. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/benchmarks/bench_fields.py +0 -0
  17. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/docs/api/analysis.rst +0 -0
  18. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/docs/api/config.rst +0 -0
  19. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/docs/api/constants.rst +0 -0
  20. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/docs/api/core.rst +0 -0
  21. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/docs/api/fields.rst +0 -0
  22. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/docs/api/io.rst +0 -0
  23. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/docs/api/simulation.rst +0 -0
  24. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/docs/api/units.rst +0 -0
  25. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/docs/changelog.rst +0 -0
  26. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/docs/conf.py +0 -0
  27. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/docs/contributing.rst +0 -0
  28. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/docs/examples.md +0 -0
  29. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/docs/index.rst +0 -0
  30. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/docs/installation.md +0 -0
  31. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/docs/quickstart.md +0 -0
  32. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/docs/requirements.txt +0 -0
  33. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/examples/01_empty_space.py +0 -0
  34. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/examples/02_first_particle.py +0 -0
  35. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/examples/03_measuring_gravity.py +0 -0
  36. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/examples/04_two_bodies.py +0 -0
  37. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/examples/05_electric_charge.py +0 -0
  38. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/examples/06_dark_matter.py +0 -0
  39. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/examples/07_matter_creation.py +0 -0
  40. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/examples/08_universe.py +0 -0
  41. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/examples/09_hydrogen_atom.py +0 -0
  42. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/examples/10_hydrogen_molecule.py +0 -0
  43. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/examples/11_oxygen.py +0 -0
  44. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/examples/12_fluid_dynamics.py +0 -0
  45. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/examples/13_weak_force.py +0 -0
  46. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/examples/14_strong_force.py +0 -0
  47. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/analysis/__init__.py +0 -0
  48. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/analysis/color.py +0 -0
  49. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/analysis/energy.py +0 -0
  50. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/analysis/metrics.py +0 -0
  51. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/analysis/observables.py +0 -0
  52. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/analysis/structure.py +0 -0
  53. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/config.py +0 -0
  54. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/constants.py +0 -0
  55. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/core/__init__.py +0 -0
  56. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/core/backends/__init__.py +0 -0
  57. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/core/backends/cupy_backend.py +0 -0
  58. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/core/backends/kernel_source.py +0 -0
  59. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/core/backends/numpy_backend.py +0 -0
  60. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/core/backends/protocol.py +0 -0
  61. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/core/evolver.py +0 -0
  62. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/core/integrator.py +0 -0
  63. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/core/stencils.py +0 -0
  64. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/fields/__init__.py +0 -0
  65. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/fields/arrangements.py +0 -0
  66. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/fields/equilibrium.py +0 -0
  67. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/fields/random.py +0 -0
  68. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/fields/soliton.py +0 -0
  69. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/io/__init__.py +0 -0
  70. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/py.typed +0 -0
  71. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/simulation.py +0 -0
  72. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/lfm/units.py +0 -0
  73. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/paper_experiments/why_is_c_what_it_is.py +0 -0
  74. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/tests/__init__.py +0 -0
  75. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/tests/conftest.py +0 -0
  76. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/tests/test_analysis.py +0 -0
  77. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/tests/test_backends.py +0 -0
  78. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/tests/test_config.py +0 -0
  79. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/tests/test_constants.py +0 -0
  80. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/tests/test_evolver.py +0 -0
  81. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/tests/test_fields.py +0 -0
  82. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/tests/test_integrator.py +0 -0
  83. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/tests/test_simulation.py +0 -0
  84. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/tests/test_stencils.py +0 -0
  85. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/tutorial_03_3d_lattice.png +0 -0
  86. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/tutorial_07_3d_lattice.png +0 -0
  87. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/tutorial_08_3d_lattice.png +0 -0
  88. {lfm_physics-0.2.1 → lfm_physics-0.2.2}/tutorial_12_3d_lattice.png +0 -0
@@ -4,6 +4,25 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/).
6
6
 
7
+ ## [0.2.1] - 2026-03-20
8
+
9
+ ### Added
10
+ - GOV-02 v14: color variance term `κ_c·f_c·Σ|Ψₐ|²` with `KAPPA_C = 1/189`
11
+ - GOV-01 v15: cross-color coupling `ε_cc·χ²·(Ψₐ − Ψ̄)` with `EPSILON_CC = 2/17`
12
+ - `color_variance()` analysis function for color field diagnostics
13
+ - `momentum_density()`, `weak_parity_asymmetry()`, `confinement_proxy()` observables
14
+ - `continuity_residual()`, `fluid_fields()` for hydrodynamic analysis
15
+ - Constants: `KAPPA_C`, `EPSILON_CC`, `ALPHA_S`, `N_COLORS`
16
+ - Config: `kappa_c`, `epsilon_cc`, `n_colors` parameters
17
+ - Example 13: weak force (parity asymmetry)
18
+ - Example 14: strong force (color screening and confinement proxy)
19
+ - Website tutorials 13-14 (emergentphysicslab.com)
20
+
21
+ ### Fixed
22
+ - Ruff lint: import sorting, unused imports, line lengths
23
+ - `PlanckScale` type annotation in `SimulationConfig.planck_scale`
24
+ - Version alignment between `pyproject.toml` and `__init__.py`
25
+
7
26
  ## [0.1.3] - 2026-03-19
8
27
 
9
28
  ### Added
@@ -0,0 +1,280 @@
1
+ Metadata-Version: 2.4
2
+ Name: lfm-physics
3
+ Version: 0.2.2
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 <gpartin@gmail.com>
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: benchmark
27
+ Requires-Dist: pytest-benchmark>=4.0; extra == 'benchmark'
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
30
+ Requires-Dist: pytest>=7.0; extra == 'dev'
31
+ Requires-Dist: ruff>=0.4; extra == 'dev'
32
+ Provides-Extra: docs
33
+ Requires-Dist: furo>=2024.1; extra == 'docs'
34
+ Requires-Dist: myst-parser>=2.0; extra == 'docs'
35
+ Requires-Dist: sphinx-autodoc-typehints>=1.24; extra == 'docs'
36
+ Requires-Dist: sphinx>=7.0; extra == 'docs'
37
+ Provides-Extra: gpu
38
+ Requires-Dist: cupy-cuda12x>=12.0; extra == 'gpu'
39
+ Provides-Extra: viz
40
+ Requires-Dist: matplotlib>=3.7; extra == 'viz'
41
+ Description-Content-Type: text/markdown
42
+
43
+ # lfm-physics
44
+
45
+ [![Tests](https://github.com/gpartin/lfm-physics/actions/workflows/test.yml/badge.svg)](https://github.com/gpartin/lfm-physics/actions/workflows/test.yml)
46
+ [![PyPI](https://img.shields.io/pypi/v/lfm-physics)](https://pypi.org/project/lfm-physics/)
47
+ [![Python 3.10 | 3.11 | 3.12](https://img.shields.io/pypi/pyversions/lfm-physics)](https://pypi.org/project/lfm-physics/)
48
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
49
+
50
+ **Lattice Field Medium** — a physics simulation library implementing the LFM framework.
51
+
52
+ Two governing equations. One integer (χ₀ = 19). All of physics.
53
+
54
+ LFM runs two coupled wave equations on a discrete 3D lattice.
55
+ Gravity, electromagnetism, the strong and weak forces, dark matter, and cosmic
56
+ structure all emerge from the dynamics — no forces injected, no constants
57
+ assumed. Just a grid, two update rules, and initial noise.
58
+
59
+ ## Install
60
+
61
+ ```bash
62
+ pip install lfm-physics
63
+ ```
64
+
65
+ GPU acceleration (NVIDIA, optional):
66
+ ```bash
67
+ pip install "lfm-physics[gpu]"
68
+ ```
69
+
70
+ ## Quick Start
71
+
72
+ ```python
73
+ import lfm
74
+
75
+ # 1. Create a 64³ lattice — empty space has χ = 19 everywhere
76
+ sim = lfm.Simulation(lfm.SimulationConfig(grid_size=64))
77
+
78
+ # 2. Drop a soliton (energy blob) onto the grid
79
+ sim.place_soliton((32, 32, 32), amplitude=6.0)
80
+
81
+ # 3. Let the substrate settle into equilibrium
82
+ sim.equilibrate()
83
+
84
+ # 4. Run the two equations for 5 000 steps
85
+ sim.run(steps=5000)
86
+
87
+ # 5. Measure what emerged
88
+ m = sim.metrics()
89
+ print(f"χ_min = {m['chi_min']:.2f}") # χ dropped — a gravity well!
90
+ print(f"Wells = {m['well_fraction']*100:.1f}%")
91
+
92
+ # 6. Look at the shape of gravity
93
+ profile = lfm.radial_profile(sim.chi, center=(32,32,32), max_radius=20)
94
+ # profile['r'] and profile['profile'] — does it fall like 1/r?
95
+ ```
96
+
97
+ ## The Equations
98
+
99
+ Everything in LFM follows from two coupled wave equations evaluated on a
100
+ 3D cubic lattice with a 19-point stencil (6 face + 12 edge neighbours):
101
+
102
+ **GOV-01** — matter wave equation (Klein-Gordon on the lattice):
103
+
104
+ ```
105
+ Ψⁿ⁺¹ = 2Ψⁿ − Ψⁿ⁻¹ + Δt²[ c²∇²Ψⁿ − (χⁿ)²Ψⁿ ]
106
+ ```
107
+
108
+ **GOV-02** — substrate field equation (complete, v14):
109
+
110
+ ```
111
+ χⁿ⁺¹ = 2χⁿ − χⁿ⁻¹ + Δt²[ c²∇²χⁿ
112
+ − κ(Σₐ|Ψₐⁿ|² + ε_W·jⁿ − E₀²) ← gravity + weak
113
+ − 4λ_H·χⁿ((χⁿ)² − χ₀²) ← Higgs self-interaction
114
+ − κ_c·f_c·Σₐ|Ψₐⁿ|² ] ← color screening
115
+ ```
116
+
117
+ | Term | Force | What it does |
118
+ |------|-------|--------------|
119
+ | `κ·Σ\|Ψ\|²` | **Gravity** | Energy density creates χ wells — waves curve toward low χ |
120
+ | `ε_W·j` | **Weak** | Momentum current j breaks parity symmetry in χ |
121
+ | `4λ_H·χ(χ²−χ₀²)` | **Higgs** | Mexican-hat potential makes χ₀ = 19 a dynamical attractor |
122
+ | `κ_c·f_c·Σ\|Ψ\|²` | **Strong** | Color variance f_c gives extra χ deepening for non-singlet states |
123
+ | Phase interference | **EM** | Same phase → constructive → repel; opposite → destructive → attract |
124
+
125
+ ### Field Levels
126
+
127
+ | Level | Field | Components | Forces | Use for |
128
+ |-------|-------|------------|--------|---------|
129
+ | `REAL` | E ∈ ℝ | 1 real | Gravity | Cosmology, dark matter |
130
+ | `COMPLEX` | Ψ ∈ ℂ | 1 complex | Gravity + EM | Atoms, charged particles |
131
+ | `COLOR` | Ψₐ ∈ ℂ³ | 3 complex | All four | Full multi-force simulations |
132
+
133
+ ```python
134
+ # Gravity-only cosmology (fastest)
135
+ cfg = lfm.SimulationConfig(grid_size=128, field_level=lfm.FieldLevel.REAL)
136
+
137
+ # Electromagnetism + gravity
138
+ cfg = lfm.SimulationConfig(grid_size=64, field_level=lfm.FieldLevel.COMPLEX)
139
+
140
+ # All four forces
141
+ cfg = lfm.SimulationConfig(grid_size=64, field_level=lfm.FieldLevel.COLOR)
142
+ ```
143
+
144
+ ### Constants — All Derived from χ₀ = 19
145
+
146
+ | Constant | Symbol | Value | Origin |
147
+ |----------|--------|-------|--------|
148
+ | `CHI0` | χ₀ | 19 | 3D lattice modes: 1 + 6 + 12 = 19 |
149
+ | `KAPPA` | κ | 1/63 ≈ 0.0159 | Unit coupling on 4³ − 1 = 63 modes |
150
+ | `LAMBDA_H` | λ_H | 4/31 ≈ 0.129 | z₂ lattice geometry |
151
+ | `EPSILON_W` | ε_W | 2/(χ₀+1) = 0.1 | Weak mixing angle factorisation |
152
+ | `KAPPA_C` | κ_c | κ/3 = 1/189 | Color variance coupling |
153
+ | `ALPHA_S` | α_s | 2/17 ≈ 0.118 | Strong coupling at M_Z |
154
+ | `EPSILON_CC` | ε_cc | 2/17 | Cross-color coupling (GOV-01 v15) |
155
+ | `ALPHA_EM` | α | 11/(480π) ≈ 1/137.1 | Fine-structure constant |
156
+ | `OMEGA_LAMBDA` | Ω_Λ | 13/19 ≈ 0.684 | Dark energy fraction |
157
+ | `OMEGA_MATTER` | Ω_m | 6/19 ≈ 0.316 | Matter fraction |
158
+
159
+ ## Examples — Build a Universe in 14 Steps
160
+
161
+ Each example builds on the one before, from empty space to a simulated cosmos:
162
+
163
+ | # | Example | What you'll see |
164
+ |---|---------|-----------------|
165
+ | 1 | [01_empty_space.py](examples/01_empty_space.py) | A grid with χ = 19 everywhere — nothing happens |
166
+ | 2 | [02_first_particle.py](examples/02_first_particle.py) | Add energy → χ drops → a gravity well appears |
167
+ | 3 | [03_measuring_gravity.py](examples/03_measuring_gravity.py) | Measure χ(r) and check for 1/r falloff |
168
+ | 4 | [04_two_bodies.py](examples/04_two_bodies.py) | Two solitons attract — gravitational interaction emerges |
169
+ | 5 | [05_electric_charge.py](examples/05_electric_charge.py) | Phase = charge: same phase repels, opposite attracts |
170
+ | 6 | [06_dark_matter.py](examples/06_dark_matter.py) | Remove matter — the χ-well persists (substrate memory) |
171
+ | 7 | [07_matter_creation.py](examples/07_matter_creation.py) | Oscillate χ at 2χ₀ — matter appears from nothing |
172
+ | 8 | [08_universe.py](examples/08_universe.py) | Random noise on 64³ → wells + voids → cosmic structure |
173
+ | 9 | [09_hydrogen_atom.py](examples/09_hydrogen_atom.py) | Proton χ-well traps an electron — energy-level ladder emerges |
174
+ | 10 | [10_hydrogen_molecule.py](examples/10_hydrogen_molecule.py) | Two H atoms bond — bonding vs anti-bonding orbitals |
175
+ | 11 | [11_oxygen.py](examples/11_oxygen.py) | Heavier nucleus (8 electrons) — deeper well, richer structure |
176
+ | 12 | [12_fluid_dynamics.py](examples/12_fluid_dynamics.py) | 40-soliton gas → Euler equation from the stress-energy tensor |
177
+ | 13 | [13_weak_force.py](examples/13_weak_force.py) | Turn ε_W on/off and measure parity asymmetry from χ + j |
178
+ | 14 | [14_strong_force.py](examples/14_strong_force.py) | Color fields — measure confinement proxy via χ line integrals |
179
+
180
+ ```bash
181
+ cd examples
182
+ python 01_empty_space.py # start here
183
+ python 08_universe.py # the payoff — cosmic structure from noise
184
+ python 14_strong_force.py # all four forces active
185
+ ```
186
+
187
+ **Interactive tutorials with visualisations:**
188
+ [emergentphysicslab.com/tutorials](https://emergentphysicslab.com/tutorials)
189
+
190
+ ## Measurement & Analysis
191
+
192
+ ```python
193
+ # Radial χ profile around a soliton
194
+ profile = lfm.radial_profile(sim.chi, center=(32,32,32), max_radius=20)
195
+
196
+ # Find the N brightest energy peaks
197
+ peaks = lfm.find_peaks(sim.energy_density, n=5)
198
+
199
+ # Track separation between two bodies over time
200
+ sep = lfm.measure_separation(sim.energy_density)
201
+
202
+ # Energy conservation drift
203
+ drift = lfm.energy_conservation_drift(sim)
204
+
205
+ # Fluid velocity from the stress-energy tensor
206
+ fields = lfm.fluid_fields(psi_real, psi_imag, chi, dt, c=1.0)
207
+ # fields['velocity_x'], fields['pressure'], fields['energy_density']
208
+
209
+ # Momentum density (Noether current — sources weak force)
210
+ j = lfm.momentum_density(psi_real, psi_imag, dx=1.0)
211
+
212
+ # Color variance (strong force diagnostic)
213
+ fc = lfm.color_variance(psi_real_color, psi_imag_color)
214
+
215
+ # Confinement proxy — χ line integral between peaks
216
+ proxy = lfm.confinement_proxy(sim.chi, pos_a, pos_b)
217
+ ```
218
+
219
+ ## Checkpoints & Units
220
+
221
+ ```python
222
+ # Save / resume a simulation
223
+ sim.save_checkpoint("my_run.npz")
224
+ sim2 = lfm.Simulation.load_checkpoint("my_run.npz")
225
+
226
+ # Map lattice ticks to physical units
227
+ scale = lfm.CosmicScale(box_mpc=100.0, grid_size=64)
228
+ print(scale.format_cosmic_time(50_000)) # "1.28 Gyr"
229
+
230
+ # Planck-resolution mode
231
+ ps = lfm.PlanckScale.at_planck_resolution(grid_size=256)
232
+ print(ps.cells_per_planck) # 1.0 exactly
233
+ ```
234
+
235
+ ## Low-Level API — Evolver
236
+
237
+ For maximum performance or custom evolution loops:
238
+
239
+ ```python
240
+ from lfm import SimulationConfig, FieldLevel, Evolver
241
+
242
+ cfg = SimulationConfig(grid_size=128, field_level=FieldLevel.COLOR)
243
+ evo = Evolver(cfg, backend="auto") # auto-selects GPU if available
244
+
245
+ # Inject initial conditions
246
+ evo.set_psi_real(my_array)
247
+ evo.set_chi(my_chi)
248
+
249
+ # Evolve 100 000 steps
250
+ evo.evolve(100_000)
251
+
252
+ # Extract fields as NumPy arrays
253
+ chi = evo.get_chi()
254
+ psi = evo.get_psi_real()
255
+ ```
256
+
257
+ ## GPU Support
258
+
259
+ The library automatically uses your NVIDIA GPU when CuPy is installed:
260
+
261
+ ```python
262
+ print(lfm.gpu_available()) # True if CuPy + CUDA detected
263
+
264
+ # Force CPU even if GPU is available
265
+ sim = lfm.Simulation(cfg, backend="cpu")
266
+ ```
267
+
268
+ Typical speedup: **50-200×** for N ≥ 64 grids on modern NVIDIA GPUs.
269
+
270
+ ## Documentation
271
+
272
+ - [Interactive Tutorials](https://emergentphysicslab.com/tutorials) — step-by-step guides with live visualisations
273
+ - [LFM Physics Papers](https://zenodo.org/communities/lfm-physics) — 84+ published papers
274
+ - [Constants Reference](https://github.com/gpartin/lfm-physics/blob/main/lfm/constants.py) — χ₀ = 19 and everything derived from it
275
+ - [Changelog](CHANGELOG.md) — version history
276
+ - [Contributing](CONTRIBUTING.md)
277
+
278
+ ## License
279
+
280
+ MIT
@@ -0,0 +1,238 @@
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
+ [![PyPI](https://img.shields.io/pypi/v/lfm-physics)](https://pypi.org/project/lfm-physics/)
5
+ [![Python 3.10 | 3.11 | 3.12](https://img.shields.io/pypi/pyversions/lfm-physics)](https://pypi.org/project/lfm-physics/)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
7
+
8
+ **Lattice Field Medium** — a physics simulation library implementing the LFM framework.
9
+
10
+ Two governing equations. One integer (χ₀ = 19). All of physics.
11
+
12
+ LFM runs two coupled wave equations on a discrete 3D lattice.
13
+ Gravity, electromagnetism, the strong and weak forces, dark matter, and cosmic
14
+ structure all emerge from the dynamics — no forces injected, no constants
15
+ assumed. Just a grid, two update rules, and initial noise.
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ pip install lfm-physics
21
+ ```
22
+
23
+ GPU acceleration (NVIDIA, optional):
24
+ ```bash
25
+ pip install "lfm-physics[gpu]"
26
+ ```
27
+
28
+ ## Quick Start
29
+
30
+ ```python
31
+ import lfm
32
+
33
+ # 1. Create a 64³ lattice — empty space has χ = 19 everywhere
34
+ sim = lfm.Simulation(lfm.SimulationConfig(grid_size=64))
35
+
36
+ # 2. Drop a soliton (energy blob) onto the grid
37
+ sim.place_soliton((32, 32, 32), amplitude=6.0)
38
+
39
+ # 3. Let the substrate settle into equilibrium
40
+ sim.equilibrate()
41
+
42
+ # 4. Run the two equations for 5 000 steps
43
+ sim.run(steps=5000)
44
+
45
+ # 5. Measure what emerged
46
+ m = sim.metrics()
47
+ print(f"χ_min = {m['chi_min']:.2f}") # χ dropped — a gravity well!
48
+ print(f"Wells = {m['well_fraction']*100:.1f}%")
49
+
50
+ # 6. Look at the shape of gravity
51
+ profile = lfm.radial_profile(sim.chi, center=(32,32,32), max_radius=20)
52
+ # profile['r'] and profile['profile'] — does it fall like 1/r?
53
+ ```
54
+
55
+ ## The Equations
56
+
57
+ Everything in LFM follows from two coupled wave equations evaluated on a
58
+ 3D cubic lattice with a 19-point stencil (6 face + 12 edge neighbours):
59
+
60
+ **GOV-01** — matter wave equation (Klein-Gordon on the lattice):
61
+
62
+ ```
63
+ Ψⁿ⁺¹ = 2Ψⁿ − Ψⁿ⁻¹ + Δt²[ c²∇²Ψⁿ − (χⁿ)²Ψⁿ ]
64
+ ```
65
+
66
+ **GOV-02** — substrate field equation (complete, v14):
67
+
68
+ ```
69
+ χⁿ⁺¹ = 2χⁿ − χⁿ⁻¹ + Δt²[ c²∇²χⁿ
70
+ − κ(Σₐ|Ψₐⁿ|² + ε_W·jⁿ − E₀²) ← gravity + weak
71
+ − 4λ_H·χⁿ((χⁿ)² − χ₀²) ← Higgs self-interaction
72
+ − κ_c·f_c·Σₐ|Ψₐⁿ|² ] ← color screening
73
+ ```
74
+
75
+ | Term | Force | What it does |
76
+ |------|-------|--------------|
77
+ | `κ·Σ\|Ψ\|²` | **Gravity** | Energy density creates χ wells — waves curve toward low χ |
78
+ | `ε_W·j` | **Weak** | Momentum current j breaks parity symmetry in χ |
79
+ | `4λ_H·χ(χ²−χ₀²)` | **Higgs** | Mexican-hat potential makes χ₀ = 19 a dynamical attractor |
80
+ | `κ_c·f_c·Σ\|Ψ\|²` | **Strong** | Color variance f_c gives extra χ deepening for non-singlet states |
81
+ | Phase interference | **EM** | Same phase → constructive → repel; opposite → destructive → attract |
82
+
83
+ ### Field Levels
84
+
85
+ | Level | Field | Components | Forces | Use for |
86
+ |-------|-------|------------|--------|---------|
87
+ | `REAL` | E ∈ ℝ | 1 real | Gravity | Cosmology, dark matter |
88
+ | `COMPLEX` | Ψ ∈ ℂ | 1 complex | Gravity + EM | Atoms, charged particles |
89
+ | `COLOR` | Ψₐ ∈ ℂ³ | 3 complex | All four | Full multi-force simulations |
90
+
91
+ ```python
92
+ # Gravity-only cosmology (fastest)
93
+ cfg = lfm.SimulationConfig(grid_size=128, field_level=lfm.FieldLevel.REAL)
94
+
95
+ # Electromagnetism + gravity
96
+ cfg = lfm.SimulationConfig(grid_size=64, field_level=lfm.FieldLevel.COMPLEX)
97
+
98
+ # All four forces
99
+ cfg = lfm.SimulationConfig(grid_size=64, field_level=lfm.FieldLevel.COLOR)
100
+ ```
101
+
102
+ ### Constants — All Derived from χ₀ = 19
103
+
104
+ | Constant | Symbol | Value | Origin |
105
+ |----------|--------|-------|--------|
106
+ | `CHI0` | χ₀ | 19 | 3D lattice modes: 1 + 6 + 12 = 19 |
107
+ | `KAPPA` | κ | 1/63 ≈ 0.0159 | Unit coupling on 4³ − 1 = 63 modes |
108
+ | `LAMBDA_H` | λ_H | 4/31 ≈ 0.129 | z₂ lattice geometry |
109
+ | `EPSILON_W` | ε_W | 2/(χ₀+1) = 0.1 | Weak mixing angle factorisation |
110
+ | `KAPPA_C` | κ_c | κ/3 = 1/189 | Color variance coupling |
111
+ | `ALPHA_S` | α_s | 2/17 ≈ 0.118 | Strong coupling at M_Z |
112
+ | `EPSILON_CC` | ε_cc | 2/17 | Cross-color coupling (GOV-01 v15) |
113
+ | `ALPHA_EM` | α | 11/(480π) ≈ 1/137.1 | Fine-structure constant |
114
+ | `OMEGA_LAMBDA` | Ω_Λ | 13/19 ≈ 0.684 | Dark energy fraction |
115
+ | `OMEGA_MATTER` | Ω_m | 6/19 ≈ 0.316 | Matter fraction |
116
+
117
+ ## Examples — Build a Universe in 14 Steps
118
+
119
+ Each example builds on the one before, from empty space to a simulated cosmos:
120
+
121
+ | # | Example | What you'll see |
122
+ |---|---------|-----------------|
123
+ | 1 | [01_empty_space.py](examples/01_empty_space.py) | A grid with χ = 19 everywhere — nothing happens |
124
+ | 2 | [02_first_particle.py](examples/02_first_particle.py) | Add energy → χ drops → a gravity well appears |
125
+ | 3 | [03_measuring_gravity.py](examples/03_measuring_gravity.py) | Measure χ(r) and check for 1/r falloff |
126
+ | 4 | [04_two_bodies.py](examples/04_two_bodies.py) | Two solitons attract — gravitational interaction emerges |
127
+ | 5 | [05_electric_charge.py](examples/05_electric_charge.py) | Phase = charge: same phase repels, opposite attracts |
128
+ | 6 | [06_dark_matter.py](examples/06_dark_matter.py) | Remove matter — the χ-well persists (substrate memory) |
129
+ | 7 | [07_matter_creation.py](examples/07_matter_creation.py) | Oscillate χ at 2χ₀ — matter appears from nothing |
130
+ | 8 | [08_universe.py](examples/08_universe.py) | Random noise on 64³ → wells + voids → cosmic structure |
131
+ | 9 | [09_hydrogen_atom.py](examples/09_hydrogen_atom.py) | Proton χ-well traps an electron — energy-level ladder emerges |
132
+ | 10 | [10_hydrogen_molecule.py](examples/10_hydrogen_molecule.py) | Two H atoms bond — bonding vs anti-bonding orbitals |
133
+ | 11 | [11_oxygen.py](examples/11_oxygen.py) | Heavier nucleus (8 electrons) — deeper well, richer structure |
134
+ | 12 | [12_fluid_dynamics.py](examples/12_fluid_dynamics.py) | 40-soliton gas → Euler equation from the stress-energy tensor |
135
+ | 13 | [13_weak_force.py](examples/13_weak_force.py) | Turn ε_W on/off and measure parity asymmetry from χ + j |
136
+ | 14 | [14_strong_force.py](examples/14_strong_force.py) | Color fields — measure confinement proxy via χ line integrals |
137
+
138
+ ```bash
139
+ cd examples
140
+ python 01_empty_space.py # start here
141
+ python 08_universe.py # the payoff — cosmic structure from noise
142
+ python 14_strong_force.py # all four forces active
143
+ ```
144
+
145
+ **Interactive tutorials with visualisations:**
146
+ [emergentphysicslab.com/tutorials](https://emergentphysicslab.com/tutorials)
147
+
148
+ ## Measurement & Analysis
149
+
150
+ ```python
151
+ # Radial χ profile around a soliton
152
+ profile = lfm.radial_profile(sim.chi, center=(32,32,32), max_radius=20)
153
+
154
+ # Find the N brightest energy peaks
155
+ peaks = lfm.find_peaks(sim.energy_density, n=5)
156
+
157
+ # Track separation between two bodies over time
158
+ sep = lfm.measure_separation(sim.energy_density)
159
+
160
+ # Energy conservation drift
161
+ drift = lfm.energy_conservation_drift(sim)
162
+
163
+ # Fluid velocity from the stress-energy tensor
164
+ fields = lfm.fluid_fields(psi_real, psi_imag, chi, dt, c=1.0)
165
+ # fields['velocity_x'], fields['pressure'], fields['energy_density']
166
+
167
+ # Momentum density (Noether current — sources weak force)
168
+ j = lfm.momentum_density(psi_real, psi_imag, dx=1.0)
169
+
170
+ # Color variance (strong force diagnostic)
171
+ fc = lfm.color_variance(psi_real_color, psi_imag_color)
172
+
173
+ # Confinement proxy — χ line integral between peaks
174
+ proxy = lfm.confinement_proxy(sim.chi, pos_a, pos_b)
175
+ ```
176
+
177
+ ## Checkpoints & Units
178
+
179
+ ```python
180
+ # Save / resume a simulation
181
+ sim.save_checkpoint("my_run.npz")
182
+ sim2 = lfm.Simulation.load_checkpoint("my_run.npz")
183
+
184
+ # Map lattice ticks to physical units
185
+ scale = lfm.CosmicScale(box_mpc=100.0, grid_size=64)
186
+ print(scale.format_cosmic_time(50_000)) # "1.28 Gyr"
187
+
188
+ # Planck-resolution mode
189
+ ps = lfm.PlanckScale.at_planck_resolution(grid_size=256)
190
+ print(ps.cells_per_planck) # 1.0 exactly
191
+ ```
192
+
193
+ ## Low-Level API — Evolver
194
+
195
+ For maximum performance or custom evolution loops:
196
+
197
+ ```python
198
+ from lfm import SimulationConfig, FieldLevel, Evolver
199
+
200
+ cfg = SimulationConfig(grid_size=128, field_level=FieldLevel.COLOR)
201
+ evo = Evolver(cfg, backend="auto") # auto-selects GPU if available
202
+
203
+ # Inject initial conditions
204
+ evo.set_psi_real(my_array)
205
+ evo.set_chi(my_chi)
206
+
207
+ # Evolve 100 000 steps
208
+ evo.evolve(100_000)
209
+
210
+ # Extract fields as NumPy arrays
211
+ chi = evo.get_chi()
212
+ psi = evo.get_psi_real()
213
+ ```
214
+
215
+ ## GPU Support
216
+
217
+ The library automatically uses your NVIDIA GPU when CuPy is installed:
218
+
219
+ ```python
220
+ print(lfm.gpu_available()) # True if CuPy + CUDA detected
221
+
222
+ # Force CPU even if GPU is available
223
+ sim = lfm.Simulation(cfg, backend="cpu")
224
+ ```
225
+
226
+ Typical speedup: **50-200×** for N ≥ 64 grids on modern NVIDIA GPUs.
227
+
228
+ ## Documentation
229
+
230
+ - [Interactive Tutorials](https://emergentphysicslab.com/tutorials) — step-by-step guides with live visualisations
231
+ - [LFM Physics Papers](https://zenodo.org/communities/lfm-physics) — 84+ published papers
232
+ - [Constants Reference](https://github.com/gpartin/lfm-physics/blob/main/lfm/constants.py) — χ₀ = 19 and everything derived from it
233
+ - [Changelog](CHANGELOG.md) — version history
234
+ - [Contributing](CONTRIBUTING.md)
235
+
236
+ ## License
237
+
238
+ MIT
@@ -15,7 +15,7 @@ Quick start::
15
15
  print(sim.metrics())
16
16
  """
17
17
 
18
- __version__ = "0.2.1"
18
+ __version__ = "0.2.2"
19
19
 
20
20
  from lfm.analysis import (
21
21
  chi_statistics,
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "lfm-physics"
7
- version = "0.2.1"
7
+ version = "0.2.2"
8
8
  description = "Lattice Field Medium physics simulation library"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -1,181 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: lfm-physics
3
- Version: 0.2.1
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 <gpartin@gmail.com>
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: benchmark
27
- Requires-Dist: pytest-benchmark>=4.0; extra == 'benchmark'
28
- Provides-Extra: dev
29
- Requires-Dist: pytest-cov>=4.0; extra == 'dev'
30
- Requires-Dist: pytest>=7.0; extra == 'dev'
31
- Requires-Dist: ruff>=0.4; extra == 'dev'
32
- Provides-Extra: docs
33
- Requires-Dist: furo>=2024.1; extra == 'docs'
34
- Requires-Dist: myst-parser>=2.0; extra == 'docs'
35
- Requires-Dist: sphinx-autodoc-typehints>=1.24; extra == 'docs'
36
- Requires-Dist: sphinx>=7.0; extra == 'docs'
37
- Provides-Extra: gpu
38
- Requires-Dist: cupy-cuda12x>=12.0; extra == 'gpu'
39
- Provides-Extra: viz
40
- Requires-Dist: matplotlib>=3.7; extra == 'viz'
41
- Description-Content-Type: text/markdown
42
-
43
- # lfm-physics
44
-
45
- [![Tests](https://github.com/gpartin/lfm-physics/actions/workflows/test.yml/badge.svg)](https://github.com/gpartin/lfm-physics/actions/workflows/test.yml)
46
- [![PyPI](https://img.shields.io/pypi/v/lfm-physics?v=2)](https://pypi.org/project/lfm-physics/)
47
- [![Python 3.10+](https://img.shields.io/pypi/pyversions/lfm-physics?v=2)](https://pypi.org/project/lfm-physics/)
48
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
49
-
50
- **Simulate a universe from two equations.**
51
-
52
- The Lattice Field Medium (LFM) framework runs two coupled wave equations on a
53
- discrete 3D lattice — and gravity, electromagnetism, dark matter, and cosmic
54
- structure all emerge from the dynamics. No forces injected. No constants
55
- assumed. Just a grid, two update rules, and initial noise.
56
-
57
- ## Install
58
-
59
- ```bash
60
- pip install lfm-physics
61
- ```
62
-
63
- GPU acceleration (NVIDIA):
64
- ```bash
65
- pip install lfm-physics[gpu]
66
- ```
67
-
68
- ## Quick Start
69
-
70
- ```python
71
- import lfm
72
-
73
- # 1. Create a 64³ lattice — empty space has χ = 19 everywhere
74
- sim = lfm.Simulation(lfm.SimulationConfig(grid_size=64))
75
-
76
- # 2. Drop a soliton (energy blob) onto the grid
77
- sim.place_soliton((32, 32, 32), amplitude=6.0)
78
-
79
- # 3. Let the substrate settle into equilibrium
80
- sim.equilibrate()
81
-
82
- # 4. Run the two equations for 5 000 steps
83
- sim.run(steps=5000)
84
-
85
- # 5. Measure what emerged
86
- m = sim.metrics()
87
- print(f"χ_min = {m['chi_min']:.2f}") # χ dropped — a gravity well!
88
- print(f"Wells = {m['well_fraction']*100:.1f}%")
89
-
90
- # 6. Look at the shape of gravity
91
- profile = lfm.radial_profile(sim.chi, center=(32,32,32), max_radius=20)
92
- # profile['r'] and profile['profile'] — does it fall like 1/r?
93
- ```
94
-
95
- ## Examples — Build a Universe in 14 Steps
96
-
97
- Each example builds on the one before, from empty space to a simulated cosmos.
98
- Run them in order:
99
-
100
- | # | Example | What you'll see |
101
- |---|---------|-----------------|
102
- | 1 | [01_empty_space.py](examples/01_empty_space.py) | A grid with χ=19 everywhere — nothing happens (that's the point) |
103
- | 2 | [02_first_particle.py](examples/02_first_particle.py) | Add energy → χ drops → a gravity well appears |
104
- | 3 | [03_measuring_gravity.py](examples/03_measuring_gravity.py) | Measure χ(r) and check for 1/r falloff |
105
- | 4 | [04_two_bodies.py](examples/04_two_bodies.py) | Two solitons attract — gravitational interaction emerges |
106
- | 5 | [05_electric_charge.py](examples/05_electric_charge.py) | Phase = charge: same phase repels, opposite attracts |
107
- | 6 | [06_dark_matter.py](examples/06_dark_matter.py) | Remove matter — the χ-well persists (substrate memory) |
108
- | 7 | [07_matter_creation.py](examples/07_matter_creation.py) | Oscillate χ at 2χ₀ — matter appears from nothing |
109
- | 8 | [08_universe.py](examples/08_universe.py) | Random noise on 64³ → wells + voids → cosmic structure |
110
- | 9 | [09_hydrogen_atom.py](examples/09_hydrogen_atom.py) | Proton χ-well traps an electron — energy-level ladder emerges |
111
- | 10 | [10_hydrogen_molecule.py](examples/10_hydrogen_molecule.py) | Two H atoms bond — bonding vs anti-bonding orbitals |
112
- | 11 | [11_oxygen.py](examples/11_oxygen.py) | Heavier nucleus (8 electrons) — deeper well, richer structure |
113
- | 12 | [12_fluid_dynamics.py](examples/12_fluid_dynamics.py) | 40-soliton gas → Euler equation from the stress-energy tensor |
114
- | 13 | [13_weak_force.py](examples/13_weak_force.py) | Turn epsilon_w on/off and measure parity asymmetry from chi + j |
115
- | 14 | [14_strong_force.py](examples/14_strong_force.py) | Run color fields and measure confinement proxy via chi line integrals |
116
-
117
- ```bash
118
- cd examples
119
- python 01_empty_space.py # 30 seconds
120
- # ... work through each one ...
121
- python 08_universe.py # the payoff
122
- python 12_fluid_dynamics.py # fluid velocity from wave mechanics
123
- ```
124
-
125
- **Interactive tutorials with visualisations:** https://emergentphysicslab.com/tutorials
126
-
127
- ## What is LFM?
128
-
129
- Two coupled wave equations on a cubic lattice:
130
-
131
- **GOV-01** — what matter does:
132
- ```
133
- ∂²Ψ/∂t² = c²∇²Ψ − χ²Ψ
134
- ```
135
-
136
- **GOV-02** — what the substrate does:
137
- ```
138
- ∂²χ/∂t² = c²∇²χ − κ(|Ψ|² − E₀²)
139
- ```
140
-
141
- The substrate field χ starts at 19 everywhere (derived from 3D lattice
142
- geometry: 1 center + 6 face + 12 edge modes = 19). Energy (|Ψ|²) pushes
143
- χ down, creating wells. Waves curve toward low χ. That's gravity.
144
-
145
- Complex phase differences in Ψ create interference — constructive (repulsion)
146
- or destructive (attraction). That's electromagnetism.
147
-
148
- When matter leaves a region, χ doesn't snap back instantly — the well
149
- persists. That's dark matter.
150
-
151
- No forces are coded in. Everything emerges from the two update rules.
152
-
153
- ## Measurement Tools
154
-
155
- The library includes tools to extract physics from your simulation:
156
-
157
- ```python
158
- # Radial χ profile around a soliton
159
- profile = lfm.radial_profile(sim.chi, center=(32,32,32), max_radius=20)
160
-
161
- # Find the N brightest energy peaks
162
- peaks = lfm.find_peaks(sim.energy_density, n=5)
163
-
164
- # Track separation between two bodies over time
165
- sep = lfm.measure_separation(sim.energy_density)
166
-
167
- # Map lattice ticks to physical units (Gyr, Mpc)
168
- scale = lfm.CosmicScale(box_mpc=100.0, grid_size=64)
169
- print(scale.format_cosmic_time(50_000)) # "1.28 Gyr"
170
- ```
171
-
172
- ## Documentation
173
-
174
- - [Interactive Tutorials](https://emergentphysicslab.com/tutorials) — step-by-step guides with live visualisations
175
- - [LFM Physics Papers](https://zenodo.org/communities/lfm-physics)
176
- - [Constants](https://github.com/gpartin/lfm-physics/blob/main/lfm/constants.py) — χ₀ = 19, κ = 1/63, and the rest
177
- - [Contributing](CONTRIBUTING.md)
178
-
179
- ## License
180
-
181
- MIT
@@ -1,139 +0,0 @@
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
- [![PyPI](https://img.shields.io/pypi/v/lfm-physics?v=2)](https://pypi.org/project/lfm-physics/)
5
- [![Python 3.10+](https://img.shields.io/pypi/pyversions/lfm-physics?v=2)](https://pypi.org/project/lfm-physics/)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
7
-
8
- **Simulate a universe from two equations.**
9
-
10
- The Lattice Field Medium (LFM) framework runs two coupled wave equations on a
11
- discrete 3D lattice — and gravity, electromagnetism, dark matter, and cosmic
12
- structure all emerge from the dynamics. No forces injected. No constants
13
- assumed. Just a grid, two update rules, and initial noise.
14
-
15
- ## Install
16
-
17
- ```bash
18
- pip install lfm-physics
19
- ```
20
-
21
- GPU acceleration (NVIDIA):
22
- ```bash
23
- pip install lfm-physics[gpu]
24
- ```
25
-
26
- ## Quick Start
27
-
28
- ```python
29
- import lfm
30
-
31
- # 1. Create a 64³ lattice — empty space has χ = 19 everywhere
32
- sim = lfm.Simulation(lfm.SimulationConfig(grid_size=64))
33
-
34
- # 2. Drop a soliton (energy blob) onto the grid
35
- sim.place_soliton((32, 32, 32), amplitude=6.0)
36
-
37
- # 3. Let the substrate settle into equilibrium
38
- sim.equilibrate()
39
-
40
- # 4. Run the two equations for 5 000 steps
41
- sim.run(steps=5000)
42
-
43
- # 5. Measure what emerged
44
- m = sim.metrics()
45
- print(f"χ_min = {m['chi_min']:.2f}") # χ dropped — a gravity well!
46
- print(f"Wells = {m['well_fraction']*100:.1f}%")
47
-
48
- # 6. Look at the shape of gravity
49
- profile = lfm.radial_profile(sim.chi, center=(32,32,32), max_radius=20)
50
- # profile['r'] and profile['profile'] — does it fall like 1/r?
51
- ```
52
-
53
- ## Examples — Build a Universe in 14 Steps
54
-
55
- Each example builds on the one before, from empty space to a simulated cosmos.
56
- Run them in order:
57
-
58
- | # | Example | What you'll see |
59
- |---|---------|-----------------|
60
- | 1 | [01_empty_space.py](examples/01_empty_space.py) | A grid with χ=19 everywhere — nothing happens (that's the point) |
61
- | 2 | [02_first_particle.py](examples/02_first_particle.py) | Add energy → χ drops → a gravity well appears |
62
- | 3 | [03_measuring_gravity.py](examples/03_measuring_gravity.py) | Measure χ(r) and check for 1/r falloff |
63
- | 4 | [04_two_bodies.py](examples/04_two_bodies.py) | Two solitons attract — gravitational interaction emerges |
64
- | 5 | [05_electric_charge.py](examples/05_electric_charge.py) | Phase = charge: same phase repels, opposite attracts |
65
- | 6 | [06_dark_matter.py](examples/06_dark_matter.py) | Remove matter — the χ-well persists (substrate memory) |
66
- | 7 | [07_matter_creation.py](examples/07_matter_creation.py) | Oscillate χ at 2χ₀ — matter appears from nothing |
67
- | 8 | [08_universe.py](examples/08_universe.py) | Random noise on 64³ → wells + voids → cosmic structure |
68
- | 9 | [09_hydrogen_atom.py](examples/09_hydrogen_atom.py) | Proton χ-well traps an electron — energy-level ladder emerges |
69
- | 10 | [10_hydrogen_molecule.py](examples/10_hydrogen_molecule.py) | Two H atoms bond — bonding vs anti-bonding orbitals |
70
- | 11 | [11_oxygen.py](examples/11_oxygen.py) | Heavier nucleus (8 electrons) — deeper well, richer structure |
71
- | 12 | [12_fluid_dynamics.py](examples/12_fluid_dynamics.py) | 40-soliton gas → Euler equation from the stress-energy tensor |
72
- | 13 | [13_weak_force.py](examples/13_weak_force.py) | Turn epsilon_w on/off and measure parity asymmetry from chi + j |
73
- | 14 | [14_strong_force.py](examples/14_strong_force.py) | Run color fields and measure confinement proxy via chi line integrals |
74
-
75
- ```bash
76
- cd examples
77
- python 01_empty_space.py # 30 seconds
78
- # ... work through each one ...
79
- python 08_universe.py # the payoff
80
- python 12_fluid_dynamics.py # fluid velocity from wave mechanics
81
- ```
82
-
83
- **Interactive tutorials with visualisations:** https://emergentphysicslab.com/tutorials
84
-
85
- ## What is LFM?
86
-
87
- Two coupled wave equations on a cubic lattice:
88
-
89
- **GOV-01** — what matter does:
90
- ```
91
- ∂²Ψ/∂t² = c²∇²Ψ − χ²Ψ
92
- ```
93
-
94
- **GOV-02** — what the substrate does:
95
- ```
96
- ∂²χ/∂t² = c²∇²χ − κ(|Ψ|² − E₀²)
97
- ```
98
-
99
- The substrate field χ starts at 19 everywhere (derived from 3D lattice
100
- geometry: 1 center + 6 face + 12 edge modes = 19). Energy (|Ψ|²) pushes
101
- χ down, creating wells. Waves curve toward low χ. That's gravity.
102
-
103
- Complex phase differences in Ψ create interference — constructive (repulsion)
104
- or destructive (attraction). That's electromagnetism.
105
-
106
- When matter leaves a region, χ doesn't snap back instantly — the well
107
- persists. That's dark matter.
108
-
109
- No forces are coded in. Everything emerges from the two update rules.
110
-
111
- ## Measurement Tools
112
-
113
- The library includes tools to extract physics from your simulation:
114
-
115
- ```python
116
- # Radial χ profile around a soliton
117
- profile = lfm.radial_profile(sim.chi, center=(32,32,32), max_radius=20)
118
-
119
- # Find the N brightest energy peaks
120
- peaks = lfm.find_peaks(sim.energy_density, n=5)
121
-
122
- # Track separation between two bodies over time
123
- sep = lfm.measure_separation(sim.energy_density)
124
-
125
- # Map lattice ticks to physical units (Gyr, Mpc)
126
- scale = lfm.CosmicScale(box_mpc=100.0, grid_size=64)
127
- print(scale.format_cosmic_time(50_000)) # "1.28 Gyr"
128
- ```
129
-
130
- ## Documentation
131
-
132
- - [Interactive Tutorials](https://emergentphysicslab.com/tutorials) — step-by-step guides with live visualisations
133
- - [LFM Physics Papers](https://zenodo.org/communities/lfm-physics)
134
- - [Constants](https://github.com/gpartin/lfm-physics/blob/main/lfm/constants.py) — χ₀ = 19, κ = 1/63, and the rest
135
- - [Contributing](CONTRIBUTING.md)
136
-
137
- ## License
138
-
139
- MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes