Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…_devel into hi_class
  • Loading branch information
Miguel Zumalacarregui committed Sep 18, 2019
2 parents 60a93df + 2782b8c commit e7395f0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
6 changes: 6 additions & 0 deletions python/cclassy.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ cdef extern from "class.h":
double w0_fld
double wa_fld
double cs2_fld
short shooting_failed
int parameters_size_smg
int parameters_2_size_smg
double * parameters_smg
double * parameters_2_smg
int tuning_index_smg
double Omega0_ur
double Omega0_dcdmdr
double Omega0_scf
Expand Down
24 changes: 24 additions & 0 deletions python/classy.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1721,11 +1721,35 @@ cdef class Class:
value = self.sp.sigma8
elif name == 'sigma8_cb':
value = self.sp.sigma8_cb
elif name == 'Omega0_smg' or name == 'Omega_smg':
value = self.Omega0_smg()
elif 'parameters_smg_real' in name:
value = self.__MontePython_ask_for_array_component(name, self.ba.parameters_smg, self.ba.parameters_size_smg)
elif 'parameters_2_smg_real' in name:
value = self.__MontePython_ask_for_array_component(name, self.ba.parameters_2_smg, self.ba.parameters_2_size_smg)
elif name == 'tuning_parameter':
value = self.ba.parameters_smg[self.ba.tuning_index_smg]
else:
raise CosmoSevereError("%s was not recognized as a derived parameter" % name)
derived[name] = value
return derived

cdef __MontePython_ask_for_array_component(self, name, double * carray, carray_size):

try:
index = int(name.split('_')[-1])
except:
print "Index not given or not an interger: printing the whole array"
array = []
for i in range(carray_size):
array.append(carray[i])
return array

if index <= carray_size:
return carray[index-1]
else:
raise CosmoSevereError("%s index is greater than array length" % name)

def nonlinear_scale(self, np.ndarray[DTYPE_t,ndim=1] z, int z_size):
"""
nonlinear_scale(z, z_size)
Expand Down
4 changes: 2 additions & 2 deletions source/background.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ int background_init(
/** - if shooting failed during input, catch the error here */
class_test_except(pba->shooting_failed == _TRUE_,
pba->error_message,
background_free(pba),
background_free_input(pba),
"Shooting failed, try optimising input_get_guess(). Error message:\n\n%s",
pba->shooting_error);

Expand Down Expand Up @@ -1781,7 +1781,7 @@ int background_solve(

class_test_except((tau_end-tau_start)/tau_start < ppr->smallest_allowed_variation,
pba->error_message,
gt_free(&gTable);cleanup_generic_integrator(&gi);background_free(pba);free(pvecback_integration);free(pvecback),
gt_free(&gTable);cleanup_generic_integrator(&gi);background_free_input(pba);free(pvecback_integration);free(pvecback),
"integration step: relative change in time =%e < machine precision : leads either to numerical error or infinite loop",(tau_end-tau_start)/tau_start);

/* -> save data in growTable */
Expand Down

0 comments on commit e7395f0

Please sign in to comment.