Detailed Program Flow
Implementation in C++
The code is written in C++ for speed. We attempt to use an somewhat object-based approach, but a good many of the member variables are declared as static global to allow their access across threads.
Here is a breakdown of the main classes and functions in the program. There are numerous other functions but this is the core of the program:
- Main()
- Spawns threads:
collisiondetectionthread,linkforcesthreadandapplyforcesthreaddepending on theUSETHREAD_COLLISION,USETHREAD_LINKFORCESandUSETHREAD_APPLYFORCESparameters. - Parses the
comet_params.inifile to read parameters. All of the parameters are implemented as globals (should fix at some point) - Creates the main
theactinandnuc_objectobjects. - Runs through the main iteration loop, calling
theactin.iterate()and saving snapshots every so often.
- Spawns threads:
- Actin class
- There is only one actin object,
theactin, which constitutes the network, i.e.~contains the nodes and the functions that deal with them. - The
iterate()function does one iteration pass, calling:nucleator_node_interactions()displaces any nodes out of the nucleator object along a normal to the nucleator surfacenucleate()adds new harbinger nodes to the surface of the nucleatorcrosslinknewnodes()crosslinks harbingers once they are readysortnodesbygridpoint()orders nodes by gridpoint. The {\it only} reason for this is for the division of labor when using threads: We do repulsion by gridpoint to save re-calculating nearby nodes if there are multiple nodes on one gridpoint, and we do not want to divide nodes on one gridpoint across multiple threads.collisiondetection()detects whether nodes are withinNODE_REPULSIVE_RANGEof one another and adds the repulsive force torep_force_vec[].linkforces()Calculates the forces between nodes due to links and puts intolink_force_vec[]. If a link goes above a certain threshold force, marks it as broken and removes next time (again to prevent thread problems---since a link is removed both ways and we can't guarantee that both nodes are being processed by same thread)applyforces()updates the positions of all the nodes. Sums over the threads forrep_force_vec[],link_force_vec[]andrepulsion_displacement_vec[].- Numerous other functions for things like saving bmps, vrml etc.
- Nucleator class
- There is only one nucleator object at the moment,
nuc_object, which is closely linked to the actin object - The nucleator is either a sphere, a capsule (i.e.~a sphere with a cylindrical segment stuck in the middle) or ellipsoid
addnodes()adds harbingers to the surface of the nucleator. The probablility of addition of nodes is normalized by surface area and is symmetric ifASYMMETRIC_NUCLEATIONis zero, or asymmetric if 1 or 2 (stepped or linear bias)definenucleatorgrid()sets a list of gridpoints to check in case of nodes entering the nucleator. Called once at the beginning.iswithinnucleator()returns true if the node is within the nucleatorcollision()moves a node out of the nucleator along a normal vector
- There is only one nucleator object at the moment,
- Nodes class
- Nodes exist only as members of the actin object
nodegridis a 3 dimensional C++ vector of node pointers. Each nodegrid entry starts a circularly linked list of nodes representing the nodes within that gridpoint voxel.- The actin class contains a vector of nodes. Each node has an associated
nodenum,xyandzposition,nextnodeandprevnodenode pointers for the nodegrid linked list,rep_force_vec[],link_force_vec[]andrepulsion_displacement_vec[]as described above, the grid position of the node,harbingerandpolymerflags and alistoflinksi.e. a vector of link object which attach this node to other nodes. polymerize()Creates a node as a harbinger. Adds its pointer to the gridpoint linked list.depolymerize()Removes a node, deletes all links and removes from grid.setgridcoords()Calculates new grid co-ordinates based on x,y,z positionaddtogrid()adds the node to the current gridpointremovefromgrid()removes node from the gridupdategrid()checks to see if node has moved gridpoints, and updates grid is needs toremovelink()removes the specified node from the list of links
- Links class
- Links exist only as members of the node objects
- Each link has an associated
linkednodeptrwhich points to the target node that the link is to and abrokenflag which is read byactin::linkforces()and tells it to delete the link if it broke. orig_distandorig_distsqrstore the original distance of the link (and the square of that in a misguided attempt to avoid taking square roots.)breakcountstores the number of consecutive iterations the link force has been aboveLINK_BREAKAGE_FORCEand is used to increase the probability of breakagegetlinkforces()returns the force acting on the link. Also sets thebrokenflag and incrementsbreakcountif appropriate
- There is only one actin object,