コード例 #1
0
    def test1(self):
        from mccomponents.sample.sansmodel import sansspheremodel_kernel
        scale=1.0e-6
        radius=60.0 #A
        contrast=1.0 #A-2
        background=0 #cm-1

        absorption_cross_section = 0
        scattering_cross_section = 1
        Qmin = 0
        Qmax = 10
        k = sansspheremodel_kernel(
            scale, radius, contrast, background,
            absorption_cross_section, scattering_cross_section,
            Qmin, Qmax)

        from mccomponents.sample import scattererEngine
        kengine = scattererEngine( k )

        print dir(kengine)

        n = mcni.neutron( r = (0,0,0), v = (0,0,3000) )
        kengine.scatter( n )
        print n
        return
コード例 #2
0
    def test2(self):
        from mccomponents.sample.phonon import periodicdispersion_fromidf
        dispersion = periodicdispersion_fromidf(datapath)

        from mccomponents.sample import scattererEngine
        disp = scattererEngine(dispersion)

        from mccomponents.sample.phonon.bindings import default
        binding = default()

        b = 2.001014429

        N = 20
        Qs = [
            [b / 2, b / 2, 0],
            [0, 0, 0],
            [b, 0, 0],
            [b / 2, b / 2, b / 2],
            [0, 0, 0],
        ]

        xs = [[] for i in range(3)]
        ys = [[] for i in range(3)]
        segment = 0
        for start, end in zip(Qs[:-1], Qs[1:]):
            start = numpy.array(start)
            end = numpy.array(end)
            diff = end - start
            step = diff / N

            qs = [start + step * i for i in range(N + 1)]

            for br in range(3):
                es = [disp.energy(br, binding.Q(q)) for q in qs]

                xs[br] += list(numpy.arange(0, 1. + 1e-10, 1. / N) + segment)
                ys[br] += es

            segment += 1

        for br in range(3):
            x = xs[br]
            y = ys[br]
            pylab.plot(x, y)

        pylab.show()

        return
コード例 #3
0
    def test2(self):
        from mccomponents.sample.phonon import periodicdispersion_fromidf
        dispersion = periodicdispersion_fromidf( datapath )
        
        from mccomponents.sample import scattererEngine
        disp = scattererEngine( dispersion )
        
        from mccomponents.sample.phonon.bindings import default
        binding = default()

        b = 2.001014429
        
        N = 20
        Qs = [
            [b/2,b/2,0],
            [0,0,0],
            [b,0,0],
            [b/2,b/2,b/2],
            [0,0,0],
            ]

        xs=[[] for i in range(3)]; ys=[[] for i in range(3)]
        segment = 0
        for start, end in zip(Qs[:-1], Qs[1:]):
            start = numpy.array(start)
            end = numpy.array(end)
            diff = end-start
            step = diff/N
            
            qs = [ start + step*i for i in range(N+1) ]
            
            for br in range(3):
                es = [ disp.energy(br, binding.Q(q)) for q in qs ]

                xs[br] += list(numpy.arange(0, 1.+1e-10, 1./N)+segment)
                ys[br] += es

            segment += 1

        for br in range(3):
            x = xs[br]
            y = ys[br]
            pylab.plot(x,y)
            
        pylab.show()
                                            
        return
コード例 #4
0
    def test1(self):
        from mccomponents.sample.phonon import dispersion_fromidf
        dispersion = dispersion_fromidf(datapath)

        from mccomponents.sample import scattererEngine
        disp = scattererEngine(dispersion)

        a = 3.52  # Ni lattice parameter
        from math import pi
        ra = 2 * pi / a  # reciprocal lattice parameter
        N = 10
        qs = [(0, 0, ra * i / N) for i in range(N)]
        from mccomponents.sample.phonon.bindings import default
        binding = default()
        es = [disp.energy(0, binding.Q(q)) for q in qs]
        print qs, es
        return
コード例 #5
0
    def test1(self):
        from mccomponents.sample.sansmodel import sansspheremodel_kernel
        scale = 1.0e-6
        radius = 60.0  #A
        contrast = 1.0  #A-2
        background = 0  #cm-1

        absorption_cross_section = 0
        scattering_cross_section = 1
        Qmin = 0
        Qmax = 10
        k = sansspheremodel_kernel(scale, radius, contrast, background,
                                   absorption_cross_section,
                                   scattering_cross_section, Qmin, Qmax)

        from mccomponents.sample import scattererEngine
        kengine = scattererEngine(k)

        print dir(kengine)

        n = mcni.neutron(r=(0, 0, 0), v=(0, 0, 3000))
        kengine.scatter(n)
        print n
        return
