ppafm.io#
- ppafm.io.limit_vec_field(FF, Fmax=100.0)[source]#
remove too large values; preserves direction of vectors.
- Parameters:
FF – np.array of shape(nz, ny, nx, 3) with volumetric (vector data) we want to be limited.
Fmax – float maximum value to which all the larger values will be lowered to.
- ppafm.io.loadNpy(fname)[source]#
Function for loading scalar grid data, together with its lattice_vector and information about original atoms and the original lattice vector (lvec0) in numpy format
- Parameters:
fname – str. name of the npz file. fname should be without the npz expension, which is added by this function.
- Returns:
data – np.array of shape(nz, ny, nx) with volumetric (scaler data) we want to save
lvec – np.array of shape(4,3) with lattice vector of the volumetric data
atomic_info tuple of shape (2) with 2 np.arrays - one is np.array([e,x,y,z]) with atoms positions and the second one is np.array(lvec0) of shape (4,3)
- ppafm.io.loadXYZ(fname)[source]#
Read the contents of an xyz file.
The standard xyz file format only has per-atom elements and xyz positions. However, in ppafm we also use per-atom charges, which can be written as an extra column into the xyz file. By default the fifth column is interpreted as the charges, but if the file is written in the extended xyz format used by ASE, the relevant column indicated in the comment line is used.
- Parameters:
fname – str. Path to file.
- Returns:
xyzs – np.ndarray of shape (N_atoms, 3). Atom xyz positions.
Zs – np.ndarray of shape (N_atoms,). Atomic numbers.
qs – np.ndarray of shape (N_atoms). Per-atom charges. All zeros if no charges are present in the file.
comment – str. The contents of the second line of the xyz file.
- ppafm.io.load_scal_field(fname, data_format='xsf')[source]#
Loading Vector fields from xsf, or npy
- Parameters:
fname – str. name of the npz or xsf file. fname should be without any extension, which is added later automatically based on the format (data_format).
data_fromat – str “xsf” or “npy”
- Returns:
data – np.array of shape(nz, ny, nx) with volumetric (scalar data) we want to load.
lvec – np.array of shape(4,3) with lattice vector of the volumetric data.
atomic_info_or_head – tuple or string. If tupple then shape (2) with 2 np.arrays, one is np.array([e,x,y,z]) with atoms positions and the second one is np.array(lvec0) of shape (4,3) with saved information about lattice vector. if string, the same information is basically stored as the header of xsf
- ppafm.io.load_vec_field(fname, data_format='xsf')[source]#
Loading Vector fields from xsf, or npy
- Parameters:
fname – str. name of the npz or xsf file. fname should be without any extension, which is added later automatically based on the format (data_format).
data_fromat – str “xsf” or “npy”
- Returns:
data – np.array of shape(nz, ny, nx, 3) with volumetric (vector data) we want to load.
lvec – np.array of shape(4,3) with lattice vector of the volumetric data.
ndim – tupple of lenght 4 with dimmensions of the vector data.
atomic_info_or_head – tuple or string. If tupple then shape (2) with 2 np.arrays, one is np.array([e,x,y,z]) with atoms positions and the second one is np.array(lvec0) of shape (4,3) with saved information about lattice vector. if string, the same information is basically stored as the header of xsf
- ppafm.io.makePovCam(pos, up=[0.0, 1.0, 0.0], rg=[-1.0, 0.0, 0.0], fw=[0.0, 0.0, 100.0], lpos=[0.0, 0.0, -100.0], W=10.0, H=10.0)[source]#
- ppafm.io.parseLvecASE(comment)[source]#
Try to parse the lattice vectors in an xyz file comment line according to the extended xyz file format used by ASE. The origin is always at zero.
- Parameters:
comment – str. Comment line to parse.
- Returns:
lvec – np.array of shape (4, 3) or None. The found lattice vectors or None if the comment line does not match the extended xyz file format.
- ppafm.io.saveNpy(fname, data, lvec, atomic_info)[source]#
Function for saving scalar grid data, together with its lattice_vector and information about original atoms and the original lattice vector (lvec0) in numpy format
- Parameters:
fname – str. Path to file. fname should be without the npz expension, which is added by this function.
data – np.ndarray of shape (n_z, n_y, n_x) with scallar data
lvec – np.ndarray of shape (4, 3). Lattice vector of the data
atomic_info – tuple of shape (2). First part is [e, x, y, z] of atoms, the second is lvec of the atoms from the original geometry file, named as lvec0;
- ppafm.io.saveXSFData(fname, data, lvec=None, dd=None, head='\nATOMS\n 1 0.0 0.0 0.0\n\nBEGIN_BLOCK_DATAGRID_3D\n some_datagrid\n BEGIN_DATAGRID_3D_whatever\n', data_is_xyz_order=True)[source]#
- ppafm.io.saveXYZ(fname, xyzs, Zs, qs=None, comment='', append=False)[source]#
Save atom types, positions, and, (optionally) charges to an xyz file.
- Parameters:
fname – str. Path to file.
xyzs – np.ndarray of shape (N_atoms, 3). Atom xyz positions.
Zs – np.ndarray of shape (N_atoms,). Atom atomic numbers.
qs – np.ndarray of shape (N_atoms) or None. If not None, the partial charges of atoms written as the fifth column into the xyz file.
comment – str. Comment string written to the second line of the xyz file.
append – bool. Append to file instead of overwriting if it already exists. Useful for creating movies of changing structures.
- ppafm.io.save_scal_field(fname, data, lvec, data_format='xsf', head='\nATOMS\n 1 0.0 0.0 0.0\n\nBEGIN_BLOCK_DATAGRID_3D\n some_datagrid\n BEGIN_DATAGRID_3D_whatever\n', atomic_info=None)[source]#
Saving scalar fields into xsf, or npy
- Parameters:
fname – str. name of the npz or xsf file. fname should be without any extension, which is added later automatically based on the format (data_format).
data – np.array of shape(nz, ny, nx, 3) with volumetric (scalar data) we want to save.
lvec – np.array of shape(4,3) with lattice vector of the volumetric data.
data_format – str “xsf” or “npy”.
head – string header of the XSF file
atomic_info – tuple of shape (2) with 2 np.arrays - one is np.array([e,x,y,z]) with atoms positions and the second one is np.array(lvec) of shape (4,3) with saved information about lattice vector.
- ppafm.io.save_vec_field(fname, data, lvec, data_format='xsf', head='\nATOMS\n 1 0.0 0.0 0.0\n\nBEGIN_BLOCK_DATAGRID_3D\n some_datagrid\n BEGIN_DATAGRID_3D_whatever\n', atomic_info=None)[source]#
Saving vector fields into xsf, or npy
- Parameters:
fname – str. name of the npz or xsf file. fname should be without any extension, which is added later automatically based on the format (data_format).
data – np.array of shape(nz, ny, nx, 3) with volumetric (vector data) we want to save; note [:,:,:,0] are x part, [:,:,:,1] is the y part and [:,:,:,2] is the z part of the vector
lvec – np.array of shape (4,3) with lattice vector of the volumetric data
data_format – string “xsf” or “npy”
head – string header of the XSF file
atomic_info – tuple of shape (2) with 2 np.arrays - one is np.array([e,x,y,z]) with atoms positions and the second one is np.array(lvec) of shape (4,3) with saved information about lattice vector.
- ppafm.io.writePov(fname, xyzs, Zs, bonds=None, HEAD='\n// ***********************************************\n// Camera & other global settings\n// ***********************************************\n#declare Zoom = 30.0;\n#declare Width = 800;\n#declare Height = 800;\ncamera{\n orthographic\n location < 0, 0, -100>\n sky < 0, -1, 0 >\n right < -Zoom, 0, 0>\n up < 0, Zoom, 0 >\n look_at < .0.0, 0.0, 0.0 >\n}\n\nbackground { color rgb <1.0,1.0,1.0> }\n//background { color rgb <0.5,0.5,0.5> }\n//global_settings { ambient_light rgb< 0.2, 0.2, 0.2> }\n// ***********************************************\n// macros for common shapes\n// ***********************************************\n#default { finish {\n ambient 0.45\n diffuse 0.84\n specular 0.22\n roughness .00001\n metallic\n phong 0.9\n phong_size 120\n}\n}\n#macro translucentFinish(T)\n finish {\n ambient 0.45\n diffuse 0.84\n specular 0.22\n roughness .00001\n metallic 1.0\n phong 0.9\n phong_size 120\n}#end\n#macro a(X,Y,Z,RADIUS,R,G,B,T)\n sphere{<X,Y,Z>,RADIUS\n pigment{rgbt<R,G,B,T>}\n translucentFinish(T)\n no_shadow // comment this out if you want include shadows\n }\n#end\n#macro b(X1,Y1,Z1,RADIUS1,X2,Y2,Z2,RADIUS2,R,G,B,T)\n cone{<X1,Y1,Z1>,RADIUS1,<X2,Y2,Z2>,RADIUS2\n pigment{rgbt<R,G,B,T> }\n translucentFinish(T)\n no_shadow // comment this out if you want include shadows\n }\n#end\n', bondw=0.1, spherescale=0.25, ELEMENTS=[[1, 'H', 1, 1, 'S', 'Hydrogen', 0.365, 1.487, (255, 255, 255), 1], [2, 'He', 1, 0, '0', 'Helium', 0.32, 1.481, (217, 255, 255), 2], [3, 'Li', 2, 1, 'S', 'Lithium', 1.395, 2.0, (204, 128, 255), 1], [4, 'Be', 2, 2, 'S', 'Beryllium', 0.975, 2.0, (194, 255, 0), 2], [5, 'B', 2, 3, 'P', 'Boron', 0.835, 2.08, (255, 181, 181), 3], [6, 'C', 2, 4, 'P', 'Carbon', 0.735, 1.908, (144, 144, 144), 4], [7, 'N', 2, 5, 'P', 'Nitrogen', 0.7, 1.78, (48, 80, 248), 5], [8, 'O', 2, 6, 'P', 'Oxygen', 0.665, 1.661, (255, 13, 13), 6], [9, 'F', 2, 7, 'P', 'Fluorine', 0.605, 1.75, (144, 224, 80), 7], [10, 'Ne', 2, 0, '0', 'Neon', 0.69, 1.543, (179, 227, 245), 8], [11, 'Na', 3, 1, 'S', 'Sodium', 1.67, 2.77, (171, 92, 242), 1], [12, 'Mg', 3, 2, 'S', 'Magnesium', 1.4, 2.42, (138, 255, 0), 2], [13, 'Al', 3, 3, 'P', 'Aluminium', 1.215, 2.4, (191, 166, 166), 3], [14, 'Si', 3, 4, 'P', 'Silicon', 1.105, 1.9, (240, 200, 160), 4], [15, 'P', 3, 5, 'P', 'Phosphorus', 1.03, 2.1, (255, 128, 0), 5], [16, 'S', 3, 6, 'P', 'Sulfur', 1.01, 2.0, (255, 255, 48), 6], [17, 'Cl', 3, 7, 'P', 'Chlorine', 0.995, 1.948, (31, 240, 31), 7], [18, 'Ar', 3, 0, '0', 'Argon', 0.84, 1.88, (128, 209, 227), 8], [19, 'K', 4, 1, 'S', 'Potassium', 2.08, 3.02, (143, 64, 212), 1], [20, 'Ca', 4, 2, 'S', 'Calcium', 1.77, 2.78, (250, 150, 0), 2], [21, 'Sc', 4, 3, 'D', 'Scandium', 1.52, 2.62, (230, 230, 230), 3], [22, 'Ti', 4, 4, 'D', 'Titanium', 1.38, 2.44, (191, 194, 199), 4], [23, 'V', 4, 5, 'D', 'Vanadium', 1.3, 2.27, (166, 166, 171), 5], [24, 'Cr', 4, 6, 'D', 'Chromium', 1.335, 2.23, (138, 153, 199), 6], [25, 'Mn', 4, 7, 'D', 'Manganese', 1.395, 2.25, (156, 122, 199), 7], [26, 'Fe', 4, 8, 'D', 'Iron', 1.325, 2.27, (224, 102, 51), 8], [27, 'Co', 4, 9, 'D', 'Cobalt', 1.305, 2.25, (240, 144, 160), 9], [28, 'Ni', 4, 10, 'D', 'Nickel', 1.28, 2.23, (80, 208, 80), 0], [29, 'Cu', 4, 1, 'D', 'Copper', 1.365, 2.23, (200, 128, 51), 0], [30, 'Zn', 4, 2, 'D', 'Zinc', 1.33, 2.24, (125, 128, 176), 0], [31, 'Ga', 4, 3, 'P', 'Gallium', 1.28, 2.41, (194, 143, 143), 0], [32, 'Ge', 4, 4, 'P', 'Germanium', 1.235, 2.32, (102, 143, 143), 0], [33, 'As', 4, 5, 'P', 'Arsenic', 1.17, 2.25, (189, 128, 227), 0], [34, 'Se', 4, 6, 'P', 'Selenium', 1.155, 2.18, (255, 161, 0), 0], [35, 'Br', 4, 7, 'P', 'Bromine', 1.145, 2.22, (166, 41, 41), 0], [36, 'Kr', 4, 0, '0', 'Krypton', 1.1, 2.0, (92, 184, 209), 0], [37, 'Rb', 5, 1, 'S', 'Rubidium', 2.23, 3.15, (112, 46, 176), 0], [38, 'Sr', 5, 2, 'S', 'Strontium', 1.96, 2.94, (0, 255, 0), 0], [39, 'Y', 5, 3, 'D', 'Yttrium', 1.71, 2.71, (148, 255, 255), 0], [40, 'Zr', 5, 4, 'D', 'Zirconium', 1.515, 2.57, (148, 224, 224), 0], [41, 'Nb', 5, 5, 'D', 'Niobium', 1.41, 2.46, (115, 194, 201), 0], [42, 'Mo', 5, 6, 'D', 'Molybdenum', 1.45, 2.39, (84, 181, 181), 0], [43, 'Tc', 5, 7, 'D', 'Technetium', 1.455, 2.37, (59, 158, 158), 0], [44, 'Ru', 5, 8, 'D', 'Ruthenium', 1.28, 2.35, (36, 143, 143), 0], [45, 'Rh', 5, 9, 'D', 'Rhodium', 1.35, 2.32, (10, 125, 140), 0], [46, 'Pd', 5, 10, 'D', 'Palladium', 1.355, 2.35, (0, 105, 133), 0], [47, 'Ag', 5, 1, 'D', 'Silver', 1.565, 2.37, (192, 192, 192), 0], [48, 'Cd', 5, 2, 'D', 'Cadmium', 1.515, 2.37, (255, 217, 143), 0], [49, 'In', 5, 3, 'P', 'Indium', 1.495, 2.53, (166, 117, 115), 0], [50, 'Sn', 5, 4, 'P', 'Tin', 1.43, 2.46, (102, 128, 128), 0], [51, 'Sb', 5, 5, 'P', 'Antimony', 1.415, 2.41, (158, 99, 181), 0], [52, 'Te', 5, 6, 'P', 'Tellurium', 1.375, 2.36, (212, 122, 0), 0], [53, 'I', 5, 7, 'P', 'Iodine', 1.365, 2.35, (148, 0, 148), 0], [54, 'Xe', 5, 0, '0', 'Xenon', 1.3, 2.181, (66, 158, 176), 0], [55, 'Cs', 6, 1, 'S', 'Caesium', 2.425, 3.3, (87, 23, 143), 0], [56, 'Ba', 6, 2, 'S', 'Barium', 2.065, 3.05, (0, 201, 0), 0], [57, 'La', 6, 3, 'F', 'Lanthanum', 1.82, 2.81, (112, 212, 255), 0], [58, 'Ce', 6, 4, 'F', 'Cerium', 1.85, 2.0, (255, 255, 199), 0], [59, 'Pr', 6, 5, 'F', 'Praseodymium', 1.85, 2.0, (217, 255, 199), 0], [60, 'Nd', 6, 6, 'F', 'Neodymium', 1.85, 2.0, (199, 255, 199), 0], [61, 'Pm', 6, 7, 'F', 'Promethium', 1.85, 2.0, (163, 255, 199), 0], [62, 'Sm', 6, 8, 'F', 'Samarium', 1.85, 2.0, (143, 255, 199), 0], [63, 'Eu', 6, 9, 'F', 'Europium', 1.85, 2.0, (97, 255, 199), 0], [64, 'Gd', 6, 10, 'F', 'Gadolinium', 1.8, 2.0, (69, 255, 199), 0], [65, 'Tb', 6, 11, 'F', 'Terbium', 1.75, 2.0, (48, 255, 199), 0], [66, 'Dy', 6, 12, 'F', 'Dysprosium', 1.75, 2.0, (31, 255, 199), 0], [67, 'Ho', 6, 13, 'F', 'Holmium', 1.75, 2.0, (0, 255, 156), 0], [68, 'Er', 6, 14, 'F', 'Erbium', 1.75, 2.0, (0, 230, 117), 0], [69, 'Tm', 6, 1, 'F', 'Thulium', 1.75, 2.0, (0, 212, 82), 0], [70, 'Yb', 6, 2, 'F', 'Ytterbium', 1.75, 2.0, (0, 191, 56), 0], [71, 'Lu', 6, 3, 'D', 'Lutetium', 1.675, 2.0, (0, 171, 36), 0], [72, 'Hf', 6, 4, 'D', 'Hafnium', 1.525, 2.52, (77, 194, 255), 0], [73, 'Ta', 6, 5, 'D', 'Tantalum', 1.415, 2.42, (77, 166, 255), 0], [74, 'W', 6, 6, 'D', 'Tungsten', 1.405, 2.36, (33, 148, 214), 0], [75, 'Re', 6, 7, 'D', 'Rhenium', 1.47, 2.35, (38, 125, 171), 0], [76, 'Os', 6, 8, 'D', 'Osmium', 1.29, 2.33, (38, 102, 150), 0], [77, 'Ir', 6, 9, 'D', 'Iridium', 1.36, 2.34, (23, 84, 135), 0], [78, 'Pt', 6, 10, 'D', 'Platinum', 1.315, 2.37, (208, 208, 224), 0], [79, 'Au', 6, 1, 'D', 'Gold', 1.395, 2.41, (255, 209, 35), 0], [80, 'Hg', 6, 2, 'D', 'Mercury', 1.495, 2.25, (184, 184, 208), 0], [81, 'Tl', 6, 3, 'P', 'Thallium', 1.69, 2.53, (166, 84, 77), 0], [82, 'Pb', 6, 4, 'P', 'Lead', 1.635, 2.53, (87, 89, 97), 0], [83, 'Bi', 6, 5, 'P', 'Bismuth', 1.53, 3.52, (158, 79, 181), 0], [84, 'Po', 6, 6, 'P', 'Polonium', 1.9, 2.0, (171, 92, 0), 0], [85, 'At', 6, 7, 'P', 'Astatine', 2.0, 2.0, (117, 79, 69), 0], [86, 'Rn', 6, 0, '0', 'Radon', 2.0, 2.0, (66, 130, 150), 0], [87, 'Fr', 7, 1, 'S', 'Francium', 2.0, 2.0, (66, 0, 102), 0], [88, 'Ra', 7, 2, 'S', 'Radium', 2.0, 2.0, (0, 125, 0), 0], [89, 'Ac', 7, 3, 'F', 'Actinium', 2.0, 2.0, (112, 171, 250), 0], [90, 'Th', 7, 4, 'F', 'Thorium', 2.0, 2.75, (0, 186, 255), 0], [91, 'Pa', 7, 5, 'F', 'Protactinium', 2.0, 2.0, (0, 161, 255), 0], [92, 'U', 7, 6, 'F', 'Uranium', 2.0, 2.65, (0, 143, 255), 0], [93, 'Np', 7, 7, 'F', 'Neptunium', 2.0, 2.0, (0, 128, 255), 0], [94, 'Pu', 7, 8, 'F', 'Plutonium', 2.0, 2.0, (0, 107, 255), 0], [95, 'Am', 7, 9, 'F', 'Americium', 2.0, 2.0, (84, 92, 242), 0], [96, 'Cm', 7, 10, 'F', 'Curium', 2.0, 2.0, (120, 92, 227), 0], [97, 'Bk', 7, 11, 'F', 'Berkelium', 2.0, 2.0, (138, 79, 227), 0], [98, 'Cf', 7, 12, 'F', 'Californium', 2.0, 2.0, (161, 54, 212), 0], [99, 'Es', 7, 13, 'F', 'Einsteinium', 2.0, 2.0, (179, 31, 212), 0], [100, 'Fm', 7, 14, 'F', 'Fermium', 2.0, 2.0, (179, 31, 186), 0], [101, 'Md', 7, 1, 'F', 'Mendelevium', 2.0, 2.0, (179, 13, 166), 0], [102, 'No', 7, 2, 'F', 'Nobelium', 2.0, 2.0, (189, 13, 135), 0], [103, 'Lr', 7, 3, 'D', 'Lawrencium', 2.0, 2.0, (199, 0, 102), 0], [104, 'Rf', 7, 4, 'D', 'Rutherfordium', 2.0, 2.0, (204, 0, 89), 0], [105, 'Db', 7, 5, 'D', 'Dubnium', 2.0, 2.0, (209, 0, 79), 0], [106, 'Sg', 7, 6, 'D', 'Seaborgium', 2.0, 2.0, (217, 0, 69), 0], [107, 'Bh', 7, 7, 'D', 'Bohrium', 2.0, 2.0, (224, 0, 56), 0], [108, 'Hs', 7, 8, 'D', 'Hassium', 2.0, 2.0, (230, 0, 46), 0], [109, 'Mt', 7, 9, 'D', 'Meitnerium', 2.0, 2.0, (235, 0, 38), 0], [110, 'Ds', 7, 10, 'D', 'Darmstadtium', 2.0, 2.0, (128, 128, 128), 0], [111, 'Rg', 7, 1, 'D', 'Roentgenium', 2.0, 2.0, (128, 128, 128), 0], [112, 'Uub', 7, 2, 'D', 'Ununbium', 2.0, 2.0, (128, 128, 128), 0]])[source]#