当前位置: 首页>>代码示例>>Python>>正文


Python CellVariable.setValue方法代码示例

本文整理汇总了Python中fipy.variables.cellVariable.CellVariable.setValue方法的典型用法代码示例。如果您正苦于以下问题:Python CellVariable.setValue方法的具体用法?Python CellVariable.setValue怎么用?Python CellVariable.setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fipy.variables.cellVariable.CellVariable的用法示例。


在下文中一共展示了CellVariable.setValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Grid1D

# 需要导入模块: from fipy.variables.cellVariable import CellVariable [as 别名]
# 或者: from fipy.variables.cellVariable.CellVariable import setValue [as 别名]
    ## 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
    ## viewer = viewers.make(vars = C, limits = {'datamin': 0, 'datamax': 1})
开发者ID:ghorn,项目名称:Eg,代码行数:32,代码来源:transientPulse.py

示例2: CellVariable

# 需要导入模块: from fipy.variables.cellVariable import CellVariable [as 别名]
# 或者: from fipy.variables.cellVariable.CellVariable import setValue [as 别名]
    bench.start()

    timeStepDuration = 5e-5
    tau = 3e-4
    alpha = 0.015
    c = 0.02
    N = 4.
    kappa1 = 0.9
    kappa2 = 20.    
    tempDiffusionCoeff = 2.25
    theta = 0.
    from fipy.variables.cellVariable import CellVariable
    phase = CellVariable(name='phase field', mesh=mesh, hasOld=1)
    x, y = mesh.getCellCenters()[...,0], mesh.getCellCenters()[...,1]
    phase.setValue(1., where=(x - seedCenter[0])**2 + (y - seedCenter[1])**2 < radius**2)
    temperature = CellVariable(
        name='temperature',
        mesh=mesh,
        value=initialTemperature,
        hasOld=1
        )

    bench.stop('variables')

    bench.start()

    from fipy.tools import numerix
    mVar = phase - 0.5 - kappa1 / numerix.pi * \
        numerix.arctan(kappa2 * temperature)
开发者ID:ghorn,项目名称:Eg,代码行数:31,代码来源:anisotropy.py

示例3: ModularVariable

# 需要导入模块: from fipy.variables.cellVariable import CellVariable [as 别名]
# 或者: from fipy.variables.cellVariable.CellVariable import setValue [as 别名]
    from fipy.variables.modularVariable import ModularVariable
    pi = numerix.pi
    theta = ModularVariable(
        name = 'Theta',
        mesh = mesh,
        value = -pi + 0.0001,
        hasOld = 1
        )

    x, y = mesh.getCellCenters()[...,0], mesh.getCellCenters()[...,1]
    for a, b, thetaValue in ((0., 0.,  2. * pi / 3.), 
                             (Lx, 0., -2. * pi / 3.), 
                             (0., Lx, -2. * pi / 3. + 0.3), 
                             (Lx, Lx,  2. * pi / 3.)):
        segment = (x - a)**2 + (y - b)**2 < (Lx / 2.)**2
        phase.setValue(1., where=segment)
        theta.setValue(thetaValue, where=segment)

    bench.stop('variables')

    bench.start()



    from fipy.terms.transientTerm import TransientTerm
    from fipy.terms.explicitDiffusionTerm import ExplicitDiffusionTerm
    from fipy.terms.implicitSourceTerm import ImplicitSourceTerm

    def buildPhaseEquation(phase, theta):

        mPhiVar = phase - 0.5 + temperature * phase * (1 - phase)
开发者ID:ghorn,项目名称:Eg,代码行数:33,代码来源:phaseImpingement.py

示例4: abs

