Professional Documents
Culture Documents
Gabriele Keller
Hugh Chaffey-Millar
Manuel M. T. Chakravarty
Don Stewart
Christopher Barner-Kowollik
14000
concentration 12000
-1
/mol L
10000
14000 8000
6000
4000
7000 2000
0
10000
0
7500
5000
800 simulated time
700 / seconds
600 2500
500
400
300
degree 200 0
of 100
0
polymerisation
14000
concentration 12000
-1
/mol L
10000
14000 8000
6000
4000
7000 2000
0
10000
0
7500
5000
800 simulated time
700 / seconds
600 2500
500
400
300
degree 200 0
of 100
0
polymerisation
I copolymer composition
À updateProbabilities ();
Á reactIndex = pickRndReact ();
 mol1Len = pickRndMol (reactToSpecInd1 (reactIndex));
if (consumesTwoMols (reactIndex))
mol2Len = pickRndMol (reactToSpecInd2 (reactIndex));
à switch (reactIndex) // compute reaction products
DO_REACT_BODY // defined in genpolymer.h
incrementMolCnt (resMol1Spec, resMol1Len);
if (resMolCnt == 2)
incrementMolCnt (resMol2Spec, resMol2Len);
advanceSystemTime (); // compute ∆t of this reaction
}
Programming in Haskell
• Popular functional language: fast, all functions, no OO!
• Pure – no side effects by default
• Richly and strongly typed – no runtime type errors
• Easy to parallelise, implicit and explicit cheap threads
• Algebraic data types – good for symbolic manipulation
Portability
• Simulator generation easy to retarget: single core,
multicore, clusters
• Just port the simulator runtime
Markov-chain Monte-Carlo
• Probability distribution function is dynamic
• It is dependent on previous stochastic events
• Fully sequential (no parallelism)
Markov-chain Monte-Carlo
• Probability distribution function is dynamic
• It is dependent on previous stochastic events
• Fully sequential (no parallelism)
50
40
Time (sec)
30
20
10
0
107 2*107 3*107 4*107 5*107
Simulator steps
6 6
Relative Speedup
5 5
4 4
3 3
2 2
1 1
1 2 3 4 5 6 7 8
PE
35000
logarithmic depiction
100000
30000
simulation time / seconds
10000
25000
1000
20000
100
15000
10
10000 (1) (2) (3) (4) (5) (6) (7) (8) (9)
5000
0
(1) (2) (3) (4) (5) (6) (7) (8) (9)
Prototyping
• Simulator development by prototyping in Haskell (→ paper)
Future work
• Other polymer structures (meshes)
• Application to financial mathematics