Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

lammpsplugin.c File Reference

#include "largefiles.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include "molfile_plugin.h"
#include "periodic_table.h"
#include "vmdconio.h"
#include "hash.h"
#include "inthash.h"

Go to the source code of this file.

Compounds

struct  lammpsdata

Defines

#define THISPLUGIN   plugin
#define VMDPLUGIN_STATIC
#define LAMMPS_DEBUG   0
#define M_PI_2   1.57079632679489661922
#define MIN(A, B)   ((A) < (B) ? (A) : (B))
#define MAX(A, B)   ((A) > (B) ? (A) : (B))
#define SMALL   1.0e-12f
#define LINE_LEN   1024
#define KEY_ATOMS   "NUMBER OF ATOMS"
#define KEY_BOX   "BOX BOUNDS"
#define KEY_DATA   "ATOMS"
#define KEY_TSTEP   "TIMESTEP"
#define KEY_TIME   "TIME"
#define LAMMPS_COORD_NONE   0x000U
#define LAMMPS_COORD_WRAPPED   0x001U
#define LAMMPS_COORD_SCALED   0x002U
#define LAMMPS_COORD_IMAGES   0x004U
#define LAMMPS_COORD_UNWRAPPED   0x008U
#define LAMMPS_COORD_UNKNOWN   0x010U
#define LAMMPS_COORD_VELOCITIES   0x020U
#define LAMMPS_COORD_FORCES   0x040U
#define LAMMPS_COORD_DIPOLE   0x080U
#define LAMMPS_COORD_TRICLINIC   0x100U
#define LAMMPS_MAX_NUM_FIELDS   64
#define FileDesc   FILE*
#define myFprintf   fprintf
#define myFopen   fopen
#define myFclose   fclose
#define myFgets(buf, size, fd)   fgets(buf,size,fd)
#define myRewind   rewind

Typedefs

typedef enum lammps_attribute l_attr_t

Enumerations

enum  lammps_attribute {
  LAMMPS_FIELD_UNKNOWN = 0, LAMMPS_FIELD_ATOMID, LAMMPS_FIELD_MOLID, LAMMPS_FIELD_TYPE,
  LAMMPS_FIELD_POSX, LAMMPS_FIELD_POSY, LAMMPS_FIELD_POSZ, LAMMPS_FIELD_POSXS,
  LAMMPS_FIELD_POSYS, LAMMPS_FIELD_POSZS, LAMMPS_FIELD_POSXU, LAMMPS_FIELD_POSYU,
  LAMMPS_FIELD_POSZU, LAMMPS_FIELD_POSXSU, LAMMPS_FIELD_POSYSU, LAMMPS_FIELD_POSZSU,
  LAMMPS_FIELD_IMGX, LAMMPS_FIELD_IMGY, LAMMPS_FIELD_IMGZ, LAMMPS_FIELD_VELX,
  LAMMPS_FIELD_VELY, LAMMPS_FIELD_VELZ, LAMMPS_FIELD_FORX, LAMMPS_FIELD_FORY,
  LAMMPS_FIELD_FORZ, LAMMPS_FIELD_CHARGE, LAMMPS_FIELD_RADIUS, LAMMPS_FIELD_DIAMETER,
  LAMMPS_FIELD_ELEMENT, LAMMPS_FIELD_MASS, LAMMPS_FIELD_QUATW, LAMMPS_FIELD_QUATI,
  LAMMPS_FIELD_QUATJ, LAMMPS_FIELD_QUATK, LAMMPS_FIELD_MUX, LAMMPS_FIELD_MUY,
  LAMMPS_FIELD_MUZ, LAMMPS_FIELD_USER0, LAMMPS_FIELD_USER1, LAMMPS_FIELD_USER2,
  LAMMPS_FIELD_USER3, LAMMPS_FIELD_USER4, LAMMPS_FIELD_USER5, LAMMPS_FIELD_USER6,
  LAMMPS_FIELD_USER7, LAMMPS_FIELD_USER8, LAMMPS_FILED_USER9
}

Functions

