Dear Steve and Axel,
Please find attached the fix_client_gcmc.cpp, fix_client_gcmc.h, message_w_gcmc.cpp files that I have created. I added these files to the src/MESSAGE directory, and tried to build LAMMPS again to include this new fix, but it threw an error. I briefly list my edits below:
-
From LAMMPS documentation and the fix_gcmc.cpp file, I saw that it has a energy_full() method that calculates the energy of the configuration using fix_nvt. Since we want to use VASP, I edited this function to do so. I essentially copied the post_force() method from the fix_client_md.cpp file into this method, which sends the coordinates to VASP, and receives the energy.
-
I also copied other functions, variables and enumerators from fix_client_md.cpp which I understand are necessary for LAMMPS to communicate coordinates with VASP and receive energy, namely-
a. Copied the error checks and variables defined in the FixClientMD() constructor into the FixGCMC() constructor
b. Copied memory->destroy(xpbc) from the FixClientMD() destructor into the FixGCMC() destructor
c. Copied commands from init() in fix_client_md.cpp into init() of fix_gcmc.cpp
d. Commented out the lines that calculate force and energy in energy_full() since VASP does this for us (lines 2333-2354 and 2362 in fix_gcmc.cpp)
e. Copied setup(), compute_scalar(), pack_coords(), pack_box(), receive_fev() from fix_client_md.cpp into fix_gcmc.cpp
f. Edited receive_fev() to return energy (in fix_client_md.cpp, it does not return anything) as the energy needs to be returned so that LAMMPS GCMC can decide whether to accept or reject the trial move.
g. I made all these changes in the file fix_client_gcmc.cpp (so I did not alter fix_gcmc.cpp directly). Everything else is mostly the same from fix_gcmc.cpp.
h. I also edited message.cpp to validate gcmc as a supported protocol (new file- message_w_gcmc.cpp).
In the attached files, I have commented my edits with ‘// begin edit’ and ‘// end of edit’ to make the edits easier to find since the number of lines of code is quite long.
When I tried building LAMMPS again with these new files, the error I get is-
…/fix_client_gcmc.cpp(2452): error #547: nonstandard form for taking the address of a member function
energy = receive_fev(vflag);
…/fix_client_gcmc.cpp(2452): error: expression must be a modifiable lvalue
energy = receive_fev(vflag);
…/fix_client_gcmc.cpp(2460): error #547: nonstandard form for taking the address of a member function
return energy;
…/fix_client_gcmc.cpp(2460): error: return value type does not match the function type
return energy;
…/fix_client_gcmc.cpp(2754): error #547: nonstandard form for taking the address of a member function
energy = receive_fev(vflag);
…/fix_client_gcmc.cpp(2754): error: expression must be a modifiable lvalue
energy = receive_fev(vflag);
…/fix_client_gcmc.cpp(2863): error: operand of “*” must be a pointer
return *eng;
So my questions are –
-
Could you please tell me what this error is caused by? I think it is because I define “double FixClientGCMC::receive_fev(int vflag)” to return *eng. I thought eng=econvert * cs->unpack_double(ENERGY) returns a pointer to the energy value and not the energy value itself, so I return *eng. But it seems like eng is not a pointer.
-
Could you please tell me if the rest of the edits I have made are generally correct or flag any major errors in my understanding?
Thank you so much for your help ! Any insight is greatly appreciated !
Regards,
Vrindaa
fix_client_gcmc.cpp (90.4 KB)
fix_client_gcmc.h (10.2 KB)
message_w_gcmc.cpp (3.54 KB)