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


Python CellVariable.updateOld方法代码示例

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


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

示例1: FixedFlux

# 需要导入模块: from fipy.variables.cellVariable import CellVariable [as 别名]
# 或者: from fipy.variables.cellVariable.CellVariable import updateOld [as 别名]
from fipy.boundaryConditions.nthOrderBoundaryCondition import NthOrderBoundaryCondition
BCs = (FixedFlux(mesh.getFacesRight(), 0),
       FixedFlux(mesh.getFacesLeft(), 0),
       NthOrderBoundaryCondition(mesh.getFacesLeft(), 0, 3),
       NthOrderBoundaryCondition(mesh.getFacesRight(), 0, 3),
       NthOrderBoundaryCondition(mesh.getFacesTop(), 0, 3),
       NthOrderBoundaryCondition(mesh.getFacesBottom(), 0, 3))

if __name__ == '__main__':

    import fipy.viewers
    viewer = fipy.viewers.make(vars = var, limits = {'datamin': 0., 'datamax': 1.0})
    viewer.plot()
    
dexp=-5

for step in range(steps):
    dt = numerix.exp(dexp)
    dt = min(100, dt)
    dexp += 0.01
    var.updateOld()
    eqch.solve(var, boundaryConditions = BCs, solver = solver, dt = dt)

    if __name__ == '__main__':
        viewer.plot()
        print 'step',step,'dt',dt
	
def _run():
    pass
            
开发者ID:ghorn,项目名称:Eg,代码行数:31,代码来源:input2D.py

示例2: TransientTerm

# 需要导入模块: from fipy.variables.cellVariable import CellVariable [as 别名]
# 或者: from fipy.variables.cellVariable.CellVariable import updateOld [as 别名]
    anisotropySource = (A * dxi).getDivergence()
    from fipy.terms.transientTerm import TransientTerm
    from fipy.terms.explicitDiffusionTerm import ExplicitDiffusionTerm
    from fipy.terms.implicitSourceTerm import ImplicitSourceTerm
    phaseEq = TransientTerm(tau) == ExplicitDiffusionTerm(D) + \
        ImplicitSourceTerm(mVar * ((mVar < 0) - phase)) + \
        ((mVar > 0.) * mVar * phase + anisotropySource)

    from fipy.terms.implicitDiffusionTerm import ImplicitDiffusionTerm
    temperatureEq = TransientTerm() == \
                    ImplicitDiffusionTerm(tempDiffusionCoeff) + \
                    (phase - phase.getOld()) / timeStepDuration

    bench.stop('terms')

    phase.updateOld()
    temperature.updateOld()
    phaseEq.solve(phase, dt=timeStepDuration)
    temperatureEq.solve(temperature, dt=timeStepDuration)

    steps = 10

    bench.start()

    for i in range(steps):
        phase.updateOld()
        temperature.updateOld()
        phaseEq.solve(phase, dt=timeStepDuration)
        temperatureEq.solve(temperature, dt=timeStepDuration)

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

示例3: TransientTerm

# 需要导入模块: from fipy.variables.cellVariable import CellVariable [as 别名]
# 或者: from fipy.variables.cellVariable.CellVariable import updateOld [as 别名]
        diffusionCoeff = phaseSq * (s * IGamma + epsilon**2)

        thetaGradDiff = theta.getFaceGrad() - theta.getFaceGradNoMod()
        sourceCoeff = (diffusionCoeff * thetaGradDiff).getDivergence()

        from fipy.terms.implicitDiffusionTerm import ImplicitDiffusionTerm
        return TransientTerm(thetaTransientCoeff * phaseModSq * pFunc) == \
                   ImplicitDiffusionTerm(diffusionCoeff) \
                   + sourceCoeff

    thetaEq = buildThetaEquation(phase, theta)

    bench.stop('terms')

    theta.updateOld()
    phase.updateOld()
    thetaEq.solve(theta, dt = timeStepDuration)
    phaseEq.solve(phase, dt = timeStepDuration)

    bench.start()

    ##from profiler import Profiler
    ##from profiler import calibrate_profiler
    ##fudge = calibrate_profiler(10000)
    ##profile = Profiler('profile-HEAD-i686', fudge=fudge)

    for i in range(steps):
        theta.updateOld()
        phase.updateOld()
        thetaEq.solve(theta, dt = timeStepDuration)
        phaseEq.solve(phase, dt = timeStepDuration)
开发者ID:ghorn,项目名称:Eg,代码行数:33,代码来源:phaseImpingement.py

示例4: range