void id_merge (int *output, int *left, int nl, int *right, int nr)
void id_sort (int *idmap, int num)
const char * remap_field (const char *tag, const char *list)
char * find_next_item (FileDesc fd, char *linebuf, int buflen)
char * find_item_keyword (FileDesc fd, const char *keyword, char *linebuf, int buflen)
void * open_lammps_read (const char *filename, const char *filetype, int *natoms)
int read_lammps_structure (void *mydata, int *optflags, molfile_atom_t *atoms)
float cosangle2deg (double val)
int read_lammps_timestep (void *mydata, int natoms, molfile_timestep_t *ts)
void close_lammps_read (void *mydata)
void * open_lammps_write (const char *filename, const char *filetype, int natoms)
int write_lammps_structure (void *mydata, int optflags, const molfile_atom_t *atoms)
int write_lammps_timestep (void *mydata, const molfile_timestep_t *ts)
void close_lammps_write (void *mydata)
VMDPLUGIN_API int VMDPLUGIN_init ()
VMDPLUGIN_API int VMDPLUGIN_register (void *v, vmdplugin_register_cb cb)
VMDPLUGIN_API int VMDPLUGIN_fini ()

Variables

int velinfo = 1
molfile_plugin_t plugin


Define Documentation

#define FileDesc   FILE*
 

Definition at line 155 of file lammpsplugin.c.

Referenced by find_item_keyword, find_next_item, and open_lammps_read.

#define KEY_ATOMS   "NUMBER OF ATOMS"
 

Definition at line 103 of file lammpsplugin.c.

Referenced by open_lammps_read, and read_lammps_timestep.

#define KEY_BOX   "BOX BOUNDS"
 

Definition at line 104 of file lammpsplugin.c.

Referenced by read_lammps_structure, and read_lammps_timestep.

#define KEY_DATA   "ATOMS"
 

Definition at line 105 of file lammpsplugin.c.

Referenced by read_lammps_structure, and read_lammps_timestep.

#define KEY_TIME   "TIME"
 

Definition at line 107 of file lammpsplugin.c.

Referenced by read_lammps_timestep.

#define KEY_TSTEP   "TIMESTEP"
 

Definition at line 106 of file lammpsplugin.c.

Referenced by read_lammps_timestep.

#define LAMMPS_COORD_DIPOLE   0x080U
 

Definition at line 118 of file lammpsplugin.c.

Referenced by read_lammps_structure, and read_lammps_timestep.

#define LAMMPS_COORD_FORCES   0x040U
 

Definition at line 117 of file lammpsplugin.c.

Referenced by read_lammps_structure.

#define LAMMPS_COORD_IMAGES   0x004U
 

Definition at line 113 of file lammpsplugin.c.

Referenced by read_lammps_structure, and read_lammps_timestep.

#define LAMMPS_COORD_NONE   0x000U
 

Definition at line 110 of file lammpsplugin.c.

Referenced by open_lammps_read, and read_lammps_structure.

#define LAMMPS_COORD_SCALED   0x002U
 

Definition at line 112 of file lammpsplugin.c.

Referenced by read_lammps_structure, and read_lammps_timestep.

#define LAMMPS_COORD_TRICLINIC   0x100U
 

Definition at line 119 of file lammpsplugin.c.

Referenced by read_lammps_structure, and read_lammps_timestep.

#define LAMMPS_COORD_UNKNOWN   0x010U
 

Definition at line 115 of file lammpsplugin.c.

Referenced by read_lammps_structure.

#define LAMMPS_COORD_UNWRAPPED   0x008U
 

Definition at line 114 of file lammpsplugin.c.

Referenced by read_lammps_structure, and read_lammps_timestep.

#define LAMMPS_COORD_VELOCITIES   0x020U
 

Definition at line 116 of file lammpsplugin.c.

Referenced by read_lammps_structure.

#define LAMMPS_COORD_WRAPPED   0x001U
 

Definition at line 111 of file lammpsplugin.c.

Referenced by read_lammps_structure, and read_lammps_timestep.

#define LAMMPS_DEBUG   0
 

Definition at line 82 of file lammpsplugin.c.

#define LAMMPS_MAX_NUM_FIELDS   64
 

flags to indicate the property stored in a custom lammps dump

Definition at line 122 of file lammpsplugin.c.

Referenced by read_lammps_structure.

#define LINE_LEN   1024
 

Definition at line 100 of file lammpsplugin.c.

Referenced by open_lammps_read, read_lammps_structure, and read_lammps_timestep.

#define M_PI_2   1.57079632679489661922
 

Definition at line 86 of file lammpsplugin.c.

Referenced by cosangle2deg, and write_lammps_timestep.

#define MAX A,
     ((A) > (B) ? (A) : (B))
 

Definition at line 93 of file lammpsplugin.c.

Referenced by read_lammps_timestep, and read_lammpsyaml_timestep.

#define MIN A,
     ((A) < (B) ? (A) : (B))
 

Definition at line 90 of file lammpsplugin.c.

Referenced by read_lammps_timestep, read_lammpsyaml_timestep, tpr_save_string, and write_situs_data.

#define myFclose   fclose
 

Definition at line 158 of file lammpsplugin.c.

Referenced by close_lammps_read, and close_lammpsyaml_read.

#define myFgets buf,
size,
fd       fgets(buf,size,fd)
 

Definition at line 159 of file lammpsplugin.c.

Referenced by find_next_item, open_lammps_read, open_lammpsyaml_read, read_lammps_structure, read_lammps_timestep, read_lammpsyaml_structure, and read_lammpsyaml_timestep.

#define myFopen   fopen
 

Definition at line 157 of file lammpsplugin.c.

Referenced by open_lammps_read, and open_lammpsyaml_read.

#define myFprintf   fprintf
 

Definition at line 156 of file lammpsplugin.c.

#define myRewind   rewind
 

Definition at line 160 of file lammpsplugin.c.

Referenced by open_lammps_read, open_lammpsyaml_read, read_lammps_structure, and read_lammpsyaml_structure.

#define SMALL   1.0e-12f
 

Definition at line 97 of file lammpsplugin.c.

Referenced by write_lammps_timestep.

#define THISPLUGIN   plugin
 

Definition at line 74 of file lammpsplugin.c.

#define VMDPLUGIN_STATIC
 

Definition at line 77 of file lammpsplugin.c.


Typedef Documentation

typedef enum lammps_attribute l_attr_t
 

Definition at line 143 of file lammpsplugin.c.


Enumeration Type Documentation

enum lammps_attribute
 

Enumeration values:
LAMMPS_FIELD_UNKNOWN 
LAMMPS_FIELD_ATOMID 
LAMMPS_FIELD_MOLID 
LAMMPS_FIELD_TYPE 
LAMMPS_FIELD_POSX 
LAMMPS_FIELD_POSY 
LAMMPS_FIELD_POSZ 
LAMMPS_FIELD_POSXS 
LAMMPS_FIELD_POSYS 
LAMMPS_FIELD_POSZS 
LAMMPS_FIELD_POSXU 
LAMMPS_FIELD_POSYU 
LAMMPS_FIELD_POSZU 
LAMMPS_FIELD_POSXSU 
LAMMPS_FIELD_POSYSU 
LAMMPS_FIELD_POSZSU 
LAMMPS_FIELD_IMGX 
LAMMPS_FIELD_IMGY 
LAMMPS_FIELD_IMGZ 
LAMMPS_FIELD_VELX 
LAMMPS_FIELD_VELY 
LAMMPS_FIELD_VELZ 
LAMMPS_FIELD_FORX 
LAMMPS_FIELD_FORY 
LAMMPS_FIELD_FORZ 
LAMMPS_FIELD_CHARGE 
LAMMPS_FIELD_RADIUS 
LAMMPS_FIELD_DIAMETER 
LAMMPS_FIELD_ELEMENT 
LAMMPS_FIELD_MASS 
LAMMPS_FIELD_QUATW 
LAMMPS_FIELD_QUATI 
LAMMPS_FIELD_QUATJ 
LAMMPS_FIELD_QUATK 
LAMMPS_FIELD_MUX 
LAMMPS_FIELD_MUY 
LAMMPS_FIELD_MUZ 
LAMMPS_FIELD_USER0 
LAMMPS_FIELD_USER1 
LAMMPS_FIELD_USER2 
LAMMPS_FIELD_USER3 
LAMMPS_FIELD_USER4 
LAMMPS_FIELD_USER5 
LAMMPS_FIELD_USER6 
LAMMPS_FIELD_USER7 
LAMMPS_FIELD_USER8 
LAMMPS_FILED_USER9 

