Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a derviation of the energy based on edge and element - use xraylib #27

Open
stan-dot opened this issue Dec 4, 2024 · 14 comments
Open

Comments

@stan-dot
Copy link
Collaborator

stan-dot commented Dec 4, 2024

https://github.com/tschoonj/xraylib

@stan-dot
Copy link
Collaborator Author

stan-dot commented Dec 4, 2024

image
info from @iain-hall

the Qexafs screen - on the left hand side of the GUI there are 'element' and 'edge' combo boxes. Selecting an element and edge will populate the 'edge energy' box with an appropriate value (looked up from an ascii file of atomic data), which can then be used to populate the initial and final energy boxes by clicking on the 'Load defaults' button. Currently in GDA the atomic data is loaded from an ascii file

@stan-dot
Copy link
Collaborator Author

stan-dot commented Dec 4, 2024

https://mesonbuild.com/Reference-tables.html#cpu-families

might need to compile with meson into wasm64

@stan-dot
Copy link
Collaborator Author

stan-dot commented Dec 4, 2024

@stan-dot
Copy link
Collaborator Author

stan-dot commented Dec 4, 2024

the main problem was with 'where to get emcc from if I install emscripten' https://developer.mozilla.org/en-US/docs/WebAssembly/C_to_Wasm

@stan-dot
Copy link
Collaborator Author

stan-dot commented Dec 4, 2024

@stan-dot
Copy link
Collaborator Author

stan-dot commented Dec 4, 2024

trying with this, it fails:

meson setup builddir --buildtype=release --prefix=/tmp --cross-file=wasm64-cross-file.txt
DEPRECATION: c_args in the [properties] section of the machine file is deprecated, use the [built-in options] section.
DEPRECATION: c_link_args in the [properties] section of the machine file is deprecated, use the [built-in options] section.
The Meson build system
Version: 1.6.0
Source dir: /home/stan-dot/xraylib/xraylib
Build dir: /home/stan-dot/xraylib/xraylib/builddir
Build type: cross build

Project name: xraylib
Project version: 4.1.5

meson.build:1:0: ERROR: Compiler /home/stan-dot/xraylib/emsdk/upstream/emscripten/emcc cannot compile programs.

A full log can be found at /home/stan-dot/xraylib/xraylib/builddir/meson-logs/meson-log.txt

@stan-dot
Copy link
Collaborator Author

stan-dot commented Dec 4, 2024

of course, emcc is only for libraries, as wasm modules never work standalone

@stan-dot
Copy link
Collaborator Author

stan-dot commented Dec 4, 2024

some tricks and meson-log.txt investigation led me to know that the WASM64=1 flag was not recognized

@stan-dot
Copy link
Collaborator Author

stan-dot commented Dec 4, 2024

new error

-----------
Command line: `/home/stan-dot/xraylib/emsdk/upstream/emscripten/emcc /home/stan-dot/xraylib/xraylib/build_to_wasm/meson-private/tmpbhgpaypr/testfile.c -o /home/stan-dot/xraylib/xraylib/build_to_wasm/meson-private/tmpbhgpaypr/output.o -c -s WASM=1 -D_FILE_OFFSET_BITS=64 -O0 -Werror=implicit-function-declaration -Werror=unknown-warning-option -Werror=unused-command-line-argument -Werror=deprecated-declarations` -> 1
stderr:
emcc: error: linker setting ignored during compilation: 'WASM' [-Wunused-command-line-argument] [-Werror]
-----------
Compiler for C supports arguments -Werror=deprecated-declarations: NO 
Running compile:
Working directory:  /home/stan-dot/xraylib/xraylib/build_to_wasm/meson-private/tmp7o9gr4q9
Code:
int main(void) { return 0; }

