McCode icon indicating copy to clipboard operation
McCode copied to clipboard

Sqw_monitor didn't work in McStas-3.1 for instrument ILL_IN5_Spots

Open XuShuqi7 opened this issue 2 years ago • 1 comments

Hi,

my name is Shuqi Xu, currently working remotely for the HighNESS project of ESS. I am using McStas-3.1 + NCrystal-3.2.0 to simulate the measurements performed at IN5 provided by our colleagues from ILL.

I have installed McStas-3.1 on my MacBook (Monterey 12.3.1) by following the corresponding README file. By starting a masts-3.1 environmental terminal, I launched a simulation of the instrument ILL_IN5_Spots given in "File->New From Template->ILL". IN5

The simulation finished without errors. Nevertheless, the Sqw_monitor didn't work. I tried with another case ILL_IN6 while the Sqw_monitor worked. IN6

I am new user for McStas. Even I tried to fix the issue by modifying the .instr file of IN5, I failed. So I would like to ask for help to solve this problem, thank you very much.

Best regards, Shuqi

XuShuqi7 avatar Aug 26 '22 08:08 XuShuqi7

Hello @XuShuqi7,

Sorry for the delay in responding, I have been very busy. Let me first report that I have reproduced your finding, and will now investigate further.

I should be back with more information within a few more days.

willend avatar Sep 01 '22 13:09 willend

Hello again @XuShuqi7, I tried with "today's development version" (i.e. built from the mccode-3 branch) and did not reproduce the issue.

I only later realised the issue is how restore_neutron=1 works in the McStas 3.1 release - where in fact anything done in an EXTEND block on a Monitor with restore_neutron=1 will be "annihilated". (... and this has been fixed in the code-tree.)

You can do a workaround with your already installed McStas 3.1 release and simply move the EXTEND block from the COMPONENT Det_sample_t to the previous collimator, i.e.:

COMPONENT Collimator = Guide_channeled(
  w1 = 0.01400, h1 = 0.05617, w2 = 0.01400, h2 = 0.05400, l = L_Collimator,
  R0 = Guide_Ro, Qcx = Guide_Qc, alphax = Guide_alpha, mx = 2,
  W  = Guide_W,  Qcy = Guide_Qc, alphay = Guide_alpha, my = 3)
AT (0,0,L_Guide45+mono_gap) RELATIVE Guide45
EXTEND %{
  if (!SCATTERED) ABSORB;
  vix=vx,viy=vy,viz=vz;
%}
  • then you will get output: Screenshot 2022-09-21 at 14 49 09

I attach a corrected instrument-file here: ILL_IN5_Spots.instr.txt

willend avatar Sep 21 '22 12:09 willend

Hi @willend,

thank you very much for resolving the issue and providing me with the new instrument file!

While I found that I confronted a new situation, which may be the same as reported by @farhi in #1281. When I started a mcstas-3.1 environmental terminal, and typed "mcgui" to open the instrument file, after clicking "run" I got:

''' xushuqi@xushuqideMacBook-Pro ~ % mcgui loading system configuration qt.qpa.fonts: Populating font family aliases took 221 ms. Replace uses of missing font family "Deja Vu Sans Mono" with one that exists to avoid this cost. Traceback (most recent call last): File "/Applications/McStas-3.1.app/Contents/Resources/mcstas/3.1/bin/../tools/Python/mcgui/mcgui.py", line 596, in handleRunOrInterruptSim fixed_params, new_instr_params, inspect, mcdisplay, autoplotter = self.view.showStartSimDialog( File "/Applications/McStas-3.1.app/Contents/Resources/mcstas/3.1/tools/Python/mcgui/viewclasses.py", line 157, in showStartSimDialog self.__ssd.createParamsWidgets(params) File "/Applications/McStas-3.1.app/Contents/Resources/mcstas/3.1/tools/Python/mcgui/viewclasses.py", line 798, in createParamsWidgets self.ui.gridGrid.addWidget(lbl, y, x, 1, 1) TypeError: arguments did not match any overloaded call: addWidget(self, QWidget): too many arguments addWidget(self, QWidget, int, int, alignment: Union[Qt.Alignment, Qt.AlignmentFlag] = Qt.Alignment()): argument 2 has unexpected type 'float' addWidget(self, QWidget, int, int, int, int, alignment: Union[Qt.Alignment, Qt.AlignmentFlag] = Qt.Alignment()): argument 2 has unexpected type 'float' /Applications/McStas-3.1.app/Contents/Resources/mcstas/3.1/bin/mcgui: line 69: 1385 Abort trap: 6 python3 ${LIB}/mcgui.py $* '''

