File:Circulation accordeon animation.gif

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Circulation_accordeon_animation.gif(720 × 50 pixels, file size: 381 KB, MIME type: image/gif, looped, 200 frames, 20 s)

Captions

Captions

Example of a stop-and-go traffic.

Summary[edit]

 
This plot was created with Matplotlib.
Description
Français : Illustration d'une circulation en accordéon.
English: Example of a stop-and-go traffic.
Date
Source Own work
Author Cdang

Python source

#!/usr/bin/python3

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

chemin=""
nom="Circulation_accordeon_animation.gif"

nL = 35 # nombre de véhicules dans la longueur
nl = 3 # nombre de voies
L = nL*2 # longueur de voie

N = 200 # nombre d'images générées

v0 = 0.25 # vitesse globale de flux
vsin = 10*v0 # amplitude des perturbations sinusoïdales de vitesse
pesp = 0.3 # amplitude du placement aléatoire

xbase = np.linspace(0, L, nL)
x0 = np.array([xbase, xbase, xbase]) + pesp*np.random.randn(nl, nL)
x0[x0<0] = 0
x0[x0>L] = L

y0 = np.ones(nL)

fig, ax = plt.subplots(figsize = [10, 0.7])
ligne1, = ax.plot(x0[0,:], y0, "sk")
ligne2, = ax.plot(x0[1,:], 2*y0, "sk")
ligne3, = ax.plot(x0[2,:], 3*y0, "sk")
ax.get_xaxis().set_visible(False)
ax.get_yaxis().set_visible(False)

plt.show()

def anime(i):
    dx = i*v0
    x = x0 + dx + vsin*np.sin(6*np.pi*(x0+dx)/L)
    x[x>L] = x[x>L]-L
    ligne1.set_xdata(x[0,:])
    ligne2.set_xdata(x[1,:])
    ligne3.set_xdata(x[2,:])
    return ligne1, ligne2, ligne3

ani = animation.FuncAnimation(
    fig, anime, interval=100, blit=True, save_count=N)

ani.save(chemin+nom, writer="imagemagick")

Licensing[edit]

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution
This file is licensed under the Creative Commons Attribution 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.

File history

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

Date/TimeThumbnailDimensionsUserComment
current16:00, 21 December 2023Thumbnail for version as of 16:00, 21 December 2023720 × 50 (381 KB)Cdang (talk | contribs)paramètres différents pour un effet plus visible
11:02, 21 December 2023Thumbnail for version as of 11:02, 21 December 2023720 × 72 (404 KB)Cdang (talk | contribs)Uploaded own work with UploadWizard

There are no pages that use this file.

File usage on other wikis

The following other wikis use this file: