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_getZ_A_l_atIndex(statusMessageReporting *smr, int index, int *Z, int *A, int *l)
static int PoPs_particleProperIndex(int index)
void PoPs_print(int sorted)
int PoPs_unitConversionRatio(char const *_from, char const *_to, double *ratio)
double PoP_getMassInUnitOf(statusMessageReporting *smr, PoP *pop, char const *unit)
#define POPS_VERSION_MAJOR
int PoPs_getAtomsIndex(statusMessageReporting *smr, char const *name)
char const * PoPs_getAtomsName(statusMessageReporting *smr, char const *name)
static int PoPs_sortedParticleIndex(char const *name)
#define smr_allocateCopyString2(smr, s, forItem)
#define smr_setReportError2(smr, libraryID, code, fmt,...)
static unitConversions conversions[]
int PoPs_versionMinor(void)
int PoPs_readDatabase(statusMessageReporting *smr, char const *fileName)
const char * PoPs_version(void)
double PoPs_getMassInUnitOf_atIndex(statusMessageReporting *smr, int index, char const *unit)
int PoPs_versionPatchLevel(void)
int PoPs_numberOfParticle(void)
int PoPs_hasNucleus_atIndex(statusMessageReporting *smr, int index, int protonIsNucleus)
int PoPs_releasePrivate(statusMessageReporting *smr)
PoP * PoP_makeAlias(statusMessageReporting *smr, char const *name, char const *alias)
char const * PoPs_getAtomsName_atIndex(statusMessageReporting *smr, int index)
enum PoPs_genre PoPs_getGenre(statusMessageReporting *smr, char const *name)
int PoPs_getAtomsIndex_atIndex(statusMessageReporting *smr, int index)
PoP * PoPs_addAliasIfNeeded(statusMessageReporting *smr, char const *name, char const *alias)
int PoPs_particleReadDatabase(statusMessageReporting *smr, char const *name)
#define smr_malloc2(smr, size, zero, forItem)
int PoPs_versionMajor(void)
char const * PoP_getName(PoP *pop)
int PoPs_particleIndex(char const *name)
void PoPs_write(FILE *f, int sorted)
#define POPS_VERSION_MINOR
double A(double temperature)
int PoPs_particleIndex_smr(statusMessageReporting *smr, char const *name, char const *file, int line, char const *func)
int PoP_release(PoP *pop)
char const * PoPs_genreTokenToString(enum PoPs_genre genre)
char const * unitsDB_addUnitIfNeeded(statusMessageReporting *smr, char const *unit)
void * smr_freeMemory(void **p)
#define POPS_VERSION_PATCHLEVEL
static char versionStr[64]
static int unitsDB_release(void)
static char const * PoPs_genreStrings[]
PoP * PoPs_copyAddParticleIfNeeded(statusMessageReporting *smr, PoP *pop)
static int referenceCount
int PoPs_Bcast2(statusMessageReporting *smr, MPI_Comm comm, int bossRank, unitsDB *unitsRoot, PoPs *popsRoot)
int PoP_getIndex(PoP *pop)
char const * PoPs_getName_atIndex(statusMessageReporting *smr, int index)
int PoPs_hasNucleus(statusMessageReporting *smr, char const *name, int protonIsNucleus)
int PoP_setZ_A_l(statusMessageReporting *smr, PoP *pop, int Z, int A, int l)
PoP * PoP_new(statusMessageReporting *smr)
PoP * PoP_makeParticle(statusMessageReporting *smr, enum PoPs_genre genre, char const *name, double mass, char const *massUnit)
void * MPI_Comm
to pass hd2mpi ////////////////////////////////////////////
PoP * PoPs_addParticleIfNeeded(statusMessageReporting *smr, PoP *pop)
enum PoPs_genre PoPs_getGenre_atIndex(statusMessageReporting *smr, int index)
char const * unitsDB_stringFromIndex(statusMessageReporting *smr, int index)
double PoPs_getMassInUnitOf(statusMessageReporting *smr, char const *name, char const *unit)
int PoP_copyParticle(statusMessageReporting *smr, PoP *desc, PoP *src)
int smr_setReportError(statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt,...)
int PoP_initialize(statusMessageReporting *smr, PoP *pop)
PoP * PoPs_getParticle_atIndex(int index)
int unitsDB_index(statusMessageReporting *smr, char const *unit)
int PoPs_getZ_A_l(statusMessageReporting *smr, char const *name, int *Z, int *A, int *l)
int PoPs_release(statusMessageReporting *smr)