610 likes | 1.03k Views
Chapter 13 Simulation and Modeling. 1. Objectives. In this chapter, you will learn about: Computational modeling Running the model and visualizing results. Introduction. Simulation and modeling Probably the single most important scientific use of computing today
E N D
Chapter 13 • Simulation and Modeling 1
Objectives In this chapter, you will learn about: • Computational modeling • Running the model and visualizing results Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Introduction • Simulation and modeling • Probably the single most important scientific use of computing today • Having an impact on quantitative fields, such as chemistry, biology, medicine, meteorology, ecology, geography, economics, etc. Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Modeling: Introduction to Systems and Models • The scientific method • Observe the behavior of a system • Formulate a hypothesis about system behavior • Design and carry out experiments to prove or disprove the validity of the hypothesis • Often a model of the system is used Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Introduction to Systems and Models (continued) • A model • An abstraction of the system being studied that we claim behaves much like the original • Computer simulation • A physical system is modeled as a set of mathematical equations and/or algorithmic procedures Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Introduction to Systems and Models (continued) • Computer simulation (continued) • Model is translated into a high-level language and executed on the Von Neumann computer • Computational models • Also called simulation models • Used to: • Design new systems • Study and improve the behavior of existing systems Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Introduction to Systems and Models (continued) • Computational models (continued) • Allow the use of an interactive design methodology (sometimes called computational steering) • Used in most branches of science and engineering Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Objectives After studying this chapter, students will be able to: • Describe the purpose of modeling in science • List the benefits of a computational model over a physical model • Explain the tradeoff between accuracy and complexity in models • Define different types of simulation models, including discrete and continuous, deterministic and stochastic • Describe how a discrete event simulation works • Design a simple discrete event simulation similar to the McBurger example Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Objectives (continued) After studying this chapter, students will be able to: • Explain the purpose of data visualization • Describe the common tools of data visualization, including graphs of data, use of colors, and image animation • Suggest a useful kind of data visualization, given an example model and its data Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Modeling • Science involves forming hypotheses and performing experiments to test them • A model is a representation of a real system that acts like the real thing in important ways • Experimenting with a model may be preferred • Physical models are physical objects • Computational models are simulations • Equations and algorithms inside a computer • Also called simulation models Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Modeling (continued) Why experiment on a simulation model? • Existence: real system may not exist yet • Physical realization: system may not be made of physical things (e.g., social systems) • Safety: system may be unsafe to experiment with (e.g., nuclear reactor design) • Speed of construction: physical model may take too long to build Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Modeling (continued) Why experiment on a simulation model? • Time scale: physical system may happen too fast or too slow to experiment • Ethical behavior: experimenting on physical system may be ethically wrong • Ease of modification: can change the model quickly and easily Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Modeling (continued) Computational steering: • Repeat until satisfied with design: • Build simulation model of design • Test and experiment on model • Refine design • Used for the design of brand-new systems Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Models, Accuracy, and Errors • Proper balance between accuracy and complexity must be achieved • A model must be both: • An accurate representation of the physical system • Simple enough to implement as a program and solve on a computer in a reasonable amount of time Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Models, Accuracy, and Errors (continued) • To build a model • Include important factors that act on the system • Omit unimportant factors that only make the model harder to build, understand, and solve Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Models, Accuracy, and Errors (continued) • Continuous model • A set of equations that describe the behavior of a system as a continuous function of time t • Models that use statistical approximations • Needed for systems that cannot be modeled using precise mathematical equations Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Modeling (continued) • Models balance between accuracy and complexity • All models include some features and omit others • Example: model of falling mass • d = vinit t + ½ g t2 • Omits effects of air resistance • Assumes constant gravity • Continuous model: a formula based on continuous time • Stochastic components: elements of randomness Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Modeling (continued) • Discrete event simulation: • Model time as discrete time steps • Events: activities that change the state of system • Examples: customer enters store, customer purchases item, customer leaves store • Simulate only times where events take place • Keep a list of events and their scheduled times • Repeat • Advance time to time of next event • Skip any intervening time steps • Perform next event’s actions Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
An Example of Model Building (continued) • Problem • You are the owner of a new take-out restaurant, McBurgers, currently under construction • You want to determine the proper number of checkout stations needed • You decide to build a model of McBurgers to determine the optimal number of servers Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Modeling (continued) Example simulation: McBurger • Determine how many checkout stations for fast food restaurant • Single line of customers • N server stations • If server is free, next customer goes • Server is busy while customer orders, waits, and pays Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Modeling (continued) Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
An Example of Model Building (continued) • First: identify the events that can change the system • A new customer arriving • An existing customer departing after receiving food and paying • Next: develop an algorithm for each event • Should describe exactly what happens to the system when this event occurs Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Modeling (continued) Example simulation: McBurger • Events in this model • Customer arrives • Adds to line or makes idle server busy • Customer departs • Removes customer from line or makes server idle • Construct algorithms for each event • Update state of simulation for event • Record data to be collected Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Modeling (continued) Example simulation: McBurger • For each customer, record • Time spent waiting (Tdepart – Tarrive – Tserve) • Time being served (Tserve) • For each server, record • Total time spent serving Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Modeling (continued) Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Modeling (continued) Example simulation: McBurger • Time being served, Tserve, is stochastic • Generate based on statistical distribution • Equation that captures probabilities of different values occurring • Derive distribution from external sources • Other restaurants • Garbage in, garbage out: quality of the results depend on quality of data and assumptions Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Modeling (continued) Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Modeling (continued) Example simulation: McBurger • To generate stochastic time • Generate a value from distribution • Use that to generate a time • Uniform random number: • Chosen randomly from a range of values • All values equally likely to be chosen Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Modeling (continued) Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Modeling (continued) Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Computational Modeling (continued) Example simulation: McBurger • Outcomes: what data should be reported? • Average customer waiting time • Maximum length of waiting line • Server busy percentage • Try the model, examine results • Retry with different parameters Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Running the Model and Visualizing the Results • Real-world models require many more computations • NERSC climate system model: • 1017 computations • Requires large parallel computer systems • Produces 500 million data values • Scientific visualization: methods for visualizing data to highlight important characteristics • Not computer graphics Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Running the Model and Visualizing Results (continued) • Output of a computer model can be represented visually, such as through: • A two-dimensional graph • A three-dimensional image • Visual representation of data helps identify important features of the model’s output Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Running the Model and Visualizing the Results (continued) Example 1: Model of ocean tides • Produces predicted tide height for every 30 seconds of 24-hour day • Display as graph, easier to see features Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Running the Model and Visualizing the Results (continued) Example 2: Model of tides and temperatures • Produces twice as much data • Display both sets of data on one graph • Interactions become more evident Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Running the Model and Visualizing the Results (continued) Example 3: Model of forest fire intensity • Three-dimensional data and visualization • Hottest: yellow and red • Coolest: blue and green Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Running the Model and Visualizing the Results (continued) Example 4: Model of chemical compound • Give 3-d display of atoms and chemical bonds • Can animate chemical reactions/changes • Use of color and size to identify parts Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Running the Model and Visualizing the Results (continued) Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Running the Model and Visualizing the Results (continued) Example 5: Model of tsunami waves • Color indicates wave heights • Purple = highest • Yellow = lowest • Integrated with map data Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Figure 12.13 Visualization of Gas Dispersion Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Running the Model and Visualizing the Results (continued) Example 6: Model of atmospheric ozone over one year • Models where results appear over time • Image animation: a movie showing changes • One image per day • Color means ozone amounts Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Running the Model and Visualizing the Results (continued) Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012
Summary • A model is an abstraction of a system that behaves much like the original • Computer simulation: • Physical system is modeled using mathematical equations and/or algorithmic procedures • Model is translated into a high-level language program and executed Invitation to Computer Science, 6th Edition, modified by SJF, Fall 2012