Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ build/
.DS_Store
Thumbs.db

# Opencode
.opencode

# Temporary / generated files
*.log
temp_*.xyz
1 change: 1 addition & 0 deletions Scripts/format_conversion/abacus2xyz_scf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
def main():
if len(sys.argv) != 3:
print("Usage: python abacus2xyz_scf.py <dir> <extxyz>")
print(" or: gpumdkit.sh -abacus2xyz <dir> <extxyz>")
sys.exit(1)
if __name__ == "__main__":
main()
Expand Down
6 changes: 6 additions & 0 deletions Scripts/format_conversion/add_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
from ase.io import read, write
import numpy as np

# Check arguments
if len(sys.argv) < 3:
print("Usage: python add_groups.py <input.xyz> <element1> <element2> ...")
print(" or: gpumdkit.sh -addgroup <input.xyz> <element1> <element2> ...")
sys.exit(1)

# Read the file name from command line arguments
file_name = sys.argv[1]

Expand Down
3 changes: 2 additions & 1 deletion Scripts/format_conversion/add_weight.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
def main():
# Check if the correct number of arguments are provided
if len(sys.argv) != 4:
print("Usage: python script.py <input_file> <output_file> <new_weight>")
print("Usage: python add_weight.py <input.xyz> <output.xyz> <weight>")
print(" or: gpumdkit.sh -addweight <input.xyz> <output.xyz> <weight>")
sys.exit(1)

# Parse command line arguments
Expand Down
3 changes: 2 additions & 1 deletion Scripts/format_conversion/cif2exyz.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

# Check command line arguments
if len(sys.argv) != 3:
print(" Usage: python cif2exyz.py input.cif output.xyz")
print("Usage: python cif2exyz.py <input.cif> <output.xyz>")
print(" or: gpumdkit.sh -cif2exyz <input.cif> <output.xyz>")
sys.exit(1)

# Read input and output file paths
Expand Down
3 changes: 2 additions & 1 deletion Scripts/format_conversion/cif2pos.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

# Check command line arguments
if len(sys.argv) != 3:
print(" Usage: python cif2poscar.py input.cif output.vasp")
print("Usage: python cif2pos.py <input.cif> <output.vasp>")
print(" or: gpumdkit.sh -cif2pos <input.cif> <output.vasp>")
sys.exit(1)

# Read input and output file paths
Expand Down
6 changes: 6 additions & 0 deletions Scripts/format_conversion/clean_xyz.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
from ase.io import read, write
import sys

# Check arguments
if len(sys.argv) < 3:
print("Usage: python clean_xyz.py <input.xyz> <output.xyz>")
print(" or: gpumdkit.sh -clean_xyz <input.xyz> <output.xyz>")
sys.exit(1)

# Read all frames from the input train.xyz file
frames = read(sys.argv[1], index=':')

Expand Down
8 changes: 7 additions & 1 deletion Scripts/format_conversion/exyz2pos.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ def print_progress_bar(iteration, total, length=50):
if iteration == total:
print()

input_file = sys.argv[1] if len(sys.argv) > 1 else 'train.xyz'
# Check arguments
if len(sys.argv) < 2:
print("Usage: python exyz2pos.py <input.xyz>")
print(" or: gpumdkit.sh -exyz2pos <input.xyz>")
sys.exit(1)

input_file = sys.argv[1]

# Read all frames
frames = read(input_file, index=':')
Expand Down
6 changes: 6 additions & 0 deletions Scripts/format_conversion/get_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
import sys
from ase.io import read, write

# Check arguments
if len(sys.argv) < 3:
print("Usage: python get_frame.py <input.xyz> <frame_number>")
print(" or: gpumdkit.sh -get_frame <input.xyz> <frame_number>")
sys.exit(1)

def get_frame():
input_file = sys.argv[1]
frame_number = int(sys.argv[2])
Expand Down
3 changes: 2 additions & 1 deletion Scripts/format_conversion/lmp2exyz.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def lmp2exyz(dump_file, elements):

