OneSimulation docs Website Free books Plans on Gumroad

Docs › Build a first case in each physics package › Electromagnetics

5.5 Electromagnetics

onesim.physics.electromagnetics

For an AC field, choose FrequencyDomainMaxwell. Supply the frequency in Hz, an electromagnetic material and the phasor and amplitude conventions. The stationary solve returns complex phasors at that frequency. Add explicit PEC, impedance, waveguide port or periodic conditions suited to the experiment. WaveguideModeBasis describes incident modes and relative amplitudes. Choose a compatible H(curl) or mimetic carrier and a complex linear solver. Plot magnitude and phase separately and check absorbed power with the declared amplitude convention.

# geometry is a volume geometry. Add the conditions for your experiment.
from onesim.materials.electromagnetic import IsotropicElectromagneticMaterial
from onesim.numerics.fem import FiniteElement, Nedelec
from onesim.numerics.linear import ComplexSparseDirect
from onesim.physics.electromagnetics import FrequencyDomainMaxwell

em = FrequencyDomainMaxwell(
    domain=geometry.volume, frequency=1e7,
    material=IsotropicElectromagneticMaterial(
        relative_permittivity=1.0, relative_permeability=1.0, conductivity=0.001,
    ),
    phasor_convention="exp(-i*omega*t)", amplitude_convention="peak",
)
numerics = Numerics(
    spatial=FiniteElement(element=Nedelec(order=1)),
    linear_solver=ComplexSparseDirect(),
)

The fully sourced periodic case in test_maxwell_method_flexibility.py supplies a known field for both phasor signs and integrates the absorbed power density. test_finite_integration_electromagnetics.py compares supported metric and topological choices. Use MagneticDiffusion for a transient induction balance on a line. Use SeriesRLC, AveragedBuckConverter, or DCMotor for circuit and electromechanical states on LumpedDomain. For an RLC circuit initialize charge and current, then compare the voltage and stored energy to the circuit balance. The averaged buck model uses duty cycle as a physical input.