dkirkby / randomfield

Generate random fields for cosmology
2 stars 2 forks source link

Adding numerical integration of growth function #4

Open kgage opened 8 years ago

kgage commented 8 years ago

While the package already contains an approximation of the growth function, it is possible to add the ability to integrate the differential equation to calculate the growth function using the ode class in scipy.integrate. This method would be more time consuming than using the approximation (and for many cosmological models the approximation differs from the numerically integrated answer by < 1%), but it might be useful. Since the ode class will output values for both the growth function and its derivative, I created a potential function that outputs the information as a structured array with columns 'G' and 'Gp' (I figured having a p for prime made more sense than using an apostrophe and forcing people to type "G'".)

dkirkby commented 8 years ago

It would be useful to convert the returned the derivative into the usual log-derivative d(log(G)) / d(log(a)).

kgage commented 8 years ago

I've worked the function out to now return either dG/dz or d(lnG)/d(lna) based on a boolean input to the function. Would it perhaps be better to always output both? (Make the output array have 3 columns 'G', 'd_G', and 'd_lnG')