Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some scripts used for the phaseD work #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
41 changes: 41 additions & 0 deletions scripts/make_runcastep.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python

_SCRIPT = """#PBS -N castep
#PBS -l select=5
#PBS -l walltime=09:00:00
#PBS -A n03-walk
#PBS -j oe
#PBS -m n

# Go to the submit dir - and set environment vars for
# fortran temp files, OMP etc.
cd $(readlink -f $PBS_O_WORKDIR)
export TMPDIR=$(readlink -f $PBS_O_WORKDIR)
export GFORTRAN_TMPDIR=$(readlink -f $PBS_O_WORKDIR)
export OMP_NUM_THREADS=1

# Load castep module
export CASTEP=/usr/local/packages/castep/8.0.0-phase1/bin/castep.mpi

# Run with 120 MPI processes (n), 24 per 24 core node (N),
# split 12 per NUMA region (S), one thread per MPI process (d)
# and one hyperthread per core (j). This is 5 nodes
echo "Starting castep"
aprun -n 120 -N 24 -S 12 -d 1 -j 1 $CASTEP {basename}
echo "Castep done"
"""

def create_runcastep(basename, filename='runcastep.sh'):

f = open(filename, 'w')
f.write(_SCRIPT.format(basename=basename))
f.close()

if __name__ == "__main__":
import sys
import os

for dir in sys.argv[1:]:
file = os.path.join(dir, 'runcastep.sh')
create_runcastep(dir, file)

25 changes: 25 additions & 0 deletions scripts/setup_gsf_phaseD.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python

import numpy as np

from pyDis.atomic import crystal as cry
from pyDis.atomic import castep_utils as cas
from pyDis.atomic import atomistic_utils as atm
from pyDis.pn import gsf_setup as gsf

path_to_phased = './'
sc_length = 6 # Number of unit cells along z
# must be an even number in this case.
resolution = 0.33 # Spacing of points in x and y

phaseD = cas.CastepCrystal()
sys_info = cas.parse_castep('phaseD.cell', phaseD,
path=path_to_phased)
phaseD.translate_cell(0.02*cry.ei(3))

slab = gsf.make_slab(phaseD,sc_length, free_atoms=['Mg', 'O', 'H'])
atm.scale_kpoints(sys_info['mp_kgrid'],np.array([1,1,sc_length]))

gsf.gamma_surface(slab,resolution,cas.write_castep,sys_info,
basename='gsf_phaseD',suffix='cell', limits=(0.5, 0.5),
mkdir=True)