pyiron / pyiron_atomistics

pyiron_atomistics - an integrated development environment (IDE) for atomistic simulation in computational materials science.
https://pyiron-atomistics.readthedocs.io
BSD 3-Clause "New" or "Revised" License
39 stars 15 forks source link

[VASP] final_magmoms not parsed. #1423

Closed pmrv closed 1 day ago

pmrv commented 2 months ago

When running a spin polarized calculation (ISPIN=2, collinear) it seems that the optimized magnetic moments (output/generic/dft/final_magmoms) are never read back in to pyiron, only the total magnetization (output/generic/dft/magnetization).

@ligerzero-ai Have you ever run spin stuff via pyiron?

ligerzero-ai commented 2 months ago

I have, and I think it should!? If not, I'll hop on this asap. I'll check and fix it this week

pmrv commented 2 months ago

It seems our code expects some per direction output in the OUTCAR that is not present or I'm missing some input flag that makes VASP write this only conditionally.

ligerzero-ai commented 2 months ago

It must lie in the way it is written to hdf, since the infrastructure (i.e. the parser parses magmoms properly). So the breakdown must be between the parser and the hdf5 information writer

pmrv commented 2 months ago

This is my INCAR

['SYSTEM=test_ni #jobname\n',
 'PREC=Accurate\n',
 'ALGO=Fast\n',
 'LREAL=.FALSE.\n',
 'LWAVE=.FALSE.\n',
 'LORBIT=0\n',
 'ISIF=2\n',
 'IBRION=2\n',
 'NELM=400\n',
 'NSW=100\n',
 'EDIFFG=-0.01\n',
 'ISPIN=2\n',
 'MAGMOM=1   1   1   1\n']

Is the parser reading it from vasprun.xml or OUTCAR (it seems the latter). Do you know off hand where I can reach into the parser directly?

ligerzero-ai commented 2 months ago

https://github.com/pyiron/pyiron_atomistics/blob/9210e83f33176b5c9df41b8d89c6018ea26e20c3/pyiron_atomistics/vasp/parser/outcar.py#L113

To access:

outcar = Outcar()
outcar.from_file(filename = outcar_path)
magmoms = np.array(outcar.parse_dict["final_magmoms"])
pmrv commented 2 months ago

Yeah, that one's empty, which is why it doesn't appear in the output. The pymatgen parser also doesn't return it for, so it does seem like I'm missing something when I start the run? :S

ligerzero-ai commented 2 months ago

your magmoms look weird - are you sure that's an accepted format? can you send me the outcar, I'll scroll through

pmrv commented 2 months ago

Dunno, that's how pyiron writes it when I set the initial magmoms.

OUTCAR.txt

ligerzero-ai commented 2 months ago

ahhhh lmfao, you need to set LORBIT = 10 in the INCAR to make sure magnetisation is actually written to the outcar, else it doesn't.

I'll patch it in when magmoms are specified.

pmrv commented 2 months ago

Ah, I thought it must be something like this. I do love how I even was on the correct page in the VASP wiki for LORBIT, but closed it again, because this is nowhere mentioned.

Anyway, thanks for your quick help!

ligerzero-ai commented 2 months ago

I have suspicion that it's removed from the wiki because it is no longer a necessity in the latest vasp versions, but if you are running old vasp it will require it. I remember it being on their wiki but they must have removed it. I see that vasp 5.4.4 is specified on your OUTCAR.

Still really dumb, regardless

pmrv commented 2 months ago

I also checked it with 6.4.4, but maybe I didn't read carefully enough.

pmrv commented 2 months ago

It seems it was also discovered here: https://github.com/pyiron/pyiron_atomistics/issues/1060 I'll add a FAQ entry for it tomorrow.

jan-janssen commented 2 months ago

@pmrv How did you define the MAGMOM ? Did you manually set it? Did you set the magnetic moments using the ASE structure? Can you share the pyiron input script?

ligerzero-ai commented 2 months ago

https://github.com/pyiron/pyiron_atomistics/pull/1424 fixes this and #1060

pmrv commented 2 months ago

@pmrv How did you define the MAGMOM ? Did you manually set it? Did you set the magnetic moments using the ASE structure? Can you share the pyiron input script?

I used this line to set up the moments as is done also in our unit tests.

j.structure.set_initial_magnetic_moments(1.0 * np.random.rand(4))

So the MAGMOM was pyiron generated. Anyway it worked after setting LORBIT.