File:Mplwp skydive trajectory.svg

From testwiki
Jump to navigation Jump to search
    Original file (SVG file, nominally 480 × 500 pixels, file size: 44 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: Plot of a ballistic trajectory with air resistance for a typical skydive from an airplane. The trajectory follows the differential equation r→¨(t)=−μ|v|⋅v→−g⋅y→̂ with initial conditions r→(0)=0→,r→˙(0)=v0x→̂.

    The parameters are:

    • g=9.81m/s2, vmax=50m/s, μ=k/m=g/vmax2
    • The horizontal starting velocity takes the values v0=0m/s, v0=17m/s, v0=33m/s, v0=50m/s
    The second-order ordinary differential equation system is reduced to a first-order system, using velocity components as independent variables. The system is then solved numerically using Scipy odeint.
    Date
    Source Own work
    Author Geek3
    SVG development
    InfoField
     The SVG code is valid.
     This plot was created with mplwp, the Matplotlib extension for Wikipedia plots.
    Source code
    InfoField

    mplwp source code

    The plot was generated with mplwp 1.8
    #!/usr/bin/python
    # -*- coding: utf8 -*-
    
    import matplotlib.pyplot as plt
    import matplotlib as mpl
    import numpy as np
    from math import *
    
    code_website = 'http://commons.wikimedia.org/wiki/User:Geek3/mplwp'
    try:
        import mplwp
    except ImportError, er:
        print 'ImportError:', er
        print 'You need to download mplwp.py from', code_website
        exit(1)
    
    name = 'mplwp_skydive_trajectory.svg'
    fig = mplwp.fig_standard(mpl)
    fig.set_size_inches(480. / fig.dpi, 500. / fig.dpi)
    mplwp.move_axes(fig, 24, 6)
    
    xlim = -10,320; fig.gca().set_xlim(xlim)
    ylim = -340,20; fig.gca().set_ylim(ylim)
    fig.gca().set_aspect('equal')
    fig.gca().xaxis.set_major_locator(mpl.ticker.MultipleLocator(100))
    fig.gca().yaxis.set_major_locator(mpl.ticker.MultipleLocator(100))
    
    from scipy.integrate import odeint
    from scipy.optimize import brentq
    def ballistic(g, mu, xy0, v0, alpha0, tt):
        # use a four-dimensional vector function vec = [x, y, vx, vy]
        def dif(vec, t):
            v = sqrt(vec[2]**2 + vec[3]**2)
            return [vec[2], vec[3], -mu*v*vec[2], -g -mu*v*vec[3]]
        
        # solve the differenctial equation numerically
        vec = odeint(dif, [xy0[0], xy0[1], v0*cos(alpha0), v0*sin(alpha0)], tt)
        return vec[:,0], vec[:,1] # return x(tt) and y(tt)
    
    g = 9.81
    vmax = 50.
    mu = g / vmax**2
    alpha0 = 0.
    
    for iv, v0 in enumerate((0, 17, 33, 50)):
        t1 = brentq(lambda t: ballistic(g,mu,[0,0],v0,alpha0,[0,t])[1][1]-ylim[0],0,20)
        t = np.linspace(0, t1, 5001)
        x, y = ballistic(g, mu, [0, 0], v0, alpha0, t)
        plt.plot(x, y, label='$v_0 = {:.0f}\,m/s$'.format(v0), zorder=-iv)
        col = fig.gca().lines[-1].get_color()
        xmax = ballistic(g, mu, [0, 0], v0, alpha0, [0, 100*vmax/g])[0][-1]
        plt.axvline(xmax, 0, 0.33, linestyle='--', dashes=[10,10],
            color=col, zorder=-5, lw=1.5)
        times = np.arange(t1)
        xt, yt = ballistic(g, mu, [0, 0], v0, alpha0, times)
        plt.plot(xt, yt, '.', color=col, label=None, zorder=-iv-0.5)
        
        if v0 == 50.:
            for ti, xi, yi in zip(times, xt, yt):
                plt.text(xi+8*sin(pi/2*ti/10), yi+8*cos(pi/2*ti/10),
                    '{:.0f}s'.format(ti), ha='left', va='center', fontsize=10)
    
    plt.xlabel('x [m]')
    plt.ylabel('y [m]')
    fig.gca().xaxis.labelpad = 0
    fig.gca().yaxis.set_label_coords(-0.08, 0.95)
    mpl.rc('legend', borderaxespad=0.4)
    plt.legend(loc='upper right')
    
    plt.savefig(name)
    mplwp.postprocess(name)
    

    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

    Computed trajectories of a skydiver

    Items portrayed in this file

    depicts

    8 September 2020

    image/svg+xml

    File history

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

    Date/TimeThumbnailDimensionsUserComment
    current19:31, 8 September 2020Thumbnail for version as of 19:31, 8 September 2020480 × 500 (44 KB)wikimediacommons>Geek3time markers

    There are no pages that use this file.