-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.html
33 lines (33 loc) · 35.3 KB
/
Main.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>Main</title><link href="linuwial.css" rel="stylesheet" type="text/css" title="Linuwial" /><link rel="stylesheet" type="text/css" href="quick-jump.css" /><link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=PT+Sans:400,400i,700" /><script src="haddock-bundle.min.js" async="async" type="text/javascript"></script><script type="text/x-mathjax-config">MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script></head><body><div id="package-header"><span class="caption empty"> </span><ul class="links" id="page-menu"><li><a href="src/Main.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>None</td></tr></table><p class="caption">Main</p></div><div id="table-of-contents"><div id="contents-list"><p class="caption" onclick="window.scrollTo(0,0)">Contents</p><ul><li><a href="#g:1">Types and data constructors</a></li><li><a href="#g:2">Constant functions (throughout all main)</a></li><li><a href="#g:3">Simulations</a><ul><li><a href="#g:4">First simulation</a><ul><li><a href="#g:5">Helper functions</a></li></ul></li><li><a href="#g:6">Second simulation</a><ul><li><a href="#g:7">Additional helper functions</a></li></ul></li><li><a href="#g:8">Third simulation</a><ul><li><a href="#g:9">Additional helper functions</a></li></ul></li><li><a href="#g:10">Fourth simulation</a><ul><li><a href="#g:11">Additional helper functions</a></li></ul></li><li><a href="#g:12">Fourth simulation</a><ul><li><a href="#g:13">Additional helper functions</a></li></ul></li></ul></li></ul></div></div><div id="synopsis"><details id="syn"><summary>Synopsis</summary><ul class="details-toggle" data-details-id="syn"><li class="src short"><a href="#v:main">main</a> :: IO ()</li><li class="src short"><span class="keyword">type</span> <a href="#t:Position">Position</a> = V2 Float</li><li class="src short"><span class="keyword">type</span> <a href="#t:Velocity">Velocity</a> = V2 Float</li><li class="src short"><span class="keyword">type</span> <a href="#t:Index">Index</a> = Int</li><li class="src short"><span class="keyword">type</span> <a href="#t:Force">Force</a> = V2 Float</li><li class="src short"><span class="keyword">type</span> <a href="#t:TimeStep">TimeStep</a> = Float</li><li class="src short"><span class="keyword">data</span> <a href="#t:Particle">Particle</a> = <a href="#v:Particle">Particle</a> {<ul class="subs"><li><a href="#v:idx">idx</a> :: <a href="Main.html#t:Index" title="Main">Index</a></li><li><a href="#v:pos">pos</a> :: <a href="Main.html#t:Position" title="Main">Position</a></li><li><a href="#v:vel">vel</a> :: <a href="Main.html#t:Velocity" title="Main">Velocity</a></li></ul>}</li><li class="src short"><span class="keyword">type</span> <a href="#t:Model">Model</a> = [<a href="Main.html#t:Particle" title="Main">Particle</a>]</li><li class="src short"><a href="#v:dotSize">dotSize</a> :: Float</li><li class="src short"><a href="#v:windowDisplay">windowDisplay</a> :: Display</li><li class="src short"><a href="#v:simulationRate">simulationRate</a> :: Int</li><li class="src short"><a href="#v:toPixels">toPixels</a> :: Float -> Float</li><li class="src short"><a href="#v:aLength">aLength</a> :: Float</li><li class="src short"><a href="#v:bLength">bLength</a> :: Float</li><li class="src short"><a href="#v:mainNewton">mainNewton</a> :: IO ()</li><li class="src short"><a href="#v:drawParticle">drawParticle</a> :: <a href="Main.html#t:Particle" title="Main">Particle</a> -> Picture</li><li class="src short"><a href="#v:newton">newton</a> :: <a href="Main.html#t:TimeStep" title="Main">TimeStep</a> -> [<a href="Main.html#t:Particle" title="Main">Particle</a>] -> [<a href="Main.html#t:Particle" title="Main">Particle</a>]</li><li class="src short"><a href="#v:mainNewtonBounce">mainNewtonBounce</a> :: IO ()</li><li class="src short"><a href="#v:drawWalls">drawWalls</a> :: Picture</li><li class="src short"><a href="#v:newtonBounce">newtonBounce</a> :: Float -> [<a href="Main.html#t:Particle" title="Main">Particle</a>] -> [<a href="Main.html#t:Particle" title="Main">Particle</a>]</li><li class="src short"><a href="#v:boundaryCondition">boundaryCondition</a> :: <a href="Main.html#t:Particle" title="Main">Particle</a> -> V2 Float</li><li class="src short"><a href="#v:mainVerlet">mainVerlet</a> :: IO ()</li><li class="src short"><a href="#v:verletStep">verletStep</a> :: <a href="Main.html#t:TimeStep" title="Main">TimeStep</a> -> <a href="Main.html#t:Model" title="Main">Model</a> -> <a href="Main.html#t:Model" title="Main">Model</a></li><li class="src short"><a href="#v:m">m</a> :: Float</li><li class="src short"><a href="#v:epsilon">epsilon</a> :: Float</li><li class="src short"><a href="#v:sigma">sigma</a> :: Float</li><li class="src short"><a href="#v:sigma6">sigma6</a> :: Float</li><li class="src short"><a href="#v:sigma12">sigma12</a> :: Float</li><li class="src short"><a href="#v:calcForces">calcForces</a> :: [<a href="Main.html#t:Particle" title="Main">Particle</a>] -> [<a href="Main.html#t:Force" title="Main">Force</a>]</li><li class="src short"><a href="#v:calcForceAcc">calcForceAcc</a> :: [<a href="Main.html#t:Particle" title="Main">Particle</a>] -> [<a href="Main.html#t:Particle" title="Main">Particle</a>] -> [<a href="Main.html#t:Force" title="Main">Force</a>]</li><li class="src short"><a href="#v:calcForceOnOne">calcForceOnOne</a> :: <a href="Main.html#t:Particle" title="Main">Particle</a> -> [<a href="Main.html#t:Particle" title="Main">Particle</a>] -> [<a href="Main.html#t:Force" title="Main">Force</a>]</li><li class="src short"><a href="#v:calcForceBetween">calcForceBetween</a> :: <a href="Main.html#t:Particle" title="Main">Particle</a> -> <a href="Main.html#t:Particle" title="Main">Particle</a> -> <a href="Main.html#t:Force" title="Main">Force</a></li><li class="src short"><a href="#v:repulsion">repulsion</a> :: <a href="Main.html#t:Position" title="Main">Position</a> -> <a href="Main.html#t:Position" title="Main">Position</a> -> <a href="Main.html#t:Force" title="Main">Force</a></li><li class="src short"><a href="#v:attraction">attraction</a> :: <a href="Main.html#t:Position" title="Main">Position</a> -> <a href="Main.html#t:Position" title="Main">Position</a> -> <a href="Main.html#t:Force" title="Main">Force</a></li><li class="src short"><a href="#v:updatePosition">updatePosition</a> :: <a href="Main.html#t:TimeStep" title="Main">TimeStep</a> -> <a href="Main.html#t:Particle" title="Main">Particle</a> -> <a href="Main.html#t:Force" title="Main">Force</a> -> <a href="Main.html#t:Particle" title="Main">Particle</a></li><li class="src short"><a href="#v:updateVelocity">updateVelocity</a> :: <a href="Main.html#t:TimeStep" title="Main">TimeStep</a> -> <a href="Main.html#t:Particle" title="Main">Particle</a> -> <a href="Main.html#t:Force" title="Main">Force</a> -> <a href="Main.html#t:Particle" title="Main">Particle</a></li><li class="src short"><a href="#v:updatePositions">updatePositions</a> :: <a href="Main.html#t:TimeStep" title="Main">TimeStep</a> -> [<a href="Main.html#t:Particle" title="Main">Particle</a>] -> [<a href="Main.html#t:Force" title="Main">Force</a>] -> [<a href="Main.html#t:Particle" title="Main">Particle</a>]</li><li class="src short"><a href="#v:updateVelocities">updateVelocities</a> :: <a href="Main.html#t:TimeStep" title="Main">TimeStep</a> -> [<a href="Main.html#t:Particle" title="Main">Particle</a>] -> [<a href="Main.html#t:Force" title="Main">Force</a>] -> [<a href="Main.html#t:Particle" title="Main">Particle</a>]</li><li class="src short"><a href="#v:mainVerletSquare">mainVerletSquare</a> :: IO ()</li><li class="src short"><a href="#v:squareLatticeModel">squareLatticeModel</a> :: Int -> [<a href="Main.html#t:Particle" title="Main">Particle</a>]</li><li class="src short"><a href="#v:squareLattice">squareLattice</a> :: Int -> Int -> [<a href="Main.html#t:Position" title="Main">Position</a>]</li><li class="src short"><a href="#v:latticeRow">latticeRow</a> :: Int -> Int -> Float -> [<a href="Main.html#t:Position" title="Main">Position</a>]</li><li class="src short"><a href="#v:mainVerletRandom">mainVerletRandom</a> :: IO ()</li><li class="src short"><a href="#v:modelRandom">modelRandom</a> :: RandomGen g => Int -> g -> [<a href="Main.html#t:Particle" title="Main">Particle</a>]</li><li class="src short"><a href="#v:randomVel">randomVel</a> :: RandomGen g => Int -> g -> [<a href="Main.html#t:Velocity" title="Main">Velocity</a>]</li><li class="src short"><a href="#v:randomPos">randomPos</a> :: RandomGen g => Int -> g -> [<a href="Main.html#t:Position" title="Main">Position</a>]</li><li class="src short"><a href="#v:genPos">genPos</a> :: RandomGen g => g -> (<a href="Main.html#t:Position" title="Main">Position</a>, g)</li></ul></details></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><a id="v:main" class="def">main</a> :: IO () <a href="src/Main.html#main" class="link">Source</a> <a href="#v:main" class="selflink">#</a></p><div class="doc"><p>Select the main function of your choice</p><ul><li><code><a href="Main.html#v:mainNewton" title="Main">mainNewton</a></code></li><li><code><a href="Main.html#v:mainNewtonBounce" title="Main">mainNewtonBounce</a></code></li><li><code><a href="Main.html#v:mainVerlet" title="Main">mainVerlet</a></code></li><li><code><a href="Main.html#v:mainVerletSquare" title="Main">mainVerletSquare</a></code></li><li><code><a href="Main.html#v:mainVerletRandom" title="Main">mainVerletRandom</a></code></li></ul><p>to perform the according simulation</p></div></div><a href="#g:1" id="g:1"><h1>Types and data constructors</h1></a><div class="top"><p class="src"><span class="keyword">type</span> <a id="t:Position" class="def">Position</a> = V2 Float <a href="src/Main.html#Position" class="link">Source</a> <a href="#t:Position" class="selflink">#</a></p><div class="doc"><p>Represents the spatial vector (<code><a href="Main.html#t:Position" title="Main">Position</a></code>) <span class="mathjax">\(\vec{r}\)</span> as a two-dimensional vector</p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a id="t:Velocity" class="def">Velocity</a> = V2 Float <a href="src/Main.html#Velocity" class="link">Source</a> <a href="#t:Velocity" class="selflink">#</a></p><div class="doc"><p>Represents the velocity vector <span class="mathjax">\(\vec{v}\)</span> as a two-dimensional vector</p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a id="t:Index" class="def">Index</a> = Int <a href="src/Main.html#Index" class="link">Source</a> <a href="#t:Index" class="selflink">#</a></p><div class="doc"><p>Index of a <code><a href="Main.html#t:Particle" title="Main">Particle</a></code> to make it distinguishable from other <code><a href="Main.html#t:Particle" title="Main">Particle</a></code>s</p><p><strong>Note</strong>: <code><a href="Main.html#t:Position" title="Main">Position</a></code> and <code><a href="Main.html#t:Velocity" title="Main">Velocity</a></code> do not make a <code><a href="Main.html#t:Particle" title="Main">Particle</a></code> distinguishable
and even if, floating point errors would make this comparison invalid</p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a id="t:Force" class="def">Force</a> = V2 Float <a href="src/Main.html#Force" class="link">Source</a> <a href="#t:Force" class="selflink">#</a></p><div class="doc"><p>Represents the force vector <span class="mathjax">\(\vec{F}\)</span> as a two-dimensional vector</p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a id="t:TimeStep" class="def">TimeStep</a> = Float <a href="src/Main.html#TimeStep" class="link">Source</a> <a href="#t:TimeStep" class="selflink">#</a></p><div class="doc"><p>Represents the time step in the simulation <span class="mathjax">\( (\Delta t) \)</span></p></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:Particle" class="def">Particle</a> <a href="src/Main.html#Particle" class="link">Source</a> <a href="#t:Particle" class="selflink">#</a></p><div class="doc"><p>Representation of a <code><a href="Main.html#t:Particle" title="Main">Particle</a></code>. All we need is a <code><a href="Main.html#t:Index" title="Main">Index</a></code> (comparison) and a <code><a href="Main.html#t:Position" title="Main">Position</a></code>
and <code><a href="Main.html#t:Velocity" title="Main">Velocity</a></code>. The mass of the particle <code><a href="Main.html#v:m" title="Main">m</a></code> is assumed to be the same for all
<code><a href="Main.html#t:Particle" title="Main">Particle</a></code>s</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a id="v:Particle" class="def">Particle</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><ul><li><dfn class="src"><a id="v:idx" class="def">idx</a> :: <a href="Main.html#t:Index" title="Main">Index</a></dfn><div class="doc empty"> </div></li><li><dfn class="src"><a id="v:pos" class="def">pos</a> :: <a href="Main.html#t:Position" title="Main">Position</a></dfn><div class="doc empty"> </div></li><li><dfn class="src"><a id="v:vel" class="def">vel</a> :: <a href="Main.html#t:Velocity" title="Main">Velocity</a></dfn><div class="doc empty"> </div></li></ul></div></td></tr></table></div><div class="subs instances"><h4 class="instances details-toggle-control details-toggle" data-details-id="i:Particle">Instances</h4><details id="i:Particle" open="open"><summary class="hide-when-js-enabled">Instances details</summary><table><tr><td class="src clearfix"><span class="inst-left"><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Particle:Eq:1"></span> Eq <a href="Main.html#t:Particle" title="Main">Particle</a></span> <a href="src/Main.html#line-58" class="link">Source</a> <a href="#t:Particle" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><details id="i:id:Particle:Eq:1"><summary class="hide-when-js-enabled">Instance details</summary><p>Defined in <a href="Main.html">Main</a></p> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="Main.html#t:Particle" title="Main">Particle</a> -> <a href="Main.html#t:Particle" title="Main">Particle</a> -> Bool</p><p class="src"><a href="#v:-47--61-">(/=)</a> :: <a href="Main.html#t:Particle" title="Main">Particle</a> -> <a href="Main.html#t:Particle" title="Main">Particle</a> -> Bool</p></div></details></td></tr></table></details></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a id="t:Model" class="def">Model</a> = [<a href="Main.html#t:Particle" title="Main">Particle</a>] <a href="src/Main.html#Model" class="link">Source</a> <a href="#t:Model" class="selflink">#</a></p><div class="doc"><p>The <code><a href="Main.html#t:Model" title="Main">Model</a></code> consists of a set/list of <code><a href="Main.html#t:Particle" title="Main">Particle</a></code></p></div></div><a href="#g:2" id="g:2"><h1>Constant functions (throughout all main)</h1></a><div class="top"><p class="src"><a id="v:dotSize" class="def">dotSize</a> :: Float <a href="src/Main.html#dotSize" class="link">Source</a> <a href="#v:dotSize" class="selflink">#</a></p><div class="doc"><p>Size of the <code><a href="Main.html#t:Particle" title="Main">Particle</a></code>s</p></div></div><div class="top"><p class="src"><a id="v:windowDisplay" class="def">windowDisplay</a> :: Display <a href="src/Main.html#windowDisplay" class="link">Source</a> <a href="#v:windowDisplay" class="selflink">#</a></p><div class="doc"><p>Window display config</p><p>Show a 800x800 window at the window coordinate (200, 800) with the title "MD in
Haskell"</p></div></div><div class="top"><p class="src"><a id="v:simulationRate" class="def">simulationRate</a> :: Int <a href="src/Main.html#simulationRate" class="link">Source</a> <a href="#v:simulationRate" class="selflink">#</a></p><div class="doc"><p>Number of frames per second</p></div></div><div class="top"><p class="src"><a id="v:toPixels" class="def">toPixels</a> :: Float -> Float <a href="src/Main.html#toPixels" class="link">Source</a> <a href="#v:toPixels" class="selflink">#</a></p><div class="doc"><p>Transform a value to the scale of Pixels</p></div></div><div class="top"><p class="src"><a id="v:aLength" class="def">aLength</a> :: Float <a href="src/Main.html#aLength" class="link">Source</a> <a href="#v:aLength" class="selflink">#</a></p><div class="doc"><p>Length in the x dimension (width)</p></div></div><div class="top"><p class="src"><a id="v:bLength" class="def">bLength</a> :: Float <a href="src/Main.html#bLength" class="link">Source</a> <a href="#v:bLength" class="selflink">#</a></p><div class="doc"><p>Length in the y dimension (height)</p></div></div><a href="#g:3" id="g:3"><h1>Simulations</h1></a><a href="#g:4" id="g:4"><h2>First simulation</h2></a><div class="top"><p class="src"><a id="v:mainNewton" class="def">mainNewton</a> :: IO () <a href="src/Main.html#mainNewton" class="link">Source</a> <a href="#v:mainNewton" class="selflink">#</a></p><div class="doc"><p>The initial model consists of one <code><a href="Main.html#t:Particle" title="Main">Particle</a></code>,
which will be drawn and updated according to <code><a href="Main.html#v:newton" title="Main">newton</a></code>.</p><p>This results in a <code><a href="Main.html#t:Particle" title="Main">Particle</a></code> moving from the center of the
screen to the right:</p></div></div><a href="#g:5" id="g:5"><h3>Helper functions</h3></a><div class="top"><p class="src"><a id="v:drawParticle" class="def">drawParticle</a> :: <a href="Main.html#t:Particle" title="Main">Particle</a> -> Picture <a href="src/Main.html#drawParticle" class="link">Source</a> <a href="#v:drawParticle" class="selflink">#</a></p><div class="doc"><p>Visualize a single <code><a href="Main.html#t:Particle" title="Main">Particle</a></code> as blue dot
by transforming the <code><a href="Main.html#t:Position" title="Main">Position</a></code> of the <code><a href="Main.html#t:Particle" title="Main">Particle</a></code> into
a <code>Picture</code>, which can be rendered</p></div></div><div class="top"><p class="src"><a id="v:newton" class="def">newton</a> :: <a href="Main.html#t:TimeStep" title="Main">TimeStep</a> -> [<a href="Main.html#t:Particle" title="Main">Particle</a>] -> [<a href="Main.html#t:Particle" title="Main">Particle</a>] <a href="src/Main.html#newton" class="link">Source</a> <a href="#v:newton" class="selflink">#</a></p><div class="doc"><p>Update velocity of one <code><a href="Main.html#t:Particle" title="Main">Particle</a></code>
assuming no acceleration</p></div></div><a href="#g:6" id="g:6"><h2>Second simulation</h2></a><div class="top"><p class="src"><a id="v:mainNewtonBounce" class="def">mainNewtonBounce</a> :: IO () <a href="src/Main.html#mainNewtonBounce" class="link">Source</a> <a href="#v:mainNewtonBounce" class="selflink">#</a></p><div class="doc"><p>The initial model consists of one <code><a href="Main.html#t:Particle" title="Main">Particle</a></code>,
which will be drawn and updated according to <code><a href="Main.html#v:newtonBounce" title="Main">newtonBounce</a></code>.</p><p>This results in a <code><a href="Main.html#t:Particle" title="Main">Particle</a></code> moving from the center of the
screen to the right and will bounce of the wall:</p></div></div><a href="#g:7" id="g:7"><h3>Additional helper functions</h3></a><div class="top"><p class="src"><a id="v:drawWalls" class="def">drawWalls</a> :: Picture <a href="src/Main.html#drawWalls" class="link">Source</a> <a href="#v:drawWalls" class="selflink">#</a></p><div class="doc"><p>A <code>Picture</code> of the wall surrounding the <code><a href="Main.html#t:Particle" title="Main">Particle</a></code> ("simulation box")</p></div></div><div class="top"><p class="src"><a id="v:newtonBounce" class="def">newtonBounce</a> :: Float -> [<a href="Main.html#t:Particle" title="Main">Particle</a>] -> [<a href="Main.html#t:Particle" title="Main">Particle</a>] <a href="src/Main.html#newtonBounce" class="link">Source</a> <a href="#v:newtonBounce" class="selflink">#</a></p><div class="doc"><p>Updated <code><a href="Main.html#v:newton" title="Main">newton</a></code> function, which incorporates bouncing of the wall (see
<code><a href="Main.html#v:boundaryCondition" title="Main">boundaryCondition</a></code>)</p></div></div><div class="top"><p class="src"><a id="v:boundaryCondition" class="def">boundaryCondition</a> :: <a href="Main.html#t:Particle" title="Main">Particle</a> -> V2 Float <a href="src/Main.html#boundaryCondition" class="link">Source</a> <a href="#v:boundaryCondition" class="selflink">#</a></p><div class="doc"><p>Transformation vector, which is used to change the direction of a <code><a href="Main.html#t:Particle" title="Main">Particle</a></code>, when it
is close (current <code><a href="Main.html#t:Position" title="Main">Position</a></code> + radius of the particle) to a wall in x,
y or (x and y) direction.</p></div></div><a href="#g:8" id="g:8"><h2>Third simulation</h2></a><div class="top"><p class="src"><a id="v:mainVerlet" class="def">mainVerlet</a> :: IO () <a href="src/Main.html#mainVerlet" class="link">Source</a> <a href="#v:mainVerlet" class="selflink">#</a></p><div class="doc"><p>First simulation using the <a href="https://en.wikipedia.org/wiki/Verlet_integration#Velocity_Verlet">Velocity Verlet
algorithm</a>
and the <a href="https://en.wikipedia.org/wiki/Lennard-Jones_potential">Lennard-Jones
potential</a>
of two <code><a href="Main.html#t:Particle" title="Main">Particle</a></code>s. They attract and repulse each other.</p></div></div><a href="#g:9" id="g:9"><h3>Additional helper functions</h3></a><div class="top"><p class="src"><a id="v:verletStep" class="def">verletStep</a> :: <a href="Main.html#t:TimeStep" title="Main">TimeStep</a> -> <a href="Main.html#t:Model" title="Main">Model</a> -> <a href="Main.html#t:Model" title="Main">Model</a> <a href="src/Main.html#verletStep" class="link">Source</a> <a href="#v:verletStep" class="selflink">#</a></p><div class="doc"><p>Implementation of the <a href="https://en.wikipedia.org/wiki/Verlet_integration#Velocity_Verlet">Velocity Verlet
algorithm</a> (without
the half-step)</p></div></div><div class="top"><p class="src"><a id="v:m" class="def">m</a> :: Float <a href="src/Main.html#m" class="link">Source</a> <a href="#v:m" class="selflink">#</a></p><div class="doc"><p>Mass of all our <code><a href="Main.html#t:Particle" title="Main">Particle</a></code>s</p></div></div><div class="top"><p class="src"><a id="v:epsilon" class="def">epsilon</a> :: Float <a href="src/Main.html#epsilon" class="link">Source</a> <a href="#v:epsilon" class="selflink">#</a></p><div class="doc"><p>The <span class="mathjax">\(\epsilon\)</span> value of the <a href="https://en.wikipedia.org/wiki/Lennard-Jones_potential">Lennard-Jones
potential</a></p></div></div><div class="top"><p class="src"><a id="v:sigma" class="def">sigma</a> :: Float <a href="src/Main.html#sigma" class="link">Source</a> <a href="#v:sigma" class="selflink">#</a></p><div class="doc"><p>The <span class="mathjax">\(\sigma\)</span> value of the <a href="https://en.wikipedia.org/wiki/Lennard-Jones_potential">Lennard-Jones
potential</a></p></div></div><div class="top"><p class="src"><a id="v:sigma6" class="def">sigma6</a> :: Float <a href="src/Main.html#sigma6" class="link">Source</a> <a href="#v:sigma6" class="selflink">#</a></p><div class="doc"><p>Helper function for</p><p><span class="mathjax">\(\sigma^6\)</span></p></div></div><div class="top"><p class="src"><a id="v:sigma12" class="def">sigma12</a> :: Float <a href="src/Main.html#sigma12" class="link">Source</a> <a href="#v:sigma12" class="selflink">#</a></p><div class="doc"><p>Helper function for</p><p><span class="mathjax">\(\sigma^{12}\)</span></p></div></div><div class="top"><p class="src"><a id="v:calcForces" class="def">calcForces</a> :: [<a href="Main.html#t:Particle" title="Main">Particle</a>] -> [<a href="Main.html#t:Force" title="Main">Force</a>] <a href="src/Main.html#calcForces" class="link">Source</a> <a href="#v:calcForces" class="selflink">#</a></p><div class="doc"><p>Calculate <strong>all</strong> <code><a href="Main.html#t:Force" title="Main">Force</a></code>s on <strong>all</strong> <code><a href="Main.html#t:Particle" title="Main">Particle</a></code>s employing
<code><a href="Main.html#v:calcForceAcc" title="Main">calcForceAcc</a></code></p></div></div><div class="top"><p class="src"><a id="v:calcForceAcc" class="def">calcForceAcc</a> :: [<a href="Main.html#t:Particle" title="Main">Particle</a>] -> [<a href="Main.html#t:Particle" title="Main">Particle</a>] -> [<a href="Main.html#t:Force" title="Main">Force</a>] <a href="src/Main.html#calcForceAcc" class="link">Source</a> <a href="#v:calcForceAcc" class="selflink">#</a></p><div class="doc"><p>Helper function for
calculating <strong>all</strong> <code><a href="Main.html#t:Force" title="Main">Force</a></code>s on <strong>all</strong> <code><a href="Main.html#t:Particle" title="Main">Particle</a></code>s</p></div></div><div class="top"><p class="src"><a id="v:calcForceOnOne" class="def">calcForceOnOne</a> :: <a href="Main.html#t:Particle" title="Main">Particle</a> -> [<a href="Main.html#t:Particle" title="Main">Particle</a>] -> [<a href="Main.html#t:Force" title="Main">Force</a>] <a href="src/Main.html#calcForceOnOne" class="link">Source</a> <a href="#v:calcForceOnOne" class="selflink">#</a></p><div class="doc"><p>Calculate <strong>all</strong> <code><a href="Main.html#t:Force" title="Main">Force</a></code>s on <strong>one</strong> <code><a href="Main.html#t:Particle" title="Main">Particle</a></code></p></div></div><div class="top"><p class="src"><a id="v:calcForceBetween" class="def">calcForceBetween</a> :: <a href="Main.html#t:Particle" title="Main">Particle</a> -> <a href="Main.html#t:Particle" title="Main">Particle</a> -> <a href="Main.html#t:Force" title="Main">Force</a> <a href="src/Main.html#calcForceBetween" class="link">Source</a> <a href="#v:calcForceBetween" class="selflink">#</a></p><div class="doc"><p>Calculates the <code><a href="Main.html#t:Force" title="Main">Force</a></code> between <strong>two</strong> <code><a href="Main.html#t:Particle" title="Main">Particle</a></code>
as long as they are not the same (compare <code><a href="Main.html#t:Index" title="Main">Index</a></code>)</p></div></div><div class="top"><p class="src"><a id="v:repulsion" class="def">repulsion</a> :: <a href="Main.html#t:Position" title="Main">Position</a> -> <a href="Main.html#t:Position" title="Main">Position</a> -> <a href="Main.html#t:Force" title="Main">Force</a> <a href="src/Main.html#repulsion" class="link">Source</a> <a href="#v:repulsion" class="selflink">#</a></p><div class="doc"><p>Repulsion term of the <a href="https://en.wikipedia.org/wiki/Lennard-Jones_potential">Lennard-Jones
potential</a></p></div></div><div class="top"><p class="src"><a id="v:attraction" class="def">attraction</a> :: <a href="Main.html#t:Position" title="Main">Position</a> -> <a href="Main.html#t:Position" title="Main">Position</a> -> <a href="Main.html#t:Force" title="Main">Force</a> <a href="src/Main.html#attraction" class="link">Source</a> <a href="#v:attraction" class="selflink">#</a></p><div class="doc"><p>Attraction term of the <a href="https://en.wikipedia.org/wiki/Lennard-Jones_potential">Lennard-Jones
potential</a></p></div></div><div class="top"><p class="src"><a id="v:updatePosition" class="def">updatePosition</a> :: <a href="Main.html#t:TimeStep" title="Main">TimeStep</a> -> <a href="Main.html#t:Particle" title="Main">Particle</a> -> <a href="Main.html#t:Force" title="Main">Force</a> -> <a href="Main.html#t:Particle" title="Main">Particle</a> <a href="src/Main.html#updatePosition" class="link">Source</a> <a href="#v:updatePosition" class="selflink">#</a></p><div class="doc"><p>Update the position/velocity of <strong>one</strong> <code><a href="Main.html#t:Particle" title="Main">Particle</a></code></p></div></div><div class="top"><p class="src"><a id="v:updateVelocity" class="def">updateVelocity</a> :: <a href="Main.html#t:TimeStep" title="Main">TimeStep</a> -> <a href="Main.html#t:Particle" title="Main">Particle</a> -> <a href="Main.html#t:Force" title="Main">Force</a> -> <a href="Main.html#t:Particle" title="Main">Particle</a> <a href="src/Main.html#updateVelocity" class="link">Source</a> <a href="#v:updateVelocity" class="selflink">#</a></p><div class="doc"><p>Update the position/velocity of <strong>one</strong> <code><a href="Main.html#t:Particle" title="Main">Particle</a></code></p></div></div><div class="top"><p class="src"><a id="v:updatePositions" class="def">updatePositions</a> :: <a href="Main.html#t:TimeStep" title="Main">TimeStep</a> -> [<a href="Main.html#t:Particle" title="Main">Particle</a>] -> [<a href="Main.html#t:Force" title="Main">Force</a>] -> [<a href="Main.html#t:Particle" title="Main">Particle</a>] <a href="src/Main.html#updatePositions" class="link">Source</a> <a href="#v:updatePositions" class="selflink">#</a></p><div class="doc"><p>Apply <code><a href="Main.html#v:updatePosition" title="Main">updatePosition</a></code>/<code><a href="Main.html#v:updateVelocity" title="Main">updateVelocity</a></code> to
<strong>all</strong> (list/set) <code><a href="Main.html#t:Particle" title="Main">Particle</a></code>s</p></div></div><div class="top"><p class="src"><a id="v:updateVelocities" class="def">updateVelocities</a> :: <a href="Main.html#t:TimeStep" title="Main">TimeStep</a> -> [<a href="Main.html#t:Particle" title="Main">Particle</a>] -> [<a href="Main.html#t:Force" title="Main">Force</a>] -> [<a href="Main.html#t:Particle" title="Main">Particle</a>] <a href="src/Main.html#updateVelocities" class="link">Source</a> <a href="#v:updateVelocities" class="selflink">#</a></p><div class="doc"><p>Apply <code><a href="Main.html#v:updatePosition" title="Main">updatePosition</a></code>/<code><a href="Main.html#v:updateVelocity" title="Main">updateVelocity</a></code> to
<strong>all</strong> (list/set) <code><a href="Main.html#t:Particle" title="Main">Particle</a></code>s</p></div></div><a href="#g:10" id="g:10"><h2>Fourth simulation</h2></a><div class="top"><p class="src"><a id="v:mainVerletSquare" class="def">mainVerletSquare</a> :: IO () <a href="src/Main.html#mainVerletSquare" class="link">Source</a> <a href="#v:mainVerletSquare" class="selflink">#</a></p><div class="doc"><p>Same as <code><a href="Main.html#v:mainVerlet" title="Main">mainVerlet</a></code> but with a square lattice of <span class="mathjax">\(4 \times 4\)</span> <code><a href="Main.html#t:Particle" title="Main">Particle</a></code>s</p></div></div><a href="#g:11" id="g:11"><h3>Additional helper functions</h3></a><div class="top"><p class="src"><a id="v:squareLatticeModel" class="def">squareLatticeModel</a> :: Int -> [<a href="Main.html#t:Particle" title="Main">Particle</a>] <a href="src/Main.html#squareLatticeModel" class="link">Source</a> <a href="#v:squareLatticeModel" class="selflink">#</a></p><div class="doc"><p>Function to construct a <a href="https://en.wikipedia.org/wiki/Square_lattice">square lattice</a>
of dimension <span class="mathjax">\(n \times n\)</span></p></div></div><div class="top"><p class="src"><a id="v:squareLattice" class="def">squareLattice</a> :: Int -> Int -> [<a href="Main.html#t:Position" title="Main">Position</a>] <a href="src/Main.html#squareLattice" class="link">Source</a> <a href="#v:squareLattice" class="selflink">#</a></p><div class="doc"><p>Constructs the <a href="https://en.wikipedia.org/wiki/Square_lattice">square lattice</a>
(<code><a href="Main.html#v:squareLatticeModel" title="Main">squareLatticeModel</a></code>) row by row.
Each row has the same distance from the next row</p></div></div><div class="top"><p class="src"><a id="v:latticeRow" class="def">latticeRow</a> :: Int -> Int -> Float -> [<a href="Main.html#t:Position" title="Main">Position</a>] <a href="src/Main.html#latticeRow" class="link">Source</a> <a href="#v:latticeRow" class="selflink">#</a></p><div class="doc"><p>Constructs a even-distanced row of <code><a href="Main.html#t:Particle" title="Main">Particle</a></code>s</p></div></div><a href="#g:12" id="g:12"><h2>Fourth simulation</h2></a><div class="top"><p class="src"><a id="v:mainVerletRandom" class="def">mainVerletRandom</a> :: IO () <a href="src/Main.html#mainVerletRandom" class="link">Source</a> <a href="#v:mainVerletRandom" class="selflink">#</a></p><div class="doc"><p>Same as <code><a href="Main.html#v:mainVerlet" title="Main">mainVerlet</a></code> but with 16 random generated <code><a href="Main.html#t:Particle" title="Main">Particle</a></code>s</p></div></div><a href="#g:13" id="g:13"><h3>Additional helper functions</h3></a><div class="top"><p class="src"><a id="v:modelRandom" class="def">modelRandom</a> :: RandomGen g => Int -> g -> [<a href="Main.html#t:Particle" title="Main">Particle</a>] <a href="src/Main.html#modelRandom" class="link">Source</a> <a href="#v:modelRandom" class="selflink">#</a></p><div class="doc"><p>Generates <span class="mathjax">\(n\)</span> random <code><a href="Main.html#t:Particle" title="Main">Particle</a></code>s (random <code><a href="Main.html#t:Position" title="Main">Position</a></code> and <code><a href="Main.html#t:Velocity" title="Main">Velocity</a></code>).</p></div></div><div class="top"><p class="src"><a id="v:randomVel" class="def">randomVel</a> :: RandomGen g => Int -> g -> [<a href="Main.html#t:Velocity" title="Main">Velocity</a>] <a href="src/Main.html#randomVel" class="link">Source</a> <a href="#v:randomVel" class="selflink">#</a></p><div class="doc"><p>Generates <span class="mathjax">\(n\)</span> random <code><a href="Main.html#t:Velocity" title="Main">Velocity</a></code> values</p><p><strong>Range</strong>: <span class="mathjax">\(v \in [-0.2,0.2]\)</span></p></div></div><div class="top"><p class="src"><a id="v:randomPos" class="def">randomPos</a> :: RandomGen g => Int -> g -> [<a href="Main.html#t:Position" title="Main">Position</a>] <a href="src/Main.html#randomPos" class="link">Source</a> <a href="#v:randomPos" class="selflink">#</a></p><div class="doc"><p>Generates <span class="mathjax">\(n\)</span> random <code><a href="Main.html#t:Position" title="Main">Position</a></code>s</p></div></div><div class="top"><p class="src"><a id="v:genPos" class="def">genPos</a> :: RandomGen g => g -> (<a href="Main.html#t:Position" title="Main">Position</a>, g) <a href="src/Main.html#genPos" class="link">Source</a> <a href="#v:genPos" class="selflink">#</a></p><div class="doc"><p>Generates <span class="mathjax">\(1\)</span> random <code><a href="Main.html#t:Position" title="Main">Position</a></code></p><p><strong>Range</strong>: All values inside the simulation box (<code><a href="Main.html#v:drawWalls" title="Main">drawWalls</a></code>)</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.23.0</p></div></body></html>