A computer simulation or a computer model is a computer program that attempts to simulate an abstract model of a particular system. Computer simulations have become a useful part of mathematical modelling of many natural systems in physics (Computational Physics), chemistry and biology, human systems in economics, psychology, and social science and in the process of engineering new technology, to gain insight into the operation of those systems. Traditionally, the formal modeling of systems has been via a mathematical model, which attempts to find analytical solutions to problems which enables the prediction of the behaviour of the system from a set of parameters and initial conditions. Computer simulations build on, and are a useful adjunct to purely mathematical models in science, technology and entertainment.[1][2]
Computer simulation was developed hand-in-hand with the rapid growth of the computer, following its first large-scale deployment during the Manhattan Project in World War II to model the process of nuclear detonation]]. It was a simulation of 12 hard spheres using a Monte Carlo algorithm. Computer simulation is often used as an adjunct to, or substitution for, modeling systems for which simple closed form analytic solutions are not possible. There are many different types of computer simulation; the common feature they all share is the attempt to generate a sample of representative scenarios for a model in which a complete enumeration of all possible states of the model would be prohibitive or impossible. Computer models were initially used as a supplement for other arguments, but their use later became rather widespread.
Computer models can be classified according to several criteria including:
For example:
Generic examples of types of computer simulations in science, which are derived from an underlying mathematical description:
Specific examples of computer simulations follow:
Notable, and sometimes controversial, computer simulations used in science include: Donella Meadows' World3 used in the Limits to Growth, James Lovelock's Daisyworld and Thomas Ray's Tierra.
Although generally ignored in computer simulations, in strict logic the rules governing floating-point arithmetic still apply. For example, the probabilistic risk analysis of factors determining the success of an oilfield exploration program involves combining samples from a variety of statistical distributions using the Monte Carlo method. These include normal, lognormal, uniform and the triangular distributions. However, a sample from a distribution cannot sustain more significant figures than were present in data or estimates that established those distributions. Thus, abiding by the rules of significance arithmetic, no result of a simulation can sustain more significant figures than were present in the input parameter with the least number of significant figures. If, for instance the net/gross ratio of oil-bearing strata is known to only one significant figure, then the result of the simulation cannot be more precise than one significant figure, although it may be presented as having three or four significant figures.
Another consideration can be a weakness for production use of the simulation, although it can be quite useful in testing, is that pseudorandom number generators, such as UNIX/LINUX random()
will produce the same pseudorandom number when given the same initialization value, variously called a seed or a nonce. If Version 1 of the simulation produced some verifiable results of some function foo
that should not be changed by Version 2, during the development of the new version, initial tests should use the same seed. If the expected result changes, the programmer has made an error that affects foo
, and may have other undesired effects. More changes should not be made until the reason foo
changed has been found and corrected.
Computer simulations are used in a wide variety of practical contexts, such as:
The reliability and the trust people put in computer simulations depends on the validity of the simulation model, therefore verification and validation are of crucial importance in the development of computer simulations. Another important aspect of computer simulations is that of reproducibility of the results, meaning that a simulation model should not provide a different answer for each execution. Although this might seem obvious, this is a special point of attention in stochastic simulations, where random numbers should actually be semi-random numbers. An exception to reproducibility are human in the loop simulations such as flight simulations and video games. Here a human is part of the simulation and thus influences the outcome in a way that is hard if not impossible to reproduce exactly.
Computer graphics can be used to display the results of a computer simulation. Animations can be used to experience a simulation in real-time e.g. in training simulations. In some cases animations may also be useful in faster than real-time or even slower than real-time modes. For example, faster than real-time animations can be useful in visualizing the buildup of queues in the simulation of humans evacuating a building. Furthermore, simulation results are often aggregated into static images using various ways of scientific visualization.
In debugging, simulating a program execution under test (rather than executing natively) can detect far more errors than the hardware itself can detect and, at the same time, log useful debugging information such as instruction trace, memory alterations and instruction counts. This technique can also detect buffer overflow and similar "hard to detect" errors as well as produce performance information and tuning data.