SuperScreen

Getting Started

  • Installation
  • Quickstart
  • Background

Tutorials

  • Working with polygons
  • Magnetic field sources
  • Terminal currents
  • Saving and loading models
  • GPU acceleration
  • Parallel processing
  • Generating the SuperScreen logo

API Reference

  • Devices & Geometry
  • Solver
  • Finite Element Methods
  • Visualization
  • Field Sources

About SuperScreen

  • Change Log
  • License
  • Contributing
  • References
SuperScreen
  • »
  • Generating the SuperScreen logo
  • Edit on GitHub

Generating the SuperScreen logo¶

The SuperScreen logo is a superconducting “S” screening a uniform applied magnetic field. This notebook generates the logo as follows:

  1. Define a matplotlib TextPath object and use it to extract polygon vertices that draw an “S”.

  2. Create a superscreen.Device to represent the superconducting “S”.

  3. Solve for the response of the “S” to an applied magnetic field.

  4. Visualize the resulting screening currents and fields.

[1]:
%config InlineBackend.figure_formats = {"retina", "png"}
%matplotlib inline

import os

os.environ["OPENBLAS_NUM_THREADS"] = "1"

import numpy as np
from matplotlib.textpath import TextPath
from matplotlib.font_manager import FontProperties

import superscreen as sc

SAVE = False

Define the TextPath:

[2]:
fontprops = FontProperties(weight="bold", family="sans-serif")
path = TextPath((0, 0), "S", size=10, prop=fontprops)

Sample each of the TextPath’s Bezier curves to get polygon vertices:

[3]:
t = np.linspace(0, 1, 11)
segments = [bezier(t) for bezier, _ in path.iter_bezier()]
points = np.concatenate(segments)

Center the resulting points and remove duplicates:

[4]:
points -= points.mean(axis=0)
_, ix = np.unique(points, axis=0, return_index=True)
points = points[np.sort(ix)]

Create and plot a superscreen.Polygon representing the “S”:

[5]:
S = sc.Polygon(points=points).resample(501)
ax = S.plot(marker=".")
../_images/notebooks_logo_9_0.png

Create a Device containing the Polygon:

[6]:
layers = [
    sc.Layer("base", Lambda=1, z0=0),
]

S.layer = "base"
S.name = "S"
films = [S]

abstract_regions = [
    sc.Polygon(
        "bounding_box",
        layer="base",
        points=sc.geometry.circle(4.75, center=(0, -0.35)),
    ),
]

device = sc.Device(
    "S",
    layers=layers,
    films=films,
    abstract_regions=abstract_regions,
)
[7]:
fig, ax = device.draw()
../_images/notebooks_logo_12_0.png
[8]:
device.make_mesh(min_points=4_000, smooth=100)
[9]:
ax = device.plot(mesh=True)
../_images/notebooks_logo_14_0.png

Solve for the Device’s response to a constant applied field:

[10]:
solutions = sc.solve(
    device=device,
    applied_field=sc.sources.ConstantField(1),
    field_units="mT",
)
INFO:superscreen.solve:Calculating base response to applied field.

Plot and save the results:

[11]:
fig_formats = ["png"]
[12]:
fig, axes = solutions[-1].plot_currents(
    grid_shape=500, streamplot=False, vmin=0, vmax=750, colorbar=False
)

for a in axes:
    a.axis("off")
    a.set_title("")

if SAVE:
    fig.set_facecolor("none")
    for fmt in fig_formats:
        fig.savefig(f"../images/logo_currents.{fmt}", dpi=600, bbox_inches="tight")
../_images/notebooks_logo_19_0.png
[13]:
fig, axes = solutions[-1].plot_currents(
    grid_shape=500,
    streamplot=False,
    vmin=0,
    vmax=800,
    colorbar=False,
)

for a in axes:
    a.axis("off")
    a.set_title("")
    a.set_xlim(-25, 25)
    a.set_ylim(-5.1, 5.1)

if SAVE:
    fig.set_facecolor("none")
    for fmt in fig_formats:
        fig.savefig(
            f"../images/logo_currents_small.{fmt}", dpi=600, bbox_inches="tight"
        )
../_images/notebooks_logo_20_0.png
[14]:
fig, axes = solutions[-1].plot_fields(colorbar=False)

for a in axes:
    a.axis("off")
    a.set_title("")

if SAVE:
    fig.set_facecolor("none")
    for fmt in fig_formats:
        fig.savefig(f"../images/logo_fields.{fmt}", dpi=600, bbox_inches="tight")
../_images/notebooks_logo_21_0.png
[15]:
fig, axes = solutions[-1].plot_streams(colorbar=False)

for a in axes:
    a.axis("off")
    a.set_title("")

if SAVE:
    fig.set_facecolor("none")
    for fmt in fig_formats:
        fig.savefig(f"../images/logo_streams.{fmt}", dpi=600, bbox_inches="tight")
../_images/notebooks_logo_22_0.png
[16]:
device = sc.TransportDevice(
    "S",
    layer=layers[0],
    film=films[0],
    source_terminals=[
        sc.Polygon("source", points=sc.geometry.box(0.1, 2, center=(-2.92, -2.8))),
    ],
    drain_terminal=sc.Polygon(
        "drain", points=sc.geometry.box(0.1, 2, center=(2.32, 2.4))
    ),
)
[17]:
device.make_mesh(min_points=2_000)
INFO:superscreen.device.device:Generating mesh...
INFO:superscreen.device.device:Finished generating mesh with 2064 points and 3626 triangles.
INFO:superscreen.device.device:Calculating weight matrix.
INFO:superscreen.device.device:Calculating Laplace operator.
INFO:superscreen.device.device:Calculating kernel matrix.
INFO:superscreen.device.device:Calculating gradient matrix.
[18]:
ax = device.plot(mesh=True)
../_images/notebooks_logo_25_0.png
[19]:
solutions = sc.solve(device, terminal_currents=dict(source="-1 uA"))
INFO:superscreen.solve:Calculating base response to applied field.
[20]:
fig, axes = solutions[-1].plot_currents(
    grid_shape=500,
    streamplot=True,
    colorbar=False,
    vmin=0,
    vmax=1.5,
)
fig.set_facecolor("k")

for a in axes:
    a.axis("off")
    a.set_title("")

if SAVE:
    for fmt in fig_formats:
        fig.savefig(
            f"../images/logo_terminal_currents.{fmt}", dpi=600, bbox_inches="tight"
        )
../_images/notebooks_logo_27_0.png
[21]:
fig, axes = solutions[-1].plot_streams(colorbar=False)

for a in axes:
    a.axis("off")
    a.set_title("")

if SAVE:
    fig.set_facecolor("none")
    for fmt in fig_formats:
        fig.savefig(
            f"../images/logo_terminal_streams.{fmt}", dpi=600, bbox_inches="tight"
        )
../_images/notebooks_logo_28_0.png
[22]:
sc.version_table()
[22]:
SoftwareVersion
SuperScreen0.8.0
Numpy1.24.1
SciPy1.10.0
matplotlib3.6.2
ray2.2.0
jax0.4.1
IPython8.8.0
Python3.9.15 (main, Oct 26 2022, 11:17:18) [GCC 9.3.0]
OSposix [linux]
Number of CPUsPhysical: 1, Logical: 2
BLAS InfoOPENBLAS
Wed Jan 11 19:33:34 2023 UTC
[ ]:

Next Previous

© Copyright 2021-2022, Logan Bishop-Van Horn. Revision 14ff92f2.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: latest
Versions
latest
stable
Downloads
On Read the Docs
Project Home
Builds