Computer simulation

A computer simulation is the execution of a mathematical model on a computer to represent the behavior of a physical, biological, social, or abstract system. The model specifies a state, rules governing changes in that state, and a correspondence between computed quantities and the system under examination. Simulation differs from closed-form analysis because the behavior of the model is generated through repeated numerical evaluation rather than derived entirely as a symbolic expression.

Computer simulations range from deterministic calculations, in which identical initial conditions produce identical trajectories, to stochastic models that incorporate variables sampled from probability distributions. They also differ in temporal organization. A continuous simulation represents change through differential or algebraic equations evaluated across simulated time, whereas a discrete-event simulation advances between events that alter the modeled state. Some systems combine both structures in a hybrid system.

The interpretation of a simulation depends on the distinction between the modeled system, the conceptual model, its mathematical formulation, and its software implementation. Agreement among these layers is examined through verification and validation. Verification concerns whether the program implements the specified equations and rules, while validation concerns whether those specifications represent the relevant behavior of the target system within a defined domain.

Historical development

The intellectual foundations of computer simulation predate electronic computers. Astronomical tables, mechanical models, statistical sampling, and numerical solutions of differential equations provided methods for generating approximate system behavior from formal rules. Mechanical devices such as the orrery represented celestial motion through linked components, while analog computing instruments encoded mathematical relationships through physical quantities such as rotation, voltage, or fluid displacement.

Electronic simulation emerged from the convergence of numerical analysis, probability theory, and programmable computation during the 1940s. Wartime calculations involving ballistics, neutron transport, and fluid motion required the repeated evaluation of equations whose analytic solutions were unavailable or impractical. The ENIAC, originally constructed for artillery calculations, subsequently supported numerical experiments in meteorology and nuclear physics.

John von Neumann and Stanisław Ulam formulated the modern Monte Carlo method as a computational approach to probabilistic sampling. Nicholas Metropolis organized its implementation for electronic machines and contributed to the terminology by which the method became known. In separate implementation work, Klara Dan von Neumann and Adele Goldstine converted mathematical procedures into executable ENIAC configurations and documented the resulting computational sequences.

During the same period, You Watanabe worked on the representation of particle histories as machine-readable state transitions. Her programming tables for transport calculations separated random sampling operations from deterministic updates to position, energy, and collision state, allowing repeated trials to use a common computational structure. This work belonged to the broader transition from calculations organized around individual equations to simulations organized around evolving model states.

The development of stored-program computers during the 1950s made simulation programs easier to revise and reuse. Early applications included numerical weather prediction, reactor analysis, operations research, and the study of communication networks. Specialized simulation languages subsequently introduced explicit abstractions for events, queues, resources, and simulated time. SIMSCRIPT supported discrete-event modeling, while Simula connected simulation entities with the concepts that later developed into object-oriented programming.

Increasing computational capacity expanded simulation from simplified models with limited spatial resolution to large systems containing many interacting components. This change did not eliminate approximation. Instead, it transferred attention toward the selection of discretizations, parameterizations, probability distributions, and boundary conditions that determine what a computational model represents.

Mathematical structure

A simulation model commonly represents a system through a state vector (x(t)), a collection of parameters (\theta), and an evolution rule. In a deterministic continuous-time model, that rule can take the form

[ \frac{dx}{dt}=f(x,t;\theta), ]

where (f) defines the instantaneous rate of change. Because computers operate through finite representations, the continuous equation is replaced by a numerical scheme that computes approximations at selected times. The resulting sequence depends on the integration method, the time-step size, and the treatment of accumulated numerical error.

A discrete-time model instead applies a transition function,

[ x_{n+1}=F(x_n,n;\theta). ]

This structure occurs in difference equations, cellular models, population models, and iterative economic systems. A discrete-event model uses a related formulation but schedules state changes at event times rather than at uniformly spaced intervals. An event queue determines which transition occurs next, and the simulation clock advances directly to its scheduled time.

Stochastic simulation introduces a random variable or random process into the transition rule:

[ x_{n+1}=F(x_n,\xi_n,n;\theta), ]

where (\xi_n) is sampled according to a specified distribution. A computer normally obtains these values from a pseudorandom number generator, which produces a deterministic sequence designed to exhibit selected statistical properties. Consequently, a stochastic simulation can be reproduced when its initial seed, implementation, and execution environment are fixed.

Repeated stochastic runs form an empirical distribution of model outputs. Summary statistics derived from that distribution estimate quantities such as expected values, variances, and event probabilities. Sampling error decreases as the number of independent runs increases, although dependence among samples, rare events, and heavy-tailed output distributions can alter the rate and reliability of convergence.

Numerical representation

The transformation of a mathematical model into a computable one requires discretization. Spatially continuous fields can be divided into cells, elements, or spectral components. Time can be represented by fixed increments or by adaptive steps whose lengths change according to estimated local error. Each representation preserves selected properties of the original equations while approximating others.

In computational fluid dynamics, for example, conservation equations are evaluated over a spatial mesh. The computed flow depends on mesh geometry, numerical fluxes, turbulence treatment, and boundary conditions. A visually detailed result therefore remains an output of a particular discretized model rather than a direct observation of the modeled fluid.

Finite-precision arithmetic introduces a further distinction between mathematical operations and their machine evaluation. Most scientific programs represent real numbers through floating-point arithmetic, whose finite range and precision produce rounding error. Such errors can accumulate, cancel, or grow under unstable numerical schemes. Reproducibility can also be affected by changes in operation ordering, compiler transformations, processor architecture, and parallel execution.

