modified python files to use either numarray or Numeric

This commit is contained in:
Dave Goodwin 2004-12-10 19:32:14 +00:00
parent 83b08d7a26
commit 748649b122
19 changed files with 41 additions and 43 deletions

View file

@ -7,7 +7,7 @@ corresponding classes in the C++ kernel.
"""
from Numeric import array, asarray, ravel, shape, transpose
from Cantera.num import array, asarray, ravel, shape, transpose
import _cantera
import types

View file

@ -5,7 +5,7 @@ Kinetics managers.
from Cantera.exceptions import CanteraError, getCanteraError
from Cantera.ThermoPhase import ThermoPhase
from Cantera.XML import XML_Node
import Numeric
from Cantera.num import zeros
import _cantera
@ -167,7 +167,7 @@ class Kinetics:
coefficient of species k in reaction i."""
nsp = _cantera.kin_nspecies(self.ckin)
nr = _cantera.kin_nreactions(self.ckin)
nu = Numeric.zeros((nsp,nr),'d')
nu = zeros((nsp,nr),'d')
for i in range(nr):
for k in range(nsp):
nu[k,i] = _cantera.kin_rstoichcoeff(self.ckin,k,i)
@ -183,7 +183,7 @@ class Kinetics:
coefficient of species k in reaction i."""
nsp = _cantera.kin_nspecies(self.ckin)
nr = _cantera.kin_nreactions(self.ckin)
nu = Numeric.zeros((nsp,nr),'d')
nu = zeros((nsp,nr),'d')
for i in range(nr):
for k in range(nsp):
nu[k,i] = _cantera.kin_pstoichcoeff(self.ckin,k,i)

View file

@ -1,6 +1,6 @@
import _cantera
import types
from Numeric import zeros, array, asarray
from Cantera.num import zeros, array, asarray
from exceptions import CanteraError
class Mixture:
@ -216,7 +216,7 @@ class Mixture:
def selectSpecies(self, f, species):
"""Given an array 'f' of floating-point species properties,
return a Numeric array of those values corresponding to species
return an array of those values corresponding to species
listed in 'species'. This method is used internally to implement
species selection in methods like moleFractions, massFractions, etc.
>>> f = mix.chemPotentials()
@ -233,7 +233,7 @@ class Mixture:
for s in s:
k = self.speciesIndex(s)
fs.append(f[k])
return Numeric.asarray(fs)
return asarray(fs)
else:
return f

View file

@ -1,5 +1,5 @@
from onedim import *
import Numeric
from Cantera.num import array, zeros
class BurnerDiffFlame(Stack):
"""A burner-stabilized flat flame."""
@ -47,7 +47,7 @@ class BurnerDiffFlame(Stack):
self.getInitialSoln()
gas = self.gas
nsp = gas.nSpecies()
yin = Numeric.zeros(nsp, 'd')
yin = zeros(nsp, 'd')
for k in range(nsp):
yin[k] = self.burner.massFraction(k)
gas.setState_TPY(self.burner.temperature(), self.pressure, yin)
@ -61,7 +61,7 @@ class BurnerDiffFlame(Stack):
u1 = self.burner.mdot()/gas.density()
z1 = 0.2
locs = Numeric.array([0.0, z1, 1.0],'d')
locs = array([0.0, z1, 1.0],'d')
self.setProfile('u', locs, [u0, u1, u1])
self.setProfile('T', locs, [t0, teq, teq])
for n in range(nsp):
@ -122,7 +122,7 @@ class BurnerDiffFlame(Stack):
"""Set the state of the object representing the gas to the
current solution at grid point j."""
nsp = self.gas.nSpecies()
y = Numeric.zeros(nsp, 'd')
y = zeros(nsp, 'd')
for n in range(nsp):
nm = self.gas.speciesName(n)
y[n] = self.solution(nm, j)

View file

