Skip to content

File PITensor.h

File List > code_source > cosmolattice > include > CosmoInterface > definitions > PITensor.h

Go to the documentation of this file

#ifndef COSMOINTERFACE_HELPERS_PITENSOR_H
#define COSMOINTERFACE_HELPERS_PITENSOR_H

/* This file is part of CosmoLattice, available at www.cosmolattice.net .
   Copyright Daniel G. Figueroa, Adrien Florio, Francisco Torrenti and Wessel Valkenburg.
   Released under the MIT license, see LICENSE.md. */

// File info: Main contributor(s): Jorge Baeza-Ballesteros, Adrien Florio, Nicolás Layza,  Year: 2022

#include "TempLat/util/rangeiteration/tagliteral.h"
#include "TempLat/lattice/algebra/complexalgebra/complexalgebra.h"
#include "TempLat/lattice/algebra/su2algebra/su2algebra.h"
#include "CosmoInterface/definitions/gaugederivatives.h"
#include "TempLat/lattice/algebra/gaugealgebra/forwardcovariantderivative.h"
#include "TempLat/lattice/algebra/su2algebra/su2multiply.h"
#include "TempLat/lattice/algebra/gaugealgebra/fieldstrength.h"
#include "TempLat/lattice/algebra/matrix3x3algebra/symtracelesswrapper.h"
#include "TempLat/lattice/algebra/gaugealgebra/plaquette.h"
#include "TempLat/lattice/algebra/operators/power.h"
#include "TempLat/lattice/algebra/spatialderivatives/normgradientsquare.h"
#include "TempLat/lattice/algebra/operators/operators.h"

namespace TempLat
{
  class PITensor
  {
  public:
    // Put public methods here. These should change very little over time.
    PITensor() = delete;


    template<class Model> requires (Model::NDim != 3)
    static inline auto effectiveAnisotropicTensor(Model& model)
    {
      return ZeroType();
    }

    template<class Model> requires (Model::NDim == 3)
    static inline auto effectiveAnisotropicTensor(Model &model)
    {
      return ConstructSymTraceless(effectiveAnisotropicTensor(model, 1_c, 1_c),
                                   effectiveAnisotropicTensor(model, 1_c, 2_c),
                                   effectiveAnisotropicTensor(model, 1_c, 3_c),
                                   effectiveAnisotropicTensor(model, 2_c, 2_c),
                                   effectiveAnisotropicTensor(model, 2_c, 3_c),
                                   effectiveAnisotropicTensor(model, 3_c, 3_c));

    }

  private:
    // @label:pitensor_total_source
    template <class Model, int I, int J> static inline auto effectiveAnisotropicTensor(Model &model, Tag<I> i, Tag<J> j)
    {
      return scalarSingletContribution(model, i, j) + complexScalarContribution(model, i, j) + electricU1Contribution(model, i, j) +
             magneticU1Contribution(model, i, j);
    }
    // @endlabel

    // @label:pitensor_singlet_source
    template <class Model, int I, int J> static inline auto scalarSingletContribution(Model &model, Tag<I> i, Tag<J> j)
    {
      return Total(a, 0, Model::Ns - 1, forwDiff(model.fldS(a), i) * forwDiff(model.fldS(a), j));
    }
    // @endlabel

    // @label:pitensor_complex_source
    template <class Model, int I, int J> static inline auto complexScalarContribution(Model &model, Tag<I> i, Tag<J> j)
    {
      return Total(a, 0, Model::NCs - 1,
                   2 * Real(GaugeDerivatives::forwardCovGradientCS(model, a, i) *
                            conj(GaugeDerivatives::forwardCovGradientCS(model, a, j))));
    }
    // @endlabel

    // @label:pitensor_u1_source
    template <class Model, int I, int J> static inline auto electricU1Contribution(const Model &model, Tag<I> i, Tag<J> j)
    {
      return Total(a, 0, Model::NU1 - 1,
                   -1. / pow<2>(model.aI) / pow<2>(model.fStar / model.omegaStar) * model.piU1(a)(i) *
                       model.piU1(a)(j)
                   * IfElse(Model::DefectsModel, model.resolutionPreservingFactor, OneType())
                   );
    }

    template <class Model, int I, int J> static inline auto magneticU1Contribution(const Model &model, Tag<I> i, Tag<J> j)
    {
      return Total(a, 0, Model::NU1 - 1,
                   -1. / pow<2>(model.aI) / pow<2>(model.fStar / model.omegaStar) * magneticFieldU1(model.fldU1(a), i) *
                       magneticFieldU1(model.fldU1(a), j)
                   / IfElse(Model::DefectsModel, model.resolutionPreservingFactor, OneType()));
    }
    // @endlabel

    // @label:pitensor_u1_magnetic_field
    template <class Field> static inline auto magneticFieldU1(const Field &f, Tag<1>)
    {
      return fieldStrength(f, 2_c, 3_c);
    }

    template <class Field> static inline auto magneticFieldU1(const Field &f, Tag<2>)
    {
      return fieldStrength(f, 3_c, 1_c);
    }

    template <class Field> static inline auto magneticFieldU1(const Field &f, Tag<3>)
    {
      return fieldStrength(f, 1_c, 2_c);
    }
    // @endlabel
  };
} // namespace TempLat

#endif