Thanks Joe for the comment.
Actually that was just a stupid choice of sub-region that I left at the end of my testing.

The same problem is present if instead of the condition
        if abs(x) < r1 and abs(y) < r1:
one uses
        if abs(x) < 2 and abs(y) < 2:

or any similar small region entirely included in the ring.
Sorry for the useless extra-mistake that has misled already some people.

Best,
Diego


On 24/3/14 11:47 PM, Joseph Weston wrote:
Hi,

Seems to me that in your onsite function::

    def mu(site, p):
        (x, y) = site.pos
        if abs(x) < r1 and abs(y) < r1:
            return p.mu_inside   # this is the critical line: changing mu values inside the ring should not change the ring conductance
        else:
            return p.mu_ring

the condition ``abs(x) < r1 and abs(y) < r1`` actually describes a *square* centred on (0, 0) with sides of length ``2 * r1``, and **not**
a circle centred on (0, 0) with radius ``r1``. There are thus some sites at the corners which are included in this square, the onsites
of which are affected when you change the value of ``mu_inside``. Changing the onsite function to the following should fix your problem::

    def mu(site, p):
        (x, y) = site.pos
        if x**2 + y**2 < r1**2:
            return p.mu_inside   # this is the critical line: changing mu values inside the ring should not change the ring conductance
        else:
            return p.mu_ring

Regards,

Joe


P.S. I have not tested the above code. You may need to change your shape function to::

    def ring(pos):
        (x, y) = pos
        rsq = x ** 2 + y ** 2
        return (r1 ** 2 <= rsq < r2 ** 2)   # changed `<` to `<=`

to avoid some possible annoying edge case