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
37 changes: 37 additions & 0 deletions capolanco/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# K-point convergence tracker (Materials)

> Ideal candidate: scientists skilled in Density Functional Theory and proficient in python.

# Overview

The aim of this task is to create a python package that implements automatic convergence tracking mechanism for a materials simulations engine. The convergence is tracked with respect to the k-point sampling inside a reciprocal cell of a crystalline compound.

# Requirements

1. automatically find the dimensions of a k-point mesh that satisfy a certain criteria for total energy (eg. total energy is converged within dE = 0.01meV)
1. the code shall be written in a way that can facilitate easy addition of convergence wrt other characteristics extracted from simulations (forces, pressures, phonon frequencies etc)
1. the code shall support VASP or Quantum ESPRESSO

# Expectations

- correctly find k-point mesh that satisfies total energy convergence parameters for a set of 10 materials, starting from Si2, as simplest, to a 10-20-atom supercell of your choice
- modular and object-oriented implementation
- commit early and often - at least once per 24 hours

# Timeline

We leave exact timing to the candidate. Must fit Within 5 days total.

# User story

As a user of this software I can start it passing:

- path to input data (eg. pw.in / POSCAR, INCAR, KPOINTS) and
- kinetic energy cutoff

as parameters and get the k-point dimensions (eg. 5 5 5).

# Notes

- create an account at exabyte.io and use it for the calculation purposes
- suggested modeling engine: Quantum ESPRESSO
121 changes: 121 additions & 0 deletions capolanco/RunConvergence.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# This code will run a k-point convergence up to a desire delta energy

import subprocess
import ioqeclass as qe
import ioclusterclass as cluster

###########################
##### USER INPUTS
###########################

# Define the path of the input file
# The k-grid of this file will be set as the starting point
# for the convergence process
filein='Si.scf.in'

# Define delta energy threshold for
# convergence (eV)
dEthreshold=1.0 # (eV)


###########################
##### DEVELOPERS INPUTS
###########################

## Convergence
# maximum of iterations
Nitermax=20
# increasing step of kgrid
kstep=2

## Cluster
# number of nodes to be used
Nnodes=1
# number of processors per node
ppn=8
# queue
queue='OR'
# walltime
walltimehours=5
walltimeminutes=3


###########################
##### PROGRAM
###########################


### Set up initial parameters
# Initialize pw.x input class
qeinput=qe.qepwinput()
# load the pw.x input
qeinput.load(filein)
# Create the input file for initial run
testin='test.scf.in'
testout='test.scf.out'
qeinput.save(filein,testin)
# Create the job to send to the cluster
# Initialize job class
job=cluster.jobclass()
# set up job class
job.name='test'
job.nodes=Nnodes
job.ppn=ppn
job.queue=queue
job.walltimehours=walltimehours
job.walltimeminutes=walltimeminutes
# create the job file
jobname=f'job.test.sh'
job.createjobQEpw(jobname,testin,testout)
# Run initial test
subprocess.run(['echo',f'runing {jobname}'])
##subprocess.run(['qsub',f'{jobname}'])

# Initialize pw.x output class
qeoutput=qe.qepwoutput()
# Read the Total energy from the output
qeoutput.getenergy(testout)


# Loop testing for dE
dE=2.0*dEthreshold
EnergyOld=qeoutput.energy
counter=0
while ((dE>dEthreshold) and (counter<Nitermax)):

# Increase counter
counter=counter+1
print(f'\n## Iteration {counter}')

# Increase k grid
qeinput.kgrid=qeinput.kgrid+kstep

# Create the input file for initial run
testin=f'test.scf{counter}.in'
testout=f'test.scf{counter}.out'
qeinput.save(filein,testin)

# create the job file
jobname=f'job.test{counter}.sh'
job.createjobQEpw(jobname,testin,testout)
# Run QE calculation
subprocess.run(['echo',f'runing {jobname}'])
##subprocess.run(['qsub',f'{jobname}'])

# Read the Total energy from the output
qeoutput.getenergy(testout)

# Update dE and EnergyOld
dE=abs(EnergyOld-qeoutput.energy)
EnergyOld=qeoutput.energy
print(f'dE {dE} eV')

# Display results
if (dE<dEthreshold):
print(f'Convergence has been achieved in {counter} iterations')
print(f'for kgrid {qeinput.kgrid}')
print(f'The total enegy change is less than {dEthreshold} eV')
else:
print(f'Convergence has NOT been achieved in {counter} iterations')


30 changes: 30 additions & 0 deletions capolanco/Si.scf.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
&control
calculation='scf',
outdir = '/global/cscratch1/sd/cpolanco/Si/',
prefix='Si',
pseudo_dir = '/global/homes/c/cpolanco/Materials/pseudo/',
restart_mode='from_scratch',
tprnfor= .true.,
tstress= .true.,
/
&system
ibrav= 2,
celldm(1)= 10.20777693,
nat= 2,
ntyp= 1,
ecutwfc= 100.0
/
&electrons
mixing_beta= 0.7
conv_thr= 1.0d-14
/

ATOMIC_SPECIES
Si 28.086 Si.pz-vbc.UPF

ATOMIC_POSITIONS (alat)
Si 0.00 0.00 0.00
Si 0.25 0.25 0.25

K_POINTS (automatic)
8 8 8 0 0 0
Loading