Skip to content

Commit

Permalink
aesthetic
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-24 committed Oct 22, 2023
1 parent 303dc9b commit 2f0c68b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
12 changes: 8 additions & 4 deletions phonopy_vibspec/phonons_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,9 @@ def make_vesta_for_modes(
directory: pathlib.Path,
modes: Optional[List[int]] = None,
scaling: float = 2.0,
radius: float = 0.15,
color: Tuple[int, int, int] = (0, 255, 0)
radius: float = 0.30,
color: Tuple[int, int, int] = (0, 255, 0),
threshold: float = 0.05,
):
"""Make a VESTA file for each `modes` (or all except acoustic if `mode` is None) containing a vector for
each atom, corresponding to the eigenvector.
Expand All @@ -230,20 +231,23 @@ def make_vesta_for_modes(
cart_to_cell = numpy.linalg.inv(cell)

eigv = self.eigenvectors.reshape(-1, self.N, 3)
eigv_norms = numpy.linalg.norm(eigv, axis=2)

for mode in modes:
if mode < 0 or mode >= 3 * self.N:
raise IndexError(mode)

l_logger.info('Creating file for mode {}'.format(mode))

max_norm = eigv_norms[mode].max()

# convert to coordinates along cell vectors
ceignedisps = numpy.einsum('ij,jk->ik', eigv[mode], cart_to_cell)
ceigendisps = ceignedisps[:] * norms * scaling

vectors = [
VestaVector(True, ceigendisps[i], [i], radius=radius, through_atom=True, color=color)
for i in range(self.N)
VestaVector(True, ceigendisps[i], [i], radius=radius, through_atom=True, color=color, add_radius=True)
for i in range(self.N) if eigv_norms[mode][i] > threshold * max_norm
]

with (directory / self.VESTA_MODE_TEMPLATE.format(mode + 1)).open('w') as f:
Expand Down
11 changes: 9 additions & 2 deletions phonopy_vibspec/scripts/vesta_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ def main():
add_common_args(parser)

parser.add_argument('-s', '--scaling', help='Scaling factor', type=float, default=2.0)
parser.add_argument('-r', '--radius', help='Radius of the vectors', type=float, default=0.15)
parser.add_argument('-r', '--radius', help='Radius of the vectors', type=float, default=0.30)
parser.add_argument('--color', help='Color of the vectors', type=get_color, default='0 255 0')
parser.add_argument(
'--threshold',
help='Remove vectors that are below a certain percentage of the largest one',
type=float,
default=0.05
)

args = parser.parse_args()

Expand All @@ -48,7 +54,8 @@ def main():
modes=args.modes if len(args.modes) > 0 else None,
scaling=args.scaling,
radius=args.radius,
color=args.color
color=args.color,
threshold=args.threshold
)


Expand Down

0 comments on commit 2f0c68b

Please sign in to comment.