Skip to content

Commit

Permalink
add very simple vacuum propagator, mainly as a test of tensor machinery
Browse files Browse the repository at this point in the history
  • Loading branch information
ewanwm committed Jul 8, 2024
1 parent ad8ee0d commit f636140
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
6 changes: 6 additions & 0 deletions nuTens/propagator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@


add_library(propagator STATIC vacuum-propagator.hpp vacuum-propagator.cpp)
target_link_libraries(propagator PUBLIC tensor)

target_include_directories(propagator PUBLIC "${CMAKE_SOURCE_DIR}")
set_target_properties(propagator PROPERTIES LINKER_LANGUAGE CXX)
17 changes: 17 additions & 0 deletions nuTens/propagator/vacuum-propagator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <nuTens/propagator/vacuum-propagator.hpp>


Tensor VacuumPropagator::calculateProbs(){
Tensor weightMatrix;
weightMatrix.ones({1,nGenerations, nGenerations}, NTdtypes::kComplexFloat).requiresGrad(false);

for(int i = 0; i < nGenerations; i++){
weightMatrix.setValue({0, i, "..."}, Tensor::exp(Tensor::div(Tensor::scale(Tensor::mul(masses, masses), -1.0j * baseline), Tensor::scale(energies, 2.0))));
}
weightMatrix.requiresGrad(true);

Tensor sqrtProbabilities = Tensor::matmul(PMNSmatrix.conj(), Tensor::transpose(Tensor::mul(PMNSmatrix, weightMatrix), 1, 2));
Tensor probabilities = Tensor::mul(sqrtProbabilities.abs(), sqrtProbabilities.abs());

return probabilities;
}
37 changes: 37 additions & 0 deletions nuTens/propagator/vacuum-propagator.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#pragma once

#include <nuTens/tensors/tensor.hpp>
#include <vector>

class VacuumPropagator{

public:

VacuumPropagator(int nGenerations, float baseline)
:
baseline(baseline),
nGenerations(nGenerations)
{};

Tensor calculateProbs();

/// @name Setters
/// @{
void setEnergies(Tensor newEnergies){ energies = newEnergies; }

void setMasses(Tensor newMasses){ masses = newMasses; }

inline void setPMNS(Tensor newPMNS){ PMNSmatrix = newPMNS; }

inline void setPMNS(const std::vector<int> &indices, float value){ PMNSmatrix.setValue(indices, value); }

inline void setPMNS(const std::vector<int> &indices, std::complex<float> value){ PMNSmatrix.setValue(indices, value); }
/// @}

private:
Tensor PMNSmatrix;
Tensor masses;
Tensor energies;
int nGenerations;
float baseline;
};

0 comments on commit f636140

Please sign in to comment.