In [2]:
import sys
import numpy as np
from siman import header
from siman.header      import db # database dictionary
from siman.SSHTools import SSHTools
from siman.calc_manage import smart_structure_read, add, res
from siman.geo         import supercell
from siman.database    import read_database, write_database
from siman.picture_functions import fit_and_plot
from siman.set_functions import read_vasp_sets

read_database() # read saved results

user = "d.aksenov"
host = "10.30.16.168"
header.ssh_object = SSHTools()
header.ssh_object.setup(user=user, host=host, pkey="/home/aksenov/.ssh/id_rsa")
header.PATH2POTENTIALS = 'potcars/' # path to POTCAR files

In [2]:
st = smart_structure_read(input_geo_file = 'Li2/POSCAR') # read poscar
sc = supercell(st, [10,3,3]) # create 3x1x1 supercell, sizes close to 10 3 3 A; we need slab!


-- Calculating mul_matrix for ortho: [10, 3, 3] 

mul_matrix_float:
 [[2.91205591 0.         0.        ]
 [0.         0.87361677 0.        ]
 [0.         0.         0.87361677]] 
mul_matrix:
 [[3 0 0]
 [0 1 0]
 [0 0 1]] 
Old vectors (rprimd):
 [[3.4 0.  0. ]
 [0.  3.4 0. ]
 [0.  0.  3.4]] 
New vectors (rprimd) of supercell:
 [[10.3  0.   0. ]
 [ 0.   3.4  0. ]
 [ 0.   0.   3.4]] 
The supercell should contain 5.999999999999999 atoms ... 
  -- OK 

Create 100 surfaces with different vacuum thickness, run and read


In [3]:
thickness_list = [1,2,3,4,5,6,7,8,9,10]
add('Li311',    'opt', 1, up = 'up2', input_st = sc, it_folder = 'recitationCD/',     run = 0) 

for thickness in thickness_list:
    ''
    add('Li_suf_'+str(thickness), 'opt', 1, up = 'up2', input_st = sc.add_vacuum(0, thickness), it_folder = 'recitationCD/', run = 0)


-- Attention!, cluster None is not found, using default CEE 

-- check_kpoints(): Kpoint   mesh is:  [4, 10, 10] 

-- check_kpoints(): The actual k-spacings are  [0.15 0.18 0.18] 

-- POSCAR was written to /home/aksenov/recitations/Rec10_DS/recitationCD///Li311.opt/1.POSCAR 

-- Attention! ngkpt =  [4, 10, 10]  is adopted from struct_des which you provided for it  Li311  and kspacing =  0.2 


Calculation ('Li311', 'opt', 1) successfully created

 

-- Attention!, cluster None is not found, using default CEE 

-- check_kpoints(): Kpoint   mesh is:  [3, 10, 10] 

-- check_kpoints(): The actual k-spacings are  [0.19 0.18 0.18] 

-- POSCAR was written to /home/aksenov/recitations/Rec10_DS/recitationCD///Li_suf_1.opt/1.POSCAR 

-- Attention! ngkpt =  [3, 10, 10]  is adopted from struct_des which you provided for it  Li_suf_1  and kspacing =  0.2 


Calculation ('Li_suf_1', 'opt', 1) successfully created

 

-- Attention!, cluster None is not found, using default CEE 

-- check_kpoints(): Kpoint   mesh is:  [3, 10, 10] 

-- check_kpoints(): The actual k-spacings are  [0.17 0.18 0.18] 

-- POSCAR was written to /home/aksenov/recitations/Rec10_DS/recitationCD///Li_suf_2.opt/1.POSCAR 

-- Attention! ngkpt =  [3, 10, 10]  is adopted from struct_des which you provided for it  Li_suf_2  and kspacing =  0.2 


Calculation ('Li_suf_2', 'opt', 1) successfully created

 

-- Attention!, cluster None is not found, using default CEE 

-- check_kpoints(): Kpoint   mesh is:  [3, 10, 10] 

-- check_kpoints(): The actual k-spacings are  [0.16 0.18 0.18] 

-- POSCAR was written to /home/aksenov/recitations/Rec10_DS/recitationCD///Li_suf_3.opt/1.POSCAR 

-- Attention! ngkpt =  [3, 10, 10]  is adopted from struct_des which you provided for it  Li_suf_3  and kspacing =  0.2 


Calculation ('Li_suf_3', 'opt', 1) successfully created

 

-- Attention!, cluster None is not found, using default CEE 

