COMPUTATIONAL METHODS IN ENGINEERING AND SCIENCE EPMESC X, Aug. 21-23, 2006, Sanya, Hainan, China ©2006 Tsinghua University Press & Springer The Pseudo-spectral Method and Matlab Implement Songling Wang1, Zhengren Wu1*, Youliang Cheng1, Lu Da2 1 2 School of Energy & Power Engineering, North china electric power university, Baoding, 071003 China Hebei University, Baoding, 071003, China Email: [email protected] Abstract The pseudo-spectral method based on function approach was good for solving nonlinear equation. Matlab can solve many complicated engineering problem, and the numerical results can be showed by its excellent graphics. It is convenience to program with the Matlab for PS method. The PS method used Fourier transform treatment of the space dependence together with a leapfrog scheme in time, in the paper, the traditional Lax-Wendroff form is discarded, and the PS method is adopted. We adopt the averages of adjacent levels and restart the scheme from the new levels for the possibility of separation of the solutions between successive time levels. And the complex-valued problem in Fourier transform is treated. Taking an example, the fKdV equation is calculated, and draws the waterfall with Matlab. Key words: PS method, fKdV equation, Matlab, waterfall, solitary INTRODUCTION The pseudo-spectral method (PS method) based on trigonometric interpolation is good for solving nonlinear equation and often provided good numerical solution of PDE. The PS method, spectral method, and Tau method, which are different versions of spectral methods, can be derived from the method of weighted residual, and the methods stem from the classical Ritz-Galerkin method, which have high accuracy so called the convergence of “infinite order”. Although finite difference methods and finite element methods are very successful in numerical solutions of partial differential equations for long histories, but the surplus term in difference scheme sometimes can affect the computing result, thereby, the function approach method becomes a more popular one in the numerical simulation. It is no doubt that for some problems spectral methods are more favorable because of its high accuracy. Now, the pseudo-spectral method is the major one, for its small aliasing error. And the pseudo-spectral method is the simplest and can be viewed as a higher order finite difference method. Its simplicity and close relation with finite difference methods make it a preferred alternation for finite difference methods if the solution shows enough regularity, it can provide higher accurate solution than finite difference methods with the same number of grid points, or achieve the same accuracy with a much less number of grid points, so the method have been used by some peoples with development on different equations [1-3]. As a common spectral method, the pseudo-spectral method used spectral disperse (Fourier transform) treatment of the space dependence together with a difference scheme in time [1], then the derivatives (or other operations) are algebraic in the transformed variable. The PS method is second order accuracy in time. It has been used extensively for the computation of approximately solutions of differential equations with periodic solutions. Spectral methods for nonlinear problems have also advanced rapidly with their application to fluid dynamics, weather prediction, nonlinear heat conductions, plate problem, quantum mechanics, and other fields [4-5]. There are some kinds of language for program in solving the PDE, Matlab has been a good one in numerical computation and simulation, and it has been widely used in hydrodynamics and applied mathematics, etc. many complicated engineering problem can be solved by Matlab, and the numerical results can be showed by its excellent graphics. It is convenience to program with the Matlab for the pseudo-spectral method. In the paper, we implement the pseudo-spectral method with Matlab software, and researched fKdV equation with the method. At last, the waterfall plot of the equation is showed. ⎯ 942 ⎯ THE PS METHOD AND MATLAB IMPLEMENT The PS method used Fourier transform treatment of the space dependence together with a difference scheme in time, and, in the paper, we adopted the leapfrog scheme. The PS method can solve some questions connected with wave: Such as solitary wave interactions, wave breaking, and the development of nonlinear wave train instabilities, and so on. The nonlinear equation with integral term can also be resolved with the method. It is well known that leapfrog scheme is three layers explicit formulation, the first layer is the initial value, and the value of the third layer is request. For computation, the value of the second layer must be known firstly, the traditional method that calculates it with Lax-Wendroff scheme in the computational process, but for higher derivative, it is more complex to calculate with Taylor expansion. We replace the Lax-Wendroff scheme with PS method. So there are two parts in the program. A well-known feature of leapfrog time differencing is the possibility of separation of the solution between two successive time levels. This could be expected since small round off errors, uncorrelated for odd and even time steps, triggered large-scale effects for unstable solutions. This possibility of separation is however easily circumvented. When we have calculated the solution up to levels t − Δt , t , and t + Δt , we can introduce levels t − 0.5Δt , and t + 0.5Δt as averages of adjacent levels and restart the scheme from these two new levels. Another possibility of separation in leapfrog type schemes is that every second mesh value for fixed t may separate from every other second value. In our case there is no complete separation. As is common for explicit finite-difference schemes, smoothing or numerical damping must be used to suppress the unphysical high-frequency oscillations. For nonlinear problems, the pseudo-spectral method is easier to be implemented, but it is not as stable as spectral method due to the aliasing interaction. There have been some filtering techniques to remedy this deficiency [6-8]. With the follow procedure we can cancel the effect of the aliasing. For ease of presentation, the spatial period is normalized to [0, 2π ] , and was discredited by N equidistant points. The function u ( x, t ) , numerically defined only on these points, can be transformed to the discrete Fourier space by uˆk = Fu = 1 N −1 −2π ikj N , ∑u je N j =0 N −1 u j = F −1u = ∑ uˆk e 2π ikj N , k =0 k = 0,1L N − 1 (1) j = 0,1,L, N − 1 (2) These transforms can be performed efficiently with the fast Fourier transform algorithm. And in Matlab, the function FFT and IFFT can be eased used for the above computation. It follows directly form (1) that uˆk + pN = 1 N −1 −2π i ( k + pN ) j ∑u je N j =0 N = uˆk (3) For any integer p , thus modes for which k values differ by N (or by any multiple of N ) become indistinguishable at the node points. We can therefore interpret uˆ N − k = uˆ− k , k = 0,1L N 2 − 1 . This interpretation of the mode numbers turns out to be necessary when determining the interpolation trigonometric polynomial of lower degree, finding its derivative, and so on, otherwise, and the trigonometric polynomials takes complex values in between the real data points and so its derivatives become nonsensical. Here, for the period[a, b] , Requiring the interpolating trigonometric polynomial to take the values u j at locations x j = a + jh ( j = 0,1, 2,L N − 1 , h = (b − a) N ), according to the above equation (1) and (2), lead to the following closed form (now expressed not in j , but in x ∈ [a, b] ): u ( x) = N 2 −1 ∑ k =− N 2 +1 2 uˆk e b − a π ik ( x − a ) + uˆ± N 2 cos πN 2 ( x − a) (4) Its derivations as follows: u′ = 2 π ik ( x − a ) 2 πN πN b−a ˆ − π iku e uˆ± N 2 sin ( x − a) ∑ k 2 2 k =− N 2 +1 b − a N 2 −1 ⎯ 943 ⎯ (5) u ′′′ = − 2 π ik ( x − a ) 8 π 3N 3 πN 3 3 b−a ˆ + π ik u e uˆ± N 2 sin ( x − a) k 3 8 2 k =− N 2 +1 (b − a ) N 2 −1 ∑ (6) At grid points x j , the modes 0 and ± N 2 do not contribute anything to the derivation. This leads to the easily implemented procedure for obtaining value for the first derivation u x and the third derivation u xxx . With above method, the aliasing error can be avoided effectively. Many theoretical models of internal solitons or surface wave are based on the weakly nonlinear Korteweg-de Vries equation and its modifications. The KdV equation is a nonlinear equation arising in the study of a number of physical problems, such as water waves, plasma physics, and anharmonic lattices. The first-order approximation of long nonlinear surface waves in flow of an inviscid, incompressible fluid over a bottom results in a forced Korteweg-de Vries equation (fKdV). Those equations involve a balance between nonlinearity and dispersion at leading-order and the effect of the bottom [9-11]. The fKdV as follow: − ∂A ∂A ∂ 3 A ∂G +A − 3 + =0 ∂t ∂x ∂x ∂x (7) In which, A( x, t ) is the amplitude of the critical mode, t is the time, and x is the spatial coordinate, G is the height of the obstacle or the function of the bottom (the forcing). There is a distinction between positive and negative forcing and the solitary polarity according to the sign of G . Simultaneity, and G presents the central position of the forcing and the size of the forcing. So, with PS method, and denote dt the time step, and the fKdV equation would be approximated by A( x, t + dt ) − A( x.t − dt ) + 2iAdtF −1 ( kFA) − 2dtiF −1 ( k 3 FA) + 2dtGx = 0 (8) Matlab is a software package for computation in engineering, science, and applied mathematics. It offers a powerful programming language, excellent graphics, and a wide range of expert knowledge. The focus in Matlab is on computation, not mathematics. All results are not only numerical but inexact, thanks to the rounding errors inherent in computer arithmetic. The limitation to numerical computation can be seen as a drawback, but it is a source of strength too. On the other hand, compared to other numerically oriented languages like C++ and Fortran, Matlab is much easier to use and comes with a huge standard library. The only major unfavorable comparison here is a gap in execution speed; this gap can often be narrowed or closed with good Matlab programming, but Matlab is never going to be the best tool for high-performance computing. Draw up program by Matlab, the code for (9) as follows: Ax(s, :) = real (N*ifft (Ax2(s, :))); Axxx(s, :) = real (N*ifft (Axxx2(s, :))); k=1:N; A(s+1, k) = A (s-1, k) +2*dt*A(s, k). *Ax(s, k)… −2*dt. *Axxx(s, k) + 0.18*dt*exp (−0.09*((k-1)*dx−170.7). ^2). *((k-1)*dx−170.7); In which, s denotes time layer, k is the node point, “Ax” denotes the first derivate, and “Axxx” denotes the third derivate. In the computational process, there are two parts in the program, the first is for the value of the second layer, and the other one is for value of the all layer. Because we replaced the Lax-Wendroff in leapfrog scheme with the PS method, so the program for PS method will be used for twice. In the program for the all layer, the time step takes dt , and in the program for the second layer, the time takes dt 10 , our numerical experiments showed that the number of the step did not affect the results only the computation time. After calculation for three layers ahead, we can make the other layers easily. RESULTS OF FKDV EQUATION BY MATLAB Taking an example, we make Matlab program to calculate solitons solutions of fKdV equation, and draw the waterfall with Matlab. The waterfalls as follows: Form these waterfalls; the changes of the surface wave with the different bottom can be show. About our conclusions, some are in agreement with classical ones, some verify the known experiment, and some new conclusions must be further tested by the experiment. ⎯ 944 ⎯ (a) a positive bottom (b) a negative bottom (c) a forward-step upward convex bottom (d) a combined bottom with two negative bottom Figure 1: Waterfalls of fKdV equation with different bottom (the time interval between neighboring curves is 1.5) Acknowledgements The support of the National Natural Science Foundation of China (No. 10272044) and Research Fund for the Doctoral Program of the ministry of Education of China (20040079004) are gratefully acknowledged. REFERENCES 1. Fornberg B, Whitham GB. A numerical and theoretical study of certain nonlinear wave phenomena. J. Fluid. Mech, Trans R. Soc., London, 1978; 289: 333-404. 2. Ma HP, Guo BY. The Fourier pesudospectral method wih a restrain operator for the Korteweg-de Vries equation. Journal of Computational Physics, 1986; 65: 120-137. 3. Milewski PA, Tabak EG. Pseudospectral procedures for the solution of nonlinear wave equations with examples form free-surface flows. SIAM J. Sci. Comput., 1999; 21(3): 1102-1114. 4. Guo BY, Ma HP. Spectral methods for two-dimensional incompressible. Journal of Mathematical Research & Exposition, 1999; 19(2): 375-390. 5. Guo BY, Li J. Fourier-Chebyshev pseudo-spectral approximation with mixed filtering for two-dimensional viscous incompressible flow. Journal of Applied Sciences, 1995; 13(3): 253-271. 6. Woodward P, Collela P. The numerical simulations of two-dimensional fluid flows with strong shock. J. Comp. Phys., 1984; 54: 115-173. 7. Kuo P. The convergence of the spectral scheme for solving two-dimensional vorticity equation. J. of Comp. Math., 1983; 1: 353-362. 8. Guo BY, Xiong YS. Pseudospectral-finite difference method for three-dimensional vorticity equation with bilaterally periodic boundary condition. Journal of Mathematical Research & Exposition, 1994; 14(1): 1-23. 9. Djordjevic VD, Redekopp LG. The fission and disintegration of internal solitary waves moving over two-dimensional topography. Journal of Physical Oceanography, 1978; 11(8): 1016-1024 10. Grimshaw G, Yi Z. Resonant generation of finite-amplitude waves by the flow of a uniform stratified fluid over topography. J. Fluid. Mech, 1991; 229: 603-628. 11. John PB. Weakly non-local solitons for capiliary-gravity waves: fifth-degree Korteweg-de Vries equation. Physics D, 1991; 48: 129-146. ⎯ 945 ⎯
© Copyright 2026 Paperzz