Is it possible to apply a static electrostatic field from a matrix in an external file?

Good morning,

Would it be possible for LAMMPS to read a 3D matrix from an external file, containing a map of forces due to an external static electrostatic field, and apply them to all the atoms in the system?

The goal would be to reproduce a large and charged porous matrix for confinement in a computationally efficient way: Instead of calculating all the forces due to each pair of atoms of the POROUS NETWORK and the ADSORBATE (about 2million atoms in the pore or 0.1 million if I coarse-grain it), the whole effect of the pore over the adsorbate will be stored in the matrix.

After an extensive search I didn´t find anything like this in the manual, but I may be missing something or not using the proper terms in the search…

Also, if this issue is not implemented in LAMMPS and some modification needs to be done, what I am planning is:
go through the fix ADDFORCE command and add some code to read the force from the external file. But I need to know the coordinates of each atoms to know which cell of the matrix I need to select. Does this seem plausible to you? Has anybody done this before or has a better idea?

Thanks a lot for your time and help!
Cecilia Bores

Good morning,

Would it be possible for LAMMPS to read a 3D matrix from an external file, containing a map of forces due to an external static electrostatic field, and apply them to all the atoms in the system?

i think that would require some C++ (or python?) programming.

The goal would be to reproduce a large and charged porous matrix for confinement in a computationally efficient way: Instead of calculating all the forces due to each pair of atoms of the POROUS NETWORK and the ADSORBATE (about 2million atoms in the pore or 0.1 million if I coarse-grain it), the whole effect of the pore over the adsorbate will be stored in the matrix.

After an extensive search I didn´t find anything like this in the manual, but I may be missing something or not using the proper terms in the search…

Also, if this issue is not implemented in LAMMPS and some modification needs to be done, what I am planning is:
go through the fix ADDFORCE command and add some code to read the force from the external file. But I need to know the coordinates of each atoms to know which cell of the matrix I need to select. Does this seem plausible to you? Has anybody done this before or has a better idea?

the main concern would be the amount of RAM required to store the information. if you can fit the entire matrix on every process, then things would be rather straightforward. inside the fix code, you would just do a loop over all local(!) atoms, compute the force due to their position and apply it. the matrix data you would just read on rank 0 and broadcast everywhere. if you need some inspiration, you might want to look at fix ttm/mod, which allows to read some 3d-gridded data. fix ttm and ttm/mod handle interactions of atoms with a continuum representation of electrons to model coupling between the two subsystems. while this is not exactly what you are looking for, it may have some solutions to problems that you might encounter for your project.

when you need to distribute the matrix data across processors, you might find some inspiration in the pppm.cpp code, where it has to apply forces from a grid due to the charge density.

HTH,
axel.