Exemplo n.º 1
0
def getpath():
    path = sys.path[0]+'/'
    return path

def remove_files(filenames):
    ''' delete files in filenames list '''
    for f in filenames:
        if os.path.exists(f):
            try:
                os.remove(f)
            except OSError as e:
                print ("Error: %s - %s" %(e.filename,e.strerror))
        else:
            pass

Profiling.logEvent("Testing Bodydynamics")

class TestAuxFunctions(unittest.TestCase):
    def testForwardEler(self):
        from proteus.mprans.BodyDynamics import forward_euler
        p0 = 5.0
        v0 = 2.0
        a  = 0.5
        dt = 0.01
        v = v0 + a*dt
        p = p0 + v*dt
        p1, v1 = forward_euler(p0, v0, a, dt)
        self.assertTrue(p==p1)
        self.assertTrue(v==v1)

    def testRungeKutta(self):
Exemplo n.º 2
0


from proteus import Comm, Profiling
import numpy as np
import numpy.testing as npt
import unittest
import pytest

comm = Comm.init()
Profiling.procID = comm.rank()

Profiling.logEvent("Testing SedClosure")
class GlobalVariables():
    def __init__(self):
        from proteus.mprans.SedClosure import HsuSedStress
        self.C4e = 1.
        self.C3e = 1.2
        self.eR = 0.8
        self.aDarcy = 1.
        self.bForch = 1.
        self.grain = 0.1
        self.packFraction = 0.2
        self.packMargin = 0.01
        self.sigmaC = 1.1
        self.maxFraction = 0.635
        self.frFraction = 0.57
        self.fContact = 0.02
        self.mContact = 2.
        self.nContact = 5.
        self.angFriction = np.pi/6.
Exemplo n.º 3
0
def getpath():
    path = sys.path[0]+'/'
    return path

def remove_files(filenames):
    ''' delete files in filenames list '''
    for f in filenames:
        if os.path.exists(f):
            try:
                os.remove(f)
            except OSError, e:
                print ("Error: %s - %s" %(e.filename,e.strerror))
        else:
            pass

Profiling.logEvent("Testing Bodydynamics")

class TestAuxFunctions(unittest.TestCase):
    def testForwardEler(self):
        from proteus.mprans.BodyDynamics import forward_euler
        p0 = 5.0
        v0 = 2.0
        a  = 0.5
        dt = 0.01
        v = v0 + a*dt
        p = p0 + v*dt
        p1, v1 = forward_euler(p0, v0, a, dt)
        self.assertTrue(p==p1)
        self.assertTrue(v==v1)

    def testRungeKutta(self):
Exemplo n.º 4
0
from proteus import Comm, Profiling
import numpy as np
import numpy.testing as npt
import unittest
import pytest

comm = Comm.init()
Profiling.procID = comm.rank()

Profiling.logEvent("Testing SedClosure")


class GlobalVariables():
    def __init__(self):
        from proteus.mprans.SedClosure import HsuSedStress
        self.C4e = 1.
        self.C3e = 1.2
        self.eR = 0.8
        self.aDarcy = 1.
        self.bForch = 1.
        self.grain = 0.1
        self.packFraction = 0.2
        self.packMargin = 0.01
        self.sigmaC = 1.1
        self.maxFraction = 0.635
        self.frFraction = 0.57
        self.fContact = 0.02
        self.mContact = 2.
        self.nContact = 5.
        self.angFriction = np.pi / 6.
        self.vos_limiter = 0.6
Exemplo n.º 5
0
import sys,os
import logging


comm = Comm.init()
Profiling.procID = comm.rank()
def getpath():
    path =str(os.getcwd())
    if "tests" in path[-6:]:
        path =""
    else:
        path = path+"/proteus/tests/"
    return path


Profiling.logEvent("Testing WaveTools")
class TestAuxFunctions(unittest.TestCase):
    def testVDir(self):
        from proteus.WaveTools import setVertDir
        self.assertTrue(np.array_equal(setVertDir(np.array([0,-9.81,0])), np.array([0,1,0])))
    def testDirVector(self):
        from proteus.WaveTools import setDirVector
        self.assertTrue(all(setDirVector(np.array([2.,2.,1.]))== np.array([2.,2.,1])/3.))
    def testDirCheck(self):
        from proteus.WaveTools import dirCheck
        dirCheck(np.array([1.,2.,3.]),np.array([7.,4.,-5.]) )# Just loading the function with two vertical vectors
        with self.assertRaises(SystemExit) as cm:
            dirCheck(np.array([9,9,9]),np.array([4,5,6]))
        self.assertEqual(cm.exception.code, 1)     
        
    def testReduceToIntervals(self):