當前位置: 首頁>>代碼示例>>Python>>正文


Python cellVariable.CellVariable類代碼示例

本文整理匯總了Python中fipy.variables.cellVariable.CellVariable的典型用法代碼示例。如果您正苦於以下問題:Python CellVariable類的具體用法?Python CellVariable怎麽用?Python CellVariable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CellVariable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

    def __init__(self, mesh, name = '', value = 0., unit = None, hasOld = 0, narrowBandWidth = 1e+10):
        """
        Creates a `distanceVariable` object.

        :Parameters:
          - `mesh`: The mesh that defines the geometry of this variable.
          - `name`: The name of the variable.
	  - `value`: The initial value.
	  - `unit`: the physical units of the variable
          - `hasOld`: Whether the variable maintains an old value.
          - `narrowBandWidth`: The width of the region about the zero level set
            within which the distance function is evaluated.

        """
        CellVariable.__init__(self, mesh, name = name, value = value, unit = unit, hasOld = hasOld)
        self._markStale()
        self.narrowBandWidth = narrowBandWidth

        self.cellToCellDistances = MA.filled(self.mesh._getCellToCellDistances(), 0)
        self.cellNormals = MA.filled(self.mesh._getCellNormals(), 0)      
        self.cellAreas = MA.filled(self.mesh._getCellAreas(), 0)
##         self.cellToCellDistances = numerix.array(MA.array(self.mesh._getCellToCellDistances()).filled(0))
##         self.cellNormals = numerix.array(MA.array(self.mesh._getCellNormals()).filled(0))       
##         self.cellAreas = numerix.array(MA.array(self.mesh._getCellAreas()).filled(0))
        self.cellToCellIDs = numerix.array(self.mesh._getCellToCellIDsFilled())
        self.adjacentCellIDs = self.mesh._getAdjacentCellIDs()
        self.exteriorFaces = self.mesh.getExteriorFaces()
        self.cellFaceIDs = self.mesh._getCellFaceIDs()
開發者ID:regmi,項目名稱:fipy,代碼行數:28,代碼來源:distanceVariable.py

示例2: __init__

    def __init__(self, faceVariable, mesh = None):
        if not mesh:
            mesh = faceVariable.getMesh()

        CellVariable.__init__(self, mesh, hasOld = 0)
    
        self.faceVariable = self._requires(faceVariable)
開發者ID:calbaker,項目名稱:FiPy-2.1.3,代碼行數:7,代碼來源:addOverFacesVariable.py

示例3: __init__

    def __init__(self, distanceVar, bulkVar, rateConstant):
        CellVariable.__init__(self, mesh = distanceVar.getMesh())

        self.distanceVar = self._requires(distanceVar)
        self.bulkVar = self._requires(bulkVar)
        self.rateConstant = rateConstant
        self.dt = 0
開發者ID:regmi,項目名稱:fipy,代碼行數:7,代碼來源:adsorbingSurfactantEquation.py

示例4: __init__

    def __init__(self, value = 0., distanceVar = None, name = 'surfactant variable', hasOld=False):
        """

        A simple 1D test:

           >>> from fipy.meshes.grid1D import Grid1D
           >>> mesh = Grid1D(dx = 1., nx = 4)
           >>> from fipy.models.levelSet.distanceFunction.distanceVariable \\
           ...     import DistanceVariable
           >>> distanceVariable = DistanceVariable(mesh = mesh, 
           ...                                     value = (-1.5, -0.5, 0.5, 941.5))
           >>> surfactantVariable = SurfactantVariable(value = 1, 
           ...                                         distanceVar = distanceVariable)
           >>> print numerix.allclose(surfactantVariable, (0, 0., 1., 0))
           1

        A 2D test case:

           >>> from fipy.meshes.grid2D import Grid2D
           >>> mesh = Grid2D(dx = 1., dy = 1., nx = 3, ny = 3)
           >>> distanceVariable = DistanceVariable(mesh = mesh,
           ...                                     value = (1.5, 0.5, 1.5,
           ...                                              0.5,-0.5, 0.5,
           ...                                              1.5, 0.5, 1.5))
           >>> surfactantVariable = SurfactantVariable(value = 1, 
           ...                                         distanceVar = distanceVariable)
           >>> print numerix.allclose(surfactantVariable, (0, 1, 0, 1, 0, 1, 0, 1, 0))
           1

        Another 2D test case:

           >>> mesh = Grid2D(dx = .5, dy = .5, nx = 2, ny = 2)
           >>> distanceVariable = DistanceVariable(mesh = mesh, 
           ...                                     value = (-0.5, 0.5, 0.5, 1.5))
           >>> surfactantVariable = SurfactantVariable(value = 1, 
           ...                                         distanceVar = distanceVariable)
           >>> print numerix.allclose(surfactantVariable, 
           ...                  (0, numerix.sqrt(2), numerix.sqrt(2), 0))
           1

        :Parameters:
          - `value`: The initial value.
          - `distanceVar`: A `DistanceVariable` object.
          - `name`: The name of the variable.
          
        """


        CellVariable.__init__(self, mesh = distanceVar.getMesh(), name = name, hasOld=False)

        self.distanceVar = self._requires(distanceVar)
        self.value = distanceVar.getCellInterfaceAreas() * value / self.mesh.getCellVolumes()

        if hasOld:
            self.old = self.copy()
        else:
            self.old = None

        self.interfaceSurfactantVariable = None
