ulissigroup / vasp-interactive

GNU Lesser General Public License v2.1
53 stars 11 forks source link

socket mode get stucked without any vasp output #57

Open GengSS opened 1 month ago

GengSS commented 1 month ago

Hello,

I am trying to use the socket mode to run vaspinteractive calculator, Here is my input python script:

import sys
from ase.optimize import BFGS
from ase.io.trajectory import Trajectory
from ase.io import read,write
import os
from vasp_interactive import VaspInteractive
from ase.calculators.socketio import SocketIOCalculator

ncpus = os.environ['NUMBER_OF_CPUS']
parameters = dict(istart=0, icharg=2, encut=400, ispin=2, ediff=1.0e-5, nelm=120, nelmin=4, xc='pbe',
          kpts=(2,2,1), gamma=True, prec="N", algo="N",ismear=0, sigma=0.1,
          npar=8,lreal="Auto",lcharg=False,lwave=False,iwavpr=11, directory='calculator',
          ldau_luj={'Ti': {'L': 2, 'U': 4.5, 'J': 0}},
          command="mpirun -np {} vasp_std".format(ncpus))

atoms=read(sys.argv[1])
atoms.set_pbc(True)
job_id = os.environ['SLURM_JOB_ID']
vpi = VaspInteractive(**parameters)

with SocketIOCalculator(vpi, unixsocket='vasp_jobid_{}'.format(job_id)) as calc:
    atoms.set_calculator(calc)
    trajectory = Trajectory(traj, mode='a', atoms=atoms, master=True)
    dyn = BFGS(atoms, logfile=log, trajectory=trajectory)
    dyn.run(fmax=0.03)
    write("optimized.traj",atoms)

The job is not killed by the queue system, however, I don't see any output files generated by VASP (such as OUTCAR, OSZICAR etc). In the directory 'calculator', I can only find those files, ase-sort.dat INCAR KPOINTS POSCAR POTCAR socket-client.log and socket-client.log is empty.

Is there anything wrong with my input? BTW, I am using vasp6.3.2 without the patches,

Best, Geng

alchem0x2A commented 1 month ago

Hi @GengSS, your vasp-interactive calculator wasn't initialized as socket mode, there are additional keywords to enable the socket communication layer, see https://github.com/ulissigroup/vasp-interactive/blob/3e82db258b9c6fb47fdda8ee1c6171a71fba49f4/vasp_interactive/vasp_interactive.py#L107

Parameters for socket-I/O mode:
            `use_socket`: if True, attach a socket client to the calculator and self.run() method
                          will be available. Note you don't need to set use_socket when passing through
                          SocketIOCalculator
            `host`: hostname of the socket server running iPI protocol
            `port`: server port to connect to
            `unixsocket`: name of local unix socket
            `timeout`: socket I/O timeout
            `log`: logfile for the socket client. If None, write to stdout

You can try specifying unixsocket in your parameters dict to see if it could solve your issue.

In your case it seems normal usage of vasp-interactive would suffice, could you also give a try? If you have copied the parameters from ex16_socketio.py, I appologize for the confusion as there seems to be some missing parts, I'll fix the examples asap.

GengSS commented 1 week ago

Hi @alchem0x2A , Thank you for your reply, but I tried to add the 'unixsocket' parameter to VaspInteractive, but it did not work. I also tried to switch on the use_socket=True, but it still fails to run. Could you please show me an example that uses unixsocket mode? Thank you very much in advance. Best Wishes, Geng