alex-mcdaniel / RX-DMFIT

A tool used for calculating the expected secondary emission from DM annihilation and placing constraints on dark matter properties, incorporating important astrophysics including the diffusion of charged particles, relevant radiative energy losses, and magnetic field modelling.
12 stars 5 forks source link

Error when running example1 #1

Open Nthabi83 opened 5 years ago

Nthabi83 commented 5 years ago

Hey I am interested in using your code for my PhD research and I came across an error when running example1 and example 2. I am using DarkSUSY-6.0.0 instead of the 5.1.2 because the older versions have been removed from the DarkSUSY page, I am not sure if that is what's causing the problem. This is the error from the terminal:

nthabiseng:~/RX-DMFIT-master$ make example1 g++ -o example1 Constants.cpp Target.cpp bfield.cpp DM_profile.cpp greens.cpp diffusion.cpp dist.cpp psyn.cpp pIC.cpp emissivity.cpp surface_brightness_profile.cpp flux.cpp calc_sv.cpp run.cpp example1.cpp \ -I//home/nthabiseng/darksusy-6.0.0/include -L//home/nthabiseng/darksusy-6.0.0/lib \ -lgsl -lgslcblas -ldarksusy -lFH -lHB -lgfortran /usr/bin/ld: cannot find -ldarksusy collect2: error: ld returned 1 exit status makefile:14: recipe for target 'example1' failed make: *** [example1] Error 1

please assist if possible

alex-mcdaniel commented 5 years ago

Yea this is a version conflict. In the DarkSUSY 5 versions the main library used was libdarksusy, but if you go into home/nthabiseng/darksusy-6.0.0/lib you'll see that libdarksusy does not exist so you get the “cannot find -ldarksusy” error. Instead in DarkSUSY 6 there are several libraries like libds_core.a, libds_mssm.a, libds_generic_wimp.a, etc. due to how DarkSUSY is restructured in the newer version. So, to fix this you can go into the makefile and replace:

LDLIBS = -lgsl -lgslcblas -ldarksusy -lFH -lHB -lgfortran

with:

LDLIBS = -lgsl -lgslcblas \
-lcfitsio        -lds_generic_decayingDM       -lds_mssm_user          -lFH       -lHS  \
-lds_core        -lds_generic_decayingDM_user  -lds_silveira_zee       -lgif      -lisajet  \
-lds_core_user   -lds_generic_wimp             -lds_silveira_zee_user  -lHB       -lisospin  \
-lds_empty       -lds_generic_wimp_user        -lds_vdSIDM             -lhealpix  -lsharp_healpix_f  \
-lds_empty_user  -lds_mssm                     -lds_vdSIDM_user        -lhpxgif   \
-lgfortran

To give the correct libraries for DarkSUSY 6. You will also need to account for the fact that DarkSUSY 6 changed several routines from the DarkSUSY 5 versions. In RX-DMFIT, the only DarkSUSY routines (version 5) used are dsinit.f which initializes DarkSUSY, and dshayield.f which gives the injection spectrum from annihilations. You don’t need to do anything differently for dsinit, but dshayield was changed to dsanyieldsim.f. More details about the routines are described in the long form DarkSUSY manual, but basically all that needs to be done is change the function call in the RX-DMFIT header file Darksusy.h and then make sure that the correct functions and arguments are passed in the RX-DMFIT file diffusion.cpp. So in Darksusy.h replace `double dshayield(double mwimp, double emuthr, int ch, int yieldk, int istat); with double dsanyieldsim(double mwimp, double e, int pdg, char hel, int yieldpdg, int diff, int istat); ` and in diffusion.cpp replace the darksusy function with:

double darksusy (double Ep){
    char hel='O';
    int yieldpdg = -11;
    int diff = 1;
    int istat;
    int ch_WW = 24;
    int ch_mumu = 13;
    int ch_tautau = 15;
    int ch_bb = 5;
    double ds = 0;

    if (Target::p.BR_WW !=0){
        ds += Target::p.BR_WW * dsanyield_sim_(&Target::p.mx, &Ep, &ch_WW, &hel, &yieldpdg, &diff, &istat);
    }
    if (Target::p.BR_mumu !=0){
        ds += Target::p.BR_mumu * dsanyield_sim_(&Target::p.mx, &Ep, &ch_mumu, &hel, &yieldpdg, &diff, &istat);
    }
    if (Target::p.BR_tautau !=0){
        ds += Target::p.BR_tautau * dsanyield_sim_(&Target::p.mx, &Ep, &ch_tautau, &hel, &yieldpdg, &diff, &istat);
    }
    if (Target::p.BR_bb !=0){
        ds += Target::p.BR_bb * dsanyield_sim_(&Target::p.mx, &Ep, &ch_bb, &hel, &yieldpdg, &diff, &istat);
    }

    return ds;
}