-----------
Command line: `/home/stan-dot/xraylib/emsdk/upstream/emscripten/emcc /home/stan-dot/xraylib/xraylib/build_to_wasm/meson-private/tmp7o9gr4q9/testfile.c -o /home/stan-dot/xraylib/xraylib/build_to_wasm/meson-private/tmp7o9gr4q9/output.js -s WASM=1 -D_FILE_OFFSET_BITS=64 -O0 -Werror=implicit-function-declaration -Wl,--fatal-warnings -Wl,--output-def,/home/stan-dot/xraylib/xraylib/build_to_wasm/src/libxrl-11.def` -> 1
stderr:
wasm-ld: error: unknown argument: --output-def
wasm-ld: error: cannot open /home/stan-dot/xraylib/xraylib/build_to_wasm/src/libxrl-11.def: No such file or directory
emcc: error: '/home/stan-dot/xraylib/emsdk/upstream/bin/wasm-ld -o /home/stan-dot/xraylib/xraylib/build_to_wasm/meson-private/tmp7o9gr4q9/output.wasm /tmp/emscripten_temp_w_mt936e/testfile_0.o --fatal-warnings --output-def /home/stan-dot/xraylib/xraylib/build_to_wasm/src/libxrl-11.def -L/home/stan-dot/xraylib/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten -lGL-getprocaddr -lal -lhtml5 -lstubs-debug -lnoexit -lc-debug -ldlmalloc -lcompiler_rt -lc++-noexcept -lc++abi-debug-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr /tmp/tmpzh2u_m97libemscripten_js_symbols.so --strip-debug --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_get_base --export=emscripten_stack_get_current --export=emscripten_stack_init --export=_emscripten_stack_alloc --export=__get_temp_ret --export=__set_temp_ret --export=__wasm_call_ctors --export=_emscripten_stack_restore --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export-if-defined=main --export-if-defined=__main_argc_argv --export-if-defined=fflush --export-table -z stack-size=65536 --no-growable-memory --initial-heap=16777216 --no-entry --stack-first --table-base=1' failed (returned 1)
-----------
Compiler for C supports link arguments -Wl,--output-def,/home/stan-dot/xraylib/xraylib/build_to_wasm/src/libxrl-11.def: NO 
Pkg-config binary missing from cross or native file, or env var undefined.
Default target is not allowed for cross use
Found pkg-config: NO
Adding test "atomiclevelwidth"
Adding test "atomicweight"
Adding test "auger"
Adding test "compoundparser"
Adding test "comptonprofiles"
Adding test "coskron"
Adding test "cross_sections"
Adding test "crystal_diffraction"
Adding test "cs_barns"
Adding test "cs_cp"
Adding test "cs_line"
Adding test "densities"
Adding test "edges"
Adding test "fi"
Adding test "fii"
Adding test "fluor_lines"
Adding test "fluor_yield"
Adding test "jump"
Adding test "kissel_pe"
Adding test "polarized"
Adding test "radrate"
Adding test "refractive_indices"
Adding test "scattering"
Adding test "nist-compounds"
Adding test "radionuclides"
Adding test "error"
Adding test "version"
Compiler for language cpp for the host machine not found.
cplusplus/meson.build:13: WARNING: The C++ tests will not get built and run
Program python3 (numpy) found: NO
meson.build:120: WARNING: No suitable Python installation was found. The Python bindings cannot not be built
Compiler for language fortran for the host machine not found.
Adding test "xrlexample1"
Build targets in project: 32

xraylib 4.1.5

  User defined options
    Cross files: wasm64-cross-file.ini
    prefix     : /tmp

Found ninja-1.11.1.git.kitware.jobserver-1 at /venv/bin/ninja
Running compile:
Working directory:  /home/stan-dot/xraylib/xraylib/build_to_wasm/meson-private/tmpbmqta6n2
Code:

-----------
Command line: `cc /home/stan-dot/xraylib/xraylib/build_to_wasm/meson-private/tmpbmqta6n2/testfile.c -o /home/stan-dot/xraylib/xraylib/build_to_wasm/meson-private/tmpbmqta6n2/output.obj -c -D_FILE_OFFSET_BITS=64 -O0 --print-search-dirs` -> 0
stdout:
install: /usr/lib/gcc/x86_64-linux-gnu/12/
programs: =/usr/lib/gcc/x86_64-linux-gnu/12/:/usr/lib/gcc/x86_64-linux-gnu/12/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/12/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/bin/x86_64-linux-gnu/12/:/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/bin/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/bin/
libraries: =/usr/lib/gcc/x86_64-linux-gnu/12/:/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/lib/x86_64-linux-gnu/12/:/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/lib/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/12/:/usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/12/../../../../lib/:/lib/x86_64-linux-gnu/12/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/12/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/lib/:/usr/lib/gcc/x86_64-linux-gnu/12/../../../:/lib/:/usr/lib/
-----------

ERROR: ld.wasm does not support shared libraries.

@stan-dot
Copy link
Collaborator Author

stan-dot commented Dec 5, 2024

we could just use raw sqlite
https://xraypy.github.io/XrayDB/dbschema.html

@stan-dot
Copy link
Collaborator Author

stan-dot commented Dec 6, 2024

it looks like using just the db file with custom function calls would work the simplest way, and to include the raw db file in the repo.

@iain-hall which functions, physical dimensions do we need to map for this use case?

@stan-dot
Copy link
Collaborator Author

stan-dot commented Dec 6, 2024

the relevant nodejs api is here: https://nodejs.org/api/sqlite.html

@stan-dot
Copy link
Collaborator Author

stan-dot commented Dec 6, 2024

made a new issue for this in here https://jira.diamond.ac.uk/projects/K14/issues

@stan-dot stan-dot changed the title Add a derviation of the energy based on edge and element Add a derviation of the energy based on edge and element - use xraylib Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant