lesgourg / class_public

Public repository of the Cosmic Linear Anisotropy Solving System (master for the most recent version of the standard code; GW_CLASS to include Cosmic Gravitational Wave Background anisotropies; classnet branch for acceleration with neutral networks; ExoCLASS branch for exotic energy injection; class_matter branch for FFTlog)
230 stars 285 forks source link

Error in classy when choosing more than one contribution for 'number count contributions' #256

Closed KalusB closed 5 years ago

KalusB commented 5 years ago

Hiya,

I have written the following python function to compute the density Cls for a given set of cosmological parameters.

cpdef np.ndarray Cl(double A_s, double n_s, double h, double omega_b, double omega_cdm, bint C):
    cdef dict params
    if C:
        params = {
        'output': 'dCl, mPk',
        'A_s': A_s,
        'n_s': n_s,
        'h': h,
        'omega_b': omega_b,
        'omega_cdm': omega_cdm,
        'selection_mean': bins_z_str+str(zbins[-1]),
        'non_diagonal': len(zbins)-1,
        'selection_magnification_bias_analytic': 'yes',
        'selection_bias_analytic': 'yes',
        'selection_dNdz_evolution_analytic': 'yes',
        'number count contributions': 'density, rsd, lensing, gr'}
    else:
        params = {
        'output': 'dCl, mPk',
        'A_s': A_s,
        'n_s': n_s,
        'h': h,
        'omega_b': omega_b,
        'omega_cdm': omega_cdm,
        'selection_mean': bins_z_str+str(zbins[-1]),
        'non_diagonal': len(zbins)-1,
        'selection_magnification_bias_analytic': 'yes',
        'selection_bias_analytic': 'yes',
        'selection_dNdz_evolution_analytic': 'yes',
        'number count contributions': 'density'}

    cosmo = classy.Class()
    cosmo.set(params)
    cosmo.compute()
    cdef dict densCl = cosmo.density_cl()['dd']
    cdef np.ndarray ret = np.empty((len(densCl),len(densCl[0][2:])))
    cdef int i
    for i in np.arange(len(densCl)):
        ret[i]=densCl[i][2:]
    return ret

The code works fine for C=False, thus when setting 'number count contributions' to 'density' only. It also works fine if I set them to another one word setting such as 'rsd' only. However, if I want to include all possible setting, such as in the code above, I get the following errors:

Error in python': free(): invalid next size (fast): 0x00007fb224031b70 Error in ======= Backtrace: ========= Error in python': free(): invalid next size (fast): 0x/lib64/libc.so.6(+0x81499)[0x7fbb762e3499] /home/bkalus/class_3Dcorr/python/build/lib.linux-x86_64-2.7/classy.so(transfer_source_resample+0x140)[0x7fbb65c5a270] /home/bkalus/class_3Dcorr/python/build/lib.linux-x86_64-2.7/classy.so(transfer_sources+0x5d0 Error in /home/bkalus/class_3Dcorr/python/build/lib.linux-x86_64-2.7/classy.so(transfer_compute_for_each_q+0x3d7)[0x7fbb65c64a17] /home/bkalus/class_3Dcorr/python/build/lib.linux-x86_64-2.7/classy.so(+0x12907b)[0x7fbb65c6507b] Error in python': free(): invalid next size (fast): 0x00007fbb50031a80 Error in python': free(): invalid next size (fast): 0x00007fb704031a50 /opt/anaconda2/lib/python2.7/site-packages/numpy/../../../libiomp5.so( Error in Error in python': free(): invalid next size (fast): 0x00007fb820031a50 Error in python': free(): invalid next size (fast): 0x00007fb1e4031a50 Error in python': free(): invalid next size (fast): 0x00007fb1ec031a50 Error in python': free(): invalid next size (fast): 0x00007fb2f4031a50 __kmp_invoke_microtaskpython': free(): invalid next size (fast): 0x00007fb834031a50 /opt/anaconda2/lib/python2.7/site-packages/numpy/../../../libiomp5.so(+0x Error in python': free(): invalid next size (fast): 0x00007fbb20031a50 b5fa4 Error in /lib64/libpthread.so.0(+0x7e25)[0x7fbb76d3fe25] /lib64/libc.so.6(clone+0x6d)[0x7fbb76360bad] ======= Memory map: ======== Error in python': free(): invalid next size (fast): 0x00007fba70031a50 python': free(): invalid next size (fast): 0x00007fb5e4031a50 Error in Error in python': free(): invalid next size (fast): 0x00007fb978031a50 Error in Error in python': free(): invalid next size (fast): 0x00007fb5cc031a50 pythonpython': free(): invalid next size (fast): 0x00007fb9e0031a50 Error in python': free(): invalid next size (fast): 0x00007fb544031a50 Error in python': free(): invalid next size (fast): 0x00007fb1d4031a50 Error in python': free(): invalid next size (fast)======= Backtrace: ========= /lib64/libc.so.6(+0x81499)[0x7fbb762e3499] /home/bkalus/class_3Dcorr/python/build/lib.linux-x86_64-2.7/classy.so(transfer_source_resample+0x140)[0x7fbb65c5a270] /home/bkalus/class_3Dcorr/python/build/lib.linux-x86_64-2.7/classy.so(transfer_sources+0x5d0)[0x7fbb65c61660] /home/bkalus/class_3Dcorr/python/build/lib.linux-x86_64-2.7/classy.so(transfer_compute_for_each_q+0x3d7)[0x7fbb65c64a17] /home/bkalus/class_3Dcorr/python/build/lib.linux-x86_64-2.7/classy.so(+0x12907b)[0x7fbb65c6507b] /opt/anaconda2/lib/python2.7/site-packages/numpy/../../../libiomp5.so(__kmp_invoke_microtask+0x93)[0x7fbb6d69bac3] /opt/anaconda2/lib/python2.7/site-packages/numpy/../../../libiomp5.so(+0x84257): 0x00007fb404031a50 /opt/anaconda2/lib/python2.7/site-packages/numpy/../../../libiomp5.so(+0xb5fa4)[0x7fbb6d69bfa4] /lib64/libpthread.so.0(+0x7e25)[0x7fbb76d3fe25] /lib64/libc.so.6(clone+0x6d)[0x7fbb76360bad] ======= Memory map: ======== Error in python': free(): invalid next size (fast): 0x00007fb2c8031a50 Error in python': free(): invalid next size (fast): 0x00007fb9b0031a50 Error in python': free(): invalid next size (fast): 0x00007fba24031a50 Error in python': free(): invalid next size (fast): 0x00007fb324031a50 Error in python': free(): invalid next size (fast): 0x00007fb7fc031a50 Error in python': free(): invalid next size (fast): 0x00007fb220031a50 Error in python': free(): invalid next size (fast): 0x00007fb488031a50 Error in python': free(): invalid next size (fast): 0x00007fb31c031a50 Error in python': free(): invalid next size (fast): 0x00007fb23c031a50 Error in python': Error in python': free(): invalid next size (fast): 0x00007fb200031a50 Error in `python': free(): invalid next size (fast): 0x00007fb588031a50 *** Aborted (core dumped)

Am I doing something wrong here? Thank you very much for your help.

KalusB commented 5 years ago

It turned out that the spaces in the parameter list caused the error. It works perfectly fine if it's 'number count contributions': 'density,rsd,lensing,gr'