Example #1
0
def threefold(n, h, d, points=True):
    s = System(hextess(n, points))
    ct = []
    ct.append(PatternRangeConstraint(min=0, max=1.))
    for p in 0, 4*np.pi/3, 2*np.pi/3:
        x = np.array([d/3**.5*np.cos(p), d/3**.5*np.sin(p), h])
        r = euler_matrix(p, np.pi/2, np.pi/4, "rzyz")[:3, :3]
        for i in "x y z xy xz yz".split():
            ct.append(PotentialObjective(derivative=i, x=x,
                                         rotation=r, value=0))
        for i, v in ("xx", 1), ("yy", 1):
            ct.append(PotentialObjective(derivative=i, x=x,
                                         rotation=r, value=v))
    s.rfs, c = s.optimize(ct)
    return s, c
Example #2
0
def five_wire(edge, width, top, mid, bot):
    e, r, t, m, b = edge, width/2, top + mid/2, mid/2, -bot - mid/2
    electrodes = [
        ("tl", [[(-e, e), (-e, t), (-r, t), (-r, e)]]),
        ("tm", [[(-r, e), (-r, t), (r, t), (r, e)]]),
        ("tr", [[(r, e), (r, t), (e, t), (e, e)]]),
        ("bl", [[(-e, -e), (-r, -e), (-r, b), (-e, b)]]),
        ("bm", [[(-r, -e), (r, -e), (r, b), (-r, b)]]),
        ("br", [[(r, -e), (e, -e), (e, b), (r, b)]]),
        ("r", [[(-e, t), (-e, m), (e, m), (e, t)],
               [(-e, b), (e, b), (e, -m), (-e, -m)]]),
        ("c",  [[(-e, m), (-e, -m), (e, -m), (e, m)]]),
        ]
    s = System([PolygonPixelElectrode(name=n, paths=map(np.array, p))
                for n, p in electrodes])
    s["r"].rf = 1.
    return s
Example #3
0
fig, ax = plt.subplots(subplot_kw=dict(aspect="equal"))
mesh.plot(ax)

# explore it in fancy 3D
# fire up a mayavi2 window showing base mesh, charges on final mesh
# and isosurfaces of the pseudopotential
# Result.view(prefix, "RF")
# need to start the full eventloop for the window.
# close it to return control to the notebook
# from pyface.api import GUI
# GUI().start_event_loop()

from electrode import System, GridElectrode

# load the electrostatics results into a electrode.System()
s = System()
for name in "DC1 DC2 DC3 DC4 DC5 RF".split():
    r = Result.from_vtk(prefix, name)
    e = GridElectrode.from_result(r)
    e.name = name
    s.append(e)
s["RF"].rf = 1.

n = 30
xyz = grid.to_mgrid()
p = s.potential(xyz.reshape(3, -1).T, 0).reshape(xyz[0].shape)
v = np.linspace(0, 2e-2, 21)
fig, ax = plt.subplots()
ax.set_aspect("equal")
ax.contour(xyz[1, 10, :, :],
           xyz[2, 10, :, :],
Example #4
0
# explore it in fancy 3D
# fire up a mayavi2 window showing base mesh, charges on final mesh
# and isosurfaces of the pseudopotential
Result.view(prefix, "RF")
# need to start the full eventloop for the window.
# close it to return control to the notebook
from pyface.api import GUI
GUI().start_event_loop()

# <codecell>

from electrode import System, GridElectrode

# load the electrostatics results into a electrode.System()
s = System()
for name in "DC1 DC2 DC3 DC4 DC5 RF".split():
    r = Result.from_vtk(prefix, name)
    e = GridElectrode.from_result(r)
    e.name = name
    s.append(e)
s["RF"].rf = 1.

# <codecell>

from scipy.constants import atomic_mass
x0 = s.minimum((0, 0, 1.))
for _ in s.analyze_static(x0, m=25*atomic_mass, u=50.,
                          l=40e-6, o=100e6*2*np.pi):
    print(_)
Example #5
0
# compensate stray fields and confine the ion axially.
# 
# The `shim()` method can be used to calculate voltage vectors for these
# dc electrodes that are result in orthogonal effects with regards to some
# cartesian partial derivatives at certain points. To use it we build a
# temporary new system `s1` holding only the dc electrodes. Since these dc
# electrode instances also appear in our primary system `s`, changes in
# voltages are automatically synchronized between the two systems.
# 
# We then can calculate the shim voltage vectors that result in unit
# changes of each of the partial derivatives `y, z, xx, xy, xz, yy` at
# `x0` and plot the voltage distributions.

# <codecell>

s1 = System([e for e in s if not e.rf])
derivs = "y z xx xy xz yy".split()
u = s1.shims([(x0, None, deriv) for deriv in derivs])
fig, ax = plt.subplots(2, len(derivs)/2, figsize=(12, 10))
for d, ui, axi in zip(derivs, u, ax.flat):
    with s1.with_voltages(dcs=ui):
        s.plot_voltages(axi)
        axi.set_aspect("equal")
        axi.set_xlim(-r, r)
        axi.set_ylim(-r, r)
        um = ui[np.argmax(np.fabs(ui))]
        axi.set_title("%s, max=%g" % (d, um))

# <markdowncell>

# Rf/dc pattern optimization