<commit_before>#!/usr/bin/env python
#
# <NAME>


"""
compute one-phonon and multi-phonon S(Q,E) from phonon DOS

We follow the formulas in section
"Calculation of Multiphonon Scattering"
of the book 
"Experimental Inelastic Neutron Scattering".

Some of the implementation here were taken from
Max Kresch's original multiphonon code.
"""


def sqe(
    E, g, Qmax=None, Qmin=0, dQ=None,
    T=300, M=50, N=5, starting_order=2, Emax=None,
    ):
    """compute sum of multiphonon SQE from dos
    S = \sum_{i=2,N} S_i(Q,E)
    
    Note: single phonon scattering is not included. only 2-phonons and up
    
    E,g: input DOS data
    energy axis is inferred from input DOS data
    Q axis is defined by Qmax, Qmin, and dQ
    T: temperature (Kelvin)
    M: atomic mass 
    N: maximum number of order for multi-phonon scattering<commit_msg>Refs #11. forward.py added method sqehist<commit_after>#!/usr/bin/env python
#
# <NAME>


"""
compute one-phonon and multi-phonon S(Q,E) from phonon DOS

We follow the formulas in section
"Calculation of Multiphonon Scattering"
of the book 
"Experimental Inelastic Neutron Scattering".

Some of the implementation here were taken from
Max Kresch's original multiphonon code.
"""


def sqehist(E, g, **kwds):
    "a simple wrapper of method sqe to return a histogram"
    Q,E,S = sqe(E,g, **kwds)
    import histogram as H
    Qaxis = H.axis('Q', Q, '1./angstrom')
    Eaxis = H.axis('E', E, 'meV')
    return H.histogram("SP SQE", [Qaxis, Eaxis], S)


def sqe(
    E, g, Qmax=None, Qmin=0, dQ=None,
    T=300, M=50, N=5, starting_order=2, Emax=None,
    ):
    """compute sum of multiphonon SQE from dos
    S = \sum_{i=2,N} S_i(Q,E)
    
    Note: single phonon scattering is not included. only 2-phonons and up
    
    E,g: input DOS data
    energy axis is inferred from input DOS data
    Q axis is defined by Qmax, Qmin, and dQ
    T: temperature (Kelvin)
    M: atomic mass 
    N: maximum number of order for multi-phonon scattering
{'fraction_non_alphanumeric': 0.10348308934881373, 'fraction_numerical': 0.011610297829379102, 'mean_word_length': 3.318082788671024, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4701952', 'n_tokens_mistral': 751, 'n_tokens_neox': 689, 'n_words': 257}