-- check_kpoints(): Kpoint   mesh is:  [3, 10, 10] 

-- check_kpoints(): The actual k-spacings are  [0.15 0.18 0.18] 

-- POSCAR was written to /home/aksenov/recitations/Rec10_DS/recitationCD///Li_suf_4.opt/1.POSCAR 

-- Attention! ngkpt =  [3, 10, 10]  is adopted from struct_des which you provided for it  Li_suf_4  and kspacing =  0.2 


Calculation ('Li_suf_4', 'opt', 1) successfully created

 

-- Attention!, cluster None is not found, using default CEE 

-- check_kpoints(): Kpoint   mesh is:  [3, 10, 10] 

-- check_kpoints(): The actual k-spacings are  [0.14 0.18 0.18] 

-- POSCAR was written to /home/aksenov/recitations/Rec10_DS/recitationCD///Li_suf_5.opt/1.POSCAR 

-- Attention! ngkpt =  [3, 10, 10]  is adopted from struct_des which you provided for it  Li_suf_5  and kspacing =  0.2 


Calculation ('Li_suf_5', 'opt', 1) successfully created

 

-- Attention!, cluster None is not found, using default CEE 

-- check_kpoints(): Kpoint   mesh is:  [2, 10, 10] 

-- check_kpoints(): The actual k-spacings are  [0.19 0.18 0.18] 

-- POSCAR was written to /home/aksenov/recitations/Rec10_DS/recitationCD///Li_suf_6.opt/1.POSCAR 

-- Attention! ngkpt =  [2, 10, 10]  is adopted from struct_des which you provided for it  Li_suf_6  and kspacing =  0.2 


Calculation ('Li_suf_6', 'opt', 1) successfully created

 

-- Attention!, cluster None is not found, using default CEE 

-- check_kpoints(): Kpoint   mesh is:  [2, 10, 10] 

-- check_kpoints(): The actual k-spacings are  [0.18 0.18 0.18] 

-- POSCAR was written to /home/aksenov/recitations/Rec10_DS/recitationCD///Li_suf_7.opt/1.POSCAR 

-- Attention! ngkpt =  [2, 10, 10]  is adopted from struct_des which you provided for it  Li_suf_7  and kspacing =  0.2 


Calculation ('Li_suf_7', 'opt', 1) successfully created

 

-- Attention!, cluster None is not found, using default CEE 

-- check_kpoints(): Kpoint   mesh is:  [2, 10, 10] 

-- check_kpoints(): The actual k-spacings are  [0.17 0.18 0.18] 

-- POSCAR was written to /home/aksenov/recitations/Rec10_DS/recitationCD///Li_suf_8.opt/1.POSCAR 

-- Attention! ngkpt =  [2, 10, 10]  is adopted from struct_des which you provided for it  Li_suf_8  and kspacing =  0.2 


Calculation ('Li_suf_8', 'opt', 1) successfully created

 

-- Attention!, cluster None is not found, using default CEE 

-- check_kpoints(): Kpoint   mesh is:  [2, 10, 10] 

-- check_kpoints(): The actual k-spacings are  [0.16 0.18 0.18] 

-- POSCAR was written to /home/aksenov/recitations/Rec10_DS/recitationCD///Li_suf_9.opt/1.POSCAR 

-- Attention! ngkpt =  [2, 10, 10]  is adopted from struct_des which you provided for it  Li_suf_9  and kspacing =  0.2 


Calculation ('Li_suf_9', 'opt', 1) successfully created

 

-- Attention!, cluster None is not found, using default CEE 

-- check_kpoints(): Kpoint   mesh is:  [2, 10, 10] 

-- check_kpoints(): The actual k-spacings are  [0.15 0.18 0.18] 

-- POSCAR was written to /home/aksenov/recitations/Rec10_DS/recitationCD///Li_suf_10.opt/1.POSCAR 

-- Attention! ngkpt =  [2, 10, 10]  is adopted from struct_des which you provided for it  Li_suf_10  and kspacing =  0.2 


Calculation ('Li_suf_10', 'opt', 1) successfully created

 


In [4]:
res('Li311',    'opt', 1)
for thickness in thickness_list:
    ''
    res('Li_suf_'+str(thickness), 'opt', 1, up = 'up1')



Max. F. tot  (meV/A) = 
[0]; 

-- name                          |  energy(eV)|    Vector lenghts (A)   | Stresses (MPa)     | N MD, N SCF    
-- db['Li311.opt.1']             |  -11.3790  |10.30;3.43;3.43|   -184,175,175     |   1, 9,  9    


