Jump to content

Requests for technical support from the VASP team should be posted in the VASP Forum.

Vacuum reference

From VASP Wiki

A vacuum reference for the Fe2+/Fe3+ half-cell is obtained from a water slab, by referencing its local potential to the O 1s states of the oxygen atoms in its water molecules. In each of the solvated ion cells, the O 1s level of the water molecules is taken as the same reference, so the energies of the solvated cells can be placed on a common vacuum scale [1]. The derivation and the approximations behind it are given in Vacuum reference: theory.

Input files

The vacuum alignment is obtained from calculations on three different systems: Fe3+ in 64 H2O (Fe3P_64H2O), Fe2+ in 64 H2O (Fe2P_64H2O), H2O slab with 128 molecules (128H2O_slab), that is, [math]\displaystyle{ [\mathrm{Fe}(\mathrm{H}_2\mathrm{O})_n]^{3+} }[/math], [math]\displaystyle{ [\mathrm{Fe}(\mathrm{H}_2\mathrm{O})_n]^{2+} }[/math], and the water slab.

Figure 1. Top left: Fe3+ in 64 H2O (Fe3P_64H2O), top center: Fe2+ in 64 H2O (Fe2P_64H2O), top right: bulk H2O with 64 molecules (64H2O_bulk), and bottom: H2O slab with 128 molecules (128H2O_slab).

The 128H2O_slab calculations are more expensive, since many structures are required to converge the local potential; Ref. [1] uses ~3000. Only the H2O molecules' O1s levels in the center of the slab are used, shaded in gray in Fig. 1, representing the bulk. This only needs to be done once to determine the chemical potential relative to vacuum, and can then be used for any half-cell reaction within 64H2O_bulk and with the same method. In contrast, repeat the Fe2P/Fe3P_64H2O calculations for each reaction. The POSCAR files are described on more detail in the redox potential overview page.

POSCARs

Click to reveal the [math]\displaystyle{ [\mathrm{Fe}(\mathrm{H}_2\mathrm{O})_n]^{3+} }[/math] POSCAR
Fe_64H2O
1
     12.42282200       0.00000000       0.00000000
      0.00000000      12.42282200       0.00000000
      0.00000000       0.00000000      12.42282200
H  O  Fe
  128    64     1
Direct
     -0.38272023       0.47236734       0.69895078
     -0.27203601       0.41866794       0.72914269
      0.60916541       0.72796225       0.09306829
      0.71070494       0.78725068       0.14392771
      1.08865564       0.93820602       0.24600432
      1.03755512       0.98120737       0.35350048
      0.04276558       1.23801733       0.56678300
      0.45616640       0.36926572       0.39344586
     -0.16977976       0.40716591       0.53863440
     -0.25237329       0.38130525       0.44755164
      0.44169261       1.14516978       0.14529032
      0.37457743       1.13530301       0.24819417
      0.18407518       0.25222959       0.06812304
      0.09998538       0.14744161       0.06444770
      0.27831295       0.57479968       0.31380844
      0.29633366       0.45926581       0.36724418
      0.64763154      -0.53184911       0.87002912
      0.63022496       0.40977773       0.99107908
      0.47906160       0.58853267       0.63100265
      0.59945353       0.62329058       0.64816927
      0.87712851       0.41898140       1.07505748
      0.26314503      -0.13253460       0.01243951
      0.16153170      -0.19745195       0.05804701
      0.34412600      -0.01810085       0.81692911
      0.14554222       0.77130921      -0.25213594
      0.21209078       0.79452634      -0.14442072
      0.41500251       0.04461290       0.96837924
      0.49008610       0.14359786       0.93019679
      0.82125847       0.86254586       1.27147476
      0.00873717       0.10267666       0.23211446
      0.35980746       0.34237108       0.76169366
      0.33485343       0.46345006       0.77046483
      0.90320251       0.61221204       0.04264507
      0.97690745       0.71802735       1.06017819
      0.96030764       0.81465128       0.70019704
      1.01749178       0.74674122       0.60432752
      0.64007416       0.23981183       0.92947124
      0.31788389      -0.12374136       0.74827741
      0.99321033       0.93631524       0.55767630
      0.15487454       0.51028490      -0.09542554
      0.66815917       0.79686891       0.72718580
      0.76202793       0.70002522       0.75366280
      0.13591369      -0.02901335       0.00566347
      0.08957800       1.06396642      -0.07143824
      0.53392446      -0.11896063       0.23953882
      0.48718378      -0.00799262       0.25860106
     -0.07163033       1.26809135       0.50762252
      0.67405502       0.12105566       0.95083205
      0.74551359       0.62681866       0.34775553
      0.66650260       0.64357368       0.25540936
      0.38872827       0.12804968       0.55656518
      0.33782256       0.21579745       0.49248801
      0.92231233      -0.04307885       1.00089073
      0.79411522      -0.04854941       1.01531498
     -0.40705912       1.12847907       0.48347215
      0.65420892       1.23981902       0.47957005
      0.84599640      -0.09249550       0.84023452
      0.80327236       0.97997213       0.74592535
      0.88638541       0.47237368       0.72110537
      0.88941805       0.35493190       0.74249811
      0.55296221       0.93428417       0.55243420
      0.51441228       0.92952738       0.43767406
      0.73847683       0.51634987       1.03266322
      0.40092134       0.63952229      -0.01737781
      0.41176789       0.89134362       1.10615330
      0.44444253       0.84405868       0.99393367
      0.58073572       0.63347610      -0.04423652
      0.60854638       0.72933752      -0.11607112
     -0.16580359       0.22001380       0.89963070
     -0.04391612       0.21085677       0.85654400
      0.40533602       0.50000334       0.11555470
      0.34998095       0.38355577       0.10448457
     -0.24359234       0.77537730       0.45894937
     -0.26614437       0.70560002       0.56106171
      0.28303298       0.61126441       0.01597951
      0.37578327       0.33380444       0.30290136
      0.59618764       0.27699048       1.12423906
      0.50319683       0.35108728       1.09799129
      0.18989659       0.76741117       1.22566037
      0.06153560       0.75549602       0.22936925
      0.51785592       0.24354330       0.65223118
      0.56708719       0.32005973       0.73245604
      0.61206395       0.98022340       0.70759384
      0.50678625       0.91620503       0.71723010
      0.68602440       0.14707860       0.76412395
      0.69294218       0.12172781       0.64036372
      0.33488986       0.71525634       0.14956129
      0.35814895       0.80854785       0.22920363
      0.95945912       1.05245660       0.53679791
      0.77994512       0.55222218       1.15138214
      0.69626269       0.94689443       0.43758767
      0.82244291       0.95270203       0.44158402
     -0.08533410       0.30668689       0.99691887
      0.88689642       0.15254779       0.21721075
      0.96565778       0.66203563       0.74352603
      0.91899641       0.64391575       0.86105003
      0.60192845       0.32627053       0.34541527
      0.54412777       0.22739074       0.29056180
      0.33801876       0.24481339      -0.03610605
      0.27498242       0.34868783      -0.07124872
      0.63970642       0.49240211       0.35877270
      0.61552019       0.46892953       0.48438447
      0.30584874       0.64699933      -0.22951580
      0.42787645       0.64881697      -0.19623458
      0.05975532       0.12314654       0.75074831
     -0.02832220       1.03112946       0.76086242
      1.07382577       0.25251612       0.39457391
      1.17074101       0.24004400       0.30909053
      0.90882853       0.66787644       0.52270722
      0.07399163       0.59412808       0.95304999
      0.13906082       0.47905225       0.10518101
      1.17121656       0.46180650       0.23562581
      0.97971011       0.63429872       0.37278291
      0.90631471       0.68858591       0.26904690
      0.60516786       0.96463888       0.06395544
      0.68233031       1.04347277       1.12012494
      0.20897747       0.21380315       0.63498998
      0.20507421       0.29490009       0.72649781
      0.21069366       1.05104536      -0.68658423
      0.27938942       1.09406910       0.40078460
      0.70263174       0.14455648       1.25970691
      0.75730930       0.04722448       1.29768294
      0.91307779       0.40130091       0.34978752
      0.94369056       0.50994390       0.28013594
      0.08933991       0.43228293       0.60852163
      1.17837154       0.48628664       0.53072146
      1.00504493       0.58007882       0.54073092
      0.86291931      -0.13828811       1.15173275
     -0.34491075       0.43621986       0.75416516
      0.63900568       0.75492759       0.15829659
      1.07199795       1.00257563       0.28363155
      0.38420131       0.34485841       0.37967695
     -0.17342306       0.37643136       0.46438657
      0.45349630       1.14005000       0.22505348
      0.11869813       0.21939929       0.09604324
      0.23622993       0.50759344       0.33909324
      0.64875252       0.47771851       0.95286519
      0.55590506       0.57693205       0.60050819
      0.18736673      -0.15437724      -0.00677806
      0.37523088      -0.06818877       0.76435686
      0.21811495       0.76245384      -0.22055952
      0.42220970       0.12606004       0.96558981
      0.85780135       0.81574581       1.21531426
      0.30433544       0.39124488       0.77849745
      0.95758533       0.65697710       1.00747411
      1.03085555       0.79681957       0.66923251
      0.69067343       0.18643375       0.90833405
      0.96523126       0.16955239       0.22035170
      0.68612747       0.72230731       0.74299918
      0.08987161       0.03581255       0.00348357
      0.46357734      -0.08420990       0.24196675
     -0.01222913       1.21468404       0.51335175
      0.71162904       0.58691114       0.28804098
      0.32268708       0.16090339       0.53975026
      0.86234882      -0.08436224       0.98773807
     -0.38355188       0.19092778       0.52248232
      0.85291582      -0.08281162       0.75894361
      0.86323773       0.40597333       0.69118967
      0.54292990       0.98123241       0.48667605
      0.80728528       0.53397589       1.07560692
      0.39528125       0.89790682       1.02768167
      0.56047647       0.70886600      -0.05694049
     -0.09585039       0.25981162       0.89091800
      0.40071565       0.42814971       0.14908255
     -0.23238312       0.70278251       0.48864911
      0.35169257       0.62880569       0.04279978
      0.56212715       0.31299799       1.06345122
      0.12066294       0.79773619       1.19966391
      0.51154081       0.26173878       0.72839369
      0.58450605       0.90652737       0.69203180
      0.70957535       0.09399646       0.71195964
      0.32002783       0.74390105       0.22241023
      0.95247763       0.97831298       0.50380136
      0.76168681       0.93342180       0.39565898
     -0.07590969       0.35133103       1.07020111
      0.90649162       0.63028257       0.78114555
      0.61524001       0.25974801       0.30414551
      0.30266553       0.31064613      -0.00899828
      0.62120647       0.43621160       0.41233540
      0.36878355       0.59976322      -0.20951626
      0.00592307       0.09406140       0.79582533
      1.10947213       0.28743919       0.33114811
      0.13898678       0.54360995       0.97023057
      1.15168897       0.42574337       0.16437693
      0.96099089       0.62982868       0.29120309
      0.66514203       1.00695060       0.04564722
      0.15635030       0.24896214       0.68388955
      0.26078411       1.11001890       0.32632346
      0.75255117       0.09346553       1.23417762
      0.93550375       0.42521425       0.27361930
      1.12555194       0.49730673       0.58995753
      0.97951694       0.64650296       0.50479031
      1.02535902       0.32276265       0.18627127
