Loading - Unloading for elasto plactic material

Hello everybody,

Right now, I am trying to modify the code of this tutorial. I think the code is written very well and step by step I am understanding the idea of fenics.

Now I wanted to try to modify the code such that I can simulate loading and unloading procedure. My idea was to rewrite the loading steps by:

Nincr_l = 20
Nincr_u = 20
Nincr = Nincr_l + Nincr_u

load_steps = np.linspace(0, 1.1, num=Nincr_l+1)[1:]**0.5
unload_steps = 0.5*np.linspace(0, 1.1, num=Nincr_u+1)[1:]**0.5

all_loading_steps = np.concatenate((load_steps, unload_steps[::-1]))

With that I wanted to simulate that the loading goes up by q_lim * load_steps[:] and then
falls of by 1/2 * q_lim * unload_steps[:].

The Problem I got is that my residuum is exploding when it comes to the unload_steps. Therefore Newton-Raphson is not converging here. Does anybody has an idea what my mistake is?

Try to decrease the steps automaticly before residuum exploid.

if niter > 15
step=step*0.5