def three_particle_free_non_equilibrium_test(params): eps = 1e-14 photon = Particle(**SMP.photon) neutrino_e = Particle(**SMP.leptons.neutrino_e) neutrino_mu = Particle(**SMP.leptons.neutrino_mu) sterile = Particle(**NuP.dirac_sterile_neutrino(mass=140 * UNITS.MeV)) neutral_pion = Particle(**SMP.hadrons.neutral_pion) theta = 1e-3 thetas = defaultdict(float, { 'electron': theta, }) interaction = NuI.sterile_hadrons_interactions( thetas = thetas, sterile=sterile, neutrinos = [neutrino_e], leptons = [], mesons = [neutral_pion] ) universe = Universe(params=params) universe.add_particles([photon, neutrino_e, neutrino_mu, sterile, neutral_pion]) universe.interactions += interaction params.update(universe.total_energy_density(), universe.total_entropy()) universe.update_particles() universe.init_interactions() photon_distribution = photon._distribution neutrino_e_distribution = neutrino_e._distribution neutrino_mu_distribution = neutrino_mu._distribution sterile_distribution = sterile._distribution neutral_pion_distribution = neutral_pion._distribution universe.calculate_collisions() assert all(photon.collision_integral == 0), "Equilibrium particle integral is non-zero" assert all(numpy.abs(neutrino_e.collision_integral * params.h) < eps), "Integrals do not cancel" assert all(numpy.abs(sterile.collision_integral * params.h) < eps), "Integrals do not cancel" assert all(numpy.abs(neutral_pion.collision_integral * params.h) < eps), "Integrals do not cancel" assert all(neutrino_mu.collision_integral == 0), "Free particle integral is non-zero" universe.update_distributions() assert all(photon._distribution == photon_distribution),\ "Equilibrium particle distribution changed" assert all(neutrino_e._distribution - neutrino_e_distribution < eps),\ "Interacting particle distribution changed" assert all(sterile._distribution - sterile_distribution < eps),\ "Interacting particle distribution changed" assert all(neutral_pion._distribution - neutral_pion_distribution < eps),\ "Interacting particle distribution changed" assert all(neutrino_mu._distribution == neutrino_mu_distribution),\ "Free particle distribution changed"
def non_equilibium_setup(): args, _ = setup() params = args[0] photon = Particle(**SMP.photon) neutrino_e = Particle(**SMP.leptons.neutrino_e) neutrino_mu = Particle(**SMP.leptons.neutrino_mu) neutrino_self_scattering = SMI.neutrino_scattering(neutrino_e, neutrino_e) universe = Universe(params=params) universe.add_particles([photon, neutrino_e, neutrino_mu]) universe.interactions += [neutrino_self_scattering] return [params, universe], {}
def four_particle_decay_test(params): os.environ['SPLIT_COLLISION_INTEGRAL'] = '' photon = Particle(**SMP.photon) neutrino_e = Particle(**SMP.leptons.neutrino_e) sterile = Particle(**NuP.dirac_sterile_neutrino(mass=200 * UNITS.MeV)) theta = 1e-4 thetas = defaultdict(float, { 'electron': theta, }) interaction = NuI.sterile_leptons_interactions( thetas=thetas, sterile=sterile, neutrinos=[neutrino_e], leptons=[], kind = CollisionIntegralKind.F_f_vacuum_decay ) for inter in interaction: inter.integrals = [integral for integral in inter.integrals if sum(reactant.side for reactant in integral.reaction) in [2]] universe = Universe(params=params) universe.add_particles([photon, neutrino_e, sterile]) universe.interactions += interaction params.update(universe.total_energy_density(), universe.total_entropy()) universe.update_particles() universe.init_interactions() collision_integral = sterile.collision_integrals[0].integrate(sterile.grid.TEMPLATE) theo_value = (CONST.G_F * theta)**2 * sterile.mass**5 / (192 * numpy.pi**3) / UNITS.MeV decay_rate = -(collision_integral * sterile.params.H \ * sterile.conformal_energy(sterile.grid.TEMPLATE) / sterile.conformal_mass \ / sterile._distribution) / UNITS.MeV ratio = decay_rate / theo_value assert any(numpy.abs(val) - 1 < 1e-2 for val in ratio), "Four-particle decay test failed"
def three_particle_decay_test(params): os.environ['SPLIT_COLLISION_INTEGRAL'] = '' photon = Particle(**SMP.photon) neutrino_e = Particle(**SMP.leptons.neutrino_e) sterile = Particle(**NuP.dirac_sterile_neutrino(mass=200 * UNITS.MeV)) neutral_pion = Particle(**SMP.hadrons.neutral_pion) theta = 1e-2 thetas = defaultdict(float, { 'electron': theta, }) interaction = NuI.sterile_hadrons_interactions( thetas = thetas, sterile=sterile, neutrinos = [neutrino_e], leptons = [], mesons = [neutral_pion], kind = CollisionIntegralKind.F_f_vacuum_decay ) universe = Universe(params=params) universe.add_particles([photon, neutrino_e, sterile, neutral_pion]) universe.interactions += interaction params.update(universe.total_energy_density(), universe.total_entropy()) universe.update_particles() universe.init_interactions() collision_integral = sterile.collision_integrals[0].integrate(sterile.grid.TEMPLATE) theo_value = (CONST.G_F * theta * neutral_pion.decay_constant)**2 \ * sterile.mass**3 * (1 - (neutral_pion.mass / sterile.mass)**2)**2 \ / (16 * numpy.pi) / UNITS.MeV decay_rate = -(collision_integral * sterile.params.H \ * sterile.conformal_energy(sterile.grid.TEMPLATE) / sterile.conformal_mass \ / sterile._distribution) / UNITS.MeV ratio = decay_rate / theo_value assert any(numpy.abs(val) - 1 < 1e-2 for val in ratio), "Three-particle decay test failed"
from particles import Particle from library.SM import particles as SMP, interactions as SMI from library.NuMSM import particles as NuP, interactions as NuI from evolution import Universe from common import UNITS, Params folder = os.path.join(os.path.split(__file__)[0], 'output') T_initial = 200 * UNITS.MeV T_final = 50 * UNITS.MeV params = Params(T=T_initial, dy=0.025) universe = Universe(params=params, logfile=os.path.join(folder, 'log.txt')) photon = Particle(**SMP.photon) electron = Particle(**SMP.leptons.electron) neutrino_e = Particle(**SMP.leptons.neutrino_e) neutral_pion = Particle(**SMP.hadrons.neutral_pion) sterile = Particle(**NuP.sterile_neutrino(300 * UNITS.MeV)) sterile.decoupling_temperature = T_initial universe.add_particles([ photon,
theta = float(args.theta) lifetime = float(args.tau) * UNITS.s Tdec = float(args.Tdec) * UNITS.MeV folder = utils.ensure_dir( op.split(__file__)[0], 'output', "mass={:e}_theta={:e}_Tdec={:e}_tau={:e}".format( mass / UNITS.MeV, theta, Tdec / UNITS.MeV, lifetime / UNITS.s) + args.comment) T_initial = Tdec T_interactions_freeze_out = 0.005 * UNITS.MeV T_final = 0.0008 * UNITS.MeV params = Params(T=T_initial, dy=0.003125) universe = Universe(params=params, folder=folder) photon = Particle(**SMP.photon) electron = Particle(**SMP.leptons.electron) muon = Particle(**SMP.leptons.muon) neutrino_e = Particle(**SMP.leptons.neutrino_e) neutrino_mu = Particle(**SMP.leptons.neutrino_mu) neutrino_tau = Particle(**SMP.leptons.neutrino_tau) sterile = Particle(**NuP.dirac_sterile_neutrino(mass)) from common import LogSpacedGrid linear_grid = LogSpacedGrid() sterile.decoupling_temperature = T_initial for neutrino in [neutrino_e, neutrino_mu, neutrino_tau]: neutrino.decoupling_temperature = 10 * UNITS.MeV
from particles import Particle from evolution import Universe from common import CONST, UNITS, Params params = Params(T=2 * UNITS.MeV, dy=0.025) photon = Particle(**SMP.photon) neutrino = Particle(**SMP.leptons.neutrino_e) neutrino_scattering = CrossGeneratingInteraction( particles=((neutrino, neutrino), (neutrino, neutrino)), antiparticles=((False, True), (False, True)), Ms=(FourParticleM(K1=64 * CONST.G_F**2, order=(0, 1, 2, 3)), ), integral_type=FourParticleIntegral) universe = Universe(params=params) universe.PARALLELIZE = False universe.add_particles([photon, neutrino]) universe.interactions += [neutrino_scattering] import numpy addition = numpy.vectorize(lambda x: 0.1 * numpy.exp(-(x / UNITS.MeV - 3)**2), otypes=[numpy.float_]) neutrino._distribution += addition(neutrino.grid.TEMPLATE) # def check(p=[]): # return neutrino_scattering.F_B(in_p=p[:2], out_p=p[2:]) * (1 - neutrino.distribution(p[0])) \ # - neutrino_scattering.F_A(in_p=p[:2], out_p=p[2:]) * neutrino.distribution(p[0]) # # print [neutrino.distribution(p) - neutrino._distribution_interpolation(p) # # for p in numpy.linspace(neutrino.grid.MIN_MOMENTUM, neutrino.grid.MAX_MOMENTUM,