@ -1,5 +1,5 @@
from onedim import *
import Numeric
from Cantera.num import array, zeros
class BurnerFlame(Stack):
"""A burner-stabilized flat flame."""
@ -47,7 +47,7 @@ class BurnerFlame(Stack):
self.getInitialSoln()
gas = self.gas
nsp = gas.nSpecies()
yin = Numeric.zeros(nsp, 'd')
yin = zeros(nsp, 'd')
for k in range(nsp):
yin[k] = self.burner.massFraction(k)
gas.setState_TPY(self.burner.temperature(), self.pressure, yin)
@ -61,7 +61,7 @@ class BurnerFlame(Stack):
u1 = self.burner.mdot()/gas.density()
z1 = 0.2
locs = Numeric.array([0.0, z1, 1.0],'d')
locs = array([0.0, z1, 1.0],'d')
self.setProfile('u', locs, [u0, u1, u1])
self.setProfile('T', locs, [t0, teq, teq])
for n in range(nsp):
@ -122,7 +122,7 @@ class BurnerFlame(Stack):
"""Set the state of the object representing the gas to the
current solution at grid point j."""
nsp = self.gas.nSpecies()
y = Numeric.zeros(nsp, 'd')
y = zeros(nsp, 'd')
for n in range(nsp):
nm = self.gas.speciesName(n)
y[n] = self.solution(nm, j)

View file

@ -1,7 +1,7 @@
"""A counterflow flame."""
from onedim import *
import Numeric
from Cantera.num import zeros
import math
def erfc(x):

View file

@ -1,5 +1,5 @@
from onedim import *
import Numeric
from Cantera.num import array, zeros
class StagnationFlow(Stack):
"""An axisymmetric flow impinging on a surface at normal incidence."""

View file

@ -1,6 +1,6 @@
from Cantera import *
from Cantera import _cantera
import Numeric
from Cantera.num import asarray, zeros
_onoff = {'on':1, 'yes':1, 'off':0, 'no':0, 1:1, 0:0}
@ -153,7 +153,7 @@ class Domain1D:
d.setupGrid([0.0, 0.1, 0.2])
"""
return _cantera.domain_setupGrid(self._hndl, Numeric.asarray(grid))
return _cantera.domain_setupGrid(self._hndl, asarray(grid))
def setID(self, id):
return _cantera.domain_setID(self._hndl, id)
@ -461,7 +461,7 @@ class Stack:
def __init__(self, domains = None):
self._hndl = 0
nd = len(domains)
hndls = Numeric.zeros(nd,'i')
hndls = zeros(nd,'i')
for n in range(nd):
hndls[n] = domains[n].domain_hndl()
self._hndl = _cantera.sim1D_new(hndls)
@ -504,7 +504,7 @@ class Stack:
idom = dom.index()
icomp = dom.componentIndex(comp)
_cantera.sim1D_setProfile(self._hndl, idom, icomp,
Numeric.asarray(pos), Numeric.asarray(v))
asarray(pos), asarray(v))
def setFlatProfile(self, dom, comp, v):
"""Set a flat profile for one component in one domain.
@ -540,7 +540,7 @@ class Stack:
"""
_cantera.sim1D_setTimeStep(self._hndl, stepsize,
Numeric.asarray(nsteps))
asarray(nsteps))
def getInitialSoln(self):
"""Load the initial solution from each domain into the global

View file

