I want to implement a model where the interactions are Lennard-Jones, but the Lennard-Jones length parameter, sigma, is different for
every particle and there is a non-standard mixing rule. If I go the easy way and list the pair coefficients for every interaction, then the memory usage is very large
and it does not parallelize well. I can design the potential such that sigma[i] is read for each particle i. However, when the program loops over the neighbors of particle i, the
i don't understand the part about not parallelizing well. when
defining each atom to have a different type, the per-type data is
communicated once and doesn't have to change.
memory consumption and memory access performance is an issue, as the
memory usage is O(n**2) in this case, but why does this affect
neighbor index j can be greater than the total number of particles. In that case, is there an easy way I can determine which particle j corresponds to in the index in the initial list of particles so I can determine which sigma to use for particle j?
there are different ways to approach this.
1) have a global storage for your sigma values, but index those values
by atom id, i.e. the value of atom->tag[i]. this way you reduce the
O(n**2) sized storage back to O(n) and after reading the data, e.g.
from a potential file, you just need to do one big broadcast during
pair->init_style(). for this you don't need to worry about atom
indices of ghost atoms, since your don't look at those at all.
2) you can store sigma as per-atom properties and assign them to local
atoms. then they have to migrate with their "host" atoms. this can be
done from within the pair style, but probably the easiest approach
would be to use fix property/atom. this will require the least amount
of per-processor memory and using the fix has the benefit of having
built-in support for reading/storing the properties from/to data
files. fix property/atom has an option to signal whether a property
needs to be communicated to ghost atoms, so that is taken care of as
well without extra programming effort.
3) you can write a custom atom style, or use one that is similar to
what you need, e.g. atom style sphere. if you have per-atom sigma's,
you'd also have to have per atom masses, right? atom style sphere
offers both. the mass part only affects the integrator, so this
doesn't affect your custom pair styles. in your custom lennard jones
pair style you would simply use atom->radius[i] instead of sigma.
there are probably more, but this is what came to me right away.
unless there is something else in your setup, that you haven't
mentioned, i'd probably try out option 3) first, as this would require
the least changes and the least knowledge of LAMMPS internals.