tschoonj / xraylib

A library for X-ray matter interaction cross sections for X-ray fluorescence applications
https://github.com/tschoonj/xraylib/wiki
Other
120 stars 54 forks source link

CS_Photo, CS_compton, CS_Rayleigh with C++Builder 6 library give the wrong value #22

Closed rgouelSTA closed 9 years ago

rgouelSTA commented 9 years ago

Hi, I am using C++Builder6 and have recently added the library libxrl-7-bcc.lib. The example xrlexample6.cpp runs properly. Other xraylib functions that I want to use also run properly, like the attenuation coefficients amongst others. The only problem I found is with the cubic splines cross sections, I get the wrong answers.

I duplicated the cubic splines from the source code and the data files and I get reasonable answers.Ssince the libxrl-7-bcc.lib is compiled it seems to me that something went wrong there. Can you please advise? I also noticed that the values of the log(keV) are not exactly the same as the one I compute for the same keV, they differ after the 4th or 5th digit, but is not the source of the problem.

My use is for simulation of x-ray measurements for thickness of materials and thickness of metal coatings.

Thanks a lot.

Roland.

tschoonj commented 9 years ago

Hi Roland,

I have tried to reproduce your problem here but I failed: using the free 5.5 Borland compiler both the C and C++ example produced the right results, even after I included calls to CS_Compt and CS_Rayl.

In fact I am quite surprised that you would get the right values for the attenuation coefficients (CS_Total) since these are calculated as the sum of CS_Photo, CS_Compt and CS_Rayl and these, as you know, rely on cubic spline interpolation.

Also: the import library libxrl-7-bcc.lib is not compiled, but is instead generated from the libxrl-7.dll using Borland's implib utility:

implib.exe -a -c libxrl-7-bcc.lib libxrl-7.dll

I think something else is going on here, perhaps some incompatibility between Borland 5.5 and C++ Builder? Could you try generating the import library yourself?

By the way, if you are interested in Monte Carlo simulations of X-ray fluorescence experiments, you may want to have a look at my other project XMI-MSIM

Thanks,

Tom

rgouelSTA commented 9 years ago

Hi Tom,

Sorry for the delay in responding and thank you for your answer.

I should have thought that the Total cross-section is the sum of the others, I read it in the manual sometime ago.

My apologies.

In fact there is no problem with the library, it was me caught in a vicious circle of mishaps when I tried to compare the cross sections in barn to those of the LLL-Plechaty tables I have been using in years.

I can report that both libxrl-7-bcc.lib as well as libxrl-7.lib work well with C++Builder 6 and give the same results.

Only the libxrl-7.lib works with Visual studio Express.

Thank you for the link to your Monte Carlo project, I am certainly interested and will look into it.

May be my mistakes happened to have you direct me to your Monte Carlo project.

My Best Regards,

Roland.

From: Tom Schoonjans [mailto:notifications@github.com] Sent: Saturday, April 04, 2015 2:54 AM To: tschoonj/xraylib Cc: Roland Gouel Subject: Re: [xraylib] CS_Photo, CS_compton, CS_Rayleigh with C++Builder 6 library give the wrong value (#22)

Hi Roland,

I have tried to reproduce your problem here but I failed: using the free 5.5 Borland compiler both the C and C++ example produced the right results, even after I included calls to CS_Compt and CS_Rayl.

In fact I am quite surprised that you would get the right values for the attenuation coefficients (CS_Total) since these are calculated as the sum of CS_Photo, CS_Compt and CS_Rayl and these, as you know, rely on cubic spline interpolation.

Also: the import library libxrl-7-bcc.lib is not compiled, but is instead generated from the libxrl-7.dll using Borland's implib utility:

implib.exe -a -c libxrl-7-bcc.lib libxrl-7.dll

I think something else is going on here, perhaps some incompatibility between Borland 5.5 and C++ Builder? Could you try generating the import library yourself?

By the way, if you are interested in Monte Carlo simulations of X-ray fluorescence experiments, you may want to have a look at my other project XMI-MSIM https://github.com/tschoonj/xmimsim

Thanks,

Tom

— Reply to this email directly or view it on GitHub https://github.com/tschoonj/xraylib/issues/22#issuecomment-89514235 . https://github.com/notifications/beacon/ALGJm7qPiNq82Gh67L7Yk_HtmfQik3_Vks5n74H-gaJpZM4D55uD.gif

tschoonj commented 9 years ago

Hi Roland,

Glad to hear things are working properly now. Let me know if I can be of further assistance!

Best,

Tom