Charge Density Data

Hi,

When I download the chgcar data using mp_api.client.MPRester(‘api_key’).get_charge_density_from_material_id(‘mpid’), how should I interpret the chgcar object? Specifically, how to interpret the grid for chgcar.data[‘total’] ? Is the grid over the unitcell we get from MPRester(‘api_key’).get_structure_by_material_id(‘mpid’)?

Hope to see some documentation here soon!

Hi @shravangodse16,

Good question. The grid is over the structure found in the associated task document. To get that data alongside the CHGCAR object, you can pass inc_task_doc=True to get_charge_density_from_material_id alongside the MPID.

– Jason

Thanks!
Do we need VASP POTCAR files for inc_task_doc=True?
I am getting the following error upon running chgcar, data = mpr.get_charge_density_from_material_id('mp-861724', inc_task_doc=True):

ValueError: No POTCAR for Ac with functional PBE found. Please set the PMG_VASP_PSP_DIR environment in .pmgrc.yaml, or you may need to set PMG_DEFAULT_FUNCTIONAL to PBE_52 or PBE_54 if you are using newer psps from VASP.

I do not have a VASP license, however, I only need the structure (POSCAR file) used in the charge density calculations.

You shouldn’t, that is a bug. I will look into fixing it. In the mean time, here is a way around the issue to get the POSCAR data:

from mp_api.client import MPRester

with MPRester("your_api_key", monty_decode=False) as mpr:
    chgcar, task_doc = mpr.get_charge_density_from_material_id("mp-149", inc_task_doc=True)
    poscar = task_doc.orig_inputs.poscar

– Jason

This works, thanks a lot!