# 需要导入模块: from fipy.variables.cellVariable import CellVariable [as 别名]
# 或者: from fipy.variables.cellVariable.CellVariable import setValue [as 别名]
        timeStepDuration = cfl * dx / velocity
        distanceVariable.updateOld()
        distanceVariable.setValue(numerix.array(distanceVariable) - velocity * timeStepDuration)
        surfactantEquation.solve(surfactantVariable)
        
        totalTime += timeStepDuration
        
        distanceViewer.plot()
        surfactantViewer.plot()
        errorViewer.plot()

        finalRadius = initialRadius + totalTime * velocity + distanceVariable
        answer = initialSurfactantValue * initialRadius / finalRadius
        coverage = surfactantVariable.getInterfaceVar()

        error.setValue(numerix.where((coverage > 1e-3) & (distanceVariable > 0), abs(coverage - answer), 0))

        adjDistanceVariables = numerix.take(distanceVariable,  mesh._getCellToCellIDs())
        adjCoverages = numerix.take(coverage,  mesh._getCellToCellIDs())
        flag = (adjDistanceVariables < 0) & (adjCoverages > 1e-6)




        error.setValue(0, where=numerix.sum(flag, index=1) > 0)

        
        del L1[0]
        del L2[0]
        del Linf[0]
开发者ID:wd15,项目名称:fipy-attachments,代码行数:32,代码来源:expandingCircle1.py

示例5: range

# 需要导入模块: from fipy.variables.cellVariable import CellVariable [as 别名]
# 或者: from fipy.variables.cellVariable.CellVariable import setValue [as 别名]
if __name__ == '__main__':
    
    import fipy.viewers
    distanceViewer = fipy.viewers.make(vars = distanceVariable, limits = {'datamin': -initialRadius, 'datamax': initialRadius})
    surfactantViewer = fipy.viewers.make(vars = surfactantVariable, limits = {'datamin': 0., 'datamax': 100.})
    velocityViewer = fipy.viewers.make(vars = velocity, limits = {'datamin': 0., 'datamax': 200.})
    distanceViewer.plot()
    surfactantViewer.plot()
    velocityViewer.plot()

    totalTime = 0

    for step in range(steps):
        print 'step',step
        velocity.setValue(surfactantVariable.getInterfaceVar() * k)
        distanceVariable.extendVariable(velocity)
        timeStepDuration = cfl * dx / numerix.max(velocity)
        distanceVariable.updateOld()
        advectionEquation.solve(distanceVariable, dt = timeStepDuration)
        surfactantEquation.solve(surfactantVariable)
        
        totalTime += timeStepDuration
        
        velocityViewer.plot()
        distanceViewer.plot()
        surfactantViewer.plot()

        finalRadius = numerix.sqrt(2 * k * initialRadius * initialSurfactantValue * totalTime + initialRadius**2)
        answer = initialSurfactantValue * initialRadius / finalRadius
        coverage = surfactantVariable.getInterfaceVar()
开发者ID:ghorn,项目名称:Eg,代码行数:32,代码来源:expandingCircle.py

示例6: runLeveler

