Incorporating the development of a graphical user interface in
Transcription
Incorporating the development of a graphical user interface in
Incorporating the development of a graphical user interface in courses teaching numerical methods for engineers P. B. Kosasih (corresponding author) and A. K. Tieu School of Mechanical, Material and Mechatronics Engineering, Faculty of Engineering, University of Wollongong, NSW 2522, Australia Abstract This paper describes how students’ learning interests can be stimulated and their understanding of topics in numerical methods can be improved by incorporating the development of graphical user interface (GUI) in a numerical methods course or related courses. The students’ interest and understanding are raised because they are able to implement the theory to solve practical problems and see how the methods can be used in practical situations with the help of the GUI that they design and create. To illustrate how development of GUI can be incorporated into numerical methods courses, two illustrative examples are given: solution of systems of ordinary differential equations related to vibratory motion of masses, springs and dampers system; and solution of an elliptic partial differential equation (i.e. Poisson equation). The tool of choice in the authors’ class was MATLAB. The two examples have been tested on final-year undergraduate and postgraduate engineering courses. The authors also discuss delivery strategy of GUI-related materials in their numerical course. Keywords graphical user interface (GUI); numerical methods; ordinary differential equation; partial differential equation Introduction Mathematical modellings have played a significant role in many advances in engineering, science and technology during the past century. This is primarily due to our ability to develop accurate mathematical models of physical processes and to solve them either analytically or numerically. Most of the equations describing the physical world are differential equations, which are either ordinary differential equations (ODEs) or partial differential equations. Hence graduate engineers would be better equipped if they could master basic skills in solving differential equations. There are two ways to solve differential equations. The analytical solution is mathematically demanding and only a handful of students with sound mathematical skill might attempt to do it this way. A more convenient and familiar way is to apply numerical methods to attain approximate solutions with acceptable accuracy. Numerical methods courses are taught as part of undergraduate and postgraduate engineering degrees. Ideally, numerical method courses could be clearly linked to other courses in which students are taught how to derive mathematical models of physical systems. However, in teaching numerical methods to engineering students, it is often the case that the teaching is concentrated on techniques/methods to solve given differential equations only. Thus the link between the physical problem and the mathematical model that is supposed to represent the problem is lost in the International Journal of Mechanical Engineering Education 35/1 Downloaded from ijj.sagepub.com by guest on February 16, 2015 Incorporating a GUI in numerical methods 47 subtlety of the solution methods, and consequently students will quickly lose interest in learning the methods. This is because they could easily perceive that they are being trained to arrive at approximate solutions of mathematical problems rather than physical problems, which is often the case in solving differential equations. Therefore it is important that the links between the physical problem and the mathematical model be carefully maintained in the teaching of numerical methods. It is the aim of this paper to show that these links can be maintained throughout the course via exercises in the building of a graphical user interface (GUI). In standard numerical courses students are normally introduced to the mathematics of finite-difference, finite-element or finite-volume techniques and solution of systems of linear equations. They are taught how the methods work and made aware of the accuracy of each method so that they can control the accuracy of the approximate solutions associated with each method. During the courses they are required to construct programs implementing the methods of solving given mathematical problems and finally analyse the results in terms of their accuracy and physical correctness. Using a GUI, checking physical correctness can be made more accessible and fun. This benefit of incorporating a GUI in the standard course is illustrated as follows. Students will normally be able to solve a given differential equation specific to an engineering problem. When different scenarios, for example different sets of boundary conditions, are to be imposed, the program is normally re-run, which will involve recompilation of the program. By giving students, in addition, the skills to build a GUI, they will be able to build software and use it to explore all possible scenarios of the problem interactively. In fact, the students can build a research tool. With the visibility and interactivity associated with the software, students are able to relate the physical problem to the mathematical and numerical methods with ease. Another factor that we think also helps boost the students’ interest and confidence is that they get the chance to create numerical software. This is a tangible outcome of the course. In this paper, two examples where a GUI can be incorporated in the teaching of numerical methods are illustrated. The two examples are: solution of a system of second-order ODEs related to vibratory motion of masses, springs and dampers system; and solution of an elliptic partial differential equation (i.e. Poisson equation). The first example involves solution of a system of first-order ODE using Runge–Kutta methods. The second example illustrates solution of partial differential equations using finite-difference method. In both cases students must develop programs for solving the equations and create a GUI, and finally use the software to analyse different conditions. Several OOPs (object-orientated programs) can be used to build a GUI, such VisualBasic, VisualC++, VisualFortran and MATLAB. However, the authors adopt MATLAB to introduce this concept as it incorporates a specific tool with which to do so. The addition of a GUI to a typical numerical course should not burden the already packed course contents. The typical structure of the course contents and delivery in teaching numerical methods is shown in Fig. 1. There are four stages in a standard numerical methods course: International Journal of Mechanical Engineering Education 35/1 Downloaded from ijj.sagepub.com by guest on February 16, 2015 48 P. B. Kosasih and A. K. Tieu Develop Mathematical Model OTHER COURSE NUMERICAL COURSE 1. Derivation of Numerical Methods 2. Develop Algorithm 3. Develop Program 5. Build GUI 4. Presentation & Analyses Fig. 1 (1) (2) (3) (4) Path for teaching a numerical methods course. derivation of the numerical methods; development of algorithm; implementation in a program; presentation and analyses of the numerical results. In addition to these standard approaches we introduce a fifth element, namely building a GUI in parallel with program implementation. We discuss, after the presentation of two examples, how this fifth element is brought into the class with minimum disruption to the other four main elements. Example 1. Motion of spring-mass-damper system The first example relates to solution system of first-order ODEs. The problem at hand is motion simulation of three masses, three springs and two dampers, as shown in Fig. 2 [1]. The motions or displacements of the masses are given by the Newton law, yielding a system of three second-order ODEs: y1′ = [−c1y1′ − k1y1 + c1y2′ + k1y2 + F1(t)]/m1 (1) y 2′ = [c1y1′ + k1y1 − c1y2′ − (k1 + k2)y2 + k2 y3]/m2 (2) ′ 3 ′ 3 3 y = [k2y2 − c y − (k2 + k3)y3]/m3 The system is excited by the forcing function, given by: International Journal of Mechanical Engineering Education 35/1 Downloaded from ijj.sagepub.com by guest on February 16, 2015 (3) Incorporating a GUI in numerical methods Fig. 2 F1 = At =0 49 Spring-mass-damper system. 0≤t≤T t >T (4) It is subjected to the following initial conditions: · (0) · · (0) · · (0) (0) · y1(0) = y1(0), y2(0) = y (0) 2 , y3(0) = y3 , y1(0) = y1 , y2(0) = y2 and y3(0) = y3 Students are first taught methods to solve the boundary-value first-order ODE. Several methods were introduced including: Euler; improved/modified Euler; and Runge–Kutta methods [2]. Once they have mastered how to solve a single first-order ODE, application of these methods to solve systems of first-order ODEs is then taught. For ODEs of higher order (>2), the equation will be transformed into system of first-order ODEs (i.e. second-order ODEs into two first-order ODEs and thirdorder ODEs into three first-order ODEs, and so on). The task is to solve the equations for a given set of data and boundary conditions: k1 = k2 = k3 = 1 kgm/s2, m1 = m2 = m3 = 0.5 kg, c1 = c3 = 0.1 kg/s. Initial conditions are y1(0) = y·1(0) − y2(0) = y·2(0) = y3(0) = y·3(0) = 0. And F1(t) = 0.1 t N for 0 ≤ t ≤ 1 s, F1(t) = 0 N for t > 1 s. Students are asked to plot the motion of each mass for the first 30 seconds. Once this task is completed, they then develop the GUI software for the problem. The software must enable users to investigate the motion of the masses subjected to different conditions. In this example the software is designed to allow users to change the system conditions, such as the masses, the spring constants and damping coefficients of the dampers. To do this, all the variables that might affect the solution must be identified. There are 14 values that can be changed, namely: m1, m2, (0) (0) · (0) · (0) · (0) m3, k1, k2, k3, c1, c3, t0, tn, T, A, initial condition vectors [y(0) 1 y2 y3 y1 y2 y3 ] and the number of time intervals. These parameters can all be entered in the GUI (Fig. 3). The software makes it possible for students to come up with the solution pertaining to the system. For example, if it is decided to increase one of the damper coefficients, then using the software they can investigate the effect of increasing the damper coefficient quickly and interactively. Fig. 4 shows the masses’ motion when c1 is increased to 0.5 kg/s. Fig. 5 shows the masses’ motion when c3 is increased to 0.5 kg/s. Hence a student can quickly arrive at a solution using the software. In addition to this benefit we found that students seem to be encouraged to explore the effects of changing other parameters with the software. As a result their understanding of the behaviour of vibration systems is also increased. International Journal of Mechanical Engineering Education 35/1 Downloaded from ijj.sagepub.com by guest on February 16, 2015 P. B. Kosasih and A. K. Tieu Fig. 3 Initial window of the GUI for the spring-mass-damper system. 50 International Journal of Mechanical Engineering Education 35/1 Downloaded from ijj.sagepub.com by guest on February 16, 2015 Incorporating a GUI in numerical methods 51 Fig. 4 The masses’ motion with c1 = 0.5 kg/s. Fig. 5 The masses’ motion with c3 = 0.5 kg/s. Example 2. Poisson equation The second example illustrates a two-dimensional field problem governed by an elliptic partial differential equation (Poisson equation). The equation appears in many engineering problems, including ones on two-dimensional heat conduction, International Journal of Mechanical Engineering Education 35/1 Downloaded from ijj.sagepub.com by guest on February 16, 2015 52 P. B. Kosasih and A. K. Tieu hydrodynamic lubrication (Reynolds equation) and irrotational flow of an ideal fluid. The Poisson equation may be written as: ∂ ∂T ∂ ∂T k2 k1 + = f ( x, y) ∂x ∂x ∂y ∂Y (5) The equation may be subjected to three types boundary conditions: Dirichlet; Neumann; or Robin. In this example we consider only the case where all the boundary conditions are of Dirichlet type, defined by: T(x,y0) = f1(x,y), T(x,yn) = f2(x,y) for x0 ≤ x ≤ xn T(x0,y) = f3(x,y), T(xn,y) = f4(x,y) for y0 ≤ y ≤ yn To solve the problem, students are first taught how to solve a system of algebraic linear equations using techniques such Jacobi iteration or Gauss–Seidel [2] discretization techniques using finite difference. Then they are taught to design the GUI. In the design stage they must identify all the variables and/or functions that might affect the solution of the equation. For the example, these variables are k1, k2, x0, xn, y0, yn, n (number of intervals in x) and m (number of intervals in y). The functions are f(x,y), f1(x,y), f2(x,y), f3(x,y) and f4(x,y). Thus there are eight variables and five functions that can be changed. The GUI must be designed to allow user to write/enter the functions and variables in clearly identifiable cells. The 13 cells used in this example are clearly labeled (see Fig. 6) and strategically placed around the screen. The position and the labelling must be clear so that user can identify them with ease. The initial screen setting of the GUI is shown in Fig. 6. Here, f(x,y) = x + y, f1(x,y) = x, f2(x,y) = 1, f3(x,y) = y, f4(x,y) = 1, and k1 and k2 are constants and set to one. The numbers of intervals in x and in y are set to 5. The software allows users to quickly investigate the problem at hand for different boundary conditions and source functions, f(x,y). Fig. 7 shows the screen for f(x,y) = 0, f1(x,y) = sin(pi * x), f2(x,y) = 0, f3(x,y) = sin(pi * y), f4(x,y) = 0, and k1 and k2 are constants and set to one. The numbers of intervals in x and in y are set to 15. Delivery strategy The GUI element in the numerical course described in the paper was not yet part of a syllabus or general policy to increase the use of new technologies within mathematics/numerical methods courses. It is, rather, a recommended addition to it. Hence the introduction of GUI development to the class needs to be done in such a way that students do not become distracted from the main syllabus. Teachers intending to incorporate GUI development into such classes must give careful consideration to how and when to do so, in order not to confuse students with the underlying numerical methods theory. As the subject of the following discussion, a numerical course taught to 27 students from various educational backgrounds (many were international students who had never studied numerical methods before attending this course) by the authors in autumn 2004 will be used. The course was ENGG952 Engineering Computing and International Journal of Mechanical Engineering Education 35/1 Downloaded from ijj.sagepub.com by guest on February 16, 2015 Incorporating a GUI in numerical methods Fig. 6 Fig. 7 53 Initial window of the GUI for solving the Poisson equation. Window of the GUI for different boundary conditions and source functions. International Journal of Mechanical Engineering Education 35/1 Downloaded from ijj.sagepub.com by guest on February 16, 2015 54 P. B. Kosasih and A. K. Tieu was offered as part of a masters degree. The course covered topics such as: simultaneous linear algebraic equations; matrix eigenvalue problem; ODE initial-value problems; ODE boundary-value problems; and partial differential equations. The course contents were delivered over 13 weeks, and in each these were two hours of lecture and two hours of laboratory session. Each topic was presented following the logical path shown in Fig. 1. The GUI-related materials, which usually are about designing an appealing and user-friendly interface suited to the problem at hand, were discussed once stage 3 was completed and when students were about to tackle their programming assignments. A GUI element was always attached to the assignments associated with each topic. The presentation of GUI-related materials could be delivered during either lectures or laboratory sessions. In either case the authors found that for students to get the most out of their GUI experience it was best for us (the teachers) to merely introduce to them the main GUI commands (in MATLAB) – uimenu, uicontrol, get, set, and axes – and basic principles of GUI design layout. Students then creatively designed their GUI-based presentation and analysis tools. Students’ creativities are significant factors in determining the quality of their GUI. As students have different creativity levels, we awarded marks associated with the GUI element only according to its functional correctness and accuracy. This did not seem to affect their pursuit of an attractive and functional presentation. It was clear that the class was motivated not only by the assignment’s mark but also the satisfaction brought about by having created well functioning presentation and numerical analysis tools. When time permitted, we also asked some students to voluntarily present their work to the class and they responded willingly and proudly. While we will not claim that the strategy discussed above is the best, it nevertheless is quite clear that the students were greatly motivated and satisfied with what they learned in the course, as reflected in the survey conducted at the end of the course. The teaching survey at the University of Wollongong consists of two components: teacher evaluation and student questionnaire. Teacher evaluation measured teacher attributes such as: teacher’s preparedness (5.9/6), clarity of presentation (5.6/6), organization (5.7/6), assignment marking and feedback (5.8/6), and so on. In the questionnaire students provided comments in their own words. The survey did not, however, ask specific questions about the GUI materials. Overall, students’ performance improved, based on the high proportions of students achieving distinction (≥75) or above, as shown in Fig. 8. The authors believe that GUI materials could be readily attached to other teaching materials delivered via web-based and e-learning tools and this will be tried in the future classes. Conclusion The paper introduces the development of a GUI as part of the teaching of numerical methods courses to undergraduate and beginning postgraduate students. It can be easily integrated into any existing numerical methods courses, as illustrated in the two examples presented. By incorporating this element, the students’ appreciaInternational Journal of Mechanical Engineering Education 35/1 Downloaded from ijj.sagepub.com by guest on February 16, 2015 Incorporating a GUI in numerical methods 55 Distribution of student grades No. of students 10 8 6 4 2 0 Fig. 8 HD D C P F Distribution of students’ grades. HD = high distinction; D = distinction; C = credit; P = pass; F = fail. tion of the subject materials is increased. The teaching survey at the end of the course clearly indicated that students were greatly motivated and their enthusiasm boosted when they found themselves able to apply the numerical methods and create software implementing the methods. The authors on request can provide the source codes of the two examples. Acknowledgement The first author (PBK) would like to express his gratitude to the school of Mechanical, Materials and Mechatronics Engineering, Faculty of Engineering, at the University of Wollongong, for allowing him to further develop the Engineering Computing Course. References [1] S. Nakamura, Numerical Analysis and Graphic Visualization with MATLAB (Prentice-Hall, New Jersey, 1996). [2] L. V. Fausett, Applied Numerical Analysis Using MATLAB (Prentice-Hall, New Jersey, 1999). International Journal of Mechanical Engineering Education 35/1 Downloaded from ijj.sagepub.com by guest on February 16, 2015