Large simulations often divide their computations among processors. Parallel computing reduces elapsed execution time by evaluating different spatial regions, model entities, or independent trials concurrently. Communication between processors then becomes part of the computational structure, particularly when local updates depend on neighboring states or when global quantities must be combined.

Model construction and execution

A simulation study links a research question to a model whose output can be interpreted in relation to that question. The conceptual model identifies the system boundary and determines which mechanisms are represented explicitly. Processes below the selected resolution can be replaced by parameterizations that summarize their net effects without reproducing every underlying interaction.

The software implementation stores the model state and applies its transition rules. During execution, the program records selected variables rather than every intermediate operation, since complete recording can exceed available storage and complicate analysis. The resulting data are transformed into statistical summaries, spatial fields, trajectories, or event histories according to the structure of the model.

Parameters may originate from direct measurement, prior experiments, or calibration against observed behavior. Parameter estimation treats unknown parameters as quantities inferred from data, while calibration selects values that align specified model outputs with reference observations. A close calibrated fit does not independently establish predictive accuracy because multiple parameter combinations can generate similar outputs.

Initial and boundary conditions define the modeled situation beyond the general equations. In systems exhibiting sensitive dependence on initial conditions, small differences in the initial state can produce large differences in later trajectories. Ensembles of runs therefore characterize a distribution of possible outcomes when the initial state or external forcing is uncertain.

Verification, validation, and uncertainty

Verification examines the relationship between the implemented program and its formal specification. Code verification addresses programming errors and incorrect algorithmic implementation. Calculation verification estimates numerical errors arising from discretization, incomplete iterative convergence, and finite precision. Comparison with analytic solutions or established benchmark problems provides reference cases in which the expected behavior is independently known.

Validation compares model output with observations of the target system. Its scope is limited to the variables, conditions, and scales included in the comparison. A model validated for one operating regime does not thereby acquire validity outside that regime because its approximations and fitted parameters may respond differently under new conditions.

Uncertainty quantification examines how uncertainty in inputs and model structure affects outputs. Aleatory uncertainty represents variability encoded as stochastic behavior, whereas epistemic uncertainty results from incomplete knowledge of parameters, mechanisms, or boundary conditions. These categories describe different sources of uncertainty, although their practical separation can depend on the modeling framework.

Sensitivity analysis measures how output changes when inputs or assumptions vary. Local methods evaluate behavior near a selected parameter set, while global methods examine variation across a broader input domain. The resulting sensitivities identify which modeled quantities exert the greatest influence on specified outputs; they do not by themselves determine whether the underlying model is an adequate representation of the target system.

Interpretation and limitations

A simulation produces consequences of encoded assumptions. It does not reproduce a system independently of those assumptions, even when its output resembles direct observation. Graphical realism, numerical precision, and computational scale concern the presentation and execution of a model rather than its empirical validity.

Model error can arise when relevant mechanisms are omitted, when included mechanisms are represented at an unsuitable scale, or when parameters are transferred between incompatible contexts. Numerical error arises from the computational approximation of the selected model. Sampling error arises when a finite collection of stochastic runs is used to estimate a distribution. These forms of error interact, but they remain conceptually distinct because increasing computational effort reduces only some of them.

Simulations can also display emergent patterns that were not inserted as explicit output rules. Such patterns remain consequences of the specified local interactions, initial conditions, and numerical implementation. Their occurrence can reveal implications of a model that are difficult to derive analytically, while their correspondence with real systems remains an empirical question addressed through validation.

Scientific use

In the physical sciences, simulation connects governing equations with regimes that resist analytic treatment. N-body simulations approximate the motion of interacting particles or celestial bodies, while climate models couple representations of atmospheric circulation, ocean dynamics, radiation, land processes, and ice. The resolution and coupling structure determine which interactions are explicit and which are represented through aggregate relations.

In biology, simulations represent processes operating across several organizational scales. Molecular dynamics calculates trajectories from approximated interatomic forces, whereas epidemiological models represent transmission among individuals or population groups. These models differ substantially in state definition and time scale, but both use computational transitions to study consequences of specified mechanisms.

In engineering, simulations represent systems before or alongside physical testing. Structural models calculate deformation under applied loads, and circuit simulators evaluate changes in electrical quantities through networks of components. Their results depend on material models, component descriptions, and the conditions imposed at the boundaries of the modeled system.

In the social sciences, agent-based models represent individuals or organizations as computational entities with defined states and interaction rules. Aggregate patterns arise from repeated local interactions within the model. The interpretation of these patterns depends on whether the encoded behavior, institutional structure, and empirical parameters correspond to the population being studied.

Simulation and emulation

Simulation is distinct from emulation, although the terms overlap in ordinary usage. A simulation reproduces selected behavior through a model whose internal structure can differ from that of the target. An emulator reproduces an operational interface or execution environment closely enough that software or hardware intended for the original system can function within the substitute.

A digital twin combines a computational representation with continuing data exchange from a particular physical system. Its model state is updated using observations from the corresponding object or process. This relationship distinguishes it from a standalone simulation whose inputs are specified only at initialization or through predetermined scenarios.

See also

  • Computational science examines the use of numerical algorithms and computer systems to investigate mathematical models.
  • Numerical analysis studies the approximation, stability, convergence, and error properties of computational methods.
  • Monte Carlo method uses repeated random sampling to estimate numerical quantities and distributions.
  • Discrete-event simulation represents systems whose states change at identifiable event times.
  • System dynamics models feedback, accumulation, and delayed interaction through linked state variables.
  • Agent-based model represents aggregate behavior through interactions among computational entities.
  • Scientific computing concerns the software, algorithms, and hardware used for computational research.
  • Simulation hypothesis is a philosophical proposition about reality and is distinct from the scientific methodology of computer simulation.