Definition at line 123 of file lammpsplugin.c.


Function Documentation

void close_lammps_read void *    mydata [static]
 

Definition at line 1410 of file lammpsplugin.c.

References lammpsdata::file, lammpsdata::file_name, lammpsdata::idmap, inthash_destroy, inthash_stats, and myFclose.

Referenced by VMDPLUGIN_init.

void close_lammps_write void *    mydata [static]
 

Definition at line 1597 of file lammpsplugin.c.

References lammpsdata::atomtypes, lammpsdata::file_name, and lammpsdata::fp.

Referenced by VMDPLUGIN_init.

float cosangle2deg double    val [static]
 

Definition at line 989 of file lammpsplugin.c.

References M_PI_2.

char* find_item_keyword FileDesc    fd,
const char *    keyword,
char *    linebuf,
int    buflen
[static]
 

Scan the file for the next occurence of a record of the type given in keyword. If such a record is found, the file descriptor points to the beginning of the record content, and this function returns a pointer to the remainder of the line (EOL character or or additional data). otherwise a NULL pointer is returned. a pointer to a line buffer and its length have to be given. the return value will point to some location inside this buffer.

Definition at line 329 of file lammpsplugin.c.

References FileDesc, and find_next_item.

char* find_next_item FileDesc    fd,
char *    linebuf,
int    buflen
[static]
 

Scan the file for the next line beginning with the string "ITEM: " and returns a string containing the remainder of that line or NULL. Upon return, the file descriptor points either to the beginning of the next line or at the first character that didn't fit into the buffer (linebuf[buflen]).

Definition at line 301 of file lammpsplugin.c.

References FileDesc, and myFgets.

void id_merge int *    output,
int *    left,
int    nl,
int *    right,
int    nr
[static]
 

Definition at line 187 of file lammpsplugin.c.

void id_sort int *    idmap,
int    num
[static]
 

Definition at line 204 of file lammpsplugin.c.

References id_merge.

void* open_lammps_read const char *    filename,
const char *    filetype,
int *    natoms
[static]
 

Definition at line 363 of file lammpsplugin.c.

References lammpsdata::coord_data, lammpsdata::dip2atoms, lammpsdata::dumx, lammpsdata::dumy, lammpsdata::dumz, lammpsdata::fieldinit, lammpsdata::file, lammpsdata::file_name, FileDesc, find_item_keyword, KEY_ATOMS, LAMMPS_COORD_NONE, LINE_LEN, lammpsdata::maxatoms, myFgets, myFopen, myRewind, lammpsdata::numatoms, velinfo, and VMDCON_INFO.

Referenced by VMDPLUGIN_init.

void* open_lammps_write const char *    filename,
const char *    filetype,
int    natoms
[static]
 

Definition at line 1425 of file lammpsplugin.c.

References lammpsdata::file_name, lammpsdata::fp, lammpsdata::nstep, and lammpsdata::numatoms.

Referenced by VMDPLUGIN_init.

int read_lammps_structure void *    mydata,
int *    optflags,
molfile_atom_t   atoms
[static]
 

Definition at line 450 of file lammpsplugin.c.

