-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfdprime.c
executable file
·104 lines (90 loc) · 3.16 KB
/
fdprime.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/***************************************************************************
get_fpp.c - Use mucal to et f'' values
-------------------
begin : Sat July 6 12:01:02 GMT 2002
copyright : (C) 2002 by Gwyndaf Evans
email : gwyndaf@gwyndafevans.co.uk
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <float.h>
#include <math.h>
#include "chooch.h"
#include "mucal.h"
double get_CrossSection(char *sElement, double dEnergyKeV)
{
double dEnergy[9], dXsec[11], dFluo[4];
double dXsection;
int iZZ = 0, iPflag=0;
int err;
char sUnit='a', sErrmsg[256];
// printf("%s ",sElement);
if((err=mucal(sElement, iZZ, dEnergyKeV, sUnit, iPflag, dEnergy, dXsec, dFluo, &sErrmsg[0])) != 0) {
// printf("MUCAL error in get_fpp %d %s\n", err, sErrmsg);
// exit(EXIT_FAILURE);
}
dXsection = dXsec[0];
return dXsection;
}
/*
* Return the name of absorption edge given the array index of dEnergy
*/
char *edge_name(int n)
{
static char *name[] = {
"K", "L1", "L2", "L3", "M", "Bad edge"
};
return (n < 0 || n > 4) ? name[5] : name[n];
}
char *get_Edge(char *sElement, double fMidE, double *fE)
{
/*
* Given the mid point of recorded spectrum and element, guess the edge energy
*/
extern int verbose;
double dEnergy[9], dXsec[11], dFluo[4];
/* double diff, mindiff=1e10, E; changed for next line on 7/3/2010 for v5.0.8*/
double diff, mindiff=1e10;
int i, iE=0, iZZ = 0, iPflag=0;
int err;
char sUnit='a', sErrmsg[256];
fMidE/=1000.0;
if((err=mucal(sElement, iZZ, 0.0, sUnit, iPflag, dEnergy, dXsec, dFluo, &sErrmsg[0])) != 0) {
printf("WARNING: Problem getting edge energy from mucal");
}
if(verbose>0)printf(" Mid point of spectrum = %f\n", fMidE);
if(verbose>0)printf(" E edge E diff\n");
for(i=0; i<5; i++){
diff=fabs(fMidE-dEnergy[i]);
if(diff < mindiff){
mindiff=diff;
iE=i;
*fE=dEnergy[i]*1000.0;
}
if(verbose>0)printf(" %8.4f %8.4f\n", dEnergy[i], diff);
}
return edge_name(iE);
}
double get_fpp (char *sElement, double dEnergyKeV)
{
double dFdprime;
dFdprime = 143.10935e-10 * dEnergyKeV * 1000.0 * get_CrossSection(sElement, dEnergyKeV);
return dFdprime;
}
double get_splinor (char *sElement, double dEnergyKeV)
{
double dCrossSection;
dCrossSection = get_CrossSection(sElement, dEnergyKeV);
return dCrossSection;
}