P.S: a lot of these improvements were made possible from the work of Steven Andrews (author of Smoldyn - which is a sophisticated and mature tool to model molecular interactions)
I have made slight improvements to the code. To be more realistic, the simulation box should be considered with periodic boundary condition to ensure that the particles are diffusing in an infinitely large medium. The module that provides the ability is as follows:
periodicBoundary[finalpt_] := Module[{x, y},
{x, y} = finalpt;
Which[x >= 1, x = x - 2, x <= -1, x = 2 + x, True, x];
Which[y >= 1, y = y - 2, y <= -1, y = 2 + y, True, y];
{x, y}
] (* Simulation box dimension is 2 *)
The particles are usually reflected off the surface of a cell. In order to ensure the case, a new module ballisticReflect was added. The region that is fed to this module is a surface.
ballisticReflect[inside_] := Module[{near},
near = RegionNearest[Subscript[\[ScriptCapitalR], 2 b], inside];
inside + 2*(near - inside)
] (* region specification should be a boundary *)
Moreover, when a ligand separates from a receptor, the separation or unbinding distance can be non-zero. Previously, in the code the dissociation left the ligand at the same place as the receptor. I introduced a random offset for the dissociation event (an angular offset for a fixed radius). The unbinding radius is computed from Steven Andrew's Smoldyn package.
unbindingDist[centre_, radius_, cellrad_] := Module[{pt = {0, 0}},
While[Norm[pt] <= cellrad,
pt = RandomPoint[Circle[centre, radius]]
]; pt]
The interAct
module has been altered as well so as to ensure that the interacting particles react whenever close-by rather than probabilistically react (adapted from the approach used in Smoldyn).
Owing to these adjustments, I am attaching a second notebook where all the necessary changes have been incorporated.
Attachments: