Upload
rosaline-watts
View
214
Download
0
Embed Size (px)
Citation preview
Developing Simulations and Developing Simulations and Demonstrations Using Demonstrations Using Microsoft Visual C++Microsoft Visual C++
Mike O’LearyMike O’Leary
Shiva AzadeganShiva Azadegan
Towson UniversityTowson University
Supported by the National Science Foundation under grant DUE 9952625
IntroductionIntroduction
We have developed a course in Scientific We have developed a course in Scientific Modeling and SimulationModeling and Simulation
What is the Course?What is the Course?
This is a one-semester interdisciplinary course This is a one-semester interdisciplinary course straddling the boundaries between mathematical straddling the boundaries between mathematical modeling, numerical methods, and modern modeling, numerical methods, and modern object-oriented computer programming. object-oriented computer programming.
Our course is project-driven.Our course is project-driven. Given a realistic problem, weGiven a realistic problem, we
Create a model, Create a model, discuss appropriate numerical methods, and then discuss appropriate numerical methods, and then create a simulation of the problem using Microsoft create a simulation of the problem using Microsoft
Visual C++ that takes full advantage of our Visual C++ that takes full advantage of our computer's graphical capabilities.computer's graphical capabilities.
Course ObjectivesCourse Objectives The students upon completing these courses will have:The students upon completing these courses will have:
the knowledge to choose proper numerical methods to solve a the knowledge to choose proper numerical methods to solve a scientific problem;scientific problem;
the knowledge of modeling techniques to develop a model for the knowledge of modeling techniques to develop a model for the problem;the problem;
the programming skills to implement the model using an object-the programming skills to implement the model using an object-oriented programming language;oriented programming language;
the critical thinking skill to form conclusion based upon the the critical thinking skill to form conclusion based upon the results;results;
the communication and writing skills to prepare and present the communication and writing skills to prepare and present technical reports;technical reports;
the experience of working in teams with their peers from different the experience of working in teams with their peers from different disciplines on multidisciplinary problems.disciplines on multidisciplinary problems.
What are the Prerequisites?What are the Prerequisites?
Calculus 1, Calculus 2 Calculus 1, Calculus 2 Introduction to Programming 1 Introduction to Programming 1
How does the Course Proceed?How does the Course Proceed?
The course is driven by the projects.The course is driven by the projects. The modeling, numerical methods, and The modeling, numerical methods, and
computer programming are introduced as computer programming are introduced as needed for the solution of a particular problem.needed for the solution of a particular problem.
Course can be split into four large portionsCourse can be split into four large portions IntroductionIntroduction First projectFirst project Second projectSecond project Third project Third project
IntroductionIntroduction
Introduction to programming with MFC & Introduction to programming with MFC & dialog based programming.dialog based programming.
Review of numerical methods for Review of numerical methods for integration.integration.
Write some programs that evaluate Write some programs that evaluate integrals.integrals.
Review of classes.Review of classes. Introduction to numerical methods for Introduction to numerical methods for
differential equations.differential equations.
First ProjectFirst Project
Involves solving a system of differential Involves solving a system of differential equations.equations.
May or may not require the use of graphics.May or may not require the use of graphics. Introduction to graphics.Introduction to graphics. Dynamic memory allocationDynamic memory allocation Allows more sophisticated graphics- e.g. graphs Allows more sophisticated graphics- e.g. graphs
of functions.of functions. This is more sophisticated programming This is more sophisticated programming
concept.concept.
Second ProjectSecond Project Also a system of differential equations.Also a system of differential equations. More sophisticated mathematicsMore sophisticated mathematics Either a more sophisticated model: e.g. calculus Either a more sophisticated model: e.g. calculus
of variationsof variations or better numerical methods: e.g. adaptive or better numerical methods: e.g. adaptive
methodsmethods More sophisticated programmingMore sophisticated programming Function graphsFunction graphs Multiple graphsMultiple graphs Scrolling & slidersScrolling & sliders
Third ProjectThird Project
Partial differential equationsPartial differential equationsModelingModelingAnalysis of numerical methodsAnalysis of numerical methodsMore sophisticated programmingMore sophisticated programmingThe mouseThe mouseTimersTimers
What are the Assignments?What are the Assignments?
Each project takes students 2-4 weeks to Each project takes students 2-4 weeks to complete.complete.
Students complete a written project report Students complete a written project report 10-30 pages10-30 pages Describes in detail the model, the numerical methods, Describes in detail the model, the numerical methods,
and the program used to solve the problem.and the program used to solve the problem. Gives a complete answer to the assigned project Gives a complete answer to the assigned project
questions.questions. Students programs are also graded.Students programs are also graded. It is important that the paper and the program It is important that the paper and the program
have different due dates!have different due dates!
What have we developed?What have we developed?
Lecture notes for the entire coursesLecture notes for the entire courses Not all of the material was used each semester, so Not all of the material was used each semester, so
there is more than can be covered in one semester.there is more than can be covered in one semester.
Projects that were assigned. Projects that were assigned. 8 Projects are given; we only would use 3 in a single 8 Projects are given; we only would use 3 in a single
semester.semester.
Sample codeSample code CD contains source code for the examples described CD contains source code for the examples described
in the notes.in the notes.
Chapter 12: Adaptive Methods for Differential Equations
Chapter 1: Dialog Based ProgrammingChapter 2: Introduction to Numerical MethodsChapter 3: Classes and Software DesignChapter 4: Differential Equations
Chapter 5: Project- The Baseball Problem
Chapter 6: Graphics
Chapter 7: Project- The Three Body ProblemChapter 8: Project- The Double Spring
Chapter 9: Sliders & Scrolling
Chapter 10: Dynamic Memory Allocation
Chapter 13: Project- Dynamics of HIVChapter 14: Project- The Double Pendulum
Chapter 11: Project- The Resonant Filter
Chapter 15: The Mouse
Chapter 16: Project- DiffusionChapter 18: Project- Waves
Chapter 17: Timers
What are the Projects?What are the Projects?
Motion of a baseball under air Motion of a baseball under air resistance. resistance.
What is the optimal angle to hit a baseball What is the optimal angle to hit a baseball so that it travels the farthest? Does this so that it travels the farthest? Does this angle change with the velocity of the ball?angle change with the velocity of the ball?
Students write a program that gives the Students write a program that gives the total distance the ball will travel.total distance the ball will travel.
This project does not require a graphical This project does not require a graphical component, but one can be incorporated.component, but one can be incorporated.
The three body problemThe three body problem
Determine the motion of three (or more) Determine the motion of three (or more) bodies in the plane under the influence of bodies in the plane under the influence of gravity.gravity.
Students are asked to find roughly periodic Students are asked to find roughly periodic orbits.orbits.
The double springThe double spring Describe the motion of a mass attached to two Describe the motion of a mass attached to two
springs in the plane.springs in the plane. Project questions include:Project questions include:
Given initial conditions, determine the location of the Given initial conditions, determine the location of the mass after a period of time, and estimate the mass after a period of time, and estimate the accuracy of the answer.accuracy of the answer.
Are there solutions that remain above the line Are there solutions that remain above the line connecting the two fixed points for all time?connecting the two fixed points for all time?
Analyze the stability properties of the system. Does it Analyze the stability properties of the system. Does it display sensitive dependence on initial conditions?display sensitive dependence on initial conditions?
Prove that the sum of the kinetic energy and the Prove that the sum of the kinetic energy and the energy stored in the springs is conserved.energy stored in the springs is conserved.
The resonant filterThe resonant filter Create a model of an LRC resonant filter.Create a model of an LRC resonant filter. Project questions:Project questions:
Given a class that contains an unknown input signal known to be Given a class that contains an unknown input signal known to be the sum of sinusoids, find the frequency of the unknown signal.the sum of sinusoids, find the frequency of the unknown signal.
This requires an analysis of the preferred frequency of This requires an analysis of the preferred frequency of the solutions to a constant coefficient second order the solutions to a constant coefficient second order differential equation.differential equation.
Programming notesProgramming notes The interface is best built with slider controls.The interface is best built with slider controls. Because this requires displaying a graph of a function, some Because this requires displaying a graph of a function, some
more complex graphical programming is needed. more complex graphical programming is needed. Almost requires the use of dynamically created arrays.Almost requires the use of dynamically created arrays.
Dynamics of HIVDynamics of HIV Create a simple one-compartment model for HIV Create a simple one-compartment model for HIV
infection of CD4+ T-cells.infection of CD4+ T-cells. Obtain three equations in three variables.Obtain three equations in three variables. Investigate the effect of an RT-inhibitor. Though they do Investigate the effect of an RT-inhibitor. Though they do
not kill HIV, they prevent HIV cells from infecting healthy not kill HIV, they prevent HIV cells from infecting healthy cells.cells.
Project questionsProject questions Show that that the system tends to a steady state.Show that that the system tends to a steady state. Show that, if the RT inhibitor is sufficiently effective, then HIV will Show that, if the RT inhibitor is sufficiently effective, then HIV will
be entirely removed from the body.be entirely removed from the body. Show that, there is a lower threshold for effectiveness of the RT Show that, there is a lower threshold for effectiveness of the RT
inhibitor which, though it would not eliminate the virus, it would inhibitor which, though it would not eliminate the virus, it would prevent the onset of AIDS.prevent the onset of AIDS.
Compare the numerical results with their analytic counterparts.Compare the numerical results with their analytic counterparts.
The double pendulumThe double pendulum
Create a model for a jointed pendulum.Create a model for a jointed pendulum.Best technique requires variational Best technique requires variational
methods.methods.Project questionsProject questions
Does the double pendulum display sensitive Does the double pendulum display sensitive dependence on initial conditions?dependence on initial conditions?
DiffusionDiffusion Create a model for diffusion processes.Create a model for diffusion processes. Three different methods to create the model-Three different methods to create the model-
System of ordinary differential equationsSystem of ordinary differential equations Directly, as a partial differential equationDirectly, as a partial differential equation Probabilistic methods.Probabilistic methods.
Introduce finite difference methods for solving partial differential Introduce finite difference methods for solving partial differential equationsequations Discuss consistency, stability and convergence. Discuss consistency, stability and convergence.
Project question to simulate the temperature of a solid bar.Project question to simulate the temperature of a solid bar. Because the exact value can be found using Fourier series techniques, Because the exact value can be found using Fourier series techniques,
one can compare the students solution to the actual result for grading.one can compare the students solution to the actual result for grading. Programming note: the best way to enter the initial data is to use the Programming note: the best way to enter the initial data is to use the
mouse.mouse.
Wave MotionWave Motion
Create a model of wave motion. Create a model of wave motion. Can be done as a system of ordinary differential Can be done as a system of ordinary differential
equations, or directly as a partial differential equations, or directly as a partial differential equation.equation.
Introduce finite difference methods for the Introduce finite difference methods for the solution.solution.
Project question is to simulate the motion of a Project question is to simulate the motion of a vibrating string.vibrating string.
Students verify that the wave speed is correctly Students verify that the wave speed is correctly calculated.calculated.