mirror of
https://github.com/LCPQ/DEHam
synced 2024-08-16 01:28:36 +02:00
40 lines
1.1 KiB
C
40 lines
1.1 KiB
C
|
#include "get_ntot.h"
|
||
|
|
||
|
int get_ntot(_Bool FAM1, int natom, long int isz, long int ntrou, long int fix_trou1, long int fix_trou2){
|
||
|
int tnt1, tnt2;
|
||
|
int natom2;
|
||
|
if(FAM1){
|
||
|
if(fix_trou1 == fix_trou2){
|
||
|
natom2 = natom/2;
|
||
|
}
|
||
|
else{
|
||
|
natom2 = fix_trou2 - fix_trou1;
|
||
|
}
|
||
|
}
|
||
|
else{
|
||
|
natom2 = natom;
|
||
|
}
|
||
|
|
||
|
tnt1 = (int)exp(lgamma((double)(natom2+1)) - (lgamma((double)(natom2-ntrou+1)) + lgamma((double)(ntrou+1))));
|
||
|
int nalpha, nbeta;
|
||
|
|
||
|
if((((natom-ntrou) + 2*isz) % 2) == 0){
|
||
|
nalpha=(natom-ntrou+2*isz)/2;
|
||
|
nbeta=(natom -ntrou-2*isz)/2;
|
||
|
if(((natom-ntrou)/2) == isz){
|
||
|
nbeta=0;
|
||
|
}
|
||
|
}
|
||
|
else{
|
||
|
nalpha=(natom-ntrou+2*isz+1)/2;
|
||
|
nbeta=(natom -ntrou-2*isz-1)/2;
|
||
|
if(((natom-ntrou+1)/2) == isz){
|
||
|
nbeta=0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
tnt2 = (int) exp(lgamma((double)(natom-ntrou+1)) - (lgamma((double)(nalpha+1)) + lgamma((double)(nbeta+1))));
|
||
|
//printf("nalpha=%d nbeta=%d | | %d %d ntot=%d\n",nalpha, nbeta, tnt1, tnt2, tnt1*tnt2);
|
||
|
return tnt1*tnt2;
|
||
|
}
|