開發者ID:calbaker,項目名稱:FiPy-2.1.3,代碼行數:59,代碼來源:surfactantVariable.py

示例5: __init__

    def __init__(self, distanceVar):
        """
        Creates an `_InterfaceAreaVariable` object.

        :Parameters:
          - `distanceVar` : A `DistanceVariable` object.

        """
        CellVariable.__init__(self, distanceVar.mesh, hasOld=False)
        self.distanceVar = self._requires(distanceVar)
開發者ID:LWhitson2,項目名稱:fipy,代碼行數:10,代碼來源:interfaceAreaVariable.py

示例6: __init__

 def __init__(self, distribution, dx = 1., nx = None, offset = 0.):
     r"""
     Produces a histogram of the values of the supplied distribution.
     
     :Parameters:
         
         - `distribution`: The collection of values to sample.
         - `dx`: the bin size
         - `nx`: the number of bins
         - `offset`: the position of the first bin
     """
     CellVariable.__init__(self, mesh = Grid1D(dx = dx, nx = nx) + (offset,))
     self.distribution = self._requires(distribution)
開發者ID:LWhitson2,項目名稱:fipy,代碼行數:13,代碼來源:histogramVariable.py

示例7: __init__

    def __init__(self, mesh, name = '', value = 0., unit = None, hasOld = 0):
        """
        Creates a `distanceVariable` object.

        :Parameters:
          - `mesh`: The mesh that defines the geometry of this variable.
          - `name`: The name of the variable.
	  - `value`: The initial value.
	  - `unit`: the physical units of the variable
          - `hasOld`: Whether the variable maintains an old value.

        """
        CellVariable.__init__(self, mesh, name = name, value = value, unit = unit, hasOld = hasOld)
        self._markStale()
開發者ID:LWhitson2,項目名稱:fipy,代碼行數:14,代碼來源:distanceVariable.py

示例8: __init__

    def __init__(self, ionVar = None, distanceVar = None, depositionRate = None, metalIonMolarVolume = None):
        """
        Creates a `_MetalIonSourceVariable` object.

        :Parameters:
          - `ionVar` : The metal ion concentration.
          - `distanceVar` : A `DistanceVariable` object.
          - `depositionRate` : The deposition rate.
          - `metalIonMolarVolume` : Molar volume of the metal ions.
       
        """
        
        CellVariable.__init__(self, distanceVar.getMesh(), hasOld = 0)
        self.ionVar = self._requires(ionVar)
        self.distanceVar = self._requires(distanceVar)
        self.depositionRate = self._requires(depositionRate)
        self.metalIonMolarVolume = metalIonMolarVolume
開發者ID:calbaker,項目名稱:FiPy-2.1.3,代碼行數:17,代碼來源:metalIonSourceVariable.py

示例9: _getArithmeticBaseClass

 def _getArithmeticBaseClass(self, other=None):
     """
     Given `self` and `other`, return the desired base
     class for an operation result.
     """
     if other is None:
         return ModularVariable
         
     return CellVariable._getArithmeticBaseClass(self, other)
開發者ID:calbaker,項目名稱:FiPy-2.1.3,代碼行數:9,代碼來源:modularVariable.py

示例10: Grid2D

dy = 2.

L = dx * nx

asq = 1.0
epsilon = 1
diffusionCoeff = 1

from fipy.meshes.grid2D import Grid2D
mesh = Grid2D(dx, dy, nx, ny)

from fipy.variables.cellVariable import CellVariable
from fipy.tools.numerix import random

var = CellVariable(name = "phase field",
                   mesh = mesh,
                   value = random.random(nx * ny))

