File:QuadrupoleContour.svg

From testwiki
Jump to navigation Jump to search
    Original file (SVG file, nominally 540 × 540 pixels, file size: 158 KB)

    This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.

    Summary

    Description
    English: Contour plot of the equipotential surfaces of an electric quadrupole field. The field is accurately computed from a physical model.
    Date
    Source Own work
    Author Geek3
    SVG development
    InfoField
     The SVG code is valid.
     This plot was created with Matplotlib.
    Source code
    InfoField

    Python code

    import numpy as np
    from matplotlib import pyplot as plt
    from matplotlib import colors
    
    def simplify_contours(qcset, thresh=plt.rcParams['path.simplify_threshold']):
        for c in qcset.collections:
            paths = c.get_paths()
            for i, p in enumerate(paths):
                p.simplify_threshold = thresh / plt.gcf().dpi
                paths[i] = p.cleaned(simplify=True)
    
    xmax = 3.2
    vmax = 4
    levels = np.linspace(-vmax, vmax, 22)
    X, Y = np.mgrid[-xmax:xmax:400j, -xmax:xmax:400j]
    V  = 1.0 / np.maximum(np.sqrt((X + 1)**2 + (Y + 1)**2), 1e-5)
    V += 1.0 / np.maximum(np.sqrt((X - 1)**2 + (Y - 1)**2), 1e-5)
    V -= 1.0 / np.maximum(np.sqrt((X + 1)**2 + (Y - 1)**2), 1e-5)
    V -= 1.0 / np.maximum(np.sqrt((X - 1)**2 + (Y + 1)**2), 1e-5)
    plt.figure(figsize=(6, 6)).add_axes([0, 0, 1, 1])
    contf = plt.contourf(X, Y, V, levels=levels, cmap='RdBu_r', extend='both',
           norm=colors.SymLogNorm(linthresh=1.5, vmin=-vmax, vmax=vmax))
    simplify_contours(contf, plt.rcParams['lines.linewidth'])
    cont = plt.contour(X, Y, V, levels=contf.levels, colors='k', linestyles='solid')
    plt.xticks([]), plt.yticks([])
    plt.gca().set_aspect(aspect='equal')
    plt.gca().axis('off')
    for i in -1,1:
        for j in -1,1:
            plt.text(i, j, {-1:u'\u2212', 1:'+'}[i*j],
                     size=18, ha='center', va='center')
    plt.savefig('QuadrupoleContour.svg')
    

    Licensing

    I, the copyright holder of this work, hereby publish it under the following license:
    w:en:Creative Commons
    attribution share alike
    This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
    You are free:
    • to share – to copy, distribute and transmit the work
    • to remix – to adapt the work
    Under the following conditions:
    • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
    • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

    Captions

    Add a one-line explanation of what this file represents

    Items portrayed in this file

    depicts

    22 October 2017

    162,169 byte

    image/svg+xml

    265348925ac38aeda5216d57189d8cbaa5df4607

    File history

    Click on a date/time to view the file as it appeared at that time.

    Date/TimeThumbnailDimensionsUserComment
    current23:52, 14 May 2018Thumbnail for version as of 23:52, 14 May 2018540 × 540 (158 KB)wikimediacommons>Geek3Potential must be 1/r, not 1/r².

    There are no pages that use this file.