if __name__ == '__main__':
if len(sys.argv) < 3:
print(" Usage: python lmp2exyz.py <dump_file> <element1> <element2> ...")
print("Usage: python lmp2exyz.py <dump_file> <element1> <element2> ...")
print(" or: gpumdkit.sh -lmp2exyz <dump_file> <element1> <element2> ...")
sys.exit(1)

dump_file = sys.argv[1]
Expand Down
5 changes: 5 additions & 0 deletions Scripts/format_conversion/mtp2xyz.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ def dump_xyz(frames):


if __name__ == "__main__":
# Check arguments
if len(sys.argv) < 3:
print("Usage: python mtp2xyz.py <train.cfg> <Symbol1> <Symbol2> ...")
sys.exit(1)

type_to_symbol = {i: s for i, s in enumerate(sys.argv[2:])}
frames = load_cfg(sys.argv[1], type_to_symbol)
#dump_nep(frames)
Expand Down
6 changes: 6 additions & 0 deletions Scripts/format_conversion/out2exyz.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
from ase import Atoms, Atom
from tqdm import tqdm

# Check arguments
if len(sys.argv) < 2:
print("Usage: python out2exyz.py <directory>")
print(" or: gpumdkit.sh -out2exyz <directory>")
sys.exit(1)

def Convert_atoms(atom):
xx,yy,zz,yz,xz,xy = -atom.calc.results['stress']*atom.get_volume()
atom.info['virial'] = np.array([(xx, xy, xz), (xy, yy, yz), (xz, yz, zz)])
Expand Down
5 changes: 2 additions & 3 deletions Scripts/format_conversion/pos2exyz.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ def convert_poscar_to_extxyz(poscar_filenames, extxyz_filename):
if __name__ == '__main__':
# Check if the number of arguments is correct
if len(sys.argv) < 3:
print("Usage: python pos2exyz.py <POSCAR> <extxyz_filename>")
print("Example 1: python pos2exyz.py POSCAR model.xyz")
# print("Example 2: python pos2exyz.py 'POSCAR*' train.xyz")
print("Usage: python pos2exyz.py <POSCAR> <output.xyz>")
print(" or: gpumdkit.sh -pos2exyz <POSCAR> <output.xyz>")
sys.exit(1)

poscar_filename_pattern = sys.argv[1]
Expand Down
1 change: 1 addition & 0 deletions Scripts/format_conversion/pos2lmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def convert_poscar_to_lammps(poscar_path, lammps_data_path):
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: python pos2lmp.py <poscar_file> <lammps_data_file>")
print(" or: gpumdkit.sh -pos2lmp <poscar_file> <lammps_data_file>")
sys.exit(1)

poscar_file = sys.argv[1]
Expand Down
6 changes: 4 additions & 2 deletions Scripts/format_conversion/replicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ def reorder_atoms_by_input_species_order(atoms, original_atoms):

def main():
if len(sys.argv) < 4:
print(" Usage 1: python replicate.py input.vasp output.vasp a b c")
print(" Usage 2: python replicate.py input.vasp output.vasp target_num")
print("Usage 1: python replicate.py input.vasp output.vasp a b c")
print("Usage 2: python replicate.py input.vasp output.vasp target_num")
print(" or: gpumdkit.sh -replicate input.vasp output.vasp a b c")
print(" or: gpumdkit.sh -replicate input.vasp output.vasp target_num")
sys.exit(1)

infile = sys.argv[1]
Expand Down
2 changes: 1 addition & 1 deletion Scripts/format_conversion/split_single_xyz.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def split_xyz_to_individual_models(input_xyz_filename):
if __name__ == '__main__':
# Check if the number of arguments is correct
if len(sys.argv) < 2:
print(" Usage: python script_name.py <input_xyz_filename>")
print("Usage: python split_single_xyz.py <input.xyz>")
sys.exit(1)

