Beispiel #1
0
def calc_NDreflWeights(npy_materialDef, hkls):

    if isinstance(npy_materialDef, dict):

        mat = Material(npy_materialDef)

        str_fac = {}

        for fi, fam in enumerate(hkls):

            str_fac[fi] = []

            for h in fam:

                str_fac[fi].append(_np.abs(mat.calc_nuc_str_fac(h))**2)

            str_fac[fi] = _np.average(str_fac[fi])

        #normalize
        norm = 1 / _np.max(list(str_fac.values()))

        for fi, fam in enumerate(hkls):

            str_fac[fi] *= norm

            if abs(str_fac[fi] - 1) < 1E-3: str_fac[fi] = 1

        return str_fac

    else:
        raise ValueError('supplied mat def not valid')
def test_str_fac():
    """Tests various positions for structure factor
    """
    structure = Material(input)
    assert (np.abs(structure.calc_nuc_str_fac((2., 0., 0.))) ** 2 - 1702170.4663405998 < 1e-6)
    assert (np.abs(structure.calc_nuc_str_fac((2, 0, 0))) ** 2 - 1702170.4663405998 < 1e-6)
    assert (np.abs(structure.calc_nuc_str_fac((0, 2., 0))) ** 2 - 1702170.4663405998 < 1e-6)
    assert (np.abs(structure.calc_nuc_str_fac((0, 2, 0))) ** 2 - 1702170.4663405998 < 1e-6)

    ndarray_example = np.linspace(0.5, 1.5, 21)
    assert (np.sum(abs(structure.calc_nuc_str_fac((ndarray_example, 0, 0))) ** 2) - 7058726.6759794801 < 1e-6)
    assert (np.sum(abs(structure.calc_nuc_str_fac((0, ndarray_example, 0))) ** 2) - 7058726.6759794801 < 1e-6)
    assert (np.sum(abs(structure.calc_nuc_str_fac((0, 0, ndarray_example))) ** 2) - 16831011.814390473 < 1e-6)
    assert (
        np.sum(abs(structure.calc_nuc_str_fac((ndarray_example, ndarray_example, 0))) ** 2) - 10616602.544519115 < 1e-6)

    list_example = list(ndarray_example)
    assert (np.sum(abs(structure.calc_nuc_str_fac((list_example, 0, 0))) ** 2) - 7058726.6759794801 < 1e-6)
    assert (np.sum(abs(structure.calc_nuc_str_fac((0, list_example, 0))) ** 2) - 7058726.6759794801 < 1e-6)
    assert (np.sum(abs(structure.calc_nuc_str_fac((0, 0, list_example))) ** 2) - 16831011.814390473 < 1e-6)

    tuple_example = tuple(ndarray_example)
    assert (np.sum(abs(structure.calc_nuc_str_fac((tuple_example, 0, 0))) ** 2) - 7058726.6759794801 < 1e-6)
    assert (np.sum(abs(structure.calc_nuc_str_fac((0, tuple_example, 0))) ** 2) - 7058726.6759794801 < 1e-6)
    assert (np.sum(abs(structure.calc_nuc_str_fac((0, 0, tuple_example))) ** 2) - 16831011.814390473 < 1e-6)
from neutronpy import Material
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
h, k = np.meshgrid(np.linspace(0, 2, 81), np.linspace(0, 2, 81))
def_FeTe = {'name': 'Fe1.1Te',
            'composition': [{'ion': 'Fe', 'pos': [0.75, 0.25, 0.0]},
                            {'ion': 'Fe', 'pos': [0.25, 0.75, 0.0]},
                            {'ion': 'Te', 'pos': [0.25, 0.25, 0.2839]},
                            {'ion': 'Te', 'pos': [0.75, 0.75, -0.2839]},
                            {'ion': 'Fe', 'pos': [0.25, 0.25, 0.721], 'occupancy': 0.1},
                            {'ion': 'Fe', 'pos': [0.75, 0.75, -0.721], 'occupancy': 0.1}],
            'debye-waller': False,
            'massNorm': False,
            'lattice': {'abc': [3.81, 3.81, 6.25],
                        'abg': [90, 90, 90]}}
FeTe = Material(def_FeTe)
str_fac = 0.25 * (np.abs(FeTe.calc_nuc_str_fac((h, k, 0))) ** 2 +
                  np.abs(FeTe.calc_nuc_str_fac((-h, k, 0))) ** 2 +
                  np.abs(FeTe.calc_nuc_str_fac((h, -k, 0))) ** 2 +
                  np.abs(FeTe.calc_nuc_str_fac((-h, -k, 0))) ** 2)