# 需要导入模块: from fipy.variables.cellVariable import CellVariable [as 别名]
# 或者: from fipy.variables.cellVariable.CellVariable import updateOld [as 别名]
## set up the comparison arrays

theta = surfactantVar.getInterfaceVar()[1]
    

if __name__ == "__main__":

    ## set up the viewers

    import fipy.viewers

    ## start time stepping

    currentTime = 0.

    for i in range(totalTimeSteps):

        ## evaluate the analytical and numerical solution and plot

        theta = surfactantVar.getInterfaceVar()[1]
        print "theta:",theta

        ## do a time step
        surfactantVar.updateOld()
        bulkVar.updateOld()
        surfEqn.solve(surfactantVar, dt = dt)
        bulkEqn.solve(bulkVar, dt = dt, boundaryConditions = bcs)
        currentTime += dt

    raw_input("finished")
开发者ID:ghorn,项目名称:Eg,代码行数:32,代码来源:adsorption.py

示例5: ImplicitDiffusionTerm

# 需要导入模块: from fipy.variables.cellVariable import CellVariable [as 别名]
# 或者: from fipy.variables.cellVariable.CellVariable import updateOld [as 别名]
eq= ImplicitDiffusionTerm(coeff=(a,a))+(u.getOld().getOld() - 2*u.getOld() + u) / timeStepDuration ** 2




from fipy.boundaryConditions.fixedValue import FixedValue
from fipy.boundaryConditions.fixedFlux import FixedFlux
from fipy.boundaryConditions.nthOrderBoundaryCondition import NthOrderBoundaryCondition

BCs = ( NthOrderBoundaryCondition(faces=mesh.getFacesRight(), value=0,order=2),
	NthOrderBoundaryCondition(faces=mesh.getFacesRight(), value=1,order=3),
	FixedValue(faces=mesh.getFacesLeft(), value=0),
	FixedFlux(faces=mesh.getFacesLeft(), value=0))

from fipy import viewers
viewer = viewers.make(vars=(u))

def hit_continue(Prompt='Hit any key to continue'):
	raw_input(Prompt)


for step in range(steps):
	u.updateOld()
	eq.solve(var=u,boundaryConditions=BCs,dt=timeStepDuration)
	eq= ImplicitDiffusionTerm(coeff=(a,a))+(u.getOld().getOld() - 2*u.getOld() + u) / timeStepDuration ** 2
	viewer.plot()
	hit_continue()

#getOld seems to be not working
开发者ID:ghorn,项目名称:Eg,代码行数:31,代码来源:plank.py

示例6: runGold

# 需要导入模块: from fipy.variables.cellVariable import CellVariable [as 别名]
# 或者: from fipy.variables.cellVariable.CellVariable import updateOld [as 别名]

#.........这里部分代码省略.........
    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:

        try:
            
            from fipy.viewers.mayaviViewer.mayaviSurfactantViewer import MayaviSurfactantViewer
            viewers = (
                MayaviSurfactantViewer(distanceVar, catalystVar.getInterfaceVar(), zoomFactor = 1e6, limits = { 'datamax' : 1.0, 'datamin' : 0.0 }, smooth = 1, title = 'catalyst coverage'),)
            
        except:
            
            class PlotVariable(CellVariable):
                def __init__(self, var = None, name = ''):
                    CellVariable.__init__(self, mesh = mesh.getFineMesh(), name = name)
                    self.var = self._requires(var)

                def _calcValue(self):
                    return numerix.array(self.var[:self.mesh.getNumberOfCells()])

            from fipy.viewers import make
            viewers = (
                make(PlotVariable(var = distanceVar), limits = {'datamax' : 1e-9, 'datamin' : -1e-9}),
                make(PlotVariable(var = catalystVar.getInterfaceVar())))

    else:
        viewers = ()
    levelSetUpdateFrequency = int(0.7 * narrowBandWidth / cellSize / cflNumber / 2)
    step = 0
    
    while step < numberOfSteps:

        if step % 10 == 0:
            for viewer in viewers:
                viewer.plot()

        if step % levelSetUpdateFrequency == 0:
            
            distanceVar.calcDistanceFunction(deleteIslands = True)
            
        extensionVelocityVariable.setValue(numerix.array(depositionRateVariable))
        argmax = numerix.argmax(extensionVelocityVariable)
        dt = cflNumber * cellSize / extensionVelocityVariable[argmax]
        distanceVar.extendVariable(extensionVelocityVariable, deleteIslands = True)
        
        distanceVar.updateOld()
        catalystVar.updateOld()
        metalVar.updateOld()

        advectionEquation.solve(distanceVar, dt = dt)
        catalystSurfactantEquation.solve(catalystVar, dt = dt)
        metalEquation.solve(metalVar, boundaryConditions = metalEquationBCs, dt = dt)

        step += 1

    try:
        from fipy.tools import dump
        import os
        import examples.levelSet.electroChem
        data = dump.read(os.path.join(examples.levelSet.electroChem.__path__[0], 'goldData.gz'))
        n = mesh.getFineMesh().getNumberOfCells()
        print numerix.allclose(catalystVar[:n], data[:n], atol=1.0)
    except:
        return 0
