<div dir="ltr">I figured out the problem, Matt. It was due to the fact that I was setting the sphere radius equal to the surface radius -- the trilinear interpolation was impacted by this. When I simply increased the sphere radius to a value larger than the surface radius, the flux calculation worked perfectly. <div>
<br></div><div>I noticed this when I used the code below to plot the generated surface and saw that there were large regions that were empty. The flux was not being computed in these regions and, as a result, the total flux was lower than what I had expected. <br>
</div><div><div><br></div><div>****code to generate a plot of the generated surface************************************</div><div><div>colors = apply_colormap(np.log10(surf["Temperature"]), cmap_name="hot")</div>
<div>#cmap_name="jet", "algae", "hot", "gist_stern", "RdBu","kamae"</div><div><br></div><div>fig = plt.figure(figsize=(10, 10), dpi=150)</div><div>ax = fig.gca(projection='3d')</div>
<div>p3dc = Poly3DCollection(surf.triangles, linewidth=0.0)</div><div>p3dc.set_facecolors(colors[0,:,:]/255.)</div><div>ax.add_collection(p3dc)</div><div>ax.auto_scale_xyz(surf.vertices[0,:], surf.vertices[1,:], surf.vertices[2,:])</div>
<div>ax.set_aspect(1.0)</div><div>plt.savefig("%s_Surface.png" % pf)</div></div></div><div><br></div><div><br></div><div>Also, I realized what you meant by the surface area of a sphere! ;)</div><div class="gmail_extra">
<br clear="all"><div><div dir="ltr"><div><font face="georgia, serif">Regards,</font></div><font face="georgia, serif">Melinda Soares-Furtado</font><div><br></div></div></div>
<br><br><div class="gmail_quote">On Wed, Jul 30, 2014 at 2:59 PM, Matthew Turk <span dir="ltr"><<a href="mailto:matthewturk@gmail.com" target="_blank">matthewturk@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 Melinda,<br>
<br>
(As a quick note, we have test coverage for a few cases like this, but<br>
non-spherical.  The rest of my email assumes that the flux calculation<br>
is working as desired, but I can also attempt to set up a simple<br>
problem to demonstrate this from first principles, which I will put on<br>
my todo list.)<br>
<br>
I can think of a few things that might be going on.  The first is that<br>
the flux is typically computed using tri-linear interpolation, as well<br>
as a dot product.  This will interpolate to the barycenter of the<br>
triangles found through the marching cubes algorithm the velocity and<br>
density.  Increasing the refinement will increase this value, but<br>
we're still both approximating the sphere surface as a set of<br>
triangles, as well as taking the interpolated velocities and<br>
multiplying them by the area.  So the weak points:<br>
<br>
 * Interpolation<br>
 * Dot product of interpolated values<br>
 * Approximating surface<br>
<br>
One possible thing to try would be to examine the flux of "ones"<br>
across the surface, where the fluxing field is defined radially<br>
outward.  This would then give the total surface area.  So, we'd<br>
create three new derived fields:<br>
<br>
@derived_field(name="rad_x_vec")<br>
def rad_x_vec(field, data):<br>
    center = data.get_field_parameter("center")<br>
    return data["x"] - center[0]<br>
<br>
@derived_field(name="rad_y_vec")<br>
def rad_y_vec(field, data):<br>
    center = data.get_field_parameter("center")<br>
    return data["y"] - center[1]<br>
<br>
@derived_field(name="rad_z_vec")<br>
def rad_z_vec(field, data):<br>
    center = data.get_field_parameter("center")<br>
    return data["z"] - center[2]<br>
<br>
Then you can use "rad_x_vec", "rad_y_vec", "rad_z_vec" as the vector<br>
fields, which should point radially outward, and the "ones" field as<br>
the fluxing field.  This should return to you the total surface area,<br>
which you can then compare against 4/3 pi r**3, and see the total<br>
difference between the two.  That will at least indicate how different<br>
they are, and provide a semblance of a normalization?<br>
<br>
-Matt<br>
<div><div class="h5"><br>
On Mon, Jul 28, 2014 at 5:13 PM, Melinda Soares-Furtado<br>
<<a href="mailto:msoares.physics@gmail.com">msoares.physics@gmail.com</a>> wrote:<br>
> I have used yt to determine the flux calculation for a region surrounding a<br>
> single star with a given mass loss rate. This region is right outside the<br>
> stellar radius (see attached). Comparing the flux calculation to the known<br>
> mass loss rate, I see that not all of the mass is accounted for and, what's<br>
> more, improved refinement of the simulation enhances this percentage,<br>
> however it is still below 70%. I need to calculate the flux for a region<br>
> surrounding a large group of stars, so simply increasing the refinement is<br>
> really not an option. Any suggestions as to how I can use yt for my flux<br>
> diagnostics in a manner that is more accurate?<br>
><br>
> Best,<br>
> Melinda<br>
><br>
</div></div>> _______________________________________________<br>
> yt-users mailing list<br>
> <a href="mailto:yt-users@lists.spacepope.org">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/listinfo.cgi/yt-users-spacepope.org</a><br>
><br>
_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org">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/listinfo.cgi/yt-users-spacepope.org</a><br>
</blockquote></div><br></div></div>