previous page / next page


Coding Conventions

The MDX libraries are written in C using an object-based style.

An example:

The Step library offers a "class" (struct) Step along with "methods" (functions) that act on a Step "object" (struct instantiation).

The members of a Step object should not be accessed directly. Instead its state is supplied directly by the methods and through the use of "helper objects" (structs whose members should be set) StepParam and StepSystem.

Class: Step - perform time stepping
Helpers: StepParam - supplies configuration data
(configured once before simulation begins)
StepSystem - supplies data for system
(initial trajectories provided, then updates to position, velocity, and force arrays)
Methods: int step_init(Step *, StepParam *)
  • constructor
void step_done(Step *)
  • destructor
int step_compute(Step *, StepSystem *, int32 numsteps)
  • perform leapfrog (velocity Verlet) time stepping
int step_find_reductions(Step *, StepSystem *)
  • determine kinetic energy and temperature
int step_set_random_velocities(Step *, StepSystem *)
  • set velocities for initial temperature
int step_remove_com_motion(Step *, StepSystem *)
  • remove center of mass motion for system

Note the naming conventions:

  • Step
  • StepParam - user-supplied configuration data
  • StepSystem - user-accessible state data
  • function names begin with "step_" and pass explicit "this" pointer (Step *) as first parameter

The other libraries similarly follow these conventions.


previous page / next page