# Computer Simulation

## Wikipedia

A computer simulation (also referred to as a computer model or a computational model) is a computer program, or network of computers, that attempts to simulate an abstract model of a particular system. Computer simulations have become a useful part of the 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, so as to gain insight into the operation of those systems or to observe their behaviour.

Computer simulations vary from computer programs that run a few minutes, to network- -based groups of computers running for hours or ongoing simulations that run for days. The scale of events being simulated by computer simulations has far exceeded anything possible (or perhaps even imaginable) using the traditional paper-and-pencil mathematical modelling: over 10 years ago. A desert-battle simulation, of one force invading another, involved the modelling of 66,239 tanks, trucks and other vehicles on simulated terrain around Kuwait, using multiple supercomputers in the DoD High Performance Computer Modernization Program. Another simulation ran a 1-billion- -atom model, where previously, a 2.64-million-atom model of a ribosome, in 2005, had been considered a massive computer simulation. And the Blue Brain project at EPFL (Switzerland) began in May 2005 to create the first computer simulation of the entire human brain, right down to the molecular level.

## Simulation versus modelling

Traditionally, the formal modelling, or modelling, 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.

While computer simulations might use some algorithms from purely mathematical models, computers can combine simulations with the reality of actual events, such as generating input responses to simulate test subjects who are no longer present. Although the missing test subjects (i.e. the users of equipment or systems) are being modelled/simulated, the whole process can be conducted with the actual equipment or system they use, revealing performance limits or defects in long-term use by the simulated users.

Note that the term computer simulation is broader than computer modelling, which implies that all aspects are being modelled in the computer representation. However, computer simulation also includes generating inputs from simulated users to run actual computer software or equipment, with only part of the system being modelled: an example would be flight simulators which can run machines as well as actual flight software.

Computer simulations are used in many fields, including science, technology, entertainment, and business planning and scheduling.

## History

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, modelling 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.

## Data preparation

The data input/output for the simulation can be either through formatted text files or a pre- and post processor.

## Types of computer simulation

Computer models can be classified according to several criteria including:

- stochastic or deterministic (and as a special case of deterministic, chaotic)
- steady-state or dynamic
- continuous or discrete (and as an important special case of discrete, discrete event or DE models)
- local or distributed.

For example, steady-state models use equations defining the relationships between elements of the modelled system and attempt to find a state in which the system is in equilibrium. Such models are often used in simulating physical systems as a simpler modelling case before dynamic simulation is attempted. Dynamic simulations model changes in a system in response to (usually changing) input signals. Stochastic models use random number generators to model chance or random events; they are also called Monte Carlo simulations. A discrete event simulation (DES) manages events in time. Most computer, logic-test and fault-tree simulations are of this type. In this type of simulation, the simulator maintains a queue of events sorted by the simulated time in which they should occur. The simulator reads the queue and triggers new events as each event is processed. It is not important to execute the simulation in real time. It’s often more important to be able to access the data produced by the simulation, to discover logic defects in the design or the sequence of events. A continuous dy- namic simulation performs numerical solutions of differential-algebraic equations or differential equations (either partial or ordinary). Periodically, the simulation program solves all the equations, and uses the numbers to change the state and output of the simulation. Applications include flight simulators, simulation games, chemical process modelling, and simulations of electrical circuits. Originally, these kinds of simulations were actually implemented on analogue computers, where the differential equations could be represented directly by various electrical components such as op-amps. By the late 1980s, however, most “analogue” simulations were run on conventional digital computers that emulate the behaviour of an analogue computer. A special type of discrete simulation which does not rely on a model with an underlying equation, but can nonetheless be represented formally, is agent-based simulation. In agent-based simulation, the individual entities (such as molecules, cells, trees or consumers) in the model are represented directly (rather than by their density or concentration) and possess an internal state and set of behaviours or rules which determine how the agent’s state is updated from one time-step to the next. Distributed models run on a network of interconnected computers, possibly through the Internet. Simulations dispersed across multiple host computers like this are often referred to as “distributed simulations”. There are several standards for distributed simulation, including Aggregate Level Simulation Protocol (ALSP), Distributed Interactive Simulation (DIS), the High Level Architecture (HLA) and the Test and Training Enabling Architecture (TENA).

## CGI computer simulation

