Energy density perturbation of massive neutrino: gfortran error

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Diogo Souza
Posts: 3
Joined: July 01 2022
Affiliation: IFT UNESP

Energy density perturbation of massive neutrino: gfortran error

Post by Diogo Souza » December 14 2022

Hello,
I'm trying to reproduce figure 11 of astro-ph/0603494 with massive neutrinos. This figure shows the density contrast for CDM, photons, baryons, massive neutrino,\phi and \psi in the Newtonian gauge. To do this in CAMB I'm following the examples in the jupyter notebook ScalEqs.
For example, the piece of code below

Code: Select all

Delta_photon_N = make_frame_invariant(Delta_g, 'Newtonian') 
ev_photon_N = data.get_time_evolution(k, eta, Delta_photon_N)
gives the evolution for the photon density contrast as function of the conformal time "eta" at the scale "k" in the "Newtonian" gauge. I have checked and this is working for all metric and density perturbation, except for massive neutrinos. The problem with massive neutrinos is in the Newtonian gauge, in the Synchronous this is working. For exemple: The code below run without error

Code: Select all

Delta_nu_sync = make_frame_invariant(Delta_nu, 'CDM') 
ev_nu_sync = data.get_time_evolution(k, eta, Delta_nu_sync)
but the code below return a error

Code: Select all

Delta_nu_N = make_frame_invariant(Delta_nu, 'Newtonian') 
ev_nu_N = data.get_time_evolution(k, eta, Delta_nu_N)
The error is shown below

Code: Select all

gfortran -shared -fPIC -O1 -fmax-errors=4 camb_source12.f90 -o camb_source12.dll
Error compiling generated code:
b'camb_source12.f90:24:45:\n\n   24 |     sources(1) = (-3*adotoa*sigma*(a**2*kappa*p_nu + grhonu_t) + &\n      | 
 1\nError: Symbol \xe2\x80\x98kappa\xe2\x80\x99 at (1) has no IMPLICIT type\ncamb_source12.f90:24:50:\n\n   24 |
      sources(1) = (-3*adotoa*sigma*(a**2*kappa*p_nu + grhonu_t) + &\n      |
 1\nError: Symbol \xe2\x80\x98p_nu\xe2\x80\x99 at (1) has no IMPLICIT type\n'
Source is:
 sources(1) = (-3*adotoa*sigma*(a**2*kappa*p_nu + grhonu_t) + &
    clxnu*grhonu_t*k)/(grhonu_t*k)

---------------------------------------------------------------------------
CalledProcessError                        Traceback (most recent call last)
Input In [79], in <cell line: 17>()
     15 ev_photon = data.get_time_evolution(k, eta, Delta_photon_N)
     16 ev_cdm = data.get_time_evolution(k, eta, Delta_cdm_N)
---> 17 ev_nu = data.get_time_evolution(k, eta, Delta_nu_N)
     18 ev_psi = data.get_time_evolution(k, eta, Psi_N)
     19 ev_phi = data.get_time_evolution(k, eta, Phi_N)

File ~/CAMBVersions/code/CAMB/camb/results.py:550, in CAMBdata.get_time_evolution(self, q, eta, vars, lAccuracyBoost, frame)
    548 if ncustom:
    549     from . import symbolic
--> 550     funcPtr = symbolic.compile_sympy_to_camb_source_func(custom_vars, frame=frame)
    551     custom_source_func = ctypes.cast(funcPtr, ctypes.c_void_p)
    552 else:

File ~/CAMBVersions/code/CAMB/camb/symbolic.py:856, in compile_sympy_to_camb_source_func(sources, code_path, frame)
    854 for i, source in enumerate(sources):
    855     code += camb_fortran(source, 'sources(%s)' % (i + 1), frame=frame) + '\n'
--> 856 return compile_source_function_code(code, file_path=code_path)

File ~/CAMBVersions/code/CAMB/camb/symbolic.py:821, in compile_source_function_code(code_body, file_path, compiler, fflags, cache)
    819 command = " ".join([compiler, fflags, source_file, "-o", dll_name])
    820 try:
--> 821     subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True, cwd=workdir, env=compiler_environ)
    822 except subprocess.CalledProcessError as E:
    823     print(command)

File /usr/lib/python3.10/subprocess.py:420, in check_output(timeout, *popenargs, **kwargs)
    417         empty = b''
    418     kwargs['input'] = empty
--> 420 return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
    421            **kwargs).stdout

File /usr/lib/python3.10/subprocess.py:524, in run(input, capture_output, timeout, check, *popenargs, **kwargs)
    522     retcode = process.poll()
    523     if check and retcode:
--> 524         raise CalledProcessError(retcode, process.args,
    525                                  output=stdout, stderr=stderr)
    526 return CompletedProcess(process.args, retcode, stdout, stderr)

CalledProcessError: Command 'gfortran -shared -fPIC -O1 -fmax-errors=4 camb_source12.f90 -o camb_source12.dll' returned non-zero exit status 1.
At the beginning of the error it says that the symbol "kappa" and "p_nu" as no IMPLICIT type, which is a fortran error. I am using the latest CAMB version 1.3.7.

I will appreciate any help.
Thanks.

Antony Lewis
Posts: 1852
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: Energy density perturbation of massive neutrino: gfortran error

Post by Antony Lewis » December 15 2022

Yes, looks like p_nu is not defined in CAMB, so you'd need to modify the source equations.f90 so that it is defined in custom_sources_func().

Post Reply