From 4752b731601dccef52d671167abefe7755ae3195 Mon Sep 17 00:00:00 2001 From: Parfenov Sergey Date: Sat, 22 Aug 2015 22:21:09 +0500 Subject: [PATCH 1/6] New parameter The new parameter is used to check whether the user provides velocity from the predefined grid. --- src/lime.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lime.h b/src/lime.h index 2a5353b..e5e933c 100644 --- a/src/lime.h +++ b/src/lime.h @@ -87,7 +87,7 @@ typedef struct { char *pregrid; char *restart; char *dust; - int sampling,collPart,lte_only,antialias,polarization,doPregrid,nThreads; + int sampling,collPart,lte_only,antialias,polarization,doPregrid,nThreads,pregridVel; char **moldatfile; } inputPars; From 2c3dd2f505523b1a9e858de313ff83d2bce25ba6 Mon Sep 17 00:00:00 2001 From: Parfenov Sergey Date: Sat, 22 Aug 2015 22:25:22 +0500 Subject: [PATCH 2/6] Default value for the new parameter The default value of the new parameter means that the velocity field obtained with the velocity function but not from the predefined grid. --- src/aux.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/aux.c b/src/aux.c index ce7f383..aa53415 100644 --- a/src/aux.c +++ b/src/aux.c @@ -39,6 +39,7 @@ parseInput(inputPars *par, image **img, molData **m){ par->sinkPoints=0; par->doPregrid=0; par->nThreads=0; + par->pregridVel=0; /* Allocate space for output fits images */ (*img)=malloc(sizeof(image)*MAX_NSPECIES); From bb6034eb6dde053d877cf47c054eb88da3ed3f1d Mon Sep 17 00:00:00 2001 From: Parfenov Sergey Date: Sat, 22 Aug 2015 22:37:20 +0500 Subject: [PATCH 3/6] Additional check of velocity field The code always assumes that if the user supplied the predefined grid then the velocity was taken from this grid. This may be not the case. It is better to perform additional check on whether the velocity field was taken from the predefined grid or was obtained with the velocity function. --- src/photon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/photon.c b/src/photon.c index 4533870..8991e40 100644 --- a/src/photon.c +++ b/src/photon.c @@ -217,7 +217,7 @@ photon(int id, struct grid *g, molData *m, int iter, const gsl_rng *ran,inputPar ds=g[here].ds[dir]/2.; halfFirstDs[iphot]=ds; for(l=0;lnSpecies;l++){ - if(!par->doPregrid) velocityspline(g,here,dir,g[id].mol[l].binv,deltav,&vfac[l]); + if(!par->doPregrid || !par->pregridVel) velocityspline(g,here,dir,g[id].mol[l].binv,deltav,&vfac[l]); else velocityspline_lin(g,here,dir,g[id].mol[l].binv,deltav,&vfac[l]); mp[l].vfac[iphot]=vfac[0]; } @@ -228,7 +228,7 @@ photon(int id, struct grid *g, molData *m, int iter, const gsl_rng *ran,inputPar } for(l=0;lnSpecies;l++){ - if(!par->doPregrid) velocityspline(g,here,dir,g[id].mol[l].binv,deltav,&vfac[l]); + if(!par->doPregrid || !par->pregridVel) velocityspline(g,here,dir,g[id].mol[l].binv,deltav,&vfac[l]); else velocityspline_lin(g,here,dir,g[id].mol[l].binv,deltav,&vfac[l]); } @@ -259,7 +259,7 @@ photon(int id, struct grid *g, molData *m, int iter, const gsl_rng *ran,inputPar alpha=0.; for(jline=0;jlinedoPregrid) velocityspline(g,here,dir,g[id].mol[counta[jline]].binv,deltav-matrix[jline].deltav,&vblend); + if(!par->doPregrid || !par->pregridVel) velocityspline(g,here,dir,g[id].mol[counta[jline]].binv,deltav-matrix[jline].deltav,&vblend); else velocityspline_lin(g,here,dir,g[id].mol[counta[jline]].binv,deltav-matrix[jline].deltav,&vblend); sourceFunc_line(&jnu,&alpha,m,vblend,g,here,counta[jline],countb[jline]); dtau=alpha*ds; From de2df3b083b6f1e7dfae878c4b4ca8b133620687 Mon Sep 17 00:00:00 2001 From: Parfenov Sergey Date: Sat, 22 Aug 2015 22:39:12 +0500 Subject: [PATCH 4/6] Additional check of velocity field The code always assumes that if the user supplied the predefined grid then the velocity was taken from this grid. This may be not the case. It is better to perform additional check on whether the velocity field was taken from the predefined grid or was obtained with the velocity function. --- src/raytrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/raytrace.c b/src/raytrace.c index 8c6131e..dc330a6 100644 --- a/src/raytrace.c +++ b/src/raytrace.c @@ -125,7 +125,7 @@ traceray(rayData ray, int tmptrans, int im, inputPars *par, struct grid *g, molD vThisChan=(ichan-(img[im].nchan-1)/2.)*img[im].velres; // Consistent with the WCS definition in writefits(). deltav = vThisChan - img[im].source_vel + shift; - if(!par->pregrid) velocityspline2(x,dx,ds,g[posn].mol[counta[iline]].binv,deltav,&vfac); + if(!par->pregrid || !par->pregridVel) velocityspline2(x,dx,ds,g[posn].mol[counta[iline]].binv,deltav,&vfac); else vfac=gaussline(deltav+veloproject(dx,g[posn].vel),g[posn].mol[counta[iline]].binv); sourceFunc_line(&jnu,&alpha,m,vfac,g,posn,counta[iline],countb[iline]); From c7ee1a2004da0b772e982b8fa187e1df693321bc Mon Sep 17 00:00:00 2001 From: Parfenov Sergey Date: Sat, 22 Aug 2015 22:52:34 +0500 Subject: [PATCH 5/6] Check of what variables are given in input file These commits allow the code to check what variables were supplied by the user in the predefined grid. If some variables were not provided in the input file then they will be computed with the model functions. It also important that the code checks whether the velocity field was supplied in the predefined grid. This information is then used in photon and traceray procedures. --- src/predefgrid.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/predefgrid.c b/src/predefgrid.c index 4aed807..57a95b8 100644 --- a/src/predefgrid.c +++ b/src/predefgrid.c @@ -25,6 +25,13 @@ predefinedGrid(inputPars *par, struct grid *g){ par->ncell=par->pIntensity+par->sinkPoints; for(i=0;ipIntensity;i++){ + g[i].id = -1; + g[i].dens[0] = -1.0; + g[i].t[0] = -1.0; + g[i].dopb = -1.0; + g[i].abun[0] = -1.0; + g[i].vel[0] = 1.e40; g[i].vel[1] = 1.e40; g[i].vel[2] = 1.e40; + // fscanf(fp,"%lf %lf %lf\n", &g[i].x[0], &g[i].x[1], &g[i].x[2]); // fscanf(fp,"%d %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf\n", &g[i].id, &g[i].x[0], &g[i].x[1], &g[i].x[2], &g[i].dens[0], &g[i].t[0], &abun, &g[i].dopb, &g[i].vel[0], &g[i].vel[1], &g[i].vel[2]); // fscanf(fp,"%d %lf %lf %lf %lf %lf %lf %lf\n", &g[i].id, &g[i].x[0], &g[i].x[1], &g[i].x[2], &g[i].dens[0], &g[i].t[0], &abun, &g[i].dopb); int nRead = fscanf(fp,"%d %lf %lf %lf %lf %lf %lf %lf %lf\n", &g[i].id, &g[i].x[0], &g[i].x[1], &g[i].x[2], &g[i].dens[0], &g[i].t[0], &g[i].vel[0], &g[i].vel[1], &g[i].vel[2]); @@ -34,19 +41,22 @@ predefinedGrid(inputPars *par, struct grid *g){ exit(0); } - g[i].dopb=200; - g[i].abun[0]=1e-9; - + if(g[i].id==-1) g[i].id = i; + if(g[i].dens[0]==-1.0) density(g[i].x[0],g[i].x[1],g[i].x[2],g[i].dens); + if(g[i].t[0]==-1.0) temperature(g[i].x[0],g[i].x[1],g[i].x[2],g[i].t); + if(g[i].dopb==-1.0) doppler(g[i].x[0],g[i].x[1],g[i].x[2],&g[i].dopb); + if(g[i].abun[0]==-1.0) abundance(g[i].x[0],g[i].x[1],g[i].x[2],g[i].abun); + if(g[i].vel[0]!=1.e40 && g[i].vel[1]!=1.e40 && g[i].vel[2]!=1.e40) par->pregridVel = 1; g[i].sink=0; - g[i].t[1]=g[i].t[0]; - g[i].nmol[0]=g[i].abun[0]*g[i].dens[0]; + g[i].t[1]=g[i].t[0]; + g[i].nmol[0]=g[i].abun[0]*g[i].dens[0]; - /* This next step needs to be done, even though it looks stupid */ - g[i].dir=malloc(sizeof(point)*1); - g[i].ds =malloc(sizeof(double)*1); - g[i].neigh =malloc(sizeof(struct grid *)*1); - if(!silent) progressbar((double) i/((double)par->pIntensity-1), 4); + /* This next step needs to be done, even though it looks stupid */ + g[i].dir=malloc(sizeof(point)*1); + g[i].ds =malloc(sizeof(double)*1); + g[i].neigh =malloc(sizeof(struct grid *)*1); + if(!silent) progressbar((double) i/((double)par->pIntensity-1), 4); } for(i=par->pIntensity;incell;i++){ @@ -73,7 +83,8 @@ predefinedGrid(inputPars *par, struct grid *g){ distCalc(par,g); // getArea(par,g, ran); // getMass(par,g, ran); - getVelosplines_lin(par,g); + if(par->pregridVel) getVelosplines_lin(par,g); + else getVelosplines(par,g); if(par->gridfile) write_VTK_unstructured_Points(par, g); gsl_rng_free(ran); } From 8eea8b954e734b0add1db5f88f163a4302830e80 Mon Sep 17 00:00:00 2001 From: Parfenov Sergey Date: Sat, 22 Aug 2015 23:13:26 +0500 Subject: [PATCH 6/6] Notes on modification of predefined grid Additional notes may be useful for the users who want to change the format of file with the predefined grid. --- doc/usermanual.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/usermanual.rst b/doc/usermanual.rst index e6c9578..4267600 100644 --- a/doc/usermanual.rst +++ b/doc/usermanual.rst @@ -409,6 +409,11 @@ If this option is used, LIME will not generate its own grid, but rather use the grid defined in this file. The file needs to contain all physical properties of the grid points, i.e., density, temperature, abundance, velocity etc. There is no default value. +An experienced user can change what physical properties will be taken +from the input file. This can be done modifying the predefinedGrid +function in the predefgrid.c file. The physical properties that will not +be taken from the input file will be computed with the model +functions (see below). .. code:: c