# Continuous simulation

Continuous Simulation refers to simulation approaches where a system is modeled with the help of variables that change continuously according to a set of differential equations.

## History

It is notable as one of the first uses ever put to computers, dating back to the Eniac in 1946. Continuous simulation allows prediction of
* rocket trajectories
* hydrogen bomb dynamics (N.B. this is the first use ever put to the Eniac)
* electric circuit simulation
* robotics
Established in 1952, the Society for Modeling and Simulation International (SCS) is a nonprofit, volunteer-driven corporation dedicated to advancing the use of modeling & simulation to solve real-world problems. Their first publication strongly suggested that the Navy was wasting a lot of money through the inconclusive flight-testing of missiles, but that the Simulation Council's analog computer could provide better information through the simulation of flights. Since that time continuous simulation has been proven invaluable in military and private endeavors with complex systems. No Apollo moon shot would have been possible without it.

## Clarification of concepts

The distinction between continuous and discrete applies both to real-world dynamic systems and to their simulation.
A (real-world) dynamic system may be continuous or discrete. Continuous dynamic systems (like physical systems with material objects moving in space) are characterized by state variables the values of which change continuously, while the state variable values of discrete dynamic systems (like predator-prey ecosystems) "jump", that is, they are changed at discrete time steps only.
In continuous simulation, continuously changing state variables of a system are modeled by differential equations. However, in digital computing, real numbers cannot be faithfully represented and differential equations can only be solved numerically with approximate algorithms (like the method of Euler or Runge–Kutta) using some form of discretization. Consequently, digital computers cannot run truly continuous simulations. Only analog computers can run truly continuous simulations. In many cases though, digital computing approaches based on incremental time progression (with either fixed or dynamically adjusted increments) for discretizing time into small time steps provide satisfactory approximations.
Discrete event simulation, on the other hand, changes state variables only in response to events, typically using next-event time progression.
Continuous dynamic systems can only be captured by a continuous simulation model, while discrete dynamic systems can be captured either in a more abstract manner by a continuous simulation model (like the Lotka-Volterra equations for modeling a predator-prey eco-system) or in a more realistic manner by a discrete event simulation model (in a predator-prey eco-system, births, deaths and predator-prey encounters are discrete events). When using a continuous simulation model of the discrete dynamic system of a population of animals, one may get results like 23.7 animals, which first have to be rounded for making sense.
In the example shown to the right, the sales of a certain product over time is shown. Using a discrete event simulation makes it necessary to have an occurring event to change the number of sales. In contrast to this the continuous simulation has a smooth and steady development in its number of sales. It is worth noting that sales are discrete events that come with discrete state changes. A continuous simulation of sales implies the possibility of fractional sales e.g. 1/3 of a sale. For that reason, a continuous simulation of sales does not faithfully model reality but may nevertheless capture the system's dynamics approximately.

## Conceptual simulation model

Continuous simulations are based on a set of differential equations. These equations define the peculiarity of the state variables, the environment factors so to speak, of a system. These parameters of a system change in a continuous way and thus change the state of the entire system.
The set of differential equations can be formulated in a conceptual model representing the system on an abstract level. In order to develop the conceptual model 2 approaches are feasible:
* The deductive approach: The behaviour of the system arises from physical laws that can be applied
* The inductive approach: The behaviour of the system arises from observed behaviour of an example
A widely known example for a continuous conceptual simulation model is the "predator-prey model".

### The predator-prey model

This model is typical for revealing the dynamics of populations. As long as the population of the prey is on the rise, the predators population also rises, since they have enough to eat. But very soon the population of the predators becomes too large so that the hunting exceeds the procreation of the prey. This leads to a decrease in the prey population and as a consequence of this also to a decrease of the predator population as they do not have enough food to feed the entire population.
Any population dynamics involves the events of births and deaths and is therefore fundamentally a discrete dynamic system. However, modeling discrete state changes with differential equations often produces useful insights. A continuous simulation of population dynamics represents an approximation effectively fitting a curve to a finite set of measurements/points.

## Mathematical theory

In continuous simulation, the continuous time response of a physical system is modeled using ODEs, embedded in a conceptual model. The time response of a physical system depends on its initial state. The problem of solving the ODEs for a given initial state is called the initial value problem.
In very few cases these ODEs can be solved in a simple analytic way. More common are ODEs which do not have an analytic solution. In these cases one has to use numerical approximation procedures.
Two well known families of methods for solving initial value problems are:
* The Runge-Kutta family
* The Linear Multistep family.
When using numerical solvers the following properties of the solver must be considered:
* the stability of the method
* the method property of stiffness
* the discontinuity of the method
* Concluding remarks contained in the method and available to the user
These points are crucial to the success of the usage of one method.

### Mathematical examples

Newton's 2nd law, F = ma, is a good example of a single ODE continuous system. Numerical integration methods such as Runge Kutta, or Bulirsch-Stoer could be used to solve this particular system of ODEs.
By coupling the ODE solver with other numerical operators and methods a continuous simulator can be used to model many different physical phenomena such as
* flight dynamics
* robotics
* automotive suspensions
* hydraulics
* electric power
* electric motors
* human respiration
* polar ice cap melting
* steam power plants
* coffee machine
* etc.
There is virtually no limit to the kinds of physical phenomena that can be modeled by a system of ODE's. Some systems though can not have all derivative terms specified explicitly from known inputs and other ODE outputs. Those derivative terms are defined implicitly by other system constraints such as Kirchhoff's law that the flow of charge into a junction must equal the flow out. To solve these implicit ODE systems a converging iterative scheme such as Newton–Raphson must be employed.

## Simulation software

To speed creation of continuous simulations you can use graphical programming software packages like VisSim or Simcad Pro. The packages provide options for integration method, step size, optimization method, unknowns and cost function, and allow for conditional execution of subsystems to speed execution and prevent numerical errors for certain domains. Such graphical simulation software can be run in real-time and used as a training tool for managers and operators.

## Modern applications

Continuous simulation is found
* inside Wii stations
* commercial flight simulators
* jet plane auto pilots
* advanced engineering design tools
Indeed, much of modern technology that we enjoy today would not be possible without continuous simulation.

## Other types of simulation

* Discrete event simulation
* Computer simulation
* Process simulation
* Instructional Simulation
* Social simulation