abelcarreras / DynaPhoPy

Phonon anharmonicity analysis from molecular dynamics
http://abelcarreras.github.io/DynaPhoPy/
MIT License
113 stars 51 forks source link

DynaPhoPy does not take NBLOCK into account #11

Closed gabkrenzer closed 3 years ago

gabkrenzer commented 3 years ago

Hello,

I want to use DynaPhoPy to analyse three 100ps runs generated with the following INCAR on VASP: image The issue is that I don't think DynaPhoPy reads my XDATCAR knowing that NBLOCK = 50 and therefore interprets it as a regular XDATCAR with about 1,000 MD steps, while there are actually about 50,000 steps. I say about because I have cat together 7 runs due to walltime limits and there might be a few steps missing here and there.

Another point that raised concern is that even when I set my timestep to a particular value, so in this case -ts 0.002, DynaPhoPy states another value - see screenshot of the interactive interface after entering the command dynaphopy input_file 300_XDATCAR -ts 0.002 -i: image This may be due to my NBLOCK setting again because I tried setting various timestep using -ts on a short simulation with NBLOCK = 1 and DynaPhoPy worked fine - see screenshot of the interactive interface after entering the command dynaphopy input_file XDATCAR -ts 0.00005 -i when the timestep actually used was 1fs: image

Looking at the source code, there is only one mention of NBLOCK but in the unittest and it looks like that you assume it is 1 since in the line time = np.array([i*time_step for i in range(trajectory.shape[0])], dtype=float) you assume that the total simulation time is timestep*number_of_steps.

Kind Regards,

Gabriel

abelcarreras commented 3 years ago

Hi Gabriel,

Thank you for your feedback. VASP XDATCAR file is parsed by this function:

https://github.com/abelcarreras/DynaPhoPy/blob/5074b04b6336d8c28e205fa0d5d426f6488998d0/dynaphopy/interface/iofile/trajectory_parsers.py#L355

in principle NBOCK is supported by reading the step number after = sign in Direct configuration line (XDATCAR)

https://github.com/abelcarreras/DynaPhoPy/blob/5074b04b6336d8c28e205fa0d5d426f6488998d0/dynaphopy/interface/iofile/trajectory_parsers.py#L424

https://github.com/abelcarreras/DynaPhoPy/blob/5074b04b6336d8c28e205fa0d5d426f6488998d0/dynaphopy/interface/iofile/trajectory_parsers.py#L469

I did some tests with different NBLOCK and it seems to work fine for me. The number that is displayed in Time step is:

timestep times NBLOCK (therefore the timestep per block).

I think the problem occurs because you concatenated several XDATCAR files without changing the step numbers. Dynaphopy relays in those numbers to be sequential.

gabkrenzer commented 3 years ago

Hi Abel,

Thank for your quick reply. I will look into the concatenation and will let you know!

Gabriel

gabkrenzer commented 3 years ago

Hi Abel,

I have looked into this a bit more and you were right, the steps numbers in my concatenated XDATCAR were not sequential. I wrote a little code using the Xdatcar class of pymatgen to do the concatenation, however, even though the step numbers are now sequential, they are written in steps of 1, instead of steps of 50 as my original NBLOCK was set. There is no option in pymatgen to play with the step number, so I wondered whether DynaPhoPy would recognise it, and still work the same if I feed it my new file and the timestep per block, so -ts 0.002*50, as you mentioned the timestep that DynaPhoPy reads from a file is timestep times NBLOCK.

Gabriel

abelcarreras commented 3 years ago

Hi Gabriel,

Yes, I think that if you multiply your timestep by NBLOCK it will work just fine.

gabkrenzer commented 3 years ago

Hi Abel,

Great, that's all sorted then! Thank you so much for your help!

Gabriel

abelcarreras commented 3 years ago

No problem! I will close this issue then.