Nevertheless, when I directly double clicked the mcstas app and run the instrument file which you provided, it was OK:

Screen Shot 2022-09-23 at 10 59 09

But I would like to know how to fix this issue because later I should link with NCrystal, to start with a mcstas-3.1 environmental terminal is expected.

Thank you very much for your help!

Best regards, Shuqi

XuShuqi7 avatar Sep 23 '22 09:09 XuShuqi7

xushuqi@xushuqideMacBook-Pro ~ % mcgui
loading system configuration
qt.qpa.fonts: Populating font family aliases took 221 ms. Replace uses of missing font family "Deja Vu Sans Mono" with one that exists to avoid this cost. 
Traceback (most recent call last):
  File "/Applications/McStas-3.1.app/Contents/Resources/mcstas/3.1/bin/../tools/Python/mcgui/mcgui.py", line 596, in handleRunOrInterruptSim
    fixed_params, new_instr_params, inspect, mcdisplay, autoplotter = self.view.showStartSimDialog(
  File "/Applications/McStas-3.1.app/Contents/Resources/mcstas/3.1/tools/Python/mcgui/viewclasses.py", line 157, in showStartSimDialog
    self.__ssd.createParamsWidgets(params)
  File "/Applications/McStas-3.1.app/Contents/Resources/mcstas/3.1/tools/Python/mcgui/viewclasses.py", line 798, in createParamsWidgets
    self.ui.gridGrid.addWidget(lbl, y, x, 1, 1)
TypeError: arguments did not match any overloaded call:
  addWidget(self, QWidget): too many arguments
  addWidget(self, QWidget, int, int, alignment: Union[Qt.Alignment, Qt.AlignmentFlag] = Qt.Alignment()): argument 2 has unexpected type 'float'
  addWidget(self, QWidget, int, int, int, int, alignment: Union[Qt.Alignment, Qt.AlignmentFlag] = Qt.Alignment()): argument 2 has unexpected type 'float'
/Applications/McStas-3.1.app/Contents/Resources/mcstas/3.1/bin/mcgui: line 69:  1385 Abort trap: 6           python3 ${LIB}/mcgui.py $*

I made a mistake about the code highlight command...

XuShuqi7 avatar Sep 23 '22 09:09 XuShuqi7

@XuShuqi7 yes, quite sure your the issue is close to that reported by @farhi and solved elsewhere by @g5t. The official releases of McStas and McXtrace at the moment don't work well with Python 3.10 "out of the box", sorry.

I would

  • replace /Applications/McStas-3.1.app/Contents/Resources/mcstas/3.1/tools/Python/mcgui/viewclasses.py by https://raw.githubusercontent.com/McStasMcXtrace/McCode/mccode-3/tools/Python/mcgui/viewclasses.py
  • replace /Applications/McStas-3.1.app/Contents/Resources/mcstas/3.1/tools/Python/mccodelib/pqtgfrontend.py by https://raw.githubusercontent.com/McStasMcXtrace/McCode/mccode-3/tools/Python/mccodelib/pqtgfrontend.py

Please report back if this helps?

willend avatar Sep 23 '22 09:09 willend

Hi @willend,

yes by replacing the indicated .py files, it worked perfectly !

Screen Shot 2022-09-23 at 15 13 06

Thank you very much for solving my problems!

Best regards, Shuqi

XuShuqi7 avatar Sep 23 '22 13:09 XuShuqi7

From my side, the issue is resolved. Thank you very much for helping me @willend @farhi.

XuShuqi7 avatar Sep 23 '22 13:09 XuShuqi7