1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

Computational Physics - M. Jensen Episode 2 Part 6 pptx

20 389 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 20
Dung lượng 340,74 KB

Nội dung

14.6. PHYSICS EXAMPLES 269 V L C R Figure 14.3: Simple RLC circuit with a voltage source . 14.6.2 Damping of harmonic oscillations and external forces Most oscillatory motion in nature does decrease until the displacement becomes zero. We call such a motion for damped and the system is said to be dissipative rather than conservative. Con- sidering again the simple block sliding on a plane, we could try to implement such a dissipative behavior through a drag force which is proportional to the first derivative of , i.e., the velocity. We can then expand Eq. (14.50) to (14.58) where is the damping coefficient, being a measure of the magnitude of the drag term. We could however counteract the dissipative mechanism by applying e.g., a periodic external force (14.59) and we rewrite Eq. (14.58) as (14.60) Although we have specialized to a block sliding on a surface, the above equations are rather general for quite many physical systems. If we replace by the charge , with the resistance , the velocity with the current , the inductance with the mass , the spring constant with the inverse capacitance and the force with the voltage drop , we rewrite Eq. (14.60) as (14.61) The circuit is shown in Fig. 14.3. How did we get there? We have defined an electric circuit which consists of a resistance with voltage drop , a capacitor with voltage drop and an inductor with voltage 270 CHAPTER 14. DIFFERENTIAL EQUATIONS mg mass m length l pivot θ Figure 14.4: A simple pendulum. drop . The circuit is powered by an alternating voltage source and using Kirchhoff’s law, which is a consequence of energy conservation, we have (14.62) and using (14.63) we arrive at Eq. (14.61). This section was meant to give you a feeling of the wide range of applicability of the methods we have discussed. However, before leaving this topic entirely, we’ll dwelve into the problems of the pendulum, from almost harmonic oscillations to chaotic motion! 14.6.3 The pendulum, a nonlinear differential equation Consider a pendulum with mass at the end of a rigid rod of length attached to say a fixed frictionless pivot which allows the pendulum to move freely under gravity in the vertical plane as illustrated in Fig. 14.4. The angular equation of motion of the pendulum is again given by Newton’s equation, but now as a nonlinear differential equation (14.64) 14.6. PHYSICS EXAMPLES 271 with an angular velocity and acceleration given by (14.65) and (14.66) For small angles, we can use the approximation and rewrite the above differential equation as (14.67) which is exactly of the same form as Eq. (14.50). We can thus check our solutions for small values of against an analytical solution. The period is now (14.68) We do however expect that the motion will gradually come to an end due a viscous drag torque acting on the pendulum. In the presence of the drag, the above equation becomes (14.69) where is now a positive constant parameterizing the viscosity of the medium in question. In order to maintain the motion against viscosity, it is necessary to add some external driving force. We choose here, in analogy with the discussion about the electric circuit, a periodic driving force. The last equation becomes then (14.70) with and two constants representing the amplitude and the angular frequency respectively. The latter is called the driving frequency. If we now define (14.71) the so-called natural frequency and the new dimensionless quantities (14.72) (14.73) 272 CHAPTER 14. DIFFERENTIAL EQUATIONS and introducing the quantity , called the quality factor, (14.74) and the dimensionless amplitude (14.75) we can rewrite Eq. (14.70) as (14.76) This equation can in turn be recast in terms of two coupled first-order differential equations as follows (14.77) and (14.78) These are the equations to be solved. The factor represents the number of oscillations of the undriven system that must occur before its energy is significantly reduced due to the viscous drag. The amplitude is measured in units of the maximum possible gravitational torque while is the angular frequency of the external torque measured in units of the pendulum’s natural frequency. 14.6.4 Spinning magnet Another simple example is that of e.g., a compass needle that is free to rotate in a periodically reversing magnetic field perpendicular to the axis of the needle. The equation is then (14.79) where is the angle of the needle with respect to a fixed axis along the field, is the magnetic moment of the needle, its moment of inertia and and the amplitude and angular frequency of the magnetic field respectively. 14.7 Physics Project: the pendulum 14.7.1 Analytic results for the pendulum Although the solution to the equations for the pendulum can only be obtained through numerical efforts, it is always useful to check our numerical code against analytic solutions. For small angles , we have and our equations become (14.80) 14.7. PHYSICS PROJECT: THE PENDULUM 273 and (14.81) These equations are linear in the angle and are similar to those of the sliding block or the RLC circuit. With given initial conditions and they can be solved analytically to yield (14.82) and (14.83) with . The first two terms depend on the initial conditions and decay exponentially in time. If we wait long enough for these terms to vanish, the solutions become independent of the initial conditions and the motion of the pendulum settles down to the following simple orbit in phase space (14.84) and (14.85) tracing the closed phase-space curve (14.86) with (14.87) This curve forms an ellipse whose principal axes are and . This curve is closed, as we will see from the examples below, implying that the motion is periodic in time, the solution repeats itself exactly after each period . Before we discuss results for various frequencies, quality factors and amplitudes, it is instructive to compare different numerical methods. In Fig. 14.5 we show the angle as function of time for the case with , and . The length is set equal to m and mass of the pendulum is set equal to kg. The inital velocity is and . Four different methods have been used to solve the equations, Euler’s method from Eq. (14.17), Euler-Richardson’s method in Eqs. (14.32)-(14.33) and finally the fourth-order Runge-Kutta scheme RK4. We note that after few time steps, we obtain the classical harmonic 274 CHAPTER 14. DIFFERENTIAL EQUATIONS motion. We would have obtained a similar picture if we were to switch off the external force, and set the frictional damping to zero, i.e., . Then, the qualitative picture is that of an idealized harmonic oscillation without damping. However, we see that Euler’s method performs poorly and after a few steps its algorithmic simplicity leads to results which deviate considerably from the other methods. In the discussion hereafter we will thus limit ourselves to Figure 14.5: Plot of as function of time with , and . The mass and length of the pendulum are set equal to . The initial velocity is and . Four different methods have been used to solve the equations, Euler’s method from Eq. (14.17), the half-step method, Euler-Richardson’s method in Eqs. (14.32)-(14.33) and finally the fourth-order Runge-Kutta scheme RK4. Only integration points have been used for a time interval . present results obtained with the fourth-order Runge-Kutta method. The corresponding phase space plot is shown in Fig. 14.6, for the same parameters as in Fig. ??. We observe here that the plot moves towards an ellipse with periodic motion. This stable phase-space curve is called a periodic attractor. It is called attractor because, irrespective of the initial conditions, the trajectory in phase-space tends asymptotically to such a curve in the limit . It is called periodic, since it exhibits periodic motion in time, as seen from Fig. ??. In addition, we should note that this periodic motion shows what we call resonant behavior since the the driving frequency of the force approaches the natural frequency of oscillation of the pendulum. This is essentially due to the fact that we are studying a linear system, yielding the well-known periodic motion. The non-linear system exhibits a much richer set of solutions and these can only be studied numerically. In order to go beyond the well-known linear approximation we change the initial conditions to say but keep the other parameters equal to the previous case. The curve for is 14.7. PHYSICS PROJECT: THE PENDULUM 275 Figure 14.6: Phase-space curve of a linear damped pendulum with , and . The inital velocity is and . shown in Fig. 14.7. This curve demonstrates that with the above given sets of parameters, after a certain number of periods, the phase-space curve stabilizes to the same curve as in the previous case, irrespective of initial conditions. However, it takes more time for the pendulum to establish a periodic motion and when a stable orbit in phase-space is reached the pendulum moves in accordance with the driving frequency of the force. The qualitative picture is much the same as previously. The phase-space curve displays again a final periodic attractor. If we now change the strength of the amplitude to we see in Fig. ?? that as func- tion of time exhibits a rather different behavior from Fig. 14.6, even though the initial contiditions and all other parameters except are the same. If we then plot only the phase-space curve for the final orbit, we obtain the following figure We will explore these topics in more detail in Section 14.8 where we extende our discussion to the phenomena of period doubling and its link to chaotic motion. 14.7.2 The pendulum code The program used to obtain the results discussed above is presented here. The program solves the pendulum equations for any angle with an external force . It employes several methods for solving the two coupled differential equations, from Euler’s method to adaptive size methods coupled with fourth-order Runge-Kutta. It is straightforward to apply this program to other systems which exhibit harmonic oscillations or change the functional form of the external force. # include < s t dio . h> 276 CHAPTER 14. DIFFERENTIAL EQUATIONS Figure 14.7: Plot of as function of time with , and . The mass of the pendulum is set equal to kg and its length to 1 m. The inital velocity is and . Figure 14.8: Phase-space curve with , and . The mass of the pendulum is set equal to kg and its length m The inital velocity is and . 14.7. PHYSICS PROJECT: THE PENDULUM 277 Figure 14.9: Phase-space curve for the attractor with , and . The inital velocity is and . # include < iostrea m . h> # include < math . h> # include < fstream . h> / D i f fer e n t methods f or sol vi ng ODEs are prese nted We are s olv in g the fo ll owi ng eq ation : m l ( phi ) ’ ’ + v i sc o s i t y ( phi ) ’ + m g sin ( phi ) = A cos (omega t ) I f you want to s olve s i mil a r equation s with other v alues you have to rew rit e the methods ’ d e r i v a t i v es ’ and ’ i n i t i a l i s e ’ and change the v ari abl es in the pri vat e part of the cl a ss Pendulum At f i r s t we rew rit e the equation using the foll ow ing d e fi n i t i o n s : omega_0 = s q rt ( g l ) t _r oo f = omega_0 t omega_roof = omega / omega_0 Q = (m g) / ( omega_0 r eib ) A_roof = A / (m g ) and we get a dimens ionle ss equati on 278 CHAPTER 14. DIFFERENTIAL EQUATIONS ( phi ) ’ ’ + 1/Q ( phi ) ’ + sin ( phi ) = A_roof cos ( omega_roof t_ ro of ) This equation can be w rit ten as two equat ions of f i r s t order : ( phi ) ’ = v ( v ) ’ = v /Q sin ( phi ) + A_roof cos ( omega_roof t_ ro of ) All numerical methods are appl ied to the la s t two eq uations . The a lgorith ms are taken from the book " An i ntr o duc t i on to computer sim ula ti on methods " / c las s pendelum { private : double Q , A_roof , omega_0 , omega_roof , g ; / / double y [ 2 ] ; / / f or the i n i t i a l valu es of phi and v int n ; / / how many s tep s double de lta _t , d e l t a _t_r o o f ; public : void derivat i v e s ( double , double , double ) ; void i n i t i a l i s e ( ) ; void eu le r ( ) ; void euler_cromer ( ) ; void midpoint ( ) ; void eu ler _ ric har d son ( ) ; void ha l f _st e p ( ) ; void rk2 ( ) ; / / runge kutta second order void rk4_ step ( double , double , double , double ) ; / / we need i t in f unc t io n rk4 ( ) and asc ( ) void rk4 ( ) ; / / runge kutta fourth order void asc ( ) ; / / runge kutta fourth order with ad aptiv e s te p s i z e con tr ol }; void pendelum : : d e r i v a t i v e s ( double t , double in , double out ) { / Here we are c alc u l ati n g the d e r i v a t i v es at ( dimens ionle ss ) time t ’ in ’ are the val ues of phi and v , which are used for the c alcu l a tio n The r e s u l t s are given to ’ out ’ / out [0]= in [ 1 ] ; / / out [ 0 ] = ( phi ) ’ = v i f (Q) out [1]= in [ 1 ] / ( ( double )Q) sin ( in [ 0 ] ) +A_roof cos ( omega_roof t ) ; / / [...]... k2 , k3 , k4 f o r v and phi , so we u s e t o a r r a y s k1 [ 2 ] and k2 [ 2 ] f o r t h i s k1 [ 0 ] , k2 [ 0 ] a r e t h e p a r a m e t e r s f o r phi , k1 [ 1 ] , k2 [ 1 ] a r e t h e p a r a m e t e r s f o r v Ê/ int i ; d ou b le t _ h ; d ou b le y o u t [ 2 ] , y_h [ 2 ] ; / / k1 [ 2 ] , k2 [ 2 ] , k3 [ 2 ] , k4 [ 2 ] , y_k [ 2 ] ; t_h =0; y_h [ 0 ] = y [ 0 ] ; / / p h i y_h [ 1 ] = y [ 1... + 1 0 / 6 0 Ê ( k1 [ 0 ] + 2 Ê k2 [ 0 ] + 2 Ê k3 [ 0 ] + k4 [ 0 ] ) ; y o u t [ 1 ] = y i n [ 1 ] + 1 0 / 6 0 Ê ( k1 [ 1 ] + 2 Ê k2 [ 1 ] + 2 Ê k3 [ 1 ] + k4 [ 1 ] ) ; } 14.7 PHYSICS PROJECT: THE PENDULUM 28 5 v o i d pendelum : : r k 4 ( ) { / Ê We a r e u s i n g t h e f o u r t h o r d e r RungeK u t t a a l g o r i t h m We have t o c a l c u l a t e t h e p a r a m e t e r s k1 , k2 , k3 ,... , hh , e r r m a x ; d ou b le y o u t [ 2 ] , y_h [ 2 ] , y_m [ 2 ] , y1 [ 2 ] const const const const d ou b le d ou b le d ou b le d ou b le we c a l c u l a t e a new s t e p s i z e u s i n g ^ ( 0 2 5 ) where " S a f e t y " i s c o n s t a n t y ( x+h ) , y2 [ 2 ] , d e l t a [ 2 ] , y s c a l [ 2 ] ; e p s = 1 0 e 6; safety =0.9; e r r c o n = 6 0 e 4; t i n y = 1 0 e 30; t_h =0;... ; } fout close ; } v o i d pendelum : : r k 2 ( ) { / Ê We a r e u s i n g t h e second o r d e r RungeK u t t a a l g o r i t h m We have t o c a l c u l a t e t h e p a r a m e t e r s k1 and k2 f o r v and phi , so we u s e t o a r r a y s k1 [ 2 ] and k2 [ 2 ] f o r t h i s k1 [ 0 ] , k2 [ 0 ] a r e t h e p a r a m e t e r s f o r phi , k1 [ 1 ] , k2 [ 1 ] a r e t h e p a r a m e t e r s f o r... ] a r e t h e p a r a m e t e r s f o r v Ê/ int i ; d ou b le t _ h ; d ou b le y o u t [ 2 ] , y_h [ 2 ] , k1 [ 2 ] , k2 [ 2 ] , y_k [ 2 ] ; t_h =0; y_h [ 0 ] = y [ 0 ] ; / / p h i y_h [ 1 ] = y [ 1 ] ; / / v o f s t r e a m f o u t ( ệ ắểỉ ) ; fout s e tf ( ios : : s c i e n t i f i c ) ; fout precisio n (20 ) ; f o r ( i = 1 ; i . 14 .6. PHYSICS EXAMPLES 26 9 V L C R Figure 14.3: Simple RLC circuit with a voltage source . 14 .6 .2 Damping of harmonic oscillations and external forces Most oscillatory motion in nature. 0 ] +1.0 / 6 .0 ( k1 [0] +2 k2 [0] +2 k3 [0]+ k4 [ 0]) ; yout [1]= yin [ 1 ] +1.0 / 6 .0 ( k1 [1] +2 k2 [1] +2 k3 [1]+ k4 [ 1]) ; } 14.7. PHYSICS PROJECT: THE PENDULUM 28 5 void pendelum : : rk4 (. errmax ; double yout [ 2] , y_h [ 2] , y _m [2] , y1 [ 2] , y2 [ 2 ] , delt a [ 2] , ys cal [ 2 ]; const double eps =1.0e 6; const double s a fet y =0.9; const double er rcon =6. 0e 4; const double

Ngày đăng: 07/08/2014, 12:22

TỪ KHÓA LIÊN QUAN