@@ -626,26 +626,24 @@ def replicate(self, ncopy):
626
626
627
627
def perturb (self ,
628
628
pert_num ,
629
- box_pert_fraction ,
629
+ cell_pert_fraction ,
630
630
atom_pert_distance ,
631
631
atom_pert_style = 'normal' ):
632
632
"""
633
633
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.
636
635
637
636
Parameters
638
637
----------
639
638
pert_num : int
640
639
Each frame in the system will make `pert_num` copies,
641
640
and all the copies will be perturbed.
642
641
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).
649
647
atom_pert_distance: float
650
648
unit: Angstrom. A distance determines how far atoms will move.
651
649
Atoms will move about `atom_pert_distance` in random direction.
@@ -670,27 +668,27 @@ def perturb(self,
670
668
for ii in range (nframes ):
671
669
for jj in range (pert_num ):
672
670
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 )
676
674
for kk in range (len (tmp_system .data ['coords' ][0 ])):
677
675
atom_perturb_vector = get_atom_perturb_vector (atom_pert_distance , atom_pert_style )
678
676
tmp_system .data ['coords' ][0 ][kk ] += atom_perturb_vector
679
677
tmp_system .rot_lower_triangular ()
680
678
perturbed_system .append (tmp_system )
681
679
return perturbed_system
682
680
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' )
686
684
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 (
689
687
[[1 + e [0 ], 0.5 * e [5 ], 0.5 * e [4 ]],
690
688
[0.5 * e [5 ], 1 + e [1 ], 0.5 * e [3 ]],
691
689
[0.5 * e [4 ], 0.5 * e [3 ], 1 + e [2 ]]]
692
690
)
693
- return box_pert_matrix
691
+ return cell_pert_matrix
694
692
695
693
def get_atom_perturb_vector (atom_pert_distance , atom_pert_style = 'normal' ):
696
694
random_vector = None
0 commit comments