\begin{Verbatim}[commandchars=\\\{\}]
    \PY{k}{def} \PY{n+nf}{SecondPiolaKirchhoffStress}\PY{p}{(}\PY{n+nb+bp}{self}\PY{p}{,} \PY{n}{u}\PY{p}{)}\PY{p}{:}
        \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{\PYZus{}construct\PYZus{}local\PYZus{}kinematics}\PY{p}{(}\PY{n}{u}\PY{p}{)}
        \PY{n}{psi} \PY{o}{=} \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{strain\PYZus{}energy}\PY{p}{(}\PY{n}{MaterialModel}\PY{o}{.}\PY{n}{\PYZus{}parameters\PYZus{}as\PYZus{}functions}\PY{p}{(}\PY{n+nb+bp}{self}\PY{p}{,} \PY{n}{u}\PY{p}{)}\PY{p}{)}

        \PY{k}{if} \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{kinematic\PYZus{}measure} \PY{o}{==} \PY{l+s}{"}\PY{l+s}{InfinitesimalStrain}\PY{l+s}{"}\PY{p}{:}
            \PY{n}{epsilon} \PY{o}{=} \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{epsilon}
            \PY{n}{S} \PY{o}{=} \PY{n}{diff}\PY{p}{(}\PY{n}{psi}\PY{p}{,} \PY{n}{epsilon}\PY{p}{)}
        \PY{k}{elif} \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{kinematic\PYZus{}measure} \PY{o}{==} \PY{l+s}{"}\PY{l+s}{RightCauchyGreen}\PY{l+s}{"}\PY{p}{:}
            \PY{n}{C} \PY{o}{=} \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{C}
            \PY{n}{S} \PY{o}{=} \PY{l+m+mi}{2}\PY{o}{*}\PY{n}{diff}\PY{p}{(}\PY{n}{psi}\PY{p}{,} \PY{n}{C}\PY{p}{)}            
        \PY{k}{elif} \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{kinematic\PYZus{}measure} \PY{o}{==}  \PY{l+s}{"}\PY{l+s}{GreenLagrangeStrain}\PY{l+s}{"}\PY{p}{:}
            \PY{n}{E} \PY{o}{=} \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{E}
            \PY{n}{S} \PY{o}{=} \PY{n}{diff}\PY{p}{(}\PY{n}{psi}\PY{p}{,} \PY{n}{E}\PY{p}{)}
        \PY{k}{elif} \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{kinematic\PYZus{}measure} \PY{o}{==} \PY{l+s}{"}\PY{l+s}{CauchyGreenInvariants}\PY{l+s}{"}\PY{p}{:}
            \PY{n}{I} \PY{o}{=} \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{I}\PY{p}{;} \PY{n}{C} \PY{o}{=} \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{C}
            \PY{n}{I1} \PY{o}{=} \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{I1}\PY{p}{;} \PY{n}{I2} \PY{o}{=} \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{I2}\PY{p}{;} \PY{n}{I3} \PY{o}{=} \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{I3}
            \PY{n}{gamma1} \PY{o}{=} \PY{n}{diff}\PY{p}{(}\PY{n}{psi}\PY{p}{,} \PY{n}{I1}\PY{p}{)} \PY{o}{+} \PY{n}{I1}\PY{o}{*}\PY{n}{diff}\PY{p}{(}\PY{n}{psi}\PY{p}{,} \PY{n}{I2}\PY{p}{)}
            \PY{n}{gamma2} \PY{o}{=} \PY{o}{-}\PY{n}{diff}\PY{p}{(}\PY{n}{psi}\PY{p}{,} \PY{n}{I2}\PY{p}{)}
            \PY{n}{gamma3} \PY{o}{=} \PY{n}{I3}\PY{o}{*}\PY{n}{diff}\PY{p}{(}\PY{n}{psi}\PY{p}{,} \PY{n}{I3}\PY{p}{)}
            \PY{n}{S} \PY{o}{=} \PY{l+m+mi}{2}\PY{o}{*}\PY{p}{(}\PY{n}{gamma1}\PY{o}{*}\PY{n}{I} \PY{o}{+} \PY{n}{gamma2}\PY{o}{*}\PY{n}{C} \PY{o}{+} \PY{n}{gamma3}\PY{o}{*}\PY{n}{inv}\PY{p}{(}\PY{n}{C}\PY{p}{)}\PY{p}{)}
        \PY{k}{elif} \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{kinematic\PYZus{}measure} \PY{o}{==} \PY{l+s}{"}\PY{l+s}{IsochoricCauchyGreenInvariants}\PY{l+s}{"}\PY{p}{:}
            \PY{n}{I} \PY{o}{=} \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{I}\PY{p}{;} \PY{n}{Cbar} \PY{o}{=} \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{Cbar}
            \PY{n}{I1bar} \PY{o}{=} \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{I1bar}\PY{p}{;} \PY{n}{I2bar} \PY{o}{=} \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{I2bar}\PY{p}{;} \PY{n}{J} \PY{o}{=} \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{J}
            \PY{n}{gamma1bar} \PY{o}{=} \PY{n}{diff}\PY{p}{(}\PY{n}{psibar}\PY{p}{,} \PY{n}{I1bar}\PY{p}{)} \PY{o}{+} \PY{n}{I1bar}\PY{o}{*}\PY{n}{diff}\PY{p}{(}\PY{n}{psibar}\PY{p}{,} \PY{n}{I2bar}\PY{p}{)}
            \PY{n}{gamma2bar} \PY{o}{=} \PY{o}{-}\PY{n}{diff}\PY{p}{(}\PY{n}{psibar}\PY{p}{,} \PY{n}{I2bar}\PY{p}{)}
            \PY{n}{Sbar} \PY{o}{=} \PY{l+m+mi}{2}\PY{o}{*}\PY{p}{(}\PY{n}{gamma1bar}\PY{o}{*}\PY{n}{I} \PY{o}{+} \PY{n}{gamma2bar}\PY{o}{*}\PY{n}{C\PYZus{}bar}\PY{p}{)}
            ...
\end{Verbatim}
