Devin Silvia avatar Devin Silvia committed 7143470

changes na to np throughout.

Comments (0)

Files changed (5)

dengo/chemical_network.py

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
-import numpy as na
+import numpy as np
 from chemistry_constants import tevk, tiny, mh
 from .reaction_classes import reaction_registry, cooling_registry, \
     count_m, index_i, species_registry
     
     def init_temperature(self, T_bounds = (1, 1e8), n_bins=1024):
         self.n_bins = 1024
-        self.T = na.logspace(na.log(T_bounds[0]),
-                             na.log(T_bounds[1]),
-                             n_bins, base = na.e)
-        self.logT = na.log(self.T)
+        self.T = np.logspace(np.log(T_bounds[0]),
+                             np.log(T_bounds[1]),
+                             n_bins, base = np.e)
+        self.logT = np.log(self.T)
         self.tev = self.T / tevk
-        self.logtev = na.log(self.tev)
+        self.logtev = np.log(self.tev)
         self.T_bounds = T_bounds
 
     def species_total(self, species):

dengo/primordial_cooling.py

 """
 
 from chemistry_constants import tevk
-import numpy as na
+import numpy as np
 import sympy
 from reaction_classes import cooling_action, reaction_registry
 
 def cool(eq):
     @eq.table
     def ceHI(state):
-        vals = 7.5e-19*na.exp(-na.minimum(na.log(dhuge), 118348.0/state.T)) \
-                    / (1.0 + na.sqrt(state.T/1.0e5))
+        vals = 7.5e-19*np.exp(-np.minimum(np.log(dhuge), 118348.0/state.T)) \
+                    / (1.0 + np.sqrt(state.T/1.0e5))
         return vals
 
 # -- ceHeI --
 def cool(eq):
     @eq.table
     def ceHeI(state):
-        vals = 9.1e-27*na.exp(-na.minimum(na.log(dhuge), 13179.0/state.T)) \
-                      *state.T**(-0.1687)/(1.0 + na.sqrt(state.T/1.0e5))
+        vals = 9.1e-27*np.exp(-np.minimum(np.log(dhuge), 13179.0/state.T)) \
+                      *state.T**(-0.1687)/(1.0 + np.sqrt(state.T/1.0e5))
         return vals
 
 # -- ceHeIIa --
 def cool(eq):
     @eq.table
     def ceHeII(state):
-        vals = 5.54e-17*na.exp(-na.minimum(na.log(dhuge),473638.0/state.T)) \
-                       *state.T**(-0.397)/(1.+na.sqrt(state.T/1.0e5))
+        vals = 5.54e-17*np.exp(-np.minimum(np.log(dhuge),473638.0/state.T)) \
+                       *state.T**(-0.397)/(1.+np.sqrt(state.T/1.0e5))
         return vals
 
 # Collisional ionizations
 def cool(eq):
     @eq.table
     def ciHeIS(state):
-        vals = 5.01e-27*(state.T)**(-0.1687)/(1.+na.sqrt(state.T/1.0e5)) \
-                * na.exp(-na.minimum(na.log(dhuge),55338.0/state.T))
+        vals = 5.01e-27*(state.T)**(-0.1687)/(1.+np.sqrt(state.T/1.0e5)) \
+                * np.exp(-np.minimum(np.log(dhuge),55338.0/state.T))
         return vals
 
 # -- ciHI --
 def cool(eq):
     @eq.table
     def reHII(state):
-        vals = 8.70e-27*na.sqrt(state.T)*(state.T/1000.0)**(-0.2) \
+        vals = 8.70e-27*np.sqrt(state.T)*(state.T/1000.0)**(-0.2) \
             / (1.0 + (state.T/1.0e6)**(0.7)) 
         return vals
 
     @eq.table
     def reHeII2(state):
         vals = 1.24e-13*state.T**(-1.5) \
-            * na.exp(-na.minimum(na.log(dhuge),470000.0/state.T)) \
-            * (1.+0.3*na.exp(-na.minimum(na.log(dhuge),94000.0/state.T))) 
+            * np.exp(-np.minimum(np.log(dhuge),470000.0/state.T)) \
+            * (1.+0.3*np.exp(-np.minimum(np.log(dhuge),94000.0/state.T))) 
         return vals
 
 # -- reHeIII --
 def cool(eq):
     @eq.table
     def reHeIII(state):
-        vals = 3.48e-26*na.sqrt(state.T)*(state.T/1000.0)**(-0.2) \
+        vals = 3.48e-26*np.sqrt(state.T)*(state.T/1000.0)**(-0.2) \
             / (1.0 + (state.T/1.0e6)**(0.7))
         return vals
 
 def cool(eq):
     @eq.table
     def brem(state):
-        vals = 1.43e-27*na.sqrt(state.T) \
-             *(1.1+0.34*na.exp(-(5.5-na.log10(state.T))**2/3.0))
+        vals = 1.43e-27*np.sqrt(state.T) \
+             *(1.1+0.34*np.exp(-(5.5-np.log10(state.T))**2/3.0))
         return vals
 
 # Galli & Palla 1999 cooling
 def cool(eq):
     @eq.table
     def gpldl(state):
-        tm = na.minimum(na.maximum(state.T, 13.0), 1e5)
-        lt = na.log10(tm)
+        tm = np.minimum(np.maximum(state.T, 13.0), 1e5)
+        lt = np.log10(tm)
         # Low density limit from Galli & Palla
         # -- gpldl --
         vals = 10.**(-103.0+97.59*lt-48.05*lt**2+10.80*lt*lt*lt
     def gphdl(state):
         # high density limit from HM79 (typo corrected Aug 30/2007)
         # -- gphdl --
-        tm  = na.maximum(state.T, 10.0e0)
-        tm  = na.minimum(tm, 1.e4)
+        tm  = np.maximum(state.T, 10.0e0)
+        tm  = np.minimum(tm, 1.e4)
         t3 = tm/1000.
         # HDLR is from p31 of HM79.
         HDLR = ((9.5e-22*t3**3.76)/(1.+0.12*t3**2.1)*
-                na.exp(-(0.13/t3)**3)+3.e-24*na.exp(-0.51/t3))
-        HDLV = (6.7e-19*na.exp(-5.86/t3) + 1.6e-18*na.exp(-11.7/t3))
+                np.exp(-(0.13/t3)**3)+3.e-24*np.exp(-0.51/t3))
+        HDLV = (6.7e-19*np.exp(-5.86/t3) + 1.6e-18*np.exp(-11.7/t3))
         vals  = (HDLR + HDLV) 
         return vals
 
     @eq.table
     def gaHI(state):
         # Low density rates from Glover & Abel 2008
-        tm  = na.maximum(state.T, 10.0e0)
-        tm  = na.minimum(tm, 1.e4)
-        lt3 = na.log10(tm / 1.e3)  
+        tm  = np.maximum(state.T, 10.0e0)
+        tm  = np.minimum(tm, 1.e4)
+        lt3 = np.log10(tm / 1.e3)  
 
         _i1 = (state.T < 100.0)
         _i2 = (state.T < 1000.0)
     # -- gaH2 --
     @eq.table
     def gaH2(state):
-        tm  = na.maximum(state.T, 10.0e0)
-        tm  = na.minimum(tm, 1.e4)
-        lt3 = na.log10(tm / 1.e3)  
+        tm  = np.maximum(state.T, 10.0e0)
+        tm  = np.minimum(tm, 1.e4)
+        lt3 = np.log10(tm / 1.e3)  
         vals = 10**(-23.962112e0
              + 2.09433740e0  * lt3
              - 0.77151436e0  * lt3**2
     # -- gaHe --
     @eq.table
     def gaHe(state):
-        tm  = na.maximum(state.T, 10.0e0)
-        tm  = na.minimum(tm, 1.e4)
-        lt3 = na.log10(tm / 1.e3)  
+        tm  = np.maximum(state.T, 10.0e0)
+        tm  = np.minimum(tm, 1.e4)
+        lt3 = np.log10(tm / 1.e3)  
         vals = 10**(-23.689237e0
              + 2.1892372e0  * lt3
              - 0.81520438e0 * lt3**2
     # -- gaHp --
     @eq.table
     def gaHp(state):
-        tm  = na.maximum(state.T, 10.0e0)
-        tm  = na.minimum(tm, 1.e4)
-        lt3 = na.log10(tm / 1.e3)  
+        tm  = np.maximum(state.T, 10.0e0)
+        tm  = np.minimum(tm, 1.e4)
+        lt3 = np.log10(tm / 1.e3)  
         vals = 10**(-21.716699e0
              + 1.3865783e0   * lt3
              - 0.37915285e0  * lt3**2
     # -- gael --
     @eq.table
     def gael(state):
-        tm  = na.maximum(state.T, 10.0e0)
-        tm  = na.minimum(tm, 1.e4)
-        lt3 = na.log10(tm / 1.e3)  
+        tm  = np.maximum(state.T, 10.0e0)
+        tm  = np.minimum(tm, 1.e4)
+        lt3 = np.log10(tm / 1.e3)  
         _i1 = (state.T < 200)
         vals = 10**(-22.190316
              + 1.5728955  * lt3

dengo/primordial_rates.py

   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
 
-import numpy as na
+import numpy as np
 from chemistry_constants import tevk, tiny, mh
 from reaction_classes import reaction
 from .known_species import *
 # -- k01 --
 @reaction('k01', [   (1,HI),   (1,de)], [  (1,HII),   (2,de)])
 def rxn(state):
-    vals = na.exp(-32.71396786375 
+    vals = np.exp(-32.71396786375 
                  + 13.53655609057*state.logtev
                  - 5.739328757388*state.logtev**2 
                  + 1.563154982022*state.logtev**3
 def rxn(state):
     _i1 = (state.T > 5500)
     _i2 = ~_i1
-    vals = na.exp(-28.61303380689232
+    vals = np.exp(-28.61303380689232
                   - 0.7241125657826851*state.logtev
                   - 0.02026044731984691*state.logtev**2
                   - 0.002380861877349834*state.logtev**3
                   - 1.856767039775261e-8*state.logtev**8
                   - 3.071135243196595e-9*state.logtev**9)
     _i1 = (state.tev < 0.8)
-    vals[_i2] = (1.54e-9*(1.+0.3/na.exp(8.099328789667/state.tev))
-                  / (na.exp(40.49664394833662/state.tev)*state.tev**1.5)
+    vals[_i2] = (1.54e-9*(1.+0.3/np.exp(8.099328789667/state.tev))
+                  / (np.exp(40.49664394833662/state.tev)*state.tev**1.5)
                   + 3.92e-13/state.tev**0.6353) 
     vals[_i1] = 3.92e-13/state.tev**0.6353
     return vals
 def rxn(state):
     _i1 = (state.tev > 0.8)
     _i2 = ~_i1
-    vals = na.exp(-44.09864886561001
+    vals = np.exp(-44.09864886561001
                   + 23.91596563469*state.logtev
                   - 10.75323019821*state.logtev**2
                   + 3.058038757198*state.logtev**3
 def rxn(state):
     _i1 = (state.tev > 0.8)
     _i2 = ~_i1
-    vals = (1.54e-9*(1.+0.3/na.exp(8.099328789667/state.tev))
-                   / (na.exp(40.49664394833662/state.tev)*state.tev**1.5)
+    vals = (1.54e-9*(1.+0.3/np.exp(8.099328789667/state.tev))
+                   / (np.exp(40.49664394833662/state.tev)*state.tev**1.5)
                    + 3.92e-13/state.tev**0.6353) 
     vals[_i2] = tiny
     return vals
 def rxn(state):
     _i1 = (state.tev > 0.8)
     _i2 = ~_i1
-    vals = na.exp(-68.71040990212001
+    vals = np.exp(-68.71040990212001
                   + 43.93347632635*state.logtev
                   - 18.48066993568*state.logtev**2
                   + 4.701626486759002*state.logtev**3
 # -- k06 --
 @reaction('k06', [(1,HeIII),   (1,de)], [ (1,HeII),         ])
 def rxn(state):
-    vals = (3.36e-10/na.sqrt(state.T)/(state.T/1.e3)**0.2 /
+    vals = (3.36e-10/np.sqrt(state.T)/(state.T/1.e3)**0.2 /
             (1+(state.T/1.e6)**0.7))
     return vals
 
 def rxn(state):
     _i1 = (state.tev > 0.1)
     _i2 = ~_i1
-    vals = na.exp(-20.06913897587003
+    vals = np.exp(-20.06913897587003
                   + 0.2289800603272916*state.logtev
                   + 0.03599837721023835*state.logtev**2
                   - 0.004555120027032095*state.logtev**3
 def rxn(state):
     _i1 = (state.T > 6.7e3)
     vals = 1.85e-23*state.T**1.8
-    vals[_i1] = 5.81e-16*(state.T/56200)**(-0.6657*na.log10(state.T/56200))
+    vals[_i1] = 5.81e-16*(state.T/56200)**(-0.6657*np.log10(state.T/56200))
     return vals
 
 # -- k10 --
 def rxn(state):
     _i1 = (state.tev > 0.3)
     _i2 = ~_i1
-    vals = na.exp(-24.24914687731536
+    vals = np.exp(-24.24914687731536
                   + 3.400824447095291*state.logtev
                   - 3.898003964650152*state.logtev**2
                   + 2.045587822403071*state.logtev**3
 def rxn(state):
     _i1 = (state.tev > 0.3)
     _i2 = ~_i1
-    vals = 5.6e-11*na.exp(-102124/state.T)*state.T**0.5
+    vals = 5.6e-11*np.exp(-102124/state.T)*state.T**0.5
     return vals
 
 # -- k13 --
 # NOTE: This is the Glover 2008 rate
 @reaction('k13', [  (1,H2I),   (1,HI)], [   (3,HI),         ])
 def rxn(state):
-    vals = 10.0**(-178.4239 - 68.42243 * na.log10(state.T) 
-                            + 43.20243 * na.log10(state.T)**2
-                            - 4.633167 * na.log10(state.T)**3 
-                            + 69.70086 * na.log10(1 + 40870.38 / state.T)
+    vals = 10.0**(-178.4239 - 68.42243 * np.log10(state.T) 
+                            + 43.20243 * np.log10(state.T)**2
+                            - 4.633167 * np.log10(state.T)**3 
+                            + 69.70086 * np.log10(1 + 40870.38 / state.T)
                             - (23705.7 / state.T))
     return vals
 
 def rxn(state):
     _i1 = (state.tev > 0.04)
     _i2 = ~_i1
-    vals = na.exp(-18.01849334273
+    vals = np.exp(-18.01849334273
                   + 2.360852208681*state.logtev
                   - 0.2827443061704*state.logtev**2
                   + 0.01623316639567*state.logtev**3
 def rxn(state):
     _i1 = (state.tev > 0.1)
     _i2 = ~_i1
-    vals = na.exp(-20.37260896533324
+    vals = np.exp(-20.37260896533324
                   + 1.139449335841631*state.logtev
                   - 0.1421013521554148*state.logtev**2
                   + 0.00846445538663*state.logtev**3
 # -- k16 --
 @reaction('k16', [   (1,HM),  (1,HII)], [   (2,HI),         ])
 def rxn(state):
-    k16 = 6.5e-9/na.sqrt(state.tev)
+    k16 = 6.5e-9/np.sqrt(state.tev)
     return k16
 
 # -- k17 --
     _i1 = (state.T < 1e4)
     _i2 = ~_i1
     vals = 1.0e-8*state.T**(-0.4)
-    vals[_i2] = 4.0e-4*state.T**(-1.4)*na.exp(-15100.0/state.T)
+    vals[_i2] = 4.0e-4*state.T**(-1.4)*np.exp(-15100.0/state.T)
     return vals
 
 # -- k18 --
 # -- k19 --
 @reaction('k19', [ (1,H2II),   (1,HM)], [   (1,HI),  (1,H2I)])
 def rxn(state):
-    vals = 5.e-7*na.sqrt(100./state.T)
+    vals = 5.e-7*np.sqrt(100./state.T)
     return vals
 
 # -- k21 --
 # -- k23 --
 @reaction('k23', [  (1,H2I),  (1,H2I)], [   (2,HI),  (1,H2I)])
 def rxn(state):
-    vals = ((8.125e-8 / na.sqrt(state.T))
-          * na.exp(-52000/state.T)
-          * (1.0 - na.exp(-6000/state.T)))
+    vals = ((8.125e-8 / np.sqrt(state.T))
+          * np.exp(-52000/state.T)
+          * (1.0 - np.exp(-6000/state.T)))
     return vals
 

dengo/reaction_classes.py

   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
 
-import numpy as na
+import numpy as np
 from chemistry_constants import tevk, tiny, mh
 import types
 import sympy
         for i,s in enumerate(species_list):
             self._names[s.name] = i
         self.species_list = species_list
-        self.values = na.zeros(len(species_list), dtype='float64')
+        self.values = np.zeros(len(species_list), dtype='float64')
         if initial_values is not None:
             for s, v in initial_values.items():
                 self.values[self._names[s]] = v
         data = f['Table']
         
         # interpolation
-        vals = na.interp(network.T, data['T'], data['%s' %(ion_name)])
+        vals = np.interp(network.T, data['T'], data['%s' %(ion_name)])
         
         # extrapolation in logspace
-        vals = na.log10(vals)
-        logT = na.log10(network.T)
-        logdataT = na.log10(data['T'])
-        logdataS = na.log10(data['%s' %(ion_name)])
+        vals = np.log10(vals)
+        logT = np.log10(network.T)
+        logdataT = np.log10(data['T'])
+        logdataS = np.log10(data['%s' %(ion_name)])
         extrapdown = logdataS[0] + \
             (logT - logdataT[0]) * (logdataS[0] - logdataS[1]) \
             / (logdataT[0] - logdataT[1])
             (logT - logdataT[-1]) * (logdataS[-1] - logdataS[-2]) \
             / (logdataT[-1] - logdataT[-2])
         vals[logT > logdataT[-1]] = extrapdown[logT > logdataT[-1]]
+
+        # vals[logT < logdataT[0]] = np.log10(tiny)
+        # vals[logT > logdataT[-1]] = np.log10(tiny)
+
         vals = 10.0**vals
         
         f.close()

examples/write_primordial_network.py

 generate_initial_conditions = True
 
 if generate_initial_conditions:
-    import numpy as na
+    import numpy as np
     NCELLS = 1
     density = 1e7
-    init_array = na.ones(NCELLS) 
+    init_array = np.ones(NCELLS) 
     X = 0.5
 
     init_values = dict()
         density += init_values[s.name][0]
     
     # set up initial temperatures values used to define ge
-    temperature = na.logspace(2, 4, NCELLS)
+    temperature = np.logspace(2, 4, NCELLS)
     temperature[:] = 1e3
     init_values['T'] = 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.