예제 #1
0
파일: anisotropy.py 프로젝트: ghorn/Eg
    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')

    print bench.report(numberOfElements=numberOfElements, steps=steps)
예제 #2
0
파일: mesh.py 프로젝트: ghorn/Eg
    $ python setup.py efficiency_test
"""
__docformat__ = 'restructuredtext'

if __name__ == "__main__":

    from fipy.tools.parser import parse

    from benchmarker import Benchmarker
    bench = Benchmarker()

    numberOfElements = parse('--numberOfElements',
                             action='store',
                             type='int',
                             default=100)

    bench.start()

    from fipy.tools import numerix
    nx = int(numerix.sqrt(numberOfElements))
    ny = nx
    dx = 1.
    dy = 1.

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

    bench.stop('mesh')

    print bench.report(numberOfElements=numberOfElements)
예제 #3
0
    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})
    ## viewer.plot()
    ## raw_input("initial")

    bench.start()

    dt = 1e0
    steps = 1
    for step in range(steps):
        eq.solve(var=C, dt=dt)
    ##     viewer.plot()

    bench.stop('solve')

    print bench.report(numberOfElements=N, steps=steps)

    ## raw_input("finished")
예제 #4
0
                               dt=dt,
                               boundaryConditions=catalystBCs)

    bench.start()

    for step in range(numberOfSteps):

        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.stop('solve')

    print bench.report(numberOfElements=numberOfElements, steps=numberOfSteps)
예제 #5
0
파일: mesh.py 프로젝트: ghorn/Eg
r"""
This example benchmarks the speed and memory usage of creating a mesh. Run:
    
    $ python setup.py efficiency_test
"""
__docformat__ = 'restructuredtext'

if __name__ == "__main__":
        
    from fipy.tools.parser import parse

    from benchmarker import Benchmarker
    bench = Benchmarker()

    numberOfElements = parse('--numberOfElements', action = 'store', type = 'int', default = 100)

    bench.start()

    from fipy.tools import numerix
    nx = int(numerix.sqrt(numberOfElements))
    ny = nx
    dx = 1.
    dy = 1.

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

    bench.stop('mesh')

    print bench.report(numberOfElements=numberOfElements)