Skip to content

Commit

Permalink
raise error for w+wa>0; avoid some hard errors and require py>=3.7 fo…
Browse files Browse the repository at this point in the history
…r scipy compatibility
  • Loading branch information
cmbant committed Jan 13, 2021
1 parent 3a90f29 commit 1d81358
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
6 changes: 0 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ jobs:
- PYDIST="ANACONDA"
- FORTRAN="test"
python: "3.9"
- name: "Ubuntu 18.04 + Python 3.6"
addons:
apt:
packages:
- gfortran
python: "3.6"
- name: "Ubuntu 20.04 + Python 3.8"
dist: focal
addons:
Expand Down
Binary file modified camb/cambdll.dll
Binary file not shown.
10 changes: 8 additions & 2 deletions camb/dark_energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def set_params(self, w=-1.0, wa=0, cs2=1.0):
self.cs2 = cs2
self.validate_params()

def validate_params(self):
if not self.use_tabulated_w and self.wa + self.w > 0:
raise CAMBError('dark energy model has w + wa > 0, giving w>0 at high redshift')

def set_w_a_table(self, a, w):
"""
Set w(a) from numerical values (used as cublic spline). Note this is quite slow.
Expand Down Expand Up @@ -80,8 +84,10 @@ class DarkEnergyFluid(DarkEnergyEqnOfState):
_fortran_class_name_ = 'TDarkEnergyFluid'

def validate_params(self):
if not self.use_tabulated_w and self.wa and (self.w < -1 - 1e-6 or 1 + self.w + self.wa < - 1e-6):
raise CAMBError('fluid dark energy model does not support w crossing -1')
super().validate_params()
if not self.use_tabulated_w:
if self.wa and (self.w < -1 - 1e-6 or 1 + self.w + self.wa < - 1e-6):
raise CAMBError('fluid dark energy model does not support w crossing -1')


@fortran_class
Expand Down
4 changes: 4 additions & 0 deletions fortran/DarkEnergyInterface.f90
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ subroutine TDarkEnergyEqnOfState_ReadParams(this, Ini)
if(.not. this%use_tabulated_w)then
this%w_lam = Ini%Read_Double('w', -1.d0)
this%wa = Ini%Read_Double('wa', 0.d0)
! trap dark energy becoming important at high redshift
! (will still work if this test is removed in some cases)
if (this%w_lam + this%wa > 0) &
error stop 'w + wa > 0, giving w>0 at high redshift'
else
call File%LoadTxt(Ini%Read_String('wafile'), table)
call this%SetwTable(table(:,1),table(:,2), size(table(:,1)))
Expand Down
6 changes: 4 additions & 2 deletions fortran/cmbmain.f90
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ module CAMBmain
integer maximum_l !Max value of l to compute
real(dl) :: maximum_qeta = 3000._dl

integer :: l_smooth_sample = 3000 !assume transfer functions effectively small for k>2*l_smooth_sample
integer :: l_smooth_sample = 3000 !assume transfer functions effectively small for k*chi0>2*l_smooth_sample

integer :: max_bessels_l_index = 1000000
real(dl) :: max_bessels_etak = 1000000*2
Expand Down Expand Up @@ -874,14 +874,16 @@ subroutine SetkValuesForSources

q_cmb = 2*l_smooth_sample/State%chi0*SourceAccuracyBoost !assume everything is smooth at l > l_smooth_sample
if (CP%Want_CMB .and. maximum_l > 5000 .and. CP%Accuracy%AccuratePolarization) q_cmb = q_cmb*1.4
q_cmb = max(q_switch*2, q_cmb)
!prevent EE going wild in tail
dksmooth = q_cmb/2/(SourceAccuracyBoost)**2
if (CP%Want_CMB) dksmooth = dksmooth/6

associate(Evolve_q => ThisSources%Evolve_q)
call Evolve_q%Init()
call Evolve_q%Add_delta(qmin, qmax_log, dlnk0, IsLog = .true.)
call Evolve_q%Add_delta(qmax_log, min(qmax,q_switch), dkn1)
if (qmax > qmax_log) &
call Evolve_q%Add_delta(qmax_log, min(qmax,q_switch), dkn1)
if (qmax > q_switch) then
call Evolve_q%Add_delta(q_switch, min(q_cmb,qmax), dkn2)
if (qmax > q_cmb) then
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,11 @@ def run(self):
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering :: Astronomy',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9'
],
keywords=['cosmology', 'CAMB', 'CMB'],
install_requires=['scipy>=1.0', 'sympy>=1.0'],
python_requires='>=3.6'
python_requires='>=3.7'
)

0 comments on commit 1d81358

Please sign in to comment.