# GPU Acceleration Theoretical Background

## Description

This page provides the theoretical (mathematical/physics) background for the practical example "Accelerating Physics Calculations with CUDA and Python Using Numba"

## Background on Stochastic ODEs and Their Simulations

Ordinary differential equations with a stochastic component (i.e. noise) have a substantial mathematical literature.  When the noise has no memory (i.e. a delta function autocorrelation) it is referred to as white noise, and a stochastic calculus must be adopted to correctly discretize the ODE [1].  Most naturally occurring noise has a finite autocorrelation, and this type of noise is referred to as "red noise".  Realizations of red noise are continuous and hence and ODE with red noise does not require a stochastic calculus. One does need to be able to generate red noise, which our code implements using the method in [2].  Effectively, noise is a weighted sum of the previous noise and a new random number generated for each time step.

## Problem Statement

We consider a double-well nonlinear pendulum driven by periodic forcing with a stochastic component. Newton's 2nd law states that the rate of change of momentum of a body is equal to the net forcing acting on it. That is,

$\frac{d}{dt}(mv) = F_{Damping} + F_{Restoring} + F_{Driving} \,$

where the mass $$m$$ is assumed constant, $$v(t)$$ is the velocity of the pendulum and

$F_{Damping} = -\gamma v , \quad \gamma > 0 \,,$

$F_{Driving} = A\sin\left(\frac{2 \pi t}{T}\right) + \eta(t), \quad A > 0 \,,$

where $$\eta(t)$$ corresponds to correlated (red) noise with mean $$\mu = 0$$, standard deviation $$\sigma > 0$$, and auto-correlation function $$\rho(\Delta t) = \mbox{exp}\left({\frac{-\Delta t}{T_{Memory}}}\right)$$. Lastly,

$F_{Restoring} = -\frac{dV}{dx}\,,$

where

$V(x) = \left[ (x-x_{deep})(x - x_{shallow})\right]^2 + \beta x \,, \beta > 0 \,,$

defines a potential function.

Simplifying, we recover the initial value problem (IVP):

$v' + \gamma v + \frac{dV}{dx} = A \sin\left( \frac{2 \pi}{T} \right) + \eta(t) \,,$ $x' = v \,,$ $x(0) = x_0 \,, \quad v(0) = v_0 \,.$

This problem represents a system of two ODEs driving by random noise. Due to the mathematical form of the double-well potential function V(x) the problem is nonlinear and cannot be analytically integrated exactly.

To make progress, we use Monte Carlo simulations to run an ensemble of simulations with differing realizations of the random component of the driving force. For more details on the solution method, see the originating document (linked above).