{"id":513,"date":"2022-03-29T11:51:28","date_gmt":"2022-03-29T11:51:28","guid":{"rendered":"https:\/\/doublelayer.eu\/vilab\/?p=513"},"modified":"2024-05-29T09:43:01","modified_gmt":"2024-05-29T09:43:01","slug":"ts09-and-d4-corrections-with-ase","status":"publish","type":"post","link":"https:\/\/doublelayer.eu\/vilab\/2022\/03\/29\/ts09-and-d4-corrections-with-ase\/","title":{"rendered":"TS09 and D4 corrections with ASE"},"content":{"rendered":"\n<p>TS09 and D4 are atomic-charge dependent dispersion corrections (see TS09 <a href=\"https:\/\/doi.org\/10.1103\/PhysRevLett.102.073005\">PRL paper<\/a> and D4 <a href=\"https:\/\/www.chemie.uni-bonn.de\/pctc\/mulliken-center\/software\/dftd4\/d4-a-generally-applicable-atomic-charge-dependent-london-dispersion-correction\">homepage<\/a> for the refs). The D4 code is available at <a href=\"https:\/\/github.com\/dftd4\/dftd4\">github<\/a>. According to <a href=\"https:\/\/wiki.fysik.dtu.dk\/gpaw\/documentation\/xc\/vdwcorrection.html\">GPAW documentation<\/a>, TS09 and D4 show for the S26 test set smaller mean deviation than vdW-DF. Herewith, D4 correction does not depend on the actual calculation as it is added to the calculated energy.<\/p>\n\n\n\n<p>Here is how D4 correction can be added with ASE (see <a href=\"https:\/\/github.com\/dftd4\/dftd4\/blob\/main\/python\/README.rst\">Readme<\/a>) after installing it (for example, as <code>conda install -c conda-forge dftd4 dftd4-python<\/code>):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from ase.build import molecule \nfrom ase.calculators.mixing import SumCalculator \nfrom ase.optimize import BFGS\nfrom dftd4.ase import DFTD4 \nfrom gpaw import GPAW \n\natoms = molecule('H2O') \natoms.center(vacuum=4)\n\ngpaw = GPAW(mode='fd',txt='H2O_D4.txt',xc='PBE') \natoms.calc = SumCalculator(&#91;DFTD4(method='PBE'), gpaw])\n\n#atoms.get_potential_energy()\nopt = BFGS(atoms,trajectory='H2O_D4.traj', logfile='H2O_D4.log')\nopt.run(fmax=0.05)<\/code><\/pre>\n\n\n\n<p>Let me stress that before choosing TS09 or D4 one should consider all pro and contra. TS09 method used Hirshfeld charges while D4 uses the electronegativity equilibration method to obtain charges. The former naturally accounts for the interfacial charge transfer while the latter does not. The TS09 correction requires vdW radii and is implemented for a limited set on functionals (see <a href=\"https:\/\/gitlab.com\/ase\/ase\/-\/blob\/master\/ase\/calculators\/vdwcorrection.py\">ASE code<\/a>), like PBE, RPBE, and BLYP. The D4 correction supports much more functionals (see <a href=\"https:\/\/github.com\/dftd4\/dftd4\/blob\/main\/assets\/parameters.toml\">parameters<\/a>). Regarding the vdW radii values for TS09 bare in mind that there are four data sources \u2013 <a href=\"https:\/\/gitlab.com\/gpaw\/gpaw\/-\/blob\/master\/gpaw\/analyse\/vdwradii.py\">one in GPAW<\/a>, <a href=\"https:\/\/gitlab.com\/ase\/ase\/-\/tree\/master\/ase\/data\">two in ASE<\/a> and <a href=\"https:\/\/gitlab.com\/ase\/ase\/-\/blob\/master\/ase\/calculators\/vdwcorrection.py\">one more in ASE<\/a>.<\/p>\n\n\n\n<p>Here is how TS09 correction can be added with ASE and GPAW:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted wp-block-code\"><code>from ase.build import molecule\nfrom ase.calculators.vdwcorrection import vdWTkatchenko09prl\nfrom ase.data.vdw_alvarez import vdw_radii\nfrom ase.optimize import BFGS\nfrom gpaw.analyse.hirshfeld import HirshfeldPartitioning\nfrom gpaw.analyse.vdwradii import vdWradii\nfrom gpaw import GPAW\n\natoms = molecule('H2O')\natoms.center(vacuum=4)\n\ngpaw = GPAW(mode='fd',txt='H2O_TS.txt',xc='PBE')\natoms.calc = vdWTkatchenko09prl(HirshfeldPartitioning(gpaw), vdWradii(atoms.get_chemical_symbols(), 'PBE'))\n\n#atoms.get_potential_energy()\nopt = BFGS(atoms,trajectory='H2O_TS.traj', logfile='H2O_TS.log')\nopt.run(fmax=0.05)<\/code><\/pre>\n\n\n\n<p>N.B! Note that the TS09 and D4 energies are no outputted to the H2O.txt. They  are written to the log-file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>TS09 and D4 are atomic-charge dependent dispersion corrections (see TS09 PRL paper and D4 homepage for the refs). The D4 code is available at github. According to GPAW documentation, TS09 and D4 show for the S26 test set smaller mean deviation than vdW-DF. Herewith, D4 correction does not depend on the actual calculation as it&hellip; <a class=\"read-more\" href=\"https:\/\/doublelayer.eu\/vilab\/2022\/03\/29\/ts09-and-d4-corrections-with-ase\/\">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],"tags":[48,53,34],"class_list":["post-513","post","type-post","status-publish","format-standard","hentry","category-know-how","tag-ase","tag-gpaw","tag-software"],"_links":{"self":[{"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/posts\/513","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=513"}],"version-history":[{"count":12,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/posts\/513\/revisions"}],"predecessor-version":[{"id":894,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/posts\/513\/revisions\/894"}],"wp:attachment":[{"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/media?parent=513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/categories?post=513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/doublelayer.eu\/vilab\/wp-json\/wp\/v2\/tags?post=513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}