References molfile_atom_t::atomicnumber, molfile_atom_t::bfactor, molfile_atom_t::chain, molfile_atom_t::charge, lammpsdata::coord_data, lammpsdata::dip2atoms, lammpsdata::field, lammpsdata::fieldinit, lammpsdata::file, lammpsdata::file_name, find_item_keyword, get_pte_idx, get_pte_mass, get_pte_vdw_radius, id_sort, lammpsdata::idmap, inthash_init, inthash_insert, inthash_lookup, KEY_BOX, KEY_DATA, LAMMPS_COORD_DIPOLE, LAMMPS_COORD_FORCES, LAMMPS_COORD_IMAGES, LAMMPS_COORD_NONE, LAMMPS_COORD_SCALED, LAMMPS_COORD_TRICLINIC, LAMMPS_COORD_UNKNOWN, LAMMPS_COORD_UNWRAPPED, LAMMPS_COORD_VELOCITIES, LAMMPS_COORD_WRAPPED, LAMMPS_FIELD_ATOMID, LAMMPS_FIELD_CHARGE, LAMMPS_FIELD_DIAMETER, LAMMPS_FIELD_ELEMENT, LAMMPS_FIELD_FORX, LAMMPS_FIELD_FORY, LAMMPS_FIELD_FORZ, LAMMPS_FIELD_IMGX, LAMMPS_FIELD_IMGY, LAMMPS_FIELD_IMGZ, LAMMPS_FIELD_MASS, LAMMPS_FIELD_MOLID, LAMMPS_FIELD_MUX, LAMMPS_FIELD_MUY, LAMMPS_FIELD_MUZ, LAMMPS_FIELD_POSX, LAMMPS_FIELD_POSXS, LAMMPS_FIELD_POSXU, LAMMPS_FIELD_POSY, LAMMPS_FIELD_POSYS, LAMMPS_FIELD_POSYU, LAMMPS_FIELD_POSZ, LAMMPS_FIELD_POSZS, LAMMPS_FIELD_POSZU, LAMMPS_FIELD_RADIUS, LAMMPS_FIELD_TYPE, LAMMPS_FIELD_UNKNOWN, LAMMPS_FIELD_VELX, LAMMPS_FIELD_VELY, LAMMPS_FIELD_VELZ, LAMMPS_MAX_NUM_FIELDS, LINE_LEN, molfile_atom_t::mass, lammpsdata::maxatoms, MOLFILE_ATOMICNUMBER, MOLFILE_CHARGE, MOLFILE_ERROR, MOLFILE_MASS, MOLFILE_NOOPTIONS, MOLFILE_RADIUS, myFgets, myRewind, molfile_atom_t::name, lammpsdata::numatoms, lammpsdata::numfields, molfile_atom_t::occupancy, molfile_atom_t::radius, remap_field, molfile_atom_t::resid, molfile_atom_t::resname, molfile_atom_t::segid, molfile_atom_t::type, and VMDCON_INFO.

Referenced by read_lammps_timestep, and VMDPLUGIN_init.

int read_lammps_timestep void *    mydata,
int    natoms,
molfile_timestep_t   ts
[static]
 

Definition at line 996 of file lammpsplugin.c.

References molfile_timestep_t::A, molfile_timestep_t::alpha, molfile_timestep_t::B, molfile_timestep_t::beta, molfile_timestep_t::C, lammpsdata::coord_data, molfile_timestep_t::coords, cosangle2deg, lammpsdata::dip2atoms, lammpsdata::dumx, lammpsdata::dumy, lammpsdata::dumz, lammpsdata::field, lammpsdata::fieldinit, lammpsdata::file, lammpsdata::file_name, find_item_keyword, find_next_item, molfile_timestep_t::gamma, lammpsdata::idmap, inthash_entries, inthash_insert, inthash_lookup, KEY_ATOMS, KEY_BOX, KEY_DATA, KEY_TIME, KEY_TSTEP, LAMMPS_COORD_DIPOLE, LAMMPS_COORD_IMAGES, LAMMPS_COORD_SCALED, LAMMPS_COORD_TRICLINIC, LAMMPS_COORD_UNWRAPPED, LAMMPS_COORD_WRAPPED, LAMMPS_FIELD_ATOMID, LAMMPS_FIELD_IMGX, LAMMPS_FIELD_IMGY, LAMMPS_FIELD_IMGZ, LAMMPS_FIELD_MUX, LAMMPS_FIELD_MUY, LAMMPS_FIELD_MUZ, LAMMPS_FIELD_POSX, LAMMPS_FIELD_POSXS, LAMMPS_FIELD_POSXU, LAMMPS_FIELD_POSY, LAMMPS_FIELD_POSYS, LAMMPS_FIELD_POSYU, LAMMPS_FIELD_POSZ, LAMMPS_FIELD_POSZS, LAMMPS_FIELD_POSZU, LAMMPS_FIELD_VELX, LAMMPS_FIELD_VELY, LAMMPS_FIELD_VELZ, LINE_LEN, MAX, lammpsdata::maxatoms, MIN, MOLFILE_ERROR, myFgets, lammpsdata::numatoms, lammpsdata::numfields, molfile_timestep_t::physical_time, read_lammps_structure, and molfile_timestep_t::velocities.

