I've seen and used something similar in my ellipsoids, where the domain width (DW) is used to calculate the shortest distance between two points due to periodic boundary condition.  So if you do not have a periodic box then that line (involving DW) should be changed.  This is part of the reason why my ellipsoid container is limited to periodic box only.<div>
<br></div><div>I'm hoping to put in a flag to turn it off and on later, but if a flag is put in to turn it off maybe I'll imitate it for the ellipsoids, too.</div><div><br></div><div>From</div><div>G.S.<br><br><div class="gmail_quote">
On Fri, Dec 21, 2012 at 4:18 PM, Nathan Goldbaum <span dir="ltr"><<a href="mailto:nathan12343@gmail.com" target="_blank">nathan12343@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<br>
<br>
I encountered a bit of odd code deep in the field definition code and I need some help to understand why it is the way it is.<br>
<br>
The field I'm curious about is the Radius field (defined on line 796 of universal_fields.py):<br>
<br>
def _Radius(field, data):<br>
    center = data.get_field_parameter("<u></u>center")<br>
    DW = data.pf.domain_right_edge - data.pf.domain_left_edge<br>
    radius = np.zeros(data["x"].shape, dtype='float64')<br>
    for i, ax in enumerate('xyz'):<br>
        r = np.abs(data[ax] - center[i])<br>
        radius += np.minimum(r, np.abs(DW[i]-r))**2.0<br>
    np.sqrt(radius, radius)<br>
    return radius<br>
<br>
In particular, I don't understand this line:<br>
<br>
radius += np.minimum(r, np.abs(DW[i]-r))**2.0<br>
<br>
Is this supposed to correct for some effect in periodic simulations?<br>
<br>
The reason I bring this up is because it caused some very weird behavior in a 1D FLASH simulation.  In this simulation, the domain went from x = -.01 pc to x = +500 pc.  Since the middle of the domain wasn't lined up with the 'center' of the simulation at x = 0, the offending line in the radius calculation led to an incorrect calculation of the radius beyond x = 250 pc.  In that case, I was able to fix it by changing the offending line to<br>

<br>
radius += r**2.0<br>
<br>
Before I issue a patch, I want to see why it's defined the way it is currently and see if we can come up with a workaround.<br>
<br>
Cheers,<br>
<br>
Nathan<br>
______________________________<u></u>_________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/<u></u>listinfo.cgi/yt-users-<u></u>spacepope.org</a><br>
</blockquote></div><br></div>