learn-physics-0.6.3: Haskell code for learning physics

Copyright (c) Scott N. Walck 2014 BSD3 (see LICENSE) Scott N. Walck experimental Trustworthy Haskell98

Physics.Learn.Mechanics

Description

Newton's second law and all that

Synopsis

# Documentation

type TheTime = Double Source #

Time (in s).

A time step (in s).

type Velocity = Vec Source #

Velocity of a particle (in m/s).

# Simple one-particle state

A simple one-particle state, to get started quickly with mechanics of one particle.

An acceleration function gives the particle's acceleration as a function of the particle's state. The specification of this function is what makes one single-particle mechanics problem different from another. In order to write this function, add all of the forces that act on the particle, and divide this net force by the particle's mass. (Newton's second law).

Arguments

 :: SimpleAccelerationFunction acceleration function for the particle -> DifferentialEquation SimpleState differential equation

Time derivative of state for a single particle with a constant mass.

Arguments

 :: SimpleAccelerationFunction acceleration function for the particle -> TimeStep time step -> SimpleState initial state -> SimpleState state after one time step

Single Runge-Kutta step

# One-particle state

data St Source #

The state of a single particle is given by the position of the particle and the velocity of the particle.

Constructors

 St Fieldsposition :: Position velocity :: Velocity
Instances
 Source # Instance detailsDefined in Physics.Learn.Mechanics MethodsshowsPrec :: Int -> St -> ShowS #show :: St -> String #showList :: [St] -> ShowS # Source # Instance detailsDefined in Physics.Learn.Mechanics Associated Typestype Diff St :: * Source # Methods(.-.) :: St -> St -> Diff St Source #(.+^) :: St -> Diff St -> St Source # type Diff St Source # Instance detailsDefined in Physics.Learn.Mechanics type Diff St = DSt

data DSt Source #

The associated vector space for the state of a single particle.

Constructors

 DSt Vec Vec
Instances
 Source # Instance detailsDefined in Physics.Learn.Mechanics MethodsshowsPrec :: Int -> DSt -> ShowS #show :: DSt -> String #showList :: [DSt] -> ShowS # Source # Instance detailsDefined in Physics.Learn.Mechanics Associated Typestype Scalar DSt :: * # Methods(*^) :: Scalar DSt -> DSt -> DSt # Source # Instance detailsDefined in Physics.Learn.Mechanics Methods(^+^) :: DSt -> DSt -> DSt #negateV :: DSt -> DSt #(^-^) :: DSt -> DSt -> DSt # type Scalar DSt Source # Instance detailsDefined in Physics.Learn.Mechanics type Scalar DSt = Double

The state of a system of one particle is given by the current time, the position of the particle, and the velocity of the particle. Including time in the state like this allows us to have time-dependent forces.

An acceleration function gives the particle's acceleration as a function of the particle's state.

Arguments

 :: OneParticleAccelerationFunction acceleration function for the particle -> DifferentialEquation OneParticleSystemState differential equation

Time derivative of state for a single particle with a constant mass.

Arguments

 :: OneParticleAccelerationFunction acceleration function for the particle -> TimeStep time step -> OneParticleSystemState initial state -> OneParticleSystemState state after one time step

Single Runge-Kutta step

Arguments

 :: OneParticleAccelerationFunction acceleration function for the particle -> TimeStep time step -> OneParticleSystemState initial state -> [OneParticleSystemState] state after one time step

List of system states

# Two-particle state

type TwoParticleSystemState = (TheTime, St, St) Source #

The state of a system of two particles is given by the current time, the position and velocity of particle 1, and the position and velocity of particle 2.

An acceleration function gives a pair of accelerations (one for particle 1, one for particle 2) as a function of the system's state.

Arguments

 :: TwoParticleAccelerationFunction acceleration function for two particles -> DifferentialEquation TwoParticleSystemState differential equation

Time derivative of state for two particles with constant mass.

Arguments

 :: TwoParticleAccelerationFunction acceleration function -> TimeStep time step -> TwoParticleSystemState initial state -> TwoParticleSystemState state after one time step

Single Runge-Kutta step for two-particle system

# Many-particle state

type ManyParticleSystemState = (TheTime, [St]) Source #

The state of a system of many particles is given by the current time and a list of one-particle states.

An acceleration function gives a list of accelerations (one for each particle) as a function of the system's state.

Arguments

 :: ManyParticleAccelerationFunction acceleration function for many particles -> DifferentialEquation ManyParticleSystemState differential equation

Time derivative of state for many particles with constant mass.

Arguments

 :: ManyParticleAccelerationFunction acceleration function -> TimeStep time step -> ManyParticleSystemState initial state -> ManyParticleSystemState state after one time step

Single Runge-Kutta step for many-particle system