MDFloat

/*
    This file represents a hardware module that performs a subset of the
    calculations necessary for each timestep in a molecular dynamics
    simulation.  This takes in the data for two atoms in single
    precision floating point format and produces the Columbic forces
    in the X, Y, and Z direction.
*/

void MDFloat(float atomOneCurrentX_in, float atomOneCurrentY_in, float atomOneCurrentZ_in,
             float atomOneCurrentCharge_in, float atomTwoCurrentX_in, float atomTwoCurrentY_in,
             float atomTwoCurrentZ_in, float atomTwoCurrentCharge_in, float tableLookup_in,
             float& CoulombicForceX_out, float& CoulombicForceY_out, float& CoulombicForceZ_out)
{
    float twelfthTerm ;
    float sixthTerm ;
    float radiusToTheTwelfth ;
    float radiusToTheSixth ;
    float radiusSquared ;
    float distanceXSquared ;
    float distanceYSquared ;
    float distanceZSquared ;
    float differenceX ;
    float differenceY ;
    float differenceZ ;
    float vcoul ;
    float rinvsq ;
    float rinv ;

    differenceX = atomOneCurrentX_in - atomTwoCurrentX_in ;
    differenceY = atomOneCurrentY_in - atomTwoCurrentY_in ;
    differenceZ = atomOneCurrentZ_in - atomTwoCurrentZ_in ;

    distanceXSquared = differenceX * differenceX ;
    distanceYSquared = differenceY * differenceY ;
    distanceZSquared = differenceZ * differenceZ ;

    radiusSquared = distanceXSquared + distanceYSquared + distanceZSquared ;

    rinv = (tableLookup_in * (((radiusSquared * tableLookup_in) * tableLookup_in))) ;

    vcoul = atomOneCurrentCharge_in * atomTwoCurrentCharge_in * rinv ;

    rinvsq = rinv * rinv ;

    CoulombicForceX_out = vcoul * rinvsq * differenceX ;
    CoulombicForceY_out = vcoul * rinvsq * differenceY ;
    CoulombicForceZ_out = vcoul * rinvsq * differenceZ ;
}

Description

The C code for the MDFloat is shown above. Using floating point variables is as simple as declaring them as float. If you wanted the floating point values to have either 64 or 16 bit values, you would have to create a typedef at the top similiar to the doing varying bitsizes for ints.

Example:

typedef float ROCCC_float64;
typedef float ROCCC_float32;
typedef float ROCCC_float16;