예제 #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=world, order=5, max_depth=20)
    assert mra == vp.MultiResolutionAnalysis(box=world,
                                             basis=interpol,
                                             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_PeriodicBox():
    world = vp.BoundingBox(scaling=[np.pi, np.pi, np.pi], pbc=True)
    assert world.size() == 1
    assert world.size(dim=1) == 1
    assert world.scale() == 0
    assert world.isPeriodic() == True
    assert world.boxLengths() == pytest.approx([np.pi, np.pi, np.pi])
    assert world.boxLength(dim=1) == pytest.approx(np.pi)
    assert world.upperBounds() == pytest.approx([np.pi, np.pi, np.pi])
    assert world.upperBound(dim=1) == pytest.approx(np.pi)
    assert world.lowerBounds() == pytest.approx([0.0, 0.0, 0.0])
    assert world.lowerBound(dim=1) == pytest.approx(0.0)
    assert world.unitLengths() == pytest.approx([np.pi, np.pi, np.pi])
    assert world.unitLength(dim=1) == pytest.approx(np.pi)
    assert world.scalingFactors() == pytest.approx([np.pi, np.pi, np.pi])
    assert world.scalingFactor(dim=1) == pytest.approx(np.pi)
예제 #3
0
def test_BuildProjectSemiPeriodicGauss():
    sfac = [np.pi / 3, np.pi / 3, 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)
예제 #4
0
def test_PeriodicIdentity():
    world = vp.BoundingBox(pbc=True, corner=[-1, -1, -1], nboxes=[2, 2, 2])
    pbc = vp.MultiResolutionAnalysis(box=world, order=k)

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

    I1 = vp.IdentityConvolution(mra=pbc, prec=epsilon, root=-5)
    gtree1 = vp.FunctionTree(mra=pbc)
    vp.advanced.apply(prec=epsilon, out=gtree1, oper=I1, inp=ftree)
    assert gtree1.integrate() == pytest.approx(ftree.integrate(), rel=epsilon)

    I2 = vp.IdentityConvolution(mra=pbc, prec=epsilon, reach=5)
    gtree2 = vp.FunctionTree(mra=pbc)
    vp.advanced.apply(prec=epsilon, out=gtree2, oper=I2, inp=ftree)
    assert gtree2.integrate() == pytest.approx(ftree.integrate(), rel=epsilon)
예제 #5
0
def test_BoundingBox():
    world = vp.BoundingBox(corner=[-1, -2, -3],
                           nboxes=[2, 4, 6],
                           scaling=[np.pi, np.pi, np.pi])
    assert world.size() == 48
    assert world.size(dim=2) == 6
    assert world.scale() == 0
    assert world.isPeriodic() == False
    assert world.boxLengths() == pytest.approx(
        [2 * np.pi, 4 * np.pi, 6 * np.pi])
    assert world.boxLength(dim=2) == pytest.approx(6 * np.pi)
    assert world.upperBounds() == pytest.approx([np.pi, 2 * np.pi, 3 * np.pi])
    assert world.upperBound(dim=2) == pytest.approx(3 * np.pi)
    assert world.lowerBounds() == pytest.approx(
        [-np.pi, -2 * np.pi, -3 * np.pi])
    assert world.lowerBound(dim=2) == pytest.approx(-3 * np.pi)
    assert world.unitLengths() == pytest.approx([np.pi, np.pi, np.pi])
    assert world.unitLength(dim=2) == pytest.approx(np.pi)
    assert world.scalingFactors() == pytest.approx([np.pi, np.pi, np.pi])
    assert world.scalingFactor(dim=2) == pytest.approx(np.pi)
예제 #6
0
import numpy as np
import pytest

from vampyr import vampyr3d as vp

epsilon = 1.0e-3
mu = epsilon / 10

D = 3
k = 5
N = -2
world = vp.BoundingBox(scale=N)
mra = vp.MultiResolutionAnalysis(box=world, order=k)

r0 = [0.8, 0.8, 0.8]
beta = 10.0
alpha = (beta / np.pi)**(D / 2.0)
ffunc = vp.GaussFunc(coef=alpha, exp=beta, pos=r0)
ref_energy = ffunc.calcCoulombEnergy(ffunc)

ftree = vp.FunctionTree(mra)
vp.advanced.build_grid(out=ftree, inp=ffunc)
vp.advanced.project(prec=epsilon, out=ftree, inp=ffunc)


def test_Identity():
    I = vp.IdentityConvolution(mra, prec=epsilon)

    gtree = vp.FunctionTree(mra)
    vp.advanced.apply(prec=epsilon, out=gtree, oper=I, inp=ftree)
    assert gtree.integrate() == pytest.approx(ftree.integrate(), rel=epsilon)