🔄 Format Conversion
This directory (Scripts/format_conversion/) contains utilities for converting between different file formats commonly used in computational materials science.
Script Location: Scripts/format_conversion/
This section covers the format conversion tools in GPUMDkit (Interactive Mode - Option 1).
Interactive Mode
You'll see the following menu:
------------>>
101) Convert VASP to extxyz
102) Convert mtp to extxyz
103) Convert CP2K to extxyz
104) Convert ABACUS to extxyz
105) Convert extxyz to POSCAR
000) Return to the main menu
------------>>
Input the function number:
for 101:
>-------------------------------------------------<
| Calling the script in Scripts/format_conversion |
| Script: out2xyz.sh |
| Developer: Yanzhou WANG (yanzhowang@gmail.com) |
>-------------------------------------------------<
Choose the type of conversion:
1) OUTCAR to extxyz
2) vasprun.xml to extxyz
------------>>
for 102:
>-------------------------------------------------<
| Calling the script in Scripts/format_conversion |
| Script: mtp2xyz.py |
| Developer: Ke XU (kickhsu@gmail.com) |
>-------------------------------------------------<
Input <filename.cfg> <Symbol1 Symbol2 Symbol3 ...>
Examp: train.cfg Pd Ag
------------>>
for 103:
>-------------------------------------------------<
| Calling the script in Scripts/format_conversion |
| Script: cp2k2xyz.py |
| Developer: Ke XU (kickhsu@gmail.com) |
>-------------------------------------------------<
Input [pos.xyz] [frc.xyz] [cell.cell] [-shifted yes/no]
------------>>
for 104:
>-------------------------------------------------<
| Calling the script in Scripts/format_conversion |
| Script: abacus2xyz-scf.sh/abacus2xyz-md.sh |
| Developer: Benrui TANG (tang070205@proton.me) |
>-------------------------------------------------<
Choose the type of ABACUS calculation:
1) SCF calculation
2) MD calculation
------------>>
for 105:
>-------------------------------------------------<
| Calling the script in Scripts/format_conversion |
| Script: exyz2pos.py |
| Developer: Zihan YAN (yanzihan@westlake.edu.cn) |
>-------------------------------------------------<
Input the name of extxyz
Examp: ./train.xyz
------------>>
Follow the prompts to complete the function.
Command-line Mode
| Source Format | Target Format | Command |
|---|---|---|
| OUTCAR | extxyz | gpumdkit.sh -out2xyz <dir> |
| vasprun.xml | extxyz | gpumdkit.sh -xml2xyz <dir> |
| POSCAR | extxyz | gpumdkit.sh -pos2exyz <poscar> <xyz> |
| extxyz | POSCAR | gpumdkit.sh -exyz2pos <xyz> |
| POSCAR | LAMMPS | gpumdkit.sh -pos2lmp <poscar> <lmp> <elem...> |
| LAMMPS dump | extxyz | gpumdkit.sh -lmp2exyz <dump> <elem...> |
| CIF | extxyz | gpumdkit.sh -cif2exyz <cif> |
| CIF | POSCAR | gpumdkit.sh -cif2pos <cif> |
| Add groups | - | gpumdkit.sh -addgroup <poscar> <elem...> |
| Add weight | - | gpumdkit.sh -addweight <in> <out> <weight> |
| Replicate1 | - | gpumdkit.sh -replicate input.vasp output.vasp 2 2 2 |
| Replicate2 | - | gpumdkit.sh -replicate input.vasp output.vasp <target_num> |
| Get frame | - | gpumdkit.sh -ge_frame <extxyz> <index> |
Scripts
add_groups.py
This script adds group labels to structures based on specified elements.
Usage
<filename>: The path to the input file (e.g., POSCAR).<Symbols>: Space-separated list of element symbols to group (e.g., Li Y Cl).
Example
Command-Line Mode Example
This command will read the POSCAR file and add group labels for the elements Li, Y, and Cl. The output will be saved to a file named model.xyz.
add_weight.py
This script adds weight labels to structures.
Usage
<inputfile>: The path to the input file (e.g., train.xyz).<outputfile>: The path to the input file (e.g., train_weighted.xyz).<new_weight>: Theweightyou need to change.
Example
Command-Line Mode Example
This command will read the train.xyz file and add Weight=5 labels for all structures. The output will be saved to a file named train_weighted.xyz.
exyz2pos.py
This script converts all frames in an extxyz file to POSCAR format.
Usage
Example
Command-Line Mode Example
This command will convert all frames in structs.xyz to POSCAR_*.vasp files.
pos2exyz.py
This script converts a POSCAR file to extxyz format.
Usage
<POSCAR_file>: The path to the inputPOSCARfile.<extxyz_file>: The desired name for the outputextxyzfile.
Example
Command-Line Mode Example
This command will read the POSCAR file and convert it to model.xyz in extxyz format.
pos2lmp.py
This script converts a POSCAR file to lammps-data format.
Usage
<poscar_file>: The path to the inputPOSCARfile.<lammps_data_file>: The desired name for the outputlammps-datafile.
Example
Command-Line Mode Example
This command will read the POSCAR file and convert it to lammps.data in lammps-data format.
split_single_xyz.py
This script splits an extxyz file into individual frames, each written to a separate file.
Usage
This command will split all frames in extxyz_file into separate files named model_*.xyz.
lmp2exyz.py
This script will convert the lammps-dump to extxyz format.
Usage
<dump_file>: The path to the inputlammps-dumpfile.<element>: The order of the specified elements.
Example
Command-Line Mode Example
It will convert the dump.data to dump.xyz file
get_frame.py
This script will read the extxyz file and return the specified frame by index..
Usage
<extxyz_file>: The path to the inputextxyzfile.<frame_index>: The index of the specified frame.
Example
Command-Line Mode Example
You will get the frame_1000.xyz file after perform the script.
Contributing
To add new format converters:
- Follow naming:
<source>2<target>.py - Handle errors: Validate input format before processing
- Document: Add usage to this README
- Update gpumdkit.sh: Add command-line flag if appropriate
See CONTRIBUTING.md for detailed guidelines.
Thank you for using GPUMDkit! If you have questions about format conversion, please open an issue on our GitHub repository or contact Zihan YAN (yanzihan@westlake.edu.cn).