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

"IGNORE" - implementation #78

Open
capitanevs opened this issue Mar 10, 2022 · 15 comments
Open

"IGNORE" - implementation #78

capitanevs opened this issue Mar 10, 2022 · 15 comments

Comments

@capitanevs
Copy link
Collaborator

capitanevs commented Mar 10, 2022

Aka "the Friday Bug", this bug appears to be realted with the "ignore" attribute of LibWiser, how it works alone, and how it works with the chain-of-responsibility of Oasys.

Understood by Aljosa.
I copy the email text

_Hey,

No, there is a bug... With Ignore turned on, the wavefront doesn't propagate to the next element. This is probably due to the changes/decoupling in WiserData, where the beamline is returned even if wavefront is None... This needs a bit more consideration to be solved efficiently.

Cheers,
Aljosa_

@capitanevs
Copy link
Collaborator Author

TEST OF IGNORE, in LibWiser

Everything is fine (see picture and *.py).

I think the issue is simpler than we thought:
If Ignore=True than all the plot operations etc on the optical element must be just skipped :)

Can you try to fix it?
test_layout.py.txt

immagine

@aljosahafner
Copy link
Collaborator

Thanks for opening this issue on github. I will try to implement exactly what you said.

@capitanevs
Copy link
Collaborator Author

One more thing:

This case is also useful to decide what to do with #issue 74.

immagine

As is, the code generates an error at the level of item2, and the execution stops.

We (I) wondered if it was possible to still propagate a signal downstream, even if an errorr occurred.

The rationale of this is that the signal propagates info about: the beamline layout (which almost never contains any error) and the computations (which may contain some inconsicency). It would make sense to propagate all this info whenever possible.

However, the execution can be broken by a number of elements, e.g. the GUI.

The solution to all this is not trivial. I wrote this just as a comment.

@aljosahafner
Copy link
Collaborator

Hey,

I solved the initial problem of if and else, so the computation is not breaking anymore when plotting. However, it still wouldn't run. It seems to me right now that the problem lies either at wofrywiser (highly unlikely) or LibWiser level. The breaking line is 649 in ow_optical_element that directly calls wofry do_propagation() where the breaking line is 105 in wise_propagation.py:

beamline.ComputeFields(oeStart=oeStart, oeEnd=oeEnd, Verbose=False)

I do correctly set the ComputationSettings.Ignore parameter from the GUI and it is set correctly in the "LibWiser OE".

This is the test beamline (PlaneMirror is ignored):
image

This is the error:
image

Some observations:

  • The error occurs at the detector, wavefront is correctly calculated at EllipticMirror
  • The error does not occur if the last element before the detector is ignored (regardless of type)

@capitanevs
Copy link
Collaborator Author

Got it.
Would you mind update the new version of OASYS1-Wiser , so that I can test it?

At the present moment, the only the I have in mind is the number of samples, but this does no help me...

Can you tell me where is the definition of do_propagation?

@aljosahafner
Copy link
Collaborator

I pushed the new version to PyPI (0.3.21) and the code to github.

@capitanevs
Copy link
Collaborator Author

Side note:

if ignore is True, and I had previously computed data on the same element, the plots still display the old intensity. It would make sense if they were empty. However, let's just keep it in mind for the moment
immagine

@capitanevs
Copy link
Collaborator Author

Maybe I got a clue:

immagine

@capitanevs
Copy link
Collaborator Author

Question: shouldn't the error message above appear in the error log of OASYS? (I can not say annything coz my one broke ages ago, and it always blank... that's another story)

@capitanevs
Copy link
Collaborator Author

Personal Note:

In any case, there is something strange in LibWiser (maybe)

the plane mirror is ignored, but the engine still attempts to do the propagation from it to the following. Weird.

immagine

@capitanevs
Copy link
Collaborator Author

Solution
In principle, I could add a check (if E0 is not None then...

However, it seems to me that, with a None field, this function should not be called at all. I will check the logic, first.

@aljosahafner
Copy link
Collaborator

Question: shouldn't the error message above appear in the error log of OASYS? (I can not say annything coz my one broke ages ago, and it always blank... that's another story)

Yes, it does to me, look at my previous message.

@aljosahafner
Copy link
Collaborator

aljosahafner commented Mar 28, 2022

We can discuss tomorrow if you're available. Are we by now sure that the "problem" needs to be resolved on LibWiser level?

@capitanevs
Copy link
Collaborator Author

This "new problem", which is not connected to the attempt of OASYS to plot a None field ("starting problem"), quite certainly lives at LibWiser level.

@aljosahafner
Copy link
Collaborator

aljosahafner commented Mar 28, 2022

Ok, I am available for discussion or some fast implementation at any time, if necessary. Keep in mind the peculiar behaviour, if the last element is ignored, then everything works fine!

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

2 participants