This article was downloaded by: [Marshall University] On: 02 November 2013, At: 00:51 Publisher: Taylor & Francis Informa Ltd Registered in England and Wales Registered Number: 1072954 Registered office: Mortimer House, 37-41 Mortimer Street, London W1T 3JH, UK International Journal of Mathematical Education in Science and Technology Publication details, including instructions for authors and subscription information: http://www.tandfonline.com/loi/tmes20 Introducing the boundary element method with MATLAB Keng-Cheng Ang a a National Institute of Education, Nanyang Technological University , 1 Nanyang Walk, Singapore 637616 Published online: 07 Jul 2008. To cite this article: Keng-Cheng Ang (2008) Introducing the boundary element method with MATLAB, International Journal of Mathematical Education in Science and Technology, 39:4, 505-519, DOI: 10.1080/00207390701722676 To link to this article: http://dx.doi.org/10.1080/00207390701722676 PLEASE SCROLL DOWN FOR ARTICLE Taylor & Francis makes every effort to ensure the accuracy of all the information (the “Content”) contained in the publications on our platform. However, Taylor & Francis, our agents, and our licensors make no representations or warranties whatsoever as to the accuracy, completeness, or suitability for any purpose of the Content. Any opinions and views expressed in this publication are the opinions and views of the authors, and are not the views of or endorsed by Taylor & Francis. The accuracy of the Content should not be relied upon and should be independently verified with primary sources of information. Taylor and Francis shall not be liable for any losses, actions, claims, proceedings, demands, costs, expenses, damages, and other liabilities whatsoever or howsoever caused arising directly or indirectly in connection with, in relation to or arising out of the use of the Content. This article may be used for research, teaching, and private study purposes. Any substantial or systematic reproduction, redistribution, reselling, loan, sub-licensing, systematic supply, or distribution in any form to anyone is expressly forbidden. Terms & Conditions of access and use can be found at http://www.tandfonline.com/page/termsand-conditions International Journal of Mathematical Education in Science and Technology, Vol. 39, No. 4, 15 June 2008, 505–519 CLASSROOM NOTES Introducing the boundary element method with MATLAB Keng-Cheng Ang* National Institute of Education, Nanyang Technological University, 1 Nanyang Walk, Singapore 637616 Downloaded by [Marshall University] at 00:51 02 November 2013 (Received 1 November 2006) The boundary element method provides an excellent platform for learning and teaching a computational method for solving problems in physical and engineering science. However, it is often left out in many undergraduate courses as its implementation is deemed to be difficult. This is partly due to the perception that coding the method requires complex programming skills beyond the ability of a typical undergraduate. In this article, we present a simple and systematic way of implementing the boundary element method for solving the Laplace’s equation using MATLAB, a numerical software package commonly used in undergraduate courses. The examples will demonstrate that a package such as MATLAB serves well in introducing as well as implementing the boundary element method. Keywords: boundary element method; Matlab implementation; Laplace’s equation; Matlab code 1. Introduction In many universities all over the world, the mathematical software MATLAB is being introduced to first year undergraduates pursuing engineering, science or mathematics courses. In fact, successful integration of MATLAB into mathematics or engineering mathematics courses have been frequently reported. For example, Dunn and Harman exploited the Graphics User Interface (GUI) features of MATLAB in designing programs to help students learn calculus [1]. Colgan reported the successful use of MATLAB in the teaching of core mathematics to first year engineering students [2]. More recently, Tonkes et al. managed to overcome several inherent difficulties involved in using MATLAB for numerical analysis to develop an innovative learning model for computational mathematics for their first year students [3]. Regarded as the language for technical computing, MATLAB has also been widely used by researchers in industrial and applied mathematics, as well as engineers, scientists and economists. One main reason for its popularity appears to be its efficiency in dealing with matrices and matrix algebra. In addition, the availability of special purpose toolboxes (such as Signal Processing, Optimization and Financial Toolboxes) has made it easier for researchers to use MATLAB in their work. The boundary element method (or BEM) is a computational tool that has been used in many areas of applied science and engineering. For example, the BEM has been applied to *Email: kengcheng.ang@nie.edu.sg ISSN 0020–739X print/ISSN 1464–5211 online ß 2008 Taylor & Francis DOI: 10.1080/00207390701722676 http://www.informaworld.com Downloaded by [Marshall University] at 00:51 02 November 2013 506 Classroom Notes solve problems involving the Schrödinger equation [4] and diffusion equation [5]. The BEM, however, is not introduced in undergraduate courses as frequently as other numerical methods such as finite difference or finite element methods. The main reason for this seems to be the fact that the BEM appears to be more complex to implement on the computer. Davies and Crann [6] have proposed using a spreadsheet such as Excel to introduce the BEM to undergraduates, and have developed a reasonably sound but fairly complex method of implementing it on Excel. While it is true that the spreadsheet may be a popular tool for teaching numerical methods, it also has its limitations. For instance, construction and manipulation of matrices are not the strengths of a typical spreadsheet software. Moreover, changes in values of parameters (such as number of boundary elements and hence sizes of the matrices and vectors) are not well handled by a spreadsheet nor are they convenient to make. Of course, one could use the Visual Basic Application (VBA) features provided in Excel to overcome these difficulties, but this would require a fairly sophisticated level of programming skill and defeats the purpose of using the spreadsheet in the first place. In contrast, a tool such as MATLAB provides the perfect platform and environment for a numerical method such as the BEM, which typically involves matrix computations. The ‘trade-off ’ (if it may be deemed as such), is that one has to contend with having to learn some programming. Nevertheless, as we shall demonstrate in this article, the level of programming skills required will be no higher than that required if VBA or FORTRAN were used. Moreover, MATLAB has user-friendly built-in graphical output display features which can be very useful in the post-processing phase of the BEM. In this article, we shall illustrate the implementation of the BEM using MATLAB. We shall restrict our discussion to the solution of the two-dimensional Laplace’s equation with given Dirichlet or Neumann or mixed boundary conditions. For a more detailed discussion on the origins and development of the method, the reader may wish to refer to books listed in the references such as [7], [8] and [9]. We shall also assume that the reader has a basic knowledge of MATLAB programming, although the reader may also wish to consult a standard text on MATLAB such as [10]. 2. Laplace’s equation One of the most convenient ways to introduce the BEM is through studying the solution of the two-dimensional Laplace’s equation r2 u ¼ @2 u @2 u þ ¼ 0, @x2 @y2 for ðx, yÞ 2 R, ð1Þ subject to boundary conditions u ¼ fðx, yÞ for ðx, yÞ 2 C , and q ¼ @u ¼ gðx, yÞ @n for ðx, yÞ 2 C , ð2Þ ð3Þ International Journal of Mathematical Education in Science and Technology 507 Cα n R Downloaded by [Marshall University] at 00:51 02 November 2013 Cβ Figure 1. Laplace’s equation in two dimensions for a region R. C n P R n Cε Figure 2. Domain which excludes a disc C" centred at P(, ). where R is a two-dimensional region in the x–y plane bounded by a simply closed curve C ¼ C [ C , as shown in Figure 1. A fundamental solution of Laplace’s equation in two dimensions is given by [11] u ¼ 1 ln ðx Þ2 þ ðy Þ2 : 4 ð4Þ We note that u* satisfies Laplace’s equation (1) everywhere in the region R except at point P(, ) where it has a singularity. However, if we consider a region R C", where C" is a small circle containing and centred at P(, ), then u* is defined and r2 u ¼ 0 in this region (Figure 2). Applying Green’s second identity for R C", we obtain Z Z Z 2 @u 2 @u u ur u u r u d ¼ u ds: ð5Þ @n @n RC" CþC" Clearly, the left hand side of the above equation is zero, and we thus have Z @u @u u u ds ¼ 0, @n @n CþC" ð6Þ 508 Classroom Notes which may be rewritten as Z Z @u @u @u @u u u u u ds ¼ ds: @n @n @n @n C C" Downloaded by [Marshall University] at 00:51 02 November 2013 It can be shown that for ð, Þ 2 R, Z @u ds ¼ uð, Þ lim u "!0þ C" @n Z and Further, it can also be shown that 8 Z <0 @u @u u u ds ¼ 1 : uð, Þ @n @n C" 2 lim "!0þ C" u ð7Þ @u ds ¼ 0: @n if ð, Þ 2 =R[C if ð, Þ lies on a smooth part of C: Summarizing, we can write: Z uð, Þ ¼ C @u @u u u ds @n @n ð8Þ where 8 0 > > < 1 ¼ > > :2 1 if ð, Þ 2 =R[C if ð, Þ lies on a smooth part of C ð9Þ if ð, Þ 2 R: Equation (8) is the boundary integral equation for the Laplace’s equation. We have merely ‘converted’ the problem stated in the form of a partial differential equation with boundary conditions, to a problem in the form of an integral equation in terms of the fundamental solution of Laplace’s equation. If we know everything on the right-hand side, we can in principle find the values of u(, ) for all points (, ) inside the domain R. Unfortunately, we do not have all the information we need and will have to find approximations to the unknowns. The next section describes how this is done using the boundary element approach. 3. The boundary element method In this section, we shall show how a simple boundary element numerical scheme may be obtained to find approximations to the solution of the boundary value problem given by Equations (1)–(3) at interior points of R. The first step of the BEM is to approximate the boundary C by a polygon with N straight-line segments. That is, we make C ’ C1 [ C2 [ C3 [ [ CN as illustrated in Figure 3. We construct these segments by choosing N points, say (x1, y1), (x2, y2), . . . , (xN, yN) on the boundary, and we define (xNþ1, yNþ1) ¼ (x1, y1). Then, Ck is the straight line joining (xk, yk) to (xkþ1, ykþ1). These straight line segments Ck for k ¼ 1, 2, . . . , N are known as boundary elements. International Journal of Mathematical Education in Science and Technology 509 CN C1 C2 Downloaded by [Marshall University] at 00:51 02 November 2013 C3 Figure 3. Curve approximated by boundary elements C1, C2, C3 , . . . , CN. For simplicity and convenience, we assume that values of u and @u=@n are constant over each boundary element. More specifically, we take the values at the midpoints of each element to be the values over the whole element. That is, for k ¼ 1, 2, . . . , N, u u k , and @u qk @n for ðx, yÞ 2 Ck , where u k and q k are values of u and @u=@n at the midpoint ðx k , y k Þ of boundary element Ck. Using this set-up for the boundary, we can write Equation (8) as an approximation given by uð, Þ ¼ N X ðu k Gk ð, Þ q k Fk ð, ÞÞ ð10Þ k¼1 where Z u ð, Þds ð11Þ @u ð, Þ ds @n Ck ð12Þ Fk ð, Þ ¼ Ck Z Gk ð, Þ ¼ If we know u k and q k , then we can use Equation (10) to find the values of u(, ) for ð, Þ 2 R. However, in a properly posed boundary value problem, either u k or q k (but not both) is known on any given portion of the boundary. We can, however, make use of Equation (10) to first find approximations to these unknown boundary values, before using it again to approximate the values at the interior points. To do so, we let (, ) be the midpoint of element Ck for k ¼ 1 to N, thus obtaining N equations with N unknowns. Noting that when (, ) is on Ck, ¼ 1/2, we have N X 1 ðu k Gk ðx m , y m Þ q k Fk ðx m , ym ÞÞ for m ¼ 1, 2, . . . , N, u m ¼ 2 k¼1 ð13Þ where um ¼ ð1=4Þ lnððx x m Þ2 þ ðy y m Þ2 Þ and ðx m , ym Þ is the midpoint of element Cm. 510 Classroom Notes To solve for the unknowns, it is convenient to write the equations given in (13) as a system of equations in the form of Az ¼ b. The unknowns are either u or q and are the elements in z with associated coefficients stored in matrix A b is made up of all the known values. What needs to be done is to construct the matrix A and the column vector b, and to keep track of the type of boundary value in each of the elements of z. In other words, for each m ¼ 1, 2, . . . , N, we need to construct N X Amk zk ¼ Downloaded by [Marshall University] at 00:51 02 November 2013 k¼1 N X bmk ð14Þ k¼1 We construct A and b systematically by considering the two cases, namely (a) when u is given, and (b) when q ¼ @u=@n is given over the boundary Ck, for each equation (m ¼ 1, 2, . . . , N) in (13). For each m (that is, each row in the matrix equation), we need to find the Amk entry, and the contribution bmk to the element in b by running through each boundary element Ck. If, over a boundary element Ck, u is known, then q is the unknown and the element in A is given by Amk ¼ Fk ðx m , y m Þ. The contribution to the corresponding element in b is either u k Gk ðx m , y m Þ if k 6¼ m, or u k Gk ðx m , y m Þ þ 1=2um if k ¼ m. On the other hand, if q is known over a boundary element Ck, then the contribution to b is q k Fk ðx m , ym Þ. The element in A is either Gk ðx m , y m Þ if k 6¼ m, or Gk ðx m , y m Þ 1=2 if k ¼ m. In summary, we have the following ‘rules’ for the construction of matrix A and vector b: 8 Fk ðx m , y m Þ if u given over Ck > > < if q given over Ck and k 6¼ m ð15Þ Amk ¼ Gk ðx m , ym Þ > 1 > : Gk ðx m , ym Þ if q given over Ck and k ¼ m 2 8 if > < q k Fk ðx m , y m Þ if bmk ¼ u k Gk ðx m , ym Þ > : 1 u k Gk ðx m , y m Þ þ 2 if q given over Ck u given over Ck and k 6¼ m ð16Þ u given over Ck and k ¼ m Once A and vector b are formed, we can solve for z, bearing in mind that zk ¼ qk if u is given over Ck, and zk ¼ u k if q is given over Ck. When all the values on the boundary are known, we can then use Equation (10) to obtain values at any interior point in the domain R. 4. Matlab implementation It is clear from the preceding discussion that a method such as the BEM would best be implemented with a tool that can perform matrix computations efficiently, carry out numerical integration conveniently, and produce graphical output if desired. MATLAB is one such tool that can do all of these with a simple set of code. In this section, we outline the implementation of the method using a MATLAB program. It is useful to divide the MATLAB program into three distinct stages or phases, namely Pre-processing, Processing and Post-processing. At each stage, some input is required and the outcome is some information or output. International Journal of Mathematical Education in Science and Technology 511 4.1. Pre-processing Downloaded by [Marshall University] at 00:51 02 November 2013 During Pre-processing, the program reads in information on the boundary elements from a text file. The file contains the coordinates of the node points of the boundary elements, and the types and values of boundary conditions. At this stage, we also compute the coordinates of all the midpoints and the lengths of each boundary element, as well as the unit normal vectors to each element. These are the information needed for the next two stages. 4.2. Processing The Processing phase mainly consists of setting up the matrices required to find approximations to the unknown boundary values. We follow the rules given by (15) and (16). Once the matrix A and column vector b are constructed, we can solve for z and then assign the approximate solutions to the unknown boundary values accordingly. When setting up the matrices, there are two line integrals to be computed. These are Z Z @u ð, Þ ds u ð, Þ ds and @n Ck Ck For the case when k ¼ m, the integrals are improper but they can be easily evaluated to give Z Lk Lk ln u ð, Þ ds ¼ 1 ð17Þ 2 2 Ck Z and @u ð, Þ ds ¼ 0, @n Ck ð18Þ where Lk is the length of the element Ck. When k 6¼ m, we can obtain the expressions for the integrals and evaluate the integrals, or use a numerical scheme such as Gauss quadrature. However, analytic solutions of the line integrals result in rather complicated expressions, and using a Gauss quadrature would mean more coding. Since we would like to focus on seeing how the BEM works, one convenient way to overcome this situation is to make use of available numerical integration packages in MATLAB. This is achieved by calling a function quadl and the code is as follows: F = (lk/(4.0*pi))*quadl(@(t)intf(t, xi, eta, xk, yk, nkx, nky, lk),0,1, 1e 8); G = (lk/(2.0*pi))*quadl(@(t)intg(t, xi, eta, xk, yk, nkx, nky, lk),0,1, 1e 8); where intF and intG are defined respectively as function y = intf(t, xi, eta, xk, yk, nkx, nky, lk) y = log((xk t*lk*nky xi).^2+ (yk + t*lk*nkx eta).^2); and function y = intg(t, xi, eta, xk, yk, nkx, nky, lk) y = (nkx*(xk t*lk*nky xi) + nky*(yk + t*lk*nkx eta)).. . . ./((xk t*lk*nky xi).^2 + (yk + t*lk*nkx eta).^2); 512 Classroom Notes Since the integration will have to be performed again in the Processing phase, it is convenient to write a simple function, which calls the quadl function. In the current implementation, this function is given the name findfg, which simply evaluates the integrals Fk and Gk when k 6¼ m. Downloaded by [Marshall University] at 00:51 02 November 2013 4.3. Post-processing In the Post-processing phase, we essentially use Equation (10) again to find values of u at interior points. We can choose to accept choices of interior points (, ) from the user interactively and respond with the approximate value of u(, ) using (10). We could also choose a specific set of points in R and find u at these points. With MATLAB, however, we can exploit the graphical output features and generate a surface plot or contour plot of the approximate solution. This will give a better physical interpretation for the solution of the problem. In the current implementation, we have chosen this way of post-processing and the code given in the Appendix is fairly self-explanatory. 5. Examples In this section, we examine two examples to illustrate the use of the MATLAB program. 5.1. Example 1 Consider the following problem. r2 u ¼ 0 for 0 < x < 1, 0 < y < 1, subject to the boundary conditions u¼0 on x ¼ 0, for 0 < y < 1, u ¼ cosðyÞ @u ¼ 0 on y ¼ 0 and y ¼ 1 for 0 < x < 1: q¼ @n It can easily verified that the exact solution for this problem is u¼ sinhðxÞ cosðyÞ : sinhðÞ To use the MATLAB program, we need to provide the necessary input information, stored in a file called ‘input. dat’. This input file has four columns; the first two columns are the x and y coordinates of the boundary node points, and the third and fourth columns contain the corresponding boundary condition type and boundary values respectively. In this example, the domain is a square. For simplicity, we shall choose equally spaced out points along the sides. Suppose we have four boundary elements, each of length 0.25, on each of the four sides. The boundary node points and their midpoints are shown in Figure 4(b) below. Note that when labelling boundary node points and elements, it is conventional to go in a counterclockwise direction. In the figure above, the node point (0, 0) is labelled as ‘1’, (0.25, 0) is labelled as 2 and so on. The first boundary element is from node point 1 to node 513 International Journal of Mathematical Education in Science and Technology Downloaded by [Marshall University] at 00:51 02 November 2013 (a) 1 (b) 0.00 0.25 0.50 0.75 1.00 1.00 1.00 1.00 1.00 0.75 0.50 0.25 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.25 0.50 0.75 1.00 1.00 1.00 1.00 1.00 0.75 0.50 0.25 0.00 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 0.0000 0.0000 0.0000 0.0000 0.9239 0.3827 -0.3827 -0.9239 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 13 12 10 9 0.8 0.7 14 8 15 7 16 6 0.6 0.5 0.4 0.3 0.2 0.1 0 0 1 0.2 Input file Figure 4. 11 0.9 2 0.4 3 0.6 4 0.8 5 1 Domain plot Input data and plot of boundary nodes (o) and midpoints of boundary elements (x). point 2. In this example, there are 16 node points. However, when setting up the input file, we need to include the 17th node point, which coincides with node point 1. Hence there are 17 pairs of coordinates in this case. The next two columns contain the boundary condition type and values. We denote the Dirichlet boundary condition (i.e. u given) by the value 0 and the Neumann boundary condition (i.e. q given) by the value 1. This is followed by the actual boundary value at the midpoint of the boundary element, beginning from element 1 to element 16. Using the input file and running the program in the usual way on MATLAB, a surface plot of the solution is obtained. This is shown in Figure 5 below. Although the solution is presented here as a surface plot, it will not be difficult to modify the Post-processing portion of the program to find approximate values at specified points or along a chosen line within the domain. For instance, the values of u along the line x ¼ 0.8 are found using the BEM and plotted with the exact solution in Figure 6 below. 5.2. Example 2 Consider the following problem where the domain is a quarter-circle. r2 u ¼ 0 for x40, y40 and x2 þ y2 < 1, subject to the boundary conditions u ¼ y on x ¼ 0, 2 for 05y51, u ¼ x þ y on x þ y2 ¼ 1, for x40 and y40, @u ¼ 1 on y ¼ 0 for 05x51: q¼ @n 514 Classroom Notes Surface Plot for solution 1 0.9 0.8 0.7 y 0.6 0.5 0.4 0.3 0.1 0 0 0.2 0.4 0.6 0.8 1 x Figure 5. Surface plot of solution for example 1. Values of u along x = 0.8 0.8 0.6 0.4 0.2 u Downloaded by [Marshall University] at 00:51 02 November 2013 0.2 0 0.2 0.4 0.6 0.8 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 y Figure 6. Approximate (o) and exact values (solid line) of u along x ¼ 0.8 for example 1. It is not hard to show that the exact solution is u ¼ x þ y: Suppose we have five boundary elements along each of the two sides of the quartercircle (that is, for x ¼ 0 and y ¼ 0) and along the arc. This results in 16 node points as illustrated in Figure 7(a). Assigning and labelling the boundary values on the boundary elements accordingly, the input file can be created like before and the program may be run as before. 515 International Journal of Mathematical Education in Science and Technology (a) 1 Contour Plot for solution (Example 2) (b) 1 11 10 0.9 0.9 0.8 9 12 0.8 0.7 0.7 0.6 13 y 0.5 0.4 0.3 7 0.5 0.862 0.68 0.498 0.3 0.316 0.2 15 0.1 0.1 0 0 1 0 1.04 0.4 14 0.2 1.23 0.6 8 2 0.2 3 0.4 4 0. 6 5 0.8 6 1 0.135 0 0.2 0.4 0.6 0.8 1 Downloaded by [Marshall University] at 00:51 02 November 2013 x Domain Plot Figure 7. Contour plot of solution Domain and contour plot of solution for example 2. In this case, solution is presented as a contour plot shown in Figure 7(b). As can be seen, the contour plot shows a series of (almost) straight lines of the form x þ y ¼ constant, which essentially describes the exact solution. 6. Conclusion The boundary element method is an important computational tool used by researchers in many fields such as the physical and engineering sciences. The main advantage of the BEM over other numerical methods for partial differential equations is the fact that only the boundary of the domain needs to be discretized. If one were to use the finite difference or finite element methods, the domain of the problem must be divided into computational cells. In fact, in many applications of such methods, much time and computational effort are spent on generating the computational grids. Sometimes, the choice of the number, type and position of these grids or cells may have significant impact on the accuracy or efficiency of the methods. Such a problem does not arise in the BEM as grid generation is not needed. In this article, we have demonstrated a simple way of implementing the BEM using a mathematical tool, MATLAB. Although other tools are possible, we have shown the ease at which the BEM can be introduced to a newcomer to the field very quickly using the program developed and described here. The BEM is an interesting and useful numerical method. Students should not be put off by it simply because they feel challenged by the daunting task of having to write complicated programs to implement it. With MATLAB, the method can be presented in a non-threatening way, along with results that can give a physical interpretation and meaning to the problem. References [1] P. Dunn and C. Harman, Calculus demonstrations using Matlab, Int. J. Math. Edu. Sci. and Technol. 33 (2002), pp. 584–596. [2] L. Colgan, Matlab in first-year engineering mathematics, Int. J. Math. Edu. Sci. and Technol. 31 (2000), pp. 15–25. Downloaded by [Marshall University] at 00:51 02 November 2013 516 Classroom Notes [3] E. Tonkes, B. Loch, and A. Stac, An innovative learning model for computation in first year mathematics, Int. J. Math. Edu. Sci. and Technol. 36 (2005), pp. 751–759. [4] W.T. Ang and K.C. Ang, A dual-reciprocity boundary element solution of a generalized nonlinear Schrödinger equation, Numer. Methods Partial Differential Equations 20 (2004), pp. 843–854. [5] W.T. Ang, K.C. Ang, and M. Dehghan, The determination of a control parameter in a two-dimensional diffusion equation using a dual-reciprocity boundary element method, Int. J. Comp. Math. 78 (2003), pp. 65–74. [6] A. Davies and D. Crann, The boundary element method on a spreadsheet, Int. J. Math. Edu. Sci. and Technol. 29 (1998), pp. 851–865. [7] C.A. Brebbia and J. Dominguez, Boundary Elements: An Introductory Course, 2nd ed., McGraw-Hill, Southampton, 1992. [8] W.S. Hall, The Boundary Element Method, Kluwer, London, 1994. [9] M.A. Jaswon and G.T. Symm, Integral Equation Methods in Potential Theory and Elastostatics, Academic Press, London, 1997. [10] A. Knight, Basics of MATLAB and Beyond, CRC Press, Boca Raton, 2000. [11] P.K. Kythe, An Introduction to Boundary Element Methods, CRC Press, Boca Raton, 1995. Appendix 1: Program listings Main program: %% Program to implement the Boundary Element Method for %% the Laplace’s Equation with given boundary conditions %% Author: Kengã Cheng Ang %% ====================================================== Clear % - - - - - Pre-processing - - - - % Read boundary coodinates, values and type of boundary condition % from input file Fid = fopen(’input.dat’,’r’); Indat = fscanf (fid,’%g%g%d%g’, [4, inf]); indat = indat’; xb = indat (:,1); yb = indat (:,2); bt = indat (:,3); bv = indat(:,4); n = length (xb) 1;% n = number of elements % Find midpoints and lengths of elements, and their unit % normal vectors for i = 1:n xm (i) = 0.5d0*(xb (i) + xb(i + 1)); ym (i) = 0.5d0*(yb(i) + yb(i + 1)); lm(i) = sqrt((xb(i + 1) xb(i))^2 d0 + (yb(i + 1) yb(i))^2 d0); nx(i) = (yb(i + 1) yb(i))/lm (i); ny(i) = (xb(i) xb (i + 1))/lm(i); end International Journal of Mathematical Education in Science and Technology 517 Downloaded by [Marshall University] at 00:51 02 November 2013 % - - - - - Processing - – - % Find approximations for unknown boundary values by % – constructing matrix A and vector b % – solving the system "Ax = b" for x for m = 1:n b(m) = 0d0; for k = 1:n if(k = = m) G = 0.0; F = lm(k)/(2.0*pi)*(log(1m(k)/2.0) 1.0); del = 1.0; else [F, G] = findfg (xm(m), ym (m), xb (k), yb (k), nx (k), ny (k), lm (k)); del = 0.0; end if (bt (k) = = 0) A (m, k) = F; b(m) = b(m) + bv(k)*( G + 0.5d0*del); else A(m, k) = G 0.5d0*del; b(m) = b(m) + bv(k)*F; end end end z = A\b’;% solve system "Ax = b" and store in z % Assign approximate boundary values accordingly for m = 1:n u (m) = (1 bt (m))*bv (m) + bt (m)*z(m); q(m) = (1 bt (m))*z(m) + bt(m)*bv (m); end % - - - - - - Post-processing - - - - - % Find value(s) at required point (s) for j = 1:99 y(j) = 0.01*j; for i = 1:99 x(i) = 0.01*i; s(j, i) = 0d0; for k = 1:n [F, G] = findfg (x (i), y (j), xb (k), yb (k), nx (k), ny (k), lm (k)); s(j, i) = s(j, i) + u(k)*G q(k)*F; end end end figure(1) 518 Classroom Notes Downloaded by [Marshall University] at 00:51 02 November 2013 surface (x, y, s,’EdgeColor’,’none’) hold on % graphics of elements for i = 1:n xx = [xb(i),xb(i+ 1)]; yy = [yb(i), yb(i + 1)]; line(xx, yy,’Color’,’k’,’LineWidth’,3) end title (’Surface Plot for solution’) xlabel (’x’) ylabel(’y’) axis([0 1 0 1]) axis equal %% - - - - - - - - - END OF MAIN PROGRAM - - - - - - - - - - ——————————————————————————————————————————————————————————————— Functions used by main program. Each of the following has to be saved separately with filenames ‘findfg:m’, ‘intf:m’ and ‘intg:m’ respectively and stored in the same folder as the main program. %% filename findfg.m function [F,G] = findfg (xi, eta, xk, yk, nkx, nky, lk) F = (lk/(4.0*pi))*quadl(@(t) intf (t, xi, eta, xk, yk, nkx, nky, lk),0, 1, 1e 8); G = (lk/(2.0*pi))*quadl(@(t)intg (t, xi, eta, xk, yk, nkx, nky, lk), 0, 1, 1e 8); % filename intf.m function y = intf (t, xi, eta, xk, yk, nkx, nky, lk) y = log ((xk t*lk*nky xi).^2 + (yk + t*lk*nkx eta).^2); % filename intg.m function y = intg(t, xi, eta, xk, yk, nkx, nky, lk) y = (nkx*(xk t*lk*nky xi) + nky*(yk + t*lk*nkx eta)). . . ./((xk t*lk*nky xi).^2 + (yk + t*lk*nkx eta).^2); International Journal of Mathematical Education in Science and Technology 519 Downloaded by [Marshall University] at 00:51 02 November 2013 Appendix 2: Input file (‘input.dat’) for example 1 0.00 0.25 0.50 0.75 1.00 1.00 1.00 1.00 1.00 0.75 0.50 0.25 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.25 0.50 0.75 1.00 1.00 1.00 1.00 1.00 0.75 0.50 0.25 0.00 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 0.0000 0.0000 0.0000 0.0000 0.9239 0.3827 0.3827 0.9239 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 Modelling truck camper production G.R. Kramlich II*, G. Kobylski and D. Ahner Department of Mathematical Sciences, United States Military Academy (Received 7 April 2007) This note describes an interdisciplinary project designed to enhance students’ knowledge of the basic techniques taught in a multivariable calculus course. The note discusses the four main requirements of the project and then the solutions for each requirement. Concepts covered include differentials, gradients, Lagrange multipliers, constrained and unconstrained optimization, level curves (isoquants and isocosts), marginal revenue and cost, the law of diminishing returns, marginal productivity, and inventory control. Keywords: constrained and unconstrained optimization; level curves (isoquants and isocosts) 1. Introduction This paper first briefly describes the general process of formulating an inter disciplinary project. The paper then discusses four main requirements of the project. Following the description of each requirement is a detailed solution. The paper closes with a discussion on the success of the project in the classroom. *Corresponding author. Email: gary.kramich@usma.edu DOI: 10.1080/00207390701497675
0
You can add this document to your study collection(s)
Sign in Available only to authorized usersYou can add this document to your saved list
Sign in Available only to authorized users(For complaints, use another form )