Skip to content

Commit

Permalink
Removed some dependencies on libraries/utilities.h
Browse files Browse the repository at this point in the history
  • Loading branch information
aemccoy committed Mar 19, 2021
1 parent c736a00 commit aa7c4b3
Show file tree
Hide file tree
Showing 19 changed files with 365 additions and 105 deletions.
2 changes: 1 addition & 1 deletion libraries/lsu3shell/lsu3shell_rme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ namespace lsu3shell
double residual = std::fabs(rme2-rme1);
++entries_compared;
max_residual = std::max(max_residual,residual);
total_sqr_residual += sqr(residual);
total_sqr_residual += mcutils::sqr(residual);
bool entries_agree = (residual <= tolerance);
// std::cout<<std::endl<<fmt::format("residual {} tolerance {} bool {}", residual,tolerance,entries_agree)<<std::endl<<std::endl;
success &= entries_agree;
Expand Down
16 changes: 8 additions & 8 deletions libraries/moshinsky/moshinsky_xform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
****************************************************************/
#include <cmath>
#include "fmt/format.h"

#include "am/halfint.h"
#include "sp3rlib/u3coef.h"
#include "moshinsky/moshinsky_xform.h"

#include "mcutils/gsl.h"
extern double zero_threshold;

namespace u3shell
Expand All @@ -22,11 +22,11 @@ namespace u3shell
int Kmax=std::max(std::max(int(J+M),int(J-M)),int(J-Mp));

for(int K=0; K<=Kmax; K++)
moshinsky_coef+=parity(K)*Choose(int(J+M),int(J-Mp-K))*Choose(int(J-M),K);
moshinsky_coef+=ParitySign(K)*mcutils::Choose(int(J+M),int(J-Mp-K))*mcutils::Choose(int(J-M),K);
moshinsky_coef
*=parity(int(J-Mp))
*sqrt(Factorial(int(J+Mp))*Factorial(int(J-Mp))
/(pow(2.,TwiceValue(J))*Factorial(int(J+M))*Factorial(int(J-M)))
*=ParitySign(int(J-Mp))
*sqrt(mcutils::Factorial(int(J+Mp))*mcutils::Factorial(int(J-Mp))
/(pow(2.,TwiceValue(J))*mcutils::Factorial(int(J+M))*mcutils::Factorial(int(J-M)))
);
return moshinsky_coef;
}
Expand Down Expand Up @@ -116,7 +116,7 @@ namespace u3shell
// int exchange_phase=phase_even?1:-1;
// overall factor for the bra
// the factor of 1/sqrt(1+delta) comes from the normalization for particles in the same shell
double coef=norm?(1./std::sqrt(1.+KroneckerDelta(eta1p,eta2p))):1;
double coef=norm?(1./std::sqrt(1.+mcutils::KroneckerDelta(eta1p,eta2p))):1;
bra_moshinky_12(bra_state_index,0)=coef*MoshinskyCoefficient(etap, eta_cm, eta1p, eta2p,xp);
}
// iterate over ket subspace
Expand All @@ -129,7 +129,7 @@ namespace u3shell

// overall factor for the ket
// the factor of 1/sqrt(1+delta) comes from the normalization for particles in the same shell
double coef=norm?(1./std::sqrt(1.+KroneckerDelta(eta1,eta2))):1;
double coef=norm?(1./std::sqrt(1.+mcutils::KroneckerDelta(eta1,eta2))):1;
ket_moshinky_12(0,ket_state_index)=coef*MoshinskyCoefficient(eta, eta_cm,eta1,eta2,x);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions libraries/moshinsky/moshinsky_xform.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
TransformRelativeUnitTensorToTwobodyTensor.
Renamed MoshinskyTransformUnitTensor to
MoshinskyTransformTensor.
3/19/21 (aem): Removed dependence on utilities/utilities.h in favor of mcutils
****************************************************************/

