.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples\05_example_magnetic.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_05_example_magnetic.py: Magnetic Lens Creation ------------------- Initialize a magnetic lens with the same parameters as electrodes, but with a few new concepts. Mu_r is the relative permeability- a dimensionless constant specific to what material the magnet is. Iron has ~1000, air has 1, higher values increase the flux density (magnetic field strength). MMF is the magnetomotive force- sometimes referred to as ampere-turns. This is the magnetic analogue to voltage. By specifying MMF and Mu_r you control the properties of the magnet, especially since these are applicable both to DC electromagnets and permanent magnets. Since the paraxial ray equation can sometimes create harmless artefacts at the middle particle's trajectories, feel free to increase nr and nz more than you would for electrostatic lenses. The multigrid handler can take it. .. GENERATED FROM PYTHON SOURCE LINES 12-41 .. image-sg:: /auto_examples/images/sphx_glr_05_example_magnetic_001.png :alt: Picht, Display Options :srcset: /auto_examples/images/sphx_glr_05_example_magnetic_001.png :class: sphx-glr-single-img .. code-block:: Python :lineno-start: 12 import numpy as np from picht import ElectronOptics, MagneticLensConfig import matplotlib.pyplot as plt system = ElectronOptics(nr=200, nz=400, axial_size=0.1, radial_size=0.1) mag_config = MagneticLensConfig( start=100, length=50, ap_start=80, ap_width=40, outer_diameter = 100, mu_r=1000, mmf=200 ) system.add_magnetic_lens(mag_config) system.solve_fields() trajectories = system.simulate_beam( energy_eV=10000, start_z=0, r_range=(0.042, 0.058), angle_range=(0, 0), num_particles=20, simulation_time=2e-9 ) fig = system.visualize_system(trajectories=trajectories) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 4.648 seconds) .. _sphx_glr_download_auto_examples_05_example_magnetic.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 05_example_magnetic.ipynb <05_example_magnetic.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 05_example_magnetic.py <05_example_magnetic.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 05_example_magnetic.zip <05_example_magnetic.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_