# 需要导入模块: from fipy.variables.cellVariable import CellVariable [as 别名]
# 或者: from fipy.variables.cellVariable.CellVariable import setValue [as 别名]
def runLeveler(kLeveler=0.018, bulkLevelerConcentration=0.02, cellSize=0.1e-7, rateConstant=0.00026, initialAcceleratorCoverage=0.0, levelerDiffusionCoefficient=5e-10, numberOfSteps=400, displayRate=10, displayViewers=True):

    
    kLevelerConsumption = 0.0005
    aspectRatio = 1.5
    faradaysConstant = 9.6485e4
    gasConstant = 8.314
    acceleratorDiffusionCoefficient = 4e-10
    siteDensity = 6.35e-6
    atomicVolume = 7.1e-6
    charge = 2
    metalDiffusionCoefficient = 4e-10
    temperature = 298.
    overpotential = -0.25
    bulkMetalConcentration = 250.
    bulkAcceleratorConcentration = 50.0e-3
    initialLevelerCoverage = 0.
    cflNumber = 0.2
    numberOfCellsInNarrowBand = 20
    cellsBelowTrench = 10
    trenchDepth = 0.4e-6
    trenchSpacing = 0.6e-6
    boundaryLayerDepth = 98.7e-6
    i0Suppressor = 0.3
    i0Accelerator = 22.5
    alphaSuppressor = 0.5
    alphaAccelerator = 0.4
    alphaAdsorption = 0.62
    m = 4
    b = 2.65
    A = 0.3
    Ba = -40
    Bb = 60
    Vd = 0.098
    Bd = 0.0008

    etaPrime = faradaysConstant * overpotential / gasConstant / temperature

    from fipy import TrenchMesh
    from fipy.tools import numerix
    mesh = TrenchMesh(cellSize = cellSize,
                      trenchSpacing = trenchSpacing,
                      trenchDepth = trenchDepth,
                      boundaryLayerDepth = boundaryLayerDepth,
                      aspectRatio = aspectRatio,
                      angle = numerix.pi * 4. / 180.,
                      bowWidth = 0.,
                      overBumpRadius = 0.,
                      overBumpWidth = 0.)

    narrowBandWidth = numberOfCellsInNarrowBand * cellSize
    from fipy.models.levelSet.distanceFunction.distanceVariable import DistanceVariable
    distanceVar = DistanceVariable(
        name = 'distance variable',
        mesh = mesh,
        value = -1,
        narrowBandWidth = narrowBandWidth)

    distanceVar.setValue(1, where=mesh.getElectrolyteMask())
    
    distanceVar.calcDistanceFunction(narrowBandWidth = 1e10)
    from fipy.models.levelSet.surfactant.surfactantVariable import SurfactantVariable
    levelerVar = SurfactantVariable(
        name = "leveler variable",
        value = initialLevelerCoverage,
        distanceVar = distanceVar)

    acceleratorVar = SurfactantVariable(
        name = "accelerator variable",
        value = initialAcceleratorCoverage,
        distanceVar = distanceVar)

    from fipy.variables.cellVariable import CellVariable
    bulkAcceleratorVar = CellVariable(name = 'bulk accelerator variable',
                                      mesh = mesh,
                                      value = bulkAcceleratorConcentration)

    bulkLevelerVar = CellVariable(
        name = 'bulk leveler variable',
        mesh = mesh,
        value = bulkLevelerConcentration)

    metalVar = CellVariable(
        name = 'metal variable',
        mesh = mesh,
        value = bulkMetalConcentration)

    def depositionCoeff(alpha, i0):
        expo = numerix.exp(-alpha * etaPrime)
        return 2 * i0 * (expo - expo * numerix.exp(etaPrime))

    coeffSuppressor = depositionCoeff(alphaSuppressor, i0Suppressor)
    coeffAccelerator = depositionCoeff(alphaAccelerator, i0Accelerator)

    exchangeCurrentDensity = acceleratorVar.getInterfaceVar() * (coeffAccelerator - coeffSuppressor) + coeffSuppressor

    currentDensity = metalVar / bulkMetalConcentration * exchangeCurrentDensity

    depositionRateVariable = currentDensity * atomicVolume / charge / faradaysConstant

#.........这里部分代码省略.........
开发者ID:ghorn,项目名称:Eg,代码行数:103,代码来源:inputLeveler.py

示例7: runGold

