예제 #1
0
def test_MRA():
    legendre = LegendreBasis(order=5)
    interpol = InterpolatingBasis(order=5)
    world = vp.BoundingBox(scale=-1)
    mra = vp.MultiResolutionAnalysis(box=world, basis=interpol, max_depth=20)
    assert mra == vp.MultiResolutionAnalysis(box=[0,2], order=5, max_depth=20)
    assert mra == vp.MultiResolutionAnalysis(box=world, order=5, max_depth=20)
    assert mra != vp.MultiResolutionAnalysis(box=world, basis=legendre, max_depth=20)
    assert mra.maxDepth() == 20
    assert mra.maxScale() == 19
    assert mra.world() == world
    assert mra.basis() == interpol
예제 #2
0
def test_PeriodicIdentity():
    world = vp.BoundingBox(pbc=True)
    pbc = vp.MultiResolutionAnalysis(box=world, order=k)

    pfunc = ffunc.periodify([1.0])
    ftree = vp.FunctionTree(mra=pbc)
    vp.advanced.build_grid(out=ftree, inp=pfunc)
    vp.advanced.project(prec=epsilon, out=ftree, inp=pfunc)

    I = vp.IdentityConvolution(mra=pbc, prec=epsilon, root=0, reach=5)
    gtree = vp.FunctionTree(mra=pbc)
    vp.advanced.apply(prec=epsilon, out=gtree, oper=I, inp=ftree)
    assert gtree.integrate() == pytest.approx(ftree.integrate(), rel=epsilon)
예제 #3
0
def test_BoundingBox():
    world = vp.BoundingBox(corner=[-1], nboxes=[2], scaling=[np.pi])
    assert world.size() == 2
    assert world.size(dim=0) == 2
    assert world.scale() == 0
    assert world.isPeriodic() == False
    assert world.boxLengths() == pytest.approx([2 * np.pi])
    assert world.boxLength(dim=0) == pytest.approx(2 * np.pi)
    assert world.upperBounds() == pytest.approx([np.pi])
    assert world.upperBound(dim=0) == pytest.approx(np.pi)
    assert world.lowerBounds() == pytest.approx([-np.pi])
    assert world.lowerBound(dim=0) == pytest.approx(-np.pi)
    assert world.unitLengths() == pytest.approx([np.pi])
    assert world.unitLength(dim=0) == pytest.approx(np.pi)
    assert world.scalingFactors() == pytest.approx([np.pi])
    assert world.scalingFactor(dim=0) == pytest.approx(np.pi)
예제 #4
0
def test_PeriodicBox():
    world = vp.BoundingBox(scaling=[np.pi], pbc=True)
    assert world.size() == 1
    assert world.size(dim=0) == 1
    assert world.scale() == 0
    assert world.isPeriodic() == True
    assert world.boxLengths() == pytest.approx([np.pi])
    assert world.boxLength(dim=0) == pytest.approx(np.pi)
    assert world.upperBounds() == pytest.approx([np.pi])
    assert world.upperBound(dim=0) == pytest.approx(np.pi)
    assert world.lowerBounds() == pytest.approx([0.0])
    assert world.lowerBound(dim=0) == pytest.approx(0.0)
    assert world.unitLengths() == pytest.approx([np.pi])
    assert world.unitLength(dim=0) == pytest.approx(np.pi)
    assert world.scalingFactors() == pytest.approx([np.pi])
    assert world.scalingFactor(dim=0) == pytest.approx(np.pi)
예제 #5
0
def test_BuildProjectSemiPeriodicGauss():
    sfac = [np.pi / 3]
    periodic_world = vp.BoundingBox(scaling=sfac, pbc=True)
    pbc = vp.MultiResolutionAnalysis(box=periodic_world, order=k)

    tree_1 = vp.FunctionTree(pbc)
    vp.advanced.build_grid(out=tree_1, inp=gauss)
    vp.advanced.project(out=tree_1, inp=gauss)
    assert tree_1.integrate() < 1.0

    pgauss = gauss.periodify(period=sfac, std_dev=6.0)
    assert pgauss.size() > 0

    tree_2 = vp.FunctionTree(pbc)
    vp.advanced.build_grid(out=tree_2, inp=pgauss)
    vp.advanced.project(out=tree_2, inp=pgauss)
    assert tree_2.integrate() == pytest.approx(1.0, rel=epsilon)
예제 #6
0
from vampyr import BottomUp, Hilbert, Lebesgue, TopDown
from vampyr import vampyr1d as vp

r0 = [0.1]
r1 = [-0.1]

D = 1
k = 5
N = -1
n = 1
l = [2]
name = "func"
two_d = 2**D
kp1_d = (k + 1)**D

world = vp.BoundingBox(scale=N)
root = vp.NodeIndex(scale=N)
idx = vp.NodeIndex(scale=n, translation=l)
mra = vp.MultiResolutionAnalysis(box=world, order=k)
tree = vp.FunctionTree(mra, name)


def test_FunctionTree():
    assert tree.norm() < 0.0
    assert tree.squaredNorm() < 0.0
    assert tree.nNodes() == 1
    assert tree.nEndNodes() == 1
    assert tree.nGenNodes() == 0
    assert tree.rootScale() == N
    assert tree.depth() == 1
    assert tree.name() == name