当前位置: 首页>>代码示例>>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;未经允许,请勿转载。