Two carbon atoms. Screenshot taken from Jmol software. <http://jmol.sourceforge.net/> |
Installation
SIESTAstepper is packaged as a software library available from the package repository PyPI. As such it can notably be installed with pip
or pipenv
.
To install SIESTAstepper:
$ pip install SIESTAstepper
This project is under active development, please make sure you keep it up-to-date to benefit from latest improvements:
# to make sure you have the latest version
$ pip install -U SIESTAstepper
# latest available code base
$ pip install -U git+https://github.com/eftalgezer/SIESTAstepper.git
Important remarks
All SIESTA working directories must be named as i1, i2, i3 ... and so on.
First steps
In this tutorial, we will do some calculations for two carbon atoms in SIESTA. A special constraint is defined between carbon atoms in SIESTA source code.
First, let's create a folder called Carbon
. We will do our calculation in five steps. Let's create folders called i1
, i2
, i3
, i4
, i5
in Carbon
. Copy your pseudopotential file C.psf
inside Carbon
. We created the pair
files which our SIESTA constraint script requires inside i*
. We will not go into details of the constaint, just use it here.
Create your FDF file C.fdf
in Carbon
but leave the AtomicCoordinatesAndAtomicSpecies
block empty. We will generate it from XYZ file.
Create C.xyz
in Carbon
as following:
2
C 0.000 0.0000 0.00
C 2.000 0.0000 0.00
Using in code
Create script.py
file in Carbon
.
Import the package SIESTAstepper
.
import SIESTAstepper
Import the built-in package os
to set the working directory.
import os
Set your working directory by using:
SIESTAstepper.cwd = os.getcwd()
If you are running SIESTA in Anaconda, set your environment name with:
SIESTAstepper.conda = "envir" # to work with Anaconda
If you are willing to run SIESTA in parallel with mpirun
command, set your cores with:
SIESTAstepper.cores = 4 # to set number of cores for parallel run
If you need to copy individual files to next step:
SIESTAstepper.contfiles.extend(["file1", "file2"]) # to copy individual files
If you need to create folders i*:
SIESTAstepper.make_directories(5) # to create folder if you are not created at first
To copy psf
files inside i1
:
SIESTAstepper.copy_files(["psf"], "C", ".", "i1")
Now we will convert our XYZ file C.xyz
to FDF and inject it to AtomicCoordinatesAndAtomicSpecies
block in C.fdf
.
SIESTAstepper.xyz_to_fdf("C.xyz", "C.fdf", "i1/C.fdf")
To start calculation:
SIESTAstepper.run("C")
Save your script.py
file. Open a terminal window and change your directory to Carbon
. Run the following:
$ python script.py
The output is:
Copying ./C.psf to i1/C.psf
./C.psf is copied to i1/C.psf successfully
Reading C.xyz
Reading C.fdf
Creating i1/C.fdf
i1/C.fdf is created
Changed directory to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i1
Running SIESTA for i1
PID is 4040346
#####
SIESTA output
#####
i1/log: Job completed
Reading i1/C.ANI
Reading i1/C.fdf
Creating i2/C.fdf
i2/C.fdf is created
Reading i1/C.ANI
Reading i1/C.fdf
Creating i2/C.fdf
i2/C.fdf is created
Copying /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i1/C.psf to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i2/C.psf
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i1/C.psf is copied to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i2/C.psf successfully
Changed directory to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i2
Running SIESTA for i2
PID is 4042112
#####
SIESTA output
#####
i2/log: Job completed
Reading i2/C.ANI
Reading i2/C.fdf
Creating i3/C.fdf
i3/C.fdf is created
Reading i2/C.ANI
Reading i2/C.fdf
Creating i3/C.fdf
i3/C.fdf is created
Copying /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i2/C.psf to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/C.psf
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i2/C.psf is copied to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/C.psf successfully
Changed directory to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3
Running SIESTA for i3
PID is 4043298
#####
SIESTA output
#####
i3/log: Job completed
Reading i3/C.ANI
Reading i3/C.fdf
Creating i4/C.fdf
i4/C.fdf is created
Reading i3/C.ANI
Reading i3/C.fdf
Creating i4/C.fdf
i4/C.fdf is created
Copying /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/C.psf to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4/C.psf
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/C.psf is copied to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4/C.psf successfully
Changed directory to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4
Running SIESTA for i4
PID is 4045478
#####
SIESTA output
#####
i4/log: Job completed
Reading i4/C.ANI
Reading i4/C.fdf
Creating i5/C.fdf
i5/C.fdf is created
Reading i4/C.ANI
Reading i4/C.fdf
Creating i5/C.fdf
i5/C.fdf is created
Copying /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4/C.psf to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i5/C.psf
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4/C.psf is copied to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i5/C.psf successfully
Changed directory to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i5
Running SIESTA for i5
PID is 4047427
#####
SIESTA output
#####
All iterations are completed
Now let's do analysis. Create analysis.py
in Carbon
Import the package SIESTAstepper
.
import SIESTAstepper
Import the built-in package os
to set the working directory.
import os
Set your working directory by using:
SIESTAstepper.cwd = os.getcwd()
To merge ANI files:
SIESTAstepper.merge_ani(label="C")
SIESTAstepper.merge_ani(label="C", path="i*/dir") #if you need to change the path
To analyse data:
SIESTAstepper.analysis()
data = SIESTAstepper.analysis() #if you are willing to use the data and do something
data = SIESTAstepper.analysis(plot_=False) #if you are willing to use the data and do something and don't want any figure
SIESTAstepper.analysis(path="i*/dir") #if you need to change the path
Save your analysis.py
file. Open a terminal window and change your directory to Carbon
. Run the following:
$ python analysis.py
The output is:
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/C-merged.ANI is opened
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i1/C.ANI
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i2/C.ANI
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/C.ANI
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4/C.ANI
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i5/C.ANI
All ANI files are merged
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i1/log
-297.982681
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i2/log
-299.171055
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/log
-299.791356
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4/log
-299.845957
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i5/log
-299.498399
What happens if a calculation is interrupted?
In this case, we will consider the case if the calculation is interrupted. Let's consider that our calculation is interrupted in i3.
Running the function run_interrupted
will create a folder continue
under i3
, then the function will copy the FDF, PSF, XV, DM files under it from i3
.
Create script2.py
in Carbon
.
import SIESTAstepper
import os
SIESTAstepper.cwd = os.getcwd()
Set the continuation folder name:
SIESTAstepper.cont = "continue" # default is "continue"
Set the filenames to copy to next step or continuation folder:
SIESTAstepper.contfiles.append("pair")
SIESTAstepper.contfiles.extend(["file1", "file2"]) # if you have more than one file
Run SIESTA from third step:
SIESTAstepper.run_interrupted("3", "C")
Or:
SIESTAstepper.run("C")
The output is:
Making directory 'continue' under i3
Copying /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/C.psf to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/continue/C.psf
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/C.psf is copied to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/continue/C.psf successfully
Copying /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/C.fdf to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/continue/C.fdf
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/C.fdf is copied to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/continue/C.fdf successfully
Copying /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/C.XV to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/continue/C.XV
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/C.XV is copied to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/continue/C.XV successfully
Copying /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/C.DM to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/continue/C.DM
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/C.DM is copied to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/continue/C.DM successfully
Copying /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/pair to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/continue/pair
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/pair is copied to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/continue/pair successfully
Changed directory to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/continue
Opening /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/continue/C.fdf
Setting 'DM.UseSaveDM' and 'MD.UseSaveXV' as '.true.' in /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/continue/C.fdf
Running SIESTA for i3/continue
PID is 4131598
#####
SIESTA output
#####
i3/continue/log: Job completed
Reading i3/continue/C.ANI
Reading i3/continue/C.fdf
Creating i4/C.fdf
i4/C.fdf is created
Copying /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/continue/C.psf to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4/C.psf
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/continue/C.psf is copied to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4/C.psf successfully
Copying /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/continue/pair to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4/pair
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4/pair exists
Changed directory to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4
Running SIESTA for i4
PID is 4132719
#####
SIESTA output
#####
i4/log: Job completed
Reading i4/C.ANI
Reading i4/C.fdf
Creating i5/C.fdf
i5/C.fdf is created
Reading i4/C.ANI
Reading i4/C.fdf
Creating i5/C.fdf
i5/C.fdf is created
Copying /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4/C.psf to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i5/C.psf
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4/C.psf is copied to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i5/C.psf successfully
Copying /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4/pair to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i5/pair
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i5/pair exists
Changed directory to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i5
Running SIESTA for i5
PID is 4133044
#####
SIESTA output
#####
All iterations are completed
Now let's do analysis. Create analysis.py
in Carbon
.
Import the package SIESTAstepper
.
import SIESTAstepper
Import the built-in package os
to set the working directory.
import os
Set your working directory by using:
SIESTAstepper.cwd = os.getcwd()
Set the continuation folder name:
SIESTAstepper.cont = "continue" # default is "continue"
To merge ANI files:
SIESTAstepper.merge_ani(label="C")
SIESTAstepper.merge_ani(label="C", path="i*/dir") #if you need to change the path
To analyse data:
SIESTAstepper.analysis()
data = SIESTAstepper.analysis() #if you are willing to use the data and do something
data = SIESTAstepper.analysis(plot_=False) #if you are willing to use the data and do something and don't want any figure
SIESTAstepper.analysis(path="i*/dir") #if you need to change the path
Save your analysis.py
file. Open a terminal window and change your directory to Carbon
. Run the following:
$ python analysis.py
The output is:
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/C-merged.ANI is opened
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i1/C.ANI
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i2/C.ANI
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/C.ANI
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/continue/C.ANI
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4/C.ANI
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i5/C.ANI
All ANI files are merged
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i1/log
-297.982681
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i2/log
-299.171055
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/continue/log
-299.791356
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4/log
-299.845957
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i5/log
-299.498399
Using in terminal
Open your terminal and change your directory to Carbon
by using cd
command.
Copy psf files to i1
.
$ python -m SIESTAstepper copy_files C /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i1 psf
The output is:
Copying /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/C.psf to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i1/C.psf
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/C.psf is copied to /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i1/C.psf successfully
Create the fdf file in i1
.
$ python -m SIESTAstepper xyz_to_fdf C.xyz C.fdf i1/C.fdf
The output is:
Reading C.xyz
Reading C.fdf
Creating i1/C.fdf
i1/C.fdf is created
To start calculation:
$ python -m SIESTAstepper run log C
Or, create an script.sh
file inside Carbon
with the commands above and run in terminal in Carbon
directory.
$ sh script.sh
To merge ANI files:
$ python -m SIESTAstepper merge_ani C
$ python -m SIESTAstepper merge_ani graphene path=i*/dir # if you need to change to path
The output is
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/C-merged.ANI is opened
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i1/C.ANI
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i2/C.ANI
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/C.ANI
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4/C.ANI
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i5/C.ANI
All ANI files are merged
To analyse data:
$ python -m SIESTAstepper analysis log
$ python -m SIESTAstepper analysis log noplot # if you don't want any figure
$ python -m SIESTAstepper analysis log path=i*/dir # if you need to change the path
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i1/log
-297.982681
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i2/log
-299.171055
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/log
-299.791356
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4/log
-299.845957
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i5/log
-299.498399
Or, create an analysis.sh
file inside Carbon
with the commands above and run in terminal in Carbon
directory.
$ sh analysis.sh
For the interrupted calculation
$ python -m SIESTAstepper run_interrupted log 3 C cont=continue contfiles=pair
$ python -m SIESTAstepper run_interrupted log 3 C cont=continue contfiles=file1,file2 #if you have more than one file
$ python -m SIESTAstepper run log C cont=continue contfiles=pair
Or, create an script2.sh
file inside Carbon
with the commands above and run in terminal in Carbon
directory.
$ sh script2.sh
To merge ANI files:
$ python -m SIESTAstepper merge_ani C cont=continue
$ python -m SIESTAstepper merge_ani C cont=continue path=i*/dir # if you need to change the path
The output is:
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/C-merged.ANI is opened
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i1/C.ANI
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i2/C.ANI
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/C.ANI
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/continue/C.ANI
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4/C.ANI
Writing /home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i5/C.ANI
All ANI files are merged
To analyse data:
$ python -m SIESTAstepper analysis log cont=continue
$ python -m SIESTAstepper analysis log noplot cont=continue # if you don't want any figure
$ python -m SIESTAstepper analysis log cont=continue path=i*/dir # if you need to change the path
The output is:
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i1/log
-297.982681
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i2/log
-299.171055
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i3/continue/log
-299.791356
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i4/log
-299.845957
/home/egezer/Desktop/SIESTAstepper_tutorial/Carbon/i5/log
-299.498399
Citation
If you are using SIESTAstepper, please citate relevant version. You can find relevant citation here.
@software{eftal_gezer_2022_7080175,
author = {Eftal Gezer},
title = {eftalgezer/SIESTAstepper: v1.0.0},
month = sep,
year = 2022,
publisher = {Zenodo},
version = {v1.0.0},
doi = {10.5281/zenodo.7080175},
url = {https://doi.org/10.5281/zenodo.7080175}
}
0 comments:
Post a Comment