What is unclear to me what you can extract from the [1] component of a cross-product of a 2D vector. It would at most be the third component of the cross product that would be interesting, ref: https://www.quora.com/Can-you-cross-product-2D-vectors.
What I would assume, is that you can implement the 2D cross product yourself:
def cross_2D(x, y):
return x[0] * y[1] - x[1] * y[0]
sgn = sigma(u) * n
ufl_vec = ufl.as_vector([x_pos, 3.9])
My = fem.assemble_scalar(fem.form(cross_2D(ufl_vec, sigma(u) * n) * ds(ds_section)))
However, your code is rather long, and doesn’t get straight to the point, which is:
How to compute a cross product of 2D vectors with ufl.