#ifndef MOSHINSKY_H_
Expand Down
4 changes: 2 additions & 2 deletions libraries/moshinsky/relative_cm_xform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace u3shell
u3shell::RelativeCMBraketNLST braket_rel_cm(L0,S0,T0,bra_rel_cm,ket_rel_cm);
rel_cm_lst_map[braket_rel_cm]
=am::Unitary9J(L0,0,L0,Lr,Lcm,L,Lrp,Lcm,Lp)
*parity(Lr+Lrp+L+Lp)*rme_rel;
*ParitySign(Lr+Lrp+L+Lp)*rme_rel;
}
}
}
Expand Down Expand Up @@ -124,7 +124,7 @@ namespace u3shell
{
u3shell::RelativeCMUnitTensorLabelsU3ST tensor_cm(x0,S0,T0,rho0,bra,ket);
relative_cm_u3st_map[tensor_cm]
=//parity(x.lambda()+x.mu()+xp.lambda()+xp.mu()+Np+N)
=//ParitySign(x.lambda()+x.mu()+xp.lambda()+xp.mu()+Np+N)
u3::U(x0,xr,xp,x_cm,xrp,1,1,x,1,rho0);
}
}
Expand Down
5 changes: 3 additions & 2 deletions libraries/sp3rlib/u3.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
#include "am/halfint.h"
#include "am/am.h"
#include "sp3rlib/multiplicity_tagged.h"
#include "utilities/utilities.h"
#include "mcutils/arithmetic.h"
// #include "utilities/utilities.h"

namespace u3
{
Expand Down Expand Up @@ -156,7 +157,7 @@ namespace u3
inline double Casimir2( const u3::SU3& x)
//Second order Casimir
{
return 2./3*(sqr(x.lambda())+x.lambda()*x.mu()+sqr(x.mu())+3*x.lambda()+3*x.mu());
return 2./3*(mcutils::sqr(x.lambda())+x.lambda()*x.mu()+mcutils::sqr(x.mu())+3*x.lambda()+3*x.mu());
}

inline double Casimir3(const u3::SU3& x)
Expand Down
9 changes: 5 additions & 4 deletions libraries/sp3rlib/vcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@

#include <eigen3/Eigen/Eigen>
#include <unordered_map>

#include "basis/operator.h"
#include "mcutils/arithmetic.h"
#include "sp3rlib/sp3r.h"

namespace vcs
Expand All @@ -56,9 +57,9 @@ namespace vcs
// (double) : Omega factor
{
double value=0;
value += (2*sqr(double(omega.f1()))-sqr(double(n.f1()))+8*(double(omega.f1())-double(n.f1()))-2*(2*double(omega.f1())-double(n.f1())));
value += (2*sqr(double(omega.f2()))-sqr(double(n.f2()))+8*(double(omega.f2())-double(n.f2()))-4*(2*double(omega.f2())-double(n.f2())));
value += (2*sqr(double(omega.f3()))-sqr(double(n.f3()))+8*(double(omega.f3())-double(n.f3()))-6*(2*double(omega.f3())-double(n.f3())));
value += (2*mcutils::sqr(double(omega.f1()))-mcutils::sqr(double(n.f1()))+8*(double(omega.f1())-double(n.f1()))-2*(2*double(omega.f1())-double(n.f1())));
value += (2*mcutils::sqr(double(omega.f2()))-mcutils::sqr(double(n.f2()))+8*(double(omega.f2())-double(n.f2()))-4*(2*double(omega.f2())-double(n.f2())));
value += (2*mcutils::sqr(double(omega.f3()))-mcutils::sqr(double(n.f3()))+8*(double(omega.f3())-double(n.f3()))-6*(2*double(omega.f3())-double(n.f3())));
return value/4.;

}
Expand Down
1 change: 1 addition & 0 deletions libraries/spncci/recurrence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "sp3rlib/u3coef.h"
#include "spncci/spncci_common.h"
#include "spncci/transform_basis.h"
#include "utilities/utilities.h"

extern double zero_threshold;

Expand Down
2 changes: 1 addition & 1 deletion libraries/u3shell/interaction_truncation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ namespace u3shell
// Read in the interaction from file
basis::RelativeSpaceLSJT relative_space_lsjt;
std::array<basis::RelativeSectorsLSJT,3> isospin_component_sectors_lsjt;
std::array<basis::MatrixVector,3> isospin_component_blocks_lsjt;
std::array<basis::OperatorBlocks<double>,3> isospin_component_blocks_lsjt;

basis::RelativeOperatorParametersLSJT operator_labels;

Expand Down
6 changes: 3 additions & 3 deletions libraries/u3shell/relative_branching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace u3shell
u3shell::RelativeStateLabelsNLST ket_nlst(N,L,S,T);
u3shell::RelativeStateSectorNLST sector(L0,S0,T0,bra_nlst,ket_nlst);
// double coef=u3::WCached(w_cache,u3::SU3(N,0), 1,L, x0, kappa0, L0, u3::SU3(Np,0),1,Lp,1);
rmes_nlst[sector]+=parity(n+np)*u3::WCached(w_cache,u3::SU3(N,0), 1,L, x0, kappa0, L0, u3::SU3(Np,0),1,Lp,1)*rme;
rmes_nlst[sector]+=ParitySign(n+np)*u3::WCached(w_cache,u3::SU3(N,0), 1,L, x0, kappa0, L0, u3::SU3(Np,0),1,Lp,1)*rme;
// std::cout<<fmt::format("{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} ",Np,Lp,Sp,Tp,N,L,S,T, x0, kappa0,L0,S0,T0, )
}
}
Expand All @@ -62,7 +62,7 @@ namespace u3shell
const basis::RelativeSpaceLSJT& relative_space_lsjt,
const std::unordered_map<u3shell::RelativeStateSectorNLST,double,boost::hash<u3shell::RelativeStateSectorNLST>>& rmes_nlst,
std::array<basis::RelativeSectorsLSJT,3>& isospin_component_sectors_lsjt,
std::array<basis::MatrixVector,3>& isospin_component_blocks_lsjt
std::array<basis::OperatorBlocks<double>,3>& isospin_component_blocks_lsjt
)

