コード例 #1
0
    def __init__(self):
        self.measureMemory = parse('--measureMemory', action = 'store_true', default=False)
        self.sampleTime = parse('--sampleTime', action = 'store', type = 'float', default = 1)
        
        self.keys = ['mesh', 'variables', 'terms', 'solver', 'BCs', 'solve']
        
        self.times = {}
        for key in self.keys:
            self.times[key] = 0

        if self.measureMemory:
            from fipy.tools.memoryLogger import MemoryLogger
            self.logger = MemoryLogger(sampleTime = self.sampleTime)
            self.memories = {}
            self.logger.start()
##             time.sleep(3)
            self.memories['baseline'] = self.logger.stop()
            for key in self.keys:
                self.memories[key] = self.memories['baseline']

        self.t0 = time.clock()
コード例 #2
0
ファイル: anisotropy.py プロジェクト: ghorn/Eg
#!/usr/bin/env python

## This script was derived from
## 'examples/phase/anisotropy/input.py'

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

    numberOfElements = parse('--numberOfElements', action = 'store',
                          type = 'int', default = 40)
    from fipy.tools import numerix
    N = int(numerix.sqrt(numberOfElements))

    from benchmarker import Benchmarker
    bench = Benchmarker()

    bench.start()

    Length = N * 2.5 / 100.
    nx = N
    ny = N
    dx = Length / nx
    dy = Length / ny
    radius = Length / 4.
    seedCenter = (Length / 2., Length / 2.)
    initialTemperature = -0.4
    from fipy.meshes.grid2D import Grid2D
    mesh = Grid2D(dx=dx, dy=dy, nx=nx, ny=ny)

    bench.stop('mesh')
コード例 #3
0
ファイル: versions.py プロジェクト: huahbo/FiPy-2.1.3
#
# ###################################################################
##

import os
import re
import shutil
from subprocess import Popen, PIPE
import sys
import tempfile

from fipy.tools.parser import parse

from utils import monitor

url = parse("--svnURL", action="store", type="string", default=None)

revision = parse("--svnRevision", action="store", type="string", default="HEAD:0")

args = sys.argv[1:]

import pysvn

m = re.match(r"(\d+|HEAD):(\d+|HEAD)", revision)


def str2rev(s):
    if s == "HEAD":
        return pysvn.Revision(pysvn.opt_revision_kind.head)
    else:
        return pysvn.Revision(pysvn.opt_revision_kind.number, int(s))
コード例 #4
0
import os
import sys
import re
from subprocess import Popen, PIPE

from fipy import numerix

from fipy.tools.parser import parse

from examples.benchmarking.utils import monitor

steps = parse('--numberOfSteps', action='store', type='int', default=20)

benchmarker = os.path.join(os.path.dirname(__file__), "benchmarker.py")

args = sys.argv[1:]

print "size\tcpu / (s / step / cell)\trsz / (B / cell)\tvsz / (B / cell)"

