<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p>Dear Ryoichi,</p>
<p><br>
</p>
<p>You are right that in this case scat_factor becomes small - but so does l_full since materials thickness is small. So the fraction is in any case of the order 1.</p>
<p><br>
</p>
<p>Of course if you were interested in absolute intensities, the cross section should be weighted differently, as we do in the more realistic samples.<br>
</p>
<p><br>
</p>
<p>best, Kim<br>
</p>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Ryoichi Kajimoto <ryoichi.kajimoto@j-parc.jp><br>
<b>Sent:</b> Tuesday, October 24, 2023 11:14:59 AM<br>
<b>To:</b> Kim Lefmann; pkwi@dtu.dk<br>
<b>Cc:</b> mcstas-users@mcstas.org<br>
<b>Subject:</b> Re: [mcstas-users] TOFRes_sample</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">[You don't often get email from ryoichi.kajimoto@j-parc.jp. Learn why this is important at
<a href="https://aka.ms/LearnAboutSenderIdentification">https://aka.ms/LearnAboutSenderIdentification</a> ]<br>
<br>
Dear Kim,<br>
<br>
Thank you for explaining the detail.<br>
Maybe I understand.<br>
<br>
My question is that if scat_factor = 2*(radius-thickness), it becomes very small when thickness is nearly equal to radius. Then l_full/scat_factor becomes extremely large, which seems to be unreasonable.<br>
Anyhow it may not be a problem because the absolute intensity is not important in resolution calculation.<br>
<br>
Best regards,<br>
<br>
Ryoichi<br>
<br>
<br>
Kim Lefmann wrote on 2023/10/24 17:34:<br>
> Dear Ryoichi,<br>
><br>
><br>
> Since I wrote the code, please let me explain the logic.<br>
><br>
><br>
> For a resolution calculation, the absolute intensity is irrelevant, since you only want to know the widths.<br>
><br>
><br>
> The weighing using the fraction l_full/scat_factor is done to correct for the fact that the outer parts of the sample scatter differently from the center part due to different path lengths:<br>
><br>
><br>
> l_full is exactly the path length in the sample of this neutron ray<br>
><br>
> scat_factor is the path length for a ray that hits the sample center (and is constant for the full simulation).<br>
><br>
><br>
> The latter path length is used as normalization (and to ensure that the units are correct).<br>
><br>
><br>
> best, Kim<br>
><br>
><br>
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>
> *From:* mcstas-users <mcstas-users-bounces@mcstas.org> on behalf of Ryoichi Kajimoto <ryoichi.kajimoto@j-parc.jp><br>
> *Sent:* Tuesday, October 24, 2023 9:40:56 AM<br>
> *To:* pkwi@dtu.dk<br>
> *Cc:* mcstas-users@mcstas.org<br>
> *Subject:* Re: [mcstas-users] TOFRes_sample<br>
><br>
> [You don't often get email from ryoichi.kajimoto@j-parc.jp. Learn why this is important at
<a href="https://aka.ms/LearnAboutSenderIdentification">https://aka.ms/LearnAboutSenderIdentification</a> <<a href="https://aka.ms/LearnAboutSenderIdentification">https://aka.ms/LearnAboutSenderIdentification</a>> ]<br>
><br>
> Dear Peter,<br>
><br>
>> Wrt. the scat_factor, since thickness is an optional parameter (default=0, parametrises an optional "inner hollow”) I believe the formula is OK.<br>
> Thanks, but there is a line in line 176:<br>
> p *= l_full/scat_factor; /* Scattering probability */<br>
> where l_full is "Length of full path through sample."<br>
><br>
> It seems to me that p is defined as the ratio of length of full path through sample to total size of sample. However, if scat_factor is as it is, p can be larger than unity.<br>
><br>
> Best regards,<br>
><br>
> Ryoichi<br>
><br>
><br>
> Peter Kjær Willendrup wrote on 2023/10/24 16:12:<br>
>> Dear Ryochi,<br>
>><br>
>> Once I have the edits in place and a running instrument I will send the modified component to this mailinglist thread.<br>
>><br>
>> Wrt. the scat_factor, since thickness is an optional parameter (default=0, parametrises an optional "inner hollow”) I believe the formula is OK.<br>
>><br>
>> Best<br>
>> Peter<br>
>><br>
>> On 24 Oct 2023, at 07.20, Ryoichi Kajimoto <ryoichi.kajimoto@j-parc.jp> wrote:<br>
>><br>
>> Dear Peter,<br>
>><br>
>> Thank you for the prompt response. I hope this issue will be solved soon.<br>
>><br>
>> I have another question regarding TOFRes_sample.<br>
>><br>
>> On line 169 of TOFRes_sample.comp, there is a code:<br>
>> scat_factor = 2*(radius-thickness);<br>
>><br>
>> But is this correct? I think scat_factor should be 2*radius.<br>
>><br>
>><br>
>> Best regards,<br>
>><br>
>> Ryoichi<br>
>><br>
>> Peter Kjær Willendrup wrote on 2023/10/24 3:07:<br>
>> Dear Ryoichi Kajimoto,<br>
>><br>
>><br>
>> 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.<br>
>> (This has gone unnoticed since a test-instrument for the said component was not defined in our test suite, sorry for this.)<br>
>><br>
>> I have defined a GitHub issue at <a href="https://github.com/McStasMcXtrace/McCode/issues/1512">
https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMcStasMcXtrace%2FMcCode%2Fissues%2F1512&data=05%7C01%7Clefmann%40nbi.ku.dk%7Cde77aece11cf4918c23008dbd471b476%7Ca3927f91cda14696af898c9f1ceffa91%7C0%7C0%7C638337357056579252%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=94nRHavpkrZdgXTsClxXqFXDpVH5DuAZ1gf9tER8tpM%3D&reserved=0</a>
<<a href="https://github.com/McStasMcXtrace/McCode/issues/1512">https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMcStasMcXtrace%2FMcCode%2Fissues%2F1512&data=05%7C01%7Clefmann%40nbi.ku.dk%7Cde77aece11cf4918c23008dbd471b476%7Ca3927f91cda14696af898c9f1ceffa91%7C0%7C0%7C638337357056579252%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=94nRHavpkrZdgXTsClxXqFXDpVH5DuAZ1gf9tER8tpM%3D&reserved=0</a>>
and will implement the needed changes as soon as time allows.<br>
>><br>
>><br>
>> Best,<br>
>> Peter Willendrup<br>
>><br>
>> On 23 Oct 2023, at 13.29, Ryoichi Kajimoto <ryoichi.kajimoto@j-parc.jp> wrote:<br>
>><br>
>> Hi,<br>
>><br>
>> 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.<br>
>><br>
>> My code worked with McStas 3.1, but it cannot be compiled with McStas 3.4.<br>
>> I would appreciate if you could provide any solution.<br>
>><br>
>> 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.<br>
>><br>
>> 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...<br>
>><br>
>> Thank you in advance,<br>
>><br>
>> Ryoichi Kajimoto<br>
>><br>
>><br>
>> ==================================<br>
>><br>
>> SIKIResSim.c: In function ‘Table_Read_Handle’:<br>
>> SIKIResSim.c:7518:60: warning: format ‘%i’ expects argument of type ‘int’, but argument 5 has type ‘long int’ [-Wformat=]<br>
>> 7518 | fprintf(stderr,"Warning: Read_Table :%s %s Data has %i invalid lines (*****). Ignored.\n",<br>
>> | ~^<br>
>> | |<br>
>> | int<br>
>> | %li<br>
>> ......<br>
>> 7521 | count_invalid);<br>
>> | ~~~~~~~~~~~~~<br>
>> | |<br>
>> | long int<br>
>> SIKIResSim.c: In function ‘_resmonitor_setpos’:<br>
>> SIKIResSim.c:13221:6: error: ‘RSsample’ undeclared (first use in this function)<br>
>> 13221 | if(RSsample && strlen(RSsample))<br>
>> | ^~~~~~~~<br>
>> SIKIResSim.c:13221:6: note: each undeclared identifier is reported only once for each function it appears in<br>
>> SIKIResSim.c: In function ‘class_Res_monitor_init’:<br>
>> SIKIResSim.c:663:33: warning: format not a string literal and no format arguments [-Wformat-security]<br>
>> 663 | #define NAME_CURRENT_COMP (_comp->_name)<br>
>> | ~~~~~~^~~~~~~~<br>
>> SIKIResSim.c:13781:48: note: in expansion of macro ‘NAME_CURRENT_COMP’<br>
>> 13781 | if (!strcmp(filename,"\0")) sprintf(filename,NAME_CURRENT_COMP);<br>
>> | ^~~~~~~~~~~~~~~~~<br>
>> SIKIResSim.c:641:10: error: ‘_class_Res_sample_parameters’ undeclared (first use in this function); did you mean ‘_class_TOFRes_sample_parameters’?<br>
>> 641 | &( ((_class_ ## type ##_parameters *) _getvar_parameters(compname))->par )<br>
>> | ^~~~~~~<br>
>> SIKIResSim.c:13835:18: note: in expansion of macro ‘COMP_GETPAR3’<br>
>> 13835 | int *index_ptr=COMP_GETPAR3(Res_sample, res_sample_comp, compindex);<br>
>> | ^~~~~~~~~~~~<br>
>> SIKIResSim.c:641:41: error: expected expression before ‘)’ token<br>
>> 641 | &( ((_class_ ## type ##_parameters *) _getvar_parameters(compname))->par )<br>
>> | ^<br>
>> SIKIResSim.c:13835:18: note: in expansion of macro ‘COMP_GETPAR3’<br>
>> 13835 | int *index_ptr=COMP_GETPAR3(Res_sample, res_sample_comp, compindex);<br>
>> | ^~~~~~~~~~~~<br>
>><br>
>> ==================================<br>
>><br>
>> This is how I use TOFRes_sample() and Res_monitor():<br>
>><br>
>> ==================================<br>
>><br>
>> SPLIT COMPONENT RSsample = TOFRes_sample(<br>
>> thickness = sample_r-0.0001,<br>
>> radius = sample_r,<br>
>> yheight = sample_h,<br>
>> focus_xw = Wdx+0.001,<br>
>> focus_yh = Wdy+0.001,<br>
>> target_x = sample_det_x,<br>
>> target_y = sample_det_y,<br>
>> target_z = sample_det_z,<br>
>> time_bin = (ts+tsd+toffset)*1e6,<br>
>> time_width = Dtsd*1e6<br>
>> ) AT (0,0,L1) RELATIVE mod<br>
>><br>
>> COMPONENT det_pos = Arm()<br>
>> AT (sample_det_x,sample_det_y,sample_det_z) RELATIVE RSsample<br>
>> ROTATED (0,atan(sample_det_x/sample_det_z)*RAD2DEG,0) RELATIVE RSsample<br>
>><br>
>> COMPONENT resmonitor = Res_monitor(<br>
>> res_sample_comp = RSsample,<br>
>> options = "cylinder",<br>
>> xwidth = Wdx, yheight = Wdy,<br>
>> filename = "resmonitor.dat"<br>
>> ) AT (0,0,0) RELATIVE det_pos<br>
>> _______________________________________________<br>
>> mcstas-users mailing list<br>
>> mcstas-users@mcstas.org<br>
>> <a href="https://mailman2.mcstas.org/mailman/listinfo/mcstas-users">
https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman2.mcstas.org%2Fmailman%2Flistinfo%2Fmcstas-users&data=05%7C01%7Clefmann%40nbi.ku.dk%7Cde77aece11cf4918c23008dbd471b476%7Ca3927f91cda14696af898c9f1ceffa91%7C0%7C0%7C638337357056579252%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=v%2FzSDXQAZGU0cX2pdVG7nQgqZfCVuwdDig1alrUoZhw%3D&reserved=0</a>
<<a href="https://mailman2.mcstas.org/mailman/listinfo/mcstas-users">https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman2.mcstas.org%2Fmailman%2Flistinfo%2Fmcstas-users&data=05%7C01%7Clefmann%40nbi.ku.dk%7Cde77aece11cf4918c23008dbd471b476%7Ca3927f91cda14696af898c9f1ceffa91%7C0%7C0%7C638337357056579252%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=v%2FzSDXQAZGU0cX2pdVG7nQgqZfCVuwdDig1alrUoZhw%3D&reserved=0</a>><br>
>><br>
>><br>
>> Peter Kjær Willendrup<br>
>> Forskningsingeniør, Specialkonsulent<br>
>><br>
>> DTU Physics<br>
>> [image001.gif]<br>
>><br>
>><br>
>> Technical University of Denmark<br>
>><br>
>><br>
>> [image002.gif]<br>
>><br>
>><br>
>> Department of Physics<br>
>> Fysikvej<br>
>> Building 307<br>
>> DK-2800 Kongens Lyngby<br>
>><br>
>> Main office at<br>
>> ESS DMSC<br>
>> COBIS, Ole Maaløes vej 3, 2200 København N, Denmark<br>
>><br>
>> Direct +45 2125 4612<br>
>> Mobil +45 2125 4612<br>
>> Fax +45 4593 2399<br>
>> pkwi@fysik.dtu.dk<<a href=""></a>mailto:pkwi@fysik.dtu.dk <<a href="mailto:pkwi@fysik.dtu.dk">mailto:pkwi@fysik.dtu.dk</a>>><br>
>><br>
>><br>
>> Peter Kjær Willendrup<br>
>> Forskningsingeniør, Specialkonsulent<br>
>><br>
>> DTU Physics<br>
>> [image001.gif]<br>
>><br>
>><br>
>> Technical University of Denmark<br>
>><br>
>><br>
>> [image002.gif]<br>
>><br>
>><br>
>> Department of Physics<br>
>> Fysikvej<br>
>> Building 307<br>
>> DK-2800 Kongens Lyngby<br>
>><br>
>> Main office at<br>
>> ESS DMSC<br>
>> COBIS, Ole Maaløes vej 3, 2200 København N, Denmark<br>
>><br>
>> Direct +45 2125 4612<br>
>> Mobil +45 2125 4612<br>
>> Fax +45 4593 2399<br>
>> pkwi@fysik.dtu.dk<br>
>><br>
> _______________________________________________<br>
> mcstas-users mailing list<br>
> mcstas-users@mcstas.org<br>
> <a href="https://mailman2.mcstas.org/mailman/listinfo/mcstas-users">
https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman2.mcstas.org%2Fmailman%2Flistinfo%2Fmcstas-users&data=05%7C01%7Clefmann%40nbi.ku.dk%7Cde77aece11cf4918c23008dbd471b476%7Ca3927f91cda14696af898c9f1ceffa91%7C0%7C0%7C638337357056579252%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=v%2FzSDXQAZGU0cX2pdVG7nQgqZfCVuwdDig1alrUoZhw%3D&reserved=0</a>
<<a href="https://mailman2.mcstas.org/mailman/listinfo/mcstas-users">https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman2.mcstas.org%2Fmailman%2Flistinfo%2Fmcstas-users&data=05%7C01%7Clefmann%40nbi.ku.dk%7Cde77aece11cf4918c23008dbd471b476%7Ca3927f91cda14696af898c9f1ceffa91%7C0%7C0%7C638337357056579252%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=v%2FzSDXQAZGU0cX2pdVG7nQgqZfCVuwdDig1alrUoZhw%3D&reserved=0</a>><br>
<br>
</div>
</span></font>
</body>
</html>