File:Driven-pendulums-resonance-animation.gif
Driven-pendulums-resonance-animation.gif (220 × 136 pixels, file size: 120 KB, MIME type: image/gif, looped, 100 frames, 4.0 s)
Captions
Summary[edit]
DescriptionDriven-pendulums-resonance-animation.gif |
English: Animation of three identical pendulums of resonance frequency ω0 and damping D=0.05. The pendulums are driven with the same strength, but different driving frequencies ω:
|
Date | |
Source |
Own work This plot was created with Matplotlib. |
Author | Geek3 |
Source Code[edit]
The plot was generated with Python Matplotlib.
Python Matplotlib source code |
---|
#!/usr/bin/python
# -*- coding: utf8 -*-
import os
import inspect
from math import *
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib import animation
# settings
mpl.rcParams['path.snap'] = False
fname = 'driven-pendulums-resonance-animation'
size = 220, 136
nframes = 100
susp = 16
f0 = 3.0
pendulums = [
{'x0':29, 'y0':117.5, 'f':2.0, 'A':4, 'D':0.05, 'l':89, 'phi0':0.},
{'x0':110, 'y0':117.5, 'f':3.0, 'A':4, 'D':0.05, 'l':89, 'phi0':0.},
{'x0':191, 'y0':117.5, 'f':4.0, 'A':4, 'D':0.05, 'l':89, 'phi0':0.}]
for p in pendulums:
D = p['D']
eta = p['f'] / f0
# use harmonic approximation
p['Arel'] = 1.0 / sqrt((1. - eta**2)**2 + (2.*eta*D)**2)
p['Phaserel'] = atan2(2 * eta * D, 1.0 - eta**2)
def animate(nframe, saveframes=False):
print nframe, nframes
t = float(nframe) / nframes
plt.clf()
fig.gca().set_position((0, 0, 1, 1))
plt.xlim(0, size[0])
plt.ylim(0, size[1])
plt.axis('off')
for p in pendulums:
dxSusp = p['A'] * sin(p['phi0'] + 2*pi*p['f']*t)
dsPend = p['A'] * sin(p['phi0'] + 2*pi*p['f']*t - p['Phaserel']) * p['Arel']
PhiPend = (dsPend - dxSusp) / p['l']
dxPend = dxSusp + p['l'] * sin(PhiPend)
dyPend = -p['l'] * cos(PhiPend)
xSusp = p['x0'] + dxSusp
xPend = p['x0'] + dxPend
yPend = p['y0'] + dyPend
# draw pendulum
s = 0.72
plt.plot([p['x0'] - susp, p['x0'] + susp],
[p['y0'], p['y0']], '-k', lw=3)
plt.plot([xSusp, xPend], [p['y0'], yPend], '-k', lw=1.5)
plt.plot([xSusp], [p['y0']], '.k', markersize=12)
plt.plot([xPend], [yPend], 'o', color='#aaaaaa',
markersize=14, markeredgewidth=1.5)
if saveframes:
# export frame
dig = int(ceil(log10(nframes)))
fsavename = ('frame{:0' + str(dig) + '}.svg').format(nframe)
fig.savefig(fsavename)
with open(fsavename) as f: content = f.read()
content = content.replace('pt"', 'px"').replace('pt"', 'px"')
with open(fsavename, 'w') as f: f.write(content)
fig = plt.figure(figsize=(size[0]/72., size[1]/72.))
#anim = animation.FuncAnimation(fig, animate, frames=nframes)
#anim.save(fname + '.gif', writer='imagemagick', fps=25)
# use imagemagick on svgs rather than builtin imagemagick support
# this avoids snapping and offers some custom settings
os.chdir(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))))
for i in range(nframes):
animate(i, True)
os.system('convert -loop 0 -delay 4 frame*.svg +dither -posterize 16 ' + fname + '.gif')
for i in os.listdir('.'):
if i.startswith('frame') and i.endswith('.svg'):
os.remove(i)
|
Licensing[edit]
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.http://www.gnu.org/copyleft/fdl.htmlGFDLGNU Free Documentation Licensetruetrue |
- 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/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 21:08, 10 April 2016 | 220 × 136 (120 KB) | Geek3 (talk | contribs) | smaller drive amplitude | |
20:57, 10 April 2016 | 220 × 136 (121 KB) | Geek3 (talk | contribs) | {{Information |Description ={{en|1=Animation of three identical pendulums of resonance frequency ''ω''<sub>0</sub> and damping ''D''=0.1. The pendulums are driven with the sam... |
You cannot overwrite this file.
File usage on Commons
The following 2 pages use this file:
File usage on other wikis
The following other wikis use this file:
- Usage on cv.wikipedia.org
- Usage on de.wikipedia.org
- Usage on de.wikibooks.org
- Usage on zh-yue.wikipedia.org
Metadata
This file contains additional information such as Exif metadata which may have been added by the digital camera, scanner, or software program used to create or digitize it. If the file has been modified from its original state, some details such as the timestamp may not fully reflect those of the original file. The timestamp is only as accurate as the clock in the camera, and it may be completely wrong.
GIF file comment | https://commons.wikimedia.org/wiki/File:Driven-pendulums-resonance-animation.gif |
---|