Formerly, the output data from a computer simulation was sometimes presented in a table, or a matrix, showing how data was affected by numerous changes in the simulation parameters. The use of the matrix format was related to the traditional use of the matrix concept in mathematical models; however, psychologists and others noted that humans could quickly perceive trends by looking at graphs or even moving-images or motion-pictures generated from the data, as displayed by computer -generated-imagery (CGI) animation. Although observers couldn’t necessarily read out numbers, or spout maths formulas, from observing a moving weather chart, they might be able to predict events (and “see that rain was headed their way”), much faster than scanning tables of rain-cloud coordinates. Such intense graphical displays, which transcended the world of numbers and formulae, sometimes also led to output that lacked a coordinate grid or omitted timestamps, as if straying too far from numeric data displays. Today, weather forecasting models tend to balance the view of moving rain/snow clouds against a map that uses numeric coordinates and numeric timestamps of events.

Similarly, CGI computer simulations of CAT scans can simulate how a tumour might shrink or change, during an extended period of medical treatment, presenting the passage of time as a spinning view of the visible human head, as the tumour changes.

Other applications of CGI computer simulations are being developed to graphically display large amounts of data in motion, as changes occur during a simulation run.

## Computer simulation in science

The following are generic examples of types of computer simulations in science, which are derived from an underlying mathematical description:

A numerical simulation of differential equations which cannot be solved analytically. Falling into this category are:

- theories which involve continuous systems such as phenomena in physical cosmology
- fluid dynamics (e.g. climate models, roadway noise models, roadway air dispersion models)
- continuum mechanics and chemical kinetics

- genetic drift
- biochemical or gene regulatory networks with small numbers of molecules (See also: Monte Carlo method). Specific examples of computer simulations follow:
- agent based simulation has been used effectively in ecology, where it is often called individual based modelling and has been used in situations for which individual variability in the agents cannot be neglected, such as population dynamics of salmon and trout (most purely mathematical models assume all trout behave identically)
- time stepped dynamic model; in hydrology there are several such hydrology trans- port models such as the SWMM and DSSAM Models developed by the U.S. Envi- ronmental Protection Agency for river water quality forecasting
- computer simulations have also been used to formally model theories of human cognition and performance, e.g. ACT-R
- computer simulation using molecular modelling for drug discovery
- computational fluid dynamics simulations are used to simulate the behaviour of flowing air, water and other fluids. There are one-, two- and three- dimensional models used. A one dimensional model might simulate the effects of water hammer in a pipe. A two-dimensional model might be used to simulate the drag forces on the cross-section of an aeroplane wing. A three-dimensional simulation might estimate the heating and cooling requirements of a large building.
- Donella Meadows’ World3 used in the Limits to Growth
- James Lovelock’s Daisyworld
- Thomas Ray’s Tierra.
- analysis of air pollutant dispersion using atmospheric dispersion modelling
- design of complex systems such as aircraft and logistics systems
- design of noise barriers to effect roadway noise mitigation
- flight simulators to train pilots
- weather forecasting
- behaviour of structures (such as buildings and industrial parts) under stress and other conditions
- design of industrial processes, such as chemical processing plants
- strategic management and organizational studies
- reservoir simulation for the petroleum engineering to model the subsurface reservoir
- Process Engineering Simulation tools
- robot simulators for the design of robots and robot control algorithms

- statistical simulations based upon an agglomeration of a large number of input
profiles, such as the forecasting of equilibrium temperature of receiving waters,
allowing the gamut of meteorological data to be input for a specific locale. This
technique was developed for thermal pollution forecasting.

Understanding of statistical thermodynamic molecular theory is fundamental to the appreciation of molecular solutions. Development of the Potential Distribution Theorem (PDT) allows one to simplify this complex subject to down-to-earth presentations of molecular theory.

Notable, and sometimes controversial, computer simulations used in science include:

## Simulation environments for physics and engineering

Graphical environments to design simulations have been developed. Special care was taken to handle “events” (situations in which the simulation equations are not valid and have to be changed). The open project Open Source Physics was started in order to develop reusable libraries for simulations in Java, together with Easy Java Simulations, a complete graphical environment that generates code based on these libraries.

## Pitfalls in computer simulation

Although sometimes ignored in computer simulations, it is very important to perform sensitivity analysis to ensure that the accuracy of the results is properly understood. 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. If, for instance, one of the key parameters (i.e. the net ratio of oil-bearing strata) is known to only one significant figure, then the result of the simulation might not be more precise than one significant figure, although it might (misleadingly) be presented as having four significant figures.

## Computer simulation in practical contexts

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 computer 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 build-up 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.

See also: