It is wrong to calculate the charge per atom considering the volume below.
volume = right_electrode_lattice.unitCellVolume()
volume = float(volume/(0.01*Meter)**3)
doping = doping_density * volume / len(right_electrode_elements)
this is true for bulk systems where the atoms occupy the entire volume of the cell.
This is probably the reason you get "negative electrons" before.
Please, add the proper doping.
we probably need to add this to the tutorial