Skip to content

Commit

Permalink
version 0.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvin Chua committed Nov 9, 2018
1 parent ddeb6a3 commit 9473b3c
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 22 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -32,6 +32,8 @@
bin/*
lib/*
*~
build/*
AAKwrapper/AAKwrapper.cpp
AAKwrapper/__pycache__/*
AAKwrapper.egg-info/*
build/*
dist/*
21 changes: 11 additions & 10 deletions AAKwrapper/AAKwrapper.pyx
Expand Up @@ -39,7 +39,7 @@ cdef extern from "AAKpy.h":
double AAKwave(SetPar& AAK, double *t, double *hI, double *hII)

cdef extern from "AAKpy.h":
double AAKphase(SetPar &AAK, double *t, double *phase_r, double *phase_theta, double *phase_phi, double *omega_r, double *omega_theta, double *omega_phi)
double AAKphase(SetPar &AAK, double *t, double *phase_r, double *phase_theta, double *phase_phi, double *omega_r, double *omega_theta, double *omega_phi, double *eccentricity)

def wave(pars = {}):
cdef SetPar setpar
Expand Down Expand Up @@ -113,14 +113,15 @@ def phase(pars = {}):
setpar.alpha = pars['alpha']
setpar.D = pars['D']

cdef numpy.ndarray[double,ndim=1] t = numpy.zeros(setpar.length, 'd')
cdef numpy.ndarray[double,ndim=1] phase_r = numpy.zeros(setpar.length, 'd')
cdef numpy.ndarray[double,ndim=1] phase_theta = numpy.zeros(setpar.length, 'd')
cdef numpy.ndarray[double,ndim=1] phase_phi = numpy.zeros(setpar.length, 'd')
cdef numpy.ndarray[double,ndim=1] omega_r = numpy.zeros(setpar.length, 'd')
cdef numpy.ndarray[double,ndim=1] omega_theta = numpy.zeros(setpar.length, 'd')
cdef numpy.ndarray[double,ndim=1] omega_phi = numpy.zeros(setpar.length, 'd')
cdef numpy.ndarray[double,ndim=1] t = numpy.zeros(setpar.length, 'd')
cdef numpy.ndarray[double,ndim=1] phase_r = numpy.zeros(setpar.length, 'd')
cdef numpy.ndarray[double,ndim=1] phase_theta = numpy.zeros(setpar.length, 'd')
cdef numpy.ndarray[double,ndim=1] phase_phi = numpy.zeros(setpar.length, 'd')
cdef numpy.ndarray[double,ndim=1] omega_r = numpy.zeros(setpar.length, 'd')
cdef numpy.ndarray[double,ndim=1] omega_theta = numpy.zeros(setpar.length, 'd')
cdef numpy.ndarray[double,ndim=1] omega_phi = numpy.zeros(setpar.length, 'd')
cdef numpy.ndarray[double,ndim=1] eccentricity = numpy.zeros(setpar.length, 'd')

cdef double timing = AAKphase(setpar, &t[0], &phase_r[0], &phase_theta[0], &phase_phi[0], &omega_r[0], &omega_theta[0], &omega_phi[0])
cdef double timing = AAKphase(setpar, &t[0], &phase_r[0], &phase_theta[0], &phase_phi[0], &omega_r[0], &omega_theta[0], &omega_phi[0], &eccentricity[0])

return t, phase_r, phase_theta, phase_phi, omega_r, omega_theta, omega_phi, timing
return t, phase_r, phase_theta, phase_phi, omega_r, omega_theta, omega_phi, eccentricity, timing
5 changes: 3 additions & 2 deletions Makefile
Expand Up @@ -8,7 +8,6 @@ TOP = .
BIN = $(TOP)/bin
INC = $(TOP)/include
LIB = $(TOP)/lib
PYBUILD = $(TOP)/build
PYFILES = $(TOP)/AAKwrapper

SRC = $(TOP)/src
Expand Down Expand Up @@ -120,7 +119,9 @@ KSOBJS = AAK.o AAKPhase.o AK.o GKTrajFast.o KSParMap.o KSTools.o AAKpy.o
clean : dummy
$(RM) $(BIN)/*
$(RM) $(LIB)/*
$(RM) -r $(PYBUILD)/*
$(RM) -r $(PYFILES)/__pycache__
$(RM) $(PYFILES)/*.cpp
$(RM) $(PYFILES)/*.so
$(RM) -rf AAKwrapper.egg-info
$(RM) -rf build
$(RM) -rf dist
2 changes: 1 addition & 1 deletion examples/AAKdemo.py
Expand Up @@ -54,6 +54,6 @@

print("Computing phases...")

t, phase_r, phase_theta, phase_phi, omega_r, omega_theta, omega_phi, timing = AAKwrapper.phase(pars)
t, phase_r, phase_theta, phase_phi, omega_r, omega_theta, omega_phi, eccentricity, timing = AAKwrapper.phase(pars)

print("Time taken: {}".format(timing))
2 changes: 1 addition & 1 deletion include/AAKPhase.h
Expand Up @@ -13,6 +13,6 @@

void PNevolutionPhase(double *t, double *e, double *v, double *M, double *S, double *gim, double *Phi, double *alp, double *nu, double *gimdotvec, double *Phidotvec, double *alpdotvec, double timestep, int vlength, double *par, double e_traj[], double v_map[], double M_phys, double M_map[], double S_phys, double S_map[], double dt_map[], int steps, int *i_plunge, int *i_buffer, bool backint);

void GenPhase(double *t, double *phase_r, double *phase_theta, double *phase_phi, double *omega_r, double *omega_theta, double *omega_phi, double timestep, int vlength, double e_traj[], double v_map[], double M_phys, double M_map[], double mu, double S_phys, double S_map[], double dist, double inc, double gim0, double Phi0, double qS, double phiS, double alp0, double qK, double phiK, double dt_map[], int steps, bool backint, bool mich, bool traj);
void GenPhase(double *t, double *phase_r, double *phase_theta, double *phase_phi, double *omega_r, double *omega_theta, double *omega_phi, double *eccentricity, double timestep, int vlength, double e_traj[], double v_map[], double M_phys, double M_map[], double mu, double S_phys, double S_map[], double dist, double inc, double gim0, double Phi0, double qS, double phiS, double alp0, double qK, double phiK, double dt_map[], int steps, bool backint, bool mich, bool traj);

#endif
2 changes: 1 addition & 1 deletion include/AAKpy.h
Expand Up @@ -16,6 +16,6 @@

double AAKwave(SetPar &AAK, double *t, double *hI, double *hII);

double AAKphase(SetPar &AAK, double *t, double *phase_r, double *phase_theta, double *phase_phi, double *omega_r, double *omega_theta, double *omega_phi);
double AAKphase(SetPar &AAK, double *t, double *phase_r, double *phase_theta, double *phase_phi, double *omega_r, double *omega_theta, double *omega_phi, double *eccentricity);

#endif
8 changes: 5 additions & 3 deletions src/exec/AAK_Phase.cc
Expand Up @@ -58,15 +58,16 @@ int main(int argc, char *argv[]){
dt_map[i-1]=traj3[i].t*SOLARMASSINSEC*AAK.M*AAK.M/AAK.mu;
}

double *t,*phase_r,*phase_theta,*phase_phi,*omega_r,*omega_theta,*omega_phi;
double *t,*phase_r,*phase_theta,*phase_phi,*omega_r,*omega_theta,*omega_phi,*eccentricity;
t=(double*)malloc(AAK.length*sizeof(double));
phase_r=(double*)malloc(AAK.length*sizeof(double));
phase_theta=(double*)malloc(AAK.length*sizeof(double));
phase_phi=(double*)malloc(AAK.length*sizeof(double));
omega_r=(double*)malloc(AAK.length*sizeof(double));
omega_theta=(double*)malloc(AAK.length*sizeof(double));
omega_phi=(double*)malloc(AAK.length*sizeof(double));
GenPhase(t,phase_r,phase_theta,phase_phi,omega_r,omega_theta,omega_phi,AAK.dt,AAK.length,e_traj,v_map,AAK.M,M_map,AAK.mu,AAK.s,s_map,AAK.D,AAK.iota,AAK.gamma,Phi,AAK.theta_S,AAK.phi_S,AAK.alpha,AAK.theta_K,AAK.phi_K,dt_map,steps,AAK.backint,AAK.LISA,false);
eccentricity=(double*)malloc(AAK.length*sizeof(double));
GenPhase(t,phase_r,phase_theta,phase_phi,omega_r,omega_theta,omega_phi,eccentricity,AAK.dt,AAK.length,e_traj,v_map,AAK.M,M_map,AAK.mu,AAK.s,s_map,AAK.D,AAK.iota,AAK.gamma,Phi,AAK.theta_S,AAK.phi_S,AAK.alpha,AAK.theta_K,AAK.phi_K,dt_map,steps,AAK.backint,AAK.LISA,false);

ticks=clock()-ticks;
double secs=((double)ticks)/CLOCKS_PER_SEC;
Expand All @@ -79,7 +80,7 @@ int main(int argc, char *argv[]){
strcat(filename,"_wave.dat");
if(CheckFile(filename)==1) fprintf(stderr,"Output warning: Overwriting %s\n",filename);
file=fopen(filename,"w");
for(int i=0;i<AAK.length;i++) fprintf(file,"%8.6e %8.6e %8.6e %8.6e %8.6e %8.6e %8.6e\n",t[i],phase_r[i],phase_theta[i],phase_phi[i],omega_r[i],omega_theta[i],omega_phi[i]);
for(int i=0;i<AAK.length;i++) fprintf(file,"%8.6e %8.6e %8.6e %8.6e %8.6e %8.6e %8.6e %8.6e\n",t[i],phase_r[i],phase_theta[i],phase_phi[i],omega_r[i],omega_theta[i],omega_phi[i],eccentricity[i]);
fclose(file);

if(AAK.timing==true){
Expand All @@ -99,6 +100,7 @@ int main(int argc, char *argv[]){
free(omega_r);
free(omega_theta);
free(omega_phi);
free(eccentricity);

}

3 changes: 2 additions & 1 deletion src/suite/AAKPhase.cc
Expand Up @@ -311,7 +311,7 @@ void PNevolutionPhase(double *t, double *e, double *v, double *M, double *S, dou
}


void GenPhase(double *t, double *phase_r, double *phase_theta, double *phase_phi, double *omega_r, double *omega_theta, double *omega_phi, double timestep, int vlength, double e_traj[], double v_map[], double M_phys, double M_map[], double mu, double S_phys, double S_map[], double dist, double inc, double gim0, double Phi0, double qS, double phiS, double alp0, double qK, double phiK, double dt_map[], int steps, bool backint, bool mich, bool traj){
void GenPhase(double *t, double *phase_r, double *phase_theta, double *phase_phi, double *omega_r, double *omega_theta, double *omega_phi, double *eccentricity, double timestep, int vlength, double e_traj[], double v_map[], double M_phys, double M_map[], double mu, double S_phys, double S_map[], double dist, double inc, double gim0, double Phi0, double qS, double phiS, double alp0, double qK, double phiK, double dt_map[], int steps, bool backint, bool mich, bool traj){

double par[12];
par[0]=mu*SOLARMASSINSEC;
Expand Down Expand Up @@ -352,6 +352,7 @@ void GenPhase(double *t, double *phase_r, double *phase_theta, double *phase_phi
omega_r[i]=Phidotvec[i];
omega_theta[i]=Phidotvec[i]+gimdotvec[i];
omega_phi[i]=Phidotvec[i]+gimdotvec[i]+alpdotvec[i];
eccentricity[i]=evec[i];
}

free(tvec);
Expand Down
4 changes: 2 additions & 2 deletions src/suite/AAKpy.cc
Expand Up @@ -48,7 +48,7 @@ double AAKwave(SetPar &AAK, double *t, double *hI, double *hII){

}

double AAKphase(SetPar &AAK, double *t, double *phase_r, double *phase_theta, double *phase_phi, double *omega_r, double *omega_theta, double *omega_phi){
double AAKphase(SetPar &AAK, double *t, double *phase_r, double *phase_theta, double *phase_phi, double *omega_r, double *omega_theta, double *omega_phi, double *eccentricity){

clock_t ticks=clock();

Expand Down Expand Up @@ -78,7 +78,7 @@ double AAKphase(SetPar &AAK, double *t, double *phase_r, double *phase_theta, do
dt_map[i-1]=traj3[i].t*SOLARMASSINSEC*AAK.M*AAK.M/AAK.mu;
}

GenPhase(t,phase_r,phase_theta,phase_phi,omega_r,omega_theta,omega_phi,AAK.dt,AAK.length,e_traj,v_map,AAK.M,M_map,AAK.mu,AAK.s,s_map,AAK.D,AAK.iota,AAK.gamma,Phi,AAK.theta_S,AAK.phi_S,AAK.alpha,AAK.theta_K,AAK.phi_K,dt_map,steps,AAK.backint,AAK.LISA,false);
GenPhase(t,phase_r,phase_theta,phase_phi,omega_r,omega_theta,omega_phi,eccentricity,AAK.dt,AAK.length,e_traj,v_map,AAK.M,M_map,AAK.mu,AAK.s,s_map,AAK.D,AAK.iota,AAK.gamma,Phi,AAK.theta_S,AAK.phi_S,AAK.alpha,AAK.theta_K,AAK.phi_K,dt_map,steps,AAK.backint,AAK.LISA,false);

ticks=clock()-ticks;
return ((double)ticks)/CLOCKS_PER_SEC;
Expand Down

0 comments on commit 9473b3c

Please sign in to comment.