matrix &matrix::setblock_step(int ifil1, int ifil2, int dfil, int icol1, int icol2, int dcol, const matrix &a) { if(ifil1<0) ifil1+=nf; if(ifil2<0) ifil2+=nf; if(icol1<0) icol1+=nc; if(icol2<0) icol2+=nc; if(ifil1<0||ifil1>=nf||ifil2<0||ifil2>=nf||icol1<0||icol1>=nc||icol2<0||icol2>=nc) { ester_err("(matrix.setblock_step) Index exceeds matrix dimensions"); exit(1); } if(a.nf!=floor((ifil2-ifil1)/dfil)+1||a.nc!=floor((icol2-icol1)/dcol)+1) { ester_err("(matrix.setblock_step) Dimensions must agree"); exit(1); } double *pi, *pa; int i, j, N1, N2; pi=p+ifil1+icol1*nf;pa=a.p; N1=a.nc;N2=a.nf; for(i=0;i<N1;i++) { for(j=0;j<N2;j++) pi[j*dfil]=pa[j]; pa+=a.nf;pi+=dcol*nf; } return *this; }
matrix matrix::concatenate(const matrix &a, int dir) const { matrix res; if(dir==0) { if(a.nc!=nc) { ester_err("(matrix.concatenate) Dimensions must agree (%d != %d)", a.nc, nc); exit(1); } res.dim(nf+a.nf, nc); res.setblock(0, nf-1, 0, -1, *this); res.setblock(nf, a.nf+nf-1, 0, -1, a); } else { if(a.nf!=nf) { ester_err("(matrix.concatenate) Dimensions must agree"); exit(1); } res.dim(nf, nc+a.nc); res.setblock(0, -1, 0, nc-1, *this); res.setblock(0, -1, nc, nc+a.nc-1, a); } return res; }
/// \brief Re-dimension the matrix. /// /// Updates the matrix dimension. /// \returns the updated matrix object. matrix &matrix::dim(int nfil, int ncol) { unsigned tam; if(nfil<0||ncol<0) { ester_err("Can't create matrix with negative size"); exit(1); } if(nfil==0) { ester_err("Number of rows can't be zero"); exit(1); } if(ncol==0) { ester_err("Number of columns can't be zero"); exit(1); } if(nfil*ncol!=nf*nc) { delete [] p; nf=nfil; nc=ncol; tam=unsigned(nf)*unsigned(nc); p=new double[tam]; } else { nf=nfil; nc=ncol; } return *this; }
const matrix matrix::block_step(int ifil1, int ifil2, int dfil, int icol1, int icol2, int dcol) const { if(ifil1<0) ifil1+=nf; if(ifil2<0) ifil2+=nf; if(icol1<0) icol1+=nc; if(icol2<0) icol2+=nc; if(ifil1<0||ifil1>=nf||ifil2<0||ifil2>=nf||icol1<0||icol1>=nc||icol2<0||icol2>=nc) { ester_err("(matrix.block_step) Index exceeds matrix dimensions"); exit(1); } matrix res((int) floor((ifil2-ifil1)/dfil)+1, (int) floor((icol2-icol1)/dcol)+1); double *pi, *pres; int i, j, N1, N2; pi=p+ifil1+icol1*nf;pres=res.p; N1=res.nc;N2=res.nf; for(i=0;i<N1;i++) { for(j=0;j<N2;j++) pres[j]=pi[j*dfil]; pres+=res.nf;pi+=dcol*nf; } return res; }
/// \brief Default matrix constructor. /// /// Creates an nfil rows by ncol columns matrix. /// If \p nfil and \p ncol are omitted, defaults are 1. matrix::matrix(int nfil, int ncol) { unsigned tam; if(nfil<0||ncol<0) { ester_err("Can't create matrix with negative size"); } if(nfil==0) { ester_err("Number of rows can't be zero"); } if(ncol==0) { ester_err("Number of columns can't be zero"); } nf=nfil; nc=ncol; tam=unsigned(nf)*unsigned(nc); p=new double[tam]; }
/// \brief Access matrix's elements. const double &matrix::operator()(int ielem) const { if(ielem<0) ielem+=nf*nc; if(ielem>=nf*nc||ielem<0) { ester_err("Index exceeds matrix dimensions"); exit(1); } return *(p+ielem); }
int atm_onelayer(const matrix &X,double Z,const matrix &g,const matrix &Teff, const char *eos_name,const char *opa_name,atm_struct &atm) { int n=g.nrows(); int m=g.ncols(); atm.ps.dim(n,m);atm.Ts.dim(n,m); atm.dlnps_lng.dim(n,m);atm.dlnps_lnTeff.dim(n,m); atm.dlnTs_lng.dim(n,m);atm.dlnTs_lnTeff.dim(n,m); atm.Ts=Teff; atm.dlnTs_lnTeff=ones(n,m); atm.dlnTs_lng=zeros(n,m); for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { double logps,logg; matrix p,T,rho; eos_struct eos; opa_struct opa; logps=4.2; //Initial value logg=log10(g(i,j)); T=Teff(i,j)*ones(1,1); strcpy(eos.name,eos_name); strcpy(opa.name,opa_name); int fin=0; int nit=0; while(fin<2) { nit++; if(nit>100) { ester_err("Error (atm_onelayer): No convergence"); return 1; } double F,dF,dlogps; p=pow(10,logps)*ones(1,1); if(eos_calc(X(i,j)*ones(1,1),Z,T,p,rho,eos)) return 1; if(opa_calc(X(i,j)*ones(1,1),Z,T,rho,opa)) return 1; F=logps+log10(opa.k)(0)-logg-log10(2./3.); dF=1.-(1+opa.dlnxi_lnrho(0))/eos.chi_rho(0); dlogps=-F/dF; if (fabs(dlogps)<1e-8) fin++; logps+=dlogps; } atm.ps(i,j)=pow(10,logps); double kp,kT; kp=-(1+opa.dlnxi_lnrho(0))/eos.chi_rho(0); kT=3-opa.dlnxi_lnT(0)+(1+opa.dlnxi_lnrho(0))*eos.d(0); atm.dlnps_lng(i,j)=1./(1+kp); atm.dlnps_lnTeff(i,j)=-kT/(1+kp); } } return 0; }
/// \brief Access matrix's elements. const double &matrix::operator()(int ifil, int icol) const { if(ifil<0) ifil+=nf; if(icol<0) icol+=nc; if(ifil>=nf||ifil<0||icol>=nc||icol<0) { ester_err("Index exceeds matrix dimensions"); exit(1); } return *(p+icol*nf+ifil); }
matrix &matrix::setrow(int ifil, const matrix &a) { double *pi; int i; if(ifil<0) ifil+=nf; if(ifil<0||ifil>=nf) { ester_err("(matrix.setrow) Index exceeds matrix dimensions"); exit(1); } if(a.nf>1||a.nc!=nc) { ester_err("(matrix.setrow) Dimensions must agree"); exit(1); } pi=p+ifil; for(i=0;i<nc;i++) pi[i*nf]=a.p[i]; return *this; }
matrix min(const matrix &a, const matrix &b) { if( (b.nf!=a.nf) || (b.nc!=a.nc) ) { ester_err("(matrix.min) Dimensions must agree"); exit(1); } matrix res(a.nf, a.nc); int i, N; N=a.nc*a.nf; for(i=0;i<N;i++) res.p[i]=a.p[i]<b.p[i]?a.p[i]:b.p[i]; return res; }
/// \brief Re-dimension the matrix. /// /// Updates the matrix dimension. The new full matrix (\p nfil x \p ncol) size /// must match the original matrix size (nrows() x ncols()). /// \returns the updated matrix object. matrix &matrix::redim(int nfil, int ncol) { if(nfil<0||ncol<0) { ester_err("Can't create matrix with negative size"); exit(1); } if(nfil==0) { ester_err("Number of rows can't be zero"); exit(1); } if(ncol==0) { ester_err("Number of columns can't be zero"); exit(1); } if(nfil*ncol!=nf*nc) { ester_err("matrix.redim: Number of elements doesn't match"); exit(1); } nf=nfil;nc=ncol; return *this; }
matrix &matrix::setcol(int icol, const matrix &a) { double *pi; int i, N; if(icol<0) icol+=nc; if(icol<0||icol>=nc) { ester_err("(matrix.setcol) Index exceeds matrix dimensions"); exit(1); } if(a.nc>1||a.nf!=nf) { ester_err("(matrix.setcol) Dimensions must agree"); exit(1); } pi=p+icol*nf; N=nf; for(i=0;i<N;i++) pi[i]=a.p[i]; return *this; }
int atm_calc(const matrix &X,double Z,const matrix &g,const matrix &Teff, const char *eos_name,const char *opa_name,atm_struct &atm) { int error=0; if(!strcmp(atm.name,"onelayer")) { error=atm_onelayer(X,Z,g,Teff,eos_name,opa_name,atm); } else { ester_err("Unknown atmosphere type: %s", atm.name); return 1; } return error; }
int main(int argc,char *argv[]) { char *input_file; star1d m1d; star2d m2d; input_file=argv[1]; if(!m1d.read(input_file, 1)) output2d(m1d); else if (!m2d.read(input_file)) output2d(m2d); else { ester_err("Error reading input file: %s",input_file); return 1; } return 0; }
int nuc_calc(const matrix_map &X,const matrix &T,const matrix &rho, nuc_struct &nuc) { int error=0; if(!strcmp(nuc.name,"simple")) { error=nuc_simple(X,T,rho,nuc); } else if(!strcmp(nuc.name,"cesam")) { error=nuc_cesam(X,T,rho,nuc); } else { ester_err("Unknown nuc. reac. type: %s",nuc.name); return 1; } return error; }
const matrix matrix::row(int ifil) const { matrix res(1, nc); double *pi; int i; if(ifil<0) ifil+=nf; if(ifil<0||ifil>=nf) { ester_err("(matrix.row) Index exceeds matrix dimensions"); exit(1); } pi=p+ifil; for(i=0;i<nc;i++) res.p[i]=pi[i*nf]; return res; }
int opa_calc(const matrix &X,double Z,const matrix &T,const matrix &rho, opa_struct &opa) { int error=0; if(!strcmp(opa.name,"opal")) { error=opa_opal(X,Z,T,rho,opa); } else if(!strcmp(opa.name,"houdek")) { error=opa_houdek(X,Z,T,rho,opa); } else if(!strcmp(opa.name,"kramer")) { error=opa_kramer(T,rho,opa); } else { ester_err("Unknown opacity method: %s",opa.name); return 1; } return error; }
int eos_calc(const matrix &X,double Z,const matrix &T,const matrix &p, matrix &rho,eos_struct &eos) { int error=0; if(!strcmp(eos.name,"ideal")) error=eos_ideal(X,Z,T,p,rho,eos); else if(!strcmp(eos.name,"ideal+rad")) error=eos_idealrad(X,Z,T,p,rho,eos); else if(!strcmp(eos.name,"opal")) error=eos_opal(X,Z,T,p,rho,eos); else { ester_err("Unknown equation of state: %s",eos.name); return 1; } return error; }
const matrix matrix::col(int icol) const { matrix res(nf, 1); double *pi; int i, N; if(icol<0) icol+=nc; if(icol<0||icol>=nc) { ester_err("(matrix.col) Index exceeds matrix dimensions"); exit(1); } pi=p+icol*nf; N=nf; for(i=0;i<N;i++) res.p[i]=pi[i]; return res; }
matrix matrix::operator*(const matrix &a) const { matrix res; int i, j, resnf, resnc, N; if( (nf!=1&&a.nf!=1&&nf!=a.nf) || (nc!=1&&a.nc!=1&&nc!=a.nc) ) { ester_err("(matrix.*) Dimensions must agree"); exit(1); } if(nf>a.nf) resnf=nf; else resnf=a.nf; if(nc>a.nc) resnc=nc; else resnc=a.nc; res.dim(resnf, resnc); if (nf==resnf&&nc==resnc&&a.nf==resnf&&a.nc==resnc) { N=nf*nc; for(i=0;i<N;i++) res.p[i]=p[i]*a.p[i]; } else { double *pi, *pa, *pres; pi=p;pa=a.p;pres=res.p; for(i=0;i<resnc;i++) { for(j=0;j<resnf;j++) { *(pres++)=*(pi)*(*(pa)); if(nf>1) pi++; if(a.nf>1) pa++; } if(nc==1) pi=p; else if(nf==1) pi++; if(a.nc==1) pa=a.p; else if(a.nf==1) pa++; } } return res; }
int eos_freeeos(const matrix &X, double Z, const matrix &T, const matrix &p, matrix &rho, eos_struct &eos) { double t; int ifoption = 1; int ifmodified = 2; int ifion = 0; int kif_in = 1; int neps = 20; double *eps = new double[neps]; double tl; double fl; double rl; double pl; double cf; double cp; double qf; double qp; double sf; double st; double grada; double rtp; double rmue; double fh2; double fhe2; double fhe3; double xmu1; double xmu3; double eta; double gamma1; double gamma2; double gamma3; double h2rat; double h2plusrat; double lambda; double gamma_e; double degeneracy[3]; double pressure[3]; double density[3]; double energy[3]; double enthalpy[3]; double entropy[3]; int iteration_count; int N=T.nrows()*T.ncols(); rho.dim(T.nrows(), T.ncols()); eos.s.dim(T.nrows(), T.ncols()); eos.G1.dim(T.nrows(), T.ncols()); eos.del_ad.dim(T.nrows(), T.ncols()); eos.G3_1.dim(T.nrows(), T.ncols()); eos.d.dim(T.nrows(), T.ncols()); eos.cp.dim(T.nrows(), T.ncols()); eos.cv.dim(T.nrows(), T.ncols()); eos.chi_rho.dim(T.nrows(), T.ncols()); eos.chi_T.dim(T.nrows(), T.ncols()); for (int i=0; i<N; i++) { double_map comp = initial_composition(X(i), Z); eps[0] = comp["H"] / 1.008e0; // H eps[1] = (comp["He3"] + comp["He4"]) / 4.0026e0; // He3 + He4 eps[2] = (comp["C12"] + comp["C13"]) / 12.0111e0; // C12 + C13 eps[3] = (comp["N14"] + comp["N15"]) / 14.0067e0; // N14 + N15 eps[4] = (comp["O16"] + comp["O17"]) / 15.9994e0; // O16 + O17 eps[5] = 0.0; // Ne eps[6] = 0.0; // Na eps[7] = 0.0; // Mg eps[8] = 0.0; // AL eps[9] = 0.0; // Si eps[10] = .0; // P eps[11] = .0; // S eps[12] = .0; // Cl eps[13] = .0; // A eps[14] = .0; // Ca eps[15] = .0; // Ti eps[16] = .0; // Cr eps[17] = .0; // Mn eps[18] = .0; // Fe eps[19] = .0; // Ni double pi = p(i); double match_variable = log(pi); double rhoi; t = T(i); tl = log(t); pl = log(pi); free_eos_(&ifoption, &ifmodified, &ifion, &kif_in, eps, &neps, &match_variable, &tl, &fl, &t, &rhoi, &rl, &pi, &pl, &cf, &cp, &qf, &qp, &sf, &st, &grada, &rtp, &rmue, &fh2, &fhe2, &fhe3, &xmu1, &xmu3, &eta, &gamma1, &gamma2, &gamma3, &h2rat, &h2plusrat, &lambda, &gamma_e, degeneracy, pressure, density, energy, enthalpy, entropy, &iteration_count); rho(i) = rhoi; if (iteration_count < 0) { ester_err( "Values outside freeEOS eos table:\n" " X = %e\n" " Z = %e\n" " T = %e\n" " p = %e", X(i), Z, t, p(i)); } eos.s(i) = entropy[0]; eos.G1(i) = gamma1; eos.del_ad(i) = grada; eos.G3_1(i) = gamma1*(gamma2-1.0)/gamma2; eos.d(i) = -density[2]; // -d(lnRho)/d(lnT) eos.cp(i) = cp; // eos.cv(i)=1e6*(*(eeos_.eos+4)); eos.cv(i) = energy[2] * (1.0/t); // dE/dT (energy[2] is dE/dlnT) eos.chi_rho(i) = 1.0/density[1]; // dlogP/dlogRho eos.chi_T(i) = -density[2] / density[1]; // dlogP/dlogT } delete[] eps; return 0; }
void write(const star2d &A,char *var,char *fmt) { int i; double d; matrix m,m2,T,T_odd; if(pole||equator) { m2=zeros(1,A.nth+pole+equator); m2.setblock(0,0,equator,A.nth+equator-1,A.th); if(equator) m2(0)=PI/2; m=A.map.leg.eval_00(A.th,m2,T); m=A.map.leg.eval_11(A.th,m2,T_odd); } else { T=eye(A.nth); T_odd=T; } if(!strcmp(var,"nr")) { if(fmt) fprintf(stdout,fmt,A.nr); else { i=A.nr; fwrite(&i,sizeof(int),1,stdout); } } else if(!strcmp(var,"ndomains")) { if(fmt) fprintf(stdout,fmt,A.ndomains); else { i=A.ndomains; fwrite(&i,sizeof(int),1,stdout); } } else if(!strcmp(var,"npts")) { if(fmt) { for(i=0;i<A.ndomains;i++) { fprintf(stdout,fmt,*(A.map.gl.npts+i)); if(i<A.ndomains-1) fprintf(stdout,","); } } else { fwrite(A.map.gl.npts,sizeof(int),A.ndomains,stdout); } } else if(!strcmp(var,"xif")) { if(fmt) { for(i=0;i<A.ndomains+1;i++) { fprintf(stdout,fmt,*(A.map.gl.xif+i)); if(i<A.ndomains) fprintf(stdout,","); } } else { fwrite(A.map.gl.xif,sizeof(double),A.ndomains+1,stdout); } } else if(!strcmp(var,"nth")) { if(fmt) fprintf(stdout,fmt,A.nth); else { i=A.nth; fwrite(&i,sizeof(int),1,stdout); } } else if(!strcmp(var,"nex")) { if(fmt) fprintf(stdout,fmt,A.nex); else { i=A.nex; fwrite(&i,sizeof(int),1,stdout); } } else if(!strcmp(var,"ps")) { m=A.ps; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"m")) { if(fmt) fprintf(stdout,fmt,A.m); else { fwrite(&A.m,sizeof(double),1,stdout); } } else if(!strcmp(var,"surff")) { if(fmt) fprintf(stdout,fmt,A.surff); else { fwrite(&A.surff,sizeof(double),1,stdout); } } else if(!strcmp(var,"conv")) { if(fmt) fprintf(stdout,fmt,A.conv); else { fwrite(&A.conv,sizeof(int),1,stdout); } } else if(!strcmp(var,"Omega")) { if(dim) d=A.Omega*A.units.Omega; else d=A.Omega; if(fmt) fprintf(stdout,fmt,d); else { fwrite(&d,sizeof(double),1,stdout); } } else if(!strcmp(var,"Omega_bk")) { if(fmt) fprintf(stdout,fmt,A.Omega_bk); else { fwrite(&A.Omega_bk,sizeof(double),1,stdout); } } else if(!strcmp(var,"Omegac")) { if(dim) d=A.Omegac*A.units.Omega; else d=A.Omegac; if(fmt) fprintf(stdout,fmt,d); else { fwrite(&d,sizeof(double),1,stdout); } } else if(!strcmp(var,"Xc")) { if(fmt) fprintf(stdout,fmt,A.Xc); else { fwrite(&A.Xc,sizeof(double),1,stdout); } } else if(!strcmp(var,"rhoc")) { if(fmt) fprintf(stdout,fmt,A.rhoc); else { fwrite(&A.rhoc,sizeof(double),1,stdout); } } else if(!strcmp(var,"Tc")) { if(fmt) fprintf(stdout,fmt,A.Tc); else { fwrite(&A.Tc,sizeof(double),1,stdout); } } else if(!strcmp(var,"pc")) { if(fmt) fprintf(stdout,fmt,A.pc); else { fwrite(&A.pc,sizeof(double),1,stdout); } } else if(!strcmp(var,"R")) { if(fmt) fprintf(stdout,fmt,A.R); else { fwrite(&A.R,sizeof(double),1,stdout); } } else if(!strcmp(var,"Rp")) { if(fmt) fprintf(stdout,fmt,A.R); else { fwrite(&A.R,sizeof(double),1,stdout); } } else if(!strcmp(var,"Re")) { d=A.map.leg.eval_00(A.r.row(A.nr-1),PI/2)(0)*A.units.r; if(fmt) fprintf(stdout,fmt,d); else { fwrite(&d,sizeof(double),1,stdout); } } else if(!strcmp(var,"M")) { if(fmt) fprintf(stdout,fmt,A.M); else { fwrite(&A.M,sizeof(double),1,stdout); } } else if(!strcmp(var,"Lz")) { d=A.Lz(); if(fmt) fprintf(stdout,fmt,d); else { fwrite(&d,sizeof(double),1,stdout); } } else if(!strcmp(var,"Mcore")) { d=A.Mcore(); if(fmt) fprintf(stdout,fmt,d); else { fwrite(&d,sizeof(double),1,stdout); } } else if(!strcmp(var,"Lzcore")) { d=A.Lzcore(); if(fmt) fprintf(stdout,fmt,d); else { fwrite(&d,sizeof(double),1,stdout); } } else if(!strcmp(var,"X")) { if(fmt) fprintf(stdout,fmt,A.X0); else { fwrite(&A.X0,sizeof(double),1,stdout); } } else if(!strcmp(var,"Y")) { if(fmt) fprintf(stdout,fmt,A.Y0); else { fwrite(&A.Y0,sizeof(double),1,stdout); } } else if(!strcmp(var,"Z")) { if(fmt) fprintf(stdout,fmt,A.Z0); else { fwrite(&A.Z0,sizeof(double),1,stdout); } } else if(!strcmp(var,"R/R_SUN")) { if(fmt) fprintf(stdout,fmt,A.R/R_SUN); else { d=A.R/R_SUN; fwrite(&d,sizeof(double),1,stdout); } } else if(!strcmp(var,"Rp/R_SUN")) { if(fmt) fprintf(stdout,fmt,A.R/R_SUN); else { d=A.R/R_SUN; fwrite(&d,sizeof(double),1,stdout); } } else if(!strcmp(var,"Re/R_SUN")) { d=A.map.leg.eval_00(A.r.row(A.nr-1),PI/2)(0)*A.units.r/R_SUN; if(fmt) fprintf(stdout,fmt,d); else { fwrite(&d,sizeof(double),1,stdout); } } else if(!strcmp(var,"M/M_SUN")) { if(fmt) fprintf(stdout,fmt,A.M/M_SUN); else { d=A.M/M_SUN; fwrite(&d,sizeof(double),1,stdout); } } else if(!strcmp(var,"opa")) { if(fmt) fprintf(stdout,fmt,A.opa.name); else { fwrite(A.opa.name,sizeof(char),strlen(A.opa.name)+1,stdout); } } else if(!strcmp(var,"eos")) { if(fmt) fprintf(stdout,fmt,A.eos.name); else { fwrite(A.eos.name,sizeof(char),strlen(A.eos.name)+1,stdout); } } else if(!strcmp(var,"r")) { if(dim) m=A.r*A.units.r; else m=A.r; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"z")) { if(dim) m=A.z*A.units.r; else m=A.z; if(fmt) matrix_fmt(fmt,m); else m.write(stdout,'b'); } else if(!strcmp(var,"D")) { if(dim) m=A.D/A.units.r; else m=A.D; if(fmt) matrix_fmt(fmt,m); else m.write(stdout,'b'); } else if(!strcmp(var,"I")) { if(dim) m=A.map.gl.I*A.units.r; else m=A.map.gl.I; if(fmt) matrix_fmt(fmt,m); else m.write(stdout,'b'); } else if(!strcmp(var,"rex")) { if(dim) m=A.map.ex.r*A.units.r; else m=A.map.ex.r; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"phiex")) { if(dim) m=A.phiex*A.units.phi; else m=A.phiex; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"Dex")) { if(dim) m=A.map.ex.D/A.units.r; else m=A.map.ex.D; if(fmt) matrix_fmt(fmt,m); else m.write(stdout,'b'); } else if(!strcmp(var,"th")) { m=zeros(1,A.nth+pole+equator); m.setblock(0,0,equator,A.nth-1+pole,A.th); if(equator) m(0)=PI/2; if(pole) m(m.ncols()-1)=0; if(fmt) matrix_fmt(fmt,m); else m.write(stdout,'b'); } else if(!strcmp(var,"Dt")) { m2=(A.Dt,T_odd); m=zeros(A.nth+pole+equator,A.nth+pole+equator); m.setblock(equator,A.nth+equator-1,0,A.nth+pole+equator-1,m2); if(fmt) matrix_fmt(fmt,m); else m.write(stdout,'b'); } else if(!strcmp(var,"Dtodd")) { m2=(A.map.leg.D_11,T); m=zeros(A.nth+pole+equator,A.nth+pole+equator); m.setblock(equator,A.nth+equator-1,0,A.nth+pole+equator-1,m2); if(fmt) matrix_fmt(fmt,m); else m.write(stdout,'b'); } else if(!strcmp(var,"Dt2")) { m2=(A.Dt2,T); m=zeros(A.nth+pole+equator,A.nth+pole+equator); m.setblock(equator,A.nth+equator-1,0,A.nth+pole+equator-1,m2); if(fmt) matrix_fmt(fmt,m); else m.write(stdout,'b'); } else if(!strcmp(var,"It")) { m=zeros(A.nth+pole+equator,1); m.setblock(equator,A.nth+equator-1,0,0,A.map.leg.I_00); if(fmt) matrix_fmt(fmt,m); else m.write(stdout,'b'); } else if(!strcmp(var,"Ts")) { m=A.Ts; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"map.R")) { if(dim) m=A.map.R.block(1,-1,0,-1)*A.units.r; else m=A.map.R.block(1,-1,0,-1); if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"rho")) { if(dim) m=A.rho*A.units.rho; else m=A.rho; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"phi")) { if(dim) m=A.phi*A.units.phi; else m=A.phi; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"p")) { if(dim) m=A.p*A.units.p; else m=A.p; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"Xr")) { m=A.comp.X(); if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"Yr")) { m=A.comp.Y(); if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"Zr")) { m=A.comp.Z(); if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strncmp(var,"X_",2)) { std::string elem(var+2); if(A.comp.count(elem)) m=A.comp[elem]; else m=zeros(A.nr,A.nth); if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"w")) { if(dim) m=A.w*A.units.Omega; else m=A.w; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"T")) { if(dim) m=A.T*A.units.T; else m=A.T; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"vr")) { if(dim) m=A.vr*A.units.v; else m=A.vr; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"vt")) { if(dim) m=A.vt*A.units.v; else m=A.vt; if(fmt) matrix_fmt(fmt,(m,T_odd)); else (m,T_odd).write(stdout,'b'); } else if(!strcmp(var,"G")) { if(dim) m=A.G*A.units.v*A.units.r*A.units.rho; else m=A.G; if(fmt) matrix_fmt(fmt,(m,T_odd)); else (m,T_odd).write(stdout,'b'); } else if(!strcmp(var,"N2")) { m=A.N2(); if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"opa.k")) { m=A.opa.k; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"opa.xi")) { m=A.opa.xi; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"opa.dlnxi_lnT")) { m=A.opa.dlnxi_lnT; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"opa.dlnxi_lnrho")) { m=A.opa.dlnxi_lnrho; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"nuc.eps")) { m=A.nuc.eps; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"nuc.pp")) { m=A.nuc.pp; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"nuc.cno")) { m=A.nuc.cno; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"eos.G1")) { m=A.eos.G1; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"eos.cp")) { m=A.eos.cp; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"eos.del_ad")) { m=A.eos.del_ad; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"eos.G3_1")) { m=A.eos.G3_1; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"eos.cv")) { m=A.eos.cv; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"eos.d")) { m=A.eos.d; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"eos.prad")) { m=A.eos.prad; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"eos.chi_T")) { m=A.eos.chi_T; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"eos.chi_rho")) { m=A.eos.chi_rho; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"eos.s")) { m=A.eos.s; if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"L")) { d=A.luminosity(); if(fmt) fprintf(stdout,fmt,d); else { fwrite(&d,sizeof(double),1,stdout); } } else if(!strcmp(var,"L/L_SUN")) { d=A.luminosity()/L_SUN; if(fmt) fprintf(stdout,fmt,d); else { fwrite(&d,sizeof(double),1,stdout); } } else if(!strcmp(var,"Teff")) { m=A.Teff(); if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"Teff_eq")) { m=A.Teff(); d=A.map.leg.eval_00(m,PI/2)(0); if(fmt) fprintf(stdout,fmt,d); else { fwrite(&d,sizeof(double),1,stdout); } } else if(!strcmp(var,"Teff_pol")) { m=A.Teff(); d=A.map.leg.eval_00(m,0)(0); if(fmt) fprintf(stdout,fmt,d); else { fwrite(&d,sizeof(double),1,stdout); } } else if(!strcmp(var,"gsup")) { m=A.gsup(); if(fmt) matrix_fmt(fmt,(m,T)); else (m,T).write(stdout,'b'); } else if(!strcmp(var,"gsup_eq")) { m=A.gsup(); d=A.map.leg.eval_00(m,PI/2)(0); if(fmt) fprintf(stdout,fmt,d); else { fwrite(&d,sizeof(double),1,stdout); } } else if(!strcmp(var,"gsup_pol")) { m=A.gsup(); d=A.map.leg.eval_00(m,0)(0); if(fmt) fprintf(stdout,fmt,d); else { fwrite(&d,sizeof(double),1,stdout); } } else if(!strcmp(var,"eps")) { d=1-1./A.map.leg.eval_00(A.r,PI/2)(0); if(fmt) fprintf(stdout,fmt,d); else { fwrite(&d,sizeof(double),1,stdout); } } else if(!strcmp(var,"eps_c")) { d=0; if(A.conv) d=1-A.map.eta(A.conv)/A.map.leg.eval_00(A.map.R.row(A.conv),PI/2)(0); if(fmt) fprintf(stdout,fmt,d); else { fwrite(&d,sizeof(double),1,stdout); } } else if(!strcmp(var,"virial")) { d=A.virial(); if(fmt) fprintf(stdout,fmt,d); else { fwrite(&d,sizeof(double),1,stdout); } } else if(!strcmp(var,"energy_test")) { d=A.energy_test(); if(fmt) fprintf(stdout,fmt,d); else { fwrite(&d,sizeof(double),1,stdout); } } else { ester_err("Unknown variable %s", var); exit(1); } }
void configuration::missing_argument(const char *arg) { ester_err("Error: Argument to '%s' missing", arg); exit(1); }