Repository navigation
Conversation
… into a functions
…to their own functions
… k_rotated in transform_wavevector function
mads-bertelsen
left a comment
There was a problem hiding this comment.
This is an ongoing review, but want to get some information across!
The trace loop is certainly easier to read with this. Naming the functions in this complex system is difficult, will think more about how exactly that would be the most intuitive. It's mainly confusing when reading the functions before reading the trace section, which of course is not often done and can be alleviated with a header.
The function calls use pointers for everything, that reduce the overhead on function calls as nothing needs to be copied. It does make the syntax in the functions a bit harder to understand due to all the dereference operations. When a parameter is not updated in a function, one can make a local variable for the dereferenced value and use that in the equations, it should be optimized out by the compiler while being slightly more readable.
Even with the fast function calls, I do want to check the performance impact, although I don't expect it to be significant.
This is true. We might also think about grouping them together, such that all functions "belonging" to a type of logic, sit close to each other in union-lib. Looking forward to hearing your ideas regarding naming!
I was considering if we should make som helper structs, such that the function calls inside the union_master wouldn't have to be so lengthy. By doing this I also believe these dereferencing issues could be adressed to some degree.
Sounds like a good plan. You never know what operations you are by accident performing! |
…nly for the focusing processes
…. Now in correct file
…. Also move the functions toward their relevant others, i.e inhomogenous with inhomogenous
|
@Lomholy the macOS test will very likely run through OK if you update the branch against current main. (Seems to be a specific issue with mpi that I will resolve separately later.) |
|
@Lomholy and @mads-bertelsen I've just updated against main. Is the status still [NOT READY FOR MERGE]? |
@willend I am seeing @mads-bertelsen next week, where I think we will have a chat on it! Will update the PR after this. |
…ling scattering in inhomogeneous logic path
…renthesis in weight correction for inhomogenous processes
I think I have responded to all your points, and you were right on all of them. There is one bit that is wrong with the inhomogeneous sampling of processes that need_focus, see my comment to your comment for that one. But since this issue is not relevant to the current PR, I propose that we add an issue regarding it and then let this PR branch finish up if all tests are passed. |
…er is no longer in use
…thereby being misnamed. Fixed now
|
@willend I think I have now fixed the errors causing the tests to fail, but I cannot test it, when I (with a fresh build) do mctest --testdir tmp --comp Inhomogenous_incoherent_process I get, the following (slightly redacted) Have you seen this before on an apple M4 max laptop? |
…nction where the context makes it obvious
|
This here is an indication of overlap with existing test output - maybe from your This on the other hand is most probably a segfault / non-zero exit value. Check the stdout files in the output folder and lint the code |
|
@Lomholy there are separate logs for compilation / display / and each |
|
@willend I tried to examine the log for the display but it seems that none is written?
|
|
Hmm, weird. Try going in the folder to do these
It could be some var in a component |
This also works fine by hand btw |
|
Yes but you have to figure out if there is a non-zero exit value of mcdisplay itself / the simulation. |
|
The noted "error" comes from a non-zero exit value. |
|
It seems that the issue was an old .out file I had lying in my Test folder inside the local repository not inside the mctest folder inside tmp. For some reason it found that one and used it, but didn't even attempt to display. Trying to run again now, and seeing if it all works |
|
@mads-bertelsen I think a final cursory glance from you would be good before merging, but otherwise it looks good. It doesn't seem like the failing tests have anything to do with this PR, right? |
|
@Lomholy yes this would explain the issue - (And is the reason the Warning about simulation data / blah comes up... I am considering to upgrade that to an actual error / crash instead. You have to know what you are testing.) The mcstas-antlr issue should not be related but I the 'comparison' issue should be investigated - however chances are it will all go away with a rebase / update via merge request. Do you want me to do that? |
Indeed @Lomholy I have marked all of the conversations above as 'resolved' but @mads-bertelsen still needs to flick the toggle to "approved". And we of course need to still await 'green light' wherever we can get it. |
|
Great work, will look through it as soon as possible! |




Free-form text area
Please describe what your PR is adding in terms of features or bugfixes:
This PR aims to improve the readability of the Union_master component. The PR is limited in scope to only the scattering while loop inside Union_master.comp.
To perform this refactoring I propose two things:
We separate all non-primary logic paths, out into separate functions (Currently placed in Union_master for my own simplicity, but will be moved to union-lib.c).
When determining a non-primary logic paths, we use wrapper functions, that clearly indicate the intent of the branching in logic path.
An example of this is using:
if (volume_is_only_absorber(Volumes[current_volume])) {Instead of
if (Volumes[current_volume]->p_physics->number_of_processes == 0) { // If there are no processes, the volume could be vacuum or an absorberif (Volumes[current_volume]->p_physics->is_vacuum == 0) {(Maybe) We attempt to adhere to a standardized naming scheme for the functions implemented, such that all inhomogenous paths are called "inhomogenous_insert_what_function_does();".
Declaration of use of AI-tools
Development OS / boundary conditions
Please describe what OS you developed and tested your additions on, and if any special dependencies are required:
MacOS Tahoe 26.5.2
PR Checklist for contributing to McStas/McXtrace
For a coherent and useful contribution to McStas/McXtrace, please fill in relevant parts of the checklist:
My work touches / adds to the runtime lib code (.c,.h etc in multiple locations