Structure of the water molecule

This Notebook is oriented on Chapter 2 of the CP-PAW Hands-On Course on First-Principles Calculations. It covers the same content while showing different ways how to use the cppawAse interface.

cppawAse preparation

First the path to the cppawAse Files has to be set and the main module loaded. Within the jupyter notebook a path to the directory for the calculation has to be speciefied and added to the calculation label.

In [1]:
import sys
acPath = '/home/pmk/paw/hiwi/AseCppaw'
sys.path.append(acPath)
import AseCppaw
import AseCppawInputFiles

path0 = acPath + '/tests/h2o/'

Input

Within the ASE simulations are run by a calculator that is set to an atoms object containing atom coordinates, cell and border conditions. In cppawAse the calculator is the cppaw class it contains the inputfiles (at least one structure and one control file) and parameters how to run the calculation (single-core, parallel on a cluster with queueing system), backups, restart and what to log. It also contains the results of the simulation. Like total energy, band gap, fermi level etc. The instructions list can minimally contain one entry consisting of the keys 'strc' und 'cntl' or many entries that are simulated in order of the list.

The CP-PAW way

In [2]:
# loading the input files
cntl = AseCppawInputFiles.loadInputFile(path0 + 'h2o.cntl1')
strc = AseCppawInputFiles.loadInputFile(path0 + 'h2o.strc')
# setting them as cppaw input, label is the subfolder were the simulation is located 
calc = AseCppaw.cppaw(instructions=[{'cntl': cntl, 'strc': strc}],
                      label=path0 + 'h2o_220530',
                      report='l',
                      logCalc='l')
Entry ['!OCCUPATIONS', 'SPIN[HBAR]'] does not exist!
Entry ['!OCCUPATIONS', 'NSPIN'] does not exist!
In [3]:
# the ase atoms object is automatically created from the structure file and can be viewed
from ase.visualize import view, ngl
v = view(strc.atoms, viewer='x3d')
v
Out[3]:
ASE atomic visualization

The ASE way

In [4]:
# the ASE provides some common molecules as atoms object within the molecule module
from ase.build import molecule
h2o = molecule('H2O')
v = view(h2o, viewer='x3d')
v
Out[4]:
ASE atomic visualization
In [5]:
# contrary to the CP-PAW structure the h2o molecule doesn't have a unit cell
# the recomended 6.0 Angstrom distance between periodic images can be archived with ASE atom functions
h2o.center(vacuum=6.0)
# setting the periodic boundary condition pbc to False while trigger the CP-PAW !ISOLATE branch
h2o.set_pbc(False)
In [6]:
# ASE automatically chooses an bcc lattice that is suboptimal for CP-PAW calculations
# the cell can be set manually as an list of lists or numpy array
h2o = molecule('H2O')
h2o.set_cell([[0.0, 6.0, 6.0], [6.0, 0.0, 6.0], [6.0, 6.0, 0.0]])
# without viewer='x3d' defined the structure including the unit cell is shown in an interactive external window
view(h2o)
Out[6]:
<subprocess.Popen at 0x1552053a90d0>
In [8]:
# for more complicated cases the lattice parameters can be determined automatically for a given celltype and minimal
# distance between periodic images. A structure file has to be already present. 
import AseCppawTools
h2o = molecule('H2O')
cellparameter = AseCppawTools.makeLattice(celltype='FACE CENTERED', dist=7.0, filename='h2o', directory=path0,
                                          flags='-c')
h2o.set_cell(cellparameter['cell'])
view(h2o)
{'cell': [array([-4.45310576,  4.45206875,  5.15115119]), array([3.82705454, 3.82675737, 5.01881149]), array([-5.03995039e-01,  8.07555314e+00,  1.01619900e-03])], 'distance': 6.747, 'volume': 2283.10724}
Out[8]:
<subprocess.Popen at 0x15520455b1d0>
In [9]:
# the calculater can now be initialized with just the atoms object as input using default control files and setups
calcAse = AseCppaw.cppaw(atoms=h2o,
                         label=path0 + 'h2o_220915',
                         report='l',
                         logCalc='l')

interacting with input objects

In [10]:
# parameters can be accessed by entering the branch as list ...
T = strc.getValue(['!LATTICE', 'T'])
print(T)
[array([0., 6., 6.]), array([6., 0., 6.]), array([6., 6., 0.])]
In [11]:
# The automatically generated input files can be accesed in the instructions in the parameters 
# of the ase calculator object
aseStrc = calcAse.parameters['instructions'][0]['strc']
In [12]:
# ... or as string seperated by , or ; or blank space list 
T = aseStrc.getValue('!LATTICE;T')
print(T)
[[-4.57921923e+00  4.57814412e+00  5.33086538e+00]
 [ 3.95466743e+00  3.95436025e+00  5.19838797e+00]
 [-5.03185937e-01  8.32937907e+00  1.05021400e-03]]
