tschoonj / xmimsim

Monte Carlo simulation of energy-dispersive X-ray fluorescence spectrometers
Other
32 stars 11 forks source link

Custom detector response function #84

Closed bbazi closed 2 years ago

bbazi commented 2 years ago

Hi Tom, Have installed XMI-MSIM-8.1-win64.exe and can successfully simulate the provided examples. My goal is to implement a custom detector response function for a new HPGe detector. I am following the Fortran instructions as written down in the Wiki section on how to build modules on Windows.

As a test I'm using the detector-response1.F90 file (taken from XMI-MSIM_64-bit\Sources\xmimsim-8.1\custom-detector-response) but added again the choice for detector types with the magic number stuff. See attached the exact file I'm using. detector-response1.zip

It is then asked to compile the source files and link the objects together, this I could do for the detector response file with no issue (see image). Fortran instructions

Unfortnately, after this I cannot open the XMIMSIM gui, "libxmimsim-gui-0.dll cannot be found" is given as error message. I'm guessing I have to compile other source files as well..., if so, which ones? Any news is appreciated!

Cheers, Benjamin

tschoonj commented 2 years ago

Hi Benjamin,

You mean that you cannot open the GUI via the Windows Start menu? Or via the MSYS2 shell? In the latter case it probably means that your PATH variable is not pointing to the Bin folder within the XMI-MSIM folder that contains (some of) the dlls that it needs.

tschoonj commented 2 years ago

I would also recommend that you do the development of the plugin on Linux, and only when you get it working there, you move to Windows if you need to create a build of the plugin that is specific to that platform.

bbazi commented 2 years ago

Hi Tom, Yes, I was no longer able to open the GUI via the Windows Start menu or the MSYS2 shell. Have now moved to Debian "Bullseye" Linux as you recommended, am following the Wiki installation instructions. The Wiki mentions that only Debian "Strech" is supported, will the newer version give issues? I could not find Stretch on debian.org... The update of the apt cache went smooth (see image).

Update Debian apt cache

When installing XMI-MSIM, some packages could not be installed (see image), any idea how to fix this?

Installing xmimsim packages

Cheers, Benjamin

tschoonj commented 2 years ago

Bullseye is also supported, even though the wiki doesn't mention it explicitly (still need to update that).

Just replace buster with bullseye in your apt config file, run sudo apt-get update, and try installing XMI-MSIM again.

Not sure why you can't open XMI-MSIM in Windows after compiling your plugin. Doesn't make any sense to me. Did you modify the system PATH variable?

bbazi commented 2 years ago

Hey, Nope, didn't change the PATH... In the meantime, XMI-MSIM has been successfully installed on Bullseye and could perfectly simulate the examples. How do I now implement a custom detector response function? The Wiki mentions that the development packages have to be included, are these automatically installed? If so, where can I find them? Cheers, Benjamin

tschoonj commented 2 years ago

Try:

sudo apt-get install libxmimsim0-dev
bbazi commented 2 years ago

Hey, After installing libxmimsim0-dev I still cannot find the xmi_detector_f.F90 file or any .F90 file in general. Any idea how to grab those? What I have at the moment:

Cheers, B

tschoonj commented 2 years ago

You don't need those files for compilation or linking, but you will need to point the fortran compiler to the location of those MOD files. Of course it will be useful for you to look at those files to know the subroutine and function signatures, so best to keep those files open in Github or so.

bbazi commented 2 years ago

There seems to be an issue with the PKG_CONFIG_PATH, although libxmimsim.pc is located in the path that will be checked, pkg-config doesn't find it (see image). Any idea what is going wrong?

pkg-config error

Cheers, B

tschoonj commented 2 years ago

Use backticks instead of regular quotes

bbazi commented 2 years ago

Okay, now I get the following dllexport message, should I be worried about this? (see image).

dll export error

This was the test detector response function I used: detector-response1.zip

Cheers, B

tschoonj commented 2 years ago

Nope that's ok. By the way there's no reason to be root for any of this 😁

bbazi commented 2 years ago

Okay, I was hesitating :p I could successfully link the objects together, am now running a simulation with this custom detector response function. The goal is to play around with the magic number stuff, I'm guessing I can keep recompiling/linking a custom detector response function in an iterative manner? If not, please correct me.

Cheers, B

tschoonj commented 2 years ago

That's indeed how I expect that it will go.

By the way it should be possible to write a detector response plugin that calls Python code, but that would require quite a bit of work...

bbazi commented 2 years ago

I will keep it in mind should I need it. Thanks very much for the help! Cheers, B