-
Notifications
You must be signed in to change notification settings - Fork 0
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
Make CrysText plugin ready for ncrystal v4 #1
base: main
Are you sure you want to change the base?
Make CrysText plugin ready for ncrystal v4 #1
Conversation
I am not 100% sure why the CI does not run on this PR, but perhaps it is because there are still no other workflows in the repo. |
Hi @tkittel, First I created a new environment and installed NCrystal and the plugin using
Then I use Python to run
where R=0.3 in "ncplugin-CrysText_Al_sg225.ncmat", while R=1 in "ncplugin-CrysText_Al_sg225_ver.ncmat", with additional sections
and
The resulting plot is It seems that the March-Dollase model is not correctly called. Instead, the single crystal model is used. Maybe the installation of plugin is not correct? |
@XuShuqi77 first thing is to make sure your list of conda packages also includes |
I am trying to make this work in a conda env, hang on. |
The following recipe works for me. The thing is that NCrystal 4 is not out yet, so if you want to use these source-only packages in a conda environment, you have to be very careful to make sure that ncrystal-core and the new plugin gets compiled in the exactly correct environment:
|
I am trying your plotting script now, how long should I expect it to run for? |
Thanks for testing! I am following your recipe now. It will take <<1 seconds normally. |
It works: One thing you need to fix in your script is the filenames: Al_text = NC.createScatter('plugins::CrysText/Al_sg225.ncmat;temp={}K;dir1=@crys_hkl:1,1,1@lab:1,0,0;dir2=@crys_hkl:0,0,2@lab:0,1,0;mos=1deg;dirtol=180deg'.format(T))
Al_ver = NC.createScatter('plugins::CrysText/Al_sg225_ver.ncmat;temp={}K;dir1=@crys_hkl:1,1,1@lab:1,0,0;dir2=@crys_hkl:0,0,2@lab:0,1,0;mos=1deg;dirtol=180deg'.format(T))
Al = NC.createScatter('stdlib::Al_sg225.ncmat;temp={}K'.format(T)) If it worked before, you must have had the old plugin files copied into your working dir or something. To avoid this confusion, always use e.g. |
But it did take ~2 minutes to run! |
Great! Thank you @tkittel ! Oh, yes, I thought the wavelength began with 1 AA. If with 0.1 AA, 2 minutes are reasonable 😊 |
So one thing which we should consider for the test function in NCTestPlugins.cc would be to verify that this is happening, e.g. that for your Al_sg225.ncmat, you get cross sections close to 0.6barn (or whatever) for 3.5Aa neutrons. I.e. the main point of that test function is to quickly verify that the plugin is activated and doing its thing, not something more heavy than that - and not something that will break if you tweak the parameters slightly. However, once you also have it working we should probably just go ahead and merge this - or do you think anyone else is using this in the next few weeks? |
I follow the installation process and make it work. Your advice regarding the test function works for me. |
However, there is un expected warning
which should result in the cut in the lower wavelength: |
I think the problem should be due to some numerical overflow, which will not impact the use of the plugin which usually focuses on longer wavelengths. I will have a look at the source code. Or do you have any advice? |
I don't have time to debug the plugin internals in the next few weeks for sure, but of course I am not a fan of a statement like:
For a high quality plugin, it should also deal with edge cases. However, there are probably many other problems to fix (e.g. make the plugin technically "isotropic" again, since you are actually not using the neutron direction). I think for this PR it is unrelated, feel free to open an issue and investigate further there. |
Btw., I just released ncrystal-pypluginmgr 0.0.4, so with that you can simply install your plugin and then afterwards run:
To verify that the plugin exists, and run it's test function. |
This comment has been tested from my side. I agree on that the plugin should not limited to certain wavelengths and should able to address all the edges. I will open an issue and investigate this problem further. |
1 similar comment
This comment has been tested from my side. I agree on that the plugin should not limited to certain wavelengths and should able to address all the edges. I will open an issue and investigate this problem further. |
@XuShuqi77 @marquezj @dddijulio
These changes are needed to make the plugin ready for NCrystal 4, which will be out in a few weeks.
It can already be used in the meantime however, by pip installing the
ncrystal-core
andncrystal-python
packages which contains release candidates of the new code (but do NOT install the package named justncrystal
until NCrystal4 is out). For refererence,ncrystal-core
contains all binaries, headers, cmake, andncrystal-config
-- andncrystal-python
contains theNCrystal
python module and all the other command line tools (includingnctool
).To install the plugin, you can now simply point pip directly at the repo:
And then it will work with no further need to tweak environment variables or whatnot.
Of course, until you accept this PR, the above command won't work. But you can try out the code in this PR with:
This PR also adds a unit tests, that ensures a basic functionality test of the plugin on linux/mac/windows.
We will discuss more on monday about how to actually develop in this context, adding tests, etc.