{ "cells": [ { "cell_type": "markdown", "id": "fd38713b", "metadata": {}, "source": [ "# Magnetic field sources" ] }, { "cell_type": "markdown", "id": "831b8ea9", "metadata": {}, "source": [ "The `superscreen.sources` module contains functions that can be used to generate several common types of applied magnetic fields for use in `SuperScreen` simulations:\n", "\n", "- `sources.ConstantField`: A spatially uniform out-of-plane field, $\\mu_0H_z(\\vec{r})=\\text{const.}$\n", "\n", "\n", "- `sources.Monopolefield` (also aliased as `sources.VortexField`): The $z$-component of the field from a magnetic monopole with a given magnetic charge. If the magnetic charge is $\\Phi_0=h/(2e)$, then this is an approximation for the field from a vortex trapped in a bulk superconductor with a small London penetration depth. For a monopole with magnetic charge $n\\Phi_0$ located at position $\\vec{r}_0=(x_0, y_0, z_0)$, the $z$-component of the magnetic field at position $\\vec{r}=(x, y, z)$ is given by:\n", " $$\\mu_0H_z(\\vec{r})=\\frac{n\\Phi_0}{2\\pi}\\frac{(\\vec{r}-\\vec{r}_0)\\cdot\\hat{z}}{|\\vec{r}-\\vec{r}_0|^3}.$$\n", "\n", "\n", "- `sources.PearlVortexField`: The $z$-component of the magnetic field at position $\\vec{r}=(x, y, z)$ from a Pearl vortex trapped at the origin in a superconducting film with Pearl length $2\\Lambda$:\n", " $$\\mu_0 H_z(\\vec{r}) = \\mathcal{F}^{-1}\\left\\{\\mathcal{F}\\{\\mu_0 H_z\\}(k_x, k_y, z)\\right\\} = \\mathcal{F}^{-1}\\left\\{\\frac{n\\Phi_0 e^{-kz}}{1 + 2\\Lambda k}\\right\\},$$\n", "\n", " where $\\mathcal{F}$ and $\\mathcal{F}^{-1}$ are the 2D Fourier transform and inverse Fourier transform, and $k_x$ and $k_y$ are spatial frequencies with $k\\equiv\\sqrt{k_x^2 + k_y^2}$. See [Physical Review Letters 92, 157006 (2004)](https://doi.org/10.1103/PhysRevLett.92.157006) (full text PDF [here](https://art.torvergata.it/retrieve/handle/2108/33451/53023/PRL%20Tafuri%202004.pdf)).\n", "\n", "\n", "- `sources.DipoleField`: The magnetic field from a distribution of magnetic dipoles. For a set of magnetic dipoles with moments $\\vec{m}_i$ located at positions $\\vec{r}_{0, i}=(x_i, y_i, z_i)$, the vector magnetic field at position $\\vec{r}=(x, y, z)$ is given by: \n", " $$\n", " \\mu_0\\vec{H}(\\vec{r}) = \\sum_i\\frac{\\mu_0}{4\\pi}\n", " \\frac{3\\hat{r}_i(\\hat{r}_i\\cdot\\vec{m}_i) - \\vec{m}_i}{|\\vec{r}_i|^3},\n", " $$\n", "\n", " where $\\vec{r}_i=\\vec{r} - \\vec{r}_{0, i}$.\n", "\n", "\n", "- `sources.SheetCurrentField`: The $z$-component of the field from a 2D sheet of current $S$ lying in the plane $z=z_0$ with spatially varying current density $\\vec{J}=(J_x, J_y)$.\n", " $$\\mu_0H_z(\\vec{r})=\\frac{\\mu_0}{2\\pi}\\int_S\\frac{J_x(\\vec{r}')(\\vec{r}-\\vec{r}')\\cdot\\hat{y} - J_y(\\vec{r}')(\\vec{r}-\\vec{r}')\\cdot\\hat{x}}{|\\vec{r}-\\vec{r}'|^3}\\,\\mathrm{d}^2r',$$\n", "\n", " where $\\vec{r}=(x, y, z)$ and $\\vec{r}'=(x', y', z_0)$." ] }, { "cell_type": "code", "execution_count": 1, "id": "d13c2aac", "metadata": {}, "outputs": [], "source": [ "# Automatically install superscreen from GitHub only if running in Google Colab\n", "if \"google.colab\" in str(get_ipython()):\n", " %pip install --quiet git+https://github.com/loganbvh/superscreen.git" ] }, { "cell_type": "code", "execution_count": 2, "id": "c42c2be6", "metadata": {}, "outputs": [], "source": [ "%config InlineBackend.figure_formats = {\"retina\", \"png\"}\n", "%matplotlib inline\n", "\n", "import os\n", "\n", "os.environ[\"OPENBLAS_NUM_THREADS\"] = \"1\"\n", "\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "plt.rcParams[\"figure.figsize\"] = (5, 4)\n", "plt.rcParams[\"font.size\"] = 10\n", "\n", "import superscreen as sc" ] }, { "cell_type": "code", "execution_count": 3, "id": "600fecc0", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| Software | Version |
|---|---|
| SuperScreen | 0.13.0 |
| Numpy | 2.4.4 |
| Numba | 0.65.1 |
| SciPy | 1.17.1 |
| matplotlib | 3.10.9 |
| IPython | 9.13.0 |
| Python | 3.14.4 | packaged by conda-forge | (main, Apr 8 2026, 02:33:53) [Clang 20.1.8 ] |
| OS | posix [darwin] |
| Number of CPUs | Physical: 10, Logical: 10 |
| BLAS Info | Generic |
| Tue Apr 28 20:42:25 2026 EDT | |