Access User define function inside the yt derived field
Hello all, I want to use a user-defined function (say, Maxwell distribution function) with a variable (say, p--momentum, because I want to integrate the function on that variable), and want to use density and temperature field information of each grid. This function applies individually on each grid. Please suggest me the way to do so. This could be very naive to ask but I stuck in it. That function can't be a yt-field (I think) because it has a variable, and if I want to use density and temperature field even after removing units inside the function, it will show an error, because the field is in vector form (3Dim) and the variable is scaler (basically shape miss-match error). I have to use many such functions as post-processing, please suggest me a way to achieve this goal. Many thanks and regards, -Prateek Gupta
Hi, I’m not quite understanding what you’re going for. Can you make a runnable example using either fake in-memory data or one of the datasets from yt-project.org/data that demonstrates the issue you’re having? Nathan On Mon, Sep 16, 2019 at 10:12 AM Prateek Gupta <prateekgidolia@gmail.com> wrote:
Hello all,
I want to use a user-defined function (say, Maxwell distribution function) with a variable (say, p--momentum, because I want to integrate the function on that variable), and want to use density and temperature field information of each grid. This function applies individually on each grid.
Please suggest me the way to do so. This could be very naive to ask but I stuck in it. That function can't be a yt-field (I think) because it has a variable, and if I want to use density and temperature field even after removing units inside the function, it will show an error, because the field is in vector form (3Dim) and the variable is scaler (basically shape miss-match error).
I have to use many such functions as post-processing, please suggest me a way to achieve this goal.
Many thanks and regards, -Prateek Gupta
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
Yah sure. I will do so and let you know soon. On Mon, Sep 16, 2019 at 6:17 PM Nathan <nathan.goldbaum@gmail.com> wrote:
Hi,
I’m not quite understanding what you’re going for. Can you make a runnable example using either fake in-memory data or one of the datasets from yt-project.org/data that demonstrates the issue you’re having?
Nathan
On Mon, Sep 16, 2019 at 10:12 AM Prateek Gupta <prateekgidolia@gmail.com> wrote:
Hello all,
I want to use a user-defined function (say, Maxwell distribution function) with a variable (say, p--momentum, because I want to integrate the function on that variable), and want to use density and temperature field information of each grid. This function applies individually on each grid.
Please suggest me the way to do so. This could be very naive to ask but I stuck in it. That function can't be a yt-field (I think) because it has a variable, and if I want to use density and temperature field even after removing units inside the function, it will show an error, because the field is in vector form (3Dim) and the variable is scaler (basically shape miss-match error).
I have to use many such functions as post-processing, please suggest me a way to achieve this goal.
Many thanks and regards, -Prateek Gupta
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
Dear Nathan, Suppose I have this function (given below), where ne, and Temperature is the value corresponding to the grid, but this will be a yt-field, number density, and temperature of the respective grid. def max_jut_dist(p, ne, Temperature) : func = ne.d / (4.0*np.pi * (m_electron.d * speed_of_light.d)**3) theta = boltzmann.d * Temperature.d / (m_electron.d * speed_of_light.d**2) gamma = np.sqrt(1.0 + (p / (m_electron.d * speed_of_light.d))**2) func /= theta func /= syspc.kn(2, 1.0/theta) func *= np.exp( -gamma/theta) return func if I call this function inside the field to compute normalization of this function on each grid over p variable: using ---->>> scipy.integrate.quad( max_jut_dist, g1, g2, args=( data["electron_density"] , data["Temperature"]) ) but this will give an error, shape () doesn't match the broadcast shape (16, 16, 16) I hope this will explain what I want to do. Thanks -Prateek
Dear All, I want to use two functions which are basically distribution functions in momentum space. I want to compute the normalization constant for those functions and after normalization, I will get the intersection point of those distribution functions, say p_inter_point. But now the issue is that the distribution functions will depend on the temperature, density, and some other derived fields of their respective grid. And for each grid, I have to compute the normalization and intersection point (p_inter_point) for the two distributions. I used the yt-data enzo_tiny_cosmology and this is the sample code I run for example. Please have a look and suggest me the right way to achieve the goal. Many thanks and regards -Prateek Gupta
participants (2)
-
Nathan
-
Prateek Gupta