算法艺术创作
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 快照 · 自动分类 · 以原作者文档为准
Calculate magnetic field produced by given current distribution. Characterize source geometry. Select appropriate law (Biot-Savart for arbitrary geometries, Ampere's law for high-symmetry configurations). Evaluate field integrals. Check limiting cases. Incorporate magnetic material effects where relevant. Visualize resulting field-line topology.
Fully specify source before selecting 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]
Got: Complete geometric description of current distribution with coordinate system chosen, symmetries cataloged, current continuity verified.
If fail: Geometry too complex for closed-form parametric description? Discretize into short straight segments (numerical Biot-Savart). Current continuity violated? Add displacement current or return charge accumulation terms before proceeding.
Choose method that matches problem's symmetry and complexity:
Ampere's law (high symmetry): Use when current distribution has sufficient symmetry that B can be pulled out of line integral. Applicable cases:
Biot-Savart law (general): Use for arbitrary geometries where Ampere's law cannot simplify:
Magnetic dipole approximation (far field): Use when observation point far from source (r >> source dimension d):
Superposition: For multiple sources, compute B from each independently and sum vectorially. Linearity of Maxwell's equations guarantees this is 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]
Got: Justified choice of method with clear statement of why chosen law appropriate for problem's symmetry level.
If fail: Ampere's law chosen but symmetry insufficient (B cannot be extracted from integral)? Fall back to Biot-Savart. Source geometry too complex for analytic Biot-Savart? Discretize numerically.
Execute calculation using method selected in Step 2:
Ampere's law path: For each Amperian loop:
Biot-Savart integration: For each field point r:
Dipole calculation:
Superposition assembly: Sum contributions from all sources at each observation point. Track components separately to 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]
Got: Explicit expression for B(r) at observation points, with correct units (Tesla or Gauss) and convergence check for numerical results.
If fail: Integral diverges? Check for missing regularization (e.g., field on wire itself diverges for infinitely thin wire -- use finite wire radius). Numerical results oscillate with N? Integrand has near-singularity that requires adaptive quadrature or analytical subtraction of singular part.
Verify result against known physics before trusting it:
Far-field dipole limit: At large r, any localized current distribution should produce field that matches magnetic dipole formula. Compute B from your result in limit r -> infinity and compare with (mu_0 / 4 pi) * [3(m . r_hat) r_hat - m] / r^3.
Near-field infinite-wire limit: Close to long straight segment of conductor (distance rho << length L), field should approach B = mu_0 I / (2 pi rho). Check this for relevant portion of your geometry.
On-axis special cases: For loops and solenoids, on-axis field has simple closed forms:
Symmetry consistency: Verify components predicted to vanish by symmetry (Step 1) are indeed zero in computed result. Nonzero forbidden component indicates error.
Dimensional analysis: Verify B has units of Tesla. Every term should carry mu_0 * [current] / [length] or equivalent.
## 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] |
Got: All limiting cases match. Field has correct units, symmetry, asymptotic behavior.
If fail: Failed limit indicates error in integral setup or evaluation. Most common causes: wrong sign in cross product, missing factor of 2 or pi, incorrect limits of integration, or coordinate system mismatch between source and field point parameterizations.
Extend analysis to include material effects and produce field visualizations:
Linear magnetic materials: Replace mu_0 with mu = mu_r * mu_0 inside material. Apply boundary conditions at material interfaces:
Nonlinear materials (B-H curves): For ferromagnetic cores:
Demagnetization effects: For finite-geometry magnetic materials (e.g., short rods, spheres), internal field reduced by demagnetization factor N_d: H_internal = H_applied - N_d * M.
Field visualization:
Physical intuition check: Confirm field pattern makes qualitative sense. Field should be strongest near current source, should circulate around currents (right-hand rule), should decay with distance.
## 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]
Got: Complete field solution including material effects where relevant. Visualization shows closed field lines consistent with div B = 0 and qualitative behavior matching physical intuition.
If fail: Field lines do not close? Calculation has divergence error -- recheck integral or numerical method. Material introduces unexpected field amplification? Verify mu_r applied only inside material volume and boundary conditions correctly enforced at every interface.
solve-electromagnetic-induction -- use computed B-field to analyze time-varying flux and induced EMFformulate-maxwell-equations -- generalize to full set of Maxwell's equations including displacement current and wave propagationdesign-electromagnetic-device -- apply magnetic field analysis to design of electromagnets, motors, transformersformulate-quantum-problem -- quantum treatment of magnetic interactions (Zeeman effect, spin-orbit coupling)