In [13]:
# parameters can be changed in a simular way
print(cntl.getValue('!GENERIC;DT'))
cntl.setValue('!GENERIC;DT', 5.)
print(cntl.getValue('!GENERIC;DT'))
2.5
5.0
In [14]:
# if multiple branches exist a list of lists is used where the first list is the parent branch 
# the second the leaf value pair to identify the branch and the last list the branches from the parent branch 
# the identifier must be a list of the unique leaf here 'NAME' and it's value
Oid = strc.getValue([['!SPECIES'], ['NAME','O_'], ['ID']])
Oid
Out[14]:
'O_.75_6.0'
In [15]:
# alternatively the lists can be indicated in a string with pipe | characters
Hid = strc.getValue('!SPECIES|NAME;H_|ID')
Hid
Out[15]:
'H_.75_6.0'
In [16]:
# if usage or meaning of a parameter is unclear get_help returns the description in the CP-PAW manual
from IPython.display import display, Latex
display(Latex(strc.getHelp('!LATTICE;T')))
Lattice vectors in the order; (x,y,z of first vector; x,y,z of second vector...)

Running a simulation

In [17]:
# the calculation can be started by calling any function that returns a property that requires a calculation
Eurlx = calcAse.get_potential_energy()
# The energy is given in electron volts, the standard unit of the ASE
print(Eurlx)
Calculation cmd send:  THU 15 SEP 2022 15:34 (37.418478S)
!>     1   0.00012     0   0.492318     16.818157     17.310475  0.3000  0.0000
!>     2   0.00024     0   1.687588     14.263306     15.950893  0.2910  0.0000
!>     3   0.00036     0   2.958017     10.282780     13.240797  0.2823  0.0000
!>     4   0.00048     0   3.922091      5.459040      9.381131  0.2738  0.0000
!>     5   0.00060     0   4.425584      0.358104      4.783689  0.2656  0.0000
!>     6   0.00073     0   4.246524     -4.092364      0.154160  0.2576  0.0000
!>     7   0.00085     0   3.495554     -7.236907     -3.741353  0.2499  0.0000
!>     8   0.00097     0   2.680572     -9.373445     -6.692873  0.2424  0.0000
!>     9   0.00109     0   2.136236    -11.087325     -8.951088  0.2351  0.0000
!>    10   0.00121     0   1.795830    -12.570691    -10.774861  0.2281  0.0000
!>    11   0.00133     0   1.487812    -13.744887    -12.257075  0.2212  0.0000
!>    12   0.00145     0   1.157061    -14.561722    -13.404661  0.2146  0.0000
!>    13   0.00157     0   0.841983    -15.079650    -14.237668  0.2082  0.0000
!>    14   0.00169     0   0.586325    -15.398074    -14.811750  0.2019  0.0000
!>    15   0.00181     0   0.402623    -15.599587    -15.196964  0.1959  0.0000
!>    16   0.00194     0   0.279950    -15.735392    -15.455442  0.1900  0.0000
!>    17   0.00206     0   0.200349    -15.832789    -15.632440  0.1843  0.0000
!>    18   0.00218     0   0.148409    -15.905847    -15.757439  0.1787  0.0000
!>    19   0.00230     0   0.113754    -15.962492    -15.848738  0.1734  0.0000
!>    20   0.00242     0   0.090138    -16.007840    -15.917702  0.1682  0.0000
!>    21   0.00254     0   0.073843    -16.045429    -15.971586  0.1631  0.0000
!>    22   0.00266     0   0.062486    -16.077608    -16.015122  0.1582  0.0000
!>    23   0.00278     0   0.054419    -16.105818    -16.051399  0.1535  0.0000
!>    24   0.00290     0   0.048511    -16.130928    -16.082417  0.1489  0.0000
!>    25   0.00302     0   0.044045    -16.153522    -16.109477  0.1444  0.0000
!>    26   0.00314     0   0.040641    -16.174124    -16.133484  0.1401  0.0000
!>    27   0.00327     0   0.038153    -16.193286    -16.155134  0.1359  0.0000
!>    28   0.00339     0   0.036568    -16.211601    -16.175033  0.1318  0.0000
!>    29   0.00351     0   0.035934    -16.229683    -16.193748  0.1279  0.0000
!>    30   0.00363     0   0.036326    -16.248155    -16.211829  0.1240  0.0000
!>    31   0.00375     0   0.037838    -16.267655    -16.229816  0.1203  0.0000
!>    32   0.00387     0   0.040603    -16.288856    -16.248253  0.1167  0.0000
!>    33   0.00399     0   0.044800    -16.312507    -16.267707  0.1132  0.0000
!>    34   0.00411     0   0.050666    -16.339452    -16.288787  0.1098  0.0000
!>    35   0.00423     0   0.058477    -16.370635    -16.312158  0.1065  0.0000
!>    36   0.00435     0   0.068513    -16.407059    -16.338545  0.1033  0.0000
!>    37   0.00447     0   0.080998    -16.449711    -16.368712  0.1002  0.0000
!>    38   0.00460     0   0.096001    -16.499415    -16.403414  0.0972  0.0000
!>    39   0.00472     0   0.113327    -16.556641    -16.443314  0.0943  0.0000
!>    40   0.00484     0   0.132402    -16.621266    -16.488864  0.0915  0.0000
!>    41   0.00496     0   0.152196    -16.692364    -16.540167  0.0887  0.0000
!>    42   0.00508     0   0.171244    -16.768093    -16.596848  0.0861  0.0000
!>    43   0.00520     0   0.187799    -16.845774    -16.657975  0.0835  0.0000
!>    44   0.00532     0   0.200127    -16.922214    -16.722087  0.0810  0.0000
!>    45   0.00544     0   0.206830    -16.994158    -16.787328  0.0785  0.0000
!>    46   0.00556     0   0.207096    -17.058761    -16.851665  0.0762  0.0000
!>    47   0.00568     0   0.200777    -17.113889    -16.913112  0.0739  0.0000
!>    48   0.00581     0   0.188341    -17.158243    -16.969902  0.0717  0.0000
!>    49   0.00593     0   0.170774    -17.191425    -17.020651  0.0695  0.0000
!>    50   0.00605     0   0.149489    -17.213932    -17.064443  0.0674  0.0000
!>    51   0.00617     0   0.126199    -17.227097    -17.100897  0.0654  0.0000
!>    52   0.00629     0   0.102726    -17.232889    -17.130164  0.0635  0.0000
!>    53   0.00641     0   0.080737    -17.233584    -17.152847  0.0616  0.0000
!>    54   0.00653     0   0.044769    -17.231376    -17.186607  0.3000  0.0000
!>    55   0.00665     0   0.012368    -17.230173    -17.217806  0.3000  0.0000
!>    56   0.00677     0   0.005516    -17.230735    -17.225219  0.0597  0.0000
!>    57   0.00689     0   0.005990    -17.232643    -17.226652  0.0579  0.0000
!>    58   0.00701     0   0.006965    -17.235168    -17.228203  0.0562  0.0000
!>    59   0.00714     0   0.007834    -17.237716    -17.229882  0.0545  0.0000
!>    60   0.00726     0   0.008348    -17.239977    -17.231629  0.0529  0.0000
!>    61   0.00738     0   0.008515    -17.241897    -17.233382  0.0513  0.0000
!>    62   0.00750     0   0.008435    -17.243526    -17.235092  0.0497  0.0000
!>    63   0.00762     0   0.008178    -17.244904    -17.236726  0.0482  0.0000
!>    64   0.00774     0   0.007750    -17.246000    -17.238250  0.0468  0.0000
!>    65   0.00786     0   0.007130    -17.246758    -17.239628  0.0454  0.0000
!>    66   0.00798     0   0.006323    -17.247151    -17.240828  0.0440  0.0000
!>    67   0.00810     0   0.005398    -17.247230    -17.241832  0.0427  0.0000
!>    68   0.00822     0   0.003149    -17.247110    -17.243961  0.3000  0.0000
!>    69   0.00835     0   0.001326    -17.247115    -17.245790  0.0414  0.0000
!>    70   0.00847     0   0.001306    -17.247317    -17.246011  0.0402  0.0000
!>    71   0.00859     0   0.001413    -17.247650    -17.246237  0.0390  0.0000
!>    72   0.00871     0   0.001550    -17.248024    -17.246474  0.0378  0.0000
!>    73   0.00883     0   0.001651    -17.248367    -17.246716  0.0367  0.0000
!>    74   0.00895     0   0.001693    -17.248650    -17.246957  0.0356  0.0000
!>    75   0.00907     0   0.001686    -17.248879    -17.247192  0.0345  0.0000
!>    76   0.00919     0   0.001653    -17.249071    -17.247418  0.0335  0.0000
!>    77   0.00931     0   0.001601    -17.249235    -17.247634  0.0325  0.0000
!>    78   0.00943     0   0.001526    -17.249363    -17.247837  0.0315  0.0000
!>    79   0.00955     0   0.001417    -17.249438    -17.248021  0.0305  0.0000
!>    80   0.00968     0   0.001271    -17.249453    -17.248182  0.0296  0.0000
!>    81   0.00980     0   0.000759    -17.249417    -17.248658  0.3000  0.0000
!>    82   0.00992     0   0.000219    -17.249410    -17.249191  0.3000  0.0000
!>    83   0.01004     0   0.000138    -17.249454    -17.249316  0.0287  0.0000
!>    84   0.01016     0   0.000210    -17.249549    -17.249339  0.0279  0.0000
!>    85   0.01028     0   0.000298    -17.249668    -17.249370  0.0270  0.0000
!>    86   0.01040     0   0.000374    -17.249782    -17.249408  0.0262  0.0000
!>    87   0.01052     0   0.000425    -17.249875    -17.249450  0.0254  0.0000
!>    88   0.01064     0   0.000449    -17.249942    -17.249493  0.0247  0.0000
!>    89   0.01076     0   0.000451    -17.249988    -17.249537  0.0239  0.0000
!>    90   0.01088     0   0.000437    -17.250016    -17.249578  0.0232  0.0000
!>    91   0.01101     0   0.000411    -17.250029    -17.249617  0.0225  0.0000
!>    92   0.01113     0   0.000254    -17.250026    -17.249773  0.3000  0.0000
!>    93   0.01125     0   0.000073    -17.250024    -17.249951  0.3000  0.0000
!>    94   0.01137     0   0.000040    -17.250032    -17.249992  0.0219  0.0000
!>    95   0.01149     0   0.000053    -17.250050    -17.249997  0.0212  0.0000
!>    96   0.01161     0   0.000070    -17.250073    -17.250003  0.0206  0.0000
!>    97   0.01173     0   0.000086    -17.250095    -17.250009  0.0199  0.0000
!>    98   0.01185     0   0.000096    -17.250113    -17.250017  0.0193  0.0000
!>    99   0.01197     0   0.000100    -17.250124    -17.250024  0.0188  0.0000
!>   100   0.01209     0   0.000097    -17.250128    -17.250032  0.0182  0.0000
!>   101   0.01222     0   0.000060    -17.250126    -17.250067  0.3000  0.0000
!>   102   0.01234     0   0.000017    -17.250125    -17.250108  0.3000  0.0000
!>   103   0.01246     0   0.000010    -17.250128    -17.250118  0.0177  0.0000
!>   104   0.01258     0   0.000015    -17.250134    -17.250119  0.0171  0.0000
!>   105   0.01270     0   0.000021    -17.250141    -17.250120  0.0166  0.0000
!>   106   0.01282     0   0.000026    -17.250148    -17.250122  0.0161  0.0000
!>   107   0.01294     0   0.000030    -17.250154    -17.250124  0.0156  0.0000
!>   108   0.01306     0   0.000031    -17.250157    -17.250126  0.0152  0.0000
!>   109   0.01318     0   0.000031    -17.250158    -17.250128  0.0147  0.0000
!>   110   0.01330     0   0.000029    -17.250158    -17.250129  0.0143  0.0000
!>   111   0.01342     0   0.000018    -17.250158    -17.250140  0.3000  0.0000
!>   112   0.01355     0   0.000005    -17.250157    -17.250152  0.3000  0.0000
!>   113   0.01367     0   0.000003    -17.250159    -17.250155  0.0138  0.0000
!>   114   0.01379     0   0.000005    -17.250161    -17.250155  0.0134  0.0000
!>   115   0.01391     0   0.000007    -17.250163    -17.250156  0.0130  0.0000
!>   116   0.01403     0   0.000008    -17.250165    -17.250156  0.0126  0.0000
!>   117   0.01415     0   0.000009    -17.250166    -17.250157  0.0123  0.0000
!>   118   0.01427     0   0.000005    -17.250165    -17.250160  0.3000  0.0000
!>   119   0.01439     0   0.000001    -17.250165    -17.250164  0.3000  0.0000
!>   120   0.01451     0   0.000001    -17.250165    -17.250164  0.0119  0.0000
!>   121   0.01463     0   0.000002    -17.250166    -17.250164  0.0115  0.0000
!>   122   0.01476     0   0.000002    -17.250167    -17.250165  0.0112  0.0000
!>   123   0.01488     0   0.000003    -17.250168    -17.250165  0.0108  0.0000
!>   124   0.01500     0   0.000003    -17.250168    -17.250165  0.0105  0.0000
!>   125   0.01512     0   0.000002    -17.250168    -17.250166  0.3000  0.0000
!>   126   0.01524     0   0.000001    -17.250168    -17.250167  0.3000  0.0000
!>   127   0.01536     0   0.000000    -17.250168    -17.250168  0.0102  0.0000
!>   128   0.01548     0   0.000001    -17.250168    -17.250168  0.0100  0.0000
!>   129   0.01560     0   0.000001    -17.250169    -17.250168  0.0100  0.0000
!>   130   0.01572     0   0.000001    -17.250169    -17.250168  0.0100  0.0000
!>   131   0.01584     0   0.000001    -17.250169    -17.250168  0.0100  0.0000
!>   132   0.01596     0   0.000001    -17.250169    -17.250168  0.3000  0.0000
!>   133   0.01609     0   0.000000    -17.250169    -17.250169  0.3000  0.0000
!>   134   0.01621     0   0.000000    -17.250169    -17.250169  0.0100  0.0000
!>   135   0.01633     0   0.000000    -17.250169    -17.250169  0.0100  0.0000
!>   136   0.01645     0   0.000000    -17.250169    -17.250169  0.0100  0.0000
!>   137   0.01657     0   0.000000    -17.250169    -17.250169  0.0100  0.0000
!>   138   0.01669     0   0.000000    -17.250169    -17.250169  0.3000  0.0000
==============  PROGRAM FINISHED THU 15 SEP 2022 15:35 (11.949S)   =============
Calculation cmd send:  THU 15 SEP 2022 15:35 (11.974122S)
!>   138   0.01669     0   0.019819    -17.235605    -17.215786  0.1000  0.0000
!>   139   0.01681     0   0.065592    -17.309486    -17.243894  0.0970  0.0000
!>   140   0.01693     0   0.089823    -17.370804    -17.280981  0.0941  0.0000
!>   141   0.01705     0   0.064765    -17.371520    -17.306755  0.0913  0.0000
!>   142   0.01717     0   0.021870    -17.338914    -17.317045  0.2000  0.0000
!>   143   0.01730     0   0.004869    -17.330432    -17.325563  0.2000  0.0000
!>   144   0.01742     0   0.016832    -17.349327    -17.332495  0.0885  0.0000
!>   145   0.01754     0   0.028875    -17.372490    -17.343615  0.0859  0.0000
!>   146   0.01766     0   0.025252    -17.377966    -17.352714  0.0833  0.0000
!>   147   0.01778     0   0.010612    -17.368266    -17.357654  0.2000  0.0000
!>   148   0.01790     0   0.001957    -17.363339    -17.361381  0.2000  0.0000
!>   149   0.01802     0   0.004741    -17.368155    -17.363414  0.0808  0.0000
!>   150   0.01814     0   0.009304    -17.376102    -17.366797  0.0784  0.0000
!>   151   0.01826     0   0.009131    -17.378948    -17.369817  0.0760  0.0000
!>   152   0.01838     0   0.004304    -17.376062    -17.371758  0.2000  0.0000
!>   153   0.01850     0   0.000829    -17.374100    -17.373271  0.2000  0.0000
!>   154   0.01863     0   0.001502    -17.375454    -17.373951  0.0737  0.0000
!>   155   0.01875     0   0.003107    -17.378127    -17.375020  0.0715  0.0000
!>   156   0.01887     0   0.003228    -17.379228    -17.376001  0.0694  0.0000
!>   157   0.01899     0   0.001611    -17.378305    -17.376694  0.2000  0.0000
!>   158   0.01911     0   0.000338    -17.377613    -17.377275  0.2000  0.0000
!>   159   0.01923     0   0.000540    -17.378062    -17.377522  0.0673  0.0000
!>   160   0.01935     0   0.001105    -17.378987    -17.377882  0.0653  0.0000
!>   161   0.01947     0   0.001157    -17.379361    -17.378204  0.0633  0.0000
!>   162   0.01959     0   0.000581    -17.379015    -17.378434  0.2000  0.0000
!>   163   0.01971     0   0.000130    -17.378779    -17.378649  0.2000  0.0000
!>   164   0.01983     0   0.000220    -17.378964    -17.378744  0.0614  0.0000
!>   165   0.01996     0   0.000432    -17.379309    -17.378877  0.0596  0.0000
!>   166   0.02008     0   0.000438    -17.379426    -17.378988  0.0578  0.0000
!>   167   0.02020     0   0.000212    -17.379273    -17.379061  0.2000  0.0000
!>   168   0.02032     0   0.000049    -17.379189    -17.379140  0.2000  0.0000
!>   169   0.02044     0   0.000098    -17.379277    -17.379179  0.0561  0.0000
!>   170   0.02056     0   0.000186    -17.379419    -17.379232  0.0544  0.0000
!>   171   0.02068     0   0.000180    -17.379454    -17.379274  0.0527  0.0000
!>   172   0.02080     0   0.000082    -17.379378    -17.379297  0.2000  0.0000
!>   173   0.02092     0   0.000019    -17.379346    -17.379327  0.2000  0.0000
!>   174   0.02104     0   0.000047    -17.379391    -17.379344  0.0512  0.0000
!>   175   0.02117     0   0.000088    -17.379455    -17.379368  0.0496  0.0000
!>   176   0.02129     0   0.000081    -17.379466    -17.379384  0.0481  0.0000
!>   177   0.02141     0   0.000034    -17.379426    -17.379392  0.2000  0.0000
!>   178   0.02153     0   0.000008    -17.379412    -17.379405  0.2000  0.0000
!>   179   0.02165     0   0.000024    -17.379436    -17.379412  0.0467  0.0000
!>   180   0.02177     0   0.000044    -17.379468    -17.379423  0.0453  0.0000
!>   181   0.02189     0   0.000040    -17.379470    -17.379431  0.0439  0.0000
!>   182   0.02201     0   0.000016    -17.379449    -17.379433  0.2000  0.0000
!>   183   0.02213     0   0.000004    -17.379443    -17.379439  0.2000  0.0000
!>   184   0.02225     0   0.000013    -17.379456    -17.379443  0.0426  0.0000
!>   185   0.02237     0   0.000024    -17.379472    -17.379448  0.0413  0.0000
!>   186   0.02250     0   0.000021    -17.379473    -17.379452  0.0401  0.0000
!>   187   0.02262     0   0.000008    -17.379461    -17.379453  0.2000  0.0000
!>   188   0.02274     0   0.000002    -17.379457    -17.379456  0.2000  0.0000
!>   189   0.02286     0   0.000007    -17.379465    -17.379458  0.0389  0.0000
!>   190   0.02298     0   0.000013    -17.379474    -17.379461  0.0377  0.0000
!>   191   0.02310     0   0.000011    -17.379474    -17.379462  0.0366  0.0000
!>   192   0.02322     0   0.000004    -17.379467    -17.379462  0.2000  0.0000
!>   193   0.02334     0   0.000001    -17.379465    -17.379464  0.2000  0.0000
!>   194   0.02346     0   0.000004    -17.379469    -17.379465  0.0355  0.0000
!>   195   0.02358     0   0.000008    -17.379474    -17.379467  0.0344  0.0000
!>   196   0.02371     0   0.000005    -17.379474    -17.379469  0.2000  0.0000
!>   197   0.02383     0   0.000001    -17.379472    -17.379471  0.2000  0.0000
!>   198   0.02395     0   0.000000    -17.379472    -17.379471  0.2000  0.0000
!>   199   0.02407     0   0.000002    -17.379473    -17.379472  0.0334  0.0000
!>   200   0.02419     0   0.000003    -17.379475    -17.379472  0.0324  0.0000
!>   201   0.02431     0   0.000002    -17.379475    -17.379473  0.2000  0.0000
!>   202   0.02443     0   0.000000    -17.379474    -17.379473  0.2000  0.0000
!>   203   0.02455     0   0.000000    -17.379474    -17.379474  0.0314  0.0000
!>   204   0.02467     0   0.000001    -17.379475    -17.379474  0.0305  0.0000
!>   205   0.02479     0   0.000001    -17.379475    -17.379474  0.0296  0.0000
!>   206   0.02491     0   0.000001    -17.379475    -17.379474  0.2000  0.0000
!>   207   0.02504     0   0.000000    -17.379474    -17.379474  0.2000  0.0000
!>   208   0.02516     0   0.000000    -17.379475    -17.379474  0.0287  0.0000
!>   209   0.02528     0   0.000000    -17.379475    -17.379474  0.0278  0.0000
!>   210   0.02540     0   0.000001    -17.379475    -17.379475  0.0270  0.0000
!>   211   0.02552     0   0.000000    -17.379475    -17.379475  0.2000  0.0000
!>   212   0.02564     0   0.000000    -17.379475    -17.379475  0.2000  0.0000
==============  PROGRAM FINISHED THU 15 SEP 2022 15:36 ( 1.391S)   =============
-472.91959496242407
In [18]:
# the most recent results are stored in the results dict 
results = calcAse.results
for key in results.keys():
    print(key, results[key])
