11 #if defined __cplusplus
23 if( ( pops = (MCGIDI_POPs *) smr_malloc2( smr,
sizeof( MCGIDI_POPs ), 0,
"pops->sorted" ) ) == NULL )
return( NULL );
32 memset( pops, 0,
sizeof( MCGIDI_POPs ) );
33 if( size < 10 ) size = 10;
34 pops->increment = size;
43 if( pops == NULL )
return( NULL );
53 MCGIDI_POP *pop, *next;
55 if( pops == NULL )
return( 0 );
56 for( pop = pops->first; pop != NULL; pop = next ) {
68 double level_MeV, MCGIDI_POP *parent,
int globalParticle ) {
74 if( pops->size == pops->numberOfPOPs ) {
75 int size = pops->size + pops->increment;
76 MCGIDI_POP **sorted = (MCGIDI_POP **) smr_malloc2( smr, size *
sizeof( MCGIDI_POP * ), 0,
"sorted" );
78 if( sorted == NULL )
return( NULL );
79 for( i = 0; i < pops->numberOfPOPs; i++ ) sorted[i] = pops->sorted[i];
81 pops->sorted = sorted;
85 if( ( pop =
MCGIDI_POP_new( smr, name, mass_MeV, level_MeV, parent ) ) == NULL )
return( NULL );
86 for( i = pops->numberOfPOPs; i > index; i-- ) pops->sorted[i] = pops->sorted[i-1];
87 pops->sorted[index] = pop;
88 if( pops->first == NULL ) {
91 pops->last->next = pop;
95 pop->globalPoPsIndex = -1;
96 if( globalParticle ) {
106 int iCmp = 0,
min = 0, mid = 0,
max = pops->numberOfPOPs;
108 if(
max == 0 )
return( -1 );
109 while( (
max -
min ) > 1 ) {
111 iCmp = strcmp( name, pops->sorted[mid]->name );
112 if( iCmp == 0 )
return( mid );
120 if( strcmp( name, pops->sorted[0]->name ) == 0 )
return( 0 );
122 if( max < pops->numberOfPOPs ) {
123 if( strcmp( name, pops->sorted[
max]->name ) == 0 )
return(
max );
126 if( strcmp( name, pops->sorted[0]->name ) < 0 )
return( -1 );
137 if( index < 0 )
return( NULL );
138 return( pops->sorted[index] );
147 fprintf( f,
"POPs Information: n = %d\n", pops->numberOfPOPs );
148 for( i = 0; i < pops->numberOfPOPs; i++ ) fprintf( f,
" %-20s %e\n", pops->sorted[i]->name, pops->sorted[i]->mass_MeV );
165 MCGIDI_POP *
MCGIDI_POP_new( statusMessageReporting *smr,
char const *
name,
double mass_MeV,
double level_MeV, MCGIDI_POP *parent ) {
168 MCGIDI_POP *pop = (MCGIDI_POP *) smr_malloc2( smr,
sizeof( MCGIDI_POP ), 0,
"pop" );
170 if( pop == NULL )
return( NULL );
172 pop->parent = parent;
173 if( ( pop->name = smr_allocateCopyString2( smr, name,
"pop->name" ) ) == NULL ) {
182 pop->mass_MeV = mass_MeV;
183 pop->level_MeV = level_MeV;
184 pop->numberOfGammaBranchs = 0;
193 if( pop == NULL )
return( NULL );
203 if( pop == NULL )
return( NULL );
205 pop->numberOfGammaBranchs = 0;
206 if( pop->gammas != NULL )
smr_freeMemory( (
void **) &(pop->gammas) );
214 return( pop->mass_MeV );
217 #if defined __cplusplus
int MCGIDI_miscNameToZAm(statusMessageReporting *smr, const char *name, int *Z, int *A, int *m, int *level)
int MCGIDI_POPs_release(MCGIDI_POPs *pops)
MCGIDI_POP * MCGIDI_POP_new(statusMessageReporting *smr, char const *name, double mass_MeV, double level_MeV, MCGIDI_POP *parent)
int MCGIDI_POPs_initial(statusMessageReporting *, MCGIDI_POPs *pops, int size)
double A(double temperature)
MCGIDI_POP * MCGIDI_POPs_findParticle(MCGIDI_POPs *pops, char const *name)
int lPoPs_addParticleIfNeeded(statusMessageReporting *smr, char const *name, char const *special)
void * smr_freeMemory(void **p)
double MCGIDI_POP_getMass_MeV(MCGIDI_POP *pop)
MCGIDI_POP * MCGIDI_POPs_addParticleIfNeeded(statusMessageReporting *smr, MCGIDI_POPs *pops, char const *name, double mass_MeV, double level_MeV, MCGIDI_POP *parent, int globalParticle)
void MCGIDI_POPs_printSortedList(MCGIDI_POPs *pops)
int MCGIDI_POPs_findParticleIndex(MCGIDI_POPs *pops, char const *name)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
void * MCGIDI_POPs_free(MCGIDI_POPs *pops)
MCGIDI_POP * MCGIDI_POP_release(MCGIDI_POP *pop)
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
MCGIDI_POPs * MCGIDI_POPs_new(statusMessageReporting *smr, int size)
MCGIDI_POP * MCGIDI_POP_free(MCGIDI_POP *pop)
void MCGIDI_POPs_writeSortedList(MCGIDI_POPs *pops, FILE *f)