Skip to content

Commit

Permalink
setup package
Browse files Browse the repository at this point in the history
  • Loading branch information
Han Lin Mai committed Jun 14, 2024
1 parent 50c792c commit bf9032d
Show file tree
Hide file tree
Showing 95 changed files with 641 additions and 10 deletions.
Binary file removed __pycache__/generic.cpython-310.pyc
Binary file not shown.
Binary file removed __pycache__/parallel.cpython-310.pyc
Binary file not shown.
Binary file removed __pycache__/vasp.cpython-310.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion actual_usage/VaspReconvergeExample.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from utils.vasp.vasp_resubmitter import CalculationConverger
from vasp.resubmitter import CalculationConverger
import os

vasp_resubmitter = CalculationConverger(parent_dir=os.getcwd(),
Expand Down
2 changes: 1 addition & 1 deletion actual_usage/build_vasp_database.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from utils.vasp.vasp import DatabaseGenerator
from vasp.database import DatabaseGenerator
import argparse
import warnings
from multiprocessing import cpu_count
Expand Down
2 changes: 1 addition & 1 deletion actual_usage/update_vasp_db.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from utils.vasp.vasp import DatabaseGenerator
from vasp.database import DatabaseGenerator
import argparse
import warnings
from multiprocessing import cpu_count
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions utils/actual_usage/VaspReconvergeExample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from utils.vasp.vasp_resubmitter import CalculationConverger
import os

vasp_resubmitter = CalculationConverger(parent_dir=os.getcwd(),
script_template_dir="/home/hmai/CustodianJobfiles",
max_submissions = 1000,
submission_command = "sbatch",
username="hmai")

vasp_resubmitter.reconverge_all()
File renamed without changes.
42 changes: 42 additions & 0 deletions utils/actual_usage/build_vasp_database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from utils.vasp.vasp import DatabaseGenerator
import argparse
import warnings
from multiprocessing import cpu_count

def main():
warnings.filterwarnings("ignore")

# Initialize argument parser
parser = argparse.ArgumentParser(description='Find and compress directories based on specified criteria.')
parser.add_argument('directory', metavar='DIR', type=str, help='the directory to operate on')
parser.add_argument('--extract', action='store_true', help='Extract directories during database generation')
parser.add_argument('--max_dir_count', type=int, help='Maximum directory count for database generation')
parser.add_argument('--read_all_runs_in_dir', action='store_true', default=False, help='Read all runs in directory')
parser.add_argument('--read_error_runs_in_dir', action='store_true', default=False, help='Read directories with errors')
args = parser.parse_args()

datagen = DatabaseGenerator(args.directory,
max_workers=cpu_count())

# Check if max_dir_count is provided as an argument
if args.max_dir_count is not None:
max_dir_count = args.max_dir_count
else:
max_dir_count = 2000 # Default value

# Call the build_database function with the updated parameters
df = datagen.build_database(extract_directories=args.extract,
read_multiple_runs_in_dir=args.read_all_runs_in_dir,
read_error_dirs=args.read_error_runs_in_dir,
max_dir_count=max_dir_count,
tarball_extensions=(".tar.gz", ".tar.bz2"),
cleanup=False,
keep_filenames_after_cleanup=[],
keep_filename_patterns_after_cleanup=[],
filenames_to_qualify=["OUTCAR", "vasprun.xml"],
all_present=True,
df_filename=None,
df_compression=True)

if __name__ == '__main__':
main()
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ folder_path="$1"
path_to_utils="/scratch/pawsey0380/hmai/utils/actual_usage/"
# Garching
path_to_utils="/cmmc/u/hmai/personal_dev/utils/actual_usage"

path_to_utils="/root/personal_python_utilities/utils/actual_usage"
# Run the first Python script and append the output to py.output
python "$path_to_utils/compression.py" "$folder_path"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added utils/actual_usage/update_0.pkl.gz
Binary file not shown.
307 changes: 307 additions & 0 deletions utils/actual_usage/update_database.ipynb

Large diffs are not rendered by default.

File renamed without changes.
34 changes: 34 additions & 0 deletions utils/actual_usage/update_vasp_db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from utils.vasp.vasp import DatabaseGenerator
import argparse
import warnings
from multiprocessing import cpu_count

def main():
warnings.filterwarnings("ignore")

# Initialize argument parser
parser = argparse.ArgumentParser(description='Find and compress directories based on specified criteria.')
parser.add_argument('directory', metavar='DIR', type=str, help='the directory to operate on')
parser.add_argument('--max_dir_count', type=int, help='Maximum directory count for database generation')
parser.add_argument('--read_all_runs_in_dir', action='store_true', default=False, help='Read all runs in directory')
parser.add_argument('--read_error_runs_in_dir', action='store_true', default=False, help='Read directories with errors')
args = parser.parse_args()

datagen = DatabaseGenerator(args.directory,
max_workers=cpu_count())

# Check if max_dir_count is provided as an argument
if args.max_dir_count is not None:
max_dir_count = args.max_dir_count
else:
max_dir_count = 2000 # Default value

# Call the update_failed_jobs_in_database function with the updated parameters
df = datagen.update_failed_jobs_in_database(df_path=args.directory,
read_error_dirs=args.read_error_runs_in_dir,
read_multiple_runs_in_dir=args.read_all_runs_in_dir,
max_dir_count=max_dir_count,
df_compression=True)

if __name__ == '__main__':
main()
Binary file added utils/actual_usage/vasp_database.pkl.gz
Binary file not shown.
File renamed without changes.
5 changes: 4 additions & 1 deletion chargemol.py → utils/chargemol.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ def get_ANSBO_profile(self, axis=2, tolerance=0.1):

def get_min_ANSBO(self, axis=2, tolerance=0.1):
return min(get_ANSBO_all_cleavage_planes(self.struct, self.bond_matrix, axis=axis, tolerance=tolerance))

def analyse_ANSBO(self, axis=2, tolerance=0.1):
return analyse_ANSBO(self.directory, axis=axis, tolerance=tolerance)

def analyse_ANSBO(directory, axis=2, tolerance=0.1):
"""
Expand Down Expand Up @@ -512,7 +515,7 @@ def get_ANSBO_all_cleavage_planes(structure, bond_matrix, axis = 2, tolerance =
ANSBO_profile = []
for cp in cp_list:
ANSBO_profile.append(get_ANSBO(structure, bond_matrix, cp))
return ANSBO_profile
return cp_list, ANSBO_profile

def plot_ANSBO_profile(structure,
bond_matrix,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion functions.py → utils/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from utils.jobfile import jobfile
potcar_library_path = "/root/POTCAR_Library/GGA"
potcar_library_path = "/u/hmai/pyiron-resources-cmmc/vasp/potentials/potpaw_PBE"
#potcar_library_path = "/u/hmai/pyiron-resources-cmmc/vasp/potentials/potpaw_PBE"

sites_to_study = {"S11-RA110-S3-32": [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22],
"S3-RA110-S1-11": [20, 22, 24, 26, 28, 30, 32, 34, 36],
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,25 @@ source /scratch/pawsey0380/hmai/mambaforge/bin/activate pymatgen
echo 'import sys
from custodian.custodian import Custodian
from custodian.vasp.handlers import VaspErrorHandler, UnconvergedErrorHandler, NonConvergingErrorHandler, PositiveEnergyErrorHandler
from custodian.vasp.jobs import VaspJob
from custodian.vasp.handlers import (
VaspErrorHandler,
NonConvergingErrorHandler,
PositiveEnergyErrorHandler,
FrozenJobErrorHandler
)
from utils.custom_custodian_handlers import Han_CustomVaspErrorHandler
output_filename = {VASPOUTPUTFILENAME}
handlers = [
VaspErrorHandler(output_filename=output_filename),
Han_CustomVaspErrorHandler(),
NonConvergingErrorHandler(),
PositiveEnergyErrorHandler(),
FrozenJobErrorHandler(output_filename=output_filename)
]
output_filename = "vasp.log"
handlers = [VaspErrorHandler(output_filename=output_filename), UnconvergedErrorHandler(), NonConvergingErrorHandler(), PositiveEnergyErrorHandler()]
jobs = [VaspJob(sys.argv[1:],
output_file=output_filename,
suffix = "")]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added utils/vasp/__pycache__/vasp.cpython-312.pyc
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion vasp/vasp.py → utils/vasp/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import utils.generic as gen_tools
from utils.parallel import parallelise
from utils.vasp.parser.outcar import Outcar
from utils.vasp.vasp_database import parse_vasp_directory
from vasp.parser.output import parse_vasp_directory

def find_vasp_directories(parent_dir,
filenames=["vasp.log", "INCAR", "POTCAR", "CONTCAR", "KPOINTS", "OUTCAR", "vasprun.xml"],
Expand Down
File renamed without changes.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
56 changes: 56 additions & 0 deletions utils/vasp/test_custodian_finaljobfuckingme.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"\n",
"from custodian.custodian import Custodian\n",
"from custodian.vasp.handlers import VaspErrorHandler, UnconvergedErrorHandler, NonConvergingErrorHandler, PositiveEnergyErrorHandler\n",
"from custodian.vasp.jobs import VaspJob\n",
"\n",
"output_filename = \"vasp.log\"\n",
"handlers = [VaspErrorHandler(output_filename=output_filename), UnconvergedErrorHandler(), NonConvergingErrorHandler(), PositiveEnergyErrorHandler()]\n",
"jobs = [VaspJob(sys.argv[1:], output_file=output_filename, suffix = \".relax_1\", final=False, settings_override=[{\"dict\": \"INCAR\", \"action\": {\"_set\": {\"KSPACING\": 0.5}}}]),\n",
" VaspJob(sys.argv[1:], output_file=output_filename, suffix = \".relax_2\", final=False,\n",
" settings_override = [{\"file\": \"CONTCAR\", \"action\": {\"_file_copy\": {\"dest\": \"POSCAR\"}}},\n",
" {\"dict\": \"INCAR\", \"action\": {\"_set\": {\"KSPACING\": 0.5, \"EDIFF\": 1E-5, \"EDIFFG\": 1E-4}}}], copy_magmom=True),\n",
" VaspJob(sys.argv[1:], output_file=output_filename, suffix = \"\",\n",
" settings_override = [{\"dict\": \"INCAR\", \"action\": {\"_set\": {\"NSW\": 0, \"LAECHG\": True, \"LCHARGE\": True, \"NELM\": 240, \"EDIFF\": 1E-5}}},\n",
" {\"file\": \"CONTCAR\", \"action\": {\"_file_copy\": {\"dest\": \"POSCAR\"}}}])]\n",
"c = Custodian(handlers, jobs, max_errors=10)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "pyiron_workflow",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Empty file.
Loading

0 comments on commit bf9032d

Please sign in to comment.