energy -472.91959496242407
forces [[0. 0. 0.]
 [0. 0. 0.]
 [0. 0. 0.]]
positions [[ 0.       0.       0.11926]
 [ 0.       0.76324 -0.47705]
 [ 0.      -0.76324 -0.47705]]
charges [-0. -0. -0.]
eigenvalues {'k1s1': [-25.076, -12.879, -9.154, -7.042, -1.248, 1.479, 1.543, 2.316, 2.445, 2.723, 2.823, 2.854, 2.951, 3.055, 3.853, 3.985, 4.356, 4.668], 'k1s2': [-25.076, -12.879, -9.154, -7.042, -1.248, 1.479, 1.543, 2.316, 2.445, 2.723, 2.823, 2.854, 2.951, 3.055, 3.853, 3.985, 4.356, 4.668]}
occupations {'k1_s1': [1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'k1_s2': [1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}
kpoints []
symbols ['O' 'H' 'H']
cell [array([-4.579219,  4.578144,  5.330866]), array([3.954668, 3.95436 , 5.198388]), array([-5.03186e-01,  8.32938e+00,  1.05000e-03])]
dipole [0. 0. 0.]
magmom -0.0
spin_polarized True
number_of_spins 2
number_of_bands 18
converged True
ERROR False
In [19]:
# the progress can be plotted while using for opt the same letters as in the paw_show tool 
calcAse.protocol.showGraph(opt='ec')
In [20]:
# it can also display in kj/mol or ev and only track the last n steps
calcAse.protocol.showGraph(opt='ec', unit='kj/mol', nSteps=50)
In [21]:
# to run the structure relaxation we change the parameters of the default control files
calcAse.parameters
Out[21]:
{'instructions': [{'strc': "!STRUCTURE \n  !GENERIC  LUNIT=1.8897261 \n    !ISOLATE  !END\n  !END\n  !LATTICE \n    T=-4.5792192 4.5781441 5.3308654  \n              3.9546674 3.9543602 5.198388  \n              -0.50318594 8.3293791 0.001050214  \n              \n    !ISOLATE  !END\n  !END\n  !OCCUPATIONS  NSPIN=2 EMPTY=15 CHARGE[E]=0.0  SPIN[HBAR]=0.0 \n    !ISOLATE  !END\n  !END\n  !SPECIES  NAME='O_' NPRO=2 2 1  LRHOX=4 RAD/RCOV=1.4 \n    !AUGMENT  ID='MY_NDLSS_O' EL='O' ZV=6.0  RCSM/RCOV=0.25  TYPE='NDLSS'\n      RCL/RCOV=0.75 0.75 0.75 0.75  RBOX/RCOV=1.2 \n      !POT  POW=3.0  RC/RCOV=0.75  !END\n      !CORE  POW=2.0  RC/RCOV=0.75  !END\n      !GRID  DMIN=0.000001  DMAX=0.15  RMAX=9.0  !END\n    !END\n    !NTBO  NOFL=1 1 0  RAUG/RCOV=1.2  RTAIL/RCOV=1.4  TAILLAMBDA=4.0 2.0 \n      LHFWEIGHT=0.1  CV=T !END\n  !END\n  !SPECIES  NAME='H_' M=2.0  NPRO=1 1  LRHOX=4 RAD/RCOV=1.2 \n    !AUGMENT  ID='MY_NDLSS_H' EL='H' ZV=1.0  RCSM/RCOV=0.25  TYPE='NDLSS'\n      RCL/RCOV=1.2 1.2 1.2 1.2  RBOX/RCOV=1.2 \n      !POT  POW=3.0  RC/RCOV=1.2  !END\n      !CORE  POW=2.0  RC/RCOV=1.2  !END\n      !GRID  DMIN=0.000001  DMAX=0.15  RMAX=9.0  !END\n    !END\n    !NTBO  NOFL=1 0  RAUG/RCOV=1.2  RTAIL/RCOV=1.4  TAILLAMBDA=4.0 2.0 \n      LHFWEIGHT=0.1  CV=T !END\n  !END\n  !ATOM  NAME='O_1' R=0.0 0.0 0.119262  !END\n  !ATOM  NAME='H_2' R=0.0 0.763239 -0.477047  !END\n  !ATOM  NAME='H_3' R=0.0 -0.763239 -0.477047  !END\n!END\n!EOB",
   'chckpntTag1': '1',
   'chckpntTag2': '2'},
  {'cntl': '!CONTROL \n  !GENERIC  START=T NSTEP=200 DT=5.0  NWRITE=100 !END\n  !DFT  TYPE=10 !END\n  !FOURIER  EPWPSI=30.0  CDUAL=2.0  !END\n  !PSIDYN  STOP=T FRIC=0.05 \n    !AUTO  FRIC(-)=0.3  FACT(-)=0.97  FRIC(+)=0.3  FACT(+)=1.0  MINFRIC=0.01  !END\n  !END\n!END\n!EOB',
   'chckpntTag1': '1',
   'chckpntTag2': '2',
   'cmd': ['./case.sh']},
  {'cntl': '!CONTROL \n  !GENERIC  START=F NSTEP=1000 DT=5.0  NWRITE=100 !END\n  !DFT  TYPE=10 !END\n  !FOURIER  EPWPSI=50.0  CDUAL=2.0  !END\n  !PSIDYN  STOP=T FRIC=0.05  SAFEORTHO=T\n    !AUTO  FRIC(-)=0.1  FACT(-)=0.97  FRIC(+)=0.2  FACT(+)=1.0  MINFRIC=0.01  !END\n  !END\n  !RDYN_x  STOP=T FRIC=0.0 \n    !AUTO  FRIC(-)=0.0  FACT(-)=0.0  FRIC(+)=0.1  FACT(+)=1.0  !END\n  !END\n!END\n!EOB',
   'chckpntTag1': '1',
   'chckpntTag2': '2',
   'cmd': ['./case.sh']}],
 'np': 1,
 'node': '2x12o',
 'version': '1216',
 'paw': 'paw',
 'rstrt': 'F',
 'read': False,
 'verbose': False,
 'chckold': False,
 'report': 'l',
 'logCalc': 'l',
 'backup': [],
 'chckFrc': -1,
 'atom_names': ['O_1', 'H_2', 'H_3'],
 'spin': 0.0,
 'pbc': array([False, False, False])}
In [24]:
# we remove the default start control file
cntlDict = calcAse.parameters['instructions'].pop(1)
cntlDict = calcAse.parameters['instructions'].pop(1)
cntlDict
In [28]:
# and change the electron relaxation control file to include rdyn
cntlStrg = cntlDict['cntl']
rlxCntl = AseCppawInputFiles.inputtoobject(cntlStrg)
rlxCntl.setValue(['!RDYN'], True)
rlxCntl.setValue(['!PSIDYN', '!AUTO', 'FRIC(-)'], 0.0)
calcAse.parameters['instructions'].append({'cntl': rlxCntl.getInputfileStr()})
In [29]:
# and start the calculation again with the changed parameters
calcAseRlxr = AseCppaw.cppaw(label=path0 + 'h2o_220915', **calcAse.parameters)
calcAseRlxr.calculate()
Calculation cmd send:  THU 15 SEP 2022 15:41 (5.157473S)
!>   212   0.02564     0   0.000000    -17.379039    -17.379039  0.0100  0.0000
!>   213   0.02576     0   0.000001    -17.379041    -17.379039  0.0100  0.0000
!>   214   0.02588     0   0.000003    -17.379042    -17.379039  0.0100  0.0000
!>   215   0.02600     0   0.000004    -17.379044    -17.379039  0.0100  0.0000
!>   216   0.02612     0   0.000005    -17.379045    -17.379040  0.0100  0.0000
!>   217   0.02624     0   0.000005    -17.379045    -17.379040  0.0100  0.0000
!>   218   0.02637     0   0.000005    -17.379046    -17.379040  0.0100  0.0000
!>   219   0.02649     0   0.000004    -17.379046    -17.379041  0.2000  0.1000
!>   220   0.02661     0   0.000001    -17.379045    -17.379044  0.2000  0.1000
!>   221   0.02673     0   0.000001    -17.379046    -17.379044  0.0100  0.0000
!>   222   0.02685     0   0.000001    -17.379046    -17.379044  0.0100  0.0000
!>   223   0.02697     0   0.000002    -17.379047    -17.379044  0.0100  0.0000
!>   224   0.02709     0   0.000002    -17.379047    -17.379044  0.0100  0.0000
!>   225   0.02721     0   0.000002    -17.379048    -17.379045  0.0100  0.0000
!>   226   0.02733     0   0.000002    -17.379048    -17.379045  0.0100  0.0000
!>   227   0.02745     0   0.000001    -17.379048    -17.379045  0.0100  0.0000
!>   228   0.02758     0   0.000001    -17.379048    -17.379045  0.0100  0.0000
!>   229   0.02770     0   0.000001    -17.379048    -17.379045  0.0100  0.0000
!>   230   0.02782     0   0.000001    -17.379049    -17.379045  0.0100  0.0000
!>   231   0.02794     0   0.000001    -17.379049    -17.379045  0.0100  0.0000
!>   232   0.02806     0   0.000001    -17.379049    -17.379045  0.0100  0.0000
!>   233   0.02818     0   0.000001    -17.379049    -17.379045  0.0100  0.0000
!>   234   0.02830     0   0.000001    -17.379050    -17.379045  0.0100  0.0000
!>   235   0.02842     0   0.000001    -17.379050    -17.379045  0.0100  0.0000
!>   236   0.02854     0   0.000001    -17.379050    -17.379045  0.0100  0.0000
!>   237   0.02866     0   0.000001    -17.379050    -17.379045  0.0100  0.0000
!>   238   0.02878     0   0.000001    -17.379050    -17.379045  0.0100  0.0000
!>   239   0.02891     0   0.000001    -17.379051    -17.379045  0.0100  0.0000
!>   240   0.02903     0   0.000001    -17.379051    -17.379045  0.0100  0.0000
!>   241   0.02915     0   0.000001    -17.379051    -17.379046  0.2000  0.1000
!>   242   0.02927     0   0.000000    -17.379051    -17.379047  0.0100  0.0000
!>   243   0.02939     0   0.000001    -17.379051    -17.379047  0.0100  0.0000
!>   244   0.02951     0   0.000001    -17.379051    -17.379048  0.0100  0.0000
!>   245   0.02963     0   0.000001    -17.379051    -17.379048  0.0100  0.0000
!>   246   0.02975     0   0.000001    -17.379051    -17.379048  0.2000  0.1000
!>   247   0.02987     0   0.000000    -17.379051    -17.379049  0.2000  0.1000
!>   248   0.02999     0   0.000000    -17.379051    -17.379050  0.2000  0.1000
!>   249   0.03012     0   0.000000    -17.379051    -17.379050  0.0100  0.0000
!>   250   0.03024     0   0.000000    -17.379051    -17.379050  0.0100  0.0000
!>   251   0.03036     0   0.000000    -17.379051    -17.379050  0.0100  0.0000
!>   252   0.03048     0   0.000000    -17.379051    -17.379050  0.2000  0.1000
!>   253   0.03060     0   0.000000    -17.379051    -17.379051  0.2000  0.1000
!>   254   0.03072     0   0.000000    -17.379051    -17.379051  0.0100  0.0000
!>   255   0.03084     0   0.000000    -17.379051    -17.379051  0.0100  0.0000
==============  PROGRAM FINISHED THU 15 SEP 2022 15:41 (34.145S)   =============
In [30]:
# all results of the calculation can be directly accesed witin the result attribute
print(calcAseRlxr.results)
{'energy': -472.90806277702694, 'forces': array([[ 0.00205688,  0.00051422, -0.01131285],
       [-0.00102844, -0.01902616,  0.02211149],
       [-0.00051422,  0.01954039,  0.02211149]]), 'positions': array([[ 2.0000e-05,  0.0000e+00,  1.1947e-01],
       [-4.0000e-05,  7.6532e-01, -4.7775e-01],
       [-2.0000e-05, -7.6531e-01, -4.7777e-01]]), 'charges': array([-0.61728,  0.30862,  0.30866]), 'eigenvalues': {'k1s1': [-25.349, -13.16, -9.436, -7.33, -1.576, 1.151, 1.195, 1.983, 2.106, 2.416, 2.501, 2.538, 2.647, 2.748, 3.556, 3.675, 4.043, 4.358], 'k1s2': [-25.349, -13.16, -9.436, -7.33, -1.576, 1.151, 1.195, 1.983, 2.106, 2.416, 2.501, 2.538, 2.647, 2.748, 3.556, 3.675, 4.043, 4.358]}, 'occupations': {'k1_s1': [1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'k1_s2': [1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}, 'kpoints': array([], dtype=float64), 'symbols': array(['O', 'H', 'H'], dtype='<U1'), 'cell': [array([-4.579219,  4.578144,  5.330866]), array([3.954668, 3.95436 , 5.198388]), array([-5.03186e-01,  8.32938e+00,  1.05000e-03])], 'dipole': array([-3.08636000e-05, -2.75262000e-05, -3.68658135e-01]), 'magmom': -0.0, 'spin_polarized': True, 'number_of_spins': 2, 'converged': True, 'ERROR': False}
In [ ]: