gemphy 0.1.0

GEM Physics: Derives physical constants from geometric impedance in a horn torus vacuum.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
# Geometric Encoded Medium (GEM) Framework

##

### A Geometric Encoded Medium (GEM) Impedance Framework for Physics in Rust

> "The universe is a perfect geometric circuit."

![Version](https://img.shields.io/badge/version-0.1.0-blue) ![License](https://img.shields.io/badge/license-GPL--3.0-green) ![Rust](https://img.shields.io/badge/built_with-Rust-orange) [![Crates.io](https://img.shields.io/crates/v/gemphy.svg)](https://crates.io/crates/gemphy) [![Docs](https://docs.rs/gemphy/badge.svg)](https://docs.rs/gemphy) [![CI](https://github.com/troydeville/gemphy/workflows/CI/badge.svg)](https://github.com/troydeville/gemphy/actions)

---

## 🌌 Overview

The **GEM Framework** is a Rust library that models reality not as a collection of arbitrary forces and constants, but as a single **Geometric Encoded Medium**. It posits that space itself has impedance ($Z_p$) and geometry (**Horn Torus topology**), and that all physical phenomena—Gravity, Electromagnetism, Mass, and Charge—are simply different "encodings" running on this geometric hardware.

This library does not approximate physics; it **derives** it. By defining a few geometric axioms, it mathematically derives Newton's Gravitational Constant ($G$), the Fine Structure Constant ($\alpha$), and the Proton Radius from first principles. Validations match CODATA with high precision (e.g., α rel error -5.47e-10, G rel error 3.86e-6).

For a visual of the horn torus topology:

## 🧠 Core Philosophy

In GEM, the universe is treated as a software system:

- **The Hardware:** A "Horn Torus" topology representing the vacuum medium.
- **The Operating System:** The Impedance Field ($Z_0, Z_p$) that dictates how information moves.
- **The Software:**
  - **Gravity:** The interaction when the medium is encoded with Mass (Shadow Charge $Q = \Xi M$).
  - **Electromagnetism:** The interaction when the medium is encoded with Electric Charge ($q$).

Complex phases handle extreme scales (e.g., Planck or black holes), rotating real forces into imaginary (rotational/spin) components.

## Quick Start

Clone and build:

```bash
git clone https://github.com/troydeville/gemphy.git
cd gemphy
cargo test  # Run validations
cargo doc --open  # View API docs
```

Install via Cargo:

```toml
[dependencies]
gemphy = "0.1.0"
```

Basic usage:

```rust
use gemphy::GeometricEncodedMedium;

fn main() {
    let medium = GeometricEncodedMedium::new();
    println!("Derived α: {:.4e}", medium.alpha);
    println!("Derived G: {:.4e} m³ kg⁻¹ s⁻²", medium.g);
}
```

## Roadmap

| Milestone | Tasks
|-----------|-------
| v0.3      | Add horn torus simulation; publish crate
| v0.4      | Interactive CLI; Python bindings
| v1.0      | Full predictions (e.g., dark matter as impedance)

## 📦 Installation

Add to `Cargo.toml`:

```toml
[dependencies]
gemphy = "0.1.0"
```

Note: Re-exports `Complex64` from `num-complex`.

## 🚀 Usage Guide

### 1. Initialize the Medium

```rust
use gemphy::GeometricEncodedMedium;

fn main() {
    let medium = GeometricEncodedMedium::new();
    println!("Vacuum Impedance (Z0): {:.4} Ohms", medium.z_o);
    println!("Fine Structure (α):    {:.4e}", medium.alpha);
    println!("Gravitational G:       {:.4e} m³ kg⁻¹ s⁻²", medium.g);
}
```

### 2. Create Geometric Knots

```rust
use gemphy::{GeometricEncodedMedium, GeometricKnot};
use num_complex::Complex64;

fn main() {
    let medium = GeometricEncodedMedium::new();
    let electron = GeometricKnot::new(medium.clone(), 9.109e-31, Complex64::new(-1.602e-19, 0.0), 0.0, "Electron");
    let earth = GeometricKnot::new(medium, 5.972e24, Complex64::new(0.0, 0.0), 6.371e6, "Earth");

    println!("--- Particle Topology ---");
    // electron.print_analysis();  // Add this method if needed
    // earth.print_analysis();
}
```

Output Note: Electron sizes to Bohr Radius; Earth to Schwarzschild Radius.

### 3. Constants & Model Specification

#### I. Fundamental Physical Constants

These are the fixed, integer-defined values representing the bedrock of the SI system used in the model.

- **Planck Constant ($h$):** The quantum of action.
$$h = \frac{662607015}{10^{42}} \text{ J/Hz}$$

- **Speed of Light ($c$):** The universal speed limit.
$$c = 299792458 \text{ m/s}$$

- **Elementary Charge ($e$):** The fundamental unit of charge.
$$e = \frac{1602176634}{10^{28}} \text{ C}$$

#### II. Scaling & Geometric Factors

These parameters act as scaling bridges between the quantum/electromagnetic scale and the gravitational scale.

- **Magnetic Scaling Constant ($\Phi$):** A scaling factor with dimensions of inductance per meter.
$$\Phi = \frac{1}{10^7} \text{ H/m}$$

- **Mass-Charge Metric ($\phi$):** A density-like scalar connecting mass and charge squared.
$$\phi = 10^4 \text{ kg}^2 \text{ m}^{-2} \text{ s}^2 \text{ C}^{-2}$$

- **Alpha-Lambda Function ($\Lambda_\alpha(n)$):** A rational function governing specific integer-ratio field interactions.
$$\Lambda_\alpha(n) = \frac{\alpha_\delta n}{\alpha_\gamma + 2 \alpha_\delta n^2}$$

#### III. Primary Field Parameters (Planck Scale)

These variables (-subscript) represent the theoretical "maximum" impedance and field density before fine-structure scaling is applied.

- **Primary Impedance ($Z_p$):**
$$Z_p = \frac{2h}{e^2}$$

- **Primary Fine Structure ($\alpha_p $):** The geometric inverse of impedance.
$$\alpha_p = \frac{4\pi c}{Z_p}$$

- **Primary Field Constants:** Permeability ($\mu_p$), Permittivity ($\epsilon_p$), and the Gamma factor ($\Gamma_p$).
$$\mu_p = \frac{Z_p}{c}$$
$$\epsilon_p = \frac{1}{c Z_p}$$
$$\Gamma_p = \frac{e^2}{\alpha_p}$$

#### IV. Vacuum Field Parameters (Observable)

These are the standard observable vacuum constants, derived by scaling the primary parameters by the fine structure constant ($).

- **Fine Structure Constant ($\alpha $):**
$$\alpha = \alpha_p \Phi$$

- **Vacuum Impedance ($Z_0$):**
$$Z_0 = \alpha Z_p$$

- **Vacuum Permeability & Permittivity ($\mu_0$, $\epsilon_0$):**
$$\mu_0 = \frac{Z_0}{c}$$
$$\epsilon_0 = \frac{1}{c Z_0}$$

- **Vacuum Gamma ($\Gamma$):**
$$\Gamma = \alpha \Gamma_p$$

#### V. Gravitational Unification

The model derives the Gravitational Constant ($G$) not as a fundamental arbitrary value, but as a result of geometric impedance scaling.

- **Gravitational Constant ($G$):**

$$
G = \frac{Z_0}{c S \phi}
[\frac{m^3}{kg s^2}]
$$

- **Complex Unification Factor ($\Xi$):** A complex rotation relating field geometry to mass-charge equivalence.

$$
\Xi = \sqrt{4\pi \sqrt{2} G \epsilon_0} \left( \cos\frac{\pi}{8} - i \sin\frac{\pi}{8} \right)
[C/kg]
$$

#### VI. Mass & Length Scales

Definitions of the Planck scale and the specific derivation of the Proton Mass.

- **Planck Units ($m_P$, $l_P$):**
$$m_P = \sqrt{\frac{ch}{2\pi G}}$$
$$l_P = \sqrt{\frac{hG}{2\pi c^3}}$$

- **Proton Mass ($m_p$):** A derivation scaling the Planck mass by exponential and geometric corrections.
$$m_p = e^{-14\pi} \left( 1 - \frac{1}{2^{11}-4} \right) m_P \left( 1 - \frac{4 \alpha_\gamma}{\alpha_\delta} \right)$$

- **Mass-Charge Equivalence ($Q$):** A unified charge definition based on mass  and the complex factor .
$$Q = M \Xi$$

To visualize force scaling (Newtonian vs. GEM-derived, log-log plot from Sun-Earth system):

![GEM](/chart.png)

### 4. Interaction Examples


```shell
cargo test -- --nocapture
```

#### Result

```shell
running 9 tests
--- THE DECODER TEST ---
Gravity Force: 2.5686e-47-2.5686e-47i
Coulomb Force: 8.2424e-8+0.0000e0i
--- GEM HYDROGEN DECODER ---
--- GEM MASS HARMONIC SCANNER ---
--- GEM HYDROGEN INTERACTION ANALYSIS ---
1. Electron Field Energy:   13.60569 eV (Source Potential)
2. Proton Coupling Energy:  0.00741 eV (Interaction Term)
3. Net Observable Energy:   13.59828 eV (Measured State)
   Target:                  13.5983 eV
State n=1: Radius = 5.2947e-11 m, Energy = 13.5983 eV
State n=2: Radius = 2.1179e-10 m, Energy = 3.3996 eV
--- RECOIL DERIVATION (Mathematica In[204-208]) ---
Term 1 (Ideal Me):    13.60569 eV (Target: 13.6057)
Term 2 (Recoil Me/Mp):0.00741 eV (Target: 0.0074)
Difference:           13.59828 eV (Target: 13.5983)
>> HARMONIC 48 (Proton Candidate): Ratio = 1836.1318
State n=3: Radius = 4.7652e-10 m, Energy = 1.5109 eV
--- GEM COMPLEX ENERGY ANALYSIS ---
Real Part:      9.61544 eV
Imaginary Part: 9.61544 eV
Magnitude:      13.59829 eV
Target:         13.5983 eV
Derived Proton/Electron Ratio: 1836.1318
test tests::verify_derivations_and_constants ... ok
test tests::test_dynamic_system_orbit ... ok
test tests::test_decoder_philosophy ... ok
test tests::verify_hydrogen_component_interaction ... ok
test tests::verify_hydrogen_recoil_derivation ... ok
test tests::test_mass_resonance_integers ... ok
test tests::test_hydrogen_resonance_decoder ... ok
test tests::verify_complex_energy_components ... ok
test tests::verify_mass_ratio_derivation ... ok
```

```shell
cargo run --bin electron_proton_action
```

```shell
electron: GeometricKnot {
    name: "Electron",
    mass: 9.1093837139e-31,
    charge: Complex {
        re: -1.602176634e-19,
        im: -1.602176634e-19,
    },
    geometric_radius_a: 5.291772104738458e-11,
    physical_radius: 2.817940320834912e-15,
}
proton: GeometricKnot {
    name: "Proton",
    mass: 1.67262192595e-27,
    charge: Complex {
        re: 1.602176634e-19,
        im: 1.602176634e-19,
    },
    geometric_radius_a: 2.8819891620872986e-14,
    physical_radius: 1.5346982642700954e-18,
}
Result: GemInteractionResult {
    q1: Complex {
        re: 8.624716672621998e-41,
        im: -3.5724746174253846e-41,
    },
    q2: Complex {
        re: 1.5836296575938094e-37,
        im: -6.559608819516165e-38,
    },
    q_total: Complex {
        re: 1.5844921292610717e-37,
        im: -6.56318129413359e-38,
    },
    af1: Complex {
        re: 3.3694829747370465e-13,
        im: -3.3694829747370465e-13,
    },
    af2: Complex {
        re: 6.186885172111745e-10,
        im: -6.186885172111745e-10,
    },
    g1: Complex {
        re: 1.5352496334655168e-20,
        im: -1.5352496334655168e-20,
    },
    g2: Complex {
        re: 2.818952718857127e-17,
        im: -2.818952718857127e-17,
    },
    force: Complex {
        re: 2.567892198741124e-47,
        im: -2.567892198741124e-47,
    },
    curvature: Complex {
        re: 1.0000000000000002,
        im: 0.0,
    },
    g_o: Complex {
        re: 6.674325731836407e-11,
        im: 0.0,
    },
    g_recovered: Complex {
        re: 6.674325731836409e-11,
        im: 0.0,
    },
    mqr1_ev: Complex {
        re: 469136044.7141288,
        im: -469136044.7141288,
    },
    mqr2_ev: Complex {
        re: 255499.47534587674,
        im: -255499.47534587674,
    },
    ratio1: Complex {
        re: 0.9994553833012333,
        im: -0.0005440241291649849,
    },
    ratio2: Complex {
        re: 0.0002723084703826605,
        im: -0.00027216024727941913,
    },
    binding_energy_ev: Complex {
        re: 9.62067644577312,
        im: 9.62067644577312,
    },
    schwarzschild_radius: 2.485594236043889e-54,
    ratio_mr_d: 4.697091670283908e-44,
    is_complex: false,
}
(result.q1 / m2).abs(): 5.58125294864566e-14
(result.q2 / m1).abs(): 1.8816952313861778e-7
 ((result.q2 / m1).abs()/(result.q1 / m2).abs()).sqrt(): 1836.1526734215263
Abs[binding_energy_ev] = 13.60569110881573
```

#### A. Microscopic Interaction (Electron-Proton)

At the quantum scale, the medium handles interactions via the Coulomb protocol (Electric Charge) and the Gravity protocol (Mass/Shadow Charge) simultaneously.

```rust
use gemphy::{GeometricEncodedMedium, GeometricKnot, ForceProtocol};
use num_complex::Complex64;

fn main() {
    let medium = GeometricEncodedMedium::new();
    let q1 = Complex64::new(-medium.e, -medium.e);
    let q2 = Complex64::new(medium.e, medium.e);
    let electron = GeometricKnot::new(medium.clone(), 9.109e-31, q1, 0.0, "Electron");
    let proton = GeometricKnot::new(medium.clone(), 1.672e-27, q2, 0.0, "Proton");
    let d = 5.29e-11; // Bohr Radius

    // Decode as Electromagnetism (Strong Force)
    let f_coulomb = medium.decode_force(&electron, &proton, d, ForceProtocol::Electromagnetism);
    
    // Decode as Gravity (Weak Force)
    let f_gravity = medium.decode_force(&electron, &proton, d, ForceProtocol::Gravity);

    println!("--- Microscopic Interaction ---");
    println!("Coulomb Force: {:.4e} N", f_coulomb); // ~ 8.2e-8 N
    println!("Gravity Force: {:.4e} N", f_gravity); // ~ 3.6e-47 N
}
```

#### B. Macroscopic Interaction (Earth-Sun)

At the cosmic scale, the Gravity protocol dominates.

```rust
use gemphy::{GeometricEncodedMedium, GeometricKnot, ForceProtocol};

fn main() {
    let medium = GeometricEncodedMedium::new();
    let earth = GeometricKnot::new(medium.clone(), 5.972e24, 5.972e24 * medium.xi, 6.371e6, "Earth");
    let sun = GeometricKnot::new(medium.clone(), 1.989e30, 1.989e30 * medium.xi, 6.96e8, "Sun");
    let d = 149.6e9; // 1 AU

    let f_gravity = medium.decode_force(&earth, &sun, d, ForceProtocol::Gravity);

    println!("--- Macroscopic Interaction ---");
    println!("Gravitational Force: {:.4e} N", f_gravity); // ~ 3.5e22 N
}
```

### 5. The Unified Force (Complex Phase Engine)

What happens inside a Black Hole or at the Planck Scale? Standard physics breaks down. GEM handles this by rotating the force vector into the **Imaginary Plane**.

- **Real Force:** Linear Acceleration (Push/Pull).
- **Imaginary Force:** Rotational Action (Spin/Memory).

<!-- end list -->

```rust
use gemphy::{GeometricEncodedMedium, GeometricKnot};

fn main() {
    let medium = GeometricEncodedMedium::new();
    let mp = medium.m_p; // Planck Mass
    
    // Create two particles at the Planck Scale
    let p1 = GeometricKnot::new(medium.clone(), mp, mp * medium.xi, 0.0, "Planck A");
    let p2 = GeometricKnot::new(medium.clone(), mp, mp * medium.xi, 0.0, "Planck B");
    
    // Distance inside the Schwarzschild radius
    let d = 0.5 * medium.l_p; 

    let f_total = medium.calculate_total_force(&p1, &p2, d);

    println!("--- Unified Force (Planck Scale) ---");
    println!("Force Vector: {:.4e} + {:.4e}i N", f_total.re, f_total.im);
    
    if f_total.im.abs() > 0.0 {
        println!("Status: Phase Transition (Information Storage / Spin)");
    }
}
```

## 🧪 Testing the Laws of Physics

This library includes a rigorous test suite that validates the framework against CODATA observations.

Run the verification suite:

```bash
cargo test
```

**What is tested?**

- **The Golden Loop:** Verifies $\frac{h}{2\pi c} \equiv \frac{\Gamma}{\alpha}$.
  - **Grand Unification:** Verifies the geometric scaling from Electrons to the Universe.
  - **Force Parity:** Checks that GEM-derived Gravity matches Newtonian Gravity to $10^{-13}$ precision.
  - **Phase Change:** Ensures forces transition to complex numbers correctly inside event horizons.

---

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for details on issues, PRs, and development setup.

## ⚖️ License

This project is licensed under GPL-3.0.

---