Flux Across Surfaces
I have used yt to determine the flux calculation for a region surrounding a single star with a given mass loss rate. This region is right outside the stellar radius (see attached). Comparing the flux calculation to the known mass loss rate, I see that not all of the mass is accounted for and, what's more, improved refinement of the simulation enhances this percentage, however it is still below 70%. I need to calculate the flux for a region surrounding a large group of stars, so simply increasing the refinement is really not an option. Any suggestions as to how I can use yt for my flux diagnostics in a manner that is more accurate? Best, Melinda
Hi Melinda,
(As a quick note, we have test coverage for a few cases like this, but
non-spherical. The rest of my email assumes that the flux calculation
is working as desired, but I can also attempt to set up a simple
problem to demonstrate this from first principles, which I will put on
my todo list.)
I can think of a few things that might be going on. The first is that
the flux is typically computed using tri-linear interpolation, as well
as a dot product. This will interpolate to the barycenter of the
triangles found through the marching cubes algorithm the velocity and
density. Increasing the refinement will increase this value, but
we're still both approximating the sphere surface as a set of
triangles, as well as taking the interpolated velocities and
multiplying them by the area. So the weak points:
* Interpolation
* Dot product of interpolated values
* Approximating surface
One possible thing to try would be to examine the flux of "ones"
across the surface, where the fluxing field is defined radially
outward. This would then give the total surface area. So, we'd
create three new derived fields:
@derived_field(name="rad_x_vec")
def rad_x_vec(field, data):
center = data.get_field_parameter("center")
return data["x"] - center[0]
@derived_field(name="rad_y_vec")
def rad_y_vec(field, data):
center = data.get_field_parameter("center")
return data["y"] - center[1]
@derived_field(name="rad_z_vec")
def rad_z_vec(field, data):
center = data.get_field_parameter("center")
return data["z"] - center[2]
Then you can use "rad_x_vec", "rad_y_vec", "rad_z_vec" as the vector
fields, which should point radially outward, and the "ones" field as
the fluxing field. This should return to you the total surface area,
which you can then compare against 4/3 pi r**3, and see the total
difference between the two. That will at least indicate how different
they are, and provide a semblance of a normalization?
-Matt
On Mon, Jul 28, 2014 at 5:13 PM, Melinda Soares-Furtado
I have used yt to determine the flux calculation for a region surrounding a single star with a given mass loss rate. This region is right outside the stellar radius (see attached). Comparing the flux calculation to the known mass loss rate, I see that not all of the mass is accounted for and, what's more, improved refinement of the simulation enhances this percentage, however it is still below 70%. I need to calculate the flux for a region surrounding a large group of stars, so simply increasing the refinement is really not an option. Any suggestions as to how I can use yt for my flux diagnostics in a manner that is more accurate?
Best, Melinda
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
On Wed, Jul 30, 2014 at 4:59 PM, Matthew Turk
Hi Melinda,
(As a quick note, we have test coverage for a few cases like this, but non-spherical. The rest of my email assumes that the flux calculation is working as desired, but I can also attempt to set up a simple problem to demonstrate this from first principles, which I will put on my todo list.)
I can think of a few things that might be going on. The first is that the flux is typically computed using tri-linear interpolation, as well as a dot product. This will interpolate to the barycenter of the triangles found through the marching cubes algorithm the velocity and density. Increasing the refinement will increase this value, but we're still both approximating the sphere surface as a set of triangles, as well as taking the interpolated velocities and multiplying them by the area. So the weak points:
* Interpolation * Dot product of interpolated values * Approximating surface
One possible thing to try would be to examine the flux of "ones" across the surface, where the fluxing field is defined radially outward. This would then give the total surface area. So, we'd create three new derived fields:
@derived_field(name="rad_x_vec") def rad_x_vec(field, data): center = data.get_field_parameter("center") return data["x"] - center[0]
@derived_field(name="rad_y_vec") def rad_y_vec(field, data): center = data.get_field_parameter("center") return data["y"] - center[1]
@derived_field(name="rad_z_vec") def rad_z_vec(field, data): center = data.get_field_parameter("center") return data["z"] - center[2]
Then you can use "rad_x_vec", "rad_y_vec", "rad_z_vec" as the vector fields, which should point radially outward, and the "ones" field as the fluxing field. This should return to you the total surface area, which you can then compare against 4/3 pi r**3, and see the total difference between the two. That will at least indicate how different they are, and provide a semblance of a normalization?
Immediately, I received a message from someone else off-list, kindly pointing out to me that I don't know how to compute the surface area of a sphere. I'd make a joke about aspiring to live in a higher-dimensional space, but I'm too embarrassed.
-Matt
On Mon, Jul 28, 2014 at 5:13 PM, Melinda Soares-Furtado
wrote: I have used yt to determine the flux calculation for a region surrounding a single star with a given mass loss rate. This region is right outside the stellar radius (see attached). Comparing the flux calculation to the known mass loss rate, I see that not all of the mass is accounted for and, what's more, improved refinement of the simulation enhances this percentage, however it is still below 70%. I need to calculate the flux for a region surrounding a large group of stars, so simply increasing the refinement is really not an option. Any suggestions as to how I can use yt for my flux diagnostics in a manner that is more accurate?
Best, Melinda
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
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.
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.
****code to generate a plot of the generated
surface************************************
colors = apply_colormap(np.log10(surf["Temperature"]), cmap_name="hot")
#cmap_name="jet", "algae", "hot", "gist_stern", "RdBu","kamae"
fig = plt.figure(figsize=(10, 10), dpi=150)
ax = fig.gca(projection='3d')
p3dc = Poly3DCollection(surf.triangles, linewidth=0.0)
p3dc.set_facecolors(colors[0,:,:]/255.)
ax.add_collection(p3dc)
ax.auto_scale_xyz(surf.vertices[0,:], surf.vertices[1,:],
surf.vertices[2,:])
ax.set_aspect(1.0)
plt.savefig("%s_Surface.png" % pf)
Also, I realized what you meant by the surface area of a sphere! ;)
Regards,
Melinda Soares-Furtado
On Wed, Jul 30, 2014 at 2:59 PM, Matthew Turk
Hi Melinda,
(As a quick note, we have test coverage for a few cases like this, but non-spherical. The rest of my email assumes that the flux calculation is working as desired, but I can also attempt to set up a simple problem to demonstrate this from first principles, which I will put on my todo list.)
I can think of a few things that might be going on. The first is that the flux is typically computed using tri-linear interpolation, as well as a dot product. This will interpolate to the barycenter of the triangles found through the marching cubes algorithm the velocity and density. Increasing the refinement will increase this value, but we're still both approximating the sphere surface as a set of triangles, as well as taking the interpolated velocities and multiplying them by the area. So the weak points:
* Interpolation * Dot product of interpolated values * Approximating surface
One possible thing to try would be to examine the flux of "ones" across the surface, where the fluxing field is defined radially outward. This would then give the total surface area. So, we'd create three new derived fields:
@derived_field(name="rad_x_vec") def rad_x_vec(field, data): center = data.get_field_parameter("center") return data["x"] - center[0]
@derived_field(name="rad_y_vec") def rad_y_vec(field, data): center = data.get_field_parameter("center") return data["y"] - center[1]
@derived_field(name="rad_z_vec") def rad_z_vec(field, data): center = data.get_field_parameter("center") return data["z"] - center[2]
Then you can use "rad_x_vec", "rad_y_vec", "rad_z_vec" as the vector fields, which should point radially outward, and the "ones" field as the fluxing field. This should return to you the total surface area, which you can then compare against 4/3 pi r**3, and see the total difference between the two. That will at least indicate how different they are, and provide a semblance of a normalization?
-Matt
On Mon, Jul 28, 2014 at 5:13 PM, Melinda Soares-Furtado
wrote: I have used yt to determine the flux calculation for a region surrounding a single star with a given mass loss rate. This region is right outside the stellar radius (see attached). Comparing the flux calculation to the known mass loss rate, I see that not all of the mass is accounted for and, what's more, improved refinement of the simulation enhances this percentage, however it is still below 70%. I need to calculate the flux for a region surrounding a large group of stars, so simply increasing the refinement is really not an option. Any suggestions as to how I can use yt for my flux diagnostics in a manner that is more accurate?
Best, Melinda
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
Hi Melinda, this sounds like it would be a good operation to list in the yt cookbook -- do you have a simple script that illustrates it (and a small-medium sized dataset, if necessary?). I can help you add it to the cookbook if you like. Mike On Thu, Jul 31, 2014 at 3:59 PM, Melinda Soares-Furtado < msoares.physics@gmail.com> wrote:
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.
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.
****code to generate a plot of the generated surface************************************ colors = apply_colormap(np.log10(surf["Temperature"]), cmap_name="hot") #cmap_name="jet", "algae", "hot", "gist_stern", "RdBu","kamae"
fig = plt.figure(figsize=(10, 10), dpi=150) ax = fig.gca(projection='3d') p3dc = Poly3DCollection(surf.triangles, linewidth=0.0) p3dc.set_facecolors(colors[0,:,:]/255.) ax.add_collection(p3dc) ax.auto_scale_xyz(surf.vertices[0,:], surf.vertices[1,:], surf.vertices[2,:]) ax.set_aspect(1.0) plt.savefig("%s_Surface.png" % pf)
Also, I realized what you meant by the surface area of a sphere! ;)
Regards, Melinda Soares-Furtado
On Wed, Jul 30, 2014 at 2:59 PM, Matthew Turk
wrote: Hi Melinda,
(As a quick note, we have test coverage for a few cases like this, but non-spherical. The rest of my email assumes that the flux calculation is working as desired, but I can also attempt to set up a simple problem to demonstrate this from first principles, which I will put on my todo list.)
I can think of a few things that might be going on. The first is that the flux is typically computed using tri-linear interpolation, as well as a dot product. This will interpolate to the barycenter of the triangles found through the marching cubes algorithm the velocity and density. Increasing the refinement will increase this value, but we're still both approximating the sphere surface as a set of triangles, as well as taking the interpolated velocities and multiplying them by the area. So the weak points:
* Interpolation * Dot product of interpolated values * Approximating surface
One possible thing to try would be to examine the flux of "ones" across the surface, where the fluxing field is defined radially outward. This would then give the total surface area. So, we'd create three new derived fields:
@derived_field(name="rad_x_vec") def rad_x_vec(field, data): center = data.get_field_parameter("center") return data["x"] - center[0]
@derived_field(name="rad_y_vec") def rad_y_vec(field, data): center = data.get_field_parameter("center") return data["y"] - center[1]
@derived_field(name="rad_z_vec") def rad_z_vec(field, data): center = data.get_field_parameter("center") return data["z"] - center[2]
Then you can use "rad_x_vec", "rad_y_vec", "rad_z_vec" as the vector fields, which should point radially outward, and the "ones" field as the fluxing field. This should return to you the total surface area, which you can then compare against 4/3 pi r**3, and see the total difference between the two. That will at least indicate how different they are, and provide a semblance of a normalization?
-Matt
I have used yt to determine the flux calculation for a region surrounding a single star with a given mass loss rate. This region is right outside
On Mon, Jul 28, 2014 at 5:13 PM, Melinda Soares-Furtado
wrote: the stellar radius (see attached). Comparing the flux calculation to the known mass loss rate, I see that not all of the mass is accounted for and, what's more, improved refinement of the simulation enhances this percentage, however it is still below 70%. I need to calculate the flux for a region surrounding a large group of stars, so simply increasing the refinement is really not an option. Any suggestions as to how I can use yt for my flux diagnostics in a manner that is more accurate?
Best, Melinda
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
-- Michael Zingale Associate Professor Dept. of Physics & Astronomy • Stony Brook University • Stony Brook, NY 11794-3800 *phone*: 631-632-8225 *e-mail*: Michael.Zingale@stonybrook.edu *web*: http://www.astro.sunysb.edu/mzingale
participants (3)
-
Matthew Turk
-
Melinda Soares-Furtado
-
Michael Zingale