# How to print the residual and tangent matrix? [closed]

Is there any command in AceGen to print the residual and tangent matrix in a simple and robust way?

EDIT 2: It would be best to have the whole stiffness matrix and residual vector of the problem in AceFEM, not just from the particular integration point (see "EDIT") or element. Is there a way to print it?

EDIT: Judging on the comments, I think I was not precise enough in my question. The point is to easily generate the output of the residual vector and tangent matrix of the FINITE ELEMENT code generated in AceGen, while running the AceFEM simulation. So I wonder if there are some experienced AceGen/AceFEM users who know a single command to do it. Currently, for the purpose of debugging, I am "printing" (SMSPrint) both the residual vector and tangent (or stifness) matrix element by element.

Here's how I'm doing it now:

(* Tangent and residual *)
SMSDo[i, 1, SMSNoDOFGlobal];
dLagr \[DoubleRightTee] Jd wGauss SMSD[Lagr, at, i];
SMSIf[IpIndex == 1];
SMSPrint["R[[" <> ToString[i] <> "]] = ", dLagr];
SMSEndIf[];
SMSExport[dLagr, p$$[i], "AddIn" -> True]; SMSDo[j, i, SMSNoDOFGlobal]; ddLagr \[DoubleRightTee] SMSD[dLagr, at, j]; SMSIf[IpIndex == 1]; SMSPrint["K[[" <> ToString[i] <> "," <> ToString[j] <> "]] = ", ddLagr]; SMSEndIf[]; SMSExport[ddLagr, s$$[i, j], "AddIn" -> True];
SMSEndDo[];
SMSEndDo[];


The addditional problem lies in the fact that I don't get as an output something like: K[[i,j]] = 123.45, but rather K[[$V[312, 1],$V[326, 1]]] = 123.45.

• Who or what are residual and tangent matrix? – Henrik Schumacher Aug 5 '19 at 15:00
• The following change gives the particular values of i and j in the output instead of their name in the code: (* Tangent and residual *) SMSDo[i, 1, SMSNoDOFGlobal]; dLagr \[DoubleRightTee] Jd wGauss SMSD[Lagr, at, i]; SMSIf[IpIndex == 1]; SMSPrint["R[[", i, "]] = ", dLagr]; SMSEndIf[]; SMSExport[dLagr, p$$[i], "AddIn" -> True]; SMSDo[j, i, SMSNoDOFGlobal]; ddLagr \[DoubleRightTee] SMSD[dLagr, at, j]; SMSIf[IpIndex == 1]; SMSPrint["K[[", i, j, "]] = ", ddLagr]; SMSEndIf[]; SMSExport[ddLagr, s$$[i, j], "AddIn" -> True]; SMSEndDo[]; SMSEndDo[]; – Karol Frydrych Aug 6 '19 at 5:47

## 1 Answer

The solution in AceFEM is quick and simple. In order to get residual vector one should type:

SMTData["Residual"]


and the tangent matrix is available after typing:

SMTData["TangentMatrix"]