sampledoc

Particle Class API

Class data structures for atomic data

class particles.Particle(pos=[0.0, 0.0, 0.0], type='blank', charge=0.0, mass=1.0)[source]

Data structure for describing any localized object in QM/MD simulations A ‘Particle’ has a position and type specifiers

Note, for an object p1 of Particle type
p1.__dict__ returns a dictionary of all class members

Current use cases include: atoms, united-atoms and ‘beads’

Possible tags: ELN = [], ASYMB = [], CTYPE = [], CHARGES = [], R = [], VEL = []
ATYPE = [], AMASS = [], MOLNUMB = [], RING_NUMB = [], RESID = [], RESN = [], CHARN = [], UNITNUMB = [], UNITTYPE = []
isTagEqualTo(key, valList)[source]

Check if tags[key]= any of the values in valList. Exits if key not in dictionary

Args:
key dictionary key valList (list) dictionary values

Returns: true if tagsDict[key]=value for any value in valueList

setTagsDict(td)[source]

Define custom dictionary for id tags (eg {“molnum”:1,}) Leaving type tag as a default

Args:
td (dictionary)
class particles.ParticleContainer(idList=[], verbose=False)[source]

Main data structure for holding Particle objects. Map of global particle ID (integer) to Particle object instances

dump(filePrefix)[source]

Dump a pickled version of this object

Args:
filePrefix (str): name of pickle file. will dump filePrefix.pkl
getParticlesWithTags(searchDict)[source]

Return particles whose dictionary tags match all specified key,values The search dictionary criteria is that ALL key,value pairs must match (the logic is {key1:value1} AND {key2:value2}.....

Args:
searchDict (dict) dictionary of search pairs {keyTag:valTag}....

Returns: list of particle gid’s that satisfy search

getTypeInfoDict()[source]

Return a map of type to (typeIndex, mass, charge) Method assigns a type index and checkes for consistency

Returns:
dictionary of {type:[typeIndex, mass, charge], ....}
put(ptcl)[source]

Append ‘Particle’ object to this container. Updates globalID for container by incrementing the maxgid member. Performs deep copy of ptcl so container is managing memory

Args:
ptcl (Particle) correctly initialized Particle object
NOTE:
  1. One can imagine extra conditions on distances between ptcl being inserted and current particles.
  2. This could check for uniqueness of all globalID’s and throw error for copies
replaceID(findID, newID)[source]

Replace global particle ID with another value. Attempts to make rational checks about new IDs

Args:
findGID (int) ptcl ID to search newGID (int) ptcl ID to replace findGID with
Returns:
Errors if
  • findGID not found
  • newGID already present
scatterPlot()[source]

Generate a scatter plot of particle positions