[关闭]
@zqbinggong 2016-04-19T23:29:54.000000Z 字数 4144 阅读 2266

the motion of the harmonic and anharmonic oscillator

homework of Computational Physics(level2),

张强 2013301020039

Code

oscillator.py

Abstract

The question ask us to describe the motion of a simple oscillator with the motion equation ,where we can take for convenience.If we take ,this is an example if an harmonic oscillator.If we take,this is an example if an anharmonic oscillator.Calculate the period of the oscillations for several different amplititudes(amplititudes in the range to are good choices).And in my program,I choose .

Key word

Euler methonds,oscillator,easygui

Background


Oscillation is the repetitive variation, typically in time, of some measure about a central value (often a point of equilibrium) or between two or more different states. The term 'vibration' is precisely used to describe mechanical oscillation but used as a synonym of 'oscillation' too. Familiar examples include a swinging pendulum and alternating current power.
Oscillations occur not only in mechanical systems but also in dynamic systems in virtually every area of science: for example the beating human heart, business cycles in economics, predator-prey population cycles in ecology, geothermal geysers in geology, vibrating strings in musical instruments, periodic firing of nerve cells in the brain, and the periodic swelling of Cepheid variable stars in astronomy.

Body

1Hharmonic oscillator

A simple harmonic oscillator is an oscillator that is neither driven nor damped,where we can set . It consists of a mass ''m'', which experiences a single force, ''F'', which pulls the mass in the direction of the point ''x''=0 and depends only on the mass's position ''x'' and a constant ''k''. Balance of forces for the system is

Solving this differential equation, we find that the motion is described by the function

where


Remark:in question3.4,we just consider the more simple situation where ,so we have and .

The motion is periodic, repeating itself in a sinusoida fashion with constant amplitude, ''A''. In addition to its amplitude, the motion of a simple harmonic oscillator is characterized by its period ''T'', the time for a single oscillation or its frequency , the number of cycles per unit time. The position at a given time ''t'' also depends on the phase, , which determines the starting point on the sine wave. The period and frequency are determined by the size of the mass ''m'' and the force constant ''k'', while the amplitude and phase are determined by the starting position and velocity.

The velocity and acceleration]of a simple harmonic oscillator oscillate with the same frequency as the position but with shifted phases. The velocity is maximum for zero displacement, while the acceleration is in the opposite direction as the displacement.

The potential energy stored in a simple harmonic oscillator at position ''x'' is

2.Anharmonic oscillator

If we take for other value,for example, is ,we can obtain a anharmonic case.The anharmonic oscillator is a little more complex than the harmonic oscillator.

3.Euler-Cromer method

We can use Euler-Cromer methon to find the solution. The explicit progress of Euler-Cromer method is showed there:
For each time step calculate and at time step

3. Implementation of the program

1.Firstly,the program pop-up a graphical interface ask you to input the value of .And our suggestion is to take ,and if you enter for ,another graphical interface would be popped-up to ensure your choice,because if , we only obtain several straight lines

2.Then,the program run ,drae the figure and save it.

3.So why don't I draw the 3D picture?----the program with vpython is writing now,please wait with patient!

Results(with easygui)

the graphical interface

1.If you enter 1 for ,the 'good' would be printed.

2.If you enter 0 for k, the computer would pop-up another grapthical interface to ensure your choice.Then you can click 'continue' to assert your choice,and you can click 'cancel' to re-enter the value of k

Results(figure)

1.the special case:


2.for


3.for


4.for


Connclusion

1.According to the results,we draw a conclusion that period is only dependent on

2.The motion of the anharmonic oscillator is also periodic.

3.With the larger and smaller ,we have larger period.

Acknowledgement

Thanks to Liu Wentao for his template.

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注