13 #if defined __cplusplus
18 #define incrementalSize 1000
22 #define AMU2MeV 931.494028
23 #define AMU2eV ( MeV2eV * 931.494028 )
24 #define K2MeV 8.6173856922566752e-11
25 #define K2eV ( MeV2eV * K2MeV )
49 {
"MeV",
"eV",
MeV2eV }, {
"MeV",
"keV",
MeV2keV }, {
"K",
"MeV",
K2MeV }, {
"K",
"eV",
K2eV } };
51 static char const *
PoPs_genreStrings[] = {
"invalid",
"unknown",
"alias",
"photon",
"lepton",
"quark",
"meson",
"baryon",
"nucleus",
"atom" };
125 if( pops == NULL )
return( NULL );
126 sorted = &(pops[size]);
165 if( ( newPoP = (
PoP *)
smr_malloc2( smr,
sizeof(
PoP ), 0,
"newPoP" ) ) == NULL )
return( NULL );
184 if( pop->
index < 0 ) {
242 if( high == 0 )
return( -1 );
243 while( ( high - low ) > 1 ) {
244 mid = ( low + high ) >> 1;
246 if( iCmp == 0 )
return( mid );
269 if( index < 0 )
return( -1. );
329 if( index < 0 )
return( -1 );
353 if( index < 0 )
return( -1 );
369 if( protonIsNucleus ) {
381 if( index < 0 )
return( NULL );
391 if( atomIndex < 0 )
return( NULL );
401 if( index < 0 )
return( index );
409 char const *
p = NULL;
471 fprintf( f,
"\n\n" );
473 fprintf( f,
" name index genre mass hasNucleus alias info\n" );
474 fprintf( f,
" Z A l\n" );
475 fprintf( f,
" --------------------------------------------------------------------------------------------\n" );
486 fprintf( f,
" T" ); }
491 fprintf( f,
" T" ); }
495 if( pop->
Z + pop->
A > 0 ) {
496 fprintf( f,
" %3d %3d", pop->
Z, pop->
A );
498 fprintf( f,
" %d", pop->
l ); }
526 if( ( pop = (
PoP *)
smr_malloc2( smr,
sizeof(
PoP ), 0,
"pop" ) ) == NULL )
return( NULL );
589 if( ( pop =
PoP_new( smr ) ) == NULL )
return( NULL );
614 return( pop->
index );
628 double mass = -1., ratio;
635 mass = pop->
mass * ratio;
652 if( properIndex < 0 ) {
656 if( aliasIndex >= 0 ) {
666 alias, truePop->
name, name );
670 if( ( pop =
PoP_new( smr ) ) == NULL )
return( NULL );
709 char const **unsorted = (
char const **)
smr_malloc2( smr, size *
sizeof(
char * ), 0,
"unsorted" );
711 if( unsorted == NULL )
return( NULL );
753 if( strcmp( _from, _to ) == 0 )
return( 0 );
754 for( i = 0; i <
n; i++ ) {
760 else if( strcmp(
conversions[i]._to, _from ) == 0 ) {
780 #if defined __cplusplus
int PoPs_versionMinor(void)
PoP * PoP_new(statusMessageReporting *smr)
PoP * PoP_makeAlias(statusMessageReporting *smr, char const *name, char const *alias)
#define smr_allocateCopyString2(smr, s, forItem)
int PoPs_versionPatchLevel(void)
char const * PoPs_genreTokenToString(enum PoPs_genre genre)
int PoP_setZ_A_l(statusMessageReporting *smr, PoP *pop, int Z, int A, int l)
static int referenceCount
double PoPs_getMassInUnitOf(statusMessageReporting *smr, char const *name, char const *unit)
#define POPS_VERSION_PATCHLEVEL
int PoPs_getZ_A_l_atIndex(statusMessageReporting *smr, int index, int *Z, int *A, int *l)
int PoPs_versionMajor(void)
char const * PoPs_getName_atIndex(statusMessageReporting *smr, int index)
int PoPs_particleReadDatabase(statusMessageReporting *smr, char const *name)
static char versionStr[64]
int PoPs_getZ_A_l(statusMessageReporting *smr, char const *name, int *Z, int *A, int *l)
int PoP_initialize(statusMessageReporting *smr, PoP *pop)
static int PoPs_particleProperIndex(int index)
#define POPS_VERSION_MINOR
double PoPs_getMassInUnitOf_atIndex(statusMessageReporting *smr, int index, char const *unit)
int PoPs_release(statusMessageReporting *smr)
int PoPs_particleIndex_smr(statusMessageReporting *smr, char const *name, char const *file, int line, char const *func)
static int unitsDB_release(void)
char const * PoP_getName(PoP *pop)
static int PoPs_sortedParticleIndex(char const *name)
int PoP_copyParticle(statusMessageReporting *smr, PoP *desc, PoP *src)
static unitConversions conversions[]
int PoP_getIndex(PoP *pop)
enum PoPs_genre PoPs_getGenre_atIndex(statusMessageReporting *smr, int index)
void PoPs_print(int sorted)
int PoPs_Bcast2(statusMessageReporting *smr, MPI_Comm comm, int bossRank, unitsDB *unitsRoot, PoPs *popsRoot)
double A(double temperature)
#define smr_setReportError2(smr, libraryID, code, fmt,...)
static char const * PoPs_genreStrings[]
int PoPs_unitConversionRatio(char const *_from, char const *_to, double *ratio)
int PoPs_readDatabase(statusMessageReporting *smr, char const *fileName)
PoP * PoPs_addAliasIfNeeded(statusMessageReporting *smr, char const *name, char const *alias)
int PoP_release(PoP *pop)
#define smr_malloc2(smr, size, zero, forItem)
PoP * PoPs_copyAddParticleIfNeeded(statusMessageReporting *smr, PoP *pop)
PoP * PoPs_addParticleIfNeeded(statusMessageReporting *smr, PoP *pop)
char const * PoPs_getAtomsName_atIndex(statusMessageReporting *smr, int index)
int PoPs_hasNucleus_atIndex(statusMessageReporting *smr, int index, int protonIsNucleus)
#define POPS_VERSION_MAJOR
enum PoPs_genre PoPs_getGenre(statusMessageReporting *smr, char const *name)
PoP * PoP_makeParticle(statusMessageReporting *smr, enum PoPs_genre genre, char const *name, double mass, char const *massUnit)
int PoPs_getAtomsIndex_atIndex(statusMessageReporting *smr, int index)
char const * unitsDB_stringFromIndex(statusMessageReporting *smr, int index)
void * smr_freeMemory(void **p)
int smr_setReportError(statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt,...)
int unitsDB_index(statusMessageReporting *smr, char const *unit)
char const * unitsDB_addUnitIfNeeded(statusMessageReporting *smr, char const *unit)
PoP * PoPs_getParticle_atIndex(int index)
char const * PoPs_getAtomsName(statusMessageReporting *smr, char const *name)
double PoP_getMassInUnitOf(statusMessageReporting *smr, PoP *pop, char const *unit)
const char * PoPs_version(void)
void * MPI_Comm
to pass hd2mpi ////////////////////////////////////////////
int PoPs_numberOfParticle(void)
int PoPs_hasNucleus(statusMessageReporting *smr, char const *name, int protonIsNucleus)
void PoPs_write(FILE *f, int sorted)
int PoPs_getAtomsIndex(statusMessageReporting *smr, char const *name)
int PoPs_releasePrivate(statusMessageReporting *smr)
int PoPs_particleIndex(char const *name)