Click to reveal the [math]\displaystyle{ [\mathrm{Fe}(\mathrm{H}_2\mathrm{O})_n]^{2+} }[/math] POSCAR
Fe_64H2O
1
     12.42282200       0.00000000       0.00000000
      0.00000000      12.42282200       0.00000000
      0.00000000       0.00000000      12.42282200
H  O  Fe
  128    64     1
Direct
      0.12743711       0.48760461       0.68402834
      0.07224030       0.59099573       0.69720079
      0.39623895       0.90251919      -0.68562329
      0.52396846       0.89222892      -0.69202626
      0.42964083       0.63656491       0.92024856
      0.40471536       0.51747508       0.92244566
      0.50949529       0.22553243       0.82975356
      0.79695561      -0.29210416      -0.14766098
      0.00805766       0.01676094       0.93033834
     -0.01969191       0.14077136       0.89733509
      0.01773692       1.49221026      -0.45662142
     -0.09754205       1.45083180      -0.48707747
      0.28568895       0.07977712       0.14809775
      0.40460027       0.11889958       0.12632577
     -0.44823614      -0.23392047       0.91065326
     -0.44655395      -0.27382665       1.03236410
      0.55758309       0.63486700       0.51461921
      0.54015662       1.52364880       0.45450703
      0.67045916       0.85136844       0.58289035
      0.71164261       0.89435637       0.47626762
      1.16684705       0.13193713       0.89590371
      0.33871812       0.20748811       0.69296855
      0.38041592       0.31864036       0.75378916
     -0.26840230      -0.60381695       0.57433173
      0.25751301       1.09723808      -0.39131073
      0.28561906       1.17135043      -0.49010853
     -0.15559770       0.77405954       1.51947552
     -0.03350167       0.77676575       1.52339975
      0.75237735       1.02309221       1.12180723
      0.04826055       0.15234086       0.05862687
     -0.09230147      -0.06114088       1.02402855
     -0.07779336      -0.14013315       0.92524744
      0.68560087       0.63322667       1.36320530
      0.79400335       0.69800156       2.34722324
      1.01111679       0.16477327       0.53663862
      0.98618018       0.28565957       0.49809698
      0.20452861       0.81136804       0.83127978
     -0.29824646      -0.48415938       0.54811270
      0.37502040       1.26549068       0.41257460
      1.30154976       0.64025841       0.11667748
      1.75290818       0.59403116       0.98316689
      1.65052923       0.63412803       0.91547295
      0.75375838       0.00138371      -0.37473678
      0.76130867       1.05807834      -0.25911110
     -0.05696647      -0.29493528       0.76468746
      0.02811791      -0.33267590       0.85098776
      0.61065413       0.29830310       0.85951557
      0.11763966       0.86822584       0.90729729
      0.18919114       0.55109134       0.38993918
      0.21099928       0.52226945       0.51012484
      0.03269714       0.36292005       0.33650725
      0.02620788       0.48115860       0.28181401
      1.05541232       0.90157404       0.64524915
      1.07849658       0.77961507       0.68820380
     -0.62352298       1.63205141       0.30877689
      0.43788457       1.73907737       0.26620496
      0.64515164      -0.84752695       1.12986454
      0.64730542       0.18633377       1.26064334
      0.19923207      -0.08426170       0.07502044
      0.22493320      -0.20749942       0.08281964
      0.78950677       1.18291196       0.57758905
      0.83466268       1.23338961       0.48038196
      1.10490483       1.28683406       0.74494774
      0.29928808       0.66864147      -0.17842015
      0.69120317       0.84829619       1.11035412
      0.67223805       0.75611954       1.18775106
     -0.00106366       0.61277354       0.38525072
      0.01326608       0.68609575       0.28998127
     -0.07137268       0.05723237       0.64512696
      0.03262162       0.06902330       0.71661499
      0.77907316       0.40440365       0.75246685
      0.73437154       0.47097142       0.84530449
      0.22165260       0.78128841       0.57222522
      0.24873347       0.68762843       0.48624453
      0.21948415       0.65300265      -0.26571256
      0.79089209      -0.20809083      -0.24704170
      1.11107834       0.01381845       0.32957265
      1.03239487       0.10538648       0.35890625
     -0.22306466       1.43601128       1.11757892
     -0.24593929       1.53904148       0.17695298
      0.53330947      -0.13832394       0.74775872
      0.48380538      -0.08752260       0.84569979
      0.33958593       1.05428999       0.90703938
      0.29513801       0.93047632       0.90464110
     -0.10080201      -0.17071890       0.20726349
      0.00812468      -0.20258160       0.13847835
      0.08102303       0.64583254       0.03494449
     -0.04079584       0.61193214       0.04209357
      0.35121443       1.17006312       0.32377652
      1.18017291       1.28895470       0.63748305
      0.44815316       0.76165600      -0.42603898
      0.46425067       0.68605942      -0.32598380
      0.26710057       0.21583209       0.85066344
      1.08895608       0.13400129       0.17359061
      0.65188184       1.12136051       0.88104293
      0.65005020       0.99400031       0.86041374
      0.74276310       0.93357167       0.31617568
      0.65193906       1.01050888       0.33337941
      0.22155564      -0.06334224      -0.33974479
      0.31584241      -0.05457389      -0.25072038
      0.46701413       0.39534529       0.33741153
      0.37353168       0.43618379       0.40490478
      0.88534124       0.31114574       0.85608235
      0.90593210       0.27739909       0.97341481
      0.39857237      -0.04387750       0.56182123
      0.47095275       1.02320312       0.49993905
      1.25892990       0.45837652       0.17875477
      1.15656687       0.39089427       0.22252886
      0.51644837       0.17070272       0.40580457
      1.27940834       0.60940694       0.99753791
      0.42616197       0.40350440       0.06681017
      1.44539498       0.30393771      -0.01376590
      0.46562325       1.01534518       0.03284939
      0.50319974       0.99064681       0.15470387
      0.81037140       0.25082530       0.14657752
      0.90914722       0.31376690       1.17885883
      0.90887977       0.86774057       1.39942038
      0.94187889       0.97203833       1.33441155
      0.22890408       0.88765248       0.26506994
      0.22943934       0.87502350       1.39740388
      0.49252993       0.56873322       1.17531223
      0.58322974       0.47973985       1.18073167
      1.07353906       0.35801775      -0.07352972
      1.10345201       0.46291908      -0.00569576
      0.56233028       0.47301291       0.65701182
      1.50111441       0.39245196       0.57504212
      0.64733050       0.17609466       0.44047892
      0.76155406      -0.00064089       0.99805907
      0.11696365       0.55392898       0.64536596
      0.45665944       0.88787932      -0.73431062
      0.37333616       0.58173353       0.89358570
      0.83287880      -0.23084103      -0.18836803
      0.03157586       0.08326143       0.89500066
     -0.01967168       1.44066290      -0.50120574
      0.32649692       0.14675159       0.14354441
     -0.47815402      -0.28476352       0.96183234
      0.58825114       1.58190086       0.46693607
      0.73530757       0.86486122       0.54696653
      0.36850393       0.23869519       0.76098331
     -0.24064441      -0.53169325       0.57977533
      0.24867886       1.17176032      -0.42128557
     -0.09114394       0.73086170       1.49415350
      0.77082046       0.96821649       1.06941593
     -0.03834292      -0.10477073       0.98185130
      0.72904928       0.67702858       2.31155822
      0.98643994       0.21068855       0.47648425
      0.18404121       0.88355581       0.86864094
      1.08703359       0.18844511       0.11444108
      1.71734102       0.59616846       0.90840384
      0.79123200       0.05674886      -0.33394462
      0.02043659      -0.31156425       0.77570162
      0.56069314       0.24338431       0.88537227
      0.24569014       0.53057214       0.44182948
      0.03448211       0.40131521       0.26357804
      1.09819988       0.83512130       0.63612042
     -0.60356192       0.67216851       0.24349363
      0.68641610      -0.81762609       1.18817124
      0.21611881      -0.14120573       0.12450673
      0.76919341       1.22245249       0.51393968
      1.14696413       1.32734585       0.69656507
      0.65811040       0.77819298       1.11522722
      0.04903142       0.62925399       0.32627031
      0.01260756       0.05983530       0.64228866
      0.74653920       0.39814097       0.82582336
      0.26593357       0.76215637       0.50729285
      0.25423481       0.71079817      -0.23075499
      1.04656732       0.05170956       0.30685598
     -0.27090311       1.50034802       1.11590884
      0.55144479      -0.10997314       0.82138721
      0.36595179       0.97842307       0.90355956
     -0.04879022      -0.22282940       0.18797022
      0.02303649       0.60374665      -0.00064438
      0.36248716       1.18806896       0.40233898
      0.50553342       0.72818132      -0.38174573
      0.23339102       0.17685431       0.91622715
      0.69519318       1.05764833       0.86986144
      0.66244443       0.93542605       0.32313623
      0.29157406      -0.03443908      -0.32197353
      0.43576289       0.39304384       0.41288487
      0.93290635       0.26807660       0.90192508
      0.46947458      -0.04604768       0.53317357
      1.23797107       0.38686102       0.19701795
      1.24279488       0.62426866       1.06753929
      1.39453671       0.36177382       0.00797544
      0.49872289       1.04632858       0.09816681
      0.86030136       0.31356352       0.11502915
      0.87609952       0.92053833       1.35250286
      0.23398309       0.92340184       1.33460122
      0.50301930       0.49047944       1.17320678
      1.13069333       0.39166539      -0.03166013
      1.52690177       0.40275423       0.64871882
      0.59258213       0.16054156       0.38717393
      1.22868038       0.27296875       0.05742047
