[mcstas-users] TOFRes_sample
Peter Kjær Willendrup
pkwi at dtu.dk
Mon Oct 23 20:07:09 CEST 2023
Dear Ryoichi Kajimoto,
Thank you for reporting this issue, you are completely right in pointing out that needed modifications are missing in the McStas 3.4 version of TOFRes_sample.
(This has gone unnoticed since a test-instrument for the said component was not defined in our test suite, sorry for this.)
I have defined a GitHub issue at https://github.com/McStasMcXtrace/McCode/issues/1512 and will implement the needed changes as soon as time allows.
Best,
Peter Willendrup
On 23 Oct 2023, at 13.29, Ryoichi Kajimoto <ryoichi.kajimoto at j-parc.jp> wrote:
Hi,
I'm simulating a resolution function of a direct-geometry TOF spectrometer. I use TOFRes_sample() for the sample and Res_monitor() for the monitor.
My code worked with McStas 3.1, but it cannot be compiled with McStas 3.4.
I would appreciate if you could provide any solution.
Converting the .instr file to .c with mcstas command worked fine without an error, but compiling it with gcc -O3 -lm stops with an error message attached below.
I found that Res_monitor.comp and Res_sample.comp were greatly updated in McStas 3.4 but TOFRes_sample.comp was unchanged. I suspect that TOFRes_sample.comp is not compatible with Res_monitor.comp...
Thank you in advance,
Ryoichi Kajimoto
==================================
SIKIResSim.c: In function ‘Table_Read_Handle’:
SIKIResSim.c:7518:60: warning: format ‘%i’ expects argument of type ‘int’, but argument 5 has type ‘long int’ [-Wformat=]
7518 | fprintf(stderr,"Warning: Read_Table :%s %s Data has %i invalid lines (*****). Ignored.\n",
| ~^
| |
| int
| %li
......
7521 | count_invalid);
| ~~~~~~~~~~~~~
| |
| long int
SIKIResSim.c: In function ‘_resmonitor_setpos’:
SIKIResSim.c:13221:6: error: ‘RSsample’ undeclared (first use in this function)
13221 | if(RSsample && strlen(RSsample))
| ^~~~~~~~
SIKIResSim.c:13221:6: note: each undeclared identifier is reported only once for each function it appears in
SIKIResSim.c: In function ‘class_Res_monitor_init’:
SIKIResSim.c:663:33: warning: format not a string literal and no format arguments [-Wformat-security]
663 | #define NAME_CURRENT_COMP (_comp->_name)
| ~~~~~~^~~~~~~~
SIKIResSim.c:13781:48: note: in expansion of macro ‘NAME_CURRENT_COMP’
13781 | if (!strcmp(filename,"\0")) sprintf(filename,NAME_CURRENT_COMP);
| ^~~~~~~~~~~~~~~~~
SIKIResSim.c:641:10: error: ‘_class_Res_sample_parameters’ undeclared (first use in this function); did you mean ‘_class_TOFRes_sample_parameters’?
641 | &( ((_class_ ## type ##_parameters *) _getvar_parameters(compname))->par )
| ^~~~~~~
SIKIResSim.c:13835:18: note: in expansion of macro ‘COMP_GETPAR3’
13835 | int *index_ptr=COMP_GETPAR3(Res_sample, res_sample_comp, compindex);
| ^~~~~~~~~~~~
SIKIResSim.c:641:41: error: expected expression before ‘)’ token
641 | &( ((_class_ ## type ##_parameters *) _getvar_parameters(compname))->par )
| ^
SIKIResSim.c:13835:18: note: in expansion of macro ‘COMP_GETPAR3’
13835 | int *index_ptr=COMP_GETPAR3(Res_sample, res_sample_comp, compindex);
| ^~~~~~~~~~~~
==================================
This is how I use TOFRes_sample() and Res_monitor():
==================================
SPLIT COMPONENT RSsample = TOFRes_sample(
thickness = sample_r-0.0001,
radius = sample_r,
yheight = sample_h,
focus_xw = Wdx+0.001,
focus_yh = Wdy+0.001,
target_x = sample_det_x,
target_y = sample_det_y,
target_z = sample_det_z,
time_bin = (ts+tsd+toffset)*1e6,
time_width = Dtsd*1e6
) AT (0,0,L1) RELATIVE mod
COMPONENT det_pos = Arm()
AT (sample_det_x,sample_det_y,sample_det_z) RELATIVE RSsample
ROTATED (0,atan(sample_det_x/sample_det_z)*RAD2DEG,0) RELATIVE RSsample
COMPONENT resmonitor = Res_monitor(
res_sample_comp = RSsample,
options = "cylinder",
xwidth = Wdx, yheight = Wdy,
filename = "resmonitor.dat"
) AT (0,0,0) RELATIVE det_pos
_______________________________________________
mcstas-users mailing list
mcstas-users at mcstas.org
https://mailman2.mcstas.org/mailman/listinfo/mcstas-users
Peter Kjær Willendrup
Forskningsingeniør, Specialkonsulent
DTU Physics
[image001.gif]
Technical University of Denmark
[image002.gif]
Department of Physics
Fysikvej
Building 307
DK-2800 Kongens Lyngby
Main office at
ESS DMSC
COBIS, Ole Maaløes vej 3, 2200 København N, Denmark
Direct +45 2125 4612
Mobil +45 2125 4612
Fax +45 4593 2399
pkwi at fysik.dtu.dk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman2.mcstas.org/pipermail/mcstas-users/attachments/20231023/64bf9eea/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 58 bytes
Desc: image001.gif
URL: <http://mailman2.mcstas.org/pipermail/mcstas-users/attachments/20231023/64bf9eea/attachment-0002.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.gif
Type: image/gif
Size: 1055 bytes
Desc: image002.gif
URL: <http://mailman2.mcstas.org/pipermail/mcstas-users/attachments/20231023/64bf9eea/attachment-0003.gif>
More information about the mcstas-users
mailing list