def MccRhoiDeriv(self, u, v, adjoint=False): """ Derivative of :code:`MccRhoi` with respect to the model. """ if len(self.rho.shape) > 1: if self.rho.shape[1] > self.mesh.dim: raise NotImplementedError( "Full anisotropy is not implemented for MccRhoiDeriv." ) if self.storeInnerProduct: if adjoint: return self.MccRhoiDerivMat.T * (Utils.sdiag(u) * v) else: return Utils.sdiag(u) * (self.MccRhoiDerivMat * v) else: vol = self.mesh.vol rho = self.rho drho_dlogrho = Utils.sdiag(rho)*self.etaDeriv if adjoint: return drho_dlogrho.T * (Utils.sdia(u*vol*(-1./rho**2)) * v) else: return Utils.sdiag(u*vol*(-1./rho**2))*(drho_dlogrho * v)