@ -7,7 +7,7 @@ This module provides class Phase.
import _cantera
import types
import Numeric
from Cantera.num import asarray
from exceptions import CanteraError
__revision__ = "$Id$"
@ -57,7 +57,7 @@ class Phase:
for e in elements:
m = self.elementIndex(e)
ae.append(atw[m])
return Numeric.asarray(ae)
return asarray(ae)
else:
return atw
@ -242,7 +242,7 @@ class Phase:
if type(x) == types.StringType:
_cantera.phase_setstring(self._phase_id,1,x)
else:
_cantera.phase_setarray(self._phase_id,1,norm,Numeric.asarray(x))
_cantera.phase_setarray(self._phase_id,1,norm,asarray(x))
def setMassFractions(self, x, norm = 1):
@ -252,7 +252,7 @@ class Phase:
if type(x) == types.StringType:
_cantera.phase_setstring(self._phase_id,2,x)
else:
_cantera.phase_setarray(self._phase_id,2,norm,Numeric.asarray(x))
_cantera.phase_setarray(self._phase_id,2,norm,asarray(x))
def setState_TRX(self, t, rho, x):
"""Set the temperature, density, and mole fractions. The mole
@ -278,7 +278,7 @@ class Phase:
def selectSpecies(self, f, species):
"""Given an array 'f' of floating-point species properties,
return a Numeric array of those values corresponding to species
return an array of those values corresponding to species
listed in 'species'. This method is used internally to implement
species selection in methods like moleFractions, massFractions, etc.
>>> f = ph.chemPotentials()
@ -291,13 +291,13 @@ class Phase:
for s in species:
k = self.speciesIndex(s)
fs.append(f[k])
return Numeric.asarray(fs)
return asarray(fs)
else:
return f
def selectElements(self, f, elements):
"""Given an array 'f' of floating-point element properties,
return a Numeric array of those values corresponding to elements
return a nummodule array of those values corresponding to elements
listed in 'elements'.
>>> f = ph.elementPotentials()
>>> lam_o, lam_h = ph.selectElements(f, ['O', 'H'])
@ -308,7 +308,7 @@ class Phase:
for s in elements:
k = self.elementIndex(s)
fs.append(f[k])
return Numeric.asarray(fs)
return asarray(fs)
else:
return f

View file

@ -3,7 +3,7 @@ Zero-dimensional reactors.
"""
import _cantera
from Numeric import array, zeros
from Cantera.num import array, zeros
import types

View file

@ -1,7 +1,7 @@
from ThermoPhase import ThermoPhase
from exceptions import CanteraError
import Numeric
from Cantera.num import asarray
import _cantera
class SurfacePhase(ThermoPhase):
@ -23,7 +23,7 @@ class SurfacePhase(ThermoPhase):
nt = len(theta)
if nt == self.nSpecies():
_cantera.surf_setcoverages(self._phase_id,
Numeric.asarray(theta,'d'))
asarray(theta,'d'))
else:
raise CanteraError('expected '+`self.nSpecies()`+
' coverage values, but got '+`nt`)

View file

@ -1,8 +1,10 @@
""" This module implements class ThermoPhase, a class representing
thermodynamic phases. """
from Cantera.num import zeros
from Cantera.Phase import Phase
from Numeric import zeros
import _cantera
import types

View file

@ -19,7 +19,7 @@ highly simplified class structure is used in the Python interface --
there is only one class. """
import _cantera
from Numeric import asarray
from Cantera.num import asarray
import exceptions
class Transport:

View file

@ -14,8 +14,6 @@ def write_CSV_data(fname, names, npts, nvar, append, data):
the value of variable n at point j.
"""
from Numeric import array, shape
if append > 0:
f = open(fname,'a')
else:

View file

@ -15,7 +15,7 @@ Interface -- interfaces
from Cantera import CanteraError
from Cantera import units
from Numeric import array
from Cantera.num import array
from Cantera import ctsurf, constants, SurfWriter
import math
import types

View file

@ -4,7 +4,7 @@
#
from Cantera import CanteraError
from Numeric import array
from Cantera.num import array
import math, types
def solve(sim, loglevel = 0, refine_grid = 1, plotfile = '', savefile = ''):

View file

@ -1,5 +1,5 @@
from Cantera import exceptions
from Numeric import array
from Cantera.num import array
from Cantera.elements import elementMoles
def det3(A):

View file

@ -16,8 +16,6 @@ def write_TECPLOT_zone(fname, title, zone, names, npts, nvar, append, data):
the value of variable n at point j.
"""
from Numeric import array, shape
if append > 0:
f = open(fname,'a')
else:

View file

@ -1,5 +1,5 @@
from Cantera import *
from Numeric import zeros
from Cantera.num import zeros
import math