Skip to content

Commit 0e4d5c3

Browse files
authored
change all 'box' to 'cell'
1 parent 185ecf0 commit 0e4d5c3

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

dpdata/system.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -626,26 +626,24 @@ def replicate(self, ncopy):
626626

627627
def perturb(self,
628628
pert_num,
629-
box_pert_fraction,
629+
cell_pert_fraction,
630630
atom_pert_distance,
631631
atom_pert_style='normal'):
632632
"""
633633
Perturb each frame in the system randomly.
634-
The box will be changed randomly,
635-
and atoms will move random distance in random direction.
634+
The cell will be deformed randomly, and atoms will be displaced by a random distance in random direction.
636635
637636
Parameters
638637
----------
639638
pert_num : int
640639
Each frame in the system will make `pert_num` copies,
641640
and all the copies will be perturbed.
642641
That means the system to be returned will contain `pert_num` * frame_num of the input system.
643-
box_pert_fraction : float
644-
A fraction determines how much will box deform, typically less than 0.3.
645-
For a cubic box with side length `side_length`,
646-
`side_length` will increase or decrease with the max value `box_pert_fraction*side_length` .
647-
If box_pert_fraction is not zero, the shape of the box will also be changed,
648-
and that means a orthogonal box will become a non-orthogonal one.
642+
cell_pert_fraction : float
643+
A fraction determines how much (relatively) will cell deform.
644+
The cell of each frame is deformed by a symmetric matrix perturbed from identity.
645+
The perturbation to the diagonal part is subject to a uniform distribution in [-cell_pert_fraction, cell_pert_fraction),
646+
and the perturbation to the off-diagonal part is subject to a uniform distribution in [-0.5*cell_pert_fraction, 0.5*cell_pert_fraction).
649647
atom_pert_distance: float
650648
unit: Angstrom. A distance determines how far atoms will move.
651649
Atoms will move about `atom_pert_distance` in random direction.
@@ -670,27 +668,27 @@ def perturb(self,
670668
for ii in range(nframes):
671669
for jj in range(pert_num):
672670
tmp_system = self[ii].copy()
673-
box_perturb_matrix = get_box_perturb_matrix(box_pert_fraction)
674-
tmp_system.data['cells'][0] = np.matmul(tmp_system.data['cells'][0],box_perturb_matrix)
675-
tmp_system.data['coords'][0] = np.matmul(tmp_system.data['coords'][0],box_perturb_matrix)
671+
cell_perturb_matrix = get_cell_perturb_matrix(cell_pert_fraction)
672+
tmp_system.data['cells'][0] = np.matmul(tmp_system.data['cells'][0],cell_perturb_matrix)
673+
tmp_system.data['coords'][0] = np.matmul(tmp_system.data['coords'][0],cell_perturb_matrix)
676674
for kk in range(len(tmp_system.data['coords'][0])):
677675
atom_perturb_vector = get_atom_perturb_vector(atom_pert_distance, atom_pert_style)
678676
tmp_system.data['coords'][0][kk] += atom_perturb_vector
679677
tmp_system.rot_lower_triangular()
680678
perturbed_system.append(tmp_system)
681679
return perturbed_system
682680

683-
def get_box_perturb_matrix(box_pert_fraction):
684-
if box_pert_fraction<0:
685-
raise RuntimeError('box_pert_fraction can not be negative')
681+
def get_cell_perturb_matrix(cell_pert_fraction):
682+
if cell_pert_fraction<0:
683+
raise RuntimeError('cell_pert_fraction can not be negative')
686684
e0 = np.random.rand(6)
687-
e = e0 * 2 *box_pert_fraction - box_pert_fraction
688-
box_pert_matrix = np.array(
685+
e = e0 * 2 *cell_pert_fraction - cell_pert_fraction
686+
cell_pert_matrix = np.array(
689687
[[1+e[0], 0.5 * e[5], 0.5 * e[4]],
690688
[0.5 * e[5], 1+e[1], 0.5 * e[3]],
691689
[0.5 * e[4], 0.5 * e[3], 1+e[2]]]
692690
)
693-
return box_pert_matrix
691+
return cell_pert_matrix
694692

695693
def get_atom_perturb_vector(atom_pert_distance, atom_pert_style='normal'):
696694
random_vector = None

0 commit comments

Comments
 (0)