Max. F. tot  (meV/A) = 
[342 323 130 121 116 110  84  77  67  68  70  66  42  28  30  30  28  26
  24  22]; 

-- name                          |  energy(eV)|    Vector lenghts (A)   | Stresses (MPa)     | N MD, N SCF    
-- db['Li_suf_1.opt.1']          |  -11.3258  |11.30;3.43;3.43|  -1197,-983,-983   |  20, 4, 85    


Max. F. tot  (meV/A) = 
[308 298 197 187 169 151 141 145 142 137 116 106 100  67  65  56  48  33
  27  27]; 

-- name                          |  energy(eV)|    Vector lenghts (A)   | Stresses (MPa)     | N MD, N SCF    
-- db['Li_suf_2.opt.1']          |  -11.1996  |12.30;3.43;3.43| -1938,-1713,-1713  |  20, 5,104    


Max. F. tot  (meV/A) = 
[200 192 113 108  95  92  83  82  79  80  91  97  80  96  97 119  88  73
  68  68]; 

-- name                          |  energy(eV)|    Vector lenghts (A)   | Stresses (MPa)     | N MD, N SCF    
-- db['Li_suf_3.opt.1']          |  -11.0413  |13.30;3.43;3.43| -2103,-2284,-2284  |  20, 5,109    
-- Attention!, SCF was not converged to desirable prec -0.015 > 0.01 meV 



Max. F. tot  (meV/A) = 
[126 119  60  52  44  41  42  43  41  35  34  28  27  19  18  14  13  11
  11  14]; 

-- name                          |  energy(eV)|    Vector lenghts (A)   | Stresses (MPa)     | N MD, N SCF    
-- db['Li_suf_4.opt.1']          |  -10.7481  |14.30;3.43;3.43| -1239,-1273,-1273  |  20, 4, 88    
-- Attention!, SCF was not converged to desirable prec 0.012 > 0.01 meV 



Max. F. tot  (meV/A) = 
[98 92 33 31 29 26 21 20 16  7]; 

-- name                          |  energy(eV)|    Vector lenghts (A)   | Stresses (MPa)     | N MD, N SCF    
-- db['Li_suf_5.opt.1']          |  -10.7081  |15.30;3.43;3.43|  -183,-868,-868    |  10, 4, 45    


Max. F. tot  (meV/A) = 
[93 87 29 28 26 23 21 18 20 22 20 19 18 16 15 14 14 13  8]; 

-- name                          |  energy(eV)|    Vector lenghts (A)   | Stresses (MPa)     | N MD, N SCF    
-- db['Li_suf_6.opt.1']          |  -10.7018  |16.30;3.43;3.43|   -54,-788,-788    |  19, 3, 70    
-- Attention!, SCF was not converged to desirable prec 0.014 > 0.01 meV 



Max. F. tot  (meV/A) = 
[92 85 27 26 30 30 30 28 20 20 18 18 18 16 17 17 16 14 16 15]; 

-- name                          |  energy(eV)|    Vector lenghts (A)   | Stresses (MPa)     | N MD, N SCF    
-- db['Li_suf_7.opt.1']          |  -10.6980  |17.30;3.43;3.43|   84,-664,-664     |  20, 3, 64    


Max. F. tot  (meV/A) = 
[91 85 28 26 24 23 24 22 21 19 16 16 43 15 14 16 16 11 11  9]; 

-- name                          |  energy(eV)|    Vector lenghts (A)   | Stresses (MPa)     | N MD, N SCF    
-- db['Li_suf_8.opt.1']          |  -10.6996  |18.30;3.43;3.43|   -49,-714,-714    |  20, 3, 77    


Max. F. tot  (meV/A) = 
[91 85 28 26 25 22 18 18 15  9]; 

-- name                          |  energy(eV)|    Vector lenghts (A)   | Stresses (MPa)     | N MD, N SCF    
-- db['Li_suf_9.opt.1']          |  -10.6987  |19.30;3.43;3.43|   35,-633,-633     |  10, 4, 46    


Max. F. tot  (meV/A) = 
[91 86 28 26 24 25 24 22 21 17 14 15 14 12 10]; 

-- name                          |  energy(eV)|    Vector lenghts (A)   | Stresses (MPa)     | N MD, N SCF    
-- db['Li_suf_10.opt.1']         |  -10.6991  |20.30;3.43;3.43|   10,-615,-615     |  15, 4, 66    

