AutoForce icon indicating copy to clipboard operation
AutoForce copied to clipboard

Issue when running examples/VASP-command-line

Open hezhengda opened this issue 1 year ago • 2 comments
trafficstars

Dear developer,

I got the following issue when running the example examples/VASP-command-line:

RuntimeError: SocketCalculator failed! Check if the ab initio calculator works properly.

In the beginning the socket seems to be successfully established:

killing process 14824 occupying port 6666                                                                                                                                  
killed!

I tried to diagonse the error, so I commented out the "RuntimeError" part in theforce/calculator/socketcalc.py. The following is what i did:

     if ierr != 0:
             if self.rank == 0:
                 pass
                 #raise RuntimeError(
                 #    "SocketCalculator failed! "
                 #    "Check if the ab initio calculator "
                 #    "works properly."
                 #)
             else:
                 sys.exit()

After running the example again, I got the following error message:

File "/Users/zhengdahe/Documents/hzd_codes/autoforce/lib/python3.11/site-packages/theforce/calculator/socketcalc.py", line 84, in calculate
    atms = read("socket_recv.xyz")
           ^^^^^^^^^^^^^^^^^^^^^^^

The content of socket_recv.xyz is:

08/15/2024 21:59:21 reserved

While the content of socket_send.xyz is:

5
Lattice="13.258236 0.0 0.0 0.0 13.258236 0.0 0.0 0.0 13.258236" Properties=species:S:1:pos:R:3:momenta:R:3 pbc="T T T"
C        6.64219252       6.68989051       6.61079160       0.00000000       0.00000000       0.00000000
H        7.23599028       7.24111697       7.21050003       0.00000000       0.00000000       0.00000000
H        6.05430158       5.98585612       7.21643585       0.00000000       0.00000000       0.00000000
H        7.25800823       5.96245619       6.06466014       0.00000000       0.00000000       0.00000000
H        6.01894252       7.21377994       5.96386958       0.00000000       0.00000000       0.00000000

I suspect there is a socket issue in my code. But I couldn't figure out what happens here. Could you help me?

hezhengda avatar Aug 16 '24 02:08 hezhengda

Hi @hezhengda,

This issue could be related to VASP itself. First, can you make sure that using VASP directly works? For example, if you directly run the command inside the [COMMAND](https://github.com/amirhajibabaei/AutoForce/blob/main/examples/VASP-command-line/COMMAND) file?

I also recommend checking the example [examples/server](https://github.com/amirhajibabaei/AutoForce/tree/main/examples/server), which is prepared for simple test of the setup, using single point calculations.

For further explanation, the ML process writes atomic configuration to socket_send.xyz, then sends a signal to the calc_server process and waits for a signal back. The calc_server runs the dft code, VASP in this case, and writes the results in socket_recv.xyz, then sends a signal back to the ML process. Thus, in this case, because of the reserved message in socket_recv.xyz, it appears that the calc_server has successfully received the positions but the DFT calculation has either failed or isn't finished.

Let us know, if the issue remains unresolved after these trials.

amirhajibabaei avatar Aug 16 '24 13:08 amirhajibabaei

Dear Dr. Amir,

Thanks so much for your detailed response. With your help, I have solved the problem. The issue is not VASP itself since I can run VASP on my laptop by using the command in COMMAND file.

The error comes from the incomplete setup of the ASE package. We need to add VASP_PP_PATH to the environmental variable (in ~/.bashrc) in order to let ASE find the pseudopotentials. VASP_PP_PATH represents the location of pseudopotential so that the POTCAR can be found in $VASP_PP_PATH/potpaw_PBE/Na/POTCAR.

Also I have to update the Vasp function in calc.py file under example server in order to make it run successfully. Could it be related with the updated version of ASE (my version is 3.23.0)? Somehow I always encountered error by using the initial settings.

# here's my version
calc = Vasp(
    command="mpirun -n 6 vasp_std",
    directory="vasp",
    prec="Accurate",
    xc="PBE",
    lreal=False,
    ispin=2,
    lorbit=11
)

Another issue is related ASE when reading the VASP results. If "assertion error" exists related with property nbands, just add all_properties.append('nbands') in ase/calculators/singlepoint.py around line 25. It can be extended to other kinds of properties.

hezhengda avatar Aug 16 '24 16:08 hezhengda

Thanks @hezhengda, I'll try to check things are working with the updated versions of the dependencies. We haven't tested dependency updates for a long while now:)

amirhajibabaei avatar Aug 19 '24 10:08 amirhajibabaei