Select atoms based on maximum applied stress, then change atom type

Hi, I am pretty new to LAMMPS here and am starting to set a few simulations.
I am running a granular simulation with 3 different atom types. I have a compute going on,

compute 1 all stress/atom NULL

which as I understand gives the 6 components of the Cauchy stress tensor. I would then like to take the maximum principal stress (eigenvalue of the matrix containing these components) and change the atom type based on a condition, max principal stress (on atom) > some value.
I originally though I could use compute reduce, but it seems this does not return a per-atom value. My question is, is there some way to obtain the maximum principal stress (per atom) and add this as a per atom variable? If there’s a way to define a variable from the eigenvalues of input vector components, I’m not sure (syntactically) how that can be done in LAMMPS after flipping through the documentation.

Thanks in advance for taking the time to read my question.

LAMMPS does not have any of the functionality that you ask for. What you describe sounds like something that requires writing a new fix style command.

Please also note that per-atom stress is a property that is only really indicative of local stress when using averaging over space and time.