开发者ID:ghorn,项目名称:Eg,代码行数:104,代码来源:inputGold.py

示例7: int

# 需要导入模块: from fipy.variables.cellVariable import CellVariable [as 别名]
# 或者: from fipy.variables.cellVariable.CellVariable import updateOld [as 别名]
    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()
      
    for step in range(numberOfSteps):

        if step % levelSetUpdateFrequency == 0:
开发者ID:ghorn,项目名称:Eg,代码行数:32,代码来源:superfill.py

示例8: runSimpleTrenchSystem

# 需要导入模块: from fipy.variables.cellVariable import CellVariable [as 别名]
# 或者: from fipy.variables.cellVariable.CellVariable import updateOld [as 别名]

#.........这里部分代码省略.........
                             / (charge * faradaysConstant)

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

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

    surfactantEquation = AdsorbingSurfactantEquation(
        surfactantVar = catalystVar,
        distanceVar = distanceVar,
        bulkVar = bulkCatalystVar,
        rateConstant = rateConstant0 + rateConstant3 * overpotential**3)

    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.getFacesTop(), metalConcentration)

    from fipy.models.levelSet.surfactant.surfactantBulkDiffusionEquation \
                    import buildSurfactantBulkDiffusionEquation

    bulkCatalystEquation = buildSurfactantBulkDiffusionEquation(
        bulkVar = bulkCatalystVar,
        distanceVar = distanceVar,
        surfactantVar = catalystVar,
        diffusionCoeff = catalystDiffusion,
        rateConstant = rateConstant0 * siteDensity
    )

    catalystBCs = FixedValue(mesh.getFacesTop(), catalystConcentration)

    if displayViewers:
        try:
            from fipy.viewers.mayaviViewer.mayaviSurfactantViewer import MayaviSurfactantViewer
            viewers = (MayaviSurfactantViewer(distanceVar, catalystVar.getInterfaceVar(), zoomFactor = 1e6, limits = { 'datamax' : 0.5, 'datamin' : 0.0 }, smooth = 1, title = 'catalyst coverage'),)
        except:
            from fipy.viewers import make
            viewers = (
                make(distanceVar, limits = { 'datamin' :-1e-9 , 'datamax' : 1e-9 }),
                make(catalystVar.getInterfaceVar()))
    else:
        viewers = ()

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

    for step in range(numberOfSteps):

        if step % 5 == 0:
            for viewer in viewers:
                viewer.plot()

        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)

    try:
        import os
        import examples.levelSet.electroChem
        filepath = os.path.join(examples.levelSet.electroChem.__path__[0], 'test.gz')
        
        from fipy.tools import dump
        from fipy.tools import numerix
        print catalystVar.allclose(numerix.array(dump.read(filepath)), rtol = 1e-4)
    except:
        return 0
开发者ID:ghorn,项目名称:Eg,代码行数:104,代码来源:inputSimpleTrenchSystem.py

示例9: TransientTerm

# 需要导入模块: from fipy.variables.cellVariable import CellVariable [as 别名]
# 或者: from fipy.variables.cellVariable.CellVariable import updateOld [as 别名]
eqI = TransientTerm() == ImplicitDiffusionTerm(coeff = D) + ImplicitSourceTerm(a * phi - a * phi * phi)
#eqCN = eqX + eqI

###
## Define Boundary Conditions
###
from fipy.boundaryConditions.fixedValue import FixedValue
BCs = (FixedValue(mesh.getFacesLeft(),valueLeft),
        FixedValue(faces = mesh.getFacesRight(), value=valueRight),
        FixedValue(mesh.getFacesTop(),valueTop),
        FixedValue(mesh.getFacesBottom(),valueBottom))


###
## Create a viewer
###
from fipy import Viewer
viewer = Viewer(vars = phi, datamin=0., datamax=1.0)


###
## Solve; Iterate
###
for step in range(steps):
    phi.updateOld()
    eqI.solve(var = phi, boundaryConditions = BCs, dt = timeStepDuration)
    print max(phi.value)
    viewer.plot()


开发者ID:renatocoutinho,项目名称:bioift,代码行数:30,代码来源:fkpp2D.py


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