pyiron / FAQs

General question board for pyiron users
3 stars 0 forks source link

How to set a pseudo potential in pyiron? #23

Open jan-janssen opened 7 months ago

jan-janssen commented 7 months ago

There are different ways how to select a pseudo potential for a VASP calculation in pyiron. In the following the different ways are briefly introduced.

Select a pseudo potential for all atoms of a specific element:

Use the internal pseudo potentials:

from pyiron_atomistics import Project

pr = Project("test")
job = pr.create.job.Vasp("vasp")
job.structure = pr.create.structure.ase.bulk("Al", cubic=True)
# job.potential_list   # list available potentials 
job.potential.Al = "Al_sv_GW"
job.server.run_mode.manual = True
job.run()

job["POTCAR"][0]
>>> '  PAW_PBE Al_sv_GW 2Feb2008                  \n'

Use your own pseudo potential based on the absolute path:

import os
from pyiron_base import state
from pyiron_atomistics import Project

def get_vasp_potential_path():
    for p in state.settings.resource_paths:
        vasp_pot_path = os.path.join(p, "vasp", "potentials")
        if os.path.exists(vasp_pot_path): 
            return vasp_pot_path
    raise ValueError("No potentials found!")

pr = Project("test")
job = pr.create.job.Vasp("vasp")
job.structure = pr.create.structure.ase.bulk("Al", cubic=True)
# job.potential_list   # list available potentials 
job.potential.Al = os.path.join(get_vasp_potential_path(), "potpaw", "Al_sv_GW", "POTCAR")
job.server.run_mode.manual = True
job.run()

job["POTCAR"][0]
>>> '  PAW_PBE Al_sv_GW 2Feb2008                  \n'

Select a pseudo potential for specific elements

https://pyiron.readthedocs.io/en/latest/source/faq.html#how-to-use-a-custom-pseudo-potential-in-vasp

from pyiron_atomistics import Project

Al_sv_GW = pr.create_element(
    new_element_name="Al_sv_GW",
    parent_element="Al",
    potential_file="Al_sv_GW",
)
Al_GW = pr.create_element(
    new_element_name="Al_GW",
    parent_element="Al",
    potential_file="Al_GW",
)

pr = Project("test")
job = pr.create.job.Vasp("vasp")
structure = pr.create.structure.ase.bulk("Al", cubic=True)
structure[:] = Al_GW
structure[0] = Al_sv_GW
job.structure = structure 
job.server.run_mode.manual = True
job.run()

for l in job["POTCAR"]:
    if "PAW_PBE" in l:
        print(l)

There is currently a bug in this second method of setting the pseudo potentials in the way that when the structure[:] = Al_GW line is not executed and there is no default potential set for all elements of a given species, then the line which should only overwrite the potential of the first element structure[0] = Al_sv_GW accidentally overwrites the potential for all elements.

Furthermore, setting the absolute path also does not work with the creation of new elements at the moment.

jan-janssen commented 7 months ago

@t-brink I hope this fixes your issue.