{ // setting up J sectors
Expand Down Expand Up @@ -139,7 +139,7 @@ namespace u3shell
const u3shell::RelativeRMEsU3ST& interaction_u3st,
const basis::RelativeSpaceLSJT& relative_space_lsjt,
std::array<basis::RelativeSectorsLSJT,3>& isospin_component_sectors_lsjt,
std::array<basis::MatrixVector,3>& isospin_component_blocks_lsjt
std::array<basis::OperatorBlocks<double>,3>& isospin_component_blocks_lsjt
)
{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions libraries/u3shell/relative_branching.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ namespace u3shell
const basis::RelativeSpaceLSJT& relative_space_lsjt,
const std::unordered_map<u3shell::RelativeStateSectorNLST,double,boost::hash<u3shell::RelativeStateSectorNLST>>& rmes_nlst,
std::array<basis::RelativeSectorsLSJT,3>& isospin_component_sectors_lsjt,
std::array<basis::MatrixVector,3>& isospin_component_blocks_lsjt
std::array<basis::OperatorBlocks<double>,3>& isospin_component_blocks_lsjt
);
// Branching relative matrix elements from NLST to NLSJT. J-branched rmes stored in block container

void BranchRelativeRMEs(const basis::OperatorLabelsJT& operator_labels,int Nmax, int Jmax,
const u3shell::RelativeRMEsU3ST& interaction_u3st,
const basis::RelativeSpaceLSJT& relative_space_lsjt,
std::array<basis::RelativeSectorsLSJT,3>& isospin_component_sectors_lsjt,
std::array<basis::MatrixVector,3>& isospin_component_blocks_lsjt
std::array<basis::OperatorBlocks<double>,3>& isospin_component_blocks_lsjt
);
// Branch relative rmes from U3ST to NLSJT

Expand Down
4 changes: 2 additions & 2 deletions libraries/u3shell/two_body_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ namespace u3shell {
);
int biquad_grade = eta1+eta2+ConjugationGrade(x)+int(S)+int(T);
double biquad_norm_factor = 1/(
sqrt(1+KroneckerDelta(eta1p,eta2p))
*sqrt(1+KroneckerDelta(eta1,eta2))
sqrt(1+mcutils::KroneckerDelta(eta1p,eta2p))
*sqrt(1+mcutils::KroneckerDelta(eta1,eta2))
);

