# PHOTON v2.0 Learning Guide

Welcome to PHOTON—an interactive laboratory for exploring electromagnetic phenomena, plasma physics, and mathematical complexity. This guide will help you get started with each laboratory and suggests learning objectives and experiments.

## Table of Contents

1. [Getting Started](#getting-started)
2. [Laboratory Overview](#laboratory-overview)
3. [Learning Objectives](#learning-objectives)
4. [Suggested Experiments](#suggested-experiments)
5. [Mathematical Background](#mathematical-background)
6. [Glossary](#glossary)
7. [Troubleshooting](#troubleshooting)

---

## Getting Started

### Prerequisites

- A modern web browser (Chrome, Firefox, Safari, Edge)
- Basic understanding of:
  - Vectors and coordinates (x, y, z axes)
  - Trigonometry (sine, cosine, phase)
  - Electromagnetic concepts (optional—PHOTON will help you learn!)

### No Installation Required

PHOTON v2.0 runs entirely in your browser:

1. Open [index.html](../index.html) locally or visit the GitHub Pages deployment
2. Navigate between laboratories using the top menu bar
3. Use the control panels to adjust parameters and observe results in real-time

### Browser Console

If something isn't working as expected:
1. Open the browser console: **F12** → **Console** tab
2. Check for error messages (they appear in red)
3. Report issues with the console output

---

## Laboratory Overview

### 01 — Wave Laboratory

**What it shows:** How electric and magnetic fields oscillate as light travels through space.

**Key concepts:**
- Electromagnetic wave propagation along the x-axis
- Electric field oscillating along the y-axis (blue)
- Magnetic field oscillating along the z-axis (orange)
- In-phase oscillation (both peak together)
- Wavelength-frequency inverse relationship: λf = c

**Controls:**
- **Frequency slider**: Adjust 400–790 THz (visible light range)
- **Relative amplitude**: Scale electric field display
- **Initial phase**: Shift both fields in time
- **Animation speed**: Slow down or speed up propagation
- **Field visibility**: Toggle electric/magnetic/both
- **Particle density**: Add glowing particles (0–3000)

**Educational value:**
- See how frequency determines color (wavelength)
- Observe how fields remain perpendicular and in-phase
- Understand why light is an electromagnetic phenomenon

---

### 02 — Particle Dynamics Laboratory

**What it shows:** How charged particles move in electromagnetic fields.

**Key concepts:**
- Lorentz force: F = q(E + v × B)
- Gyromotion: charged particles spiral around magnetic field lines
- E×B drift: perpendicular motion in crossed fields
- Debye length: scale over which electric fields affect particles
- Plasma frequency: collective oscillation of electrons

**Controls:**
- **Particle type**: Switch between electrons (blue) and ions (orange)
- **Number of particles**: 10–100 particles to observe
- **Magnetic field strength**: Adjust B_0
- **Electric field strength**: Create drift effects
- **Initial velocity**: Change particle temperature (kinetic energy)
- **Boundaries**: Particles reflect elastically from box walls

**Educational value:**
- Discover gyromotion directly (not just reading equations)
- Observe how mass affects cyclotron frequency
- See E×B drift in action
- Compare electron vs. ion dynamics

---

### 03 — Magnetic Reconnection Laboratory

**What it shows:** How magnetic field topologies restructure in plasma.

**Key concepts:**
- Harris current sheet: opposing magnetic fields separated by current
- Magnetic null/X-point: location where field vanishes
- Particle acceleration during reconnection
- Test-particle approximation: particles in prescribed field
- Scaling relationships with plasma beta

**Controls:**
- **Particle population**: Electrons and ions separately
- **Initial temperature**: Particle energy distribution
- **Guide field strength**: Affects reconnection rate
- **Asymmetry parameter**: Model asymmetric reconnection
- **Field of view**: Zoom/pan the current sheet region

**Educational value:**
- Understand why reconnection is "fast" (independent of collisionality)
- See asymmetric acceleration of different species
- Observe field line topology change
- Compare symmetric vs. asymmetric cases

---

### 04 — Symmetry & Complexity Laboratory

**What it shows:** How symmetry breaking creates emergent complexity.

**Key concepts:**
- Double-well potential: canonical symmetry-breaking system
- Explicit vs. spontaneous symmetry breaking
- Perturbation analysis: quantifying deviation from symmetry
- Complexity metrics: harmonic content, critical points
- Model complexity vs. accuracy trade-off

**Controls:**
- **Symmetry breaking parameter (λ)**: Vary 0 (symmetric) to 1 (broken)
- **Perturbation strength**: Add oscillatory disturbance
- **Trajectory visualization**: Watch how particles evolve
- **Harmonic analysis**: View frequency content
- **Comparison mode**: Side-by-side symmetric vs. asymmetric

**Educational value:**
- Develop intuition for symmetry in physics
- See how small perturbations lead to large effects
- Understand model simplification tradeoffs
- Explore emergence of complexity

---

### 05 — MMS Spacecraft Explorer

**What it shows:** How NASA's MMS mission measures magnetic reconnection.

**Key concepts:**
- Tetrahedral constellation: 4 spacecraft in precise formation
- Gradient calculation: finite differences across formation
- Divergence measurement: ∇·B ≈ 0 validation
- Field-aligned coordinates: transformation to field-centered frame
- Multi-scale measurements: from electron to ion scales

**Controls:**
- **Formation size**: Adjust spacecraft separation (10–50 m)
- **Formation orientation**: Rotate constellation
- **Measurement resolution**: Change gradient calculation points
- **Field region**: Switch between reconnection sites
- **Data rate**: Telemetry simulation frequency

**Educational value:**
- Understand how multi-point measurements constrain theory
- Learn spacecraft formation flying principles
- See how gradients relate to field curvature
- Appreciate observational challenges in space plasma

---

### 06 — Research Notebook

**What it shows:** A local browser-based laboratory notebook for recording observations.

**Features:**
- **Add entries**: Record hypotheses, observations, findings, calculations
- **Tag system**: Organize entries by topic
- **Experiment capture**: Save full state snapshots from active labs
- **Export data**: JSON, CSV, Markdown formats
- **Research questions**: 4 open questions for investigation

**Educational value:**
- Practice scientific method: hypothesis → experiment → finding
- Develop documentation skills
- Organize research across multiple labs
- Export data for reports or presentation

---

### 07 — References & Mathematics

**What it shows:** Mathematical foundations and scientific sources.

**Sections:**
- **Physical Constants**: Exact 2019 SI definitions
- **Electromagnetic Wave Equations**: Plane wave solutions
- **Photon Energy and Visible Light**: E = hf and the spectrum
- **Lorentz Force**: Fundamental equation of particle motion
- **Boris Algorithm**: Numerical particle integration method
- **Magnetic Reconnection**: Current sheets and plasma dynamics
- **Symmetry and Complexity**: Mathematical foundations
- **Plasma Physics**: Collective phenomena
- **Research References**: Bibliography with verification status

**Educational value:**
- Quick reference for equations and constants
- Links between concepts and their mathematical forms
- Scientific literature connections
- Verification of calculations

---

## Learning Objectives

### Foundation Level (Complete All)

After completing the Foundation objectives, you should understand:

1. **Wave Laboratory**
   - [ ] How frequency and wavelength relate: λ = c/f
   - [ ] Why electric and magnetic fields oscillate perpendicular to each other
   - [ ] The difference between propagation velocity and particle oscillation
   - [ ] How color maps to frequency

2. **Physical Constants**
   - [ ] Exact values of c, h, e, m_e, m_p
   - [ ] Why exact constants matter in computation
   - [ ] How to convert between units (THz ↔ Hz, nm ↔ m, eV ↔ J)

### Intermediate Level (Choose 2+)

3. **Particle Dynamics**
   - [ ] Lorentz force components: qE vs. qv×B
   - [ ] Why cyclotron frequency depends on mass
   - [ ] How E×B drift works (independent of charge and mass!)
   - [ ] Debye length as a screening scale

4. **Magnetic Reconnection**
   - [ ] Why reconnection is "fast" in collisionless plasma
   - [ ] How particle acceleration happens at X-points
   - [ ] Difference between symmetric and asymmetric reconnection
   - [ ] Why this matters for solar flares and magnetosphere dynamics

5. **Symmetry and Complexity**
   - [ ] How symmetry constrains a system
   - [ ] What happens when symmetry breaks
   - [ ] Why complexity isn't always "better"
   - [ ] How to measure deviation from symmetry

### Advanced Level (Choose 1+)

6. **Multi-scale Measurements**
   - [ ] How 4-spacecraft formation flying constrains field gradients
   - [ ] The connection between gradient and curvature
   - [ ] Why multi-point measurements improve theory validation
   - [ ] Limitations of single-point vs. constellation measurements

7. **Research Questions**
   - [ ] Can you formulate your own testable hypothesis?
   - [ ] How would you design an experiment to answer it?
   - [ ] What measurements would validate your hypothesis?
   - [ ] How would you present findings to peers?

---

## Suggested Experiments

### Experiment 1: Visible Light Spectrum

**Objective:** Map frequency to perceived color and verify wavelength calculations.

**Procedure:**
1. Open **Wave Laboratory**
2. Slide frequency from 400 THz (red) to 790 THz (violet)
3. Record the displayed wavelength, photon energy, and angular frequency at:
   - 400 THz (deep red)
   - 500 THz (green)
   - 650 THz (orange)
   - 790 THz (violet)

**Analysis:**
- Verify λf = c for each measurement
- Calculate hf and compare to displayed photon energy
- Explain why color is determined by frequency, not wavelength

**Expected values:**
- 500 THz: λ ≈ 599.6 nm, E ≈ 2.068 eV, ω ≈ 3.14 × 10^15 rad/s

---

### Experiment 2: Cyclotron-Frequency Reference Calculation

**Objective:** Calculate the expected cyclotron-frequency scale from charge,
mass, and magnetic-field strength.

**Procedure:**
1. Choose a particle species and record its charge and mass.
2. Choose a magnetic field magnitude in tesla.
3. Calculate `ωc = |q|B/m` and `Tc = 2π/ωc`.
4. Record the assumptions and compare the expected scale with the
   visualization only qualitatively.

The current particle view has no species selector, controlled initial
conditions, or time-series measurement. Do not report a measured frequency
from it.

---

### Experiment 3: E×B Drift Reference Calculation

**Objective:** Derive the ideal uniform-field drift prediction.

**Procedure:**
1. Choose perpendicular uniform vectors E and B with `|B| > 0`.
2. Calculate `vE×B = E × B / |B|²`.
3. Repeat for two species; note charge and mass do not appear in this
   expression.
4. Record this as an analytical prediction, not a measured PHOTON result.

The current particle view does not provide seeded species comparisons or a
drift-velocity measurement, so it cannot verify this prediction.

---

### Experiment 4: Prescribed Current-Sheet Profile

**Objective:** Inspect the current density implied by the symmetric prescribed
`tanh` magnetic profile.

**Procedure:**
1. Open **Magnetic Reconnection Laboratory** and leave asymmetric mode off.
2. Vary sheet strength and thickness, and record the displayed center-sheet
   current density.
3. Compare with `Jz(0) = -B0/(μ0δ)`.

The diagnostic follows from the prescribed profile; it does not establish a
pressure-balanced equilibrium or active reconnection. Field-line overlays are
schematic and the prescribed electric field is zero. Do not infer reconnection
rates, particle outflow, or acceleration. The asymmetric toggle uses a separate
legacy profile and does not expose this current-density diagnostic.

---

### Experiment 5: Symmetry Breaking Dynamics

**Objective:** Observe how continuous symmetry breaking changes system behavior.

**Procedure:**
1. Open **Symmetry & Complexity Laboratory**
2. Set λ = 0 (perfectly symmetric); observe trajectory
3. Gradually increase λ in steps: 0.1, 0.2, 0.5, 1.0
4. For each, describe qualitative behavior: stable, oscillatory, chaotic?
5. Use harmonic analysis tool to measure complexity

**Analysis:**
- How does trajectory change with λ?
- At what λ does chaotic behavior emerge?
- Measure symmetry residual: |V(x) - V(-x)| vs. λ
- Plot complexity vs. breaking parameter

---

### Experiment 6: MMS Gradient Measurement

**Objective:** Calculate magnetic field gradients using MMS constellation data.

**Procedure:**
1. Open **MMS Spacecraft Explorer**
2. Set formation size to 20 m (typical inter-spacecraft distance)
3. Record magnetic field at each spacecraft location
4. Using 4-point measurement, calculate ∇B_z and ∇B_x
5. Verify ∇·B ≈ 0 (divergence-free constraint)

**Analysis:**
- Gradient = (B_1 - B_2) / distance_12 (finite difference)
- MMS uses 4 measurements; you need at least 2 for each component
- Real-world accuracy: ±50 nT (nanoTesla)
- Compare your gradients to spacecraft-based measurements

---

## Mathematical Background

### Essential Concepts

#### 1. Vectors and Cross Products

**Definition:** A cross product combines two vectors perpendicular to both:
```
A × B = magnitude(A) × magnitude(B) × sin(θ) × n̂
```

**Example in electromagnetic wave:**
```
E = (0, E_y, 0)      [electric field along y]
B = (0, 0, B_z)      [magnetic field along z]
k = (k_x, 0, 0)      [propagation along x]

Poynting vector S = E × B points along +x (direction of propagation)
```

#### 2. Harmonic Motion

**General form:** `y(t) = A sin(ωt + φ)`

**Key parameters:**
- **A** = amplitude (peak displacement)
- **ω** = angular frequency (radians/second), related to frequency by ω = 2πf
- **φ** = initial phase (how much the wave is "shifted" at t=0)
- **T** = period = 2π/ω = 1/f (time for one complete cycle)

**Example for electromagnetic wave:**
```
E_y(x,t) = E_0 sin(kx - ωt + φ)
B_z(x,t) = (E_0/c) sin(kx - ωt + φ)
```

#### 3. Wavelength and Frequency

**Relationship:** λf = c (wave equation for light in vacuum)

**Derivation:**
- One cycle travels distance λ in time T = 1/f
- Speed = distance/time = λ / (1/f) = λf = c

**Implications:**
- Shorter wavelength → higher frequency (more oscillations per second)
- Red light (700 nm): f ≈ 428 THz
- Violet light (380 nm): f ≈ 789 THz

#### 4. Lorentz Force

**Equation:** F = q(E + v × B)

**Components:**
- **qE** = electric force (along field direction)
- **qv × B** = magnetic force (perpendicular to both v and B)

**Example:**
```
Electron: q = -e, m_e ≈ 9.1 × 10^-31 kg
Proton: q = +e, m_p ≈ 1.67 × 10^-27 kg

Same force → different acceleration: a = F/m
```

#### 5. Cyclotron Motion

**Setup:** Particle in uniform magnetic field, no electric field

**Motion:** Particle circles around field line with:
- **Cyclotron frequency:** ω_c = qB/m (depends on q/m ratio!)
- **Gyroradius:** r_L = mv_⊥ / (qB) (depends on momentum)
- **Period:** T = 2π/ω_c = 2πm / (qB)

**Example:**
```
Electron in 1 Tesla field:
ω_c = e × B / m_e ≈ 1.76 × 10^11 rad/s = 28 GHz
Period T ≈ 35.7 nanoseconds

Ion (same field):
ω_c / (ω_c for electron) ≈ 1/1836 → much slower rotation
```

#### 6. Energy and Power

**Photon energy:** E = hf

**Where:**
- h = 6.626 × 10^-34 J·s (Planck constant)
- f = frequency (Hz)

**Conversion:** E(eV) = hf / (1.602 × 10^-19 J/eV)

**Example:**
```
500 THz green light:
E = 6.626 × 10^-34 × 500 × 10^12 = 3.313 × 10^-19 J
E = 3.313 × 10^-19 / 1.602 × 10^-19 ≈ 2.068 eV
```

### Mathematical References

For detailed derivations, see:
- [MATHEMATICS.md](../MATHEMATICS.md) — full mathematical reference
- [SCIENTIFIC-ASSUMPTIONS.md](../SCIENTIFIC-ASSUMPTIONS.md) — model classifications and limitations
- [VALIDATION.md](../VALIDATION.md) — numerical validation and accuracy analysis

---

## Glossary

### Electromagnetic Concepts

- **Electromagnetic Wave** — Coupled oscillating electric and magnetic fields propagating at speed c
- **Electric Field (E)** — Force per unit charge; in PHOTON, oscillates along y-axis
- **Magnetic Field (B)** — Force on moving charges; in PHOTON, oscillates along z-axis
- **Wavelength (λ)** — Distance between successive wave peaks; λ = c/f
- **Frequency (f)** — Number of oscillations per second (Hz); related to color
- **Phase (φ)** — Position within oscillation cycle; determines timing relative to other waves
- **Polarization** — Direction of field oscillation (in PHOTON: linear, along y and z)
- **Propagation** — Direction of wave travel (+x in PHOTON)

### Particle Dynamics Concepts

- **Lorentz Force** — Total force on charged particle: F = q(E + v × B)
- **Gyromotion** — Circular motion of charged particle around magnetic field line
- **Cyclotron Frequency** — ω_c = qB/m; rotation rate around field line
- **Gyroradius** — r_L = mv_⊥ / (qB); radius of circular orbit
- **E×B Drift** — v_drift = E × B / B²; motion perpendicular to both fields (independent of charge/mass!)
- **Plasma Frequency** — ω_p = √(n_e e² / ε₀ m_e); collective electron oscillation rate
- **Debye Length** — λ_D ≈ 743√(T_e[K] / n_e[m^-3]) meters; electric field screening distance
- **Plasma Beta** — β = thermal pressure / magnetic pressure

### Reconnection Concepts

- **Magnetic Null / X-Point** — Location where magnetic field strength goes to zero
- **Harris Current Sheet** — Standard configuration for magnetic reconnection research
- **Reconnection Rate** — Speed at which field lines break and reconnect
- **Asymmetric Reconnection** — Reconnection with different conditions on each side of current sheet
- **Guide Field** — Component of magnetic field parallel to current sheet

### Symmetry Concepts

- **Symmetry** — Property where a system looks the same under certain transformations
- **Symmetry Breaking** — Process where symmetry is explicitly or spontaneously violated
- **Double-Well Potential** — V(x) = -αx²/2 + βx⁴/4; has two equivalent minima
- **Perturbation** — Small disturbance to a system
- **Harmonic Analysis** — Decomposition into sine/cosine components (frequency content)

### Spacecraft/Measurement Concepts

- **Tetrahedral Formation** — Four spacecraft arranged as vertices of tetrahedron
- **Gradient** — Rate of change of quantity in space: ∇ = (∂/∂x, ∂/∂y, ∂/∂z)
- **Divergence** — Measure of field strength change: ∇·F
- **Field-Aligned Coordinates** — Coordinate system where one axis is parallel to magnetic field
- **Telemetry** — Data transmission from spacecraft to ground station

### Units and Constants

- **Tesla (T)** — Unit of magnetic field strength
- **Volt/meter (V/m)** — Unit of electric field strength
- **Hertz (Hz)** — Unit of frequency (oscillations per second)
- **Terahertz (THz)** — 10^12 Hz (used for visible light)
- **Nanometer (nm)** — 10^-9 m (used for wavelength of visible light)
- **Electron volt (eV)** — 1.602 × 10^-19 J; natural unit for atomic/photon energy
- **Speed of light (c)** — 299,792,458 m/s (exact, by definition)
- **Planck constant (h)** — 6.62607015 × 10^-34 J·s (exact, by definition)

---

## Troubleshooting

### "The scene isn't showing any visualization"

1. Check browser console: **F12** → **Console**
2. Look for red error messages; note the exact text
3. Verify Three.js loaded: type `THREE` in console (should show object)
4. Try refreshing the page

### "Particles aren't moving"

1. Ensure animation isn't paused (check **Pause** button)
2. Check "Pause controls update visualization" toggle—if on, motion stops
3. Verify reduced-motion setting: **System Preferences** → **Accessibility** → "Reduce motion" should be OFF
4. Try resetting the laboratory (red **Reset** button)

### "Sliders don't seem to do anything"

1. Check pause status (paused controls still update visualization)
2. Verify the slider output value is changing as you drag
3. Try dragging to extreme values (min/max) to see clear effect
4. Ensure the right laboratory is active

### "Mobile layout looks weird"

1. Rotate phone to landscape (wider layout)
2. Check if nav buttons are visible (might need to scroll)
3. Try zooming out slightly (pinch gesture)
4. Report specific UI issues with screenshot

### "Data won't save to notebook"

1. Check browser storage is enabled (not in private/incognito mode)
2. Verify you have disk space available
3. Try a different export format (JSON usually most reliable)
4. Clear browser cache and try again

### "References section is empty"

1. This is normal—it shows available documentation
2. Click **View All Sections** to see mathematical content
3. Use **Export Bibliography** to download reference list
4. Some references may require institutional access (noted in status)

### "Nothing works; the whole app is broken"

1. **Hard refresh:** Ctrl+Shift+R (Windows/Linux) or Cmd+Shift+R (Mac)
2. **Clear cache:** Settings → Privacy → Clear browsing data → "All time"
3. **Disable extensions:** Try in incognito mode (Ctrl+Shift+N)
4. **Try another browser:** Chrome, Firefox, Safari, Edge
5. **Check GitHub issues:** https://github.com/whoisd3/photon-em-lab/issues

---

## Need Help?

- **Quick reference:** See [MATHEMATICS.md](../MATHEMATICS.md)
- **Physics questions:** Check the References & Mathematics lab
- **Code questions:** See inline comments in source files
- **Report bugs:** GitHub Issues with browser console output
- **Learn Three.js:** https://threejs.org/docs/

Happy exploring! 🔬✨
