Lattice Field Medium physics simulation library
Project description
lfm-physics
Simulate a universe from two equations.
The Lattice Field Medium (LFM) framework runs two coupled wave equations on a discrete 3D lattice — and gravity, electromagnetism, dark matter, and cosmic structure all emerge from the dynamics. No forces injected. No constants assumed. Just a grid, two update rules, and initial noise.
Install
pip install lfm-physics
GPU acceleration (NVIDIA):
pip install lfm-physics[gpu]
Quick Start
import lfm
# 1. Create a 64³ lattice — empty space has χ = 19 everywhere
sim = lfm.Simulation(lfm.SimulationConfig(grid_size=64))
# 2. Drop a soliton (energy blob) onto the grid
sim.place_soliton((32, 32, 32), amplitude=6.0)
# 3. Let the substrate settle into equilibrium
sim.equilibrate()
# 4. Run the two equations for 5 000 steps
sim.run(steps=5000)
# 5. Measure what emerged
m = sim.metrics()
print(f"χ_min = {m['chi_min']:.2f}") # χ dropped — a gravity well!
print(f"Wells = {m['well_fraction']*100:.1f}%")
# 6. Look at the shape of gravity
profile = lfm.radial_profile(sim.chi, center=(32,32,32), max_radius=20)
# profile['r'] and profile['profile'] — does it fall like 1/r?
Examples — Build a Universe in 14 Steps
Each example builds on the one before, from empty space to a simulated cosmos. Run them in order:
| # | Example | What you'll see |
|---|---|---|
| 1 | 01_empty_space.py | A grid with χ=19 everywhere — nothing happens (that's the point) |
| 2 | 02_first_particle.py | Add energy → χ drops → a gravity well appears |
| 3 | 03_measuring_gravity.py | Measure χ(r) and check for 1/r falloff |
| 4 | 04_two_bodies.py | Two solitons attract — gravitational interaction emerges |
| 5 | 05_electric_charge.py | Phase = charge: same phase repels, opposite attracts |
| 6 | 06_dark_matter.py | Remove matter — the χ-well persists (substrate memory) |
| 7 | 07_matter_creation.py | Oscillate χ at 2χ₀ — matter appears from nothing |
| 8 | 08_universe.py | Random noise on 64³ → wells + voids → cosmic structure |
| 9 | 09_hydrogen_atom.py | Proton χ-well traps an electron — energy-level ladder emerges |
| 10 | 10_hydrogen_molecule.py | Two H atoms bond — bonding vs anti-bonding orbitals |
| 11 | 11_oxygen.py | Heavier nucleus (8 electrons) — deeper well, richer structure |
| 12 | 12_fluid_dynamics.py | 40-soliton gas → Euler equation from the stress-energy tensor |
| 13 | 13_weak_force.py | Turn epsilon_w on/off and measure parity asymmetry from chi + j |
| 14 | 14_strong_force.py | Run color fields and measure confinement proxy via chi line integrals |
cd examples
python 01_empty_space.py # 30 seconds
# ... work through each one ...
python 08_universe.py # the payoff
python 12_fluid_dynamics.py # fluid velocity from wave mechanics
Interactive tutorials with visualisations: https://emergentphysicslab.com/tutorials
What is LFM?
Two coupled wave equations on a cubic lattice:
GOV-01 — what matter does:
∂²Ψ/∂t² = c²∇²Ψ − χ²Ψ
GOV-02 — what the substrate does:
∂²χ/∂t² = c²∇²χ − κ(|Ψ|² − E₀²)
The substrate field χ starts at 19 everywhere (derived from 3D lattice geometry: 1 center + 6 face + 12 edge modes = 19). Energy (|Ψ|²) pushes χ down, creating wells. Waves curve toward low χ. That's gravity.
Complex phase differences in Ψ create interference — constructive (repulsion) or destructive (attraction). That's electromagnetism.
When matter leaves a region, χ doesn't snap back instantly — the well persists. That's dark matter.
No forces are coded in. Everything emerges from the two update rules.
Measurement Tools
The library includes tools to extract physics from your simulation:
# Radial χ profile around a soliton
profile = lfm.radial_profile(sim.chi, center=(32,32,32), max_radius=20)
# Find the N brightest energy peaks
peaks = lfm.find_peaks(sim.energy_density, n=5)
# Track separation between two bodies over time
sep = lfm.measure_separation(sim.energy_density)
# Map lattice ticks to physical units (Gyr, Mpc)
scale = lfm.CosmicScale(box_mpc=100.0, grid_size=64)
print(scale.format_cosmic_time(50_000)) # "1.28 Gyr"
Documentation
- Interactive Tutorials — step-by-step guides with live visualisations
- LFM Physics Papers
- Constants — χ₀ = 19, κ = 1/63, and the rest
- Contributing
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lfm_physics-0.2.1.tar.gz.
File metadata
- Download URL: lfm_physics-0.2.1.tar.gz
- Upload date:
- Size: 975.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d39824f4bb69bdfede65e38342dbabbfefa45df73fb585771b1e666fc0a5a194
|
|
| MD5 |
ce6b0e124c9c2a79d9cb1f4ef25350dd
|
|
| BLAKE2b-256 |
fee1323599c535c1b0f7c1d7dc9195576c018552dc07392fa904920a6dd13664
|
Provenance
The following attestation bundles were made for lfm_physics-0.2.1.tar.gz:
Publisher:
publish.yml on gpartin/lfm-physics
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lfm_physics-0.2.1.tar.gz -
Subject digest:
d39824f4bb69bdfede65e38342dbabbfefa45df73fb585771b1e666fc0a5a194 - Sigstore transparency entry: 1151328044
- Sigstore integration time:
-
Permalink:
gpartin/lfm-physics@04f9ca3635a57ec06c5dcc9a32f94e7845af959d -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/gpartin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@04f9ca3635a57ec06c5dcc9a32f94e7845af959d -
Trigger Event:
push
-
Statement type:
File details
Details for the file lfm_physics-0.2.1-py3-none-any.whl.
File metadata
- Download URL: lfm_physics-0.2.1-py3-none-any.whl
- Upload date:
- Size: 55.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c7556febf9c38d69cce1d91453d343b882b7262b24ce4493b50855c824de896
|
|
| MD5 |
4a22110237cca9b69d879d2ecff79148
|
|
| BLAKE2b-256 |
efef33c412683dfcc65c3ba83777d5f6c83bd361b91e14db3c2659ab4658110c
|
Provenance
The following attestation bundles were made for lfm_physics-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on gpartin/lfm-physics
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lfm_physics-0.2.1-py3-none-any.whl -
Subject digest:
9c7556febf9c38d69cce1d91453d343b882b7262b24ce4493b50855c824de896 - Sigstore transparency entry: 1151328257
- Sigstore integration time:
-
Permalink:
gpartin/lfm-physics@04f9ca3635a57ec06c5dcc9a32f94e7845af959d -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/gpartin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@04f9ca3635a57ec06c5dcc9a32f94e7845af959d -
Trigger Event:
push
-
Statement type: