Commits

Matthew Turk committed 548fd76

First pass at calculate_temperature

Comments (0)

Files changed (4)

src/python/examples/freefall.py

 my_chemistry.initialize(a_value)
 
 fc = FluidContainer(my_chemistry, 64)
+
+

src/python/pygrackle/fluid_container.py

 _fluid_names = {}
 _fluid_names[0] = ["HI", "HII", "HeI", "HeII", "HeIII", "de",
     "x-velocity", "y-velocity", "z-velocity",
-    "energy"]
+    "temperature", "gamma", "energy", "density"]
 _fluid_names[1] = _fluid_names[0] + \
     ["H2I", "H2II", "HM"]
 _fluid_names[2] = _fluid_names[1] + \

src/python/pygrackle/grackle_defs.pxd

     gr_int initialize_chemistry_data(c_chemistry_data &my_chemistry,
                                   c_code_units &my_units, gr_float a_value)
 
-    gr_int solve_chemistry(
+    gr_int c_solve_chemistry "solve_chemistry"(
                 c_chemistry_data &my_chemistry,
                 c_code_units &my_units,
                 gr_float a_value,
                 gr_float *e_density,
                 gr_float *metal_density)
 
-    gr_int calculate_cooling_time(
+    gr_int c_calculate_cooling_time "calculate_cooling_time"(
                 c_chemistry_data &my_chemistry,
                 c_code_units &my_units,
                 gr_float a_value,
                 gr_float *metal_density,
                 gr_float *cooling_time)
 
-    gr_int calculate_gamma(
+    gr_int c_calculate_gamma "calculate_gamma"(
                 c_chemistry_data &my_chemistry,
                 c_code_units &my_units,
                 gr_int grid_rank,
                 gr_float *metal_density,
                 gr_float *my_gamma)
 
-    gr_int calculate_pressure(
+    gr_int c_calculate_pressure "calculate_pressure"(
                 c_chemistry_data &my_chemistry,
                 c_code_units &my_units,
                 gr_int grid_rank,
                 gr_float *metal_density,
                 gr_float *pressure)
 
-    gr_int calculate_temperature(
+    gr_int c_calculate_temperature "calculate_temperature"(
                 c_chemistry_data &my_chemistry,
                 c_code_units &my_units,
                 gr_int grid_rank,

src/python/pygrackle/grackle_wrapper.pyx

 from grackle_defs cimport *
+cimport numpy as np
 
 cdef class chemistry_data:
     cdef c_chemistry_data data
             return self.units.a_units
         def __set__(self, val):
             self.units.a_units = val
+
+cdef gr_float* get_field(fc, name):
+    cdef np.ndarray rv = fc.get(name, None)
+    if rv is None:
+        return NULL
+    else:
+        return <gr_float *> rv.data
+
+
+def calculate_temperature(fc):
+    cdef gr_int grid_rank = 1
+    cdef gr_int grid_dimension
+    cdef c_chemistry_data my_chemistry = fc.chemistry_data.data
+    cdef c_code_units my_units = fc.chemistry_data.units
+    grid_dimension = fc["density"].shape[0]
+    cdef gr_float *density = get_field(fc, "density")
+    cdef gr_float *internal_energy = get_field(fc, "energy")
+    cdef gr_float *HI_density = get_field(fc, "HI")
+    cdef gr_float *HII_density = get_field(fc, "HII")
+    cdef gr_float *HM_density = get_field(fc, "HM")
+    cdef gr_float *HeI_density = get_field(fc, "HeI")
+    cdef gr_float *HeII_density = get_field(fc, "HeII")
+    cdef gr_float *HeIII_density = get_field(fc, "HeIII")
+    cdef gr_float *H2I_density = get_field(fc, "H2I")
+    cdef gr_float *H2II_density = get_field(fc, "H2II")
+    cdef gr_float *DI_density = get_field(fc, "DI")
+    cdef gr_float *DII_density = get_field(fc, "DII")
+    cdef gr_float *HDI_density = get_field(fc, "HDI")
+    cdef gr_float *e_density = get_field(fc, "de")
+    cdef gr_float *metal_density = get_field(fc, "metal_density")
+    cdef gr_float *temperature = get_field(fc, "temperature")
+    c_calculate_temperature(
+                my_chemistry,
+                my_units,
+                grid_rank,
+                &grid_dimension,
+                density,
+                internal_energy,
+                HI_density,
+                HII_density,
+                HM_density,
+                HeI_density,
+                HeII_density,
+                HeIII_density,
+                H2I_density,
+                H2II_density,
+                DI_density,
+                DII_density,
+                HDI_density,
+                e_density,
+                metal_density,
+                temperature)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.