I've trouble implementing in Matlab this model that describes the switching of a ferroelectric thin film.
I've to find the evolution of $P=f(x,y,t)$ in time on a 2-D mesh given the following equations:
$u = \alpha P^2 + \beta P^4 + \gamma P^6 -EP +k \|\nabla P\|^2$
$-\frac{\partial u}{\partial P}=\rho \frac{\partial P}{\partial t}$
$\alpha,\beta,\gamma,\rho$ are known and they depend on the position. $E=g(x,y,t)$. $P=f(x,y,t=0)$ and $E=g(x,y,t=0)$ are known. I wanted to solve the second equation with forward Euler but then I got stuck in dealing with $k\|\nabla P\|^2$. I can approximate the gradient with finite differences but then I don't know how to manage its derivative with respect to $P$ that appears in the second equation.
Thanks!