mdcore
0.1.5
|
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <math.h>
#include <float.h>
#include <string.h>
#include "../config.h"
#include <omp.h>
#include "cycle.h"
#include "errs.h"
#include "fptype.h"
#include "lock.h"
#include "part.h"
#include "cell.h"
#include "fifo.h"
#include "queue.h"
#include "space.h"
#include "potential.h"
#include "runner.h"
#include "bond.h"
#include "rigid.h"
#include "angle.h"
#include "dihedral.h"
#include "exclusion.h"
#include "reader.h"
#include "engine.h"
Defines | |
#define | error(id) ( engine_err = errs_register( id , engine_err_msg[-(id)] , __LINE__ , __FUNCTION__ , __FILE__ ) ) |
Functions | |
int | engine_shuffle (struct engine *e) |
Re-shuffle the particles in the engine. | |
int | engine_timers_reset (struct engine *e) |
Set all the engine timers to 0. | |
int | engine_verlet_update (struct engine *e) |
Check if the Verlet-list needs to be updated. | |
int | engine_split (struct engine *e) |
Set-up the engine for distributed-memory parallel operation. | |
int | engine_split_bisect (struct engine *e, int N) |
Split the computational domain over a number of nodes using bisection. | |
int | engine_flush (struct engine *e) |
Clear all particles from this engine. | |
int | engine_flush_ghosts (struct engine *e) |
Clear all particles from this engine's ghost cells. | |
int | engine_setexplepot (struct engine *e, struct potential *ep) |
Set the explicit electrostatic potential. | |
int | engine_unload (struct engine *e, double *x, double *v, int *type, int *pid, int *vid, double *q, unsigned int *flags, double *epot, int N) |
Unload a set of particle data from the engine. | |
int | engine_unload_marked (struct engine *e, double *x, double *v, int *type, int *pid, int *vid, double *q, unsigned int *flags, double *epot, int N) |
Unload a set of particle data from the marked cells of an engine. | |
int | engine_unload_strays (struct engine *e, double *x, double *v, int *type, int *pid, int *vid, double *q, unsigned int *flags, double *epot, int N) |
Unload real particles that may have wandered into a ghost cell. | |
int | engine_load (struct engine *e, double *x, double *v, int *type, int *pid, int *vid, double *q, unsigned int *flags, int N) |
Load a set of particle data. | |
int | engine_load_ghosts (struct engine *e, double *x, double *v, int *type, int *pid, int *vid, double *q, unsigned int *flags, int N) |
Load a set of particle data as ghosts. | |
int | engine_gettype (struct engine *e, char *name) |
Look for a given type by name. | |
int | engine_gettype2 (struct engine *e, char *name2) |
Look for a given type by its second name. | |
int | engine_addtype (struct engine *e, double mass, double charge, char *name, char *name2) |
Add a type definition. | |
int | engine_addpot (struct engine *e, struct potential *p, int i, int j) |
Add an interaction potential. | |
int | engine_start (struct engine *e, int nr_runners, int nr_queues) |
Start the runners in the given engine. | |
int | engine_start_SPU (struct engine *e, int nr_runners) |
Start the SPU-associated runners in the given engine. | |
int | engine_nonbond_eval (struct engine *e) |
Compute the nonbonded interactions in the current step. | |
int | engine_advance (struct engine *e) |
Update the particle velocities and positions, re-shuffle if appropriate. | |
int | engine_step (struct engine *e) |
Run the engine for a single time step. | |
int | engine_barrier (struct engine *e) |
Barrier routine to hold the runners back. | |
int | engine_finalize (struct engine *e) |
Initialize an engine with the given data and MPI enabled. | |
int | engine_init (struct engine *e, const double *origin, const double *dim, double *L, double cutoff, unsigned int period, int max_type, unsigned int flags) |
Initialize an engine with the given data. | |
Variables | |
int | engine_err = engine_err_ok |
char * | engine_err_msg [26] |
#define error | ( | id | ) | ( engine_err = errs_register( id , engine_err_msg[-(id)] , __LINE__ , __FUNCTION__ , __FILE__ ) ) |
int engine_addpot | ( | struct engine * | e, |
struct potential * | p, | ||
int | i, | ||
int | j | ||
) |
Add an interaction potential.
e | The engine. |
p | The potential to add to the engine. |
i | ID of particle type for this interaction. |
j | ID of second particle type for this interaction. |
Adds the given potential for pairs of particles of type i
and j
, where i
and j
may be the same type ID.
int engine_addtype | ( | struct engine * | e, |
double | mass, | ||
double | charge, | ||
char * | name, | ||
char * | name2 | ||
) |
Add a type definition.
e | The engine. |
mass | The particle type mass. |
charge | The particle type charge. |
name | Particle name, can be NULL . |
name2 | Particle second name, can be NULL . |
The particle type ID must be an integer greater or equal to 0 and less than the value max_type
specified in engine_init.
int engine_advance | ( | struct engine * | e | ) |
Update the particle velocities and positions, re-shuffle if appropriate.
e | The engine on which to run. |
int engine_barrier | ( | struct engine * | e | ) |
Barrier routine to hold the runners
back.
e | The engine to wait on. |
After being initialized, and after every timestep, every runner calls this routine which blocks until all the runners have returned and the engine signals the next timestep.
int engine_finalize | ( | struct engine * | e | ) |
Initialize an engine with the given data and MPI enabled.
e | The engine to initialize. |
origin | An array of three doubles containing the cartesian origin of the space. |
dim | An array of three doubles containing the size of the space. |
L | The minimum cell edge length, should be at least cutoff . |
cutoff | The maximum interaction cutoff to use. |
period | A bitmask describing the periodicity of the domain (see space_periodic_full). |
max_type | The maximum number of particle types that will be used by this engine. |
flags | Bit-mask containing the flags for this engine. |
comm | The MPI comm to use. |
rank | The ID of this node. |
e | the engine to finalize. |
int engine_flush | ( | struct engine * | e | ) |
Clear all particles from this engine.
e | The engine to flush. |
int engine_flush_ghosts | ( | struct engine * | e | ) |
Clear all particles from this engine's ghost cells.
e | The engine to flush. |
int engine_gettype | ( | struct engine * | e, |
char * | name | ||
) |
Look for a given type by name.
e | The engine. |
name | The type name. |
int engine_gettype2 | ( | struct engine * | e, |
char * | name2 | ||
) |
Look for a given type by its second name.
e | The engine. |
name2 | The type name2. |
int engine_init | ( | struct engine * | e, |
const double * | origin, | ||
const double * | dim, | ||
double * | L, | ||
double | cutoff, | ||
unsigned int | period, | ||
int | max_type, | ||
unsigned int | flags | ||
) |
Initialize an engine with the given data.
e | The engine to initialize. |
origin | An array of three doubles containing the cartesian origin of the space. |
dim | An array of three doubles containing the size of the space. |
L | The minimum cell edge length in each dimension. |
cutoff | The maximum interaction cutoff to use. |
period | A bitmask describing the periodicity of the domain (see space_periodic_full). |
max_type | The maximum number of particle types that will be used by this engine. |
flags | Bit-mask containing the flags for this engine. |
int engine_load | ( | struct engine * | e, |
double * | x, | ||
double * | v, | ||
int * | type, | ||
int * | pid, | ||
int * | vid, | ||
double * | q, | ||
unsigned int * | flags, | ||
int | N | ||
) |
Load a set of particle data.
e | The engine. |
x | An N times 3 array of the particle positions. |
v | An N times 3 array of the particle velocities. |
type | A vector of length N of the particle type IDs. |
pid | A vector of length N of the particle IDs. |
vid | A vector of length N of the particle virtual IDs. |
q | A vector of length N of the individual particle charges. |
flags | A vector of length N of the particle flags. |
N | the number of particles to load. |
If the parameters v
, flags
, vid
or q
are NULL
, then these values are set to zero.
int engine_load_ghosts | ( | struct engine * | e, |
double * | x, | ||
double * | v, | ||
int * | type, | ||
int * | pid, | ||
int * | vid, | ||
double * | q, | ||
unsigned int * | flags, | ||
int | N | ||
) |
Load a set of particle data as ghosts.
e | The engine. |
x | An N times 3 array of the particle positions. |
v | An N times 3 array of the particle velocities. |
type | A vector of length N of the particle type IDs. |
pid | A vector of length N of the particle IDs. |
vid | A vector of length N of the particle virtual IDs. |
q | A vector of length N of the individual particle charges. |
flags | A vector of length N of the particle flags. |
N | the number of particles to load. |
If the parameters v
, flags
, vid
or q
are NULL
, then these values are set to zero.
int engine_nonbond_eval | ( | struct engine * | e | ) |
Compute the nonbonded interactions in the current step.
e | The engine on which to run. |
This routine advances the timestep counter by one, prepares the space for a timestep, releases the runner's associated with the engine and waits for them to finnish.
int engine_setexplepot | ( | struct engine * | e, |
struct potential * | ep | ||
) |
Set the explicit electrostatic potential.
If ep
is not NULL
, the flag engine_flag_explepot is set, otherwise it is cleared.
int engine_shuffle | ( | struct engine * | e | ) |
Re-shuffle the particles in the engine.
e | The engine on which to run. |
int engine_split | ( | struct engine * | e | ) |
Set-up the engine for distributed-memory parallel operation.
e | The engine to set-up. |
This function assumes that engine_split_bisect or some similar function has already been called and that #nodeID, #nr_nodes as well as the cell nodeIDs
have been set.
int engine_split_bisect | ( | struct engine * | e, |
int | N | ||
) |
Split the computational domain over a number of nodes using bisection.
e | The engine to split up. |
N | The number of computational nodes. |
int engine_start | ( | struct engine * | e, |
int | nr_runners, | ||
int | nr_queues | ||
) |
Start the runners in the given engine.
e | The engine to start. |
nr_runners | The number of runners start. |
Allocates and starts the specified number of runner. Also initializes the Verlet lists.
int engine_start_SPU | ( | struct engine * | e, |
int | nr_runners | ||
) |
Start the SPU-associated runners in the given engine.
e | The engine to start. |
nr_runners | The number of runners start. |
Allocates and starts the specified number of runner.
int engine_step | ( | struct engine * | e | ) |
Run the engine for a single time step.
e | The engine on which to run. |
This routine advances the timestep counter by one, prepares the space for a timestep, releases the runner's associated with the engine and waits for them to finnish.
Once all the runner's are done, the particle velocities and positions are updated and the particles are re-sorted in the space.
int engine_timers_reset | ( | struct engine * | e | ) |
Set all the engine timers to 0.
e | The engine. |
int engine_unload | ( | struct engine * | e, |
double * | x, | ||
double * | v, | ||
int * | type, | ||
int * | pid, | ||
int * | vid, | ||
double * | q, | ||
unsigned int * | flags, | ||
double * | epot, | ||
int | N | ||
) |
Unload a set of particle data from the engine.
e | The engine. |
x | An N times 3 array of the particle positions. |
v | An N times 3 array of the particle velocities. |
type | A vector of length N of the particle type IDs. |
pid | A vector of length N of the particle IDs. |
vid | A vector of length N of the particle virtual IDs. |
q | A vector of length N of the individual particle charges. |
flags | A vector of length N of the particle flags. |
epot | A pointer to a #double in which to store the total potential energy. |
N | the maximum number of particles. |
The fields x
, v
, type
, pid
, vid
, q
, epot
and/or flags
may be NULL.
int engine_unload_marked | ( | struct engine * | e, |
double * | x, | ||
double * | v, | ||
int * | type, | ||
int * | pid, | ||
int * | vid, | ||
double * | q, | ||
unsigned int * | flags, | ||
double * | epot, | ||
int | N | ||
) |
Unload a set of particle data from the marked cells of an engine.
e | The engine. |
x | An N times 3 array of the particle positions. |
v | An N times 3 array of the particle velocities. |
type | A vector of length N of the particle type IDs. |
pid | A vector of length N of the particle IDs. |
vid | A vector of length N of the particle virtual IDs. |
q | A vector of length N of the individual particle charges. |
flags | A vector of length N of the particle flags. |
epot | A pointer to a #double in which to store the total potential energy. |
N | the maximum number of particles. |
The fields x
, v
, type
, pid
, vid
, q
, epot
and/or flags
may be NULL.
int engine_unload_strays | ( | struct engine * | e, |
double * | x, | ||
double * | v, | ||
int * | type, | ||
int * | pid, | ||
int * | vid, | ||
double * | q, | ||
unsigned int * | flags, | ||
double * | epot, | ||
int | N | ||
) |
Unload real particles that may have wandered into a ghost cell.
e | The engine. |
x | An N times 3 array of the particle positions. |
v | An N times 3 array of the particle velocities. |
type | A vector of length N of the particle type IDs. |
pid | A vector of length N of the particle IDs. |
vid | A vector of length N of the particle virtual IDs. |
q | A vector of length N of the individual particle charges. |
flags | A vector of length N of the particle flags. |
epot | A pointer to a #double in which to store the total potential energy. |
N | the maximum number of particles. |
The fields x
, v
, type
, vid
, pid
, q
, epot
and/or flags
may be NULL.
int engine_verlet_update | ( | struct engine * | e | ) |
Check if the Verlet-list needs to be updated.
e | The engine. |
int engine_err = engine_err_ok |
ID of the last error.
char* engine_err_msg[26] |
{ "Nothing bad happened.", "An unexpected NULL pointer was encountered.", "A call to malloc failed, probably due to insufficient memory.", "An error occured when calling a space function.", "A call to a pthread routine failed.", "An error occured when calling a runner function.", "One or more values were outside of the allowed range.", "An error occured while calling a cell function.", "The computational domain is too small for the requested operation.", "mdcore was not compiled with MPI.", "An error occured while calling an MPI function.", "An error occured when calling a bond function.", "An error occured when calling an angle function.", "An error occured when calling a reader function.", "An error occured while interpreting the PSF file.", "An error occured while interpreting the PDB file.", "An error occured while interpreting the CPF file.", "An error occured when calling a potential function.", "An error occured when calling an exclusion function.", "An error occured while computing the bonded sets.", "An error occured when calling a dihedral funtion.", "An error occured when calling a CUDA funtion.", "mdcore was not compiled with CUDA support.", "CUDA support is only available in single-precision.", "Max. number of parts per cell exceeded.", "An error occured when calling a queue funtion.", }
List of error messages.