算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
analyze-magnetic-field【设计与创意】Calculate and visualize magnetic fields produced by current distributions using the Biot-Savart law, Ampere's law, and magnetic dipole approximations. Use when computing B-fields from arbitrary current geometries, exploiting symmetry with Ampere's law, analyzing superposition of multiple sources, or characterizing magnetic materials through permeabil…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Calc B-field from current distribution: characterize src geometry → select law (Biot-Savart arbitrary, Ampere high-sym) → eval integrals → check limits → incorporate material effects → visualize field-line topology.
Fully spec src pre-method:
## Source Characterization
- **Current type**: [line I / surface K / volume J]
- **Geometry**: [parametric description]
- **Coordinate system**: [and justification]
- **Symmetries**: [translational / rotational / reflection]
- **Nonzero B-components by symmetry**: [list]
- **Current continuity**: [verified / issue noted]
→ Complete geometric desc, coord system chosen, sym cataloged, continuity verified.
If err: Too complex for closed-form → discretize short straight segments (numerical Biot-Savart). Continuity violated → add displacement current or return charge accumulation before proceeding.
Match method to sym + complexity:
Ampere (high sym): Use when B extractable from line integral. Applicable:
Biot-Savart (general): Arbitrary geometries Ampere can't simplify:
Dipole approx (far field): Obs far from src (r >> src dim d):
Superposition: Multi-src → B each independent + sum vectorially. Maxwell linearity → exact.
## Method Selection
- **Primary method**: [Ampere / Biot-Savart / dipole]
- **Justification**: [symmetry argument or distance criterion]
- **Expected complexity**: [closed-form / single integral / numerical]
- **Fallback method**: [if primary fails or for cross-validation]
→ Justified method choice, clear why law appropriate for sym level.
If err: Ampere chosen but insufficient sym (B not extractable) → fallback Biot-Savart. Src geometry too complex analytic Biot-Savart → discretize numerically.
Execute calc via Step 2 method:
Ampere path: Per Amperian loop:
Biot-Savart integration: Per field pt r:
Dipole calc:
Superposition assembly: Sum all srcs per obs pt. Track components separately → preserve cancellation accuracy.
## Field Calculation
- **Integral setup**: [explicit expression]
- **Evaluation method**: [analytic / numeric with N segments]
- **Result**: B(r) = [expression with units]
- **Convergence check** (if numerical): [N vs. 2N comparison]
→ Explicit B(r) expr at obs pts, correct units (Tesla/Gauss), convergence check numerical.
If err: Integral diverges → missing regularization (field on thin wire diverges → use finite wire radius). Numerical oscillates w/ N → near-singularity → adaptive quadrature or analytical subtraction.
Verify vs known physics pre-trust:
Far-field dipole limit: Large r, localized src → dipole formula. Compute B → r → infinity, compare (mu_0 / 4 pi) * [3(m . r_hat) r_hat - m] / r^3.
Near-field infinite-wire limit: Close to long straight segment (rho << length L) → B = mu_0 I / (2 pi rho). Check for relevant geometry portion.
On-axis special cases: Loops + solenoids have simple closed forms:
Sym consistency: Verify components predicted vanish (Step 1) are 0. Nonzero forbidden → err.
Dim analysis: Verify B = Tesla. Every term mu_0 * [current] / [length].
## Limiting Case Verification
| Case | Condition | Expected | Computed | Match |
|------|-----------|----------|----------|-------|
| Far-field dipole | r >> d | mu_0 m / (4 pi r^3) scaling | [result] | [Yes/No] |
| Near-field wire | rho << L | mu_0 I / (2 pi rho) | [result] | [Yes/No] |
| On-axis formula | [geometry] | [known result] | [result] | [Yes/No] |
| Symmetry zeros | [component] | 0 | [result] | [Yes/No] |
| Units | -- | Tesla | [check] | [Yes/No] |
→ All limits match. Field: correct units, sym, asymptotic behavior.
If err: Failed limit → err in integral setup/eval. Common: wrong sign cross product, missing factor 2/pi, wrong integration limits, coord mismatch src vs field.
Extend to material effects + produce viz:
Linear materials: Replace mu_0 w/ mu = mu_r * mu_0 inside. Boundary conds at interfaces:
Nonlinear (B-H curves): Ferromagnetic cores:
Demagnetization: Finite-geometry magnetic materials (short rods, spheres) → internal field reduced by N_d: H_internal = H_applied - N_d * M.
Viz:
Intuition check: Field pattern makes sense qualitatively. Strongest near src, circulates around currents (right-hand rule), decays w/ dist.
## Material Effects and Visualization
- **Material model**: [vacuum / linear mu_r / nonlinear B-H / hysteretic]
- **Boundary conditions applied**: [list interfaces]
- **Visualization**: [field lines / magnitude contour / both]
- **Div B = 0 check**: [field lines close / verified numerically]
→ Complete field solution + material effects, viz closed field lines consistent div B = 0, qualitative intuition match.
If err: Field lines don't close → divergence err in calc → recheck integral/numerical. Material → unexpected amplification → verify mu_r only inside material vol + boundary conds enforced each interface.
solve-electromagnetic-induction — use computed B → analyze time-varying flux + induced EMFformulate-maxwell-equations — generalize → full Maxwell + displacement current + wave propagationdesign-electromagnetic-device — apply to electromagnets, motors, transformersformulate-quantum-problem — quantum magnetic interactions (Zeeman, spin-orbit)