Click to reveal the 128H2O_slab POSCAR
SYSTEM
1
     12.50000000       0.00000000       0.00000000
      0.00000000      12.50000000       0.00000000
      0.00000000       0.00000000      50.00000000
H  O
  256   128
Direct
     -0.15047607       0.45334683       0.32730556
     -0.07219808      -0.49010458       0.34403411
      0.63805046       0.03123465       0.46999929
      0.50838374       0.00754431       0.46372876
      0.20742016      -0.23715390       0.31145651
      0.21957350       0.63504600       0.31129793
      0.49252565       0.97213243       0.52739381
      0.46254946       0.86699495       0.51338367
      0.46833659       0.30083696       0.47570094
      0.56435815       0.28642228       0.46051829
      0.73586863      -0.12693724       0.63650708
      0.75181963      -0.25406949       0.63203814
      0.41854353       0.84406884       0.44927074
      0.33515626       0.90054023       0.46728072
      0.34479509       0.57962028       0.37911763
      0.29762780      -0.47903310       0.40660055
      0.15115248       0.54108257       0.49957979
      0.08260965       0.53074503       0.52635427
      0.89266849       0.40696421       0.52478091
     -0.06057907       0.40486920       0.55352216
      0.55977900      -0.37296647       0.61748251
      0.53858714      -0.26767121       0.59987163
      0.71275400       0.42250550       0.56832405
      0.78839559       0.34546846       0.58417890
      0.67385329      -0.19610180       0.44987464
      0.59318198      -0.16624091       0.42828513
      0.12312508       0.37123899       0.28937208
      0.05023666       0.27675971       0.29997236
     -0.16681739       1.58406768       0.63195176
     -0.21800579       1.57002107       0.66191007
      0.20675683      -0.06108281       0.29221359
      0.10312049      -0.09294129       0.30396903
      0.20277637       0.06067826       0.60416144
      0.19887396      -0.00744650       0.62890026
      0.42062864      -0.24439336       0.35497596
      0.36814211      -0.33879224       0.34193308
     -0.46114333       0.32802380       0.39548517
      0.45713828       0.41873416       0.39179412
      1.05751346       0.29067408       0.55923161
      1.04348507       0.18703047       0.57744764
      0.21179010       0.87249263       0.56793233
      0.09036024       0.85931851       0.57432053
      0.60751605       1.01609789       0.65259722
      0.72696147       1.05338974       0.65871807
      0.44683747       0.21956247       0.29940199
      0.48216169       0.19981749       0.26927194
      0.10930269       0.40445023       0.47082959
      0.17010928       0.50009382       0.45569496
      0.78757796      -0.20083679       0.40459572
      0.81784835      -0.20993279       0.37400609
      0.63044955      -0.50216422       0.32507910
      0.61823261      -0.56783464       0.29754461
      0.38298254       1.64224442       0.61713447
      0.27391580       1.65127025       0.62769264
     -0.18349257       0.40823838       0.42743175
     -0.11707568       0.32822140       0.44206697
      0.37713689       0.15324147       0.36153587
      0.47188832       0.15561964       0.38076476
      0.84313290       0.66869553       0.54540293
      0.78036268       0.55967659       0.53781156
      0.62834565       0.07729786       0.39976222
      0.58336683       0.13133194       0.42359675
      1.57461032       1.43827952       0.71246905
      1.47093630       1.44260924       0.69550961
      0.56330564       1.09120276       0.50193580
      0.61593811       1.12895503       0.52786251
      0.73348421       0.31660428       0.46194097
      0.75096480       0.20702765       0.47568711
      0.18544389      -0.23514793       0.40166768
      0.22931162      -0.14674533       0.42153910
      0.36292308       0.50876490       0.64987458
      0.33531338       0.38470088       0.66057777
      1.49747974      -0.54677440       0.44932443
      0.51766749      -0.42535318       0.46152212
      1.85759374       0.75185320       0.76879203
      0.88557936       0.66337125       0.74776712
      0.66151301       0.68965700       0.41313588
      0.60698800       0.57649179       0.41787791
     -0.21783861       0.90704975       0.72268493
     -0.18062377       1.02010056       0.73108294
      0.79398077       0.91221618       0.53177815
      0.89172292       0.88245064       0.51170593
      1.21360535       1.19956259       0.58314768
      1.23188220       0.10388812       0.56520461
      0.69217913      -0.02288592       0.35644459
      0.65013288      -0.02349422       0.32542268
      0.49314736       0.09990072       0.55428120
      0.40698133       0.13735440       0.57630192
      0.06940342       0.10352406       0.53021711
      0.12918295       0.01423295       0.54673459
      1.23761207       0.03882752       0.37085803
      0.23384130       0.05388881       0.33858930
     -0.50295222       0.92300366       0.74813821
     -0.38930037       0.97841032       0.74266531
      0.13655853       0.16157403       0.39040653
      0.15373516       0.09867462       0.41870070
      0.35793276       0.15462364       0.64561652
      0.44313351       0.08542197       0.66008140
      0.12490452       1.60323574       0.67914603
      0.10103912       0.67758518       0.66052594
     -0.02910081      -0.04303719       0.33290797
     -0.08397074      -0.06715582       0.30625602
      0.47100963      -0.31135459       0.42347049
      0.44678381      -0.21727665       0.40309666
      0.17380547       1.23522872       0.64351497
      0.28087835       1.29207879       0.63186950
      0.72243965       1.04679669       0.60136565
      0.77633776       1.15885707       0.60968516
      0.20332595       1.15182338       0.29172154
      0.31769260       1.09822536       0.28860721
      0.90406410       0.53849761       0.41088426
      0.78463589       0.58505950       0.41470974
      1.12942702       1.53845314       0.71988868
      1.20054880       1.43235266       0.71382259
     -0.17158886       0.30160650       0.40269399
     -0.07101085       0.26515881       0.38366272
      0.74322462       1.32613449       0.64589263
      0.77475704       1.41411198       0.62227898
      0.14620565      -1.10616729       0.48008239
      0.18160223      -0.03968360       0.50606301
     -0.11186987       0.94149530       0.65599853
     -0.13718975       1.02669042       0.63199678
      0.56159298       0.19900069       0.59311202
      0.55920469       0.18285975       0.62176711
      0.90336505       0.15667383       0.52548512
      0.98450787       0.25110265       0.52511525
      0.97847305      -0.42779836       0.72340892
      1.02887897       0.67051183       0.71108441
      0.93053153      -0.03352705       0.43016463
      0.94358325       0.08994529       0.42307038
     -0.12458051       0.56502080       0.45311411
     -0.04730932       0.59270705       0.47590220
     -0.26829199       0.80830572       0.49363371
     -0.21717255       0.70457633       0.48040899
      0.43110180       0.68638080       0.68890088
      0.32510025       0.62119216       0.70042335
      0.12431384       0.78282478       0.61843684
      0.20700484       0.81000752       0.64341301
      0.70384786       0.11901625       0.29636532
      0.58157041       0.12693352       0.30130944
      0.75363478       0.23168055       0.54459190
      0.75644483       0.12259613       0.56105372
     -0.03231861       0.12955620       0.32499376
     -0.09853097       0.23584383       0.32218754
      1.35833840      -0.44225252       0.44591484
      1.25776038      -0.35606860       0.43991425
      0.02974229      -0.01448169       0.38634402
     -0.04925278      -0.12297578       0.38637941
      0.07972722      -0.25141011       0.36219086
      0.18306699      -0.31067445       0.35551374
      0.92747522       0.76466556       0.60868816
      0.95937680       0.87571382       0.62123825
      0.52932163       0.57770897       0.50403614
      0.58437494       0.68163282       0.49342216
      0.32115740       0.82996586       0.67667456
      0.25755504       0.94154338       0.67730506
     -0.22810590       0.37614398       0.49430267
     -0.18576922       0.49671288       0.49149878
      0.65189321       0.70221781       0.55887514
      0.58469375       0.80139057       0.54950481
      0.45751382       1.14320451       0.73814919
      0.45757048       1.25211787       0.71984711
     -0.16073265       0.53318711       0.58413419
     -0.04460020       0.52255466       0.59636621
      1.23763588       0.27151415       0.53650362
      0.26869350       1.37267158       0.55194387
      1.56531541       1.75888578       0.65789015
      1.64170785       1.76839833       0.68268336
      1.17071819       0.30450968       0.36193986
      1.07205789       0.24647217       0.34988931
      0.66268682       0.39143410       0.35576888
      0.77470013       0.33753052       0.36083320
      0.48701966      -0.62651414       0.32289219
      0.45172427      -0.71444999       0.34206563
      0.89274414       0.87693241       0.57141470
      0.77760242       0.86753703       0.58449204
      1.22348599      -0.38621798       0.54275880
      1.26314524      -0.31955173       0.56641379
      0.93813763       1.18794820       0.71316474
      0.91809214       1.10192472       0.69334364
      0.61064405       0.92402610       0.60719628
      0.55192305       1.01039312       0.59021354
      0.96908959       0.73238970       0.67284455
      0.86559314       0.75071650       0.65769890
      1.05951362      -0.45354408       0.38093143
      1.05009801      -0.58200279       0.37590291
      0.76172957       0.49270651       0.70861525
      0.72438777       0.60310359       0.69947487
      0.43493202       1.01642204       0.62370834
      0.41157215       0.90717107       0.63919892
      1.28709531       1.22977646       0.71568664
      1.22240102       1.24760104       0.69023856
     -0.36929002       0.30112790       0.68799301
      0.73835598       1.24904006       0.69307962
      1.08438837       1.16887216       0.75281234
      1.10337181       1.25880709       0.73309939
      0.00881530       0.23511529       0.66153556
      0.01992074       0.10863332       0.65331960
     -0.18762204       1.76544824       0.69589571
     -0.22099427       0.73159748       0.72364889
      0.47402075       0.21823941       0.52156939
      0.39449064       0.32549396       0.52603852
      0.49229702       0.00642229       0.70437200
      0.49041094      -0.09636789       0.68559144
      0.31519106       1.45346432       0.61090090
      0.38603816       1.37161975       0.59824648
      0.15729732       1.50568246       0.63546369
      0.21559092       1.47629782       0.66066682
     -0.19454501       1.01393222       0.39591120
     -0.22080313       1.12719611       0.38222917
      1.06810038       0.81254123       0.53206673
      1.06352248       0.70747723       0.51307936
     -0.12638475      -0.55537021       0.26026243
     -0.05760421      -0.65321822       0.26577609
     -0.09042409       1.07196610       0.58294900
      0.02325129       1.03828409       0.59636367
      0.32063486       0.92608540       0.72659258
      0.35574911       0.80830229       0.72123409
      0.10412373       0.41841079       0.59896831
      0.14274925       0.51651990       0.58178437
     -0.19591148       0.07044928       0.45554844
     -0.19021572       0.03340561       0.48590483
      1.07785299       0.53236279       0.30851784
      1.17527108       0.48273981       0.32369409
     -0.05242302       0.21986278       0.47826685
      0.04602452       0.20858933       0.45856538
      0.40878055       0.29190606       0.42949757
      0.35385287       0.26786429       0.40109729
      0.91361281       1.37763527       0.70485166
      0.92601382       1.37974445       0.73573816
      0.49180218       0.49176486       0.55630311
      0.38888954       0.54455977       0.56839724
      0.74382564       0.28498135       0.31337726
      0.81303180       0.29929615       0.28888582
      0.23876821       1.20570242       0.44319221
      0.19992227       1.11701411       0.46333591
      0.59407806       1.36278641       0.60873199
      0.54524237       1.46654437       0.59522322
      2.02346307       1.41217476       0.66399254
      1.91147497       1.37915850       0.65989115
      0.09845777       0.03688460       0.69616599
      0.09766268      -0.08531166       0.69167377
      1.25808011       0.44420386       0.36149889
      1.31081579       0.38358222       0.33934553
      0.07353811       0.81613159       0.44176424
     -0.02019300       0.78679404       0.46293839
      0.38984424       0.83369934       0.56338610
      0.37381688       0.87922811       0.59234427
      0.51453372      -0.09541985       0.35009748
      0.39484305      -0.06645979       0.35017125
      0.55593924       0.38753163       0.51869390
      0.66004756       0.46315941       0.51627573
      0.64848801       0.61180544       0.37008072
      0.57832658       0.64084106       0.34599612
      0.75386845      -0.15146447       0.33086236
      0.73564205      -0.27427126       0.33331691
     -0.09648741       0.50938984       0.32488838
      0.56504329       0.06286545       0.46968741
      0.24293994       0.69761578       0.32091286
      0.48108748       0.89535134       0.53166188
      0.49757936       0.32553516       0.45789152
      0.76744020      -0.18340073       0.62487691
      0.41144876       0.90246316       0.46247378
      0.31794376      -0.48573743       0.38681989
      0.12877684       0.58271134       0.51624414
      0.95851509       0.39985886       0.53493477
      0.52243754      -0.30282985       0.61791897
      0.76895759       0.37346632       0.56560940
      0.66848522      -0.18560993       0.43043112
      0.09074693       0.30162769       0.28441615
     -0.20154125       1.61789646       0.64720226
      0.17181260      -0.12468412       0.29662573
      0.15700557       0.00871911       0.61363921
      0.42233976      -0.32994901       0.35514866
      0.53286785       0.40322511       0.39184579
      1.07727341       0.25676911       0.57497686
      0.13716955       0.87720865       0.55959520
      0.68216863       0.99627546       0.65137040
      0.45119708       0.16614064       0.28412456
      0.10973328       0.48171438       0.46781222
      0.84388934      -0.20664059       0.39174052
      0.58303852      -0.54048463       0.31286474
      0.32808472       1.59763404       0.62452336
     -0.19165309       0.33704380       0.43457786
      0.41823919       0.20183034       0.37245093
      0.78587144       0.61673307       0.55124293
      0.56011355       0.11309492       0.40567704
      1.51701295       1.39737040       0.70673631
      0.54695764       1.10711476       0.52102138
      0.72131688       0.27947218       0.47879616
      0.18444949      -0.21210987       0.42113103
      0.36668171       0.45488107       0.66482426
      0.49064798      -0.46503727       0.44561439
      0.82820218       0.69414688       0.75657380
      0.65847198       0.61537373       0.40712496
      0.76748450       0.96128069       0.73583267
      0.81730697       0.91059549       0.51275491
      1.27220645       1.14795719       0.57873009
      0.64741928      -0.05620926       0.34353694
      0.48391157       0.12047094       0.57316210
      0.14376608       0.06922992       0.53329165
      1.27850839       0.03499489       0.35317314
     -0.46354066       0.99485951       0.74685190
      0.12508520       0.09293059       0.39933758
      0.43296574       0.12732681       0.64290755
      0.09700574       1.67696831       0.67957377
     -0.02662689      -0.02348385       0.31412699
      0.44363826      -0.24009345       0.42143376
      0.25025628       1.24855748       0.64562073
      0.79823150       1.08209822       0.60445310
      0.24357641       1.08550799       0.29686686
      0.84487510       0.54791453       0.42274978
      1.20665739       1.51259035       0.71454551
     -0.14852600       0.27439958       0.38483199
      0.79875463       1.36570466       0.63635127
      0.20013661      -0.05770220       0.48695782
     -0.08803369       1.01243312       0.64786941
      0.60681036       0.21343304       0.60836199
      0.96760512       0.18267756       0.51744002
      1.01869709      -0.36164031       0.72861865
      0.89279549       0.03025280       0.42811891
     -0.12190623       0.58173239       0.47257350
     -0.28364610       0.74658147       0.48027041
      0.35461305       0.69479199       0.69387913
      0.17636099       0.75539076       0.63132326
      0.64567772       0.08234767       0.30555919
      0.74693252       0.15345949       0.54261621
     -0.02750156       0.20761939       0.32607759
      1.27987775      -0.43232854       0.43958099
      0.00284833      -0.07336365       0.37560644
      0.13403374      -0.30077764       0.37038742
      0.98462893       0.81761037       0.60965656
      0.51924082       0.63814697       0.49321682
      0.28461449       0.88126714       0.66475622
     -0.20914894       0.44302019       0.50652580
      0.58914466       0.74769132       0.56398020
      0.41471483       1.19061656       0.72530883
     -0.12231266       0.52176874       0.60092233
      0.26021422       1.34539425       0.53435665
      1.56662855       1.77066279       0.67736079
      1.10461724       0.26953014       0.36735832
      0.72369042       0.35764108       0.34663600
      0.43147580      -0.68083095       0.32528778
      0.81926513       0.85574301       0.56746752
      1.25134221      -0.39325035       0.56126973
      0.87947711       1.14636757       0.70571444
      0.62353030       0.97359658       0.59258366
      0.91315731       0.79159814       0.67046472
      1.00887481      -0.51613717       0.38007575
      0.71990656       0.52980508       0.69520722
      0.42715157       0.93815001       0.61949356
      1.22065693       1.25957506       0.70894987
      0.68302181       0.25679220       0.67873356
      1.04556333       1.22974551       0.74538666
      0.05950376       0.17484591       0.65818294
     -0.25231321       1.76973735       0.70816158
      0.45404841       0.29350534       0.51621152
      0.47580393      -0.01885257       0.68583286
      0.31607039       1.37827042       0.60641490
      0.13921945       1.47529964       0.65395905
     -0.24949740       1.04980313       0.38476573
      1.02198254       0.77527198       0.51809412
     -0.13269955      -0.63172943       0.26362895
     -0.01665243       1.05122555       0.57819040
      0.34830926       0.86183449       0.73481007
      0.08547124       0.49199314       0.59517301
     -0.22931968       0.07879046       0.47296684
      1.15374394       0.51400513       0.30712860
     -0.02575549       0.24426930       0.46122795
      0.33910288       0.28875076       0.42031444
      0.89222545       1.42242644       0.72114703
      0.45112644       0.49752204       0.57217511
      0.78732813       0.24777689       0.30076703
      0.17546728       1.17137686       0.45167807
      0.60114018       1.43939441       0.60809185
      1.96388141       1.37112395       0.67251971
      0.13553192      -0.02618932       0.70064801
      1.23640886       0.39518318       0.34779401
      0.01704024       0.84626979       0.45444055
      0.34009588       0.83637329       0.57759905
      0.44929940      -0.11284502       0.35947285
      0.58008850       0.46021347       0.52387715
      0.65101061       0.61092524       0.34954978
      0.79285789      -0.22059881       0.33571374

