Added d_phi functions to ps_gen_base.h and fixed bug in d_R function.