// iterate over outer multiplicity on cross projector
Expand Down
2 changes: 1 addition & 1 deletion libraries/u3shell/upcoupling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ namespace u3shell
double u3_coef=u3::WCached(w_cache,ket.x(), 1,L, x0, kappa0, L0, bra.x(),1,Lp,1)
*u3::dim(x0)*am::dim(Lp)/(u3::dim(bra.x())*am::dim(L0));
std::tuple<u3shell::RelativeUnitTensorLabelsU3ST,int,int> key(operator_labels,kappa0,L0);
rme_map[key]+=u3_coef*rme_nlst*parity(n+np);
rme_map[key]+=u3_coef*rme_nlst*ParitySign(n+np);
/*if (fabs(rme_map[key]) <= zero_threshold) {
rme_map[key] = 0;
}*/
Expand Down
4 changes: 1 addition & 3 deletions programs/lgi/get_spncci_seed_blocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ files in directory seeds containing:
SPDX-License-Identifier: MIT
12/29/17 (aem): Created.
****************************************************************/
#include <fstream>
Expand Down Expand Up @@ -149,7 +147,7 @@ int main(int argc, char **argv)
////////////////////////////////////////////////////////////////
// std::cout<<"Generate tensors "<<std::endl;
// Get list of unit tensor labels between lgi's
// TODOL change to restrict N0 after testing
// TODO: Can we restrict N0?
bool restrict_positive_N0=false;
std::vector<u3shell::RelativeUnitTensorLabelsU3ST> lgi_unit_tensor_labels;
u3shell::GenerateRelativeUnitTensorLabelsU3ST(
Expand Down
7 changes: 4 additions & 3 deletions programs/operators/generate_relative_u3st_operators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
2/21/17 (aem,mac): Update input parsing. Add parsing checks.
5/14/19 (aem): Updated basis::OperatorLabelsJT to
basis::RelativeOperatorParametersLSJT for reading in operators
3/19/21 (aem) : Removed dependency on utilities/utilities.h
****************************************************************/
#include <iostream>
#include <fstream>
Expand Down Expand Up @@ -107,7 +108,7 @@ namespace u3shell
int kappa0=1;
int L0=0;

double intrinsic_factor=2.*(1.+KroneckerDelta(moshinsky_convention,false))/A;
double intrinsic_factor=2.*(1.+mcutils::KroneckerDelta(moshinsky_convention,false))/A;

for(int N=0; N<=Nmax; N++)
for(int S=0; S<=1; ++S)
Expand Down Expand Up @@ -280,7 +281,7 @@ namespace u3shell
void Tintr(int Nmax,u3shell::RelativeRMEsU3ST& Tintr, int A, double hbar_omega, double coef=1.0, bool moshinsky_convention=false)
{
// Something weird with coef factor. Won't work for moshinsky_convention=true
coef*=hbar_omega/(4*(KroneckerDelta(moshinsky_convention,false)));
coef*=hbar_omega/(4*(mcutils::KroneckerDelta(moshinsky_convention,false)));
k2intr(Nmax,Tintr, A, coef, moshinsky_convention);
}

Expand All @@ -291,7 +292,7 @@ namespace u3shell
// Read in the interaction from file
basis::RelativeSpaceLSJT relative_space_lsjt(Nmax, Jmax);
std::array<basis::RelativeSectorsLSJT,3> isospin_component_sectors_lsjt;
std::array<basis::MatrixVector,3> isospin_component_matrices_lsjt;
std::array<basis::OperatorBlocks<double>,3> isospin_component_matrices_lsjt;
basis::RelativeOperatorParametersLSJT operator_labels;
basis::ReadRelativeOperatorLSJT(
interaction_filename,relative_space_lsjt,operator_labels,
Expand Down
24 changes: 12 additions & 12 deletions programs/rotor/triaxial_rotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace rotor
A.resize(3);
for(int k=1; k<=3; ++k)
{
A[k-1]=alpha/sqr(sin(gamma-2*PI/3*k));
A[k-1]=alpha/mcutils::sqr(sin(gamma-2*PI/3*k));
}
}

Expand Down Expand Up @@ -71,18 +71,18 @@ namespace rotor
GetD(x,lambda,D);

//First coefficient
coefs[0]=lambda[1]*lambda[2]/(2*sqr(lambda[0])+lambda[1]*lambda[2])*A[0];
coefs[0]=coefs[0]+lambda[0]*lambda[2]/(2*sqr(lambda[1])+lambda[0]*lambda[2])*A[1];
coefs[0]=coefs[0]+lambda[0]*lambda[1]/(2*sqr(lambda[2])+lambda[0]*lambda[1])*A[2];
coefs[0]=lambda[1]*lambda[2]/(2*mcutils::sqr(lambda[0])+lambda[1]*lambda[2])*A[0];
coefs[0]=coefs[0]+lambda[0]*lambda[2]/(2*mcutils::sqr(lambda[1])+lambda[0]*lambda[2])*A[1];
coefs[0]=coefs[0]+lambda[0]*lambda[1]/(2*mcutils::sqr(lambda[2])+lambda[0]*lambda[1])*A[2];

//Second coefficient
coefs[1]=lambda[0]/(2*sqr(lambda[0])+lambda[1]*lambda[2])*A[0];
coefs[1]=coefs[1]+lambda[1]/(2*sqr(lambda[1])+lambda[0]*lambda[2])*A[1];
coefs[1]=coefs[1]+lambda[2]/(2*sqr(lambda[2])+lambda[0]*lambda[1])*A[2];
coefs[1]=lambda[0]/(2*mcutils::sqr(lambda[0])+lambda[1]*lambda[2])*A[0];
coefs[1]=coefs[1]+lambda[1]/(2*mcutils::sqr(lambda[1])+lambda[0]*lambda[2])*A[1];
coefs[1]=coefs[1]+lambda[2]/(2*mcutils::sqr(lambda[2])+lambda[0]*lambda[1])*A[2];

coefs[2]=1/(2*sqr(lambda[0])+lambda[1]*lambda[2])*A[0];
coefs[2]=coefs[2]+1/(2*sqr(lambda[1])+lambda[0]*lambda[2])*A[1];
coefs[2]=coefs[2]+1/(2*sqr(lambda[2])+lambda[0]*lambda[1])*A[2];
coefs[2]=1/(2*mcutils::sqr(lambda[0])+lambda[1]*lambda[2])*A[0];
coefs[2]=coefs[2]+1/(2*mcutils::sqr(lambda[1])+lambda[0]*lambda[2])*A[1];
coefs[2]=coefs[2]+1/(2*mcutils::sqr(lambda[2])+lambda[0]*lambda[1])*A[2];


}
Expand Down Expand Up @@ -132,7 +132,7 @@ namespace rotor
// std::cout<<" "
// <<am::Unitary6J(L,m,Lbar,m,L,0)<<" "
// <<ParitySign(L+Lbar+m)*Hat(Lbar)/Hat(L)/Hat(m)<<std::endl;
// // <<sqr(am::Unitary6J(L,1,L,2,Lbar,m))<<" "
// // <<mcutils::sqr(am::Unitary6J(L,1,L,2,Lbar,m))<<" "
// std::cout<<"SU3 coefs "
// <<L<<" "<<Lbar<<" "<<m<<std::endl
// <<kappa<<" "<<kappa_bar<<" "<<kappap<<std::endl
Expand All @@ -142,7 +142,7 @@ namespace rotor

rme+=ParitySign(m)*Hat(m)
*am::Unitary6J(L,m,Lbar,m,L,0)*L*(L+1)
*sqr(am::Unitary6J(L,1,L,2,Lbar,m))
*mcutils::sqr(am::Unitary6J(L,1,L,2,Lbar,m))
*u3::W(x,kappa_bar,Lbar,u3::SU3(1,1),1,2,x,kappap,L,1)
*u3::W(x,kappa,L,u3::SU3(1,1),1,2,x,kappa_bar,Lbar,1);
}
Expand Down
Loading

0 comments on commit aa7c4b3

Please sign in to comment.