I have deformed a system with a crack. I want the stress(strain) contour/distribution of the system at a given timestep. I have attached a sample image similar to which I expect a contour.
You could get the stress contour by simply using a visualization tool capable of reading LAMMPS filed (OVITO, VMD etc.). On the other hand, if you want a smooth contour like in the image without atoms, I would suggest you import the data into MATLAB and the following steps:
a) Interpolate all the atomic stress on a fine 2D mesh.
b) use contourf (filled contour) on the 2D mesh to get the contour.
Firstly you should calculate stress in LAMMPS for example by using command.
compute peratom all stress/atom NULL
Then you can use different elements of this array to find values which characterize per-atom stress, for example:
variable stress_atom atom sqrt(c_peratom[1]*c_peratom[1]+c_peratom[2]*c_peratom[2]+c_peratom[3]*c_peratom[3])
After that you can dump this per-atom variable into dump file with atom id and coordinates.
dump 3 all custom 1000 dump.lammpstrj id type x y z v_stress_atom
So you will get the dump file, which contains a set of timesteps with coordinates and per-atom stress values of each atom.
To visualize dump files I often use VMD software. But unfortunately,as I know, it cannot color atoms by arbitrary parameter. So here we should apply a small trick.
When you have your dump file with per-atom stess values, just rename column v_stress_atom into vx. Then load it into VMD and choose coloring method "By velocity". After that VMD will color atoms with per-atom stress. See attachment. You may use this trick for visualization of strain also.
I think you can do it using the method proposed by Redkov or using Ovito software. In this software, I just need to choose the component, which correspond to evaluated stress output in Dump file, in "Color assigning" option.
The stress contour images provided in the initial question were for a continuous field for that you need to interpolate between atomic position to obtain the smooth contour field. The question should have described specifically which type of contour was desired. I guess these should solve the problem.