# 需要导入模块: from fipy.variables.cellVariable import CellVariable [as 别名]
# 或者: from fipy.variables.cellVariable.CellVariable import setValue [as 别名]
def runGold(faradaysConstant=9.6e4,
            consumptionRateConstant=2.6e+6,
            molarVolume=10.21e-6,
            charge=1.0,
            metalDiffusion=1.7e-9,
            metalConcentration=20.0,
            catalystCoverage=0.15,
            currentDensity0=3e-2 * 16,
            currentDensity1=6.5e-1 * 16,
            cellSize=0.1e-7,
            trenchDepth=0.2e-6,
            aspectRatio=1.47,
            trenchSpacing=0.5e-6,
            boundaryLayerDepth=90.0e-6,
            numberOfSteps=10,
            taperAngle=6.0,
            displayViewers=True):
    
    cflNumber = 0.2
    numberOfCellsInNarrowBand = 20
    cellsBelowTrench = 10
    
    from fipy.tools import numerix
    from fipy import TrenchMesh
    mesh = TrenchMesh(cellSize = cellSize,
                      trenchSpacing = trenchSpacing,
                      trenchDepth = trenchDepth,
                      boundaryLayerDepth = boundaryLayerDepth,
                      aspectRatio = aspectRatio,
                      angle = numerix.pi * taperAngle / 180.,
                      bowWidth = 0.,
                      overBumpRadius = 0.,
                      overBumpWidth = 0.)

    narrowBandWidth = numberOfCellsInNarrowBand * cellSize

    from fipy.models.levelSet.distanceFunction.distanceVariable import DistanceVariable        
    distanceVar = DistanceVariable(
       name = 'distance variable',
       mesh = mesh,
       value = -1,
       narrowBandWidth = narrowBandWidth)

    distanceVar.setValue(1, where=mesh.getElectrolyteMask())
    distanceVar.calcDistanceFunction(narrowBandWidth = 1e10)

    from fipy.models.levelSet.surfactant.surfactantVariable import SurfactantVariable
    catalystVar = SurfactantVariable(
        name = "catalyst variable",
        value = catalystCoverage,
        distanceVar = distanceVar)

    from fipy.variables.cellVariable import CellVariable
    metalVar = CellVariable(
        name = 'metal variable',
        mesh = mesh,
        value = metalConcentration)

    exchangeCurrentDensity = currentDensity0 + currentDensity1 * catalystVar.getInterfaceVar()
    
    currentDensity = metalVar / metalConcentration * exchangeCurrentDensity

    depositionRateVariable = currentDensity * molarVolume / charge / faradaysConstant

    extensionVelocityVariable = CellVariable(
        name = 'extension velocity',
        mesh = mesh,
        value = depositionRateVariable)   

    from fipy.models.levelSet.surfactant.adsorbingSurfactantEquation \
                import AdsorbingSurfactantEquation

    catalystSurfactantEquation = AdsorbingSurfactantEquation(
        catalystVar,
        distanceVar = distanceVar,
        bulkVar = 0,
        rateConstant = 0,
        consumptionCoeff = consumptionRateConstant * extensionVelocityVariable)

    from fipy.models.levelSet.advection.higherOrderAdvectionEquation \
                   import buildHigherOrderAdvectionEquation

    advectionEquation = buildHigherOrderAdvectionEquation(
        advectionCoeff = extensionVelocityVariable)

    from fipy.boundaryConditions.fixedValue import FixedValue
    from fipy.models.levelSet.electroChem.metalIonDiffusionEquation \
                         import buildMetalIonDiffusionEquation

    metalEquation = buildMetalIonDiffusionEquation(
        ionVar = metalVar,
        distanceVar = distanceVar,
        depositionRate = depositionRateVariable,
        diffusionCoeff = metalDiffusion,
        metalIonMolarVolume = molarVolume)

    metalEquationBCs = FixedValue(mesh.getTopFaces(), metalConcentration)

    if displayViewers:

#.........这里部分代码省略.........
开发者ID:ghorn,项目名称:Eg,代码行数:103,代码来源:inputGold.py

示例8: FixedValue

# 需要导入模块: from fipy.variables.cellVariable import CellVariable [as 别名]
# 或者: from fipy.variables.cellVariable.CellVariable import setValue [as 别名]
            FixedValue(
                mesh.getFacesTop(),
                catalystConcentration
            ),)

    bench.stop('BCs')

    levelSetUpdateFrequency = int(0.8 * narrowBandWidth \
                                  / (cellSize * cflNumber * 2))

    step = 0

    if step % levelSetUpdateFrequency == 0:
        distanceVar.calcDistanceFunction()

    extensionVelocityVariable.setValue(depositionRateVariable())

    distanceVar.updateOld()
    catalystVar.updateOld()
    metalVar.updateOld()
    bulkCatalystVar.updateOld()
    distanceVar.extendVariable(extensionVelocityVariable)
    dt = cflNumber * cellSize / numerix.max(extensionVelocityVariable)
    advectionEquation.solve(distanceVar, dt = dt)
    surfactantEquation.solve(catalystVar, dt = dt)
    metalEquation.solve(metalVar, dt = dt,
                        boundaryConditions = metalEquationBCs)
    bulkCatalystEquation.solve(bulkCatalystVar, dt = dt,
                               boundaryConditions = catalystBCs)

    bench.start()