コード例 #6
0
    def test2(self):
        from mccomponents.sample.phonon import periodicdispersion_fromidf
        dispersion = periodicdispersion_fromidf(datapath)

        from mccomponents.sample import scattererEngine
        disp = scattererEngine(dispersion)

        a = 3.52  # Ni lattice parameter
        from math import pi
        ra = 2 * pi / a  # reciprocal lattice parameter
        N = 10
        qs = [(0, 0, ra * i / N) for i in range(N)]
        from mccomponents.sample.phonon.bindings import default
        binding = default()
        es = [disp.energy(0, binding.Q(q)) for q in qs]
        print qs, es

        q = qx, qy, qz = 1.2, 0.3, 0.22
        Q = binding.Q(q)
        self.assertAlmostEqual(
            disp.energy(0, binding.Q(qx + 2 * ra, qy + 8 * ra, qz - 6 * ra)),
            disp.energy(0, Q), 3)

        return
コード例 #7
0
ファイル: IDF.py プロジェクト: mcvine/phonon
def from_data_dir(
    datadir=None,
    disp=None,
    N=int(1e6),
    Q_bins=np.arange(0, 11, 0.1),
    E_bins=np.arange(0, 50, 0.5),
    doshist=None,
    T=300.,
    Ei=100.,
    max_det_angle=135.,
    include_multiphonon=True,
):
    if disp is None:
        from mccomponents.sample.phonon import periodicdispersion_fromidf
        dispersion = periodicdispersion_fromidf(datadir)
        from mccomponents.sample import scattererEngine
        disp = scattererEngine(dispersion)
    #
    poscar = os.path.join(datadir, 'POSCAR')
    from mcvine.phonon import from_phonopy
    from_phonopy.make_crystal_xyz('structure.xyz', poscar)
    from sampleassembly.crystal.ioutils import xyzfile2unitcell
    uc = xyzfile2unitcell('structure.xyz')
    # generate Q points
    max_Q = Q_bins[-1]
    Qmag_p3 = np.random.rand(N) * max_Q**3
    Qmag = Qmag_p3**(1. / 3)
    cos_theta = np.random.rand(N) * 2 - 1  # -1 -- 1
    phi = np.random.rand(N) * 2 * np.pi
    sin_theta = np.sqrt(1 - cos_theta * cos_theta)
    sin_phi = np.sin(phi)
    cos_phi = np.cos(phi)
    Qx = Qmag * sin_theta * cos_phi
    Qy = Qmag * sin_theta * sin_phi
    Qz = Qmag * cos_theta
    Qpoints = np.array([Qx, Qy, Qz]).T
    # in reciprocal units
    hkls = np.dot(Qpoints, uc.lattice.base.T) / (2 * np.pi)
    #
    omega, pols = _getEsAndPols(disp, Qpoints)
    from phonopy.interface import vasp
    atoms = vasp.read_vasp(poscar)
    masses = atoms.get_masses()
    average_mass = np.mean(masses)
    from ._calc import calcIQE, apply_corrections
    Qbb, Ebb, I = calcIQE(uc, omega, pols, Qpoints, Q_bins, E_bins)
    # additional corrections
    IQEhist = apply_corrections(I, Qbb, Ebb, N, average_mass, uc, doshist, T,
                                Ei, max_det_angle)
    if include_multiphonon:
        from ._calc import multiphononSQE
        mphIQE = multiphononSQE(T=T,
                                doshist=doshist,
                                mass=average_mass,
                                Q_bins=Q_bins,
                                E_bins=E_bins)
        symbols = [a.element for a in uc]
        from ..atomic_scattering import AtomicScattering
        total_xs = sum(AtomicScattering(s).sigma() for s in symbols)
        return IQEhist, mphIQE * (total_xs / 4 / np.pi, 0)
    return IQEhist
コード例 #8
0
ファイル: IDF.py プロジェクト: mcvine/phonon
def disp_from_datadir(datadir):
    from mccomponents.sample.phonon import periodicdispersion_fromidf
    dispersion = periodicdispersion_fromidf(datadir)
    from mccomponents.sample import scattererEngine
    return scattererEngine(dispersion)