McCode icon indicating copy to clipboard operation
McCode copied to clipboard

mcdisplay throws InstrObjectConstructor error

Open sq-meng opened this issue 1 year ago • 2 comments

Environment

Ubuntu 22.04.1 LTS English fresh install on virutal machine, McStas 2.7.2 (mcstas-suite-python) from repo.

Reproduction

  1. New instrument from template -> HZB_FLEX, save to Documents folder.
  2. Run, plot. All OK so far.
  3. Simulation-> Display 2D or 3D, error.

Error message

mcdisplay-webgl --default --no-output-files -n100 HZB_FLEX.instr&

loading system configuration
loading system configuration
Instrument parameters for HZB_FLEX (HZB_FLEX.instr)
Set value of instrument parameter kI (double) [default='1.55']:
Set value of instrument parameter kF (double) [default='1.55']:
Set value of instrument parameter wVS (double) [default='0.03']:
Set value of instrument parameter tilt (double) [default='0']:
Set value of instrument parameter SA (double) [default='-1']:
Set value of instrument parameter A3 (double) [default='0']:
Set value of instrument parameter A4 (double) [default='70']:
Set value of instrument parameter L3 (double) [default='1.00']:
Set value of instrument parameter L4 (double) [default='1.00']:
Set value of instrument parameter Mono_flatswitch (int) [default='0']:
monochromator angles are:
 A1=-37.166, A2=-74.332 [deg]
radius of curvature RMH= -3.269 [m]
radius of curvature RMV= -2.386 [m] 
sample angles are:
 A3=  0.000, A4= 70.000 [deg]
analyser angles are:
 A5=-37.166, A6=-74.332 [deg]
radius of curvature RAH= -1.655 [m]
radius of curvature RAV= -0.813 [m] 
velocity selector frequency is 213.618 [Hz]
lambda=  4.054 [A]
kI=  1.550 [A^-1] 
EI=  4.978 [meV]
Maxwellian source forced to emit only between l_min=  3.958 and l_max=  4.149 [A] in order to save simulation time
correspondingly, the energy monitors at sample position are detecting between   4.752 and   5.222 [meV]

INFO: Using directory: "HZB_FLEX_20231103_101332"
INFO: Using existing c-file: ./HZB_FLEX.c
INFO: Using existing binary: ./HZB_FLEX.out
INFO: ===
Component: elliptical_piece (Guide_tapering)
Height at the guide exit (h2): 0.125000
Component: elliptical_piece (Guide_tapering)
Width at the guide exit (w2): 0.030412
Syntax error in input!
LexToken(DEC,'1',69,3848)
InstrObjectConstructor: parsetreeroot must be a Node of type "instrdeftree"

sq-meng avatar Nov 03 '23 02:11 sq-meng

Hi @sq-meng,

Thanks for reporting. We are slowly abandoning the McStas 2.x, series and the advice for users is to use the McStas 2-3 conversion guides to migrate to McStas 3.x.

I did however invest a little time in reproducing your reported error and also found the underlying issue: The last monitor off HZB_FLEX.instr is named 1dpsd - i.e. starts with a number rather than an alphabetic character. (Which is anyway not a recommended component name)

Changing this component name to psd1d allows mcdisplay to visualise the instrument: HZB_FLEX.instr.txt Screenshot 2023-11-03 at 10 22 38 Screenshot 2023-11-03 at 10 22 14

(That patch was actually already in place in McStas 3.4, which does however exhibit the same behaviour if the corresponding instrument is edited in the opposite sense.)

I will consider creating an issue to either allow mcdisplay to parse component instances starting with numbers or let the code-generator complain about such component names...

willend avatar Nov 03 '23 09:11 willend

Thanks for looking into this @willend. I have downloaded the version 3 instead. This will be a new project for me so there is also no conversion cost going from 2 to 3.

sq-meng avatar Nov 04 '23 05:11 sq-meng