Chapter 13
Simulation and
Modeling
Learning Objectives
• Describe the purpose of modeling in science
• List the benefits of a computational model over a
physical model
• Explain the trade-off 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
• Explain the purpose of scientific visualization
• List some common methods of scientific visualization
Introduction
• Remind students of the computational devices of
the 20th and early 20th centuries.
• Briefly discuss Charles Babbage and Ada Lovelace
again.
• Go over the big accomplishments
– The 1890 Census with punch cards
– ENIAC computing artillery ballistic tables
– Turing’s Colossus breaking the Enigma Code
• Discuss all the non-scientific uses for computers in
the modern day
Computational Modeling (1 of 20)
• The scientific method entails observing the behavior of
a system, forming hypothesis, and performing
experiments to test it
• A model is a representation of a real system that can
be used to study it
• Physical models are physical objects that are different
in scale and function than the thing itself
• Computational models are simulations
– Equations and algorithms inside a computer
– Also called simulation models
Computational Modeling (2 of 20)
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
Computational Modeling (3 of 20)
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
Computational Modeling (4 of 20)
• Computational steering is the act of tweaking the
design until a satisfactory simulation has been
developed
– Step 1: Build simulation model of design
– Step 2: Test and experiment on model
– Step 3: Refine design
• Can be used for the design of brand-new systems
and for improving on existing systems
Computational Modeling (5 of 20)
Computational Modeling (6 of 20)
• 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
Computational Modeling (7 of 20)
• Discrete event simulation models time as discrete
steps
– Events are 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:
o Advance time to time of next event
o Skip any intervening time steps
o Perform next event’s actions
Computational Modeling (8 of 20)
Computational Modeling (9 of 20)
Example simulation: McBurger
• Determine how many checkout stations for a 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
Computational Modeling (10 of 20)
Computational Modeling (11 of 20)
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
Computational Modeling (12 of 20)
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
Computational Modeling (13 of 20)
Computational Modeling (14 of 20)
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
Computational Modeling (15 of 20)
Computational Modeling (16 of 20)
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
Computational Modeling (17 of 20)
Computational Modeling (18 of 20)
Computational Modeling (19 of 20)
Computational Modeling (20 of 20)
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 the results
• Retry with different parameters
Running the Model and Visualizing the
Results (1 of 13)
• 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
Running the Model and Visualizing the
Results (2 of 13)
Example 1: model of ocean tides
• Produces predicted tide height for every 30
seconds of 24-hour day
• Displays as a graph, easier to see features
Running the Model and Visualizing the
Results (3 of 13)
Running the Model and Visualizing the
Results (4 of 13)
Example 2: model of tides and temperatures
• Produces twice as much data
• Displays both sets of data on one graph
• Interactions become more evident
Running the Model and Visualizing the
Results (5 of 13)
Running the Model and Visualizing the
Results (6 of 13)
Example 3: model of forest fire intensity
• Three-dimensional data and visualization
• Hottest: yellow and red
• Coolest: blue and green
Running the Model and Visualizing the
Results (7 of 13)
Running the Model and Visualizing the
Results (8 of 13)
Example 4: model of chemical compound
• Give 3-d display of atoms and chemical bonds
• Can animate chemical reactions/changes
• Use color and size to identify parts
Running the Model and Visualizing the
Results (9 of 13)
Running the Model and Visualizing the
Results (10 of 13)
Example 5: model of tsunami waves
• Color indicates wave heights
– Purple = highest
– Yellow = lowest
• Integrated with map data
Running the Model and Visualizing the
Results (11 of 13)
Running the Model and Visualizing the
Results (12 of 13)
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
• Colors indicate ozone amounts
Running the Model and Visualizing the
Results (13 of 13)
Summary (1 of 2)
• Models are used to experiment with systems that
are difficult or impossible to work with for real
• Computational simulation models can be built and
modified faster than physical models and can
change the time or size scale to be more workable
• Ethical dilemmas can be avoided using simulations
• Choose important features for accuracy; keep
complexity manageable
• Models may be discrete or continuous,
deterministic or stochastic
Summary (2 of 2)
• Discrete event simulations jump from one event of
a system to the next, skipping intervening time
steps
• Simulations like the McBurger example can be
used to test the outcomes of design decisions
• Some real-world simulations require massive
computing resources
• Data visualization makes model outcomes easier to
understand