Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions libdedx/dedx_periodic_table.c
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
#include "dedx_periodic_table.h"
float _dedx_get_atom_charge(int id, int *err)
{
if(id < 113)
{
return id;

float _dedx_get_atom_charge(int id, int *err) {
if (id < 113) {
return id;
}
*err = 204;
return -1;
}
float _dedx_get_atom_mass(int id, int *err)
{

float _dedx_get_atom_mass(int id, int *err) {
*err = 0;
if(id < 113)
return dedx_amu[id-1];
if (id < 113)
return dedx_amu[id - 1];
*err = 204;
return -1;
}

int _dedx_get_nucleon(int id, int *err){
*err = 0;
if (id < 113)
return dedx_nucl[id - 1];
*err = 204;
return -1;
}
44 changes: 32 additions & 12 deletions libdedx/dedx_periodic_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,40 @@
#define DEDX_PERIODIC_TABLE_H_INCLUDED

static const float dedx_amu[112] = {
1.00794, 4.002602, 6.941, 9.012182, 10.811, 12.0107, 14.0067, 15.9994,
18.9984032, 20.1797, 22.98976928, 24.3050, 26.9815386, 28.0855, 30.973762,
32.065, 35.453, 39.948, 39.0983, 40.078, 44.955912, 47.867, 50.9415, 51.9961,
54.938045, 55.845, 58.933195, 58.6934, 63.546, 65.38, 69.723, 72.64,
74.92160, 78.96, 79.904, 83.798, 85.4678, 87.62, 88.90585, 91.224, 92.90638,
95.96, 98, 101.07, 102.90550, 106.42, 107.8682, 112.411, 114.818, 118.710,
121.760, 127.60, 126.90447, 131.293, 132.9054519, 137.327, 138.90547, 140.116,
140.90765, 144.242, 145, 150.36, 151.964, 157.25, 158.92535, 162.500,
164.93032, 167.259, 168.93421, 173.054, 174.9668, 178.49, 180.94788, 183.84,
186.207, 190.23, 192.217, 195.084, 196.966569, 200.59, 204.3833, 207.2,
208.98040, 209, 210, 222, 223, 226, 227, 232.03806, 231.03588, 238.02891,
237, 244, 243, 247, 247, 251,252,257,258,259,262,267,268,271,272,270,276,281,280,285};
1.00794, 4.002602, 6.941, 9.012182, 10.811, 12.0107, 14.0067, 15.9994,
18.9984032, 20.1797, 22.98976928, 24.3050, 26.9815386, 28.0855, 30.973762,
32.065, 35.453, 39.948, 39.0983, 40.078, 44.955912, 47.867, 50.9415, 51.9961,
54.938045, 55.845, 58.933195, 58.6934, 63.546, 65.38, 69.723, 72.64,
74.92160, 78.96, 79.904, 83.798, 85.4678, 87.62, 88.90585, 91.224, 92.90638,
95.96, 98, 101.07, 102.90550, 106.42, 107.8682, 112.411, 114.818, 118.710,
121.760, 127.60, 126.90447, 131.293, 132.9054519, 137.327, 138.90547, 140.116,
140.90765, 144.242, 145, 150.36, 151.964, 157.25, 158.92535, 162.500,
164.93032, 167.259, 168.93421, 173.054, 174.9668, 178.49, 180.94788, 183.84,
186.207, 190.23, 192.217, 195.084, 196.966569, 200.59, 204.3833, 207.2,
208.98040, 209, 210, 222, 223, 226, 227, 232.03806, 231.03588, 238.02891,
237, 244, 243, 247, 247, 251, 252, 257, 258, 259, 262, 267, 268,
271, 272, 270, 276, 281, 280, 285};

float _dedx_get_atom_charge(int id, int *err);

float _dedx_get_atom_mass(int id, int *err);

static const int dedx_nucl[112] = {
1, 4, 7, 9, 11, 12, 14, 16,
19, 20, 23, 24, 27, 28, 31,
32, 35, 40, 39, 40, 45, 48, 51, 52,
55, 56, 59, 58, 63, 64, 69, 74,
75, 80, 79, 84, 85, 88, 89, 90, 93,
98, 98, 102, 103, 106, 107, 114, 115, 120,
121, 130, 127, 132, 133, 138, 139, 140,
141, 142, 145, 152, 153, 158, 159, 164,
165, 166, 169, 174, 175, 180, 181, 184,
185, 192, 193, 195, 197, 202, 205, 208,
209, 209, 210, 222, 223, 226, 227, 232, 231, 238,
237, 244, 243, 247, 247, 251, 252, 257, 258, 259, 262, 267,
268, 271, 272, 270, 276, 281, 280, 285};

int _dedx_get_nucleon(int id, int *err);


#endif // DEDX_PERIODIC_TABLE_H_INCLUDED
4 changes: 3 additions & 1 deletion libdedx/dedx_wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "dedx_wrappers.h"
#include "dedx_tools.h"
#include "dedx_periodic_table.h"

void dedx_fill_program_list(int *program_list) {
/* fill list of available programs, terminated with -1 */
Expand Down Expand Up @@ -163,7 +164,8 @@ int dedx_get_csda_range_table(const int program, const int ion, const int target
config->target = target;
config->ion = ion;
config->program = program;
config->ion_a = ion;
config->ion_a = _dedx_get_nucleon(config->ion, &err);
if (err != 0) return err;
dedx_workspace *ws = dedx_allocate_workspace(1, &err);

if (err != 0) return err;
Expand Down