INCAR

The INCAR files are shown here for reference; each is reproduced and discussed in the step that uses it.

Click to reveal the molecular-dynamics INCAR
#Molecular dynamics
IBRION = 0
ISYM   = 0
NSW    = 100000
POTIM  = 1.0
TEBEG = 298
TEEND = 298
MDALGO = 3
ISIF = 2
LANGEVIN_GAMMA = 10.0 10.0 10.0 # one for each atomic species
POMASS = 2.0 16.0 55.847
RANDOM_SEED =         248489752                0                0

#Machine learning
#Must monitor/change
ML_LMLFF = .TRUE.                    # switches on machine learning
ML_MODE = run
Click to reveal the GGA INCAR
ENCUT  = 520.0
EDIFF  = 1E-5
GGA = RP
IVDW = 11
ISMEAR = 0
SIGMA  = 0.10
PREC   = Normal
LREAL  = A
NELMIN = 4
ALGO = All
NELM = 1000
LCHARG = .FALSE.
LWAVE = .FALSE.
ICHARG = 2
LVHAR = .TRUE.
WRT_POTENTIAL = hartree ionic
ICORELEVEL = 1
IBRION = -1
ISYM   = 0
NSW    = 1

KPOINTS

Only the Γ point is used, so the KPOINTS file is:

Gamma-point only
 0
Monkhorst Pack
 1 1 1
 0 0 0

POTCAR

Standard POTCAR files are used throughout:

  • PAW_PBE H 15Jun2001
  • PAW_PBE O 08Apr2002
  • PAW_PBE Fe_sv 23Jul2007

Step-by-step instructions

Step 1: Running the MD simulation with an MLFF

Perform a molecular dynamics (MD) simulation for each system using a Langevin thermostat. Use the following INCAR file:

#Molecular dynamics
IBRION = 0
ISYM   = 0
NSW    = 100000
POTIM  = 1.0
TEBEG = 298
TEEND = 298
MDALGO = 3
ISIF = 2
LANGEVIN_GAMMA = 10.0 10.0 10.0 # one for each atomic species
POMASS = 2.0 16.0 55.847
RANDOM_SEED =         248489752                0                0

#Machine learning
#Must monitor/change
ML_LMLFF = .TRUE.                    # switches on machine learning
ML_MODE = run

This example uses a 100000 fs MD simulation (100000 steps with a time step of 1 fs), using a Langevin thermostat.

Step 2: Selecting structures at random

From each of the MD calculations in Step 1, select 100-200 random structures (for the slab, use about 400), i.e., POSCAR files, excluding the first 20000 steps to allow for time to equilibrate. Save these structures to three directories (one for each system), i.e., Fe3P_64H2O, Fe2P_64H2O, and 128H2O_slab.

Using the following Python script, you can select 200 random structures for each redox system and 400 for the slab, omitting the first 20000 MD steps to allow equilibration:

from ase.io import read
from ase.io import write
import numpy as np

path1 = "$PATH_TO_MD_DIRECTORIES/"
path2 = "$PATH_TO_CORELEVEL_DIRECTORIES/"

def random_md_structures(path1, path2, systems, n, cutoff):
    # Read entire XDATCAR trajectory (all steps)
    for system in systems:
        atoms_list = read(path1 + system + "/XDATCAR", index=":")
        n_struc = len(atoms_list)
        n_random = np.random.randint(cutoff, n_struc, size=n)
        
        # Write selected frames back to POSCAR format
        for i, j in enumerate(n_random):
            #print(i+1,j)
            write(path2 + system + "/POSCAR." + str(i+1), atoms_list[j], format="vasp")

random_md_structures(path1, path2, ["Fe2P_64H2O", "Fe3P_64H2O"], 200, 20000)
random_md_structures(path1, path2, ["128H2O_slab"], 400, 20000)

which writes POSCAR.1 onwards in each directory, 200 for the redox systems and 400 for the slab. Converging the local potential of the slab needs about 3000 structures [1]; 400 are used here, which is enough to reach the literature value to within 0.1 eV.

Step 3: Calculating the O1s energies and the local potential with a GGA

For each of the structures that you have generated, perform a first-principles (FP) calculation with ICORELEVEL = 1, LVHAR = .TRUE., and WRT_POTENTIAL = hartree ionic. The energies of the O1s levels, and the local potential will be written, which can later be used to find the vacuum reference. An example INCAR for RPBE+D3 is provided below:

ENCUT  = 520.0
EDIFF  = 1E-5
GGA = RP
IVDW = 11
ISMEAR = 0
SIGMA  = 0.10
PREC   = Normal
LREAL  = A
NELMIN = 4
ALGO = All
NELM = 1000
LCHARG = .FALSE.
LWAVE = .FALSE.
ICHARG = 2
LVHAR = .TRUE.
WRT_POTENTIAL = hartree ionic
ICORELEVEL = 1
IBRION = -1
ISYM   = 0
NSW    = 1

In addition, for the charged systems, Fe2+:

ISPIN = 2
NELECT = 526
MAGMOM = 128*0 64*0 1*4

and Fe3+:

ISPIN = 2
NELECT = 525
MAGMOM = 128*0 64*0 1*5

An example bash script is given below for executing the calculations. Save the two Python blocks below as O1s_level.py and vacuum_ref.py in the directory you run from.

Click to reveal the O1s_level.py script
import numpy as np
import os
import sys

def pbc_distance(r1, r2, L):
    """Compute minimum-image distance between r1 and r2 in a periodic box of size L."""
    delta = (r1 - r2) % L

    delta = np.where(delta > L/2, delta - L, delta)
    return delta

def o1s_av(path, outcar, element_of_interest, lower_limit=0.0, upper_limit=50.0, system="bulk"):
    o1s, pos, n_species, species, cell = [], [], [], [], []
    n_ions, count = 0, 0
    with open(path + "/" + outcar, "r") as f:
        for line in f:
            # Total number of ions
            if "NIONS =" in line:
                n_ions = float(line.split()[-1])
            # Number of ions of each species
            elif "ions per type =" in line:
                n_species = line.split()[4:]
            # Name of each species
            elif "POSCAR =" in line:
                species = line.split()[2:]
            # Positions of all ions
            elif "position of ions in cartesian coordinates  (Angst)" in line:
                for ion in range(0, int(n_ions)):
                    a = [float(x) for x in f.readline().split()]
                    pos.append(a)
                count += 1
            elif "Primitive cell" in line:
                #print(line)
                f.readline()
                f.readline()
                f.readline()
                f.readline()
                cell.append(float(f.readline().split()[0]))
                cell.append(float(f.readline().split()[1]))
                cell.append(float(f.readline().split()[2]))
            elif "1s" in line:
                o1s.append(float(line.split()[-1]))

    '''Filters through positions so that only the O ions which are between
    the upper and lower limit along the z-axis are taken, i.e., in the "bulk" of the slab.
    If it contains the redox species, all O ions within a sphere of half the cell size
    are excluded. By default, all positions are taken.'''
    elements_dict = dict(zip(species, n_species))
    n_skip = 0
    index_in_limits, core_in_limits = [], []
    for key in elements_dict.keys():
        n_count=int(elements_dict[key])
        if system == "redox":
            #print(key)
            pass
        if key == element_of_interest:
            m = 0
            for ion in pos[n_skip:n_skip+n_count]:
                if system == "bulk":
                    core_in_limits.append(o1s[m])
                elif system == "slab":
                    if lower_limit <= ion[2] < upper_limit:
                        index_in_limits.append(m)
                        core_in_limits.append(o1s[m])
                elif system == "redox":
                    cell_av = np.average([cell[0],cell[1],cell[2]])
                    cell_cubic = [cell[0],cell[1],cell[2]]
                    x = pbc_distance(np.array(pos[-1]), np.array(ion), np.array(cell_cubic))
                    magnitude = np.sqrt(x.dot(x))
                    if magnitude >= cell_av/2:
                        #print(cell_av/2, magnitude, x, ion, pos[-1], o1s[m])
                        index_in_limits.append(m+n_skip)
                        core_in_limits.append(o1s[m])
                m +=1
        n_skip += int(elements_dict[key])
    return(np.average(core_in_limits))

def o1s_avg_all(path, element_of_interest, lower_limit=0.0, upper_limit=50.0, system="bulk"):
    o1s_all = []
    for outcar in (x for x in os.listdir(path + "/") if "OUTCAR." in x):
        #if len(o1s_all) < 100:
        o1s_all.append(o1s_av(path, outcar, element_of_interest, lower_limit, upper_limit, system))
        #if bulk_slab == "slab":
        #    print(o1s_all[-1])
    return(np.average(o1s_all))

# Expecting: python3 O1s_level.py z_mid z_diff system element
if len(sys.argv) != 5:
    print("Usage: python3 O1s_level.py z_mid z_diff system element")
    sys.exit(1)

# Read inputs
z_mid  = float(sys.argv[1])
z_diff = float(sys.argv[2])
system = sys.argv[3]
element_of_interest = sys.argv[4]

# Validate system type
if system not in ("bulk", "slab", "redox"):
    print('Error: system must be either "bulk" or "slab" or "redox"')
    sys.exit(1)

lower_limit, upper_limit = (z_mid - z_diff), (z_mid + z_diff)

O1s_avg =  o1s_avg_all(".", element_of_interest, lower_limit, upper_limit, system)

print(O1s_avg)
Click to reveal the vacuum_ref.py script
import py4vasp
import numpy as np
import sys

def local_pot_avg(path, z_lower, z_upper, z_mid, system="bulk"):
    # Load calculation
    calc = py4vasp.Calculation.from_path(path)
    pot_dict = calc.potential.to_dict()

    # Local potential (ionic + hartree)
    pot_local = pot_dict["ionic"] + pot_dict["hartree"]

    # Plane-average over x,y
    pot_avg = np.mean(pot_local, axis=(0, 1))  # shape: (NZ,)

    # Lattice length along z
    a_3 = pot_dict["structure"]["lattice_vectors"][2][2]
    NZ = pot_avg.shape[0]
    dz = a_3 / NZ

    # Original z-grid
    z = np.arange(NZ) * dz

    # Step 1: Extend potential with periodic images (-1, 0, 1)
    extended_pot = np.zeros(3*NZ)
    extended_z = np.zeros(3*NZ)

    for shift in (-1, 0, 1):
        base = (shift + 1) * NZ
        for k in range(NZ):
            extended_z[base + k] = (k + shift*NZ) * dz - (z_mid - 0.5*a_3)
            extended_pot[base + k] = pot_avg[k]

    # Step 2: Interpolate back onto the original z-grid
    pot_interp = np.zeros(NZ)
    for j in range(NZ):
        # Find bracketing points
        K = int((z[j] + z_mid - 0.5*a_3) / dz) + NZ  # shift to center of extended array
        K = max(0, min(K, 3*NZ-2))  # avoid overflow
        x0, x1 = extended_z[K], extended_z[K+1]
        y0, y1 = extended_pot[K], extended_pot[K+1]
        pot_interp[j] = y0 + (y1 - y0) * (z[j] - x0) / (x1 - x0)

    # Step 3: Find the vacuum reference and apply the vacuum shift to the potential
    vac_ref = pot_interp[0] # when the slab is in the middle of the cell
    #pot_interp -= vac_ref
    #print(system)

    if system in ("bulk", "redox"):
        # Step 4: Compute average over entire cell
        pot_range_avg = pot_interp.mean()
        #print(f"Average potential across bulk cell is {pot_range_avg:.10f}")
    elif system == "slab":
        # Step 4: Compute average over z_mid ± z_diff
        mask = (z >= z_lower) & (z <= z_upper)
        pot_range_avg = pot_interp[mask].mean()
        #print(f"Average potential from z={z_lower:.3f} to {z_upper:.3f} is {pot_range_avg:.10f}")

    return z, pot_interp, pot_range_avg

# Expecting: python3 vacuum_ref.py z_mid z_diff system
if len(sys.argv) != 4:
    print("Usage: python3 vacuum_ref.py z_mid z_diff system")
    sys.exit(1)

# Read inputs
z_mid  = float(sys.argv[1])
z_diff = float(sys.argv[2])
system = sys.argv[3]

# Validate system type
if system not in ("bulk", "slab", "redox"):
    print('Error: system must be either "bulk" or "slab"')
    sys.exit(1)

# Example: average potential
z_lower, z_upper = (z_mid - z_diff), (z_mid + z_diff)

path = "."
calc_temp = py4vasp.Calculation.from_path(path)
grid = np.shape(calc_temp.potential.to_dict()["ionic"])[2]
tot_avg, z, pot_avg = np.zeros(int(grid)), np.zeros(int(grid)), np.zeros(int(grid))
pot_avg_range = 0.0

z, pot_interp, pot_range_avg = local_pot_avg(path, z_lower, z_upper, z_mid, system)
#print("system, z_mid, z_diff, path, z_lower, z_upper")
#print(system, z_mid, z_diff, path, z_lower, z_upper)
print(pot_range_avg)
#!/bin/bash

VASP="mpirun -np 32 $PATH_TO_VASP/vasp_gam"

rm -rf vac_ref.dat
echo "N_struc O1s_level local_potential_avg" >> vac_ref.dat

for a in POSCAR.*; do
        echo $a
        cp $a POSCAR
        $VASP
        # Use if you don't want to run the Python scripts at the same time as the calculations
        #cp OUTCAR OUTCAR.$suffix 
        #cp vaspout.h5 vaspout.$suffix.h5
        #cp LOCPOT LOCPOT.$suffix
        suffix="${a#*.}"
        # Use the first for the Fe2+/3+ systems, and the second for the bare slab
        echo $suffix `python3 O1s_level.py 25.0 5.0 redox O` `python3 vacuum_ref.py 25.0 5.0 redox` >> vac_ref.dat
        #echo $suffix `python3 O1s_level.py 25.0 5.0 slab O` `python3 vacuum_ref.py 25.0 5.0 slab` >> vac_ref.dat 
done

An alternative script exists if you are taking the local potential from LOCPOT, rather than vaspout.h5, though it has not been as extensively tested:

Click to reveal the read_locpot.py script
import numpy as np

def read_locpot_single(filename, ZMID, DIFF):
    """
    Process a single LOCPOT file (equivalent to NCONF=1 case of the Fortran code).
    All arrays should be NumPy arrays.
    """

    IREFZ, LSHIFT, MITYP = 0, 1, 0

    global LOCPOTZ, RHOZ, POSION

    print("---------------LOCPOT--------------------")
    print("Reading single LOCPOT:", filename)

    NWRITE = 5
    TOTAL, NCOL, NMOD = 0, 0, 0

    ZMIN = ZMID - DIFF
    ZMAX = ZMID + DIFF

    A = np.zeros((3, 3))
    NITYP = 0

    with open(filename, "r") as f:
        # VASP header (8 lines)
        f.readline()
        f.readline()
        for i in range(3):
             A[i] = np.fromstring(f.readline(), sep=' ')
        f.readline()
        NITYP = np.fromstring(f.readline(), sep=' ', dtype=int)
        print(NITYP)
        NTYP = len(NITYP)
        f.readline()

        #for i in range(NTYP):
        #    for j in range(int(NITYP[i])):
        #        f.readline()
        #print("first", f.readline())

        # Allocate POSION now that NTYP and NITYP are known
        POSION = np.zeros((3, int(max(NITYP)), NTYP))

        # Read atomic positions
        for j in range(NTYP):
            for k in range(NITYP[j]):
                x, y, z = map(float, f.readline().split())
                POSION[0, k, j] = x
                POSION[1, k, j] = y
                POSION[2, k, j] = z

        f.readline()
        NX, NY, NZ = np.fromstring(f.readline(), sep=' ', dtype=int)

        LOCPOTZ = np.zeros(NZ)
        RHOZ = np.zeros(NZ)

        TOTAL = NX * NY * NZ
        NCOL = TOTAL // NWRITE
        NMOD = TOTAL % NWRITE
        MITYP = NITYP.max()

        DX = A[0,0] / NX
        DY = A[1,1] / NY
        DZ = A[2,2] / NZ

        # RHOZ accumulation (only if j == 1 in Fortran, zero-based j == 1)
        for k in range(NITYP[j]):
            for L in (-1, 0, 1):
                XYZ = np.zeros(3)
                XYZ[0] = POSION[0, k, j] * A[0,0]
                XYZ[1] = POSION[1, k, j] * A[1,1]
                XYZ[2] = (POSION[2, k, j] + L) * A[2,2]

                if j == 1:  # Fortran J==2
                    iz = int(XYZ[2] * NZ / A[2,2]) + 1
                    if 1 <= iz <= NZ:
                        RHOZ[iz-1] += (18.0 / 6.022045e23 / (A[0,0]*A[1,1]*DZ*1e-24))

        # Skip blank lines before potential data
        #f.readline()
        #f.readline()

        # Read LOCPOT grid (flattened)
        LOCPOT_HELP = np.zeros(TOTAL)
        idx = 0
        for _ in range(NCOL):
            vals = list(map(float, f.readline().split()))
            LOCPOT_HELP[idx:idx+NWRITE] = vals
            idx += NWRITE
        if NMOD > 0:
            vals = list(map(float, f.readline().split()))
            LOCPOT_HELP[idx:idx+NMOD] = vals

    # Average LOCPOT over x,y for each z-plane
    LOCPOTZ_HELP1 = np.zeros(NZ)
    for j in range(NZ):
        plane = LOCPOT_HELP[j*NX*NY:(j+1)*NX*NY]
        LOCPOTZ_HELP1[j] = plane.mean()

    # Build extended arrays for interpolation
    LOCPOTZ_HELP2 = np.zeros(3*NZ)
    Z_HELP2 = np.zeros(3*NZ)

    for shift in (-1, 0, 1):
        base = (shift + 1) * NZ
        for k in range(NZ):
            L = base + k
            Z_HELP2[L] = (L * DZ) - A[2,2] - (ZMID - 0.5*A[2,2])
            LOCPOTZ_HELP2[L] = LOCPOTZ_HELP1[k]

    # Interpolate back to correct Z grid
    LOCPOTZ_HELP3 = np.zeros(NZ)
    Z_HELP3 = np.arange(NZ) * DZ

    for j in range(NZ):
        K = int((Z_HELP3[j] + A[2,2] + ZMID - 0.5*A[2,2]) * NZ / A[2,2])
        K = max(0, min(K, 3*NZ-2))

        x0, x1 = Z_HELP2[K], Z_HELP2[K+1]
        y0, y1 = LOCPOTZ_HELP2[K], LOCPOTZ_HELP2[K+1]

        LOCPOTZ_HELP3[j] = y0 + (y1 - y0)*(Z_HELP3[j] - x0)/(x1 - x0)

    # Apply shift if required
    if LSHIFT == 1:
        LOCPOTZ_VAC = LOCPOTZ_HELP3[IREFZ-1]
        SHIFTZ = -LOCPOTZ_VAC
    else:
        SHIFTZ = 0.0

    LOCPOTZ_HELP3 += SHIFTZ

    # Compute average potential over ZMIN–ZMAX
    mask = (Z_HELP3 >= ZMIN) & (Z_HELP3 <= ZMAX)
    LOCPOTZ_AV = LOCPOTZ_HELP3[mask].mean()

    print("Potential =", LOCPOTZ_AV)

    # This is the final averaged LOCPOT vs z
    return LOCPOTZ_HELP3, RHOZ

read_locpot_single("LOCPOT", 18.175, 3.5)

These scripts will create a vac_ref.dat file containing the number, the average 1s energy levels for O in water molecules, and the average local potential for each structure:

N_struc O1s_level local_potential_avg
1 -509.526392 -1.6969455464219334
2 -509.4371388571428 -1.5132796708524134
3 -509.30019053061227 -1.0734347143520142
4 -509.4201625058023 -1.973256948325608
...

These will be required in the next step.

Step 4: Averaging the O1s energy levels

Once the FP calculations have finished, extract the O1s energy levels [math]\displaystyle{ \epsilon_{1s} }[/math]. You can find them listed in OUTCAR after the core state eigenenergies. For each structure, average these energy levels over all O, except for 128H2O_slab, where only the oxygen atoms within the central 10 [math]\displaystyle{ \AA }[/math] of the cell are used, to mimic the bulk. With the average O1s for each individual structure, average over all structures in the ensemble, to get a single value for each system.

If you used the run script structure suggested above, then you will have a vac_ref.dat file. In the first column, there is the structure number, followed by the average O1s level for water molecules, then the average local potential [math]\displaystyle{ \mu }[/math].

You have now obtained the O1s level. The values obtained for different numbers of structures, compared with the literature values, are compiled in the following table:

System GGA (RPBE+D3) Lit. [1], a
No. of structures 100 200 400
[math]\displaystyle{ \langle \epsilon_{1s,slab} \rangle }[/math], 128H2O slab -509.43 -509.46 -509.45 -511.23
[math]\displaystyle{ \langle \epsilon_{1s,Fe^{3+}} \rangle }[/math], Fe3+ + 64H2O (λ = 0) -507.45 -507.45 -507.45 -507.43
[math]\displaystyle{ \langle \epsilon_{1s,Fe^{2+}} \rangle }[/math], Fe2+ + 64H2O (λ = 1) -507.50 -507.50 -507.50 -507.50

aThe number of structures used in Jinnouchi et al. is 200 for bulk water and redox systems, and 3000 for the water slab, cf. Supplementary Table 4 for the averaged 1s levels of O atoms in Jinnouchi et al. for reference [1].

There is a small difference between the literature for the bulk and redox systems using 100 structures, which is narrowed when using 200. The difference for the water slab is much larger, as the reference with respect to the vacuum has not been given, hence the missing ~1.8 eV. The average O1s level is converged for the water slab, which shows that the local potential requires many structures to converge.

Step 5: Referencing the O1s level to the vacuum

The averaged local potential of the slab, [math]\displaystyle{ \bar{\phi}_{\mathrm{slab}} }[/math], must be included to obtain an absolute redox potential; otherwise, comparing between different cells (as in this example) or between different systems cannot be done as no common reference exists. It is important to include this because the local potential means that the vacuum reference is not equal to 0 eV, it is more negative ~-1.8 eV:

Figure 2. The local potential for the water slab (128H2O_slab). Increasing from 100 to 400 structures partially smooths out the potential, but much larger numbers of structures are required to smooth it out completely (cf. the right-hand side of Fig. 1b in [1]). You can see that the local potential is ~-1.8 eV. This is the missing term from the previous section.

You can calculate the local potential using LVHAR = .TRUE.. This saves the potential to LOCPOT, from which you could perform all of the following steps to calculate the average. Instead, WRT_POTENTIAL = hartree ionic saves the local potential to vaspout.h5, which can be analyzed with py4vasp. This gives

System GGA (RPBE+D3)
No. of structures 100 200 400
[math]\displaystyle{ \langle \bar{\phi}_{\mathrm{slab}} \rangle }[/math], 128H2O slab -1.686 -1.735 -1.729

Consider the average local potential only relative to the vacuum, that is, for the center of the water slab. The bulk and redox systems do not need to be corrected (cf. Fig. 2 below, and Fig. 1c and Eq. 7 of [1]).

The updated O1s energy for the water slab is then much closer to the literature:

System GGA (RPBE+D3) Lit. [1], a
No. of structures 100 200 400 Std POTCAR
[math]\displaystyle{ \langle \epsilon_{1s,slab} \rangle + \bar{\phi}_{\mathrm{slab}} }[/math], 128H2O slab -511.12 -511.20 -511.18 -511.23

aThe number of structures used in Jinnouchi et al. varies from 200 for bulk water and redox systems, to 3000 for the water slab, cf. Supplementary Table 4 for the averaged 1s levels of O atoms in Jinnouchi et al. for reference [1].

Step 6: Comparing the local potential in the slab and the bulk

The vacuum alignment [math]\displaystyle{ e \Delta \bar{\phi} }[/math] (in eV) can now be obtained; one electron is transferred in this half-cell reaction, so [math]\displaystyle{ n=1 }[/math]:

[math]\displaystyle{ e \Delta \bar{\phi} = \frac{[\langle \epsilon_{1s,Fe^{3+}} \rangle + \langle \epsilon_{1s,Fe^{2+}} \rangle]}{2} - \left( \langle \epsilon_{1s,slab} \rangle + \bar{\phi}_{\mathrm{slab}} \right) }[/math]

[math]\displaystyle{ = \frac{[(-507.45) + (-507.50)]}{2} - (-509.45 - 1.73) = 3.71 }[/math] eV (this example)

[math]\displaystyle{ e \Delta \bar{\phi}_{\mathrm{Lit.}} = \frac{[(-507.43) + (-507.50)]}{2} - (-511.23) = 3.74 }[/math] (for Std. POTCAR provided by R. Jinnouchi; GW POTCARs in lit. [1])

These values agree to within 0.1 eV of the literature, having used only 400 structures for the slab, rather than the 3000 in the paper. Having obtained [math]\displaystyle{ e \Delta \bar{\phi} }[/math], you now have the reference to the vacuum, necessary for calculating the absolute redox potentials.

In the next stage, you will perform TI from Fe3+ to Fe2+ using MLFFs.

Recommendations and advice

  • Read the local potential from vaspout.h5, rather than LOCPOT, as you can take advantage of the HDF5 tools for data extraction.
  • 3000 slab calculations will create a lot of large OUTCAR, vaspout.h5, and LOCPOT files (several 100 GBs). Test your setup using the Python scripts in your run script to avoid this.
  • Use a stochastic thermostat, such as the Langevin thermostat (MDALGO=3), because it generally provides more ergodic sampling than deterministic alternatives.

Related tags and articles

How-tos
Theory
Files
Tags

References