开发者ID:ghorn,项目名称:Eg,代码行数:33,代码来源:superfill.py

示例9: runSimpleTrenchSystem

# 需要导入模块: from fipy.variables.cellVariable import CellVariable [as 别名]
# 或者: from fipy.variables.cellVariable.CellVariable import setValue [as 别名]
def runSimpleTrenchSystem(faradaysConstant=9.6e4,
                          gasConstant=8.314,
                          transferCoefficient=0.5,
                          rateConstant0=1.76,
                          rateConstant3=-245e-6,
                          catalystDiffusion=1e-9,
                          siteDensity=9.8e-6,
                          molarVolume=7.1e-6,
                          charge=2,
                          metalDiffusion=5.6e-10,
                          temperature=298.,
                          overpotential=-0.3,
                          metalConcentration=250.,
                          catalystConcentration=5e-3,
                          catalystCoverage=0.,
                          currentDensity0=0.26,
                          currentDensity1=45.,
                          cellSize=0.1e-7,
                          trenchDepth=0.5e-6,
                          aspectRatio=2.,
                          trenchSpacing=0.6e-6,
                          boundaryLayerDepth=0.3e-6,
                          numberOfSteps=5,
                          displayViewers=True):

    cflNumber = 0.2
    numberOfCellsInNarrowBand = 10
    cellsBelowTrench = 10
    
    yCells = cellsBelowTrench \
             + int((trenchDepth + boundaryLayerDepth) / cellSize)

    xCells = int(trenchSpacing / 2 / cellSize)

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

    narrowBandWidth = numberOfCellsInNarrowBand * cellSize
    from fipy.models.levelSet.distanceFunction.distanceVariable import \
         DistanceVariable        

    distanceVar = DistanceVariable(
        name = 'distance variable',
        mesh = mesh,
        value = -1,
        narrowBandWidth = narrowBandWidth,
        hasOld = 1)

    bottomHeight = cellsBelowTrench * cellSize
    trenchHeight = bottomHeight + trenchDepth
    trenchWidth = trenchDepth / aspectRatio
    sideWidth = (trenchSpacing - trenchWidth) / 2

    x, y = mesh.getCellCenters()[...,0], mesh.getCellCenters()[...,1]
    distanceVar.setValue(1, where=(y > trenchHeight) | ((y > bottomHeight) & (x < xCells * cellSize - sideWidth)))

    distanceVar.calcDistanceFunction(narrowBandWidth = 1e10)

    from fipy.models.levelSet.surfactant.surfactantVariable import \
         SurfactantVariable
    
    catalystVar = SurfactantVariable(
        name = "catalyst variable",
        value = catalystCoverage,
        distanceVar = distanceVar)
    
    from fipy.variables.cellVariable import CellVariable

    bulkCatalystVar = CellVariable(
        name = 'bulk catalyst variable',
        mesh = mesh,
        value = catalystConcentration)

    metalVar = CellVariable(
        name = 'metal variable',
        mesh = mesh,
        value = metalConcentration)
    
    expoConstant = -transferCoefficient * faradaysConstant \
                   / (gasConstant * temperature)
    
    tmp = currentDensity1 * catalystVar.getInterfaceVar()

    exchangeCurrentDensity = currentDensity0 + tmp

    import fipy.tools.numerix as numerix
    expo = numerix.exp(expoConstant * overpotential)
    currentDensity = expo * exchangeCurrentDensity * metalVar \
                     / metalConcentration

    depositionRateVariable = currentDensity * molarVolume \
                             / (charge * faradaysConstant)

    extensionVelocityVariable = CellVariable(
        name = 'extension velocity',
        mesh = mesh,
        value = depositionRateVariable)   
#.........这里部分代码省略.........
开发者ID:ghorn,项目名称:Eg,代码行数:103,代码来源:inputSimpleTrenchSystem.py


注:本文中的fipy.variables.cellVariable.CellVariable.setValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。