plt.pcolormesh(h, k, str_fac, cmap=cm.jet)
plt.xlabel('h (r.l.u.)')
plt.ylabel('k (r.l.u.)')
plt.show()
from neutronpy import Material
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
h, k = np.meshgrid(np.linspace(0, 2, 81), np.linspace(0, 2, 81))
def_FeTe = {'name': 'Fe1.1Te',
            'composition': [{'ion': 'Fe', 'pos': [0.75, 0.25, 0.0]},
                            {'ion': 'Fe', 'pos': [0.25, 0.75, 0.0]},
                            {'ion': 'Te', 'pos': [0.25, 0.25, 0.2839]},
                            {'ion': 'Te', 'pos': [0.75, 0.75, -0.2839]},
                            {'ion': 'Fe', 'pos': [0.25, 0.25, 0.721], 'occupancy': 0.1},
                            {'ion': 'Fe', 'pos': [0.75, 0.75, -0.721], 'occupancy': 0.1}],
            'debye-waller': False,
            'massNorm': False,
            'lattice': {'abc': [3.81, 3.81, 6.25],
                        'abg': [90, 90, 90]},
            'space_group': 'P4/nmm'}
FeTe = Material(def_FeTe)
str_fac = np.abs(FeTe.calc_nuc_str_fac((h, k, 0))) ** 2
plt.pcolormesh(h, k, str_fac, cmap=cm.jet)
plt.xlabel('h (r.l.u.)')
plt.ylabel('k (r.l.u.)')
plt.show()
Beispiel #5
0
def test_str_fac():
    """Tests various positions for structure factor
    """
    structure = Material(input)
    assert (np.abs(structure.calc_nuc_str_fac(
        (2., 0., 0.)))**2 - 1702170.4663405998 < 1e-6)
    assert (np.abs(structure.calc_nuc_str_fac(
        (2, 0, 0)))**2 - 1702170.4663405998 < 1e-6)
    assert (np.abs(structure.calc_nuc_str_fac(
        (0, 2., 0)))**2 - 1702170.4663405998 < 1e-6)
    assert (np.abs(structure.calc_nuc_str_fac(
        (0, 2, 0)))**2 - 1702170.4663405998 < 1e-6)

    ndarray_example = np.linspace(0.5, 1.5, 21)
    assert (
        np.sum(abs(structure.calc_nuc_str_fac(
            (ndarray_example, 0, 0)))**2) - 7058726.6759794801 < 1e-6)
    assert (
        np.sum(abs(structure.calc_nuc_str_fac(
            (0, ndarray_example, 0)))**2) - 7058726.6759794801 < 1e-6)
    assert (
        np.sum(abs(structure.calc_nuc_str_fac(
            (0, 0, ndarray_example)))**2) - 16831011.814390473 < 1e-6)
    assert (np.sum(
        abs(structure.calc_nuc_str_fac(
            (ndarray_example, ndarray_example, 0)))**2) - 10616602.544519115 <
            1e-6)

    list_example = list(ndarray_example)
    assert (np.sum(abs(structure.calc_nuc_str_fac(
        (list_example, 0, 0)))**2) - 7058726.6759794801 < 1e-6)
    assert (np.sum(abs(structure.calc_nuc_str_fac(
        (0, list_example, 0)))**2) - 7058726.6759794801 < 1e-6)
    assert (np.sum(abs(structure.calc_nuc_str_fac(
        (0, 0, list_example)))**2) - 16831011.814390473 < 1e-6)

    tuple_example = tuple(ndarray_example)
    assert (np.sum(abs(structure.calc_nuc_str_fac(
        (tuple_example, 0, 0)))**2) - 7058726.6759794801 < 1e-6)
    assert (np.sum(abs(structure.calc_nuc_str_fac(
        (0, tuple_example, 0)))**2) - 7058726.6759794801 < 1e-6)
    assert (np.sum(abs(structure.calc_nuc_str_fac(
        (0, 0, tuple_example)))**2) - 16831011.814390473 < 1e-6)
Beispiel #6
0
        dict(ion='Al', pos=[0.5, 0.5, 0]),
        dict(ion='Al', pos=[0, 0.5, 0.5])
    ],
    'lattice':
    dict(abc=[4.0495, 4.0495, 4.0495], abg=[90, 90, 90]),
    'debye-waller':
    False,
    'massNorm':
    False
}

al = Material(def_al)

str_fac = {}

for fi, fam in enumerate(symHKL):

    str_fac[hkls[fi]] = []

    for h in fam:

        str_fac[hkls[fi]].append(np.abs(al.calc_nuc_str_fac(h))**2)

    str_fac[hkls[fi]] = np.average(str_fac[hkls[fi]])

#normalize
norm = 1 / np.max(list(str_fac.values()))

for fi, fam in enumerate(symHKL):

    str_fac[hkls[fi]] *= norm