Referenced by VMDPLUGIN_init.

const char* remap_field const char *    tag,
const char *    list
[static]
 

Check a token against a list of equivalences. The list has the format "toka=tok1,tokb=tok2,tokc=tok3" and is split in pairs "toka=tok1" and then if "tok1" matches, toka will be returned. The first match or tag is returned.

Definition at line 228 of file lammpsplugin.c.

VMDPLUGIN_API int VMDPLUGIN_fini void   
 

Definition at line 1645 of file lammpsplugin.c.

References VMDPLUGIN_API, and VMDPLUGIN_SUCCESS.

VMDPLUGIN_API int VMDPLUGIN_init void   
 

Definition at line 1610 of file lammpsplugin.c.

References molfile_plugin_t::close_file_read, molfile_plugin_t::close_file_write, close_lammps_read, close_lammps_write, molfile_plugin_t::filename_extension, MOLFILE_PLUGIN_TYPE, molfile_plugin_t::open_file_read, molfile_plugin_t::open_file_write, open_lammps_read, open_lammps_write, read_lammps_structure, read_lammps_timestep, molfile_plugin_t::read_next_timestep, molfile_plugin_t::read_structure, molfile_plugin_t::read_timestep_metadata, vmdplugin_ABIVERSION, VMDPLUGIN_API, VMDPLUGIN_SUCCESS, VMDPLUGIN_THREADUNSAFE, write_lammps_structure, write_lammps_timestep, molfile_plugin_t::write_structure, and molfile_plugin_t::write_timestep.

VMDPLUGIN_API int VMDPLUGIN_register void *    v,
vmdplugin_register_cb    cb
 

Definition at line 1640 of file lammpsplugin.c.

References VMDPLUGIN_API, vmdplugin_register_cb, and VMDPLUGIN_SUCCESS.

int write_lammps_structure void *    mydata,
int    optflags,
const molfile_atom_t   atoms
[static]
 

Definition at line 1445 of file lammpsplugin.c.

References lammpsdata::atomtypes, hash_destroy, hash_init, hash_insert, hash_lookup, and lammpsdata::numatoms.

Referenced by VMDPLUGIN_init.

int write_lammps_timestep void *    mydata,
const molfile_timestep_t   ts
[static]
 

Definition at line 1468 of file lammpsplugin.c.

References molfile_timestep_t::A, molfile_timestep_t::alpha, lammpsdata::atomtypes, molfile_timestep_t::B, molfile_timestep_t::beta, molfile_timestep_t::C, molfile_timestep_t::coords, lammpsdata::fp, molfile_timestep_t::gamma, M_PI_2, lammpsdata::nstep, lammpsdata::numatoms, and SMALL.

Referenced by VMDPLUGIN_init.


Variable Documentation

molfile_plugin_t plugin [static]
 

Definition at line 1608 of file lammpsplugin.c.

int velinfo = 1 [static]
 

Definition at line 184 of file lammpsplugin.c.

Referenced by open_lammps_read.


Generated on Sat Oct 12 03:09:16 2024 for VMD Plugins (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002