mir-group / flare

An open-source Python package for creating fast and accurate interatomic potentials.
https://mir-group.github.io/flare
MIT License
295 stars 71 forks source link

Copy error with CP2K in on-the-fly training #406

Closed matr1x-1 closed 3 months ago

matr1x-1 commented 4 months ago

Hi,

I am using flare on-the-fly training with CP2K. As a test, we have tried to run the full.yaml simulation from the examples folder. With vasp it seems to work fine. With CP2K however, the training crashes almost immediately with the error: "TypeError: cannot pickle '_thread.lock' object" coming from line 582 in flare/learners/otf.py:

self.atoms.calc = deepcopy(self.dft_calc)

Do you know what the issue is here and is there maybe a fix?

Flare version: 1.4.0

Thanks a lot!

YuuuXie commented 3 months ago

Hi, maybe one solution could be instead of copying the entire pickle object, you can copy the DFT settings/parameters, and rebuild a new DFT calculator. But this needs a bit hack of the flare source code

matr1x-1 commented 3 months ago

That's right. This is the approach that worked in the end. However, it's of course not very elegant.

YuuuXie commented 3 months ago

Sounds great it works in the end. And sorry for the late reply. If you think the code change is going to be helpful, feel free to make a pull request and we can consider merging it into the main code base. I will close this issue for now.