\begin{Verbatim}[commandchars=\\\{\}]
\PY{c}{# Get the problem mesh}
\PY{n}{mesh} \PY{o}{=} \PY{n}{problem}\PY{o}{.}\PY{n}{mesh}\PY{p}{(}\PY{p}{)}

\PY{c}{# Define the function space}
\PY{n}{vector} \PY{o}{=} \PY{n}{VectorFunctionSpace}\PY{p}{(}\PY{n}{mesh}\PY{p}{,} \PY{l+s}{"}\PY{l+s}{CG}\PY{l+s}{"}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{)}

\PY{c}{# Test and trial functions}
\PY{n}{v} \PY{o}{=} \PY{n}{TestFunction}\PY{p}{(}\PY{n}{vector}\PY{p}{)}
\PY{n}{u} \PY{o}{=} \PY{n}{Function}\PY{p}{(}\PY{n}{vector}\PY{p}{)}
\PY{n}{du} \PY{o}{=} \PY{n}{TrialFunction}\PY{p}{(}\PY{n}{vector}\PY{p}{)}

\PY{c}{# Get forces and boundary conditions}
\PY{n}{B} \PY{o}{=} \PY{n}{problem}\PY{o}{.}\PY{n}{body\PYZus{}force}\PY{p}{(}\PY{p}{)}
\PY{n}{PN} \PY{o}{=} \PY{n}{problem}\PY{o}{.}\PY{n}{surface\PYZus{}traction}\PY{p}{(}\PY{p}{)}
\PY{n}{bcu} \PY{o}{=} \PY{n}{problem}\PY{o}{.}\PY{n}{boundary\PYZus{}conditions}\PY{p}{(}\PY{p}{)}

\PY{c}{# First Piola-Kirchhoff stress tensor based on the material}
\PY{c}{# model}
\PY{n}{P} \PY{o}{=} \PY{n}{problem}\PY{o}{.}\PY{n}{first\PYZus{}pk\PYZus{}stress}\PY{p}{(}\PY{n}{u}\PY{p}{)}

\PY{c}{# The variational form corresponding to static hyperelasticity}
\PY{n}{L} \PY{o}{=} \PY{n}{inner}\PY{p}{(}\PY{n}{P}\PY{p}{,} \PY{n}{Grad}\PY{p}{(}\PY{n}{v}\PY{p}{)}\PY{p}{)}\PY{o}{*}\PY{n}{dx} \PY{o}{-} \PY{n}{inner}\PY{p}{(}\PY{n}{B}\PY{p}{,} \PY{n}{v}\PY{p}{)}\PY{o}{*}\PY{n}{dx} \PY{o}{-} \PY{n}{inner}\PY{p}{(}\PY{n}{PN}\PY{p}{,} \PY{n}{v}\PY{p}{)}\PY{o}{*}\PY{n}{ds}
\PY{n}{a} \PY{o}{=} \PY{n}{derivative}\PY{p}{(}\PY{n}{L}\PY{p}{,} \PY{n}{u}\PY{p}{,} \PY{n}{du}\PY{p}{)}

\PY{c}{# Setup and solve problem}
\PY{n}{equation} \PY{o}{=} \PY{n}{VariationalProblem}\PY{p}{(}\PY{n}{a}\PY{p}{,} \PY{n}{L}\PY{p}{,} \PY{n}{bcu}\PY{p}{,} \PY{n}{nonlinear} \PY{o}{=} \PY{n+nb+bp}{True}\PY{p}{)}
\PY{n}{equation}\PY{o}{.}\PY{n}{solve}\PY{p}{(}\PY{n}{u}\PY{p}{)}
\end{Verbatim}
