File:Driven-pendulums-resonance-animation.gif

頁面內容唔支援其他語言。
出自維基百科,自由嘅百科全書

Driven-pendulums-resonance-animation.gif(220 × 136 像素,檔案大細:120 KB ,MIME類型:image/gif、循環、100格、4.0 s)

摘要

描述
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 ω:
  • left: ω=2/3ω0
  • center: ω=ω0
  • right: ω=4/3ω0
One can see that the pendulums driven below and above resonance oscillate less, whereas the pendulum at resonance oscillates strongest. The pendulums also show different relative phases relative to the drive.
日期
來源 自己作品
 
This plot was created with Matplotlib.
作者 Geek3

Source Code

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)

協議

I, the copyright holder of this work, hereby publish it under the following licenses:
GNU head 根據自由軟體基金會發佈嘅無固定段落、封面文字同封底文字GNU自由文件授權條款第1.2或打後嘅版本,你獲授權可以重製、散佈同埋修改爾份文件。授權條款嘅副本喺章節GNU自由文件授權條款
w:en:Creative Commons
署名
Ĉi tiu dosiero estas disponebla laŭ la permesilo Krea Komunaĵo Atribuite 3.0 Neadaptita.
你可以:
  • 去分享 – 複製、發佈同傳播呢個作品
  • 再改 – 創作演繹作品
要遵照下面嘅條件:
  • 署名 – 你一定要畀合適嘅表彰、畀返指向呢個授權條款嘅連結,同埋寫明有無改過嚟。你可以用任何合理方式去做,但唔可以用任何方式暗示授權人認可咗你或者你嘅使用方式。
你可以揀你想用嘅牌照。

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

圖中顯示嘅係

10 4 2016

檔案歷史

撳個日期/時間去睇響嗰個時間出現過嘅檔案。

日期/時間縮圖尺寸用戶註解
現時2016年4月10號 (日) 21:08響2016年4月10號 (日) 21:08嘅縮圖版本220 × 136(120 KB)Geek3smaller drive amplitude
2016年4月10號 (日) 20:57響2016年4月10號 (日) 20:57嘅縮圖版本220 × 136(121 KB)Geek3{{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...

以下嘅1版用到呢個檔:

全域檔案使用情況

下面嘅維基都用緊呢個檔案:

Metadata