/******************************** * * FILE HEADER.H * * This is the header files for program "Binary" * ************************************/ /******************************************************* * * Preprocessor commands * * The meaning of the defined values are: * * For the stars, * DIMEN1 = theta * DIMEN2 = phi * * For the disk, * DIMEN1 = An arbitrary index that increases with r along the * top of the disk, with three more grid points on the * edge of the disk. There are no grid points on the * (always invisible) bottom of the disk. * DIMEN2 = phi * * PHASEPOINTS = The maximum number of points in orbital phase at * which the light curve can be synthesized. * Also, the maximum number of data points in the * observed light curve. * * LINEPOINTS = The maximum number of points in any array holding * one-dimensional line. Typically the longest * lines will be the ones defining the edges of * objects. * The program will terminate with an error message * unless * LINEPOINTS >= 2 * (SIZEDIMEN1 + SIZEDIMEN2) * *****************************/ #include #include #include #include #define PI 3.1415926535 #define PIOVER2 1.5707963267 #define TWOPI 6.2831853072 #define SIZEDIMEN1 201 #define SIZEDIMEN2 400 #define PHASEPOINTS 2000 #define LINEPOINTS 1500 /***************************************************** * * Structure prototypes. * *****************************************************/ struct controlmodes { char star1[20]; char star1spots[20]; char star2[20]; char star2spots[20]; char disk[20]; char thirdlight[20]; char reflection[20]; char writegrids[20]; char runtype[20]; char plotprogram[20]; char normalize[20]; double fitphase[2]; char readdata[20]; char datafile[20]; }; struct wholesystem { double q; double mass1; double mass2; double inclination; char filter[20]; double wavelength; double phaseoffset; double normflux; double normphase; double chisquared; }; struct starparams { long int whichstar; long int thetapoints; long int phipoints; double massFrac; double rL1; double psiLobe; double fracRadius; double psiSurface; double backradius; double frontradius; double sideradius; double poleradius; double gravbeta; double poletemp; double polegrav; double albedo; char fluxsource[20]; double bblimbdark; double logg; }; struct star1spotparams { long nspots; /* number of spots */ double theta[20]; /* spot theta position in radians */ double phi[20]; /* spot phi position in radians */ double radius[20]; /* spot radius in radians */ double SpotToverStarT[20]; /* ratio of spot Teff to local star Teff */ }; struct star2spotparams { long nspots; /* number of spots */ double theta[20]; /* spot theta position in radians */ double phi[20]; /* spot phi position in radians */ double radius[20]; /* spot radius in radians */ double SpotToverStarT[20]; /* ratio of spot Teff to local star Teff */ }; struct disktopparams { long int rpoints; long int phipoints; double innerR; double outerR; double flareangle; double transmission; char Tsource[20]; double Tcoef[4]; char Tfile[20]; char fluxsource[20]; double bblimbdark; double logg; double spotT; double spotr[2]; double spotphi[2]; }; struct diskrimparams { long int rpoints; long int phipoints; double outerR; double T; char fluxsource[20]; double bblimbdark; double logg; double spotT; double spotphi[2]; }; struct thirdlightparams { double fraction; double orbphase; }; struct lightcurve { long int npoints; double phases[PHASEPOINTS]; double fluxes[PHASEPOINTS]; double stdev[PHASEPOINTS]; }; /******************************************************* * * Function prototypes * *********************************************************/ /* MAIN.C */ void initParams( void ); void quit( char *outputline ); /* INPUT.C */ void readParams( void ); void OrbPhases( char *phasesource, double firstphase, double lastphase, double deltaphase); void readData( char *filename, struct lightcurve *data ); long int ReadItable( char *filter, double logg, double *T, double *Io, double *a, double *b); void readDiskT( char *filename ); /* CHECK.C */ void checkModes( void ); void checkSysParams( void ); void checkStarParams( struct starparams star ); void checkStar2SpotParams( void ); void checkStar1SpotParams( void ); void checkDiskParams( void ); void checkThirdlightParams( struct thirdlightparams thirdlight ); /* GEOMETRY.C */ void StarGeom ( struct starparams *star, double r [SIZEDIMEN1] [SIZEDIMEN2], double l [SIZEDIMEN1] [SIZEDIMEN2], double m [SIZEDIMEN1] [SIZEDIMEN2], double n [SIZEDIMEN1] [SIZEDIMEN2], double gravity [SIZEDIMEN1] [SIZEDIMEN2], double normalx [SIZEDIMEN1] [SIZEDIMEN2], double normaly [SIZEDIMEN1] [SIZEDIMEN2], double normalz [SIZEDIMEN1] [SIZEDIMEN2], double dS [SIZEDIMEN1] [SIZEDIMEN2] ); double psi( double r, double l, double n, double mu2); double findL1( double mu2 ); double dpsidr( double r, double l, double n, double mu2); double findr( double psiTarget, double rmax, double rguess, double l, double n, double mu2); double dpsidx( double r, double l, double m, double n, double mu2); double dpsidy( double r, double l, double m, double n, double mu2); double dpsidz( double r, double l, double m, double n, double mu2); void DiskGeom( void ); /* TEFF.C */ void Tstars( char *object ); void Tstar1spot( double theta, double phi, double radius, double SpotToverStarT ); void Tstar2spot( double theta, double phi, double radius, double SpotToverStarT ); void Tdisk( void ); void irradiate( void ); /* OUTPUT.C */ void writeStarData( struct starparams star ); void writeDiskData( void ); void writeLCurve( long nphases, double *orbphase, double *flux); void writePars( void ); void writeChiSq( double chisqu ); void quit( char *outputline); /* TOTFLUX.C */ double totalFlux( double orbphase ); void coordsys( double *lsky, double *msky, double *nsky, double inclination, double orbphase); void project( double *pxsky, double *pysky, double xstar, double ystar, double zstar, double *lsky, double *msky); void occult( long keepside, double transmission, long maxfirstindex, long maxsecondindex, double x[SIZEDIMEN1][SIZEDIMEN2], double y[SIZEDIMEN1][SIZEDIMEN2], double visible[SIZEDIMEN1][SIZEDIMEN2], long nedge, double *edgex, double *edgey); double planck( double temperature, double wavelength, char *mode ); double SpecInt( char *object, char *fluxsource, double temperature, double mu); /* LINES.C */ void lineImage( double orbphase ); void plotline( FILE *out, char *color, long isclosed, long npoints, double *x, double *y, double *visible); /* EDGES.C */ long int staredge( long ntheta, long nphi, double x[SIZEDIMEN1][SIZEDIMEN2], double y[SIZEDIMEN1][SIZEDIMEN2], double mu[SIZEDIMEN1][SIZEDIMEN2], double *edgex, double *edgey); long int diskedges( long edgetype, long maxrindex, long maxphiindex, double x [SIZEDIMEN1] [SIZEDIMEN2], double y [SIZEDIMEN1] [SIZEDIMEN2], double mu [SIZEDIMEN1] [SIZEDIMEN2], double *edgex, double *edgey); double edgedistance( long nedgepoints, double *edger, double *edgetheta, double x, double y); void sort( int npoints, double *x, double *y); long int cutoff( long keepside, long nedge, double *edgex, double *edgey, long isclosed, long npoints, double *x, double *y, double *visible); long int cutoffstar1( long nedge, double *edgex, double *edgey, long npoints, double *x, double *y); /* FIT.C */ double Normalize( long nphases, double *phases, double *fluxes ); double lsqrNorm( long nphasesdata, double *phasedata, double *fluxdata, double *stdevdata, long nphasescalc, double *phasecalc, double *fluxcalc); double chiSqr( long nphasesdata, double *phasedata, double *fluxdata, double *stdevdata, long nphasescalc, double *phasecalc, double *fluxcalc); /* POINTS.C */ void pointImage( double orbphase ); /******************************************************* * * Global variables * *******************************************************/ double r1 [SIZEDIMEN1] [SIZEDIMEN2]; double l1 [SIZEDIMEN1] [SIZEDIMEN2]; double m1 [SIZEDIMEN1] [SIZEDIMEN2]; double n1 [SIZEDIMEN1] [SIZEDIMEN2]; double gravity1 [SIZEDIMEN1] [SIZEDIMEN2]; double normalx1 [SIZEDIMEN1] [SIZEDIMEN2]; double normaly1 [SIZEDIMEN1] [SIZEDIMEN2]; double normalz1 [SIZEDIMEN1] [SIZEDIMEN2]; double dS1 [SIZEDIMEN1] [SIZEDIMEN2]; double localT1 [SIZEDIMEN1] [SIZEDIMEN2]; double r2 [SIZEDIMEN1] [SIZEDIMEN2]; double l2 [SIZEDIMEN1] [SIZEDIMEN2]; double m2 [SIZEDIMEN1] [SIZEDIMEN2]; double n2 [SIZEDIMEN1] [SIZEDIMEN2]; double gravity2 [SIZEDIMEN1] [SIZEDIMEN2]; double normalx2 [SIZEDIMEN1] [SIZEDIMEN2]; double normaly2 [SIZEDIMEN1] [SIZEDIMEN2]; double normalz2 [SIZEDIMEN1] [SIZEDIMEN2]; double dS2 [SIZEDIMEN1] [SIZEDIMEN2]; double localT2 [SIZEDIMEN1] [SIZEDIMEN2]; double rdisk [SIZEDIMEN1] [SIZEDIMEN2]; double ldisk [SIZEDIMEN1] [SIZEDIMEN2]; double mdisk [SIZEDIMEN1] [SIZEDIMEN2]; double ndisk [SIZEDIMEN1] [SIZEDIMEN2]; double normdiskx [SIZEDIMEN1] [SIZEDIMEN2]; double normdisky [SIZEDIMEN1] [SIZEDIMEN2]; double normdiskz [SIZEDIMEN1] [SIZEDIMEN2]; double dSdisk [SIZEDIMEN1] [SIZEDIMEN2]; double localTdisk [SIZEDIMEN1] [SIZEDIMEN2]; long int Itabn1, Itabn2, Itabntop, Itabnrim; double originalflux, thirdflux; double ItabT1 [500], ItabIo1 [500], ItabA1 [500], ItabB1 [500]; double ItabT2 [500], ItabIo2 [500], ItabA2 [500], ItabB2 [500]; double ItabTtop[500], ItabIotop[500], ItabAtop[500], ItabBtop[500]; double ItabTrim[500], ItabIorim[500], ItabArim[500], ItabBrim[500]; struct controlmodes mode; struct wholesystem starsys; struct starparams star1, star2; struct star1spotparams star1spot; struct star2spotparams star2spot; struct disktopparams disktop; struct diskrimparams diskrim; struct thirdlightparams thirdlight; struct lightcurve data1, calc;