Atom,Atoms

在目标研究的程序中,主要使用了这两个库

ase库中的AtomAtoms是用于处理分子和结构的重要工具。Atom对象用于表示单个原子,它包含原子的元素类型、位置、速度等信息。Atoms对象是一个用于存储和操纵多个Atom对象的容器,它可以用来表示分子、晶体、表面等多种结构。除了原子的信息,Atoms对象还可以存储诸如晶格参数、原子间距、键长等结构信息。

Atom类

类Atom非常简单,基本只包含原子的非常基础的信息

初始化

1
2
***class* ase.atom.Atom(*symbol='X'*, *position=(000)*, *tag=None*, *momentum=None*, 
*mass=None*, *magmom=None*, *charge=None*, *atoms=None*, *index=None*)**
  • symbol:分子式,可以使用化学符号’Si’或者相应的原子序号14来表示
  • position:三维坐标,单位为Å
  • tag:特殊用途标签
  • momentum:三位动量坐标
  • mass:质量
  • magmom:磁矩
  • charge:电荷

从Atoms读取

1
2
3
4
5
6
7
8
9
10
11
from ase.build import molecule
atoms = molecule('CH4')
atoms.get_positions()
array([[ 0. , 0. , 0. ],
[ 0.629118, 0.629118, 0.629118],
[-0.629118, -0.629118, 0.629118],
[ 0.629118, -0.629118, -0.629118],
[-0.629118, 0.629118, -0.629118]])
a = atoms[2]
a
Atom('H', [-0.62911799999999996, -0.62911799999999996, 0.62911799999999996], index=2)

Atomes类

初始化

Atomes的初始化与Atom类似,具体见例子:

1
2
3
4
5
6
7
8
9
from ase import Atoms
d = 1.1
co = Atoms('CO', positions=[(0, 0, 0), (0, 0, d)]) #双原子分子
d = 2.9
L = 10.0
wire = Atoms('Au',
positions=[[0, L / 2, L / 2]],
cell=[d, L, L],
pbc=[1, 0, 0])

  • pbc指定的沿x轴的周期性重复
  • cell:单一晶胞尺寸,它可以是正交晶胞的三个数字的序列,或者一般晶胞的3*3数字(三个数字的三个序列的序列)或六个数字(三个长度和三个角度)
  • pcb:周期性边界条件,将给出沿所有三个轴的周期性边界条件。可以给出三个布尔值的序列来指定沿特定轴的周期性

封装方法-同时作为atom的补充

这些方法基本都由get/set_属性名称组成

https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.get_atomic_numbers https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.set_atomic_numbers
https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.get_initial_charges https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.set_initial_charges
https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.get_charges
https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.get_chemical_symbols https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.set_chemical_symbols
https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.get_initial_magnetic_moments https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.set_initial_magnetic_moments
https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.get_magnetic_moments
https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.get_masses https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.set_masses
https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.get_momenta https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.set_momenta
https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.get_forces
https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.get_positions https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.set_positions
https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.get_potential_energies
https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.get_scaled_positions https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.set_scaled_positions
https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.get_stresses
https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.get_tags https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.set_tags
https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.get_velocities https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms.set_velocities

Cell操作

  • Cell类类似于一个3*3的矩阵,以以下方式查看

    1
    2
    3
    4
    5
    6
    atoms.cell
    Cell([0.0, 0.0, 0.0], pbc=False)
    atoms.cell[:]
    array([[0., 0., 0.],
    [0., 0., 0.],
    [0., 0., 0.]])
  • 可以使用set_cell设置单位晶胞大小:

    1
    2
    3
    atoms.set_cell(2 * np.identity(3))
    >>>atoms.get_cell()
    Cell([2.0, 2.0, 2.0], pbc=False)
  • 在set_cell时加入scale_atoms=True可来使原子坐标跟随晶胞尺寸改变

文件读写 ase.io