Skip to content

Commit

Permalink
Fixes #265
Browse files Browse the repository at this point in the history
- Code in collparts.c now tests for par->useAbun before issuing various warnings/errors about par->nMolWeights.
  • Loading branch information
imckstewart committed Aug 3, 2018
1 parent 5474f02 commit 99a1e00
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 28 deletions.
59 changes: 32 additions & 27 deletions src/collparts.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,12 @@ This deals with four user-settable list parameters which relate to collision par
par->collPartIds = realloc(par->collPartIds, sizeof(*(par->collPartIds))*par->numDensities);
}

if(!silent && !par->useAbun && numUserSetNMWs>0)
warning("You only need to set par->nMolWeights if you have provided an abundance function.");

/* Check if we have either 0 par->nMolWeights or the same number as the number of density values.
*/
if(numUserSetNMWs != par->numDensities){
if(par->useAbun && numUserSetNMWs != par->numDensities){
free(par->nMolWeights);
par->nMolWeights = NULL;
/* Note that in the present case we will (for a line-emission image) look for the collision partners listed in the moldatfiles and set par->nMolWeights from them. */
Expand Down Expand Up @@ -236,7 +239,7 @@ This deals with four user-settable list parameters which relate to collision par
free(uniqueCPIds);
}

if(numUserSetNMWs>0){
if(par->useAbun && numUserSetNMWs>0){
/* Check that they do not sum to zero.
*/
sum = 0.0;
Expand Down Expand Up @@ -320,40 +323,42 @@ To preserve backward compatibility I am going to try to make the same guesses as
#endif
}

if(par->nMolWeights==NULL){
/*
if(par->useAbun){
if(par->nMolWeights==NULL){
/*
The same backward-compatible guesses are made here as for par->collPartIds in the foregoing section of code. I've omitted warnings and errors because they have already been issued during the treatment of par->collPartIds.
*/
if(numUniqueCollParts==1){
if(allUniqueCollPartIds[0]==CP_H2 || allUniqueCollPartIds[0]==CP_p_H2 || allUniqueCollPartIds[0]==CP_o_H2){
*/
if(numUniqueCollParts==1){
if(allUniqueCollPartIds[0]==CP_H2 || allUniqueCollPartIds[0]==CP_p_H2 || allUniqueCollPartIds[0]==CP_o_H2){
par->nMolWeights = malloc(sizeof(double)*par->numDensities);
par->nMolWeights[0] = 1.0;
}

}else if(numUniqueCollParts==2){
if((allUniqueCollPartIds[0]==CP_p_H2 && allUniqueCollPartIds[1]==CP_o_H2)\
|| (allUniqueCollPartIds[1]==CP_p_H2 && allUniqueCollPartIds[0]==CP_o_H2)){
par->nMolWeights = malloc(sizeof(double)*par->numDensities);
for(i=0;i<par->numDensities;i++) /* At this point par->numDensities can be only ==1 (previously signalled via 'flag') or ==2. */
par->nMolWeights[i] = 1.0;
}

}else if(numUniqueCollParts==par->numDensities){ /* At this point, numUniqueCollParts must be >2. */
par->nMolWeights = malloc(sizeof(double)*par->numDensities);
for(i=0;i<par->numDensities;i++)
par->nMolWeights[i] = 0.0;
par->nMolWeights[0] = 1.0;
par->nMolWeights[1] = 1.0;
}

}else if(numUniqueCollParts==2){
if((allUniqueCollPartIds[0]==CP_p_H2 && allUniqueCollPartIds[1]==CP_o_H2)\
|| (allUniqueCollPartIds[1]==CP_p_H2 && allUniqueCollPartIds[0]==CP_o_H2)){
par->nMolWeights = malloc(sizeof(double)*par->numDensities);
for(i=0;i<par->numDensities;i++) /* At this point par->numDensities can be only ==1 (previously signalled via 'flag') or ==2. */
par->nMolWeights[i] = 1.0;
}else{
if(!silent){
warning("Your choices for par.nMolWeights have been let stand, but it");
warning("is risky to set them without also setting par.collPartIds.");
}

}else if(numUniqueCollParts==par->numDensities){ /* At this point, numUniqueCollParts must be >2. */
par->nMolWeights = malloc(sizeof(double)*par->numDensities);
for(i=0;i<par->numDensities;i++)
par->nMolWeights[i] = 0.0;
par->nMolWeights[0] = 1.0;
par->nMolWeights[1] = 1.0;
}

}else{
if(!silent){
warning("Your choices for par.nMolWeights have been let stand, but it");
warning("is risky to set them without also setting par.collPartIds.");
}
}

}else if(par->nMolWeights==NULL){ /* We get here only if the user has not supplied these values (or not supplied the right number of them) in their model.c. */
}else if(par->useAbun && par->nMolWeights==NULL){ /* We get here only if the user has not supplied these values (or not supplied the right number of them) in their model.c. */
if(par->numDensities==1){
if(par->collPartIds[0]==CP_H2 || par->collPartIds[0]==CP_p_H2 || par->collPartIds[0]==CP_o_H2){
par->nMolWeights = malloc(sizeof(double)*par->numDensities);
Expand Down
2 changes: 1 addition & 1 deletion src/lime.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

#include "dims.h"

#define VERSION "1.9.3"
#define VERSION "1.9.4"
#define DEFAULT_NTHREADS 1
#ifndef NTHREADS /* Value passed from the LIME script */
#define NTHREADS DEFAULT_NTHREADS
Expand Down

0 comments on commit 99a1e00

Please sign in to comment.