SlideShare a Scribd company logo
1 of 59
Interactive Simulation and
Knowledge Sharing of Active
Soft-Matter Physics Models
• Endre Somogyi Ph.D, 

Lecturer, Dept. Computer Science, Indiana University

andy.somogyi@gmail.com, somogyie@indiana.edu
http://mechanica.org
@AndySomogyi
• Background
• Modeling and Simulation
• Problem Domain
• Existing Solutions / challenges
• Model Specification / Knowledge Capture / Sharing
• Compiler: transform model specification into
executable model
• Numerical Simulation Environment
Outline
• CU School of Medicine — Center for Human Simulation
• Real-Time haptic enabled surgery simulations
• 300 FPS in 2002
Background
• Software Engineer / Systems Engineer
• Sequoia Software → Citrix Systems
• Rules Engine for Medical Records
• Galileo International → Cendant → Travelport
• Reverse Engineering
• Customizable Workflows
• Distributed Processing Dependencies
Background
Background
Compilation and simulation of biochemical models Speed, Speed, Speed – Just In Time compilation
Linear Scaling
have simple behavior. As the RoadRunner state vector rate is calculated with JIT compil
code, this function could have at most 63 BNE (branch on negative) instructions. The othe
all use interpreters which results in significantly longer run time.
Figure 3: Run time performace relative to system size for the multiple Brusselator
The second set of tests were the models used in the origin SOSLib paper [REF]. The
Table 4 was evaluated by us using the above testing procedure. The lower block is repr
SOSLib web site located at http://www.tbi.univie.ac.at/~raim/odeSolver/doc/benc
This second set of data is strictly here for the sake of completeness and should not be com
the first block, as we have no information on the test procedures or the type of hardware / o
although we suspect that the original SOSLib tests were most likely performed on a MS Wi
Endre Somogyi November 15, 2014
• SBML JIT Compiler
libRoadRunner
• Fastest known chemical
kinetics engine
• Embeddable Library
• Fast / Professional API
• Easy to Integrate
• Virtual Liver
• USC Neuroengineering
• CompuCell3D, etc.
Modeling and Simulation
@tx1 =f1(x1, x1, · · · , xn)
@tx2 =f2(x1, x1, · · · , xn)
...
@txn =fn(x1, x1, · · · , xn)
G = U + pV TS
f = m
dv
dt
20
30
40
xHtL
10
20
30
40
50
yHtL
10
20
30
40
zHtL
Cellular and Tissue Biology
• Physical System - Physics,
Chemistry, Biology
• Highly Dynamic
• Thermally driven by random noise
• Wiggly, Wobbly, Timey, Wimey
• Everything occurs all at once
Problem Domain
• Everything lives in a fluid
environment
• Membrane separates
cells, fluid inside, outside
• Chemical signals diffuse
into and sensed from
environment
• Mechanical connections
with other cells and
environment
• Direct signaling
Cytoplasm
Membrane
Extra-Cellular Medium
Problem Domain
Problem Domain
Physical Forces
Shear Flow
Chemical Signals
Environment Stiffness
Cell Death
Differentiation
Motion
Proliferation
Quiessence
Biological Cell Mechanics
Models of Cell Mechanics
partmentalized by these polygonal faces.
To express the multicellular dynamics within aggregates,
an equation for the motion of the ith vertex is introduced by
η
dri
dt
= −
∂U
∂ri
. (1)
The left-hand side of Eq. (1) indicates a frictional force
exerted on the ith vertex, where η is a friction coefficient
and ri is the position vector of the ith vertex. The right-hand
side of Eq. (1) indicates a conservative force acting on the ith
vertex, where U is potential energy that represents a cell’s
potential energy. In addition, cell rearrangements within an
aggregate are expressed by reconnecting local network pat-
terns (Okuda et al. 2012).
2.2 Proliferative cell behaviors
Proliferative cell behaviors are characterized by cell division
and growth (Fig. 1b, c). In particular, cell division behav-
iorsarecharacterizedbythreequantities:timing,intracellular
is expressed by potential energy that is a function of individual cell times
within their respective cell cycles, U(tc
i ). g Two polyhedrons represent-
ing two daughter cells shortly after a single mother cell has divided.
Cell division (increase in cell number after a cell cycle) is represented
by dividing a polyhedron at a dividing plane where a new polygonal
face is introduced (brown area). h Dividing plane. The dividing plane
of the ith cell is normal to the direction of the vector dcell div
i and passes
through the position of the vector ccell div
i
Ucell
tc
i =
cell
j
ucell
j rk, tc
j δ∗
j , (3)
Ucell–cell
tc
i =
cell
j
cell
k
ucell–cell
jk rl, tc
j , tc
k δ∗
j δ∗
k , (4)
Ucell–ext
tc
i =
cell
j
ucell–ext
j rk, tc
j δ∗
j , (5)
where δ∗
j = δ⌊tc
j /τcell div
j ⌋0. The functions δαβ and ⌊. . .⌋ indi-
cate Kronecker’s delta and floor functions, respectively. In
Eqs. (3), (4), and (5), cell
indicates summations for all
cells. Potential energy ucell
j represents some energy of the
jth cell, such as volume elasticity, surface elasticity, api-
cal constriction, and other effects of intracellular structures
and activities. The potential energy ucell–cell
jk indicates some
energy between the jth and kth cells, such as cell–cell adhe-
sions at intercellular junctions. The potential energy ucell–ext
j
indicates some energy between the jth cell and extracellular
components, such as extracellular matrixes, basement mem-
branes, and solvent liquids. Assuming that a cell’s potential
Modeling cell proliferation 989
g h
di
cell div
ci
cell div
Network
Polyhedron
Vertex
Edge
Polygonal face
Aggregate Cell
a
d
Cell cell boundaries
Cell division
Polyhedron division
Cell growth
Potential energy as a function of
f
b c
e
Dividing plane
&
&
individual cell times,U(ti
)c
Fig. 1 Modeling cell proliferation based on a RNR framework. a
Cell aggregate in which cells are tightly packed and adhere at cell–
cell boundaries. b Single cell embedded within an aggregate. c Two
deforming daughter cells accompanied by cell growth throughout the
cell cycle. d Network representing an aggregate in a RNR model frame-
work. The network comprises vertices and edges (solid lines). Cells are
compartmentalized by polygonal faces (gray area) that represent cell–
cell boundaries. e Single polyhedron representing a single cell. f Two
polyhedrons. Cell growth (increase in cell volume during the cell cycle)
is expressed by potential energy that is a function of individual cell times
within their respective cell cycles, U(tc
i ). g Two polyhedrons represent-
ing two daughter cells shortly after a single mother cell has divided.
Cell division (increase in cell number after a cell cycle) is represented
by dividing a polyhedron at a dividing plane where a new polygonal
face is introduced (brown area). h Dividing plane. The dividing plane
of the ith cell is normal to the direction of the vector dcell div
i and passes
through the position of the vector ccell div
i
First, for topological modeling of the cell division process,
each polyhedron is divided at a single plane, hereafter called
dividing plane (Fig. 1g), and a new polygonal face is intro-
duced on the dividing plane inside the polyhedron. The divid-
ing plane is defined as passing through a position vector,
ccell div
i , and is normal to a direction vector, dcell div
i (Fig. 1h).
Here, the position vector ccell div
i is defined as being inside of
the ith cell volume, and the direction vector dcell div
i is defined
as a unit vector normal to the dividing plane.
Under procedure for dividing a polyhedron, the dividing
plane intersects the polyhedron at several edges (Fig. 1g).
These edges are sequentially linked as a ring-like strand on
the plane and compose a single polygon, which is defined as a
new polygonal face. This polygonal face separates the poly-
hedron into two polyhedrons, which are defined as daughter
cells.
Ucell
tc
i =
cell
j
ucell
j rk, tc
j δ∗
j , (3)
Ucell–cell
tc
i =
cell
j
cell
k
ucell–cell
jk rl, tc
j , tc
k δ∗
j δ∗
k , (4)
Ucell–ext
tc
i =
cell
j
ucell–ext
j rk, tc
j δ∗
j , (5)
where δ∗
j = δ⌊tc
j /τcell div
j ⌋0. The functions δαβ and ⌊. . .⌋ indi-
cate Kronecker’s delta and floor functions, respectively. In
Eqs. (3), (4), and (5), cell
indicates summations for all
cells. Potential energy ucell
j represents some energy of the
jth cell, such as volume elasticity, surface elasticity, api-
Time (t)
Thenumberofcells(nc
)
a
t = 2827
(nc
= 500)
t = 2827
(nc
= 500)
t = 2224
(nc
= 250)
b
t = 0
(nc
= 18)
0
250
500
18
τ
ave=
37.5
c
τ
ave=
75
c
τ
ave=
150
c
τ
ave=
300
c
τ
ave=
600
c
30001500
Local regulation
t = 2224
(nc
= 250)
t = 0
(nc
= 18)
y
z
x
y
z
x
Time (t)
Thenumberofcells(nc
)
0
250
500
18
τ
ave=
37.5
c
τ
ave=
75
c
τ
ave=
150
c
τ
ave=
300
c
τ
ave=
600
c
Global regulation
30001500
Multicellular Mechanical Relations: Satoru Okuda
• SBML works well for CWSC — shareable, but no
geometry or mechanics.
• Molecular Dynamics works well for atomistic —
sharable, but not multi-scale, too small.
• Comsol / SolidWorks works well for continuum, but
no structural rearrangement, too large.
• We add spatial awareness, dynamic structure,
connectivity, and physical conservation laws.
Existing Approaches
• MATLAB hard-coded simulations. Difficult to extract
original meaning. Virtually impossible to run with
different computational back-ends. Difficult to
parallelize
• Example: “Mechanically-coupled Reaction-Diffusion
model of Glioma Growth” Abler, Büchler, Universität
Bern
Current State of the Art
MATLAB, Cellular
Automata
COMSOL,
Finite Element,
Reaction/Diffusion
Files
Files
• Made great strides in data standards: PDB/PSF, microscopy, MultiCellDS,
Mesh
• Dynamics is hard: SBML is one of few ways of exchanging dynamics.
• Spatial models nearly always written in custom code. Usually by grad students
with no training in software engineering.
• Large time cost for custom coding.
• Results in single-use models that are not sharable, nearly always poor
performance (physical domain does not map cleanly to computational domain).
• Low level language ≠ high performance (usually worse in the hands of the
untrained)
• Knowledge is lost when student leaves
• Writability, Shareability, Modularity, Runnability, Interoperability
Problems with existing approaches
Mechanica is NOT
• A theorem proving language (Sorry five-color problem)
• A magic, automatically parallelizing programming language
• A graphical user interface toolkit
• A language for numerical linear algebra (Fortran, MATLAB,
Julia, etc…)
• A language for symbolic computer algebra (Mathematica,
Maxima, etc…)
• A Discrete Event Simulation language or environment
• A General Universal PDE solver
The Mechanica System
Mechanica System
View
Model
AST
ControllerPropagator
n:nucleus , b:body)
dist(n,b) < 6)
(dist(n,b) 5)};
pfrc(a:Particle , b:Particle)
dist(a,b) < 2)
(dist(a,b) 1) };
ody, body);
ody, surface);
dX
dt
= f(X, t) + ⇠(t), x(t0) = X0, X 2 RN
(t) = eiLt
(0)
solvent.A) > (b:solvent.A)
(dist(a,b) < 5) { k ⇤ (a b)};
Red.A) > (b:Red.A)
link pfrc(a:Particle , b:Particle)
if (dist(a,b) < 2)
{ k ⇤ (dist(a,b) 1) };
pfrc(body, body);
pfrc(body, surface);
}
dX
dt
= f(X, t) + ⇠(t), x(t0) = X0, X 2 RN
(t) = eiLt
(0)
proc (a:solvent.A) > (b:solvent.A)
when (dist(a,b) < 5) { k ⇤ (a b)};
proc (a:Red.A) > (b:Red.A)
when (dist(a,b) < 5) { k ⇤ (a b)};
proc (a:solvent.A) > (b:Red.A)
when (dist(a,b) < 5) { k ⇤ (a b)};
Mechanica
Models
(Source Code)
Compiler
persistance
Model Loading (Compiler)
JScript
like syntax
source
Python like
syntax
source
Abstract
Syntax
Tree (AST)
JScript
like parser
JScript like
generator
Python like
parser /
generator
Semantic Analyzer
• Analyzes the mathematical and network
structure of the AST.
• Performs transformations on the AST.
• Transforms rules into systems of
equations and events
• Transforms the declarative, rule-based
input source into a procedural, C-like
output.
Code Generator
• Transforms procedural
data definitions into
machine-specific data
structures and
executable code.
Compiled
Model
External Code Generator
• Generates C/C++ code for
different physics engines
• (PhysiCell / BioFVM)
SBML
SBML
importer /
generator
Data Sources
(MultiCellDS)
Data
importer /
generator
Formalizing Physical Knowledge
• We observe that that everything occurring in the
physical world can naturally be described in terms of
objects and processes
• Objects are the ‘things’, such as molecules, proteins,
membranes, cells, fluids or materials
• Processes are what makes objects change,
processes act on objects and cause changes in state.
• processes can operate concurrently and
continuously, or (very rarely) can operate discretely
in response to an event.
Objects and Processes
• Chemical Reaction or Transport processes act on
chemicals - reactants are consumed and products
are produced
• Membrane Transport (active or passive) processes
acts on chemicals
• Cell Division or Death processes act on cells
• Growth, Adhesion or Motion processes act on cells
• Diffusion processes act on chemicals
• Build Mechanistic models of physical phenomena
• Based on Physics, Chemistry and Biology rather than
traditional machine abstractions or models of
computation (lambda calculus)
• Computational concepts are hard to teach, harder than
physical or chemical concepts
• Von-Neuman architecture is not close to physical reality
• Describe the world in terms of physical objects and
processes
Mechanica Modeling Language
Mechanica Modeling Language
• Start with the basic syntax of TypeScript (strongly typed
JavaScript)
• Familiar to most users, statically typed, easy to parse and extend.
• Simplify, eliminate unnecessary features to ensure a simple AST
which is easy to modify
• Side-effect free. Only the runtime changes state.
• Simple: Facilitate model interchange, designed to be extended,
think of it as Physics Assembler. Language spec is 5 pages. (C++
is ~750)
• Extensible: Homoiconic, incorporates Lisp’s macro system to build
higher level concepts
Particles
• Particles can be simple, complex, large, small, carry field
variables
• Based on tDPD, verified to be the fastest computational
fluid dynamics scheme, O(n)
• Rigorously verified to reproduce Navier-Stokes
Chemical Reactions
ning a functional language is because we would like to
and proven theory, in this case the lambda calculus
A
k1A
! X
X + 2 Y
k2XY 2
! 3 X
B + X
k3BX
! Y + D
X
k4X
! E
) { k1 ⇤ A}
> (3 X) { k2 ⇤ X ⇤ Y ⇤⇤2}
(Y, D) { k3 ⇤ B ⇤ X}
) { k4 ⇤ X}
= S · ⌫
2
6
1 0 0 1 0 0
0 0 0 0 1 2
3
7
2
6
6
6
⌫A
⌫B
⌫D
3
7
7
7
The rationale for designing a functional language is because w
base it on a well known and proven theory, in this case the lamb
A
k1A
! X
X + 2 Y
k2XY 2
! 3 X
B + X
k3BX
! Y + D
X
k4X
! E
proc (A) > (X) { k1 ⇤ A}
proc (X, 2 Y) > (3 X) { k2 ⇤ X ⇤ Y ⇤ ⇤ 2}
proc (B, X) > (Y, D) { k3 ⇤ B ⇤ X}
proc (X) > (E) { k4 ⇤ X}
dX
dt
= S · ⌫
2
6
6
6
6
6
6
4
dA/dt
dB/dt
dD/dt
dE/dt
dX/dt
dY/dt
3
7
7
7
7
7
7
5
=
2
6
6
4
1 0 0 1 0 0
0 0 0 0 1 2
0 1 1 1 1 1
0 0 0 1 1 0
3
7
7
5 ·
2
6
6
6
6
6
6
4
⌫A
⌫B
⌫D
⌫E
⌫X
⌫Y
force (r:Red, b:Blue) { k ⇤ dist(r,b)}
m to point
entally important biological processes. A chemical reaction process in
and produces a set of products, in effect, the process describes the trans-
a set of products. Modeling chemical reactions is one of the most common
processes. Transformation process syntax is similar to the conventional
based on Microsoft Typescript type specification. For example, to add a
atial region, one would simply write a set of transformation processes in
ansformation processes begin with the proc keyword, have an an optional
roducts and the reaction rate expression as in Fig. 1. If the spatial region
2
6
6
6
6
6
6
4
dA/dt
dB/dt
dD/dt
dE/dt
dX/dt
dY/dt
3
7
7
7
7
7
7
5
=
2
6
6
6
6
6
6
4
1 0 0 0
0 0 1 0
0 0 1 0
0 0 0 1
1 1 1 1
0 2 1 0
3
7
7
7
7
7
7
5
·
2
6
6
4
n1
n2
n3
n4
3
7
7
5
Generalized Transformation Process
• Generalize the concept of “chemical reactions” to
enable transformation of discrete things.
• Same syntax as continuous substrates, except when the
inputs are discrete, the process body is interpreted as a
probability
• Enables us to model stochastic reactions and stochastic
cellular automata
pfrc(body, body);
pfrc(body, surface);
}
dX
dt
= f(X, t) + ⇠(t), x(t0) = X0, X 2 RN
(t) = eiLt
(0)
proc (a:solvent.A) > (b:solvent.A)
when (dist(a,b) < 5) { k ⇤ (a b)};
proc (a:Red.A) > (b:Red.A)
when (dist(a,b) < 5) { k ⇤ (a b)};
proc (a:solvent.A) > (b:Red.A)
when (dist(a,b) < 5) { k ⇤ (a b)};
proc my reaction(a:integer , b:integer) >
(c:integer) { exp( k ⇤ (a⇤ b)/T)}
force(a:nucleus , b:surface) {
k ⇤ (
Fields are represented as attributes on particles
• Extremely Simple Syntactically
• Compiler automatically generates internal data
structures
• Completely self-consistent for solids, melts, liquids
• Get body forces, diffusion, transport for free
• No re-meshing, ever!
Inter-Particle Transport
A
A
B
C
A
B
C
A
A
AA
A
A
A
A
A
A
A
A
A
A
A
A
A
A
proc (a:solvent.A) > (b:solvent.A)
when (dist(a,b) < 5) { k ⇤ (a b)};
proc (a:Red.A) (b:Red.A)
Spatial Regions
Somogyi and Glazier
2
6
6
6
6
6
6
4
dA/dt
dB/dt
dD/dt
dE/dt
dX/dt
dY/dt
3
7
7
7
7
7
7
5
=
2
6
6
6
6
6
6
4
1 0 0 0
0 0 1 0
0 0 1 0
0 0 0 1
1 1 1 1
0 2 1 0
3
7
7
7
7
7
7
5
·
2
6
6
4
n1
n2
n3
n4
3
7
7
5
Figure 1: Things
Somogyi and G
type MyCell : SpatialRegion {
surface : Sphere {
radius:5, resolution:1
};
proc (A) -> (X) {k1 * A};
proc (X, 2 Y) -> (3 X) {
k2 * X * Y**2
};
proc (B, X) -> (Y, D) {
k3 * B * X
};
proc (X) -> (E) {k4 * X};
}
2
6
6
6
6
6
6
4
dA/dt
dB/dt
dD/dt
dE/dt
dX/dt
dY/dt
3
7
7
7
7
7
7
5
=
2
6
6
6
6
6
6
4
1
0
0
0
1
0
Dynamic Changes In Morphology
• Forces are one of the fundamental concepts in
physical systems
Polymeric fluid:Polymeric fluid: mesoscopicmesoscopic mm
 exc
 cor
 pre
 finit
Litvinov et al., Phys.Rev. E 77, 66703 (2008)
Forces
• Mass-Spring systems have been in molecular dynamics,
games for years
• Difficult to program and usually static connectivity
Forces
• Same suite of links as MD: bond, angle, dihedral…
• Working on surface links: bending, shear…
6
6
6
4
dE/dt
dX/dt
dY/dt
7
7
7
5
= 6
4 0 1 1 1 1 1
0 0 0 1 1 0
7
5
orce (r:Red, b:Blue) { k ⇤ dist(r
orce (a:Red, b:Red) { k2 ⇤ dist(a
F = ma
dv
dt
=
1
m
F
dx
dt
=
1
v ⇠(t)
dX
dt
= S · ⌫
2
6
6
6
6
6
6
4
dA/dt
dB/dt
dD/dt
dE/dt
dX/dt
dY/dt
3
7
7
7
7
7
7
5
=
2
6
6
4
1 0 0 0 1 0
0 0 0 0 1 2
0 1 1 0 1 1
0 0 0 1 1 0
3
7
7
5 ·
2
6
6
6
6
6
6
4
⌫A
⌫B
⌫D
⌫E
⌫X
⌫Y
3
7
7
7
7
7
7
5
link (r:Red, b:Blue) { k ⇤ dist(r,b)}
link (a:Red, b:Red) { k2 ⇤ dist(a,b)}
F = ma
dv
dt
=
1
m
F
dx
dt
=
1
v ⇠(t)
Forces
• Forces can be defined between individual
instances (one to one), individual instances and
collections (one to many), or collections and
collections (many to many).
• The type specifier determines how forces are
applied.
• Links may have ‘if’, ‘when’, or ‘while’
clauses, these define cut-off, activation and
deactivation conditions. May be asymmetric.
Links: bonded forces
type MyCell : SpatialRegion {
nucleus : Particle { radius:2};
surface : Sphere { radius:2; resolution :1};
body : fill(type:Particle { radius:0.3} , density:20);
link (n:nucleus , b:body)
if (dist(n,b) < 6)
{ k ⇤ (dist(n,b) 5)};
link pfrc(a:Particle , b:Particle)
if (dist(a,b) < 2)
{ k ⇤ (dist(a,b) 1) };
pfrc(body, body);
pfrc(body, surface);
}
dX
= f(X, t) + ⇠(t), x(t0) = X0, X 2 RN
Connecting Physics and Chemistry
• link body definitions can contain arbitrary, user specified
functional forms.
• link (and reaction rate) bodies can reference local
chemical concentrations at the location of the link instance
Rh
RhRh
Rh
Rh
Rh
Rh
Rh
Rh
dt
= S · ⌫
2
6
6
6
6
6
6
4
dA/dt
dB/dt
dD/dt
dE/dt
dX/dt
dY/dt
3
7
7
7
7
7
7
5
=
2
6
6
4
1 0 0 0 1 0
0 0 0 0 1 2
0 1 1 0 1 1
0 0 0 1 1 0
3
7
7
5 ·
2
6
6
6
6
6
6
4
⌫A
⌫B
⌫D
⌫E
⌫X
⌫Y
3
7
7
7
7
7
7
5
link (r:Red, b:Blue) { k ⇤ dist(r,b)}
link (a:Red, b:Red) { k2 ⇤ dist(a,b)}
link(a:mycell.nucleus , b:mycell.surface) {
k ⇤ (dist(a,b) restLength + k2 ⇤ Rho);
}
F = ma
dv
dt
=
1
m
F
dx
dt
=
1
v ⇠(t) Spatial Scoping
Cell Motion with Forces
• Combine Previous Ideas
• Spatial Scoping
force pfrc(a:Point, b:Point)
if (dist(a,b) < 2)
{ k ⇤ (dist(a,b) 1) };
pfrc(body, body);
pfrc(body, surface);
}
dX
dt
= f(X, t) + ⇠(t), x(t0) = X0, X 2 R
force(a:nucleus , b:surface) {
k ⇤ (
dist(a,b)
(restLength + b.ChemicalSignal)
)
}
Time Propagation
ous state vector C(t). Each process definition body can access the present
icle attributes, and constant parameters to calculate the process transforma-
processes defines a system of ordinary differential equations (ODEs) in the
d
dt
C =

˙Cf
˙Cr
=

N·n(C,r,v,p)
f(C,r,v,p)
. (1)
partitions: Cf is the vector of independent continuous variables (which par-
ocesses, i.e., a reaction network), and Cr is a vector of variables which are
vector p consists of time independent parameters. The reaction network of
ansformation processes defines the m⇥n stoichiometry matrix N. Each stoi-
et number of continuous variables i produced or consumed in transformation
ation process definitions combine to form the transformation rate function n.
tor, Cr, is a set of variables which form a system of conventional ODEs, i.e.
defined by a rate process. Only the Mechanica runtime can directly change
is the sum of the linked, FL, conservative, FC, random, FR, dissipative, FD,
nked force is the sum of the linked relationships between the particles. The
raction which ensures volume exclusion and keeps materials from interpene-
presents the effects of viscosity, and the random force represents the effects
rces. The linked force is the sum of the linked relationships between the pa
s a soft interaction which ensures volume exclusion and keeps materials from
ive force represents the effects of viscosity, and the random force represent
ons. Integration time steps can be large because these inter-particle forces
eractions. More details on the conservative, random and dissipative forces c
The time evolution of particle positions, r and velocities, v is defined as
d2ri
dt2
=
dvi
dt
=
1
mi
Fi =
1
mi
Â
i6=j
FL
ij +FC
ij +FD
ij +FR
ij +Fext
i
!
.
tes the time evolution of the model via time slicing – time is partitioned int
Each time step has three phases: (A) evaluate and apply the when and whil
esses determine if they should be triggered, and apply them. Links are a
1 according to their when and while predicates. (B) integrate the cont
ording to eqn. 1 and (C) integrate the particle positions according to eqn. 2.
Implemented in mdcore, Mechanica’s stand-alone
particle dynamics engine. Combined with CVODE.
Neighbors
Update when particle
displacement (rskin - rcut)/2
• Force calculations are very expensive
• Without Optimization, would be O(N2)
• Cell List• Verlet List
Most efficient is to use
both
© Copyright Khronos Group, 2010 - Page 13
Parallelism
• For each simulation iteration:
-  Compute forces in each link based on its length
-  Correct positions of masses/vertices from forces
-  Compute new vertex positions
Original layout
Current layout:
Compute forces as
Stretch from rest length
Compute new
positions
Apply position
corrections
to masses
Position Based DynamicsBender, Müller, Otaduy and Teschner / Position-based Methods for the Simulation of S
Algorithm 1 Position-based dynamics
1: for all vertices i do
2: initialize xi = x0
i , vi = v0
i , wi = 1/mi,
3: end for
4: loop
5: for all vertices i do vi vi +Dtwifext(xi)
6: for all vertices i do pi xi +Dtvi
7: for all vertices i do genCollConstraints(xi ! pi)
8: loop solverIteration times
9: projectConstraints(C1,...,CM+MColl ,p1,...,pN)
10: end loop
11: for all vertices i do
12: vi (pi xi)/Dt
13: xi pi
14: end for
15: velocityUpdate(v1,...,vN)
16: end loop
fined for. We can now write th
C1(p)
...
CM(p)
where the symbol denot
Raphson iteration is a metho
ric systems with equalities o
first guess of a solution. Each
earized in the neighborhood o
C(p+Dp) = C(p)+rpC
This yields a linear system fo
Dp
rpC1(p)·Dp
...
Parallelism
• For each simulation iteration:
-  Compute forces in each link based on
-  Correct positions of masses/vertices fr
-  Compute new vertex positions
Original layout
Current layout:
Compute forces as
Stretch from rest length
Parallelism
• For each simulation iteration:
-  Compute forces in each link based on its
-  Correct positions of masses/vertices from
-  Compute new vertex positions
Original layout
Current layout:
Compute forces as
Stretch from rest length
© Copyright Khronos Group, 2010 - Page 9
Parallelism
• Large number of particles
- Appropriate for parallel processing
- Force from each spring constraint applied
to both connected particles
Original layout
Current layout:
Compute forces as
Stretch from rest length
Compute new
positions
Apply position
corrections
to masses
Constraints
Example: Distance
constraint• Distance Constraint
• First project the particles, then satisfy constraints
Constraints
• Gauss Seidel Method
• Fast to converge, but serial
Example: Distance
constraint
Approximate solution to a system of constraints using Gauss-
Seidel method
Rest position
Constraints
• Gauss Seidel Method
• Fast to converge, but serial
Example: Distance
constraint
Approximate solution to a system of constraints using Gauss-
Seidel method
The particles are displaced by external forces
Constraints
• Gauss Seidel Method
• Fast to converge, but serial
Example: Distance
constraint
Approximate solution to a system of constraints using Gauss-
Seidel method
The constraints are solved sequentially
Constraints
• Gauss Seidel Method
• Fast to converge, but serial
Example: Distance
constraint
Approximate solution to a system of constraints using
Gauss-Seidel method
The constraints are solved sequentially
Constraints
• Gauss Seidel Method
• Fast to converge, but serial
Example: Distance
constraint
Approximate solution to a system of constraints using
Gauss-Seidel method
The constraints are solved sequentially
Constraints
• Gauss Seidel Method
• Fast to converge, but serial
Example: Distance
constraint
Approximate solution to a system of constraints using
Gauss-Seidel method
The constraints are solved sequentially
Constraints
• Gauss Seidel Method
• Fast to converge, but serial
Example: Distance
constraint
Approximate solution to a system of constraints using
Gauss-Seidel method
The constraints are solved sequentially
Constraints
• Gauss Seidel Method
• Fast to converge, but serial
Example: Distance
constraint
Approximate solution to a system of constraints using
Gauss-Seidel method
Iteration 1
Constraints
• Jacobi Method easier to parallelize, but converges
slower
Example: Distance
constraint
Approximate solution to a system of constraints using
Jacobi method
The constraints are solved in parallel
Constraints
• Jacobi Iteration 1
Example: Distance
constraint
Approximate solution to a system of constraints using
Jacobi method
Iteration 1
Constraints
• Jacobi Iteration 2
Example: Distance
constraint
Approximate solution to a system of constraints using
Jacobi method
Iteration 2
Constraints
• Jacobi Iteration 3
Example: Distance
constraint
Approximate solution to a system of constraints using
Jacobi method
Iteration 3
Constraints
• Jacobi Iteration 4
Example: Distance
constraint
Approximate solution to a system of constraints using
Jacobi method
Iteration 4
Demo
With apologies to Jack Bauer …
Cellular Automata
• Seamlessly integrate particle
systems and cellular automata
• Use Mechanica’s Python
binding to integrate with
existing CC3D scripts
• Automatically update AABB
tree as CA voxels change
• As CA boundary changes,
automatically updates
constraints on particles
• Momentum Conserving
Application Interoperability
• Core design goal
• Interoperability with existing
applications
• Same binary object layout as Python
— auto-boxing
• zero-overhead Python binding
• Python script can import a
Mechanica model just like any other
Python module
• Integrate into CompuCell3D models
with zero CompuCell3D changes
• C API — cross language compatible
Collaborations
• Priyom Adhyapok (IU): CompuCell3D integration,
somite formation.
• Mike Hosek (IU): erythrocyte cortical dynamics
• Jean-Marie Bouteiller (USC): Synaptic junction
reaction-transport
• Amit Hagar (IU): Liver carcinogenesis and toxicology
risk assessment, CompuCell3D integration, reaction/
transport of carcinogen in a liver sinusoid
Outlook
• Find tenure-track job (or funded post-doc), continue
to develop and apply Mechanica.
• Secure Funding (NIH, NSF, …)
• Applications / Collaborators (Experimental
Biologists)
• Different backends (GPU, MPI, …)
• Multi-scale factorization — combine micro and
mesoscale time evolution
• Visual Model Editing
Acknowledgements and Disclosure
• A number of concepts presented here are patent
pending.
• All code will be freely licensed under Common
Development and Distribution License (CDDL)
• We acknowledge generous financial support the
National Institutes of Health, National Institute of
General Medical Sciences, grants R01 GM076692
and R01 GM077138.
Conclusions
• Modeling description language that naturally
expresses physical constructs and captures
biological knowledge.
• Built on physical, chemical and biological
constructs.
• Enables biologists to model systems using natural
concepts.
• somogyie@indiana.edu
• http://mechanica.org

More Related Content

Similar to Mechanica

Μοντέλα διάχυσης καρκινικών όγκων εγκεφάλου
Μοντέλα διάχυσης καρκινικών όγκων εγκεφάλουΜοντέλα διάχυσης καρκινικών όγκων εγκεφάλου
Μοντέλα διάχυσης καρκινικών όγκων εγκεφάλου
Manolis Vavalis
 

Similar to Mechanica (20)

Chemical dynamics and rare events in soft matter physics
Chemical dynamics and rare events in soft matter physicsChemical dynamics and rare events in soft matter physics
Chemical dynamics and rare events in soft matter physics
 
Single fault detection and diagnosis technique for digital micro fluidic base...
Single fault detection and diagnosis technique for digital micro fluidic base...Single fault detection and diagnosis technique for digital micro fluidic base...
Single fault detection and diagnosis technique for digital micro fluidic base...
 
SINGLE FAULT DETECTION AND DIAGNOSIS TECHNIQUE FOR DIGITAL MICRO-FLUIDIC BASE...
SINGLE FAULT DETECTION AND DIAGNOSIS TECHNIQUE FOR DIGITAL MICRO-FLUIDIC BASE...SINGLE FAULT DETECTION AND DIAGNOSIS TECHNIQUE FOR DIGITAL MICRO-FLUIDIC BASE...
SINGLE FAULT DETECTION AND DIAGNOSIS TECHNIQUE FOR DIGITAL MICRO-FLUIDIC BASE...
 
SINGLE FAULT DETECTION AND DIAGNOSIS TECHNIQUE FOR DIGITAL MICRO-FLUIDIC BASE...
SINGLE FAULT DETECTION AND DIAGNOSIS TECHNIQUE FOR DIGITAL MICRO-FLUIDIC BASE...SINGLE FAULT DETECTION AND DIAGNOSIS TECHNIQUE FOR DIGITAL MICRO-FLUIDIC BASE...
SINGLE FAULT DETECTION AND DIAGNOSIS TECHNIQUE FOR DIGITAL MICRO-FLUIDIC BASE...
 
Semi-Classical Transport Theory.ppt
Semi-Classical Transport Theory.pptSemi-Classical Transport Theory.ppt
Semi-Classical Transport Theory.ppt
 
call for papers, research paper publishing, where to publish research paper, ...
call for papers, research paper publishing, where to publish research paper, ...call for papers, research paper publishing, where to publish research paper, ...
call for papers, research paper publishing, where to publish research paper, ...
 
Clustering tutorial
Clustering tutorialClustering tutorial
Clustering tutorial
 
JAISTサマースクール2016「脳を知るための理論」講義01 Single neuron models
JAISTサマースクール2016「脳を知るための理論」講義01 Single neuron modelsJAISTサマースクール2016「脳を知るための理論」講義01 Single neuron models
JAISTサマースクール2016「脳を知るための理論」講義01 Single neuron models
 
ANALYSIS OF ELEMENTARY CELLULAR AUTOMATA BOUNDARY CONDITIONS
ANALYSIS OF ELEMENTARY CELLULAR AUTOMATA BOUNDARY CONDITIONSANALYSIS OF ELEMENTARY CELLULAR AUTOMATA BOUNDARY CONDITIONS
ANALYSIS OF ELEMENTARY CELLULAR AUTOMATA BOUNDARY CONDITIONS
 
Heterogeneous relaxation dynamics in amorphous materials under cyclic loading
Heterogeneous relaxation dynamics in amorphous materials under cyclic loadingHeterogeneous relaxation dynamics in amorphous materials under cyclic loading
Heterogeneous relaxation dynamics in amorphous materials under cyclic loading
 
TOMOGRAPHY OF HUMAN BODY USING EXACT SIMULTANEOUS ITERATIVE RECONSTRUCTION AL...
TOMOGRAPHY OF HUMAN BODY USING EXACT SIMULTANEOUS ITERATIVE RECONSTRUCTION AL...TOMOGRAPHY OF HUMAN BODY USING EXACT SIMULTANEOUS ITERATIVE RECONSTRUCTION AL...
TOMOGRAPHY OF HUMAN BODY USING EXACT SIMULTANEOUS ITERATIVE RECONSTRUCTION AL...
 
My Prize Winning Physics Poster from 2006
My Prize Winning Physics Poster from 2006My Prize Winning Physics Poster from 2006
My Prize Winning Physics Poster from 2006
 
Μοντέλα διάχυσης καρκινικών όγκων εγκεφάλου
Μοντέλα διάχυσης καρκινικών όγκων εγκεφάλουΜοντέλα διάχυσης καρκινικών όγκων εγκεφάλου
Μοντέλα διάχυσης καρκινικών όγκων εγκεφάλου
 
SPAA11
SPAA11SPAA11
SPAA11
 
BP219 class 4 04 2011
BP219 class 4 04 2011BP219 class 4 04 2011
BP219 class 4 04 2011
 
Fir 05 dynamics
Fir 05 dynamicsFir 05 dynamics
Fir 05 dynamics
 
A03401001005
A03401001005A03401001005
A03401001005
 
EM Term Paper
EM Term PaperEM Term Paper
EM Term Paper
 
MD_course.ppt
MD_course.pptMD_course.ppt
MD_course.ppt
 
bmi SP.ppt
bmi SP.pptbmi SP.ppt
bmi SP.ppt
 

Recently uploaded

The Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptxThe Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptx
seri bangash
 
development of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virusdevelopment of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virus
NazaninKarimi6
 
Lipids: types, structure and important functions.
Lipids: types, structure and important functions.Lipids: types, structure and important functions.
Lipids: types, structure and important functions.
Cherry
 
Major groups of bacteria: Spirochetes, Chlamydia, Rickettsia, nanobes, mycopl...
Major groups of bacteria: Spirochetes, Chlamydia, Rickettsia, nanobes, mycopl...Major groups of bacteria: Spirochetes, Chlamydia, Rickettsia, nanobes, mycopl...
Major groups of bacteria: Spirochetes, Chlamydia, Rickettsia, nanobes, mycopl...
Cherry
 
Reboulia: features, anatomy, morphology etc.
Reboulia: features, anatomy, morphology etc.Reboulia: features, anatomy, morphology etc.
Reboulia: features, anatomy, morphology etc.
Cherry
 
ONLINE VOTING SYSTEM SE Project for vote
ONLINE VOTING SYSTEM SE Project for voteONLINE VOTING SYSTEM SE Project for vote
ONLINE VOTING SYSTEM SE Project for vote
RaunakRastogi4
 
LUNULARIA -features, morphology, anatomy ,reproduction etc.
LUNULARIA -features, morphology, anatomy ,reproduction etc.LUNULARIA -features, morphology, anatomy ,reproduction etc.
LUNULARIA -features, morphology, anatomy ,reproduction etc.
Cherry
 

Recently uploaded (20)

Human & Veterinary Respiratory Physilogy_DR.E.Muralinath_Associate Professor....
Human & Veterinary Respiratory Physilogy_DR.E.Muralinath_Associate Professor....Human & Veterinary Respiratory Physilogy_DR.E.Muralinath_Associate Professor....
Human & Veterinary Respiratory Physilogy_DR.E.Muralinath_Associate Professor....
 
Terpineol and it's characterization pptx
Terpineol and it's characterization pptxTerpineol and it's characterization pptx
Terpineol and it's characterization pptx
 
The Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptxThe Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptx
 
Role of AI in seed science Predictive modelling and Beyond.pptx
Role of AI in seed science  Predictive modelling and  Beyond.pptxRole of AI in seed science  Predictive modelling and  Beyond.pptx
Role of AI in seed science Predictive modelling and Beyond.pptx
 
development of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virusdevelopment of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virus
 
Lipids: types, structure and important functions.
Lipids: types, structure and important functions.Lipids: types, structure and important functions.
Lipids: types, structure and important functions.
 
Major groups of bacteria: Spirochetes, Chlamydia, Rickettsia, nanobes, mycopl...
Major groups of bacteria: Spirochetes, Chlamydia, Rickettsia, nanobes, mycopl...Major groups of bacteria: Spirochetes, Chlamydia, Rickettsia, nanobes, mycopl...
Major groups of bacteria: Spirochetes, Chlamydia, Rickettsia, nanobes, mycopl...
 
Reboulia: features, anatomy, morphology etc.
Reboulia: features, anatomy, morphology etc.Reboulia: features, anatomy, morphology etc.
Reboulia: features, anatomy, morphology etc.
 
GBSN - Microbiology (Unit 4) Concept of Asepsis
GBSN - Microbiology (Unit 4) Concept of AsepsisGBSN - Microbiology (Unit 4) Concept of Asepsis
GBSN - Microbiology (Unit 4) Concept of Asepsis
 
Daily Lesson Log in Science 9 Fourth Quarter Physics
Daily Lesson Log in Science 9 Fourth Quarter PhysicsDaily Lesson Log in Science 9 Fourth Quarter Physics
Daily Lesson Log in Science 9 Fourth Quarter Physics
 
X-rays from a Central “Exhaust Vent” of the Galactic Center Chimney
X-rays from a Central “Exhaust Vent” of the Galactic Center ChimneyX-rays from a Central “Exhaust Vent” of the Galactic Center Chimney
X-rays from a Central “Exhaust Vent” of the Galactic Center Chimney
 
Dr. E. Muralinath_ Blood indices_clinical aspects
Dr. E. Muralinath_ Blood indices_clinical  aspectsDr. E. Muralinath_ Blood indices_clinical  aspects
Dr. E. Muralinath_ Blood indices_clinical aspects
 
Molecular phylogeny, molecular clock hypothesis, molecular evolution, kimuras...
Molecular phylogeny, molecular clock hypothesis, molecular evolution, kimuras...Molecular phylogeny, molecular clock hypothesis, molecular evolution, kimuras...
Molecular phylogeny, molecular clock hypothesis, molecular evolution, kimuras...
 
Site specific recombination and transposition.........pdf
Site specific recombination and transposition.........pdfSite specific recombination and transposition.........pdf
Site specific recombination and transposition.........pdf
 
Adaptive Restore algorithm & importance Monte Carlo
Adaptive Restore algorithm & importance Monte CarloAdaptive Restore algorithm & importance Monte Carlo
Adaptive Restore algorithm & importance Monte Carlo
 
Cyanide resistant respiration pathway.pptx
Cyanide resistant respiration pathway.pptxCyanide resistant respiration pathway.pptx
Cyanide resistant respiration pathway.pptx
 
FS P2 COMBO MSTA LAST PUSH past exam papers.
FS P2 COMBO MSTA LAST PUSH past exam papers.FS P2 COMBO MSTA LAST PUSH past exam papers.
FS P2 COMBO MSTA LAST PUSH past exam papers.
 
Method of Quantifying interactions and its types
Method of Quantifying interactions and its typesMethod of Quantifying interactions and its types
Method of Quantifying interactions and its types
 
ONLINE VOTING SYSTEM SE Project for vote
ONLINE VOTING SYSTEM SE Project for voteONLINE VOTING SYSTEM SE Project for vote
ONLINE VOTING SYSTEM SE Project for vote
 
LUNULARIA -features, morphology, anatomy ,reproduction etc.
LUNULARIA -features, morphology, anatomy ,reproduction etc.LUNULARIA -features, morphology, anatomy ,reproduction etc.
LUNULARIA -features, morphology, anatomy ,reproduction etc.
 

Mechanica

  • 1. Interactive Simulation and Knowledge Sharing of Active Soft-Matter Physics Models • Endre Somogyi Ph.D, 
 Lecturer, Dept. Computer Science, Indiana University
 andy.somogyi@gmail.com, somogyie@indiana.edu http://mechanica.org @AndySomogyi
  • 2. • Background • Modeling and Simulation • Problem Domain • Existing Solutions / challenges • Model Specification / Knowledge Capture / Sharing • Compiler: transform model specification into executable model • Numerical Simulation Environment Outline
  • 3. • CU School of Medicine — Center for Human Simulation • Real-Time haptic enabled surgery simulations • 300 FPS in 2002 Background
  • 4. • Software Engineer / Systems Engineer • Sequoia Software → Citrix Systems • Rules Engine for Medical Records • Galileo International → Cendant → Travelport • Reverse Engineering • Customizable Workflows • Distributed Processing Dependencies Background
  • 5. Background Compilation and simulation of biochemical models Speed, Speed, Speed – Just In Time compilation Linear Scaling have simple behavior. As the RoadRunner state vector rate is calculated with JIT compil code, this function could have at most 63 BNE (branch on negative) instructions. The othe all use interpreters which results in significantly longer run time. Figure 3: Run time performace relative to system size for the multiple Brusselator The second set of tests were the models used in the origin SOSLib paper [REF]. The Table 4 was evaluated by us using the above testing procedure. The lower block is repr SOSLib web site located at http://www.tbi.univie.ac.at/~raim/odeSolver/doc/benc This second set of data is strictly here for the sake of completeness and should not be com the first block, as we have no information on the test procedures or the type of hardware / o although we suspect that the original SOSLib tests were most likely performed on a MS Wi Endre Somogyi November 15, 2014 • SBML JIT Compiler libRoadRunner • Fastest known chemical kinetics engine • Embeddable Library • Fast / Professional API • Easy to Integrate • Virtual Liver • USC Neuroengineering • CompuCell3D, etc.
  • 6. Modeling and Simulation @tx1 =f1(x1, x1, · · · , xn) @tx2 =f2(x1, x1, · · · , xn) ... @txn =fn(x1, x1, · · · , xn) G = U + pV TS f = m dv dt 20 30 40 xHtL 10 20 30 40 50 yHtL 10 20 30 40 zHtL
  • 7. Cellular and Tissue Biology • Physical System - Physics, Chemistry, Biology • Highly Dynamic • Thermally driven by random noise • Wiggly, Wobbly, Timey, Wimey • Everything occurs all at once Problem Domain
  • 8. • Everything lives in a fluid environment • Membrane separates cells, fluid inside, outside • Chemical signals diffuse into and sensed from environment • Mechanical connections with other cells and environment • Direct signaling Cytoplasm Membrane Extra-Cellular Medium Problem Domain
  • 9. Problem Domain Physical Forces Shear Flow Chemical Signals Environment Stiffness Cell Death Differentiation Motion Proliferation Quiessence
  • 11. Models of Cell Mechanics
  • 12. partmentalized by these polygonal faces. To express the multicellular dynamics within aggregates, an equation for the motion of the ith vertex is introduced by η dri dt = − ∂U ∂ri . (1) The left-hand side of Eq. (1) indicates a frictional force exerted on the ith vertex, where η is a friction coefficient and ri is the position vector of the ith vertex. The right-hand side of Eq. (1) indicates a conservative force acting on the ith vertex, where U is potential energy that represents a cell’s potential energy. In addition, cell rearrangements within an aggregate are expressed by reconnecting local network pat- terns (Okuda et al. 2012). 2.2 Proliferative cell behaviors Proliferative cell behaviors are characterized by cell division and growth (Fig. 1b, c). In particular, cell division behav- iorsarecharacterizedbythreequantities:timing,intracellular is expressed by potential energy that is a function of individual cell times within their respective cell cycles, U(tc i ). g Two polyhedrons represent- ing two daughter cells shortly after a single mother cell has divided. Cell division (increase in cell number after a cell cycle) is represented by dividing a polyhedron at a dividing plane where a new polygonal face is introduced (brown area). h Dividing plane. The dividing plane of the ith cell is normal to the direction of the vector dcell div i and passes through the position of the vector ccell div i Ucell tc i = cell j ucell j rk, tc j δ∗ j , (3) Ucell–cell tc i = cell j cell k ucell–cell jk rl, tc j , tc k δ∗ j δ∗ k , (4) Ucell–ext tc i = cell j ucell–ext j rk, tc j δ∗ j , (5) where δ∗ j = δ⌊tc j /τcell div j ⌋0. The functions δαβ and ⌊. . .⌋ indi- cate Kronecker’s delta and floor functions, respectively. In Eqs. (3), (4), and (5), cell indicates summations for all cells. Potential energy ucell j represents some energy of the jth cell, such as volume elasticity, surface elasticity, api- cal constriction, and other effects of intracellular structures and activities. The potential energy ucell–cell jk indicates some energy between the jth and kth cells, such as cell–cell adhe- sions at intercellular junctions. The potential energy ucell–ext j indicates some energy between the jth cell and extracellular components, such as extracellular matrixes, basement mem- branes, and solvent liquids. Assuming that a cell’s potential Modeling cell proliferation 989 g h di cell div ci cell div Network Polyhedron Vertex Edge Polygonal face Aggregate Cell a d Cell cell boundaries Cell division Polyhedron division Cell growth Potential energy as a function of f b c e Dividing plane & & individual cell times,U(ti )c Fig. 1 Modeling cell proliferation based on a RNR framework. a Cell aggregate in which cells are tightly packed and adhere at cell– cell boundaries. b Single cell embedded within an aggregate. c Two deforming daughter cells accompanied by cell growth throughout the cell cycle. d Network representing an aggregate in a RNR model frame- work. The network comprises vertices and edges (solid lines). Cells are compartmentalized by polygonal faces (gray area) that represent cell– cell boundaries. e Single polyhedron representing a single cell. f Two polyhedrons. Cell growth (increase in cell volume during the cell cycle) is expressed by potential energy that is a function of individual cell times within their respective cell cycles, U(tc i ). g Two polyhedrons represent- ing two daughter cells shortly after a single mother cell has divided. Cell division (increase in cell number after a cell cycle) is represented by dividing a polyhedron at a dividing plane where a new polygonal face is introduced (brown area). h Dividing plane. The dividing plane of the ith cell is normal to the direction of the vector dcell div i and passes through the position of the vector ccell div i First, for topological modeling of the cell division process, each polyhedron is divided at a single plane, hereafter called dividing plane (Fig. 1g), and a new polygonal face is intro- duced on the dividing plane inside the polyhedron. The divid- ing plane is defined as passing through a position vector, ccell div i , and is normal to a direction vector, dcell div i (Fig. 1h). Here, the position vector ccell div i is defined as being inside of the ith cell volume, and the direction vector dcell div i is defined as a unit vector normal to the dividing plane. Under procedure for dividing a polyhedron, the dividing plane intersects the polyhedron at several edges (Fig. 1g). These edges are sequentially linked as a ring-like strand on the plane and compose a single polygon, which is defined as a new polygonal face. This polygonal face separates the poly- hedron into two polyhedrons, which are defined as daughter cells. Ucell tc i = cell j ucell j rk, tc j δ∗ j , (3) Ucell–cell tc i = cell j cell k ucell–cell jk rl, tc j , tc k δ∗ j δ∗ k , (4) Ucell–ext tc i = cell j ucell–ext j rk, tc j δ∗ j , (5) where δ∗ j = δ⌊tc j /τcell div j ⌋0. The functions δαβ and ⌊. . .⌋ indi- cate Kronecker’s delta and floor functions, respectively. In Eqs. (3), (4), and (5), cell indicates summations for all cells. Potential energy ucell j represents some energy of the jth cell, such as volume elasticity, surface elasticity, api- Time (t) Thenumberofcells(nc ) a t = 2827 (nc = 500) t = 2827 (nc = 500) t = 2224 (nc = 250) b t = 0 (nc = 18) 0 250 500 18 τ ave= 37.5 c τ ave= 75 c τ ave= 150 c τ ave= 300 c τ ave= 600 c 30001500 Local regulation t = 2224 (nc = 250) t = 0 (nc = 18) y z x y z x Time (t) Thenumberofcells(nc ) 0 250 500 18 τ ave= 37.5 c τ ave= 75 c τ ave= 150 c τ ave= 300 c τ ave= 600 c Global regulation 30001500 Multicellular Mechanical Relations: Satoru Okuda
  • 13. • SBML works well for CWSC — shareable, but no geometry or mechanics. • Molecular Dynamics works well for atomistic — sharable, but not multi-scale, too small. • Comsol / SolidWorks works well for continuum, but no structural rearrangement, too large. • We add spatial awareness, dynamic structure, connectivity, and physical conservation laws. Existing Approaches
  • 14. • MATLAB hard-coded simulations. Difficult to extract original meaning. Virtually impossible to run with different computational back-ends. Difficult to parallelize • Example: “Mechanically-coupled Reaction-Diffusion model of Glioma Growth” Abler, Büchler, Universität Bern Current State of the Art MATLAB, Cellular Automata COMSOL, Finite Element, Reaction/Diffusion Files Files
  • 15. • Made great strides in data standards: PDB/PSF, microscopy, MultiCellDS, Mesh • Dynamics is hard: SBML is one of few ways of exchanging dynamics. • Spatial models nearly always written in custom code. Usually by grad students with no training in software engineering. • Large time cost for custom coding. • Results in single-use models that are not sharable, nearly always poor performance (physical domain does not map cleanly to computational domain). • Low level language ≠ high performance (usually worse in the hands of the untrained) • Knowledge is lost when student leaves • Writability, Shareability, Modularity, Runnability, Interoperability Problems with existing approaches
  • 16. Mechanica is NOT • A theorem proving language (Sorry five-color problem) • A magic, automatically parallelizing programming language • A graphical user interface toolkit • A language for numerical linear algebra (Fortran, MATLAB, Julia, etc…) • A language for symbolic computer algebra (Mathematica, Maxima, etc…) • A Discrete Event Simulation language or environment • A General Universal PDE solver
  • 17. The Mechanica System Mechanica System View Model AST ControllerPropagator n:nucleus , b:body) dist(n,b) < 6) (dist(n,b) 5)}; pfrc(a:Particle , b:Particle) dist(a,b) < 2) (dist(a,b) 1) }; ody, body); ody, surface); dX dt = f(X, t) + ⇠(t), x(t0) = X0, X 2 RN (t) = eiLt (0) solvent.A) > (b:solvent.A) (dist(a,b) < 5) { k ⇤ (a b)}; Red.A) > (b:Red.A) link pfrc(a:Particle , b:Particle) if (dist(a,b) < 2) { k ⇤ (dist(a,b) 1) }; pfrc(body, body); pfrc(body, surface); } dX dt = f(X, t) + ⇠(t), x(t0) = X0, X 2 RN (t) = eiLt (0) proc (a:solvent.A) > (b:solvent.A) when (dist(a,b) < 5) { k ⇤ (a b)}; proc (a:Red.A) > (b:Red.A) when (dist(a,b) < 5) { k ⇤ (a b)}; proc (a:solvent.A) > (b:Red.A) when (dist(a,b) < 5) { k ⇤ (a b)}; Mechanica Models (Source Code) Compiler persistance
  • 18. Model Loading (Compiler) JScript like syntax source Python like syntax source Abstract Syntax Tree (AST) JScript like parser JScript like generator Python like parser / generator Semantic Analyzer • Analyzes the mathematical and network structure of the AST. • Performs transformations on the AST. • Transforms rules into systems of equations and events • Transforms the declarative, rule-based input source into a procedural, C-like output. Code Generator • Transforms procedural data definitions into machine-specific data structures and executable code. Compiled Model External Code Generator • Generates C/C++ code for different physics engines • (PhysiCell / BioFVM) SBML SBML importer / generator Data Sources (MultiCellDS) Data importer / generator
  • 19. Formalizing Physical Knowledge • We observe that that everything occurring in the physical world can naturally be described in terms of objects and processes • Objects are the ‘things’, such as molecules, proteins, membranes, cells, fluids or materials • Processes are what makes objects change, processes act on objects and cause changes in state. • processes can operate concurrently and continuously, or (very rarely) can operate discretely in response to an event.
  • 20. Objects and Processes • Chemical Reaction or Transport processes act on chemicals - reactants are consumed and products are produced • Membrane Transport (active or passive) processes acts on chemicals • Cell Division or Death processes act on cells • Growth, Adhesion or Motion processes act on cells • Diffusion processes act on chemicals
  • 21. • Build Mechanistic models of physical phenomena • Based on Physics, Chemistry and Biology rather than traditional machine abstractions or models of computation (lambda calculus) • Computational concepts are hard to teach, harder than physical or chemical concepts • Von-Neuman architecture is not close to physical reality • Describe the world in terms of physical objects and processes Mechanica Modeling Language
  • 22. Mechanica Modeling Language • Start with the basic syntax of TypeScript (strongly typed JavaScript) • Familiar to most users, statically typed, easy to parse and extend. • Simplify, eliminate unnecessary features to ensure a simple AST which is easy to modify • Side-effect free. Only the runtime changes state. • Simple: Facilitate model interchange, designed to be extended, think of it as Physics Assembler. Language spec is 5 pages. (C++ is ~750) • Extensible: Homoiconic, incorporates Lisp’s macro system to build higher level concepts
  • 23. Particles • Particles can be simple, complex, large, small, carry field variables • Based on tDPD, verified to be the fastest computational fluid dynamics scheme, O(n) • Rigorously verified to reproduce Navier-Stokes
  • 24. Chemical Reactions ning a functional language is because we would like to and proven theory, in this case the lambda calculus A k1A ! X X + 2 Y k2XY 2 ! 3 X B + X k3BX ! Y + D X k4X ! E ) { k1 ⇤ A} > (3 X) { k2 ⇤ X ⇤ Y ⇤⇤2} (Y, D) { k3 ⇤ B ⇤ X} ) { k4 ⇤ X} = S · ⌫ 2 6 1 0 0 1 0 0 0 0 0 0 1 2 3 7 2 6 6 6 ⌫A ⌫B ⌫D 3 7 7 7 The rationale for designing a functional language is because w base it on a well known and proven theory, in this case the lamb A k1A ! X X + 2 Y k2XY 2 ! 3 X B + X k3BX ! Y + D X k4X ! E proc (A) > (X) { k1 ⇤ A} proc (X, 2 Y) > (3 X) { k2 ⇤ X ⇤ Y ⇤ ⇤ 2} proc (B, X) > (Y, D) { k3 ⇤ B ⇤ X} proc (X) > (E) { k4 ⇤ X} dX dt = S · ⌫ 2 6 6 6 6 6 6 4 dA/dt dB/dt dD/dt dE/dt dX/dt dY/dt 3 7 7 7 7 7 7 5 = 2 6 6 4 1 0 0 1 0 0 0 0 0 0 1 2 0 1 1 1 1 1 0 0 0 1 1 0 3 7 7 5 · 2 6 6 6 6 6 6 4 ⌫A ⌫B ⌫D ⌫E ⌫X ⌫Y force (r:Red, b:Blue) { k ⇤ dist(r,b)} m to point entally important biological processes. A chemical reaction process in and produces a set of products, in effect, the process describes the trans- a set of products. Modeling chemical reactions is one of the most common processes. Transformation process syntax is similar to the conventional based on Microsoft Typescript type specification. For example, to add a atial region, one would simply write a set of transformation processes in ansformation processes begin with the proc keyword, have an an optional roducts and the reaction rate expression as in Fig. 1. If the spatial region 2 6 6 6 6 6 6 4 dA/dt dB/dt dD/dt dE/dt dX/dt dY/dt 3 7 7 7 7 7 7 5 = 2 6 6 6 6 6 6 4 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 1 1 1 1 0 2 1 0 3 7 7 7 7 7 7 5 · 2 6 6 4 n1 n2 n3 n4 3 7 7 5
  • 25. Generalized Transformation Process • Generalize the concept of “chemical reactions” to enable transformation of discrete things. • Same syntax as continuous substrates, except when the inputs are discrete, the process body is interpreted as a probability • Enables us to model stochastic reactions and stochastic cellular automata pfrc(body, body); pfrc(body, surface); } dX dt = f(X, t) + ⇠(t), x(t0) = X0, X 2 RN (t) = eiLt (0) proc (a:solvent.A) > (b:solvent.A) when (dist(a,b) < 5) { k ⇤ (a b)}; proc (a:Red.A) > (b:Red.A) when (dist(a,b) < 5) { k ⇤ (a b)}; proc (a:solvent.A) > (b:Red.A) when (dist(a,b) < 5) { k ⇤ (a b)}; proc my reaction(a:integer , b:integer) > (c:integer) { exp( k ⇤ (a⇤ b)/T)} force(a:nucleus , b:surface) { k ⇤ (
  • 26. Fields are represented as attributes on particles • Extremely Simple Syntactically • Compiler automatically generates internal data structures • Completely self-consistent for solids, melts, liquids • Get body forces, diffusion, transport for free • No re-meshing, ever!
  • 27. Inter-Particle Transport A A B C A B C A A AA A A A A A A A A A A A A A A proc (a:solvent.A) > (b:solvent.A) when (dist(a,b) < 5) { k ⇤ (a b)}; proc (a:Red.A) (b:Red.A)
  • 28. Spatial Regions Somogyi and Glazier 2 6 6 6 6 6 6 4 dA/dt dB/dt dD/dt dE/dt dX/dt dY/dt 3 7 7 7 7 7 7 5 = 2 6 6 6 6 6 6 4 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 1 1 1 1 0 2 1 0 3 7 7 7 7 7 7 5 · 2 6 6 4 n1 n2 n3 n4 3 7 7 5 Figure 1: Things Somogyi and G type MyCell : SpatialRegion { surface : Sphere { radius:5, resolution:1 }; proc (A) -> (X) {k1 * A}; proc (X, 2 Y) -> (3 X) { k2 * X * Y**2 }; proc (B, X) -> (Y, D) { k3 * B * X }; proc (X) -> (E) {k4 * X}; } 2 6 6 6 6 6 6 4 dA/dt dB/dt dD/dt dE/dt dX/dt dY/dt 3 7 7 7 7 7 7 5 = 2 6 6 6 6 6 6 4 1 0 0 0 1 0
  • 29. Dynamic Changes In Morphology • Forces are one of the fundamental concepts in physical systems
  • 30. Polymeric fluid:Polymeric fluid: mesoscopicmesoscopic mm  exc  cor  pre  finit Litvinov et al., Phys.Rev. E 77, 66703 (2008) Forces • Mass-Spring systems have been in molecular dynamics, games for years • Difficult to program and usually static connectivity
  • 31. Forces • Same suite of links as MD: bond, angle, dihedral… • Working on surface links: bending, shear… 6 6 6 4 dE/dt dX/dt dY/dt 7 7 7 5 = 6 4 0 1 1 1 1 1 0 0 0 1 1 0 7 5 orce (r:Red, b:Blue) { k ⇤ dist(r orce (a:Red, b:Red) { k2 ⇤ dist(a F = ma dv dt = 1 m F dx dt = 1 v ⇠(t) dX dt = S · ⌫ 2 6 6 6 6 6 6 4 dA/dt dB/dt dD/dt dE/dt dX/dt dY/dt 3 7 7 7 7 7 7 5 = 2 6 6 4 1 0 0 0 1 0 0 0 0 0 1 2 0 1 1 0 1 1 0 0 0 1 1 0 3 7 7 5 · 2 6 6 6 6 6 6 4 ⌫A ⌫B ⌫D ⌫E ⌫X ⌫Y 3 7 7 7 7 7 7 5 link (r:Red, b:Blue) { k ⇤ dist(r,b)} link (a:Red, b:Red) { k2 ⇤ dist(a,b)} F = ma dv dt = 1 m F dx dt = 1 v ⇠(t)
  • 32. Forces • Forces can be defined between individual instances (one to one), individual instances and collections (one to many), or collections and collections (many to many). • The type specifier determines how forces are applied. • Links may have ‘if’, ‘when’, or ‘while’ clauses, these define cut-off, activation and deactivation conditions. May be asymmetric.
  • 33. Links: bonded forces type MyCell : SpatialRegion { nucleus : Particle { radius:2}; surface : Sphere { radius:2; resolution :1}; body : fill(type:Particle { radius:0.3} , density:20); link (n:nucleus , b:body) if (dist(n,b) < 6) { k ⇤ (dist(n,b) 5)}; link pfrc(a:Particle , b:Particle) if (dist(a,b) < 2) { k ⇤ (dist(a,b) 1) }; pfrc(body, body); pfrc(body, surface); } dX = f(X, t) + ⇠(t), x(t0) = X0, X 2 RN
  • 34. Connecting Physics and Chemistry • link body definitions can contain arbitrary, user specified functional forms. • link (and reaction rate) bodies can reference local chemical concentrations at the location of the link instance Rh RhRh Rh Rh Rh Rh Rh Rh dt = S · ⌫ 2 6 6 6 6 6 6 4 dA/dt dB/dt dD/dt dE/dt dX/dt dY/dt 3 7 7 7 7 7 7 5 = 2 6 6 4 1 0 0 0 1 0 0 0 0 0 1 2 0 1 1 0 1 1 0 0 0 1 1 0 3 7 7 5 · 2 6 6 6 6 6 6 4 ⌫A ⌫B ⌫D ⌫E ⌫X ⌫Y 3 7 7 7 7 7 7 5 link (r:Red, b:Blue) { k ⇤ dist(r,b)} link (a:Red, b:Red) { k2 ⇤ dist(a,b)} link(a:mycell.nucleus , b:mycell.surface) { k ⇤ (dist(a,b) restLength + k2 ⇤ Rho); } F = ma dv dt = 1 m F dx dt = 1 v ⇠(t) Spatial Scoping
  • 35. Cell Motion with Forces • Combine Previous Ideas • Spatial Scoping force pfrc(a:Point, b:Point) if (dist(a,b) < 2) { k ⇤ (dist(a,b) 1) }; pfrc(body, body); pfrc(body, surface); } dX dt = f(X, t) + ⇠(t), x(t0) = X0, X 2 R force(a:nucleus , b:surface) { k ⇤ ( dist(a,b) (restLength + b.ChemicalSignal) ) }
  • 36. Time Propagation ous state vector C(t). Each process definition body can access the present icle attributes, and constant parameters to calculate the process transforma- processes defines a system of ordinary differential equations (ODEs) in the d dt C =  ˙Cf ˙Cr =  N·n(C,r,v,p) f(C,r,v,p) . (1) partitions: Cf is the vector of independent continuous variables (which par- ocesses, i.e., a reaction network), and Cr is a vector of variables which are vector p consists of time independent parameters. The reaction network of ansformation processes defines the m⇥n stoichiometry matrix N. Each stoi- et number of continuous variables i produced or consumed in transformation ation process definitions combine to form the transformation rate function n. tor, Cr, is a set of variables which form a system of conventional ODEs, i.e. defined by a rate process. Only the Mechanica runtime can directly change is the sum of the linked, FL, conservative, FC, random, FR, dissipative, FD, nked force is the sum of the linked relationships between the particles. The raction which ensures volume exclusion and keeps materials from interpene- presents the effects of viscosity, and the random force represents the effects rces. The linked force is the sum of the linked relationships between the pa s a soft interaction which ensures volume exclusion and keeps materials from ive force represents the effects of viscosity, and the random force represent ons. Integration time steps can be large because these inter-particle forces eractions. More details on the conservative, random and dissipative forces c The time evolution of particle positions, r and velocities, v is defined as d2ri dt2 = dvi dt = 1 mi Fi = 1 mi  i6=j FL ij +FC ij +FD ij +FR ij +Fext i ! . tes the time evolution of the model via time slicing – time is partitioned int Each time step has three phases: (A) evaluate and apply the when and whil esses determine if they should be triggered, and apply them. Links are a 1 according to their when and while predicates. (B) integrate the cont ording to eqn. 1 and (C) integrate the particle positions according to eqn. 2. Implemented in mdcore, Mechanica’s stand-alone particle dynamics engine. Combined with CVODE.
  • 37. Neighbors Update when particle displacement (rskin - rcut)/2 • Force calculations are very expensive • Without Optimization, would be O(N2) • Cell List• Verlet List Most efficient is to use both
  • 38. © Copyright Khronos Group, 2010 - Page 13 Parallelism • For each simulation iteration: -  Compute forces in each link based on its length -  Correct positions of masses/vertices from forces -  Compute new vertex positions Original layout Current layout: Compute forces as Stretch from rest length Compute new positions Apply position corrections to masses Position Based DynamicsBender, Müller, Otaduy and Teschner / Position-based Methods for the Simulation of S Algorithm 1 Position-based dynamics 1: for all vertices i do 2: initialize xi = x0 i , vi = v0 i , wi = 1/mi, 3: end for 4: loop 5: for all vertices i do vi vi +Dtwifext(xi) 6: for all vertices i do pi xi +Dtvi 7: for all vertices i do genCollConstraints(xi ! pi) 8: loop solverIteration times 9: projectConstraints(C1,...,CM+MColl ,p1,...,pN) 10: end loop 11: for all vertices i do 12: vi (pi xi)/Dt 13: xi pi 14: end for 15: velocityUpdate(v1,...,vN) 16: end loop fined for. We can now write th C1(p) ... CM(p) where the symbol denot Raphson iteration is a metho ric systems with equalities o first guess of a solution. Each earized in the neighborhood o C(p+Dp) = C(p)+rpC This yields a linear system fo Dp rpC1(p)·Dp ... Parallelism • For each simulation iteration: -  Compute forces in each link based on -  Correct positions of masses/vertices fr -  Compute new vertex positions Original layout Current layout: Compute forces as Stretch from rest length Parallelism • For each simulation iteration: -  Compute forces in each link based on its -  Correct positions of masses/vertices from -  Compute new vertex positions Original layout Current layout: Compute forces as Stretch from rest length © Copyright Khronos Group, 2010 - Page 9 Parallelism • Large number of particles - Appropriate for parallel processing - Force from each spring constraint applied to both connected particles Original layout Current layout: Compute forces as Stretch from rest length Compute new positions Apply position corrections to masses
  • 39. Constraints Example: Distance constraint• Distance Constraint • First project the particles, then satisfy constraints
  • 40. Constraints • Gauss Seidel Method • Fast to converge, but serial Example: Distance constraint Approximate solution to a system of constraints using Gauss- Seidel method Rest position
  • 41. Constraints • Gauss Seidel Method • Fast to converge, but serial Example: Distance constraint Approximate solution to a system of constraints using Gauss- Seidel method The particles are displaced by external forces
  • 42. Constraints • Gauss Seidel Method • Fast to converge, but serial Example: Distance constraint Approximate solution to a system of constraints using Gauss- Seidel method The constraints are solved sequentially
  • 43. Constraints • Gauss Seidel Method • Fast to converge, but serial Example: Distance constraint Approximate solution to a system of constraints using Gauss-Seidel method The constraints are solved sequentially
  • 44. Constraints • Gauss Seidel Method • Fast to converge, but serial Example: Distance constraint Approximate solution to a system of constraints using Gauss-Seidel method The constraints are solved sequentially
  • 45. Constraints • Gauss Seidel Method • Fast to converge, but serial Example: Distance constraint Approximate solution to a system of constraints using Gauss-Seidel method The constraints are solved sequentially
  • 46. Constraints • Gauss Seidel Method • Fast to converge, but serial Example: Distance constraint Approximate solution to a system of constraints using Gauss-Seidel method The constraints are solved sequentially
  • 47. Constraints • Gauss Seidel Method • Fast to converge, but serial Example: Distance constraint Approximate solution to a system of constraints using Gauss-Seidel method Iteration 1
  • 48. Constraints • Jacobi Method easier to parallelize, but converges slower Example: Distance constraint Approximate solution to a system of constraints using Jacobi method The constraints are solved in parallel
  • 49. Constraints • Jacobi Iteration 1 Example: Distance constraint Approximate solution to a system of constraints using Jacobi method Iteration 1
  • 50. Constraints • Jacobi Iteration 2 Example: Distance constraint Approximate solution to a system of constraints using Jacobi method Iteration 2
  • 51. Constraints • Jacobi Iteration 3 Example: Distance constraint Approximate solution to a system of constraints using Jacobi method Iteration 3
  • 52. Constraints • Jacobi Iteration 4 Example: Distance constraint Approximate solution to a system of constraints using Jacobi method Iteration 4
  • 53. Demo With apologies to Jack Bauer …
  • 54. Cellular Automata • Seamlessly integrate particle systems and cellular automata • Use Mechanica’s Python binding to integrate with existing CC3D scripts • Automatically update AABB tree as CA voxels change • As CA boundary changes, automatically updates constraints on particles • Momentum Conserving
  • 55. Application Interoperability • Core design goal • Interoperability with existing applications • Same binary object layout as Python — auto-boxing • zero-overhead Python binding • Python script can import a Mechanica model just like any other Python module • Integrate into CompuCell3D models with zero CompuCell3D changes • C API — cross language compatible
  • 56. Collaborations • Priyom Adhyapok (IU): CompuCell3D integration, somite formation. • Mike Hosek (IU): erythrocyte cortical dynamics • Jean-Marie Bouteiller (USC): Synaptic junction reaction-transport • Amit Hagar (IU): Liver carcinogenesis and toxicology risk assessment, CompuCell3D integration, reaction/ transport of carcinogen in a liver sinusoid
  • 57. Outlook • Find tenure-track job (or funded post-doc), continue to develop and apply Mechanica. • Secure Funding (NIH, NSF, …) • Applications / Collaborators (Experimental Biologists) • Different backends (GPU, MPI, …) • Multi-scale factorization — combine micro and mesoscale time evolution • Visual Model Editing
  • 58. Acknowledgements and Disclosure • A number of concepts presented here are patent pending. • All code will be freely licensed under Common Development and Distribution License (CDDL) • We acknowledge generous financial support the National Institutes of Health, National Institute of General Medical Sciences, grants R01 GM076692 and R01 GM077138.
  • 59. Conclusions • Modeling description language that naturally expresses physical constructs and captures biological knowledge. • Built on physical, chemical and biological constructs. • Enables biologists to model systems using natural concepts. • somogyie@indiana.edu • http://mechanica.org