# Get input XYZ filename from command line argument
Expand Down
13 changes: 7 additions & 6 deletions Scripts/format_conversion/traj2exyz.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ def convert_traj_to_extxyz(input_file, output_file):
if __name__ == "__main__":
# Check if correct number of arguments are provided
if len(sys.argv) != 3:
print(" Usage: python traj2exyz.py <input.traj> <output.xyz>")
sys.stdout.flush()
else:
input_path = sys.argv[1]
output_path = sys.argv[2]
convert_traj_to_extxyz(input_path, output_path)
print("Usage: python traj2exyz.py <input.traj> <output.xyz>")
print(" or: gpumdkit.sh -traj2exyz <input.traj> <output.xyz>")
sys.exit(1)

input_path = sys.argv[1]
output_path = sys.argv[2]
convert_traj_to_extxyz(input_path, output_path)
27 changes: 13 additions & 14 deletions Scripts/format_conversion/xdatcar2exyz.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,38 @@
=============================================================================
"""

import argparse
import sys
from ase.io import read, write

# 1. Setup Argument Parser for positional arguments
parser = argparse.ArgumentParser(
description=" Convert VASP XDATCAR to extxyz format."
)
parser.add_argument("input", help=" Path to the input XDATCAR file")
parser.add_argument("output", help=" Path to the output .xyz file")
# Check arguments
if len(sys.argv) < 3:
print("Usage: python xdatcar2exyz.py <XDATCAR> <output.xyz>")
print(" or: gpumdkit.sh -xdat2exyz <XDATCAR> <output.xyz>")
sys.exit(1)

args = parser.parse_args()
input_file = sys.argv[1]
output_file = sys.argv[2]

# 2. Execute conversion logic
# Execute conversion logic
try:
print(f" Reading XDATCAR: {args.input} ...")
print(f" Reading XDATCAR: {input_file} ...")

# Read all frames from the trajectory (index=":")
# ASE automatically parses scaling, lattice, and species
trajectory = read(args.input, index=":", format="vasp-xdatcar")
trajectory = read(input_file, index=":", format="vasp-xdatcar")

num_frames = len(trajectory)
print(f" Detected {num_frames} frames.")

print(f" Writing to extxyz: {args.output} ...")
print(f" Writing to extxyz: {output_file} ...")

# Writing in extxyz format preserves the Lattice matrix in the header
write(args.output, trajectory, format="extxyz")
write(output_file, trajectory, format="extxyz")

print(" Conversion complete.")

except FileNotFoundError:
print(f" Error: Could not find '{args.input}'. Please check the path.")
print(f" Error: Could not find '{input_file}'. Please check the path.")
sys.exit(1)
except Exception as e:
print(f" An unexpected error occurred: {e}")
Expand Down
2 changes: 1 addition & 1 deletion Scripts/utils/completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ _gpumdkit_completions() {
prev="${COMP_WORDS[COMP_CWORD-1]}" # Previous word

# List of primary options (extracted from gpumdkit.sh)
local opts="-h -update -help -clean -time -plt -calc -cbc -range -out2xyz -xml2xyz -pos2exyz -cif2pos -cif2exyz -exyz2pos -pos2lmp -lmp2exyz -traj2exyz -cp2k2xyz -addgroup -addlabel -addweight -min_dist -min_dist_pbc -filter_dist -filter_dist_pbc -filter_box -filter_value -get_frame -clean_xyz -get_volume -analyze_comp -replicate -hbond -pda -pynep -frame_range -chem_species -xdat2exyz"
local opts="-h -update -help -clean -time -plt -calc -cbc -range -out2xyz -xml2xyz -pos2exyz -cif2pos -cif2exyz -exyz2pos -pos2lmp -lmp2exyz -traj2exyz -cp2k2xyz -addgroup -addlabel -addweight -min_dist -min_dist_pbc -filter_dist -filter_dist_pbc -filter_box -filter_value -get_frame -clean_xyz -get_volume -analyze_comp -replicate -hbond -pda -pynep -frame_range -chem_species -xdat2exyz -nep_modifier"

# Provide secondary completion based on the previous word
case "$prev" in
Expand Down
Loading