NPT simulation

How to do an NPT simulation but allow the temperature to change along the x-axis?

We’re going to need a lot more detail if you want useful feedback.

Do you mean that you want to apply a temperature gradient?

For a stress-strain analysis, the temperature of the entire system shall be kept constant during a simulation. However, I must achieve this without scaling temperature along the strain axis. Essentially the whole system has to be at a constant temperature, but it has to be performed by not affecting properties, say velocity along the strain axis. Is there any LAMMPS command to execute this?

The simplest way would be to thermalise only the degrees of freedom in the direction normal to the strain axis. It can be done by combining compute temp/partial with fix_modify.

That is a debatable requirement. Whether this is needed or not strongly depends on the speed with which the deformation for your straining would be done. Only at infinitesimally small deformation (which is unattainable in MD simulations) there would be no excess kinetic energy transferred to or from the system due to the straining.

That also makes very little sense to me. If there is thermal coupling to transfer kinetic energy, then this is non-directional and thus having thermostatting only applied in the selected directions would not be a realistic model.

In general, the thermostatting due to a Nose-Hoover thermostat like in fix nvt or fix npt should be a rather weak coupling that ensures that a small sample with periodic boundaries experiences a similar sampling of a the statistical mechanical ensemble that it is in than a larger, bulk sample.

The main item you should worry about, however, is the barostat. You must not couple the barostat to the direction of the straining. LAMMPS usually will print a warning in case your do that.