from __future__ import division
import numpy
from common import GRID, linear_interpolation
from common.integrators import lambda_integrate


name = 'non-equilibrium'
#
@lambda_integrate()
def density(particle):
    return numpy.vectorize(lambda y: (
        particle.distribution(y) * y**2
        * particle.dof / 2. / numpy.pi**2 / particle.params.a**3
    ), otypes=[numpy.float_])
#

Energy density

@lambda_integrate()
def energy_density(particle):

    return numpy.vectorize(lambda y: (
        particle.distribution(y)
        * y**2 * particle.conformal_energy(y)
        * particle.dof / 2. / numpy.pi**2 / particle.params.a**4
    ), otypes=[numpy.float_])
#

Pressure

@lambda_integrate()
def pressure(particle):

    return numpy.vectorize(lambda p: (
        particle.distribution(p) * p ** 4
        / particle.conformal_energy(p)
        * particle.dof / 6. / numpy.pi**2 / particle.params.a**4
    ), otypes=[numpy.float_])
#

Numerator

@lambda_integrate()
def numerator(particle):
    integral = linear_interpolation(particle.collision_integral / particle.params.x,
                                    particle.grid.TEMPLATE)
    return numpy.vectorize(lambda y: (
        -1. * particle.dof / 2. / numpy.pi**2
        * y**2 * particle.conformal_energy(y)
        * integral(y)
    ), otypes=[numpy.float_])
#

Denominator

def denominator(particle):

    return 0.