void UpdateuF(int k, matrix_type M, column_type* c, int ndepths) { // Calculates P in the Feautrier solution to the radiative transfer double *tmp1, *tmp2, *tmpu; int i, j; tmp1 = dvector(NMU); tmp2 = dvector(NMU); tmpu = dvector(NMU); MatrixVectorMultiply(tmpu, c[ndepths-1].BFtmpinv, c[ndepths-1].QFtmp, NMU); for (j=0; j<NMU; j++) { c[ndepths-1].u[j][k]= tmpu[j]; } for (i=(ndepths-2); i>=0; i--) { CalcCF(M.CF, i, k, c, ndepths); MatrixVectorMultiply(tmp1, M.CF, tmpu, NMU); for (j=0; j<NMU; j++) { tmp2[j] = c[i].QFtmp[j] - tmp1[j]; } MatrixVectorMultiply(tmpu, c[i].BFtmpinv, tmp2, NMU); for (j=0; j<NMU; j++) { c[i].u[j][k]= tmpu[j]; } } free(tmp1); free(tmp2); free(tmpu); }
void Updateu(int j, int k, double** TInverse, double* K, double **U, column_type* c, int ndepths) { // Calculates P in the Rybicki method in the radiative transfer double *tmp1, **tmp2, *tmp3, u; int i, s; tmp1 = dvector(ndepths); tmp2 = ddvector(ndepths); tmp3 = dvector(ndepths); for (i=0; i<ndepths; i++) { tmp2[i]=dvector(ndepths); } MatrixVectorMultiply(tmp1, TInverse, K, ndepths); MatrixDiagonalMatrixMultiply(tmp2,TInverse,U, ndepths); for (i=0; i<ndepths; i++) { tmp3[i]=0.0; for (s=0; s<ndepths; s++) { tmp3[i] += tmp2[i][s] * c[s].Jbar; } u=tmp1[i] - tmp3[i]; c[i].u[j][k]= u; } for (i=0; i<ndepths; i++) { free(tmp2[i]); } free(tmp1); free(tmp2); free(tmp3); }
void CalcQFtmp(double *QFtmp, double **AF, double **prevBFtmpinv, double *QF, double *prevQFtmp) { // Calculates a temporary vector used in the Feautrier solution to the radiative transfer double *tmp1, *tmp2; int j; tmp1 = dvector(NMU); tmp2 = dvector(NMU); MatrixVectorMultiply(tmp1, prevBFtmpinv, prevQFtmp, NMU); MatrixVectorMultiply(tmp2, AF, tmp1, NMU); for (j=0; j<NMU; j++) { QFtmp[j] = QF[j] - tmp2[j]; } free(tmp1); free(tmp2); }
void UpdateQ(double *Q, double **V, double **TInverse, double *K, int ndepths) { // Calculates the vector Q in the Rybicki method int i; double *tmp2, *tmp3; tmp2 = dvector(ndepths); tmp3 = dvector(ndepths); MatrixVectorMultiply(tmp2, TInverse, K, ndepths); MatrixVectorMultiply(tmp3,V,tmp2, ndepths); for (i=0; i<ndepths; i++) { Q[i] -= tmp3[i]; } free(tmp3); free(tmp2); }
void UpdateJt(int k, double** TInverse, double* K, double **U, column_type* c, int ndepths, int iteration, int ionekev) { // Calculates Jt in the temperature correction procedure double *tmp1, **tmp2, *tmp3, u; int i, s; FILE *fp; char filename[FILENAME]; tmp1 = dvector(ndepths); tmp2 = ddvector(ndepths); tmp3 = dvector(ndepths); for (i=0; i<ndepths; i++) { tmp2[i]=dvector(ndepths); } MatrixVectorMultiply(tmp1, TInverse, K, ndepths); MatrixDiagonalMatrixMultiply(tmp2,TInverse,U, ndepths); for (i=0; i<ndepths; i++) { tmp3[i]=0.0; for (s=0; s<ndepths; s++) { tmp3[i] += tmp2[i][s] * c[s].Jtbar; } u=tmp1[i] - tmp3[i]; c[i].Jt[k]= u; } for (i=0; i<ndepths; i++) { free(tmp2[i]); } free(tmp1); free(tmp2); free(tmp3); sprintf(filename,"OUT/JvsJt.%d.dat", iteration); fp= fopen(filename, "w"); fprintf(fp,"#J, Jt, Jt/J\n"); for (i=0; i<ndepths; i++) { fprintf(fp,"%e %e %e\n", c[i].J[ionekev], c[i].Jt[ionekev], c[i].Jt[ionekev]/c[i].J[ionekev]); } fclose(fp); }
static void CM_GetIntersectingPoint(cplane_t * a, cplane_t * b, cplane_t * c, vec3_t out) { matrix3_t sysmat, sysmatInverse; vec3_t dists; sysmat[0][0] = a->normal[0]; sysmat[0][1] = b->normal[0]; sysmat[0][2] = c->normal[0]; sysmat[1][0] = a->normal[1]; sysmat[1][1] = b->normal[1]; sysmat[1][2] = c->normal[1]; sysmat[2][0] = a->normal[2]; sysmat[2][1] = b->normal[2]; sysmat[2][2] = c->normal[2]; MatrixInverse(sysmat, sysmatInverse); VectorSet(dists, a->dist, b->dist, c->dist); MatrixVectorMultiply(sysmatInverse, dists, out); }
void CalcJbar(double **W, double *Q, column_type *c, int ndepths) { // Calculates the quantity Jbar, used in the Rybicki solution of the radiative transfer extern double *dnu; int i, k; double **tmp1, *tmp2, nutot,a; tmp1 = ddvector(ndepths); tmp2 = dvector(ndepths); for (i=0; i<ndepths; i++) { tmp1[i]=dvector(ndepths); } InvertMatrix(tmp1, W, ndepths); MatrixVectorMultiply(tmp2, tmp1, Q, ndepths); nutot=0; for (k=0; k<NFREQ; k++) { nutot+=dnu[k]; } for (i=0; i<ndepths; i++) { c[i].Jbar = tmp2[i]; c[i].Jbarb=0; for (k=0; k<NFREQ; k++) { c[i].Jbarb += c[i].J[k]*dnu[k]; } c[i].Jbarb /= nutot; a=c[i].Jbarb/c[i].Jbar; } for (i=0; i<ndepths; i++) { free(tmp1[i]); } free(tmp1); free(tmp2); }