Do the same thing with darksusy_gamma but set yieldpdg = 111 instead.

After these changes I was able to run the examples with DarkSUSY 6.2.0 and output seems to be correct. Thanks for bringing this up! I wasn't aware that the older versions of DarkSUSY were being removed. I'll try to get a proper update to the code posted soon.

EDIT: Corrected the WW channel ID from 25->24

Nthabi83 commented 5 years ago

Hey Thank you for your reply, I have made the changes but It's now complaining about the "Ep" parameter in diffusion.cpp the error is:

nthabiseng:~/RX-DMFIT-master$ make example1
g++ -o example1 Constants.cpp Target.cpp bfield.cpp DM_profile.cpp greens.cpp diffusion.cpp dist.cpp psyn.cpp pIC.cpp emissivity.cpp surface_brightness_profile.cpp flux.cpp calc_sv.cpp run.cpp example1.cpp  \
 -I//home/nthabiseng/darksusy-6.0.0/include -L//home/nthabiseng/darksusy-6.0.0/lib \
 -lgsl -lgslcblas -lcfitsio -lds_generic_decayingDM -lds_mssm_user -lFH -lHS -lds_core -lds_generic_decayingDM_user -lds_silveira_zee -lgif -lisajet -lds_core_user -lds_generic_wimp -lds_silveira_zee_user -lHB -lisospin -lds_empty -lds_generic_wimp_user -lds_vdSIDM -lhealpix -lsharp_healpix_f -lds_empty_user -lds_mssm -lds_vdSIDM_user -lhpxgif -lgfortran
diffusion.cpp: In function ‘double darksusy_gamma(double)’:
diffusion.cpp:39:58: error: ‘Ep’ was not declared in this scope
   ds += Target::p.BR_WW * dsanyield_sim_(&Target::p.mx, &Ep, &ch_WW, &hel, &yieldpdg, &diff, &istat);
                                                          ^
diffusion.cpp:45:60: error: ‘Ep’ was not declared in this scope
   ds += Target::p.BR_mumu * dsanyield_sim_(&Target::p.mx, &Ep, &ch_mumu, &hel, &yieldpdg, &diff, &istat);
                                                            ^
diffusion.cpp:51:62: error: ‘Ep’ was not declared in this scope
   ds += Target::p.BR_tautau * dsanyield_sim_(&Target::p.mx, &Ep, &ch_tautau, &hel, &yieldpdg, &diff, &istat);
                                                              ^
diffusion.cpp:57:58: error: ‘Ep’ was not declared in this scope
   ds += Target::p.BR_bb * dsanyield_sim_(&Target::p.mx, &Ep, &ch_bb, &hel, &yieldpdg, &diff, &istat);
                                                          ^
makefile:14: recipe for target 'example1' failed
make: *** [example1] Error 1

please assist, I also get the same error when I tried the DarkSUSY-6.2.0 version.

alex-mcdaniel commented 5 years ago

For darksusy_gamma the Ep should be Egamma as in the original version. So replace the Eps in that function with Egamma and it should run. You want to make sure that the variables match what’s in the header file.

This should work:

double darksusy_gamma (double Egamma){
    char hel='O';
    int yieldpdg = 111;
    int istat;
    int diff = 1;

    int ch_WW = 25;
    int ch_mumu = 13;
    int ch_tautau = 15;
    int ch_bb = 5;

    double ds = 0;

    if (Target::p.BR_WW !=0){
        ds += Target::p.BR_WW * dsanyield_sim_(&Target::p.mx, &Egamma, &ch_WW, &hel, &yieldpdg, &diff, &istat);
    }
    if (Target::p.BR_mumu !=0){
        ds += Target::p.BR_mumu * dsanyield_sim_(&Target::p.mx, &Egamma, &ch_mumu, &hel, &yieldpdg, &diff, &istat);
    }
    if (Target::p.BR_tautau !=0){
        ds += Target::p.BR_tautau * dsanyield_sim_(&Target::p.mx, &Egamma, &ch_tautau, &hel, &yieldpdg, &diff, &istat);
    }
    if (Target::p.BR_bb !=0){
        ds += Target::p.BR_bb * dsanyield_sim_(&Target::p.mx, &Egamma, &ch_bb, &hel, &yieldpdg, &diff, &istat);
    }

    return ds;
}
Nthabi83 commented 5 years ago

Yes it's now working, Thank you.