faceVar = var.getArithmeticFaceValue()
doubleWellDerivative = asq * ( 1 - 6 * faceVar * (1 - faceVar))

from fipy.terms.implicitDiffusionTerm import ImplicitDiffusionTerm
from fipy.terms.transientTerm import TransientTerm
diffTerm2 = ImplicitDiffusionTerm(coeff = (diffusionCoeff * doubleWellDerivative,))
diffTerm4 = ImplicitDiffusionTerm(coeff = (diffusionCoeff, -epsilon**2))
eqch = TransientTerm() - diffTerm2 - diffTerm4

from fipy.solvers.linearPCGSolver import LinearPCGSolver
from fipy.solvers.linearLUSolver import LinearLUSolver
##solver = LinearLUSolver(tolerance = 1e-15,steps = 1000)
solver = LinearPCGSolver(tolerance = 1e-15,steps = 1000)
開發者ID:ghorn,項目名稱:Eg,代碼行數:31,代碼來源:input2D.py

示例11: __init__

 def __init__(self, var, name = ''):
     CellVariable.__init__(self, mesh=var.getMesh(), name=name, rank=var.getRank() + 1)
     self.var = self._requires(var)
開發者ID:calbaker,項目名稱:FiPy-2.1.3,代碼行數:3,代碼來源:leastSquaresCellGradVariable.py

示例12: Grid1D

    bench.start()

    ## from fipy.meshes.numMesh.grid1D import Grid1D
    from fipy.meshes.numMesh.uniformGrid1D import UniformGrid1D as Grid1D

    N = 100000
    L = 10.
    dx = L / N
    mesh = Grid1D(nx = N, dx = dx)

    bench.stop('mesh')

    bench.start()

    from fipy.variables.cellVariable import CellVariable
    C = CellVariable(mesh = mesh)
    C.setValue(1, where=abs(mesh.getCellCenters()[...,0] - L/2.) < L / 10.)

    bench.stop('variables')

    bench.start()

    D = 1.

    from fipy.terms.implicitDiffusionTerm import ImplicitDiffusionTerm
    from fipy.terms.transientTerm import TransientTerm
    eq = TransientTerm() == ImplicitDiffusionTerm(coeff = D)

    bench.stop('terms')

    ## from fipy import viewers
開發者ID:ghorn,項目名稱:Eg,代碼行數:31,代碼來源:transientPulse.py

示例13: Grid1D

## build the mesh

from fipy.meshes.grid1D import Grid1D
dx = L / (nx - 1.5)
mesh = Grid1D(nx = nx, dx = dx)

## build the distance variable


value = mesh.getCellCenters()[:,0] - 1.499 * dx
##distanceVar = DistanceVariable(mesh = mesh, value = dx * (numerix.arange(nx) - 0.999))
distanceVar = DistanceVariable(mesh = mesh, value = value, hasOld = 1)

## Build the bulk diffusion equation

bulkVar = CellVariable(mesh = mesh, value = cinf)

surfactantVar = SurfactantVariable(distanceVar = distanceVar)

bulkEqn = buildSurfactantBulkDiffusionEquation(bulkVar,
                                          distanceVar = distanceVar,
                                          surfactantVar = surfactantVar,
                                          diffusionCoeff = diffusion,
                                          rateConstant = rateConstant * siteDensity)

bcs = (FixedValue(mesh.getFacesRight(), cinf),)

## Build the surfactant equation

surfEqn = AdsorbingSurfactantEquation(surfactantVar = surfactantVar,
                                      distanceVar = distanceVar,
開發者ID:ghorn,項目名稱:Eg,代碼行數:31,代碼來源:adsorption.py

示例14: __init__

 def __init__(self, surfactantVar):
     CellVariable.__init__(self, name = surfactantVar.name + "_interface", mesh = surfactantVar.mesh)
     self.surfactantVar = self._requires(surfactantVar)
開發者ID:LWhitson2,項目名稱:fipy,代碼行數:3,代碼來源:surfactantVariable.py

示例15: __init__

 def __init__(self, rateConstant = None, distanceVar = None):
     CellVariable.__init__(self, mesh = distanceVar.getMesh())
     self.distanceVar = self._requires(distanceVar)
     self.rateConstant = rateConstant
開發者ID:calbaker,項目名稱:FiPy-2.1.3,代碼行數:4,代碼來源:surfactantBulkDiffusionEquation.py


注:本文中的fipy.variables.cellVariable.CellVariable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。