oasys-elettra-kit / OASYS1-Wiser

The implementation of WISER into OASYS
MIT License
0 stars 1 forks source link

"IGNORE" - implementation #78

Open capitanevs opened 2 years ago

capitanevs commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

capitanevs commented 2 years ago

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 commented 2 years ago

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:

capitanevs commented 2 years ago

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 commented 2 years ago

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

capitanevs commented 2 years ago

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 commented 2 years ago

Maybe I got a clue:

immagine

capitanevs commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

capitanevs commented 2 years ago

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 commented 2 years ago

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!