Chapter 12 - Simulation and Modeling

(12.1) - Introduction

In this chapter we examine computational modeling - an application of computers that is having a major impact on chemistry, biology, medicine, meteorology, ecology, geography, economics, and a number of other quantitative sciences.

(12.2) - Computational Modeling

(12.2.1) - Introduction to Systems and Models

The scientific method is a fundamental way of obtaining new scientific knowledge:

Scientists often conduct their experiments on a model of the system they are observing. Before the advent of computers the models were physical models; e.g., a model airplane in a wind tunnel to see how a full-sized aircraft would behave. Now the models are often computational models or simulation models running a set of mathematical equations and/or algorithms on a computer.

There are a number of reasons why one might construct a simulation model of a physical system:

(12.2.3) - An Example of Model Building

An owner of a new take-out restaurant under construction wonders how many server stations should be built: Figure 12.3 is a model of the take-out restaurant with arriving customers standing in a single line waiting to be served by one of the N servers: S1, S2, S3, ..., SN.

The state of the model changes whenever a new customer arrives and whenever a customer is served and departs. Figure 12.4 shows the algorithm for New Customer Arrival.


Record the time that this customer entered the restaurant
If all servers are busy
then
Put this customer at the end of the waiting line
Increase the length of the waiting line by 1
else (server Sj is idle)
Mark that server Sj is now busy
Determine Tserve, the time it will take to serve the customer
Schedule a customer departure event for (current time + Tserve)
Increase the time that server Sj has worked by Tserve

The time it takes to serve a customer, Tserve, is a stochastic or random variable - Tserve will have a small value for a customer with a simple order or a large value for a customer with a complicated order. We don't know what Tserve will be for any particular customer but we probably know that Tserve follows some statistical distribution like that shown in Figure 12.5:

A random number generator can be used to determine the value of Tserve according to this distribution.

Another random variable in the simulation is Tinterval, the interval of time between the arrivals of two successive customers, Ci and Ci+1.

Figure 12.7 shows the algorithm for the event when server Sj is done serving a customer:


Determine the total time that this customer spent in the restaurant
If there is someone in line
then
Take the next customer out of the line
Decrease the length of the line by one
Determine Tserve for this customer
Schedule a customer departure event for (current time + Tserve)
Increase the time that server Sj has worked by Tserve
else
Mark Sj as idle

Figure 12.8 shows the main algorithm of the simulation model:
Set current time to zero
Set the length of the waiting line to zero
Get N, the number of servers
Set all N servers, S1, S2, S3, ..., SN to idle
Get an input value for the number of customers, M
Schedule M customer arrivals and put them on the list of events
- each arrival occurs Tinterval time units after the previous one
While there is still a scheduled event on the list
do
Get the next event on the list
Move current time to the time of this event
If this is a New Customer Arrival event
then
Execute the arrival algorithm of Figure 12.4
else
Execute the departure algorithm of Figure 12.7
Remove this event from the list of scheduled events
End of the loop
Print out data that describes the behavior of the system

The print out might show the: The user can run the model with different numbers of servers to decide how many server stations he should build.

(12.3) - Running the Model and Visualizing Results

There is very little data output in the example simulation model described in section (12.2) so all that's required is a text output. Complex simulation models have a lot of data to output so a graphics output might be needed. Scientific visualization is the field concerned with visualizing data to highlight its important characteristics.

Data outputs from some simulations are best displayed in two-dimensional graphs. Figure 12.9 is a chart showing the daily ocean tide at some place.

Figure 12.10 is a chart showing ocean tide and water temperature.

Other simulation models might show data in a three-dimensional display. Figure 12.11 shows a region of the earth's surface.

Chemical molecules can be displayed in three dimensions with atoms of different elements shown in different colors. Figure 12.12 shows a molecule of methyl nitrite (CH3NO2) with three hydrogen atoms (red), one carbon atom (purple), two oxygen atoms (yellow) and one nitrogen atom (blue.)

Figure 12.13 is a visualization of a dispersion of a toxic gas in the downtown area of a major city at a certain time.

Image animation can be used to show how the gas disperses as a function of time.

Figure 12.14 shows the results of a model of ozone layers in the atmosphere at two different days in the year.


Kenneth E. Batcher - 1/13/2008