ipymd package

Subpackages

Submodules

ipymd.atom_manipulation module

Created on Mon May 16 08:15:13 2016

@author: cjs14

class ipymd.atom_manipulation.Atom_Manipulation(atom_df, meta_series=None, undos=1)[source]

Bases: object

a class to manipulate atom data

atom_df : pandas.DataFrame
containing columns; x, y, z, type
meta_series : pandas.Series
containing columns; origin, a, b, c to define unit cell if none it will be constructed from the min/max x, y, z values
undos : int
number of past dataframes to save
apply_map(vmap, column, default=False, type_col='type')[source]

change values in a column, according to a mapping of another column

vmap : dict or str
A dictionary mapping values, or a string associated with a column in the ipymd.shared.atom_data() dataframe (e.g. color and RVdW)
column : str
the column to change
default : various
the default value to put when the type key cannot be found, if False then the original value will not be overwritten
change_type_variable(atom_type, variable, value, type_col='type')[source]

change particular variable for one atom type

change_variables(map_dict, vtype='type')[source]

change particular variables according to the map_dict

color_by_categories(colname, cmap='jet', sort=True)[source]

change colors to map

colname : string
a column of the dataframe that contains categories by which to color
cmap : string
the colormap to apply, see available at http://matplotlib.org/examples/color/colormaps_reference.html
color_by_index(cmap='jet', minv=None, maxv=None)[source]

change colors to map index values

cmap : string
the colormap to apply, see available at http://matplotlib.org/examples/color/colormaps_reference.html
minv, maxv : float
optional min, max cmap value, otherwise take min, max value found in column
color_by_variable(colname, cmap='jet', minv=None, maxv=None)[source]

change colors to map

colname : string
a coloumn of the dataframe that contains numbers by which to color
cmap : string
the colormap to apply, see available at http://matplotlib.org/examples/color/colormaps_reference.html
minv, maxv : float
optional min, max cmap value, otherwise take min, max value found in column
df
filter_inside_box(vectors, origin=<Mock object>)[source]

return only atoms inside box

vectors : np.array((3,3))
a, b, c vectors

origin : np.array((1,3))

filter_inside_hexagon(vectors, origin=<Mock object>)[source]

return only atoms inside hexagonal prism

vectors : np.array((2,3))
a, c vectors

origin : np.array((1,3))

filter_inside_pts(points)[source]

return only atoms inside the bounding shape of a set of points

points : np.array((N,3))

filter_variables(values, vtype='type')[source]
group_atoms_as_mols(atom_ids, name, remove_atoms=True, mean_xyz=True, color='red', transparency=1.0, radius=1.0)[source]

combine atoms into a molecule atom_ids : list of lists

list of dataframe indexes for each molecule
name : string
name of molecule
remove_atoms : bool
remove the grouped atoms from the dataframe
mean_xyz : bool
use the mean coordinate of atoms for molecule, otherwise use coordinate of first atom
meta
repeat_cell(a=1, b=1, c=1, original_first=False)[source]

repeat atoms along a, b, c directions (and update unit cell)

a : int or tuple
repeats in ‘a’ direction, if tuple then defines repeats in -/+ direction
b : int or tuple
repeats in ‘b’ direction, if tuple then defines repeats in -/+ direction
c : int or tuple
repeats in ‘c’ direction, if tuple then defines repeats in -/+ direction
original_first: bool
if True, the original atoms will be first in the DataFrame
revert_to_original()[source]

revert to original atom_df

rotate(angle, vector=[1, 0, 0], update_uc=True)[source]

rotate the clockwise about the given axis vector by theta degrees.

e.g. for rotate_atoms(90,[0,0,1]); [0,1,0] -> [1,0,0]

angle : float
rotation angle in degrees
vector : iterable
vector to rotate around [x0,y0,z0]
update_uc : bool
update unit cell (a,b,c,origin) to match rotation
slice_absolute(amin=0, amax=None, bmin=0, bmax=None, cmin=0, cmax=None, incl_max=False, update_uc=True, delta=0.01)[source]

slice along a,b,c directions (from origin) given absolute vector length

if amax, bmax or cmax is None, then will use the vector length

update_uc : bool
update unit cell (a,b,c,origin) to match slice
incl_max : bool
whether to slice < (False) <= (True) max values
delta : float
retain atoms within ‘delta’ fraction outside of slice plane)
slice_fraction(amin=0, amax=1, bmin=0, bmax=1, cmin=0, cmax=1, incl_max=False, update_uc=True, delta=0.01)[source]

slice along a,b,c directions (from origin) as fraction of vector length

incl_max : bool
whether to slice < (False) <= (True) max values
update_uc : bool
update unit cell (a,b,c,origin) to match slice
delta : float
retain atoms within ‘delta’ fraction outside of slice plane)
translate(vector, update_uc=True)[source]

translate atoms by vector

vector : list
x, y, z translation
update_uc : bool
update unit cell (a,b,c,origin) to match translation
undo_last()[source]

ipymd.data_output module

Created on Mon May 23 17:55:14 2016

@author: cjs14

class ipymd.data_output.Data_Output(atom_df, abc, origin=<Mock object>)[source]

Bases: object

save_lammps(outpath='out.lammps', overwrite=False, atom_type='atomic', header='', mass_map={})[source]

to adhere to http://lammps.sandia.gov/doc/read_data.html?highlight=read_data

Parameters:
  • outpath (string) – the output file name
  • overwrite (bool) – whether to raise an error if the file already exists
  • atom_type (str) – the lammps atom style, currently supports atomic or charge
  • header (str) – text to put in the header
  • mass_map (dict) – a mapping of atom types to mass

Example

In [1]: import pandas as pd In [2]: df = pd.DataFrame([[‘Fe’,2,3,4,1],

[‘Cr’,2,3,3,-1], [‘Fe’,4,3,1,1]],columns=[‘type’,’xs’,’ys’,’zs’,’q’])

In [3]: from ipymd.data_output import Data_Output as data_out In [4]: data = data_out(df, [[1,0,0],[0,1,0],[0,0,1]]) In [5]: data.save_lammps(‘test.lammps’, atom_type=’charge’, overwrite=True,

header=’my header’)

In [6]: cat test.lammps # This file was created by ipymd (v0.0.1) on 2016-05-23 20:51:16 # type map: {‘Cr’: 2, ‘Fe’: 1} # my header

3 atoms 2 atom types

# simulation box boundaries 0.0000 1.0000 xlo xhi 0.0000 1.0000 ylo yhi 0.0000 1.0000 zlo zhi 0.0000 0.0000 0.0000 xy xz yz

Atoms

1 1 1.0000 2.0000 3.0000 4.0000 2 2 -1.0000 2.0000 3.0000 3.0000 3 1 1.0000 4.0000 3.0000 1.0000

Module contents

Created on Sun May 1 22:46:22 2016

@author: cjs14

ipymd.version()[source]