I would suggest using class structures.
Then you can have different functions applying appropriate boundary conditions.
Also keep in mind that the only thing that should differ in the core of your variational formulation is the mesh/function space, the UFL forms should be the same in 1D/2D/3D.
I would strongly suggest you try to simplify your problem to illustrate this issue.
If you won’t simplify it, you should really be careful about the integration by parts of your problem, making sure that you are not missing a sign in the transformations. Additionally, when you say the code seem to find some “zero” voltage by itself, you should look at the equation you are now solving.
Again, using classes, and boolean inputs to either:
Add terms to your variational form
Add a c=dolfinx.fem.Constant(mesh, value) to your variational form (i.e. F += c*joule_heating_terms), where value is 0 or 1 depending on if you want to add the effect or not.
I do not have time to go through your code in detail, but I would strongly suggest you to start small, and take out simple parts of your code that you can re-use, and make up a general structure as you go.