[lammps-users] Question about the structure factor

Dear LAMMPS users,

I am wondering whether LAMMPS can calculate the structure factor for the simulated system. The structure factor I mean indicates the crystallization of the system, specially when the system transit from liquids to solids. So the structure factor can give us a kind of translational order parameter.

I am not sure which quantity in LAMMPS can show this change or something has the similar function in LAMMPS can be calculated.

Your kind help would be most appreciated.


Dear Yajie,

If your system is simple enough, you can calculate the radial distribution function using fix rdf and transform that to get the static structure factor.

Otherwise, you can dump the positions of all the atoms and post-process to get the static structure factor.



I’ve actually had good success getting structure factors by doing Fourier transforms of the radial distribution functions. You have to pay attention to some issues like truncation; in a small system, it can be difficult to keep artifacts out of the structure factor, especially at small q. But I don’t think it’s all that dangerous. There’s a recent paper (Troitzsch et al., JPCB 111,8210) that does think it’s dangerous, and gives an outline of how to calculate the structure factor directly, using something like an Ewald sum to deal with small q structure due to the periodic replicas. But their own data shows that if you’re careful, you can get good structure factors from the Fourier transform of the RDF valid down to q=2 A^-1 or so.

Hope this helps,

My recollection is you can compute some structure factors without an FFT,
but maybe that assumes some known ordering of the lattice. Kind of
like the centro-symmetry parameter that LAMMPS does have (see compute


Thank you very much, Steve. That really makes some sense.

Another question related to the structure analysis is whether LAMMPS can output the density distribution directly?


Hi Yajie Lei,

I implemented an order parameter (structure factor) in my previous work to study solid-to-liquid phase transitions using lammps (see link below). I used a post processing step to calculate it based on the atom positions, so the post processing was on files several GBs in size.



if you mean g(r) then look at fix rdf


Not radial distribution function.

I mean the mass density distribution of the simulated system, or equivalently say, the distribution of number of particles in the configuration. I know it’s doable in terms of the time average of the trajectory, similar to the g®. So I am wondering whether LAMMPS has any command or tool to output that directly.

Most appreciate.


You can get a 1d density distribution thru the fix ave/spatial command.
If you want 2d or 3d you'd have to write it yourself.