Skip to main content

electromagnetism

Electromagnetic theory including Maxwell's equations, electrostatics, magnetostatics, electromagnetic waves, and radiation for physics and engineering applications.

Quellinformationen

Repository
ffsshhttiikk/opencode-agents-skills
Letzte Quellaktivität
28. Februar 2026 um 22:53
Erkannte Sprache von SKILL.md
Englisch
Sterne
3
Forks
2

Installationsoptionen

Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.

Quelldateien prüfen

Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.

SKILL.md wird angezeigt

SKILL.md
Quellanweisungen · Schreibgeschützte Vorschau
name
electromagnetism
description
Electromagnetic theory including Maxwell's equations, electrostatics, magnetostatics, electromagnetic waves, and radiation for physics and engineering applications.
category
physics
tags
["physics","electromagnetism","maxwell-equations","electrostatics","magnetostatics","em-waves","radiation"]
difficulty
intermediate
author
neuralblitz
# Electromagnetism ## What I do I provide comprehensive expertise in electromagnetism, the branch of physics describing electromagnetic forces between charged particles. I enable you to apply Maxwell's equations, solve electrostatic and magnetostatic problems, analyze electromagnetic wave propagation, calculate radiation patterns, and model electromagnetic fields in materials. My knowledge spans from Coulomb's law to relativistic electrodynamics essential for electrical engineering, optics, plasma physics, and astrophysics. ## When to use me Use electromagnetism when you need to: calculate electric and magnetic fields of charge/current distributions, analyze wave propagation in various media, design antennas and waveguides, solve boundary value problems, compute electromagnetic radiation and scattering, model dielectric and magnetic materials, calculate forces and torques on charges and currents, or analyze electromagnetic compatibility. ## Core Concepts - **Maxwell's Equations**: Four fundamental equations governing all electromagnetic phenomena (Gauss's law, Gauss's magnetism law, Faraday's law, Ampère-Maxwell law). - **Electrostatics**: Electric fields from stationary charges with potential energy and equipotential surfaces. - **Magnetostatics**: Magnetic fields from steady currents with Biot-Savart law and Ampère's law. - **Electromagnetic Induction**: Time-varying magnetic fields inducing electric fields (Faraday's law) with self/mutual inductance. - **Electromagnetic Waves**: Self-propagating solutions to Maxwell's equations traveling at speed c. - **Boundary Conditions**: Matching conditions for fields at interfaces between different media. - **Potentials and Gauge Transformations**: Scalar and vector potentials with freedom to choose gauges (Coulomb, Lorenz). - **Radiation and Antennas**: Time-varying currents producing propagating electromagnetic fields. - **Electromagnetic Materials**: Response of matter to fields (polarization, magnetization, conductivity). - **Relativistic Electromagnetism**: Unification with special relativity and electromagnetic field tensors. ## Code Examples ### Electrostatics ```python import numpy as np from scipy.integrate import nquad, dblquad from scipy.special import ellipe, ellipk def point_charge_field(q, r, r0): """Electric field of point charge: E = kq(r-r0)/|r-r0|³""" k = 8.99e9 r_vec = np.array(r) - np.array(r0) r_mag = np.linalg.norm(r_vec) if r_mag < 1e-10: return np.zeros(3) return k * q * r_vec / r_mag**3 def line_charge_field(lambda_charge, x, L=10): """ Electric field of infinite line charge. E = (2kλ)/r radially outward """ k = 8.99e9 r = np.abs(x) if r < 1e-10: return 0 return 2 * k * lambda_charge / r * np.sign(x) def charged_ring_field(z, R, Q): """ Electric field on axis of charged ring. E_z = kQz/(z²+R²)^(3/2) """ k = 8.99e9 return k * Q * z / (z**2 + R**2)**1.5 def charged_disk_field(z, R, sigma): """ Electric field on axis of charged disk. E_z = (2πkσ)[1 - z/√(z²+R²)] """ k = 8.99e9 if z == 0: return 2 * np.pi * k * sigma return 2 * np.pi * k * sigma * (1 - z / np.sqrt(z**2 + R**2)) # Example calculations Q = 1e-9 # 1 nC z = 0.1 # 10 cm from charge print("Point charge field:") print(f" E at z=0.1m from q=1nC: {point_charge_field(Q, [z, 0, 0], [0, 0, 0])[0]:.2e} V/m") print(f"\nCharged ring (R=0.1m, Q=1μC):") for z_val in [0.05, 0.1, 0.2, 0.5]: E = charged_ring_field(z_val, 0.1, 1e-6) print(f" E(z={z_val}m) = {E:.2e} V/m") print(f"\nCharged disk (R=0.1m, σ=1e-5 C/m²):") for z_val in [0.01, 0.05, 0.1]: E = charged_disk_field(z_val, 0.1, 1e-5) print(f" E(z={z_val}m) = {E:.2e} V/m") # Electric potential def point_charge_potential(q, r, r0): """V = kq/|r-r0|""" k = 8.99e9 r_vec = np.array(r) - np.array(r0) return k * q / np.linalg.norm(r_vec) def dipole_potential(p, r, theta): """ Potential of electric dipole. V = kp·r̂/r² = kp cos(θ)/r² """ k = 8.99e9 return k * p * np.cos(theta) / r**2 # Capacitance calculations def parallel_plate_capacitor(A, d, epsilon_r=1): """C = ε₀εᵣA/d""" epsilon_0 = 8.85e-12 return epsilon_0 * epsilon_r * A / d def cylindrical_capacitor(a, b, L, epsilon_r=1): """C = 2πε₀εᵣL/ln(b/a)""" epsilon_0 = 8.85e-12 return 2 * np.pi * epsilon_0 * epsilon_r * L / np.log(b/a) def spherical_capacitor(a, b, epsilon_r=1): """C = 4πε₀εᵣab/(b-a)""" epsilon_0 = 8.85e-12 return 4 * np.pi * epsilon_0 * epsilon_r * a * b / (b - a) print(f"\nCapacitance calculations:") print(f" Parallel plate (A=1cm², d=1mm): {parallel_plate_capacitor(1e-4, 1e-3)*1e12:.2f} pF") print(f" Cylindrical (a=1mm, b=2mm, L=10cm): {cylindrical_capacitor(1e-3, 2e-3, 0.1)*1e12:.2f} pF") print(f" Spherical (a=1cm, b=2cm): {spherical_capacitor(0.01, 0.02)*1e12:.2f} pF") ``` ### Magnetostatics ```python import numpy as np from scipy.integrate import quad def biot_savart(I, dl, r, r0): """ Magnetic field from current element. dB = (μ₀I/4π) dl × r̂/r² """ mu_0 = 4 * np.pi * 1e-7 r_vec = np.array(r) - np.array(r0) r_mag = np.linalg.norm(r_vec) r_hat = r_vec / r_mag dl_vec = np.array(dl) cross = np.cross(dl_vec, r_hat) return mu_0 * I / (4 * np.pi) * cross / r_mag**2 def infinite_wire_field(I, r): """ Magnetic field of infinite straight wire. B = (μ₀I)/(2πr) φ̂ """ mu_0 = 4 * np.pi * 1e-7 return mu_0 * I / (2 * np.pi * np.abs(r)) def circular_loop_field(z, R, I): """ Magnetic field on axis of circular loop. B_z = (μ₀I R²)/(2(R²+z²)^(3/2)) """ mu_0 = 4 * np.pi * 1e-7 return mu_0 * I * R**2 / (2 * (R**2 + z**2)**1.5) def solenoid_field(n, I, L, z): """ Magnetic field of ideal solenoid. B = μ₀nI (inside), 0 (outside) """ mu_0 = 4 * np.pi * 1e-7 n_density = n / L return mu_0 * n_density * I print("Magnetostatic fields:") print(f" Infinite wire (I=1A, r=0.1m): B = {infinite_wire_field(1, 0.1):.2e} T") print(f" Circular loop (I=1A, R=0.1m, z=0): B = {circular_loop_field(0, 0.1, 1):.2e} T") print(f" Solenoid (n=1000, L=0.1m, I=1A): B = {solenoid_field(1000, 1, 0.1, 0):.2e} T") # Magnetic vector potential def infinite_wire_potential(I, r): """ Vector potential of infinite wire (Coulomb gauge). A_z = (μ₀I/2π) ln(r/r₀) """ mu_0 = 4 * np.pi * 1e-7 return mu_0 * I / (2 * np.pi) * np.log(r) def circular_loop_potential(R, I, r, theta): """ Vector potential of circular loop (Bessel functions for off-axis). Simplified: A_φ = (μ₀IR/πk) √((1-k²/2)) [Complete elliptic integral] """ mu_0 = 4 * np.pi * 1e-7 return mu_0 * I * R / (2 * np.pi) # Inductance calculations def solenoid_inductance(n, A, L): """L = μ₀n²A = μ₀(N²A)/L""" mu_0 = 4 * np.pi * 1e-7 return mu_0 * n**2 * A / L def toroid_inductance(N, a, b, mu_r=1): """L = (μ₀μᵣN²a/b) ln(b/a)""" mu_0 = 4 * np.pi * 1e-7 return mu_0 * mu_r * N**2 * a / b * np.log(b/a) def parallel_wire_inductance(d, a, L): """ Inductance per unit length of parallel wires. L/L' = (μ₀/π) [ln(d/a) - 0.5] """ mu_0 = 4 * np.pi * 1e-7 return mu_0 / np.pi * (np.log(d/a) - 0.5) print(f"\nInductance calculations:") A = np.pi * (0.01)**2 # 1cm radius print(f" Solenoid (n=1000, L=0.1m, A=πcm²): L = {solenoid_inductance(1000, A, 0.1)*1000:.2f} mH") # Magnetic force def parallel_wires_force(I1, I2, d, L): """Force per unit length between parallel currents.""" mu_0 = 4 * np.pi * 1e-7 return mu_0 * I1 * I2 / (2 * np.pi * d) * L I1, I2 = 100, 100 # 100 A each d = 0.1 # 10 cm apart L = 1 # 1 m length print(f"\nMagnetic force:") print(f" Parallel wires (I=100A, d=0.1m, L=1m): F = {parallel_wires_force(I1, I2, d, L):.2f} N") ``` ### Electromagnetic Waves ```python import numpy as np def wave_speed(epsilon, mu): """Speed of EM wave in medium: v = 1/√(εμ)""" epsilon_0 = 8.85e-12 mu_0 = 4 * np.pi * 1e-7 return 1 / np.sqrt(epsilon * epsilon_0 * mu * mu_0) def wave_impedance(epsilon, mu): """Intrinsic impedance: η = √(μ/ε)""" eta_0 = 377 # Ohms (free space) return eta_0 * np.sqrt(mu / epsilon) def skin_depth(frequency, conductivity, permeability): """δ = √(2/(ωμσ))""" mu_0 = 4 * np.pi * 1e-7 omega = 2 * np.pi * frequency return np.sqrt(2 / (omega * mu * conductivity)) # Wave propagation in media c = 3e8 # Speed of light print("EM wave propagation:") print(f" Free space: v = {c:.2e} m/s, η = 377 Ω") # In dielectric (εᵣ = 4) v_dielectric = c / 2 eta_dielectric = 377 / 2 print(f" Dielectric (εᵣ=4): v = {v_dielectric:.2e} m/s, η = {eta_dielectric:.1f} Ω") # In conductor (copper at 1 MHz) sigma_copper = 5.8e7 # S/m mu_r_copper = 1 f = 1e6 delta = np.sqrt(2 / (2 * np.pi * f * mu_0 * sigma_copper)) print(f" Copper at 1 MHz: δ = {delta*1e6:.2f} μm") # Wave equation solution def plane_wave_E(z, t, E0, k, omega): """E(z,t) = E0 cos(kz - ωt) ŷ""" return E0 * np.cos(k * z - omega * t) def plane_wave_B(z, t, E0, c): """B(z,t) = (E0/c) cos(kz - ωt) x̂""" return E0 / c * np.cos(k * z - omega * t) # Poynting vector def poynting_vector(E, B): """S = E × B/μ₀""" mu_0 = 4 * np.pi * 1e-7 return np.cross(E, B) / mu_0 def time_average_poynting(E0, eta): """⟨S⟩ = E₀²/(2η)""" return E0**2 / (2 * eta) print(f"\nPoynting vector:") E0 = 100 # V/m print(f" Free space, E₀=100V/m: ⟨S⟩ = {time_average_poynting(E0, 377):.2f} W/m²") # Reflection and transmission def fresnel_reflection(n1, n2, theta_i): """Normal incidence reflection coefficient.""" return (n2 - n1) / (n2 + n1) def fresnel_transmission(n1, n2, theta_i): """Normal incidence transmission coefficient.""" return 2 * n1 / (n2 + n1) n_air, n_glass = 1.0, 1.5 R = fresnel_reflection(n_air, n_glass, 0) T = fresnel_transmission(n_air, n_glass, 0)
Auf GitHub ansehen
Diese SKILL.md ist sehr gross, daher zeigt SkillsMP hier nur den ersten Abschnitt. Auf GitHub ansehen