for size in numerix.arange(2, 6.5, 0.5):
    p = Popen(["python", benchmarker] + args +
              ["--numberOfElements=%d" % int(10**size), "--numberOfSteps=0"],
              stdout=PIPE,
              stderr=PIPE)

    cpu0, rsz0, vsz0 = monitor(p)

    p = Popen([
        "python", benchmarker,
        "--numberOfElements=%d" % int(10**size),
        "--numberOfSteps=%d" % steps,
コード例 #5
0
ファイル: benchmarker.py プロジェクト: ztrautt/fipy
from builtins import str
import os
import sys
import re
from tempfile import mkstemp
from subprocess import Popen, PIPE
from textwrap import dedent

from fipy.tools.parser import parse
from fipy.tools.numerix import sqrt
from fipy.tests import doctestPlus

import examples.phase.anisotropy

numberOfElements = parse('--numberOfElements',
                         action='store',
                         type='int',
                         default=10000)
N = int(sqrt(numberOfElements))

steps = parse('--numberOfSteps', action='store', type='int', default=20)

start = parse('--startingStep', action='store', type='int', default=0)

cpu0 = parse('--cpuBaseLine', action='store', type='float', default=0.)

args = tuple(sys.argv[1:])

dir = os.path.dirname(__file__)

script = doctestPlus._getScript("examples.phase.anisotropy")
コード例 #6
0
ファイル: versions.py プロジェクト: ztrautt/fipy
from __future__ import print_function
from __future__ import unicode_literals
import os
import re
import shutil
from subprocess import Popen, PIPE
import sys
import tempfile

from fipy.tools.parser import parse

from examples.benchmarking.utils import monitor

url = parse('--svnURL', action='store',
              type='string', default=None)

revision = parse('--svnRevision', action='store',
                 type='string', default="HEAD:0")

args = sys.argv[1:]

import pysvn

m = re.match(r"(\d+|HEAD):(\d+|HEAD)", revision)

def str2rev(s):
    if s == "HEAD":
        return pysvn.Revision(pysvn.opt_revision_kind.head)
    else:
        return pysvn.Revision(pysvn.opt_revision_kind.number, int(s))
コード例 #7
0
ファイル: benchmarker.py プロジェクト: usnistgov/fipy
from __future__ import unicode_literals
from builtins import str
import os
import sys
import re
from tempfile import mkstemp
from subprocess import Popen, PIPE
from textwrap import dedent

from fipy.tools.parser import parse
from fipy.tools.numerix import sqrt
from fipy.tests import doctestPlus

import examples.phase.anisotropy

numberOfElements = parse('--numberOfElements', action='store',
                         type='int', default=10000)
N = int(sqrt(numberOfElements))

steps = parse('--numberOfSteps', action='store',
              type='int', default=20)

start = parse('--startingStep', action='store',
              type='int', default=0)

cpu0 = parse('--cpuBaseLine', action='store',
              type='float', default=0.)

args = tuple(sys.argv[1:])

dir = os.path.dirname(__file__)
コード例 #8
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')
コード例 #9
0
ファイル: size.py プロジェクト: LWhitson2/fipy
 #  
 # ###################################################################
 ##

import os
import sys
import re
from subprocess import Popen, PIPE

from fipy import numerix
        
from fipy.tools.parser import parse

from examples.benchmarking.utils import monitor

steps = parse('--numberOfSteps', action='store',
              type='int', default=20)

benchmarker = os.path.join(os.path.dirname(__file__), 
                           "benchmarker.py")

args = sys.argv[1:]

print "size\tcpu / (s / step / cell)\trsz / (B / cell)\tvsz / (B / cell)"

for size in numerix.arange(2,6.5,0.5):
    p = Popen(["python", benchmarker] + args 
              + ["--numberOfElements=%d" % int(10**size),
                 "--numberOfSteps=0"], 
              stdout=PIPE,
              stderr=PIPE)
コード例 #10
0
ファイル: scripy.py プロジェクト: wd15/fipy-attachments
epsilon1 = 2e-4 * gasConstant
liquidDensity = 2.04
gasDensity = 0.17

liquidDensity = 2.04325
gasDensity = 0.177207
avgDensity = (liquidDensity + gasDensity) / 2.0

velocityRelaxation = 0.8
densityRelaxation = 0.5
L = 1.
maxdt = 1e-20
dt = Variable(maxdt)

from fipy.tools.parser import parse
avgDensity = parse('--density', action='store', type='float', default=avgDensity)

dx = 0.1
nx = int(L / dx)

mesh = Grid1D(nx=nx, dx=dx)

numerix.random.seed(135851)
density = CellVariable(mesh=mesh, value=avgDensity * (1 + 0.01 * (2 * numerix.random.rand(mesh.getNumberOfCells()) - 1)), hasOld=1, name='density')
avgDensity = numerix.sum(density[:]) / mesh.getNumberOfCells()

densityCorrection = CellVariable(mesh=mesh)
velocity = []
for dim in range(mesh.getDim()):
    velocity.append(CellVariable(mesh=mesh, hasOld=1))
コード例 #11
0
ファイル: versions.py プロジェクト: usnistgov/fipy
from __future__ import print_function
from __future__ import unicode_literals
import os
import re
import shutil
from subprocess import Popen, PIPE
import sys
import tempfile

from fipy.tools.parser import parse

from examples.benchmarking.utils import monitor

url = parse('--svnURL', action='store',
              type='string', default=None)

revision = parse('--svnRevision', action='store',
                 type='string', default="HEAD:0")

args = sys.argv[1:]

import pysvn

m = re.match(r"(\d+|HEAD):(\d+|HEAD)", revision)

def str2rev(s):
    if s == "HEAD":
        return pysvn.Revision(pysvn.opt_revision_kind.head)
    else:
        return pysvn.Revision(pysvn.opt_revision_kind.number, int(s))