Commits

Matthew Turk committed 365da6b

Temperature calculation is working

Comments (0)

Files changed (3)

src/python/examples/freefall.py

 # This is a translation of freefall.C from the clib distribution
 
+kboltz      = 1.3806504e-16
+mass_h      = 1.67262171e-24   
+mass_e      = 9.10938215e-28
+pi_val      = 3.14159265
+hplanck     = 6.6260693e-27
+ev2erg      = 1.60217653e-12
+c_light     = 2.99792458e10
+GravConst   = 6.67428e-8
+sigma_sb    = 5.670373e-5
+SolarMass   = 1.9891e33
+Mpc         = 3.0857e24
+kpc         = 3.0857e21
+pc          = 3.0857e18
+
 from pygrackle.grackle_wrapper import *
 from pygrackle.fluid_container import FluidContainer
 
+tiny_number = 1e-20
+
 my_chemistry = chemistry_data()
 my_chemistry.use_chemistry = 1
 my_chemistry.primordial_chemistry = 2
 
 my_chemistry.initialize(a_value)
 
-fc = FluidContainer(my_chemistry, 64)
+fc = FluidContainer(my_chemistry, 1)
+fc["density"][:] = 1.0
+fc["HI"][:] = 0.76 * fc["density"]
+fc["HII"][:] = tiny_number * fc["density"]
+fc["HM"][:] = tiny_number * fc["density"]
+fc["HeI"][:] = (1.0 - 0.76) * fc["density"]
+fc["HeII"][:] = tiny_number * fc["density"]
+fc["HeIII"][:] = tiny_number * fc["density"]
+fc["H2I"][:] = tiny_number * fc["density"]
+fc["H2II"][:] = tiny_number * fc["density"]
+fc["DI"][:] = 2.0 * 3.4e-5 * fc["density"]
+fc["DII"][:] = tiny_number * fc["density"]
+fc["HDI"][:] = tiny_number * fc["density"]
+fc["de"][:] = tiny_number * fc["density"]
+fc["metal"][:] = 1.e-5 * fc["density"]
 
+temperature_units = mass_h*((my_chemistry.length_units/my_chemistry.time_units)**2)/kboltz
 
+fc["energy"][:] = 1000. / temperature_units
+fc["x-velocity"][:] = 0.0
+fc["y-velocity"][:] = 0.0
+fc["z-velocity"][:] = 0.0
+  
+calculate_temperature(fc)
+print fc["temperature"]

src/python/pygrackle/fluid_container.py

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

src/python/pygrackle/grackle_wrapper.pyx

     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,
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.