1. Matthew Turk
  2. grackle

Commits

Matthew Turk  committed 75c796d

Adding a fluid container

  • Participants
  • Parent commits 273edb8
  • Branches default

Comments (0)

Files changed (3)

File src/python/examples/freefall.py

View file
 # This is a translation of freefall.C from the clib distribution
 
 from pygrackle.grackle_wrapper import *
+from pygrackle.fluid_container import FluidContainer
 
 my_chemistry = chemistry_data()
 my_chemistry.use_chemistry = 1
 a_value = 1.0/(1.0+10.0)
 
 my_chemistry.initialize(a_value)
+
+fc = FluidContainer(my_chemistry, 64)

File src/python/pygrackle/fluid_container.py

View file
+import numpy as np
+
+_fluid_names = {}
+_fluid_names[0] = ["HI", "HII", "HeI", "HeII", "HeIII", "de",
+    "x-velocity", "y-velocity", "z-velocity",
+    "energy"]
+_fluid_names[1] = _fluid_names[0] + \
+    ["H2I", "H2II", "HM"]
+_fluid_names[2] = _fluid_names[1] + \
+    ["DI", "DII", "HDI"]
+
+class FluidContainer(dict):
+    def __init__(self, chemistry_data, n_vals, dtype="float64"):
+        super(FluidContainer, self).__init__()
+        self.dtype = dtype
+        self.chemistry_data = chemistry_data
+        self.n_vals = n_vals
+        for fluid in _fluid_names[self.chemistry_data.primordial_chemistry]:
+            self._setup_fluid(fluid)
+
+    def _setup_fluid(self, fluid_name):
+        self[fluid_name] = np.zeros(self.n_vals, self.dtype)

File src/python/setup.py

View file
         version="0.1",
         description="A wrapper for the Grackle chemistry library",
         configuration=configuration,
-        zip_safe=False,
         )
     return