In [5]:
Li311 = db['Li311', 'opt', 1] 
A = np.linalg.norm( np.cross(Li311.end.rprimd[1] , Li311.end.rprimd[2]) ) # surface area

gamma_list = []
for thickness in thickness_list:
    Li_suf = db['Li_suf_'+str(thickness), 'opt', 1]

    gamma = (Li_suf.e0 - Li311.e0)/A * header.eV_A_to_J_m / 2
    gamma_list.append(gamma)
    print('Surface energy = {:3.3f} J/m2; vacuum thickness = {:2d} A'.format(gamma, thickness) )


Surface energy = 0.036 J/m2; vacuum thickness =  1 A
Surface energy = 0.122 J/m2; vacuum thickness =  2 A
Surface energy = 0.229 J/m2; vacuum thickness =  3 A
Surface energy = 0.429 J/m2; vacuum thickness =  4 A
Surface energy = 0.456 J/m2; vacuum thickness =  5 A
Surface energy = 0.460 J/m2; vacuum thickness =  6 A
Surface energy = 0.463 J/m2; vacuum thickness =  7 A
Surface energy = 0.462 J/m2; vacuum thickness =  8 A
Surface energy = 0.462 J/m2; vacuum thickness =  9 A
Surface energy = 0.462 J/m2; vacuum thickness = 10 A

In [6]:
fit_and_plot(a = (thickness_list, gamma_list, '-o'), filename = None, ylabel = 'Surface energy, J/m$^2$', xlabel = 'Vacuum thickness, $\AA$')


Out[6]:
''

Optimize 100 surface


In [7]:
sc = supercell(st, [10,10,10]) # create 3x3x3 supercell, sizes close to 10 10 10 A; we need slab!
thickness = 5
read_vasp_sets([('opt_sym0', 'opt',{'ISYM':0})]) #create new set: optimization without symetry constraints
# add('Li333_suf_'+str(thickness), 'opt_sym0', 1, up = 'up2', input_st = sc.add_vacuum(0, thickness), it_folder = 'recitationCD/', run = 0)


-- Calculating mul_matrix for ortho: [10, 10, 10] 

mul_matrix_float:
 [[2.91205591 0.         0.        ]
 [0.         2.91205591 0.        ]
 [0.         0.         2.91205591]] 
mul_matrix:
 [[3 0 0]
 [0 3 0]
 [0 0 3]] 
Old vectors (rprimd):
 [[3.4 0.  0. ]
 [0.  3.4 0. ]
 [0.  0.  3.4]] 
New vectors (rprimd) of supercell:
 [[10.3  0.   0. ]
 [ 0.  10.3  0. ]
 [ 0.   0.  10.3]] 
The supercell should contain 53.999999999999986 atoms ... 
  -- OK 

-- Attention!, cluster None is not found, using default CEE 

-- check_kpoints(): Kpoint   mesh is:  [3, 4, 4] 

-- check_kpoints(): The actual k-spacings are  [0.14 0.15 0.15] 

-- POSCAR was written to /home/aksenov/recitations/Rec10_DS/recitationCD///Li333_suf_5.opt_sym0/1.POSCAR 

-- Attention! ngkpt =  [3, 4, 4]  is adopted from struct_des which you provided for it  Li333_suf_5  and kspacing =  0.2 


Calculation ('Li333_suf_5', 'opt_sym0', 1) successfully created

 

Out[7]:
'Li333_suf_5'

In [5]:
thickness = 5
res('Li333_suf_'+str(thickness), 'opt_sym0', 1, up = 'up1')



Max. F. tot  (meV/A) = 
[69 61 25 23 19 15 13 14 16 16 13 13 12 12 12  8]; 

-- name                          |  energy(eV)|    Vector lenghts (A)   | Stresses (MPa)     | N MD, N SCF    
-- db['Li333_suf_5.opt_sym0.1']  |  -96.3091  |15.30;10.30;10.30|  -103,-646,-646    |  16, 4, 69    
Out[5]:
(["db['Li333_suf_5.opt_sym0.1']  |  -96.3091  |15.30;10.30;10.30|  -103,-646,-646    |  16, 4, 69   "],
 [])

In [9]:
write_database()


Database has been successfully updated


In [10]:
db['Li333_suf_5.opt_sym0.1'].jmol() #open with jmol


-- POSCAR was written to /home/aksenov/recitations/Rec10_DS/xyz/POSCAR_Li333_suf_5_opt_sym0_1_end 


In [ ]: