{"id":531,"date":"2022-03-30T09:09:57","date_gmt":"2022-03-30T09:09:57","guid":{"rendered":"https:\/\/doublelayer.eu\/vilab\/?p=531"},"modified":"2022-12-12T12:07:57","modified_gmt":"2022-12-12T12:07:57","slug":"bayesian-error-estimation-for-rpbe","status":"publish","type":"post","link":"https:\/\/doublelayer.eu\/vilab\/2022\/03\/30\/bayesian-error-estimation-for-rpbe\/","title":{"rendered":"Bayesian Error Estimation (BEE) for RPBE"},"content":{"rendered":"\n<p>The Beyesian Error Estimation (<a href=\"https:\/\/doi.org\/10.1103\/PhysRevLett.95.216401\">BEE<\/a>) is implemented in <a href=\"https:\/\/wiki.fysik.dtu.dk\/gpaw\/documentation\/xc\/vdw.html\">GPAW<\/a> only for PBE, BEEF-vdW, and mBEEF-vdW.<\/p>\n\n\n\n<p>Here is a trick for making the BEE with the RPBE functional. Just edit the lines in ASE and GPAW codes by adding RPBE as an exception.<\/p>\n\n\n\n<p>To find the needed files, run<\/p>\n<p><pre class=\"wp-block-preformatted wp-block-code\"><code>find .\/ -name \"bee.py\"<\/code><\/pre><\/p>\n\n\n\n<p>In <a href=\"https:\/\/gitlab.com\/ase\/ase\/-\/blob\/master\/ase\/dft\/bee.py\">ase\/dft\/bee.py<\/a> change one line:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted wp-block-code\"><code>class BEEFEnsemble:\n\n\n\n            if self.xc in ['BEEF-vdW', 'BEEF', 'PBE', 'RPBE']: # add RPBE\n                self.beef_type = 'beefvdw'<\/code><\/pre>\n\n\n\n<p>In <a href=\"https:\/\/gitlab.com\/gpaw\/gpaw\/-\/blob\/master\/gpaw\/xc\/bee.py\">gpaw\/xc\/bee.py<\/a> add two lines:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted wp-block-code\"><code>class BEEFEnsemble:\n    \"\"\"BEEF ensemble error estimation.\"\"\"\n    def __init__(self, calc):\n\n\n\n        # determine functional and read parameters\n        self.xc = self.calc.get_xc_functional()\n        if self.xc == 'BEEF-vdW':\n            self.bee_type = 1\n        elif self.xc == 'RPBE': # catch the RPBE exchange functional\n            self.bee_type = 1   # assign BEEF coefficients the RBPE<\/code><\/pre>\n\n\n\n<p>Below we use <a href=\"https:\/\/wiki.fysik.dtu.dk\/gpaw\/documentation\/xc\/vdw.html\">BEEF-vdW<\/a>, RPBE, and PBE dimensionless density (<em>n<\/em>) with gradient (<em>s<\/em>) and apply <a href=\"https:\/\/doi.org\/10.1103\/PhysRevB.85.235149\">BEEF<\/a> coefficients (<em>E<\/em>\u2080, \u0394<em>E\u1d62<\/em>) to evaluate the BEE as the standard deviation for the ensemble total energies with the variable enhancement factor (<em>F<\/em>(<em>s<\/em>,<em>\u03b8\u1d62<\/em>)).<\/p>\n\n\n\n<pre class=\"wp-block-preformatted wp-block-code\"><code>\nfrom ase import Atoms\nfrom ase.dft.bee import BEEFEnsemble\nfrom ase.parallel import parprint\nfrom gpaw import GPAW\nimport time\n\nfor xc in ['BEEF-vdW','RPBE','PBE']:\n    start_time = time.time()\n\n    h2 = Atoms('H2',[[0.,0.,0.],[0.,0.,0.741]]) #exp. bond length\n    h2.center(vacuum=3)\n    cell = h2.get_cell()\n\n    calc = GPAW(xc=xc,txt='H2_{0}.txt'.format(xc))\n    h2.calc = calc\n    e_h2 = h2.get_potential_energy()\n    ens = BEEFEnsemble(calc)\n    de_h2 = ens.get_ensemble_energies()\n    del h2, calc, ens\n\n    h = Atoms('H')\n    h.set_cell(cell)\n    h.center()\n    calc = GPAW(xc=xc,txt='H_{0}.txt'.format(xc), hund=True)\n    h.calc = calc\n    e_h = h.get_potential_energy()\n    ens = BEEFEnsemble(calc)\n    de_h = ens.get_ensemble_energies()\n    del h, calc, ens\n\n    E_bind = 2*e_h - e_h2\n    dE_bind = 2*de_h[:] - de_h2[:]\n    dE_bind = dE_bind.std()\n    \n    parpting('{0} functional'.format(xc))\n    parprint('Time: {0} s'.format(round(time.time()-start_time,0)))\n    parprint('E_bind: {0} eV'.format(round(E_bind,4)))\n    parprint('Error bar {0} eV'.format(round(dE_bind,4)))\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The Beyesian Error Estimation (BEE) is implemented in GPAW only for PBE, BEEF-vdW, and mBEEF-vdW. Here is a trick for making the BEE with the RPBE functional. Just edit the lines in ASE and GPAW codes by adding RPBE as an exception. To find the needed files, run find .\/ -name &#8220;bee.py&#8221; In ase\/dft\/bee.py change&hellip; <a class=\"read-more\" href=\"https:\/\/doublelayer.eu\/vilab\/2022\/03\/30\/bayesian-error-estimation-for-rpbe\/\">Read More<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,40],"tags":[34],"class_list":["post-531","post","type-post","status-publish","format-standard","hentry","category-know-how","category-opensource","tag-software"],"_links":{"self":[{"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/posts\/531","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/comments?post=531"}],"version-history":[{"count":17,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/posts\/531\/revisions"}],"predecessor-version":[{"id":734,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/posts\/531\/revisions\/734"}],"wp:attachment":[{"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/media?parent=531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/categories?post=531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/tags?post=531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}