Setting dirichlet boundary condition for 1d mesh element

Hi, I am trying to impement a 1d element mesh on a timoshenko nonlinear beam. I am struggling to apply the dirichlet boundary condition here. The function space is mixed type, which should have displacement and rotational degrees of freedoms. rotational values are expressed as querternions. It is a cantilever beam, so it should be fixed on the left end. I would appreciate if someone guides me here on how can I implement the dirichlet boundary condition properly. I wrote the code upto following part.

FB: removed uncorrectly formatted code.

Please edit and format the code properly using “```”.