-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
429 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
""" | ||
Create a VESTA file containing the atomic displacement for each mode | ||
""" | ||
|
||
import argparse | ||
import pathlib | ||
|
||
from typing import Tuple | ||
|
||
from phonopy_vibspec.phonons_analyzer import PhononsAnalyzer | ||
from phonopy_vibspec.scripts import add_common_args | ||
|
||
|
||
def get_color(inp: str) -> Tuple[int, int, int]: | ||
e = 'invalid color: `{}`, must be 3 integers'.format(inp) | ||
|
||
try: | ||
cs = [int(x) for x in inp.split()] | ||
except ValueError: | ||
raise argparse.ArgumentTypeError(e) | ||
|
||
if len(cs) != 3: | ||
raise argparse.ArgumentTypeError(e) | ||
|
||
if any(x < 0 or x > 255 for x in cs): | ||
raise argparse.ArgumentTypeError(e) | ||
|
||
return tuple(cs) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description=__doc__) | ||
add_common_args(parser) | ||
|
||
parser.add_argument('-s', '--scaling', help='Scaling factor', type=float, default=10.0) | ||
parser.add_argument('-r', '--radius', help='Radius of the vectors', type=float, default=0.15) | ||
parser.add_argument('--color', help='Color of the vectors', type=get_color, default='0 255 0') | ||
|
||
args = parser.parse_args() | ||
|
||
phonons = PhononsAnalyzer.from_phonopy( | ||
phonopy_yaml=args.phonopy, | ||
force_constants_filename=args.fc, | ||
) | ||
|
||
phonons.make_vesta_for_modes( | ||
pathlib.Path.cwd(), | ||
modes=args.modes if len(args.modes) > 0 else None, | ||
scaling=args.scaling, | ||
radius=args.radius, | ||
color=args.color | ||
) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.