Exemple #1
0
def test_getDiscretisation(n, shape):
    atoms, species = create_atoms(n, shape)
    x = [np.linspace(0, 0.1, g) for g in (10, 21, 32)]
    X = _toMesh(x)

    f1 = get_discretisation(atoms,
                            species,
                            x,
                            pointwise=True,
                            FT=False,
                            **params)
    FT1 = get_discretisation(atoms,
                             species,
                             x,
                             pointwise=True,
                             FT=True,
                             **params)
    f2, FT2 = 0, 0
    for i in range(len(n)):
        a, b = get_atoms(n[i], True)
        f2 = f2 + a(X - atoms[i].reshape(1, 1, -1))
        FT2 = FT2 + b(X) * np.exp(-1j *
                                  (X * atoms[i].reshape(1, 1, -1)).sum(-1))

    # The errors here are from approximating exp
    np.testing.assert_allclose(f1, f2, 1e-2)
    np.testing.assert_allclose(FT1, FT2, 1e-2)
Exemple #2
0
def test_DFT(rX, rY):
    x, y = get_recip_points(len(rX), rX=rX, rY=rY)
    axes = (0 if len(x) == 1 else None)

    f, g = get_atoms(0, returnFunc=True)
    f, g = f(_toMesh(x)), g(_toMesh(y))

    ft, ift = get_DFT(x, y)
    ft1, ift1 = get_DFT(X=x)
    ft2, ift2 = get_DFT(Y=y)

    for FT in (ft, ft1, ft2):
        np.testing.assert_allclose(g, FT(f, axes=axes), 1e-5, 1e-5)
    for IFT in (ift, ift1, ift2):
        np.testing.assert_allclose(f, IFT(g, axes=axes), 1e-5, 1e-5)
Exemple #3
0
def test_getA(Z, returnFunc):
    a, b = get_atoms(Z, returnFunc)
    if returnFunc:
        x = [
            np.linspace(0, 1, 10),
            np.linspace(0, 1, 21),
            np.linspace(0, 1, 32)
        ]
        x = _toMesh(x)
        f = a(x)
        FT = b(x)
        assert x.shape == (10, 21, 32, 3)
        assert f.shape == (10, 21, 32)
        assert FT.shape == (10, 21, 32)
        assert f.min() >= 0
    else:
        assert a.min() >= 0 or Z == 19
        assert b.min() >= 0
        assert len(a) == len(b)
Exemple #4
0
def test_max_atom_getA():
    get_atoms("Es")
Exemple #5
0
def test_2_atoms_getA():
    get_atoms(np.array([0, 1]))
Exemple #6
0
def test_max_atom_getA():
    get_atoms('Es')