示例#1
0
def test_efs_kern_vec(params, ihyps):
    name, cutoffs, hyps_mask_list, _ = params

    np.random.seed(10)
    test_point = get_tstp()

    size1 = len(flare.gp_algebra._global_training_data[name])
    size2 = len(flare.gp_algebra._global_training_structures[name])

    hyps_mask = hyps_mask_list[ihyps]
    hyps = hyps_mask["hyps"]
    kernel = str_to_kernel_set(hyps_mask["kernels"], "mc", hyps_mask)

    test_point = get_tstp()

    energy_vector, force_array, stress_array = efs_kern_vec(
        name, kernel[5], kernel[4], test_point, hyps, cutoffs, hyps_mask)

    energy_vector_par, force_array_par, stress_array_par = efs_kern_vec(
        name,
        kernel[5],
        kernel[4],
        test_point,
        hyps,
        cutoffs,
        hyps_mask,
        n_cpus=2,
        n_sample=100,
    )

    assert np.equal(energy_vector, energy_vector_par).all()
    assert np.equal(force_array, force_array_par).all()
    assert np.equal(stress_array, stress_array_par).all()
示例#2
0
def test_en_kern_vec(params, ihyps):

    name, cutoffs, hyps_mask_list, _ = params
    hyps_mask = hyps_mask_list[ihyps]
    hyps = hyps_mask["hyps"]
    kernel = str_to_kernel_set(hyps_mask["kernels"], "mc", hyps_mask)

    np.random.seed(10)
    test_point = get_tstp()

    size1 = len(flare.gp_algebra._global_training_data[name])
    size2 = len(flare.gp_algebra._global_training_structures[name])

    # test the parallel implementation for multihyps
    vec = en_kern_vec(name, kernel[3], kernel[2], test_point, hyps, cutoffs,
                      hyps_mask)

    vec_par = en_kern_vec(
        name,
        kernel[3],
        kernel[2],
        test_point,
        hyps,
        cutoffs,
        hyps_mask,
        n_cpus=2,
        n_sample=100,
    )

    assert all(np.equal(vec, vec_par)), "parallel implementation is wrong"
    assert vec.shape[0] == size1 * 3 + size2
示例#3
0
def test_kernel_vector(params, ihyps):

    name, cutoffs, hyps_mask_list, _ = params

    np.random.seed(10)
    test_point = get_tstp()

    size1 = len(flare.gp_algebra._global_training_data[name])
    size2 = len(flare.gp_algebra._global_training_structures[name])

    hyps_mask = hyps_mask_list[ihyps]
    hyps = hyps_mask["hyps"]
    kernel = str_to_kernel_set(hyps_mask["kernels"], "mc", hyps_mask)

    # test the parallel implementation for multihyps
    vec = get_kernel_vector(name, kernel[0], kernel[3], test_point, 1, hyps,
                            cutoffs, hyps_mask)

    vec_par = get_kernel_vector(
        name,
        kernel[0],
        kernel[3],
        test_point,
        1,
        hyps,
        cutoffs,
        hyps_mask,
        n_cpus=2,
        n_sample=100,
    )

    assert np.isclose(vec, vec_par,
                      rtol=1e-4).all(), "parallel implementation is wrong"
    assert vec.shape[0] == size1 * 3 + size2