Introduction to atomman: pdb file dumping

Lucas M. Hale, lucas.hale@nist.gov, Materials Science and Engineering Division, NIST.

Disclaimers

1. Introduction

The ‘pdb’ dump style generates a Protein Database pdb file representation of a system. While not directly that useful for crystalline materials, the pdb format is widely recognized by atomistic plotting software.

Added version 1.4.10

[1]:
# Standard Python libraries
import datetime

# http://www.numpy.org/
import numpy as np

import atomman as am
import atomman.unitconvert as uc

# Show atomman version
print('atomman version =', am.__version__)

# Show date of Notebook execution
print('Notebook executed on', datetime.date.today())
atomman version = 1.4.11
Notebook executed on 2024-04-29

Generate test system information (CsCl)

[2]:
# Generate box
alat = uc.set_in_units(3.2, 'angstrom')
box = am.Box(a=alat, b=alat, c=alat)

# Generate atoms with atype, pos, charge, and stress properties
atype = [1, 2]
pos = [[0,0,0], [0.5, 0.5, 0.5]]
charge = uc.set_in_units([1, -1], 'e')
stress = uc.set_in_units(np.zeros((2, 3, 3)), 'MPa')
atoms = am.Atoms(pos=pos, atype=atype, charge=charge, stress=stress)

# Build system from box and atoms, and scale atoms
system = am.System(atoms=atoms, box=box, scale=True, symbols=['Cs', 'Cl'])

# Print system information
print(system)
system.atoms_df()
avect =  [ 3.200,  0.000,  0.000]
bvect =  [ 0.000,  3.200,  0.000]
cvect =  [ 0.000,  0.000,  3.200]
origin = [ 0.000,  0.000,  0.000]
natoms = 2
natypes = 2
symbols = ('Cs', 'Cl')
pbc = [ True  True  True]
per-atom properties = ['atype', 'pos', 'charge', 'stress']
     id   atype  pos[0]  pos[1]  pos[2]
      0       1   0.000   0.000   0.000
      1       2   1.600   1.600   1.600
[2]:
atype pos[0] pos[1] pos[2] charge stress[0][0] stress[0][1] stress[0][2] stress[1][0] stress[1][1] stress[1][2] stress[2][0] stress[2][1] stress[2][2]
0 1 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
1 2 1.6 1.6 1.6 -1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0

2. System.dump(‘pdb’)

Generates a PDB file based on the System. Note: the POSCAR format only captures per-atom data for each atom’s type and position. Therefore, it does not offer a lossless representation of a System object.

Parameters

  • f (str or file-like object, optional) File path or file-like object to write the content to. If not given, then the content is returned as a str.

  • ignoresymbols (bool, optional) Setting this to True will save all atom types as unknowns rather than as their element symbols. This is useful in tricking some pdb-based tools into recognizing the atoms if the model symbols differ from elemental symbols or the element is H.

Returns

  • pdb_str (str) String of the poscar object (only returned if fname is not given).

[3]:
pdb = system.dump('pdb')
print(pdb)
CRYST1    3.200    3.200    3.200  90.00  90.00  90.00 P 1
MODEL     1
HETATM    1 Cs   MOL     1       0.000   0.000   0.000  1.00  0.00          CS
HETATM    2 Cl   MOL     1       1.600   1.600   1.600  1.00  0.00          CL
ENDMDL

Setting ignoresymbols will replace elemental info with UNX and X#

[4]:
pdb = system.dump('pdb', ignoresymbols=True)
print(pdb)
CRYST1    3.200    3.200    3.200  90.00  90.00  90.00 P 1
MODEL     1
HETATM    1 UNX  MOL     1       0.000   0.000   0.000  1.00  0.00          X1
HETATM    2 UNX  MOL     1       1.600   1.600   1.600  1.00  0.00          X2
ENDMDL