From kristian.nielsen at risoe.dk Mon Jul 5 12:47:35 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 5 Jul 1999 12:47:35 +0200 Subject: Soller_trans.comp In-Reply-To: <37734792.D83D6BB9@ph.tum.de> (Georg_Artus@Physik.TU-Muenchen.DE) Message-ID: > Date: Fri, 25 Jun 1999 11:10:42 +0200 > From: "Dr. Georg Artus" > Hello Kristian, > > I just modified the component Soller to Soller_trans. The new component (I just returned from vacation, which is why I haven't answered you until now). Thanks for the Soller_trans component. I looked at it, and it looks perfectly fine to me. I added it to the list of unofficial components on the web page, maybe others will benefit from it. - Kristian. From kristian.nielsen at risoe.dk Mon Jul 5 13:16:25 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 5 Jul 1999 13:16:25 +0200 Subject: Vanadium Sample In-Reply-To: (message from Stephan Roth on Wed, 23 Jun 1999 09:04:20 +0200 (MET DST)) Message-ID: > Date: Wed, 23 Jun 1999 09:04:20 +0200 (MET DST) > From: Stephan Roth > Dear Sir, > > I am using McStas for the construction of a disc chopper time-of-flight > spectrometer of IN5-type. Especially I want to simulate angular resolved > But a detector placed at the focusing point counts no neutrons. > Hence I would like to ask you, if you could help me finding the mistake in > the setup (I have incorporated the in5.instr file in this mail). (I just returned from holiday, which is why I did not reply until now. So maybe you already solved your problem, but here is an answer just in case). Ok, I found two problems in your definition: 1. The first monitor overlaps with the sample. McStas does not deal very well with this situation. 2. The final monitor is parallel to the beam! It needs to be rotated to be perpendicular to the scattered beam from the sample. After fixing these two problems, the simulation produces neutrons in the final detector. I have attached the modified instrument definition. I also put the file on our web page, at http://neutron.risoe.dk/mcstas/support/roth/in5.instr - Kristian. -- Kristian Nielsen kristian.nielsen at risoe.dk Ris? National Laboratory Condensed Matter Physics and Chemistry Department Tel. +45 4677 5515 Fax +45 4677 4790 -------------- next part -------------- DEFINE INSTRUMENT detektest() TRACE COMPONENT arm = Arm() AT (0,0,0) ABSOLUTE COMPONENT source = Source_div(width=.02,height=.05,hdiv=.702,vdiv=.702,E0=2.2722,dE=.001) AT (0,0,0) RELATIVE arm COMPONENT guide = Guide(w1=.02,h1=0.05,w2=.02,h2=0.05,l=53,R0=0.995, Qc=.0214,alpha=5.566,m=1,W=.0033) AT (0,0,0.001) RELATIVE source COMPONENT detector1=Monitor(xmin=-.1,xmax=.1,ymin=-.2,ymax=.2) AT (0,0,0.190) RELATIVE guide COMPONENT sample1=V_sample(radius_i=.0143,radius_o=.0148,h=.05,pack=1,focus_r=.1, target_x=4,target_y=0,target_z=0) AT (0,0,.205) RELATIVE guide /* COMPONENT slit_det=Circular_slit(radius=.1) AT (4.000,0,0) RELATIVE sample1 */ COMPONENT detector1f=Monitor(xmin=-.2,xmax=.2,ymin=-.2,ymax=.2) AT (4,0,0) RELATIVE sample1 ROTATED (0,90,0) RELATIVE sample1 END From kristian.nielsen at risoe.dk Wed Jul 14 13:14:51 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 14 Jul 1999 13:14:51 +0200 Subject: Some questions concerning a vanadium scan In-Reply-To: <378C5816.BA3B2BE7@fz-juelich.de> (o.kirstein@fz-juelich.de) Message-ID: > Date: Wed, 14 Jul 1999 11:27:50 +0200 > From: "Dr. Oliver Kirstein" > I hope that you can help me with the following effect: I tried to make a > The effect is the following: If I don't use the 'Detector System 2' I > get distributions which are shown in mcstas2.ps whereas the use of > 'Detector System 2' gives the results shown in mcstas1.ps. > It makes me wonder because both detector parts don't use the same arm > definition. > Do you know what happens? Yes, I think I can explain the behaviour. Without the second detector group, the third detector group receives the full blast of the directly scattered beam from the vanadium sample, and this completely hides the faint signal from the scattering off the monochromator. With the second detector group, all neutrons scattered away from this second group (ie. the direct scattering onto the third group) is absorbed. This is a special "feature" of the monitor components in McStas that neutrons that move in the wrong direction are silently absorbed. Thus in this case only the scattering off the monochromator is observed. I think you will want to put in some shielding (just a simple slit perhaps) on arm2. You will also want to focus the scattering off the sample on the monochromator to get reasonable statistics. And you should eliminate the overlap between detectors Analyser_Div and Analyser_Energy. The silent absorbtion of backwards-moving neutrons is really a problem, and I will find some solution for it in the next McStas release. Hope this helps (otherwise ask again), - Kristian. From o.kirstein at fz-juelich.de Tue Jul 20 16:15:32 1999 From: o.kirstein at fz-juelich.de (Dr. Oliver Kirstein) Date: Tue, 20 Jul 1999 16:15:32 +0200 Subject: Again a question Message-ID: <37948484.6A2795DE@fz-juelich.de> Hi Kristian, I'm sorry but I would like to ask you again one (simple) question: In the following instrument definition I would like to use a vanadium sample (radius 1.5 cm, height 3 cm). Some of the input parameters are the focusing parameters (x,y,z and the radius of the target sphere). If i choose a target sphere with a radius of 2 m i think this must be the the parameter rt. Unfortunately I get the error message '...Did not hit cylinder from inside...'. I started the simulation with eres --ncount=2.e6 --dir=en_res --seed=334 TTM=140 E0=2.0804 DE=0.05 MOS=45 SAMPLE=2.4 Can you please tell me what happens? Thank you Oliver -- =============================================================================== _/_/_/ _/_/_/_/_/ _/_/_/_/_/ Oliver Kirstein _/ _/ _/ IFF, Neutronenstreuung _/ _/_/_/ _/_/_/ Forschungszentrum Juelich _/ _/ _/ D-52425 Juelich _/ _/ _/ Tel.: +49 (0)2461 614532 _/_/_/ _/ _/ Fax.: +49 (0)2461 612610 http://iff034.iff.kfa-juelich.de/Oliver/ =============================================================================== -------------- next part -------------- A non-text attachment was scrubbed... Name: vcard.vcf Type: text/x-vcard Size: 480 bytes Desc: Card for Dr. Oliver Kirstein URL: From kristian.nielsen at risoe.dk Wed Jul 21 08:16:07 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 21 Jul 1999 08:16:07 +0200 Subject: Again a question In-Reply-To: <37948484.6A2795DE@fz-juelich.de> (o.kirstein@fz-juelich.de) Message-ID: > Date: Tue, 20 Jul 1999 16:15:32 +0200 > From: "Dr. Oliver Kirstein" > the following instrument definition I would like to use a vanadium > sample (radius 1.5 cm, height 3 cm). Some of the input parameters are > the focusing parameters (x,y,z and the radius of the target sphere). > > If i choose a target sphere with a radius of 2 m i think this must be > the the parameter rt. Unfortunately I get the error message '...Did not > hit cylinder from inside...'. I started the simulation with Well, it looks like you forgot to attach the instrument to the mail? I would suspect a problem with the focusing. A target radius of 2 meter for the sample seems very large. Note that the sample cannot be placed inside the target sphere; in that case you will get a cryptic error message similar to the one you mentioned. So with a target sphere radius of 2 meter, the distance (length of (x,y,z)) must be more than two meter or things will not work. Maybe you have misunderstood the meaning of the target sphere? It is not explained very well in the manual. The idea is something like the following: ____ / \ O | | \____/ sample target sphere Neutrons will be scattered from the sample only in the solid angle corresponding to the target sphere as seen from the scattering point. So the sphere should be chosen just large enough to completely surround the object of interest (eg. an analyser). If you really need to have the sample inside the target sphere, you should instead set the target sphere radius to zero to make the sample scatter in all directions. I hope this helps, otherwise ask again. I will be away for most of three and a half weeks starting tomorrow (Thursday), so you might want to send any later questions to the list (neutron-mc at risoe.dk) so that Kim Lefmann or others may also help you. - Kristian. From kristian.nielsen at risoe.dk Wed Jul 21 08:19:50 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 21 Jul 1999 08:19:50 +0200 Subject: mcstas In-Reply-To: <378F4838.8FA1386F@physik.tu-dresden.de> (message from martin rotter on Fri, 16 Jul 1999 16:56:57 +0200) Message-ID: > Date: Fri, 16 Jul 1999 16:56:57 +0200 > From: martin rotter > To have a printout of mcdisplay on a postscript printer I have midified the file > > mcdisplay.pl > > the new file is attached. After quitting mcdisplay now, a file mcstas.ps is > created automatically containing the plot of the instrument. > > Maybe you can use this idea for a future version of mcstas ... Thanks for the code. I think the idea is a good one and I will try to integrate the new feature into the next release of McStas. - Kristian. From rotter at physik.tu-dresden.de Fri Jul 16 16:56:57 1999 From: rotter at physik.tu-dresden.de (martin rotter) Date: Fri, 16 Jul 1999 16:56:57 +0200 Subject: mcstas Message-ID: <378F4838.8FA1386F@physik.tu-dresden.de> dear kristian nielsen, I have started using the mcstas 1.1 package to do simulations of neutron triple axis spektrometer PANDA which is to be built in garching. To have a printout of mcdisplay on a postscript printer I have midified the file mcdisplay.pl the new file is attached. After quitting mcdisplay now, a file mcstas.ps is created automatically containing the plot of the instrument. Maybe you can use this idea for a future version of mcstas ... with best wishes Martin Rotter -------------- next part -------------- A non-text attachment was scrubbed... Name: Mcdispla.pl Type: application/x-perl Size: 15849 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: vcard.vcf Type: text/x-vcard Size: 445 bytes Desc: Visitenkarte f|r Martin Rotter URL: From kristian.nielsen at risoe.dk Mon Aug 16 12:05:52 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 16 Aug 1999 12:05:52 +0200 Subject: McStas In-Reply-To: (owner-neutron-mc@risoe.dk) Message-ID: > Date: Sat, 14 Aug 1999 04:27:32 +0200 (CEST) >From john at rrdjazz.nist.gov Sat Aug 14 04:27:31 1999 > I have just seen the article in Neutron News about McStas. Please add me to > your mailing list. You have been added with the address "john.copley at nist.gov". Another good source of information on McStas is the World Wide Web page: http://neutron.risoe.dk/mcstas/ > As a member of the Neutron Optics Advisory Committee to the SNS project I am > interested in knowing more about the extent to which a standard has been > established for neutron ray-tracing calculations. Who should I contact at > Oak Ridge and at Los Alamos to find out about their projects? I'm guessing > Lee Robertson and Phil Seeger? I just returned from a visit at Argonne National Laboratory. I talked to Ken Herwig from Argonne, he and Lee Robertson are the ones to contact about the standard. Phil Seeger is in charge of the MCRUN/MCLIB program, which as far as I know does not use the new standard at this point. At Argonne, I talked to several Scientists designing instruments for the SNS. I started three simulation projects based on McStas. One is a guide design for a reflectometer by Frank Klose and John Ankner. Another is a setup for time-focusing with off-cut analyser crystals by J. Carpenter. A third is an investigation of background contribution from small-angle scattering off Soller collimators. My colleague Kim Lefmann told me that there are some people at NIST already using the McStas program. I CC'ed this mail to him, perhaps he will send you details. > You may or may not know that I and collaborators wrote a Monte Carlo program > to calculate multiple scattering effects, MSCAT. It is almost an antique > but perhaps some of the concepts could be incorporated in your program. Actually, Ken Herwig mentioned the program to me during my visit, and I was planning to take a look at it. Do you have any pointers to references or downloads for the program that could serve as a starting point? > Meantime can I ask you whether you can simulate a neutron optical filter > with coatings that have a rather unusual (to my mind) refelctivity as a > function of Q? Roughly speaking R(Q) is near 100% up to about 0.027 A-1. > Thereafter it drops rpaidly but it has a broad peak at about 0.04 A-1 > whose peak reflectivity is about 30%! This question was actually raised also in March when I was visiting the ILL in Grenoble, France. We have not simulated such a filter yet. However, I believe it would be quite simple to add, by modifying the current simulation of supermirrors. The supermirror code contains a simple expression for the reflectivity as a function of Q; simply replacing this with an expression for the reflectivity curve for the filter should be sufficient. If you are interested, I would be happy to assist with this. Please contact me when you are back from your vacation, and we can follow up on this. - Kristian. -- Kristian Nielsen kristian.nielsen at risoe.dk Ris? National Laboratory Condensed Matter Physics and Chemistry Department Tel. +45 4677 5515 Fax +45 4677 4790 From glhansen at iucf.indiana.edu Thu Aug 19 22:14:23 1999 From: glhansen at iucf.indiana.edu (Gregory L. Hansen) Date: Thu, 19 Aug 1999 15:14:23 -0500 (EST) Subject: McStas Message-ID: I was attracted by your wonderful project, but I'm having trouble installing it on an HP-UX system. The /.configure --prefix=/user/glhansen part seemed to go well, but I got a bunch of errors on make that I don't know what to do with, they're copied below. I don't have any kind of superuser privilages. glhansen at ashima:/mcstas-1.1 $ make gcc -I. -I. -c -g -O2 -DMC_SYS_DIR='"'/users/glhansen/lib/mcstas'"' -DCC _HAS_PROTOS=1 -DHAVE_STRCASECMP=1 -DHAVE_FDOPEN=1 -DDEBUG=0 instrument.tab.c In file included from /usr/local/gnu/lib/gcc-lib/hppa1.1-hp-hpux9.05/2.7.0/inclu de/stdlib.h:231, from mcstas.h:78, from instrument.y:18: /usr/include/pwd.h:29: parse error before `int32_t' /usr/include/pwd.h:29: warning: no semicolon at end of struct or union /usr/include/pwd.h:31: parse error before `}' /usr/include/pwd.h:67: parse error before `int32_t' /usr/include/pwd.h:67: warning: no semicolon at end of struct or union /usr/include/pwd.h:69: parse error before `}' /usr/include/pwd.h:80: warning: parameter names (without types) in function decl aration *** Error exit code 1 Stop. From kristian.nielsen at risoe.dk Fri Aug 20 08:36:57 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 20 Aug 1999 08:36:57 +0200 Subject: McStas In-Reply-To: (glhansen@iucf.indiana.edu) Message-ID: > Date: Thu, 19 Aug 1999 15:14:23 -0500 (EST) > From: "Gregory L. Hansen" > I was attracted by your wonderful project, but I'm having trouble > installing it on an HP-UX system. The /.configure --prefix=/user/glhansen > part seemed to go well, but I got a bunch of errors on make that I don't > know what to do with, they're copied below. I don't have any kind of > superuser privilages. > > glhansen at ashima:/mcstas-1.1 $ make > gcc -I. -I. -c -g -O2 > -DMC_SYS_DIR='"'/users/glhansen/lib/mcstas'"' -DCC > _HAS_PROTOS=1 -DHAVE_STRCASECMP=1 -DHAVE_FDOPEN=1 -DDEBUG=0 > instrument.tab.c > In file included from > /usr/local/gnu/lib/gcc-lib/hppa1.1-hp-hpux9.05/2.7.0/inclu > de/stdlib.h:231, > from mcstas.h:78, > from instrument.y:18: > /usr/include/pwd.h:29: parse error before `int32_t' > /usr/include/pwd.h:29: warning: no semicolon at end of struct or union > /usr/include/pwd.h:31: parse error before `}' > /usr/include/pwd.h:67: parse error before `int32_t' > /usr/include/pwd.h:67: warning: no semicolon at end of struct or union Hm, this looks like there is a problem with the installation of the GCC C compiler on your machine. I think the first thing to try is to compile McStas with the standard HPUX compiler (assuming you have it installed). To do this, compile McStas again as follows: rm -f config.cache setenv CC cc ./configure --prefix=/user/glhansen make and see if it helps (or mail me the output if it does not). You do not need superuser privileges to install McStas. Just let me know if you need further assistance. I found the following on the Web, which seems to mention a similar problem: ---------------------------------------------------------------------- Norman Bullen writes: > Andy Armacost wrote: > > > > Having problems running Gnu C/C++ on hpux 10.20. When #INCLUDEing > > stdlib.h, we get parse errors in the header file pwd.h. > > from hello.c:3: > > /usr/include/pwd.h:37: parse error before `int32_t' > > /usr/include/pwd.h:37: warning: no semicolon at end of struct or union > > /usr/include/pwd.h:39: parse error before `}' > > /usr/include/pwd.h:75: parse error before `int32_t' > > /usr/include/pwd.h:75: warning: no semicolon at end of struct or union The following program works for me on an HP-UX 10.20 machine compiled using g++ #include #include #include int main(void) { cout << " hello\n"; return 0; } the pwd.h header is included in the stdlib.h file (at least in the HP version) so you should look in the gcc fixed include files. gcc does not use the standard system includes, instead it copies them and changes them to be ANSI c compliant. The sed program for HP 10.20 is broken and the gcc installation needs either a patched HP sed or the Gnu version of sed. If not, compilation of programs will fail with symptoms similar to the above. ---------------------------------------------------------------------- - Kristian. -- Kristian Nielsen kristian.nielsen at risoe.dk Ris? National Laboratory Condensed Matter Physics and Chemistry Department Tel. +45 4677 5515 Fax +45 4677 4790 From glhansen at iucf.indiana.edu Fri Aug 20 15:48:07 1999 From: glhansen at iucf.indiana.edu (Gregory L. Hansen) Date: Fri, 20 Aug 1999 08:48:07 -0500 (EST) Subject: McStas In-Reply-To: <01JEZFX5QIL29I6B2G@risoe.dk> Message-ID: On Fri, 20 Aug 1999, Kristian Nielsen wrote: > I think the first thing to try is to compile McStas with the standard > HPUX compiler (assuming you have it installed). To do this, compile > McStas again as follows: > > rm -f config.cache > setenv CC cc > ./configure --prefix=/user/glhansen > make That seems to have done it. Thanks. From john.copley at nist.gov Mon Aug 23 19:09:46 1999 From: john.copley at nist.gov (John Copley) Date: Mon, 23 Aug 1999 13:09:46 -0400 Subject: McStas Message-ID: <37C1805A.E615FC07@nist.gov> Dear Kristian Thanks for your message, and thanks for adding me to the mailing list. I'm not sure whether your colleagues got a copy of your message. The CC line read as follows: CC: kim.lefmann at risoe.dk.kurt.clausen@risoe.dk (note the . between dk and kurt) Let me tell you a little bit about MSCAT. The original program, called MSC, was written by Frank Bischoff roughly 30 years ago! When I was a postdoc at Argonne my supervisor, Mike Rowe, asked me to acquire the program and get it into a form that would be easier for neutron scatterers to use. In the process and since then a number of new features have been added. The last official release was about 15 years ago. It is described in Comp. Phys. Commun. 40 (1986) 337-357 (which I can send you if you are interested), together with references therein. Frankly the program is sufficiently antiquated that I don't particularly like to use it myself! On the other hand it is still (I think) the only comprehensive program that's available for this type of calculation. I've tried on several occasions to persuade someone to have their student rewrite the program under some sort of loose supervision from me, but it has never taken off. I have also rewritten large parts of the program myself, but there are challenges that I have never succeeded in sorting out to my own satisfaction. Largely these challenges have to do with the selection of a new direction and magnitude for the neutron wave vector k, given S(Q,omega). Within MSCAT, before the Monte Carlo loop begins, a number of functions are formed from the input S(Q,omega); these include the upscattering probability as a function of the incident neutron energy, the so-called marginal up- and down-scattering functions, and so on. These functions are used to select the new direction and magnitude of k in such a way that all choices are about equally likely (i.e. to reduce the variance), but there are problems in deciding how to do the various integrals necessary to form these functions (number of points, mesh size etc). Every time I think about this matter I ask myself whether it might be better to do the sampling in a more straightforward but less efficient manner, and I have never satisfactorily resolved this question. If you think this is worth pursuing I can fill you in with more detailed information and I can send you code. At present MSCAT is a standalone program written in Fortran and the user is required to provide a subroutine that defines S(Q,omega) (even though this is of course unknown, being the quanitity that one is trying to measure when one does a neutron scattering experiment). This should be kept in mind when rewriting the program and/or incorporating it in a larger piece of software such as McStas. With regard to simulating the optical filter at my instrument, I propose to send you a fax containing a description of the geometry of the guide, plus a measured reflectivity curve. What is your fax number? Best wishes John -- John R.D. Copley National Institute of Standards and Technology 100 Bureau Drive, Stop 8562 Gaithersburg, MD 20899-8562 Tel: (301)975-5133/6220 FAX: (301)921-9847 From kristian.nielsen at risoe.dk Tue Aug 24 09:35:58 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 24 Aug 1999 09:35:58 +0200 Subject: McStas In-Reply-To: <37C1805A.E615FC07@nist.gov> (message from John Copley on Mon, 23 Aug 1999 13:09:46 -0400) Message-ID: Dear John, > Date: Mon, 23 Aug 1999 13:09:46 -0400 > From: John Copley > I'm not sure whether your colleagues got a copy of your message. The CC > line read as follows: > CC: kim.lefmann at risoe.dk.kurt.clausen@risoe.dk > (note the . between dk and kurt) > Let me tell you a little bit about MSCAT. Thanks a lot for the information on MSCAT. I would be grateful for a copy of the paper you mentioned, which does not seem to be available from our library (though they could probably obtain it from somewhere else for me it that is more convenient). We are slowly starting to look in more detail on simulating scattering kernels, and we should clearly try to build as much as possible on previous work. As regards different techniques for sampling, this is also something that we have given much thought, though more so for general instrument simulation and less for what happens inside samples. It sounds like your ideas are quite similar to ours. Usually, we try to sample in a way that is reasonably easy to implement and which ensures good (if not perfect) variance of the results. The weight assigned to the individual event is then adjusted to make the result match the physical model. I think this is what you meant when you described your selection of outgoing wave vector? We have even experimented with making the sampling strategy variable, adapting itself to the individual simulation, with surprisingly good results. On the other hand the problem of sampling based on an arbitrary user-supplied S(Q,omega) sounds quite hard, and I am sure that we could benefit from some discussion on this. So yes, I would be very interested in more information on this. > With regard to simulating the optical filter at my instrument, I propose > to send you a fax containing a description of the geometry of the guide, > plus a measured reflectivity curve. What is your fax number? That sounds fine. My fax number is +45 4677 4790 (the +45 is the code for Denmark, as you probably know). I will be happy to look at it and work something out, it shouldn't be very difficult. - Kristian. -- Kristian Nielsen kristian.nielsen at risoe.dk Ris? National Laboratory Condensed Matter Physics and Chemistry Department Tel. +45 4677 5515 Fax +45 4677 4790 From horn at ill.fr Wed Aug 25 14:23:22 1999 From: horn at ill.fr (P. Horn) Date: Wed, 25 Aug 1999 14:23:22 +0200 Subject: McStas Message-ID: <37C3E039.41C6@ill.fr> Hello! At working with McStas i found a bug in the component Monochromator at line 59. The instrument definition i attached to this e-mail should reproduce the error or not. Something else: What else monitors are existing now? I have only seen the official and unofficial components on your McStas-pages. I have written a Monitor wich gives a 2D-output of the energy an the vertical divergence. Do you want it? Thanks a lot in forward. Pay Schulze Horn -------------- next part -------------- DEFINE INSTRUMENT mono_bug() DECLARE %{ double mono_q, lambda_zero, e_zero; %} INITIALIZE %{ lambda_zero=5; e_zero=((2*PI)/lambda_zero)*((2*PI)/lambda_zero)*K2V*K2V*VS2E; mono_q=4*PI*sin(DEG2RAD*45)/lambda_zero; /* Here is the angle 45 deg not 80 */ %} TRACE COMPONENT a1=Arm() AT (0,0,0) ABSOLUTE ROTATED (0,0,0) ABSOLUTE COMPONENT s=Source_div( width=0.001, height=0.001, hdiv=0, vdiv=0, E0=e_zero, dE=0) AT (0,0,0) RELATIVE a1 ROTATED (0,0,0) RELATIVE a1 COMPONENT m1=Monochromator( zmin=-0.5, zmax=0.5, ymin=-0.5, ymax=0.5, mosaich=15, mosaicv=15, r0=1, Q=mono_q) AT (0,0,0.2) RELATIVE a1 ROTATED (0,40,0) RELATIVE a1 COMPONENT a2=Arm() AT (0,0,0.3) RELATIVE a1 ROTATED (0,80,0) RELATIVE a1 /* But here is an angle above twice of the mosiaic.*/ COMPONENT moni1=Monitor( xmin=-0.3, xmax=0.3, ymin=-0.3, ymax=0.3) AT (0,0,0.2) RELATIVE a2 ROTATED (0,0,0) RELATIVE a2 END From kristian.nielsen at risoe.dk Thu Aug 26 10:43:45 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 26 Aug 1999 10:43:45 +0200 Subject: McStas In-Reply-To: <37C3E039.41C6@ill.fr> (horn@ill.fr) Message-ID: > Date: Wed, 25 Aug 1999 14:23:22 +0200 > From: "P. Horn" > Hello! > > At working with McStas i found a bug in the component Monochromator at > line 59. The instrument definition i attached to this e-mail should > reproduce the error or not. You did not mention exactly what the problem you experienced was, but I assume it was that some neutrons were reflected, even though the scattering angle was far off the Bragg angle? I tried running your example using the components of McStas version 1.1 (which version were you using btw? If unsure, "mcstas --version" will tell you). This gives the (correct) scattered intensity of zero; however it does scatter the neutron with a weight of zero, which is not really desirable. Was this the problem you had in mind, or did you see something else? The problem mentioned above will be fixed in the next version. Furthermore the Monochromator component has been replaced by new and much better implementation (which will be included in the next release). I can send that (or a fixed Monochromator.comp component) to you if you like? > Something else: > What else monitors are existing now? > I have only seen the official and unofficial components on your > McStas-pages. I have a 2D divergence-position detector that has not yet been put on the unofficial page. Not sure if there are any others. > I have written a Monitor wich gives a 2D-output of the energy an the > vertical divergence. Do you want it? Yes please! I would very much like to put it on the web page so that others could benefit; we already have a good number of people using McStas. If I can get documentation for the component I would also like to include it in the next release. Thanks for the report and your interest, - Kristian. -- Kristian Nielsen kristian.nielsen at risoe.dk Ris? National Laboratory Condensed Matter Physics and Chemistry Department Tel. +45 4677 5515 Fax +45 4677 4790 From eiverson at anl.gov Wed Aug 25 17:14:31 1999 From: eiverson at anl.gov (eiverson at anl.gov) Date: Wed, 25 Aug 1999 11:14:31 -0400 Subject: Mcstas Message-ID: <199908251614.LAA14041@black.pns.anl.gov> Dear Kristian, I hope your travels home went well. It was very productive to have you visit, and I once again thank you for your assistance with Mcstas. I had no trouble downloading the external packages the next week; the network recovered quite nicely. However, I have had no luck trying to install it. I installed the PGPLOT and PDL rpms with no trouble, as well as the perl-PGPLOT source rpm. However, I could not get the perl-PGPLOT to compile. I wonder if you might have any specific directions. Here is a transcript of a session... .......... ivu % perl Makefile.PL Found compiler g77 ExtUtils::F77: Using system=Generic compiler=G77 Checking for gcc in disguise Compiler is gcc version 2.7.2.3ExtUtils::F77: Validating -L/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.90.29 -L/usr/lib -lf2c -lm -L/usr/lib/gcc-lib/i386-redhat-linux/2.7.2.3 -lgcc [ok] ExtUtils::F77: Compiler: g77 ExtUtils::F77: Cflags: -O Checking if your kit is complete... Looks good Note (probably harmless): No library found for -lcpgplot Writing Makefile for PGPLOT ivu % make mkdir ./blib mkdir ./blib/lib mkdir ./blib/arch mkdir ./blib/arch/auto mkdir ./blib/arch/auto/PGPLOT mkdir ./blib/lib/auto mkdir ./blib/lib/auto/PGPLOT mkdir ./blib/man3 cp ExtUtils/F77.pm ./blib/lib/ExtUtils/F77.pm cp PGPLOT.pm ./blib/lib/PGPLOT.pm /usr/bin/perl -I/usr/lib/perl5/i386-linux/5.00405 -I/usr/lib/perl5 /usr/lib/perl5/ExtUtils/xsubpp -typemap /usr/lib/perl5/ExtUtils/typemap -typemap typemap PGPLOT.xs >PGPLOT.tc && mv PGPLOT.tc PGPLOT.c Please specify prototyping behavior for PGPLOT.xs (see perlxs manual) cc -c -I/home/aaossm/kgb/soft/pgplot/bld -I/usr/local/pgplot -Dbool=char -DHAS_BOOL -O2 -DVERSION=\"2.12\" -DXS_VERSION=\"2.12\" -fpic -I/usr/lib/perl5/i386-linux/5.00405/CORE PGPLOT.c PGPLOT.xs:14: cpgplot.h: No such file or directory make: *** [PGPLOT.o] Error 1 ivu % locate cpgplot ivu % rpm -qa | grep pgplot pgplot-5.1.1-4 ivu % ............. Obviously the difficulty is that there is no cpgplot, either library or headers. Is this supposed to be a part of the PGPLOT distribution? Best regards, Erik Iverson ---------------------------------------------------------------------- Erik B. Iverson, PhD. Spallation Neutron Source Project c/o IPNS 360 Oak Ridge National Laboratory Argonne National Laboratory (630) 252-1181 9700 S. Cass Ave. (FAX) (630) 252-4163 Argonne, IL 60439-4814 eiverson at anl.gov From eiverson at anl.gov Wed Aug 25 19:39:08 1999 From: eiverson at anl.gov (eiverson at anl.gov) Date: Wed, 25 Aug 1999 13:39:08 -0400 Subject: Mcstas In-Reply-To: "Your message of Wed, 25 Aug 1999 11:14:31 EDT." <199908251614.LAA14041@black.pns.anl.gov> Message-ID: <199908251839.NAA18982@black.pns.anl.gov> Dear Kristian, True to Murphy's Law, I have solved the specific problem about which I emailed you earlier. I got the source version of PGPLOT and compiled it on my machine, and it provided the cpgplot that I needed. Unfortunately, I still cannot get perl-PGPLOT to successfully compile. It will "make" without any errors, but "make test" fails completely. If you have any recommendations, that would be wonderful! Cheers, Erik .... black % make cc -c -I/usr/local/PGPLOT/ -I/home/aaossm/kgb/soft/pgplot/bld -I/usr/local/pgplo t -Dbool=char -DHAS_BOOL -O2 -DVERSION=\"2.12\" -DXS_VERSION=\"2.12\" -fpic - I/usr/lib/perl5/i386-linux/5.00404/CORE PGPLOT.c Running Mkbootstrap for PGPLOT () chmod 644 PGPLOT.bs LD_RUN_PATH="/usr/local/PGPLOT:/usr/X11R6/lib:/usr/lib/gcc-lib/i686-unknown-linu x/2.7.2.3.f.1:/usr/lib" cc -o blib/arch/auto/PGPLOT/PGPLOT.so -shared -L/usr/lo cal/lib PGPLOT.o -L/usr/local/PGPLOT/ -L/usr/local/lib -lcpgplot -lpgplot -L/ usr/X11R6/lib -lX11 -L/usr/lib/gcc-lib/i686-unknown-linux/2.7.2.3.f.1 -L/usr/lib -lf2c -lm -L/usr/lib/gcc-lib/i686-unknown-linux/2.7.2.3.f.1 -lgcc chmod 755 blib/arch/auto/PGPLOT/PGPLOT.so cp PGPLOT.bs ./blib/arch/auto/PGPLOT/PGPLOT.bs chmod 644 blib/arch/auto/PGPLOT/PGPLOT.bs Manifying ./blib/man3/ExtUtils::F77.3 Manifying ./blib/man3/PGPLOT.3 black % make test black % make test PERL_DL_NONLAZY=1 /usr/bin/perl -I./blib/arch -I./blib/lib -I/usr/lib/perl5/i386- linux/5.00404 -I/usr/lib/perl5 test.pl ============== Running test1.p ============== Can't load './blib/arch/auto/PGPLOT/PGPLOT.so' for module PGPLOT: ./blib/arch/aut o/PGPLOT/PGPLOT.so: undefined symbol: fstat at /usr/lib/perl5/i386-linux/5.00404/ DynaLoader.pm line 166. at test1.p line 3 BEGIN failed--compilation aborted at test1.p line 3. black % l -l ./blib/arch/auto/PGPLOT/PGPLOT.so -rwxr-xr-x 1 eiverson eiverson 168696 Aug 25 13:31 ./blib/arch/auto/PGPLOT/PG PLOT.so* black % printenv | grep PGPLOT PWD=/usr/src/redhat/SOURCES/PGPLOT-2.12 LD_LIBRARY_PATH=/usr/local/PGPLOT PGPLOT_DEV=/xwin PGPLOT_DIR=/usr/local/PGPLOT/ From horn at ill.fr Thu Aug 26 15:34:53 1999 From: horn at ill.fr (P. Horn) Date: Thu, 26 Aug 1999 15:34:53 +0200 Subject: McStas References: <01JF7Y4FJTL89JEAIX@risoe.dk> Message-ID: <37C5427D.41C6@ill.fr> Kristian Nielsen wrote: > I tried running your example using the components of McStas version 1.1 > (which version were you using btw? If unsure, "mcstas --version" will > tell you). I am runng version 1.1, but i used the monochromator of version 1.0, which is still shown in the web at http://neutron.risoe.dk/mcstas/components/Monochromator/Monochromator.comp From john.copley at nist.gov Thu Aug 26 22:17:15 1999 From: john.copley at nist.gov (John Copley) Date: Thu, 26 Aug 1999 16:17:15 -0400 Subject: MSCAT etc Message-ID: <37C5A0CB.38BBD62B@nist.gov> Kristian MSCAT does attempt to estimate the statistical error. If you want to run e.g. 10000 neutrons, you break them up into e.g. 50 groups of 20, average the results for each group, and then calculate overall means and variances treating the average results for each group as a single item. I don't know if I explained this properly but I believe it's pretty standard. I should point out that since every neutron is scored into every time channel and every detector at every scattering event, the results for different times and angles are highly correlated and one cannot learn anything by looking at the scatter of the points e.g. in a plot of intensity vs. angle. Regarding the optical filter calculation, many thanks! I would indeed appreciate more information, and I'm also wondering if you could do a few more runs? One of these days I'd like to get familiar with McStas but I have an instrument to complete before I can do that! You say the transmission for 0.5 AA neutrons is about 2e-5. What is it for 5 A neutrons? How much work would it be to calculate the transmission in steps of 0.1 AA say from 0.1 to 5 AA, using (i) the reflectivity graphs that I sent you and (ii) idealized reflectivity graphs with R=1 for Q<=0.265 (sides), R=1 for Q<=0.43 (top/bottom), 0 otherwise? In terms of running McStas here, Collin Broholm has a student who is running it. He could probably help me if needed. Best wishes John -- John R.D. Copley National Institute of Standards and Technology 100 Bureau Drive, Stop 8562 Gaithersburg, MD 20899-8562 Tel: (301)975-5133/6220 FAX: (301)921-9847 From hansen at ill.fr Fri Sep 3 09:50:05 1999 From: hansen at ill.fr (Thomas Hansen) Date: Fri, 03 Sep 1999 09:50:05 +0200 Subject: PGPLOT - no success under LinuxPPC Message-ID: I managed to install McSTAS-1.1 under LinuxPPC on a Macintosh PowerBook G3, as well as the installation on MacOS 8.6 using CodeWarrior. However, use of gscan, mcplot and mcdisplay only is possible under Linux/Unix ... and there there I encountered one problem (up to now ...) during the installation of PGPERL. I post here the hopefully helpfull reply to my Linux-specific problem. >Sender: kgb at aaoepp.aao.GOV.AU >Date: Fri, 03 Sep 1999 09:49:48 +1000 >From: Karl Glazebrook >Organization: Anglo-Australian Observatory >X-Accept-Language: en >MIME-Version: 1.0 >To: Thomas Hansen >Subject: Re: PGPLOT - no success under LinuxPPC >Status: U > > >Content-Type: message/rfc822 >Content-Transfer-Encoding: 7bit >Content-Disposition: inline > >X-Mozilla-Status2: 00000000 >Message-ID: <37A4DAC9.5F3B79B0 at aaoepp.aao.gov.au> >Date: Mon, 02 Aug 1999 09:39:53 +1000 >From: Karl Glazebrook >Organization: Anglo-Australian Observatory >X-Mailer: Mozilla 4.6 [en] (X11; I; Linux 2.2.5-22 i686) >X-Accept-Language: en >MIME-Version: 1.0 >To: Farhi >Subject: Re: PGPERL 2.12 test error >References: <37A1A2F7.8CD7974E at ill.fr> >Content-Type: multipart/mixed; > boundary="------------F2CF6A9288216BC297790A0D" > > > >This is a recent problem due to the name change in g77 from >'libf2c' to 'libg2c'. the next release of my module >should fix it. > >meanwhile try this new version of F77.pm, let me know if it >works! > > >Karl > package ExtUtils::F77; use Config; =head1 NAME ExtUtils::F77 - Simple interface to F77 libs =head1 DESCRIPTION This module tries to figure out how to link C programs with Fortran subroutines on your system. Basically one must add a list of Fortran runtime libraries. The problem is their location and name varies with each OS/compiler combination! This module tries to implement a simple 'rule-of-thumb' database for various flavours of UNIX systems. A simple self-documenting Perl database of knowledge/code for figuring out how to link for various combinations of OS and compiler is embedded in the modules Perl code. Please help save the world by sending database entries for your system to kgb at aaoepp.aao.gov.au The library list which the module returns can be explicitly overridden by setting the environment variable F77LIBS, e.g. % setenv F77LIBS "-lfoo -lbar" % perl Makefile.PL ... =cut $VERSION = "1.11"; # Database starts here. Basically we have a large hash specifying # entries for each os/compiler combination. Entries can be code refs # in which case they are executed and the returned value used. This # allows us to be quite smart. # Hash key convention is uppercase first letter of # hash keys. First key is usually the name of the architecture as # returned by Config (modulo ucfirst()). %F77config=(); ### SunOS (use this as a template for new entries) ### # Code to figure out and return link-string for this architecture # Returns false if it can't find anything sensible. $F77config{Sunos}{F77}{Link} = sub { $dir = find_highest_SC("/usr/lang/SC*"); return "" unless $dir; # Failure print "$Pkg: Found Fortran latest version lib dir $dir\n"; return "-L$dir -lF77 -lm"; }; # Whether symbols (subroutine names etc.) have trailing underscores # (true/false) $F77config{Sunos}{F77}{Trail_} = 1; # Name of default compiler - corresponds to one of the above keys $F77config{Sunos}{DEFAULT} = 'F77'; # Program to run to actually compile stuff $F77config{Sunos}{F77}{Compiler} = 'f77'; # Associated compiler flags $F77config{Sunos}{F77}{Cflags} = '-O'; ############ Rest of database is here ############ ### Solaris ### $F77config{Solaris}{F77}{Link} = sub { $dir = find_highest_SC("/opt/SUNWspro/SC*/lib"); return "" unless $dir; # Failure print "$Pkg: Found Fortran latest version lib dir $dir\n"; return "-L$dir -lF77 -lM77 -lsunmath -lm"; }; $F77config{Solaris}{F77}{Trail_} = 1; $F77config{Solaris}{F77}{Compiler} = 'f77'; $F77config{Solaris}{F77}{Cflags} = '-O'; $F77config{Solaris}{DEFAULT} = 'F77'; ### Generic GNU-77 or F2C system ### $F77config{Generic}{G77}{Link} = sub { my @libs = ( 'f2c', 'g2c'); my ($dir, $lib, $test); foreach $test (@libs) { $dir = `g77 -print-file-name=lib$test.a`; chomp $dir; # Note that -print-file-name returns just the library name # if it cant be found - make sure that we only accept the # directory if it returns a proper path (or matches a /) if (defined $dir && $dir ne "lib$test.a") { $lib = $test; # Found an existing library last; } } if( defined $dir && defined $lib) { $dir =~ s,/lib$lib.a$,,; } else { $dir = "/usr/local/lib"; $lib = "f2c"; } return( "-L$dir -L/usr/lib -l$lib -lm" ); }; $F77config{Generic}{G77}{Trail_} = 1; $F77config{Generic}{G77}{Compiler} = find_in_path('g77','f77','fort77'); $F77config{Generic}{G77}{Cflags} = '-O'; $F77config{Generic}{DEFAULT} = 'G77'; $F77config{Generic}{F2c} = $F77config{Generic}{G77}; ### cygwin ### #"-lg2c -lm"; # needed this on my cygwin system to get things working properly sub getcyglink { return join ' ', map {my $lp = `g77 -print-file-name=lib$_.a`; $lp =~ s|/[^/]+$||; $lp =~ s|L([a-z,A-Z]):|L//$1|g; "-L$lp -l$_"} qw/g2c m/; } $F77config{Cygwin}{G77}{Trail_} = 1; $F77config{Cygwin}{G77}{Compiler} = 'g77'; $F77config{Cygwin}{G77}{Cflags} = '-O'; $F77config{Cygwin}{G77}{Link} = \&getcyglink; $F77config{Cygwin}{DEFAULT} = 'G77'; ### Linux ### $F77config{Linux}{G77} = $F77config{Generic}{G77}; $F77config{Linux}{F2c} = $F77config{Generic}{G77}; $F77config{Linux}{DEFAULT} = 'G77'; ### DEC OSF/1 ### $F77config{Dec_osf}{F77}{Link} = "-L/usr/lib -lUfor -lfor -lFutil -lm -lots -lc"; $F77config{Dec_osf}{F77}{Trail_} = 1; $F77config{Dec_osf}{F77}{Compiler} = 'f77'; $F77config{Dec_osf}{F77}{Cflags} = '-O'; $F77config{Dec_osf}{DEFAULT} = 'F77'; ### HP/UX ### $F77config{Hpux}{F77}{Link} = "-L/usr/lib -lcl -lm"; $F77config{Hpux}{F77}{Trail_} = 0; $F77config{Hpux}{F77}{Compiler} = 'f77'; $F77config{Hpux}{F77}{Cflags} = '-O'; $F77config{Hpux}{DEFAULT} = 'F77'; ### IRIX ### # From: Ovidiu Toader # For an SGI running IRIX 6.4 or higher (probably lower than 6.4 also) # there is a new abi, -64, which produces 64 bit executables. This is no # longer an experimental feature and I am using it exclusively without any # problem. The code below is what I use instead of original IRIX section # in the ExtUtils::F77 package. It adds the -64 flag and it is supposed to # provide the same functionality as the old code for a non -64 abi. { my ($cflags,$mips,$default_abi,$abi,$mips_dir,$libs); $cflags = $Config{cc}; ($mips) = ($cflags =~ /(-mips\d)/g); $mips = "" if ! defined($mips); $mips_dir = $mips;$mips_dir =~ s/-//g; $default_abi = $Config{osvers} >= 6.4 ? "-n32" : "-o32"; GET_ABI: { $abi = "-o32",last GET_ABI if $cflags =~ /-o32/; $abi = "-n32",last GET_ABI if $cflags =~ /-n32/; $abi = "-64",last GET_ABI if $cflags =~ /-64/; $abi = $default_abi; } if ( $abi eq "-64" ){ $libs = ( (-r "/usr/lib64/$mips_dir") && (-d _) && (-x _) ) ? "-L/usr/lib64/$mips_dir" : ""; $libs .= " -L/usr/lib64 -lftn -lm"; } if ( $abi eq "-n32" ){ $libs = ( (-r "/usr/lib32/$mips_dir") && (-d _) && (-x _) ) ? "-L/usr/lib32/$mips_dir" : ""; $libs .= " -L/usr/lib32 -lftn -lm"; } if ( $abi eq "-o32" ){ $libs = "-L/usr/lib -lF77 -lI77 -lU77 -lisam -lm"; } $F77config{Irix}{F77}{Cflags} = "$abi $mips"; $F77config{Irix}{F77}{Link} = "$libs"; $F77config{Irix}{F77}{Trail_} = 1; $F77config{Irix}{F77}{Compiler} = "f77 $abi"; $F77config{Irix}{DEFAULT} = 'F77'; } ### AIX ### $F77config{Aix}{F77}{Link} = "-L/usr/lib -lxlf90 -lxlf -lc -lm"; $F77config{Aix}{F77}{Trail_} = 0; $F77config{Aix}{DEFAULT} = 'F77'; ### FreeBSD ### $F77config{Freebsd}{F77}{Trail_} = 1; $F77config{Freebsd}{F77}{Link} = '-L/usr/lib -lf2c -lm'; $F77config{Freebsd}{DEFAULT} = 'F77'; ### VMS ### $F77config{VMS}{Fortran}{Trail_} = 0; $F77config{VMS}{Fortran}{Link} = ''; $F77config{VMS}{DEFAULT} = 'Fortran'; $F77config{VMS}{Fortran}{Compiler} = 'Fortran'; ############ End of database is here ############ =head1 SYNOPSIS use ExtUtils::F77; # Automatic guess use ExtUtils::F77 qw(sunos); # Specify system use ExtUtils::F77 qw(linux g77); # Specify system and compiler $fortranlibs = ExtUtils::F77->runtime; =cut # Package variables $Runtime = "-LSNAFU -lwontwork"; $RuntimeOK = 0; $Trail_ = 1; $Pkg = ""; $Compiler = ""; $Cflags = ""; sub get; # See below # All the figuring out occurs during import - this is because # a lot of the answers depend on a lot of the guesswork. sub import { $Pkg = shift; my $system = ucfirst(shift); # Set package variables my $compiler = ucfirst(shift); # Guesses if system/compiler not specified. $system = ucfirst $Config{'osname'} unless $system; $system = 'Cygwin' if $system =~ /Cygwin/; $compiler = get $F77config{$system}{DEFAULT} unless $compiler; print "$Pkg: Using system=$system compiler=$compiler\n"; if (defined($ENV{F77LIBS})) { print "Overriding Fortran libs from value of enviroment variable F77LIBS = $ENV{F77LIBS}\n"; $Runtime = $ENV{F77LIBS}; } else { # Try this combination if (defined( $F77config{$system} )){ my $flibs = get ($F77config{$system}{$compiler}{Link}); if ($flibs ne "") { $Runtime = $flibs . gcclibs(); $Runtime =~ s|L([a-z,A-Z]):|L//$1|g if $^O =~ /cygwin/i; print "Runtime: $Runtime\n"; $ok = 1; $ok = validate_libs($Runtime) if $flibs ne ""; } }else { $Runtime = $ok = ""; } # If it doesn't work try Generic + GNU77 unless (defined($Runtime) && $ok) { print <<"EOD"; $Pkg: Unable to guess and/or validate system/compiler configuration $Pkg: Will try system=Generic Compiler=G77 EOD $system = "Generic"; $compiler = "G77"; my $flibs = get ($F77config{$system}{$compiler}{Link}); $Runtime = $flibs. gcclibs(); $ok = validate_libs($Runtime) if $flibs ne ""; print "$Pkg: Well that didn't appear to validate. Well I will try it anyway.\n" unless $Runtime && $ok; } $RuntimeOK = $ok; } # Not overriding # Now get the misc info for the methods. if (defined( $F77config{$system}{$compiler}{Trail_} )){ $Trail_ = get $F77config{$system}{$compiler}{Trail_}; } else{ print << "EOD"; $Pkg: There does not appear to be any configuration info about $Pkg: names with trailing underscores for system $system. Will assume $Pkg: F77 names have trailing underscores. EOD $Trail_ = 1; } if (defined( $F77config{$system}{$compiler}{Compiler} )) { $Compiler = $F77config{$system}{$compiler}{Compiler}; } else { print << "EOD"; $Pkg: There does not appear to be any configuration info about $Pkg: the F77 compiler name. Will assume 'f77'. EOD $Compiler = 'f77'; } print "$Pkg: Compiler: $Compiler\n"; if (defined( $F77config{$system}{$compiler}{Cflags} )) { $Cflags = $F77config{$system}{$compiler}{Cflags}; } else { print << "EOD"; $Pkg: There does not appear to be any configuration info about $Pkg: the options for the F77 compiler. Will assume none $Pkg: necessary. EOD $Cflags = ''; } print "$Pkg: Cflags: $Cflags\n"; } # End of import () =head1 METHODS The following methods are provided: =over 4 =item * B Returns a list of F77 runtime libraries. $fortranlibs = ExtUtils::F77->runtime; =item * B Returns TRUE only if runtime libraries have been found successfully. =item * B Returns true if F77 names have trailing underscores. =item * B Returns command to execute the compiler (e.g. 'f77'). =item * B Returns compiler flags. =item * B Test to see if compiler actually works. =back More methods will probably be added in the future. =cut sub runtime { return $Runtime; } sub runtimeok { return $RuntimeOK; } sub trail_ { return $Trail_; } sub compiler { return $Compiler; } sub cflags { return $Cflags; } ### Minor internal utility routines ### # Get hash entry, evaluating code references sub get { ref($_[0]) eq "CODE" ? &{$_[0]} : $_[0] }; # Test if any files exist matching glob sub any_exists { my @glob = glob(shift); return scalar(@glob); } # Find highest version number of SCN.N(.N) directories # (Nasty SunOS/Solaris naming scheme for F77 libs] sub find_highest_SC { print "$Pkg: Scanning for $_[0]\n"; my @glob = glob(shift); my %n=(); for (@glob) { #print "Found $_\n"; if ( m|/SC(\d)\.(\d)/?.*$| ) { $n{$_} = $1 *100 + $2 * 10; } if ( m|/SC(\d)\.(\d)\.(\d)/?.*$| ) { $n{$_} = $1 *100 + $2 * 10 + $3; } } my @sorted_dirs = sort {$n{$a} <=> $n{$b}} @glob; return pop @sorted_dirs; # Highest N } # Validate a string of form "-Ldir -lfoo -lbar" sub validate_libs { print "$Pkg: Validating $_[0] "; my @args = split(' ',shift()); my $pat; my $ret = 1; # Create list of directories to search (with common defaults) my @path = (); for (@args, "/usr/lib", "/lib") { push @path, $1 if /^-L(.+)$/ && -d $1; } # Search directories for (@args) { next if /^-L/; next if $_ eq "-lm"; # Ignore this common guy if (/^-l(.+)$/) { $pat = join(" ", map {$_."/lib".$1.".*"} @path); # Join dirs + file #print "Checking for $pat\n"; unless (any_exists($pat)) { print "\n$Pkg: Unable to find library $_" ; $ret = 0; } } } print $ret ? "[ok]\n" : "\n"; return $ret; } sub testcompiler { my $file = "/tmp/testf77$$"; my $ret; open(OUT,">$file.f"); print OUT " print *, 'Hello World'\n"; print OUT " end\n"; close(OUT); print "Compiling the test Fortran program...\n"; system "$Compiler $Cflags $file.f -o ${file}_exe"; print "Executing the test program...\n"; if (`${file}_exe` ne " Hello World\n") { print "Test of Fortran Compiler FAILED. \n"; print "Do not know how to compile Fortran on your system\n"; $ret=0; } else{ print "Congratulations you seem to have a working f77!\n"; $ret=1; } unlink("${file}_exe"); unlink("$file.f"); unlink("$file.o") if -e "$file.o"; return $ret; }; # Return gcc libs (e.g. -L/usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3_U1/2.7.0 -lgcc) sub gcclibs { my $isgcc = $Config{'cc'} eq 'gcc'; if (!$isgcc && $^O ne 'VMS') { print "Checking for gcc in disguise:\n"; $isgcc = 1 if $Config{gccversion}; my $string; if ($isgcc) { $string = "Compiler is gcc version $Config{gccversion}"; $string .= "\n" unless $string =~ /\n$/; } else { $string = "Not gcc\n"; } print $string; } if ($isgcc) { $gccdir = `gcc -print-libgcc-file-name`; chomp $gccdir; $gccdir =~ s/\/libgcc.a//; return " -L$gccdir -lgcc"; }else{ return ""; } } # Try and find a program in the users PATH sub find_in_path { my @names = @_; my @path = split(":",$ENV{PATH}); my ($name,$dir); for $name (@names) { for $dir (@path) { if (-x $dir."/$name") { print "Found compiler $name\n"; return $name; } } } return '' if $^O eq 'VMS'; die "Unable to find a fortran compiler using names: ".join(" ", at names); } =head1 AUTHOR Karl Glazebrook (kgb at aaoepp.aao.GOV.AU). =cut 1; # Return true ________________________________________________________________________ Dr.Thomas HANSEN, Science/Diffrac/D20, Institut Laue-Langevin (ILL4-100) BP 156, 38042 GRENOBLE Cedex 9, FRANCE, hansen at ill.fr, http://www.ill.fr Phone (+33/0)4.76.20-70.44 Fax:(~)4.76.48.39.06 Home:(~)4.76.18.05.53 From kristian.nielsen at risoe.dk Wed Sep 8 10:18:39 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: Wed, 08 Sep 1999 10:18:39 +0200 Subject: PGPLOT - no success under LinuxPPC In-Reply-To: (hansen@ill.fr) Message-ID: <01JFQ2ZCV3KQ9KP3YK@risoe.dk> > Date: Fri, 03 Sep 1999 09:50:05 +0200 > From: hansen at ill.fr (Thomas Hansen) > I managed to install McSTAS-1.1 under LinuxPPC on a Macintosh PowerBook G3, > as well as the installation on MacOS 8.6 using CodeWarrior. However, use of > gscan, mcplot and mcdisplay only is possible under Linux/Unix ... and there > there I encountered one problem (up to now ...) during the installation of > PGPERL. I post here the hopefully helpfull reply to my Linux-specific > problem. Hm, it is no absolutely clear to me if you did get pgplot and pgperl to work in the end -- I guess not? Anyway, I just checked the web site for Debian GNU/Linux. Debian includes working pgplot/pgperl out of the box, and Debian is available for PPC (as stable beta). HOWEVER, Debian PPC Linux does NOT include pgperl and pgplot, sadly. I wonder if there is some fundamental problem, though it does not appear likely. Anyway, I am getting really sorry about my choice of pgplot and pgperl for McStas, a LOT of people have experienced problems. Especially on Linux, I suspect because of poor Fortran support. At Ris? we use Debian, and since pgplot/pgperl worked flawlessly there, I assumed other linuxes would be similar. Apparently that is not so, not to mention the Windows situation. Anyone knows a good replacement for pgplot? Or failing that, anyone have tips for pgplot and pgperl on (non-Debian) Linux? - Kristian. From pha70 at phys.keele.ac.uk Wed Sep 8 20:00:10 1999 From: pha70 at phys.keele.ac.uk (Mark Hagen) Date: Wed, 08 Sep 1999 11:00:10 -0700 Subject: One satisfied McStas/pgplot customer :) Message-ID: <01JFQ7M3C7L09KP9NX@risoe.dk> Hi Kristian, Long time no see ! I am a bit surprised by your comment that a lot of people have been having trouble with pgplot under Linux. I use Slackware and Red Hat insetad of Debian and have never had any problems either with McStas or pgplot under either. True I haven't tried the McStas plotting, all my pgplot is for my own Fortran programmes. I've had less trouble with pgplot under Linux than under Solaris (Sun) or Dec-Unix. The only subtlety is that pgplot is not F90 compatible, although there are only 3 changes to the pgplot source to solve that problem. I use both g77 and the NAG F90 for Linux. As for MS-Windows. If one has DVF (Digital Visual Fortran) then one can again trivially produce the Fortran pgplot library for Windows. Again I use it all the Fortran pgplot library all the time. I have never thought about the pgplot C-library for Windows, although if one is careful can't one call the Fortran routines from C ? Again, although I rarely use it on Windows, I had no trouble producing the McStas with MS Visual C++ console app from the code you provided on the web site. Thus while others may be complaining about your choice of pgplot, you have at least one satisfied customer ! :) Cheers, Mark P.S. Hope to see you again some time, not sure when, but some time. Kristian Nielsen wrote: > > > Date: Fri, 03 Sep 1999 09:50:05 +0200 > > From: hansen at ill.fr (Thomas Hansen) > > > I managed to install McSTAS-1.1 under LinuxPPC on a Macintosh PowerBook G3, > > as well as the installation on MacOS 8.6 using CodeWarrior. However, use of > > gscan, mcplot and mcdisplay only is possible under Linux/Unix ... and there > > there I encountered one problem (up to now ...) during the installation of > > PGPERL. I post here the hopefully helpfull reply to my Linux-specific > > problem. > > Hm, it is no absolutely clear to me if you did get pgplot and pgperl to > work in the end -- I guess not? Anyway, I just checked the web site for > Debian GNU/Linux. Debian includes working pgplot/pgperl out of the box, > and Debian is available for PPC (as stable beta). HOWEVER, Debian PPC > Linux does NOT include pgperl and pgplot, sadly. I wonder if there is > some fundamental problem, though it does not appear likely. > > Anyway, I am getting really sorry about my choice of pgplot and pgperl > for McStas, a LOT of people have experienced problems. Especially on > Linux, I suspect because of poor Fortran support. At Ris? we use Debian, > and since pgplot/pgperl worked flawlessly there, I assumed other linuxes > would be similar. Apparently that is not so, not to mention the Windows > situation. > > Anyone knows a good replacement for pgplot? Or failing that, anyone have > tips for pgplot and pgperl on (non-Debian) Linux? > > - Kristian. From pha70 at phys.keele.ac.uk Wed Sep 8 20:00:10 1999 From: pha70 at phys.keele.ac.uk (Mark Hagen) Date: Wed, 08 Sep 1999 11:00:10 -0700 Subject: One satisfied McStas/pgplot customer :) References: <01JFQ2ZCV3KQ9KP3YK@risoe.dk> Message-ID: <01JFQ7M902E89KP9NX@risoe.dk> Hi Kristian, Long time no see ! I am a bit surprised by your comment that a lot of people have been having trouble with pgplot under Linux. I use Slackware and Red Hat insetad of Debian and have never had any problems either with McStas or pgplot under either. True I haven't tried the McStas plotting, all my pgplot is for my own Fortran programmes. I've had less trouble with pgplot under Linux than under Solaris (Sun) or Dec-Unix. The only subtlety is that pgplot is not F90 compatible, although there are only 3 changes to the pgplot source to solve that problem. I use both g77 and the NAG F90 for Linux. As for MS-Windows. If one has DVF (Digital Visual Fortran) then one can again trivially produce the Fortran pgplot library for Windows. Again I use it all the Fortran pgplot library all the time. I have never thought about the pgplot C-library for Windows, although if one is careful can't one call the Fortran routines from C ? Again, although I rarely use it on Windows, I had no trouble producing the McStas with MS Visual C++ console app from the code you provided on the web site. Thus while others may be complaining about your choice of pgplot, you have at least one satisfied customer ! :) Cheers, Mark P.S. Hope to see you again some time, not sure when, but some time. Kristian Nielsen wrote: > > > Date: Fri, 03 Sep 1999 09:50:05 +0200 > > From: hansen at ill.fr (Thomas Hansen) > > > I managed to install McSTAS-1.1 under LinuxPPC on a Macintosh PowerBook G3, > > as well as the installation on MacOS 8.6 using CodeWarrior. However, use of > > gscan, mcplot and mcdisplay only is possible under Linux/Unix ... and there > > there I encountered one problem (up to now ...) during the installation of > > PGPERL. I post here the hopefully helpfull reply to my Linux-specific > > problem. > > Hm, it is no absolutely clear to me if you did get pgplot and pgperl to > work in the end -- I guess not? Anyway, I just checked the web site for > Debian GNU/Linux. Debian includes working pgplot/pgperl out of the box, > and Debian is available for PPC (as stable beta). HOWEVER, Debian PPC > Linux does NOT include pgperl and pgplot, sadly. I wonder if there is > some fundamental problem, though it does not appear likely. > > Anyway, I am getting really sorry about my choice of pgplot and pgperl > for McStas, a LOT of people have experienced problems. Especially on > Linux, I suspect because of poor Fortran support. At Ris? we use Debian, > and since pgplot/pgperl worked flawlessly there, I assumed other linuxes > would be similar. Apparently that is not so, not to mention the Windows > situation. > > Anyone knows a good replacement for pgplot? Or failing that, anyone have > tips for pgplot and pgperl on (non-Debian) Linux? > > - Kristian. From kristian.nielsen at risoe.dk Fri Sep 10 13:45:49 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: Fri, 10 Sep 1999 13:45:49 +0200 Subject: ECNS'99 and McStas references Message-ID: <01JFT2SVJITC9KPC8N@risoe.dk> Dear McStas users, While I was myself sadly not present at the recent ECNS'99 conference in Budapest, Kim Lefmann told me that there were several presentations mentioning McStas in addition to his McStas poster presentation. This got me thinking that it would be nice to maintain a list of papers that reference McStas; such a list would be useful to impress our current sponsors and to improve the possibilities for future funding. So, if you have a paper that references McStas, please send me a reference for such a list (notes about as yet unpublished work is also welcome, of course). I will make the list available on the web page. Kim Lefmann also told me that some papers referenced McStas using the web page address. Since this summer we have a better publication to reference, the McStas paper that was published in Neutron News: K. Lefmann and K. Nielsen, Neutron News, 10/3, 20 (1999) Regards, - Kristian. -- Kristian Nielsen kristian.nielsen at risoe.dk Ris? National Laboratory Condensed Matter Physics and Chemistry Department Tel. +45 4677 5515 Fax +45 4677 4790 From kristian.nielsen at risoe.dk Wed Sep 1 08:49:06 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 1 Sep 1999 08:49:06 +0200 Subject: Mcstas In-Reply-To: <199908251839.NAA18982@black.pns.anl.gov> (eiverson@anl.gov) Message-ID: > Date: Wed, 25 Aug 1999 13:39:08 -0400 > From: eiverson at anl.gov > Dear Kristian, > Unfortunately, I still cannot get perl-PGPLOT to successfully compile. It > will "make" without any errors, but "make test" fails completely. First, sorry for answering so late, things have been busy here due to the upcoming ECNS (even though I am not going myself). > Can't load './blib/arch/auto/PGPLOT/PGPLOT.so' for module PGPLOT: ./blib/arch/aut > o/PGPLOT/PGPLOT.so: undefined symbol: fstat at /usr/lib/perl5/i386-linux/5.00404/ > DynaLoader.pm line 166. Sigh. Apparently some library problem. It is difficult to say much about it without further information. Would it be possible for you to give me a temporary account on the machine, so that I can examine the problem directly? If you want to try yourself, the "HELP" file in the pgperl source seems to give some hints. In my experience, the first place to look is in compiler and library versions for the fortran stuff. The problem with pgperl/pgplot is that it is linking THREE languages - perl, fortran, and C. This has turned out to cause a lot of problems, especially on Linux where fortran support seems somewhat weak. Pgplot with the perl interface is actually quite nice, but if users cannot install it then that does not help much. (You don't happen to know of a good alternative to pgplot for scientific plotting?) - Kristian. From kristian.nielsen at risoe.dk Wed Sep 1 14:41:08 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 1 Sep 1999 14:41:08 +0200 Subject: MSCAT etc In-Reply-To: <37C5A0CB.38BBD62B@nist.gov> (message from John Copley on Thu, 26 Aug 1999 16:17:15 -0400) Message-ID: > Date: Thu, 26 Aug 1999 16:17:15 -0400 > From: John Copley > Kristian > Regarding the optical filter calculation, many thanks! I would indeed > appreciate more information, and I'm also wondering if you could do a > few more runs? One of these days I'd like to get familiar with McStas > You say the transmission for 0.5 AA neutrons is about 2e-5. What is it > for 5 A neutrons? How much work would it be to calculate the > transmission in steps of 0.1 AA say from 0.1 to 5 AA, using (i) the > reflectivity graphs that I sent you and (ii) idealized reflectivity > graphs with R=1 for Q<=0.265 (sides), R=1 for Q<=0.43 (top/bottom), 0 > otherwise? Ok, I found a little time to do a few more runs. I actually changed my instrument definition somewhat. In your fax you mention three guide sections, the first one immediately after the source. I realized that the first 12 meters are just a 60mm channel with no mirror, right? Then comes the focusing 6.9m guide and the straight 26m guide. This gives the 4.4AA leveling of the transmission, whereas with my first guess the transmission does not level off until about 40AA. Well, the single most difficult part in simulations is to get the details right, in my experience. I made the runs with lambda from 0.1AA to 5AA for two reflectivities: either sharp cut-off at the critical angle, or the rough analytical approximation to the measured curves you sent me. I also did the same runs in the interval 0.1AA to 1.1AA (for detail at high wavelength). If you want, you can send me the actual measured reflectivity data, and I can put that into the simulation. I put up some plots for you on our web site, at http://neutron.risoe.dk/mcstas/support/copley/ Basically, they show that transmission vanishes at about 1AA, with small traces of shorter wavelength. For the idealized reflectivity, the transmission completely vanishes at about 0.6AA, whereas for my crude approximations to your measured reflectivity, neutrons down to about 0.3AA are transmitted. I wonder how you interpret these results? Of course, just ask if you need any further information. > In terms of running McStas here, Collin Broholm has a student who is > running it. He could probably help me if needed. I also put the files I used to produce the simulation on the server, in case you want to look at it. - Kristian. From horn at ill.fr Mon Sep 6 15:24:24 1999 From: horn at ill.fr (Pay H. Schulze Horn) Date: Mon, 06 Sep 1999 15:24:24 +0200 Subject: McStas References: <01JF7Y4FJTL89JEAIX@risoe.dk> Message-ID: <37D3C088.41C6@ill.fr> After a more a week now here is the Component, which gives the Divergence in relation to the energy out. Change it for distribution like you want. The other monitor, which gives out everything, has small syntax-error which i cant't find. Are there any know problems with the ROTATED-command? Also as an attachment you can find an instrument-definition with a small component-definition, which are reproducing a thing i can't understand. After the compiling with the shell command: mcstas t9.instr && gcc -O -o t9 t9.c -lm && t9 -n 3 I had this output: Phi:4.19437 theta0:-60 Phi:4.19437 theta0:-60 Phi:4.19437 theta0:-60 Why do i have a value of 4.19 degree as an divergence ? Why not 2.1 ? Why is it nearly the double value i was awaiting ? I have installed the version:"McStas version 1.1, March 31, 1999" on a Silicon graphics Iris with Irix 5.3 and gcc 2.7.2.1 . Thanks Pay P.S. Please forget the question for the monochromator component which includes multiple scattering. -------------- next part -------------- DEFINE COMPONENT Angle_test DEFINITION PARAMETERS () SETTING PARAMETERS () STATE PARAMETERS (x,y,z,vx,vy,vz,t,s1,s2,p) DECLARE %{ %} TRACE %{ double theta0, phi; PROP_Z0; theta0 = atan2(vx,vz); phi = atan2(vy,vz); printf("\nphi:%g theta0:%g\n",RAD2DEG*phi,RAD2DEG*theta0); %} END -------------- next part -------------- DEFINE INSTRUMENT t9() DECLARE %{ %} INITIALIZE %{ %} TRACE COMPONENT a1 = Arm() AT (0,0,0) ABSOLUTE ROTATED (0,0,0) ABSOLUTE COMPONENT s = Source_div( width = 0.01, height = 0.01, hdiv=0, vdiv=0, E0 = e_zero, dE = 0) AT (0,0,0) RELATIVE a1 ROTATED (0,0,0) RELATIVE a1 COMPONENT a2=Arm() AT (0,0,1) RELATIVE a1 ROTATED (2.1,60,0) RELATIVE a1 COMPONENT moni2=Angle_test() AT (0,0,0) RELATIVE a2 ROTATED (0,0,0) RELATIVE a2 END From kristian.nielsen at risoe.dk Tue Sep 7 15:45:40 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 7 Sep 1999 15:45:40 +0200 Subject: McStas In-Reply-To: <37D3C088.41C6@ill.fr> (horn@ill.fr) Message-ID: > Date: Mon, 06 Sep 1999 15:24:24 +0200 > From: "Pay H. Schulze Horn" > After a more a week now here is the Component, which gives the > Divergence in relation to the energy > out. Change it for distribution like you want. Ok, thanks, I will put it on the web page and probably later in the distribution. > The other monitor, which gives out everything, has small syntax-error > which i cant't find. Hm, if you want you can send it to me and I will have a look at it. > Are there any know problems with the ROTATED-command? > I had this output: > Phi:4.19437 theta0:-60 > Why do i have a value of 4.19 degree as an divergence ? > > Why not 2.1 ? > > Why is it nearly the double value i was awaiting ? > COMPONENT a2=Arm() > AT (0,0,1) RELATIVE a1 > ROTATED (2.1,60,0) RELATIVE a1 I think you are being confused by the double rotation here. What happens is that the axes of a2 are obtained from the axes of a1 as follows: First rotate 2,1 degrees around the X axis of a1. Then rotate 60 degrees around the _new_ Y axis. Note that order is important here; rotation in the opposite order (first around Y, then around X) would be different. You should not expect a value for phi of 2.1. For example, if the second rotation is set to 90 degrees, phi will also be 90 degrees (the neutron beam is then perpendicular to the Z axis of a2). At a rotation of 180 degrees, phi would be 180 - 2.1. Clearly what you meant was to set up the coordinate system of a2 such that the Z axis pointed in the direction (tan 60, tan 2.1, 1) in the coordinate system of a1 (but where would X and Y then point?). I am not sure that there is an easy way to do that in McStas currently, but I will think about it when I start adding other ways to specify rotations. The current way is somewhat stupid anyway, since it is almost never useful to specify multiple rotations (because the outcome is really hard to understand). I hope this helps, otherwise just ask again. - Kristian. From S.I.Campbell at rl.ac.uk Tue Sep 14 12:40:56 1999 From: S.I.Campbell at rl.ac.uk (S.I.Campbell at rl.ac.uk) Date: Tue, 14 Sep 1999 11:40:56 +0100 Subject: No subject Message-ID: <37CAC51AC5C1D211966100A0C9ED000A297BAA@exchange07.rl.ac.uk> Dear Dr Nielsen, Sorry to bother you, I am trying to start to use McStas. I can get the simulation to run with no problems, but I cannot seem to get the mcdisplay routine to run. The error message that I get is: Can't locate PGPLOT.pm in @INC (@INC contains: /usr/lib/perl5/i386-linux/5.00405 /usr/lib/perl5 /usr/lib/perl5/site_perl/i386-linux /usr/lib/perl5/site_perl .) at /home/sic01/bin/mcdisplay line 6. BEGIN failed--compilation aborted at /home/sic01/bin/mcdisplay line 6. Am I doing something stupid ? Regards Stuart Dr Stuart Campbell ISIS Facility, CLRC Rutherford Appleton Laboratory Chilton, Didcot , OX11 0QX, UK Tel : +44 (0) 1235 446245 Fax : +44 (0) 1235 445720 WWW : http://www.isis.rl.ac.uk/ Email : S.I.Campbell at rl.ac.uk From kristian.nielsen at risoe.dk Wed Sep 15 10:19:37 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 15 Sep 1999 10:19:37 +0200 Subject: In-Reply-To: <37CAC51AC5C1D211966100A0C9ED000A297BAA@exchange07.rl.ac.uk> (S.I.Campbell@rl.ac.uk) Message-ID: > Content-return: allowed > Date: Tue, 14 Sep 1999 11:40:56 +0100 > Sorry to bother you, I am trying to start to use McStas. I can get the > simulation to run with no problems, but I cannot seem to get the mcdisplay > routine to run. The error message that I get is: > > Can't locate PGPLOT.pm in @INC (@INC contains: > /usr/lib/perl5/i386-linux/5.00405 > /usr/lib/perl5 /usr/lib/perl5/site_perl/i386-linux /usr/lib/perl5/site_perl > .) > at /home/sic01/bin/mcdisplay line 6. > BEGIN failed--compilation aborted at /home/sic01/bin/mcdisplay line 6. To get mcdisplay to work, you need to install a couple of libraries first. These are pgplot and pgperl. You can download the libraries from the McStas web page: http://neutron.risoe.dk/mcstas/download.html Let me know if you have any problems installing it, and I will try to help. - Kristian. From kristian.nielsen at risoe.dk Thu Sep 16 11:55:40 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 16 Sep 1999 11:55:40 +0200 Subject: PGPERL and PGPLOT In-Reply-To: <37DFB694.9CCE180E@ill.fr> (message from Farhi on Wed, 15 Sep 1999 17:09:08 +0200) Message-ID: > Date: Wed, 15 Sep 1999 17:09:08 +0200 > From: Farhi > Hello Kristian, >

Concerning the PGPERL problem, I could install sucessfully the packages > pgplot 5.2, and PerlDL, but PGPerl doesn't pass the test phase. Well, I would really like to aolve this problem; a lot of our users experience this. Could you give me an account on the machine on which you have the problems so that I could check out the problem directly? I already have an account on grill (or whatever) to get through the ILL firewall, and I should be able to do without root access in case that would be a problem. I did solve a similar problem on Suse Linux using an account in Germany, and it would be really nice to have this working on RedHat also. Regarding the 4D ellipsoid, I was not sure if you were refering to the production of the simulation data or the visualization? The simulation is described briefly in our ECNS paper, of which I can send you a copy if you like. The visualization is produced using PDL's 3D graphics primitives. Basically, we do a russian roulette to eliminate the neutron weight from the Monte Carlo simulation and plot the points as a function of Qx, Qy, and omega. I am currently in Oxford on a vt300 terminal and so I do not have easy access to the graphics of McStas, however I will get back to you when I return late next week. I would be happy to send you the code that produced the graphics Kim showed you; also this code will likely be included in the next release of McStas. - Kristian. From farhi at ill.fr Wed Sep 15 17:09:08 1999 From: farhi at ill.fr (Farhi) Date: Wed, 15 Sep 1999 17:09:08 +0200 Subject: PGPERL and PGPLOT Message-ID: <37DFB694.9CCE180E@ill.fr> An HTML attachment was scrubbed... URL: From farhi at ill.fr Wed Sep 15 17:19:15 1999 From: farhi at ill.fr (Farhi) Date: Wed, 15 Sep 1999 17:19:15 +0200 Subject: ECNS'99 and McStas references References: <01JFT2SVJITC9KPC8N@risoe.dk> Message-ID: <37DFB8F3.99540580@ill.fr> An HTML attachment was scrubbed... URL: From kristian.nielsen at risoe.dk Thu Sep 16 14:02:17 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 16 Sep 1999 14:02:17 +0200 Subject: 4D ellipsoid In-Reply-To: <37E0D38A.9EE2BF1C@ill.fr> (message from Farhi on Thu, 16 Sep 1999 13:24:58 +0200) Message-ID: > Date: Thu, 16 Sep 1999 13:24:58 +0200 > From: Farhi > I mean production of data. In fact it is just an inquiery of the (k,w) > distribution around target (k,w), and possibly, a simple modelisation of > this as a gaussian distribution (width and main ellipsoid axes)) Well, what we do to produce the 4-D resolution ellipsoid is to define an inelastic scattering sample where S(Q,w) is a constant for all Q and omega within a predefined 4-D volume. The detector then records the initial and final k vector for every neutron that reach the detector, together with the neutron weight p for that event. The expected value of p (in the statistical sense) is then just the value of the resolution function at the (Q,w) computed from the ki and kf. You can then either do a 4D histogram of (qx,qy,qz,w), or (as we do) just store all the events in a file for later processing and visualization. >
Visualisation can be done through matlab, or whatever (PGPLOT ?) Yes (we use both Matlab and PDL). - Kristian. From kristian.nielsen at risoe.dk Fri Sep 17 16:46:03 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 17 Sep 1999 16:46:03 +0200 Subject: PGPERL and PGPLOT In-Reply-To: <37E0D1CC.151E518E@ill.fr> (message from Farhi on Thu, 16 Sep 1999 13:17:32 +0200) Message-ID: > Date: Thu, 16 Sep 1999 13:17:32 +0200 > From: Farhi >

You now have an account on macfarhi (my computer) which is Redhat Linux > for PPC I think I have fixed the PGPLOT problem (in the PGPLOT-2.14 directory). Basically, the problem is that the fortran library has been renamed from libf2c to libg2c in recent Linux distributins. I changed all instances of "f2c" to "g2c" in the makefile, and after that "make test" seemed to go better; I do not have an X display here in Oxford, though, so I cannot check myself! As to the points about resolution functions I am _very_ interested in discussing this further with you, but I cannot really work on it until I return to Ris? on September 24. I will get back to you then and send you what I have in the current development version of McStas. Meanwhile, I will think about the notes you send me. - Kristian. From kristian.nielsen at risoe.dk Tue Sep 21 21:12:29 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 21 Sep 1999 21:12:29 +0200 Subject: request help In-Reply-To: <001701bf0431$85c8c820$8f0a26ca@mipsa.ciae.ac.cn> (message from cgou on Tue, 21 Sep 1999 21:02:06 +0800) Message-ID: > Date: Tue, 21 Sep 1999 21:02:06 +0800 > From: cgou > member of Neutron scattering Lab. of China Institute of Atomic Energy, I am > charged with builing a new Triple-axis spectrometer, but I have no > experience of builing a new facility. So I hope someone who has time and > experience can help me. I am not sure that this is what you were looking for, but you might want to look at the McStas project. The web page is http://neutron.risoe.dk/mcstas/ This is a software package that allows you to simulate in great detail the performance of a neutron instrument, including triple-axis types. - Kristian. From cgou at iris.ciae.ac.cn Wed Sep 22 09:13:27 1999 From: cgou at iris.ciae.ac.cn (cgou) Date: Wed, 22 Sep 1999 15:13:27 +0800 Subject: about McStas Message-ID: <00a901bf04c9$ff58a3c0$8f0a26ca@mipsa.ciae.ac.cn> Dear Dr. Kristian, Thank you for your help. Today, I load your www page(http://neutron.risoe.dk/mcstas/)and download the soft package. I think it is very useful to me by reading your introduction. unfortunately, my computer's running environment is microsoft windows. Now, I can not extract the downloaded package by WINZIP.I don't know how you ADD it, and how i can extract it. Look forward to hearing from you Sun Kai ******************************************************************* Mail address: P.O.Box 275-30 Beijing P.R.China Email address: cgou at iris.ciae.ac.cn Telphone: 86-10-69357727 Fax: 86-10-69357787 From kristian.nielsen at risoe.dk Wed Sep 22 11:54:41 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 22 Sep 1999 11:54:41 +0200 Subject: about McStas In-Reply-To: <00a901bf04c9$ff58a3c0$8f0a26ca@mipsa.ciae.ac.cn> (message from cgou on Wed, 22 Sep 1999 15:13:27 +0800) Message-ID: > Date: Wed, 22 Sep 1999 15:13:27 +0800 > From: cgou > unfortunately, my computer's running environment is microsoft windows. Now, > I can not extract the downloaded package by WINZIP.I don't know how you ADD > it, and how i can extract it. Unfoirtunately, microsoft windows is not well supported in McStas currently, since it is not used for simulation at Risoe. You have basically two options: 1. Try to get McStas working properly in MS Windows. You should search the mailing list (http://neutron.risoe.dk/neutron-mc/) for messages about running McStas in Windows, and try to compile it. If you have any problems you can tell me and I will try to fix it. Unfortunately, I do not know winzip, but you could try to see if you can obtain a newer version perhaps? 2. Install Linux on your PC (this can be installed simultaneously with MS windows). We use Debian Linux (http://www.debian.org/) at Risoe, but other distributions should work equally well. - Kristian. -- Kristian Nielsen kristian.nielsen at risoe.dk Ris? National Laboratory Condensed Matter Physics and Chemistry Department Tel. +45 4677 5515 Fax +45 4677 4790 From cgou at iris.ciae.ac.cn Wed Sep 22 14:21:49 1999 From: cgou at iris.ciae.ac.cn (cgou) Date: Wed, 22 Sep 1999 20:21:49 +0800 Subject: =?iso-8859-1?B?u9i4tDogYWJvdXQgTWNTdGFz?= Message-ID: <001601bf04f5$131f9a00$8f0a26ca@mipsa.ciae.ac.cn> DearDr. Kristian, many thanks for your reply so quickly. OK, I'll try the second method you suggest me. I'll tell you when I have some problems or harvest. Hope can often contact you . Sun Kai -------------------------------------------- Mail address: P.O.Box 275-30 Beijing P.R.China Email address: cgou at iris.ciae.ac.cn Telphone: 86-10-69357727 Fax: 86-10-69357787 -----Original Message----- ??????: Kristian Nielsen ??????: cgou ????: 1999??9??23?? 9:40 ????: Re: about McStas > Date: Wed, 22 Sep 1999 15:13:27 +0800 > From: cgou > unfortunately, my computer's running environment is microsoft windows. Now, > I can not extract the downloaded package by WINZIP.I don't know how you ADD > it, and how i can extract it. Unfoirtunately, microsoft windows is not well supported in McStas currently, since it is not used for simulation at Risoe. You have basically two options: 1. Try to get McStas working properly in MS Windows. You should search the mailing list (http://neutron.risoe.dk/neutron-mc/) for messages about running McStas in Windows, and try to compile it. If you have any problems you can tell me and I will try to fix it. Unfortunately, I do not know winzip, but you could try to see if you can obtain a newer version perhaps? 2. Install Linux on your PC (this can be installed simultaneously with MS windows). We use Debian Linux (http://www.debian.org/) at Risoe, but other distributions should work equally well. - Kristian. -- Kristian Nielsen kristian.nielsen at risoe.dk Ris? National Laboratory Condensed Matter Physics and Chemistry Department Tel. +45 4677 5515 Fax +45 4677 4790 From kristian.nielsen at risoe.dk Wed Sep 22 16:58:09 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 22 Sep 1999 16:58:09 +0200 Subject: Optimizing McStas In-Reply-To: <37E8E009.FF857D75@ill.fr> (message from Farhi on Wed, 22 Sep 1999 15:56:25 +0200) Message-ID: > Date: Wed, 22 Sep 1999 15:56:25 +0200 > From: Farhi > I now have a (k,w) detector, that enables to plot 3D views of resolution > ellisoid and so (not only for 3 axis instruments). I've tested it, and > it gives the same results as ResTrax. It's really great and output file > is McStas compliant (same structure). I attach to this mail some files > showing how that stuff is working... That's great! I would definately like to include it in McStas (with your permission ...). I will put in some extensions to the DETECTOR_OUT stuff so that your component will work a little better. It seems that you are really getting up to speed on McStas, and it is quite unfortunate that I am in Oxford just now. I will send you my latest development of McStas as soon as I can, Monday at the latest. > I'm now working on McStas optimization. I think about having 2 > Please answer me as soon as possible about this and what you think (did > you started something equivalent already ?) Yes indeed, in fact I have a quite stable implementation already! This is in the form of a special source component Source_adapt; together with another component it performs adaptive importance sampling, just as you suggest. It works by building a 3D stair-case distribution, covering energy, horizontal position, and horizontal divergence. Initially the distribution is flat, but bins that result in useful neutrons are given a boost so that they will be selected more frequently, with lower weight. It really works quite well, and often results in a 10-fold decrease in running times. I will send you some code and documentation as soon as I can. > I've been talking with Jiri kulda about what does ResTrax do for > optimisation, but he is very cautious about giving such informations : > fear of beeing stolen without credits about ideas and sources. Anyway, > he does not know exactly how it works (Jan Saroun made that part), and > the method seems only applicable to 3-axis intruments (it starts from > the sample). Yes, there seem to be a bit of secrecy and protection surrounding ResTrax ... but actually I had a very good talk with Jan Sauron in March at the Ill, and I understand a bit of the optimizations. As you suggest, much of it is specific to triple-axis (for example it sets the energy at the monochromator, not at the source). - Kristian. From kristian.nielsen at risoe.dk Thu Sep 23 11:45:58 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 23 Sep 1999 11:45:58 +0200 Subject: Optimizing McStas In-Reply-To: <37E8F694.DCD2A6E8@ill.fr> (message from Farhi on Wed, 22 Sep 1999 17:32:36 +0200) Message-ID: > Date: Wed, 22 Sep 1999 17:32:36 +0200 > From: Farhi > I'm really looking forward to see how you did implement your optimisation. Good! The technique is actually quite complex, and I think that the code is useless without documentation. So this is a very good oppertunity to write this documentation that I have already put off for too long. I will write something up on the plane-trip home to Copenhagen tonight. > Can you put your adaptator in front of any component (in case user wants to > optimize flux on sample or final detector for instance). Yes (except that you put if after the component, and that it optimizes for all non-absorbed neutrons, but that can easily be extended). > What kind of source is it (rectangular, flat... ?). Yes. > I guess you included a minimum and maximum > weight, in order not to completely delete bad neutrons (who knows, they can > perhaps reach detector sometimes...). Yes, in fact there are several issues like this, and a lot of care is needed (the source component actually changes the adapted distribution for every neutron emitted). The user can specify a minimum fraction for neutrons. > You choosed to use a 3D matrix for sampling neutron characteristics. This is > ok, and enables to take correlated parameters into account. Right. The main application for the correllation is that of a source aiming at a monochromator; for given energy and position, only a single divergence will allow Bragg reflection. I choose not to correlate with the vertical because of a hunch that the resulting 5-D distribution would end up too large. The problem is not so much one of memory, but rather that the adaptive algorithm must have many samples in each bin in order to learn correctly, so the number of bins should be much smaller than the neutron history count. > I was rather thinking about : > 1- optimize x,y,vx,vy,vz and adapt p as required > 2- use separate 1D arrays for each state parameter (limits would be > determined in a 1st phase (say 5% of ncounts). This means that parameters are > considered completely independent. It's a choice, but it enables fast > sampling, and low memory cost for any parameter number to be optimized. I > think it's ok if the minimum weight for bad neutrons is not 0 (say 10 % of > bad neutrons are kept) > 3- a separate component from source and monitor. This would enable user to > select any kind of source, and optimize flux anywhere. > 4- bad neutrons would be ABSORBed, this would lead to a new source shot. I think this sounds quite interesting, and would nicely complement what I have. A special advantage is the fact that it is independent of the particular source component modelled. I would encourage you to go on with your idea, and I hope we can continue to discuss it! I am very open to extending the McStas core in case this is useful for your work. - Kristian. From farhi at ill.fr Thu Sep 16 13:24:58 1999 From: farhi at ill.fr (Farhi) Date: Thu, 16 Sep 1999 13:24:58 +0200 Subject: 4D ellipsoid References: <01JG1CPGS95K9KR5MF@risoe.dk> Message-ID: <37E0D38A.9EE2BF1C@ill.fr> An HTML attachment was scrubbed... URL: From farhi at ill.fr Thu Sep 16 14:04:06 1999 From: farhi at ill.fr (Farhi) Date: Thu, 16 Sep 1999 14:04:06 +0200 Subject: 4D ellipsoid References: <01JG1H4G5DNM9KS5ZJ@risoe.dk> Message-ID: <37E0DCB6.2AE1FAAF@ill.fr> An HTML attachment was scrubbed... URL: From farhi at ill.fr Fri Sep 17 10:58:34 1999 From: farhi at ill.fr (Farhi) Date: Fri, 17 Sep 1999 10:58:34 +0200 Subject: 4D ellipsoid References: <01JG1H4G5DNM9KS5ZJ@risoe.dk> Message-ID: <37E202BA.9E9D7C5E@ill.fr> An HTML attachment was scrubbed... URL: From farhi at ill.fr Fri Sep 17 11:29:43 1999 From: farhi at ill.fr (Farhi) Date: Fri, 17 Sep 1999 11:29:43 +0200 Subject: 4D ellipsoid References: <01JG1H4G5DNM9KS5ZJ@risoe.dk> Message-ID: <37E20A07.3D50AC7B@ill.fr> An HTML attachment was scrubbed... URL: From farhi at ill.fr Mon Sep 20 10:58:51 1999 From: farhi at ill.fr (Farhi) Date: Mon, 20 Sep 1999 10:58:51 +0200 Subject: PGPERL and PGPLOT References: <01JG314UW6L89KSLRM@risoe.dk> Message-ID: <37E5F74B.20DFD73F@ill.fr> An HTML attachment was scrubbed... URL: From farhi at ill.fr Wed Sep 22 17:32:36 1999 From: farhi at ill.fr (Farhi) Date: Wed, 22 Sep 1999 17:32:36 +0200 Subject: Optimizing McStas References: <01JGA10NB7QY9KSJEX@risoe.dk> Message-ID: <37E8F694.DCD2A6E8@ill.fr> Great ! please feel free to add kw_monitor to mcstas. I'm really looking forward to see how you did implement your optimisation. Can you put your adaptator in front of any component (in case user wants to optimize flux on sample or final detector for instance). What kind of source is it (rectangular, flat... ?). I guess you included a minimum and maximum weight, in order not to completely delete bad neutrons (who knows, they can perhaps reach detector sometimes...). You choosed to use a 3D matrix for sampling neutron characteristics. This is ok, and enables to take correlated parameters into account. I was rather thinking about : 1- optimize x,y,vx,vy,vz and adapt p as required 2- use separate 1D arrays for each state parameter (limits would be determined in a 1st phase (say 5% of ncounts). This means that parameters are considered completely independent. It's a choice, but it enables fast sampling, and low memory cost for any parameter number to be optimized. I think it's ok if the minimum weight for bad neutrons is not 0 (say 10 % of bad neutrons are kept) 3- a separate component from source and monitor. This would enable user to select any kind of source, and optimize flux anywhere. 4- bad neutrons would be ABSORBed, this would lead to a new source shot. Cheers again ! EF. -- Emmanuel FARHI, http://www.ill.fr/tas/people/Farhi.html \|/ ____ \|/ TAS-Group, Institut Laue-Langevin (ILL) Grenoble ~@-/ oO \-@~ Avenue des Martyrs, BP 156, 38042 Grenoble Cedex 9,France /_( \__/ )_\ Work :Tel (33/0) 4 76 20 71 83. Fax (33/0) 4 76 48 39 06 \__U_/ La Grande Arche, Chateau d'Uriage, 38410 Saint Martin d'Uriage 04 76 59 73 94 From farhi at ill.fr Thu Sep 23 11:54:44 1999 From: farhi at ill.fr (Farhi) Date: Thu, 23 Sep 1999 11:54:44 +0200 Subject: Optimizing McStas References: <01JGB4EXL8P89KUOPN@risoe.dk> Message-ID: <37E9F8E4.EEE77918@ill.fr> Hy Kristian It could be usefull as you said to have more than 1 optimizing procedure. So I will now continue with my 2 components. I guess I might feel the need to look at your solutions, if I find some problems. For the time beeing, I will do it all myself (perhaps with new ideas as I don't have any references in this subject ?!) Cheers. EF. -- Emmanuel FARHI, http://www.ill.fr/tas/people/Farhi.html \|/ ____ \|/ TAS-Group, Institut Laue-Langevin (ILL) Grenoble ~@-/ oO \-@~ Avenue des Martyrs, BP 156, 38042 Grenoble Cedex 9,France /_( \__/ )_\ Work :Tel (33/0) 4 76 20 71 83. Fax (33/0) 4 76 48 39 06 \__U_/ La Grande Arche, Chateau d'Uriage, 38410 Saint Martin d'Uriage 04 76 59 73 94 From kurt.clausen at risoe.dk Thu Sep 16 18:03:31 1999 From: kurt.clausen at risoe.dk (kurt.clausen at risoe.dk) Date: Thu, 16 Sep 1999 18:03:31 +0200 Subject: McStas Message-ID: <7F6BCF6B9307D311980C0090273C746C21D2AE@cssrv1> Dear Raphi Schorr McStas is not a transport code - it is a tool to build a MC simulation programme for a neutron spectrometer. The spectrometer is described as a sequential string of components. A component can be described analytically, using a ray tracing algoritm, using a MC description or even using transport code. The code is compact and meant to be executing fast because it is also ment to be used analysing data on-line. If you want to describe components with in McStas with transport code,then you will have to provide the code in C and the cross sections yourselves. Yours Kurt -----Original Message----- From: Raphael Schorr [mailto:raphael at jsbach.harvard.edu] Sent: 16. september 1999 16:20 To: kurt.clausen at risoe.dk Subject: Dear Dr. Clausen, I am working on a neutron physics experiment. I want to simulate cold neutrons and was told that McStas may be better suited for this than MCNP. Does McStas have cross sections for many elements? I could not manage to find them on the website. Thank you for your help. Regards, Raphi Schorr ---------------------------------------------------------------------------- --- Raphael Schorr Doyle Atomic Physics Lab at Harvard University schorr at jsbach.harvard.edu Phone: (617) 495-3386 Fax: (617) 496-5144 From kristian.nielsen at risoe.dk Mon Sep 27 12:58:27 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 27 Sep 1999 12:58:27 +0200 Subject: Optimizing McStas In-Reply-To: <37E9F8E4.EEE77918@ill.fr> (message from Farhi on Thu, 23 Sep 1999 11:54:44 +0200) Message-ID: Hi Emmanuel, Ok, I am now safely back from Oxford, so here is my latest development version of McStas. It includes - The resolution calculation stuff, with some documentation. - The adaptive importance sampling source Source_adapt.comp. There is a little bit of documentation in comments in the file and in postscript. You will need to install a new version of mcstas, called "mcstas-1.15 ALPHA". Since this is not of release-quality (yet!), I would like to know if you pass it on to others. The files you need are the new version itself: http://neutron.risoe.dk/mcstas/support/farhi/mcstas-1.15A.tar.gz The (sparse) documentation for the adaptive importance sampling (also see comments in Source_adapt.comp): http://neutron.risoe.dk/mcstas/support/farhi/adaptive.ps The documentation for the resolution calculation: http://neutron.risoe.dk/mcstas/support/farhi/resolution.ps I hope you can sort it out; ask me about anything that is unclear to you. I am very much looking forward to hearing more about your own results with resolution and optimization in McStas! - Kristian. From wildes at ill.fr Fri Sep 10 14:50:00 1999 From: wildes at ill.fr (Andrew Wildes) Date: Fri, 10 Sep 1999 13:50:00 +0100 Subject: ECNS'99 and McStas references In-Reply-To: <01JFT2SVJITC9KPC8N@risoe.dk> Message-ID: Hi Kristian, Kim has a copy of the paper we submitted to ECNS: A comparison of monte-carlo simulation using RESTRAX and McSTAS with experiment on IN14. We may be publishing something else on this, slightly more comprehensive. I'll let you know what we get up to. Cheers, Andrew ==================================================== Dr. Andrew Wildes ph: +33 (0)4 76 20 70 37 (office) Institut Laue-Langevin +33 (0)4 76 20 73 31 (IN14) BP 156 fax: +33 (0)4 76 48 39 06 38042 Grenoble Cedex 9 France ==================================================== From kristian.nielsen at risoe.dk Mon Sep 27 14:37:10 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 27 Sep 1999 14:37:10 +0200 Subject: ECNS'99 and McStas references In-Reply-To: (message from Andrew Wildes on Fri, 10 Sep 1999 13:50:00 +0100) Message-ID: > Date: Fri, 10 Sep 1999 13:50:00 +0100 > From: Andrew Wildes > Kim has a copy of the paper we submitted to ECNS: > A comparison of monte-carlo simulation using RESTRAX and McSTAS with > experiment on IN14. Ok, thanks, I have now put it on the list on the web page: http://neutron.risoe.dk/mcstas/reflist.html I found your paper very interesting, and I think it is really useful to compare a simulation with both other programs and with measurements. Kim and I were curious as to the reasons for the disagreement between the results of RESTRAX and McStas, and we were hoping that you would help us follow up on this. Would it be possible for you to send us the input and data files you used to produce the simulations in the paper? - Kristian. -- Kristian Nielsen kristian.nielsen at risoe.dk Ris? National Laboratory Condensed Matter Physics and Chemistry Department Tel. +45 4677 5515 Fax +45 4677 4790 From Georg_Artus at Physik.TU-Muenchen.DE Fri Sep 10 14:07:15 1999 From: Georg_Artus at Physik.TU-Muenchen.DE (Dr. Georg Artus) Date: Fri, 10 Sep 1999 14:07:15 +0200 Subject: ECNS'99 and McStas references References: <01JFT2SVJITC9KPC8N@risoe.dk> Message-ID: <37D8F473.470D049@ph.tum.de> Hello Kristian, Here our publications or posters with references to McStas: Poster (IN1-P1), Deutschen Neutronenstreutagung in Potsdam, 25.-27. May 1999. G. Artus, F. Frey, W. Scherer "Das thermische Einkristalldiffraktometer "RESI" an der Neuen Forschungs-Neutronenquelle FRM-II" Publication and poster (A16), 2nd European Conference on Neutron Scatterung (ECNS99) in Budapest, 1.-4. September 1999. G. Artus, R. Gilles, F. Frey, W. Scherer, Physica B, in press. "Concept of the New Single Crystal Diffractometer at FRM-II" I also will present more specific some simulations on our guide with another poster (and publication) at the NOP99. Thanks for mentioning me in the acknowledgements in the Neutron News Article!! I was surprised and of course happy to read my name there! As I saw on Kim?s laptop there are a lot of new features implemented in McStas! I was really unhappy that I finished my simulations! Best wishes, Georg -- ********************************************* Dr. Georg Artus Technische Universitaet Muenchen Neue Forschungs-Neutronenquelle Garching D-85747 Garching Tel: +49 (0)89/289-14675 Fax: +49 (0)89/289-14666 or 12112 E-mail: gartus at ph.tum.de From kristian.nielsen at risoe.dk Mon Sep 27 14:38:32 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 27 Sep 1999 14:38:32 +0200 Subject: ECNS'99 and McStas references In-Reply-To: <37D8F473.470D049@ph.tum.de> (Georg_Artus@Physik.TU-Muenchen.DE) Message-ID: > Date: Fri, 10 Sep 1999 14:07:15 +0200 > From: "Dr. Georg Artus" > Hello Kristian, > > Here our publications or posters with references to McStas: Ok, thanks, I have now put it on the list on the web page: http://neutron.risoe.dk/mcstas/reflist.html - Kristian. -- Kristian Nielsen kristian.nielsen at risoe.dk Ris? National Laboratory Condensed Matter Physics and Chemistry Department Tel. +45 4677 5515 Fax +45 4677 4790 From hansen at ill.fr Mon Sep 13 09:39:58 1999 From: hansen at ill.fr (Thomas Hansen) Date: Mon, 13 Sep 1999 09:39:58 +0200 Subject: ECNS'99 and McStas references Message-ID: I presented three times a poster containing simulations on the high intensity powder diffractometer D20 at ILL. Of course, these have been realised by means of your McSTAS package inspite the fact that nothing is for free, and I had to invest nevertheless some programming affords to obtain nice results. As I was very satisfied with your conception of McSTAS, which gives a lot of freedom to the user (if he accepts some programming ...), I encouraged the audience to try it for their own particular problem, so I made some "advertising" for your project. Especially in France, people were pretty much excited of these possibilities, less in Britain and Germany, probably as they are more involved in new national soursec and/or the future ESS and already doing simulations theirselves, some of them based upon McSTAS. Okay, but that's not the point here ... All these posters are NOT covered by proceedings, just two of them (in France and Germany) by abstract books and only in the French abstract, McSTAS has been mentioned and cited, sorry. Ah, I mentionned McSTAS also in my talk at the IUCr congress in Glasgow, but again, you won't find a citation of it in the abstracts. Just for your records: 1) 8?mes Journ?es de la Diffusion Neutronique (JDN8), La Grande Motte, May 1999, Thomas HANSEN: "Simulation Monte-Carlo du diffractom?tre ? poudre D20 et implications sur la forme de raies" 2) Deutsche Neutronenstreutagung (n99), Potsdam, May 1999, Thomas HANSEN and Pierre CONVERT: "D20 - Neutronen-Pulverdiffraktometer mit sehr hoher Intensit?t - Ein Schritt zu zeitaufgel?ster Neutronenbeugung" 3) XVIIIth IUCr Congress & General Assembly, Glasgow, August 1999, Thomas HANSEN and Pierre CONVERT: "Towards time resolved neutron diffraction: D20; a high intensity neutron powder diffractometer" [Hansen, T., and Convert, P. (1999). Acta Cryst. A55 Supplement, Abstract M07.OD.005] 4) UK Neutron and Myon Users' Meeting (NMUM99), Durham, September 1999, Thomas HANSEN: "Monte Carlo simulation of the high intensity diffractometer D20 with regard to time resolved powder diffraction" Regards, Thomas >Dear McStas users, > >While I was myself sadly not present at the recent ECNS'99 conference in >Budapest, Kim Lefmann told me that there were several presentations >mentioning McStas in addition to his McStas poster presentation. This >got me thinking that it would be nice to maintain a list of papers that >reference McStas; such a list would be useful to impress our current >sponsors and to improve the possibilities for future funding. > >So, if you have a paper that references McStas, please send me a >reference for such a list (notes about as yet unpublished work is also >welcome, of course). I will make the list available on the web page. > >Kim Lefmann also told me that some papers referenced McStas using the >web page address. Since this summer we have a better publication to >reference, the McStas paper that was published in Neutron News: > > K. Lefmann and K. Nielsen, Neutron News, 10/3, 20 (1999) > >Regards, > > - Kristian. > >-- >Kristian Nielsen kristian.nielsen at risoe.dk >Ris? National Laboratory >Condensed Matter Physics and Chemistry Department >Tel. +45 4677 5515 Fax +45 4677 4790 Institut Laue-langevin, BP 156, 38042 Grenoble C?dex 9, France ILL4-1st floor room 100, Phone +33(0)476207044, Fax +33(0)476483906 hansen at ill.fr, http://www.ill.fr/YellowBook/D20 Private: 13, all?e des ?tangs, 38240 Meylan, France, +33(0)476180553 From kristian.nielsen at risoe.dk Mon Sep 27 14:40:27 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 27 Sep 1999 14:40:27 +0200 Subject: ECNS'99 and McStas references In-Reply-To: (hansen@ill.fr) Message-ID: > Date: Mon, 13 Sep 1999 09:39:58 +0200 > From: hansen at ill.fr (Thomas Hansen) > I presented three times a poster containing simulations on the high > intensity powder diffractometer D20 at ILL. Of course, these have been > realised by means of your McSTAS package inspite the fact that nothing is Ok, thanks, I have now put it on the list on the web page: http://neutron.risoe.dk/mcstas/reflist.html I somewhat arbitrarily decided to put the France and UK references there since they were the ones that had "Monte Carlo" in the title. - Kristian. -- Kristian Nielsen kristian.nielsen at risoe.dk Ris? National Laboratory Condensed Matter Physics and Chemistry Department Tel. +45 4677 5515 Fax +45 4677 4790 From Peter_Link at physik.tu-muenchen.de Mon Sep 13 17:55:03 1999 From: Peter_Link at physik.tu-muenchen.de (Peter Link) Date: Mon, 13 Sep 1999 17:55:03 +0200 Subject: ECNS'99 and McStas references References: <01JFT2SVJITC9KPC8N@risoe.dk> Message-ID: <37DD1E57.3265A541@physik.tu-muenchen.de> Kristian Nielsen schrieb: > So, if you have a paper that references McStas, please send me a > reference for such a list (notes about as yet unpublished work is also > welcome, of course). I will make the list available on the web page. > Dear Kristian, I put a reference to the McStas package on my poster A42 of ECNS'99 and in the corresponding publication: The new thermal triple-axis spectrometer PUMA at the Munich neutron-source; P. Link, G. Eckold and J. Neuhaus; Physica B accepted for publication. If I get a chance to change the reference to your Neutron News paper in proof I'll do so. I'm going to visit Rita ( K. Clausen) on Friday, but I do not know whether there will be some time for anything else then RITA during this short time. Best wishes, Peter -- ****************************************** Dr. P. Link IPC Uni G?ttingen Au?enstelle Garching Neue Forschungs- Neutronenquelle Garching ZBE- FRM II- Bau 85747 Garching Tel. 089 2891 4622 Fax. 089 2895 4622 mailto: plink at physik.tu-muenchen.de ****************************************** From kristian.nielsen at risoe.dk Mon Sep 27 14:41:54 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 27 Sep 1999 14:41:54 +0200 Subject: ECNS'99 and McStas references In-Reply-To: <37DD1E57.3265A541@physik.tu-muenchen.de> (message from Peter Link on Mon, 13 Sep 1999 17:55:03 +0200) Message-ID: > Date: Mon, 13 Sep 1999 17:55:03 +0200 > From: Peter Link > Kristian Nielsen schrieb: > > So, if you have a paper that references McStas, please send me a > > reference for such a list (notes about as yet unpublished work is also > I put a reference to the McStas package on my poster A42 of ECNS'99 and > in the corresponding publication: Ok, thanks for the reference. I have now put it on the list on the web page: http://neutron.risoe.dk/mcstas/reflist.html - Kristian. -- Kristian Nielsen kristian.nielsen at risoe.dk Ris? National Laboratory Condensed Matter Physics and Chemistry Department Tel. +45 4677 5515 Fax +45 4677 4790 From kristian.nielsen at risoe.dk Mon Sep 27 14:53:05 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 27 Sep 1999 14:53:05 +0200 Subject: new modules In-Reply-To: <37E0C934.46CE189F@physik.tu-dresden.de> (message from martin rotter on Thu, 16 Sep 1999 12:40:52 +0200) Message-ID: > Date: Thu, 16 Sep 1999 12:40:52 +0200 > From: martin rotter > Dear Kristian Nielsen ! > > I have had the pleasure to see a presentation of some new features of mcstas at > tzhe ECNS - could > you please send me the modules for the self adapting source and for > calculating/viewing the resolution ellipsoid ? Ok, I am now safely back from Oxford, so here is my latest development version of McStas. I should warn you that this is all still in the development phase, so it may not be as stable as the proper releases. Just ask me if you have any problems. The new version includes - The resolution calculation stuff, with some documentation. - The adaptive importance sampling source Source_adapt.comp. There is a little bit of documentation in comments in the file and in postscript. You will need to install a new version of mcstas, called "mcstas-1.15 ALPHA". Since this is not of release-quality (yet!), I would like to know if you pass it on to others. The files you need are the new version itself: http://neutron.risoe.dk/mcstas/support/farhi/mcstas-1.15A.tar.gz The (sparse) documentation for the adaptive importance sampling (also see comments in Source_adapt.comp): http://neutron.risoe.dk/mcstas/support/farhi/adaptive.ps The documentation for the resolution calculation: http://neutron.risoe.dk/mcstas/support/farhi/resolution.ps - Kristian. -- Kristian Nielsen kristian.nielsen at risoe.dk Ris? National Laboratory Condensed Matter Physics and Chemistry Department Tel. +45 4677 5515 Fax +45 4677 4790 From rotter at physik.tu-dresden.de Thu Sep 16 12:40:52 1999 From: rotter at physik.tu-dresden.de (martin rotter) Date: Thu, 16 Sep 1999 12:40:52 +0200 Subject: new modules Message-ID: <37E0C934.46CE189F@physik.tu-dresden.de> Dear Kristian Nielsen ! I have had the pleasure to see a presentation of some new features of mcstas at tzhe ECNS - could you please send me the modules for the self adapting source and for calculating/viewing the resolution ellipsoid ? with best wishes Martin R -------------- next part -------------- A non-text attachment was scrubbed... Name: vcard.vcf Type: text/x-vcard Size: 460 bytes Desc: Visitenkarte f|r Martin Rotter URL: From Peter_Link at physik.tu-muenchen.de Mon Sep 27 15:59:16 1999 From: Peter_Link at physik.tu-muenchen.de (Peter Link) Date: Mon, 27 Sep 1999 15:59:16 +0200 Subject: Bug in Mon_2foc Component Message-ID: <37EF7833.BCB8E10D@physik.tu-muenchen.de> Hi Kristian, I'm sorry about a stupid beginners bug that I made in the double focussing monochromator. In some cases this produced wrong results, but not always very obious. Please find the corrected version as attached file. Best regards, Peter. P.S. What about this self optimizing source Kim talked to me about! -- ****************************************** Dr. P. Link IPC Uni G?ttingen Au?enstelle Garching Neue Forschungs- Neutronenquelle Garching ZBE- FRM II- Bau 85747 Garching Tel. 089 2891 4622 Fax. 089 2895 4622 mailto: plink at physik.tu-muenchen.de ****************************************** -------------- next part -------------- /******************************************************************************* * * McStas, version 1.0, released October 26, 1998 * Maintained by Kristian Nielsen and Kim Lefmann, * Risoe National Laboratory, Roskilde, Denmark * * Component: Mon_2foc * * Written by: KL, HMR June 16, 1997 * Rewritten by: KL Oct. 16, 1997 * Added double bent feature by: Peter Link Feb. 12,1999 * corrected bug in rotation of v-coords: Peter Link Sep. 24. 1999 * * Double bent monochromator which uses a small-mosaicity approximation as well as * the approximation vy^2 << vz^2 + vx^2. * Second order scattering is neglected. * For an unrotated monochromator component, the crystal plane lies in the y-z * plane (ie. parallel to the beam). * * INPUT PARAMETERS: * * zwidth: (horizontal) width of an individual slab * ywidth: (vertical) heigth of an individual slab * gap : typical gap between adjacent slabs * NH : number of slabs horizontal ( columns ) * NV : number of slabs vertical ( rows ) * mosaich: Horisontal mosaic (FWHM) (arc minutes) * mosaicv: Vertical mosaic (FWHM) (arc minutes) * R0: Maximum reflectivity (1) * Q: Scattering vector (AA-1) * RV : radius of vertical focussing (m) * RH : radius of horizontal focussing (m) * *******************************************************************************/ DEFINE COMPONENT Mon_2foc DEFINITION PARAMETERS (zwidth, ywidth, gap, NH, NV, mosaich, mosaicv, r0, Q, RV, RH) SETTING PARAMETERS () STATE PARAMETERS (x,y,z,vx,vy,vz,t,s1,s2,p) DECLARE %{ #define DIV_CUTOFF 2 /* ~ 10^-5 cutoff. */ %} TRACE %{ double dphi,tmp1,tmp2,tmp3,tmp4,vratio,phi,theta0,theta,v,cs,sn; double zmin,zmax,ymin,ymax,zp,yp,row,col; double tilth,tiltv; /* used to calculate tilt angle of slab */ double sna,snb,csa,csb,vxp,vyp,vzp; double old_x = x, old_y = y, old_z = z, old_t = t; double dt; if(vx != 0.0 && (dt = -x/vx) >= 0.0) { zmax = ((NH*(zwidth+gap))-gap)/2; zmin = -1*zmax; ymax = ((NV*(ywidth+gap))-gap)/2; ymin = -1*ymax; y += vy*dt; z += vz*dt; t += dt; x = 0.0; zp = fmod ( (z-zmin),(zwidth+gap) ); yp = fmod ( (y-ymin),(ywidth+gap) ); /* hit a slab or a gap ? */ if (z>zmin && zymin && y DIV_CUTOFF) { x = old_x; y = old_y; z = old_z; t = old_t; } else { p *= r0*exp(-tmp3*tmp3*4*log(2)); /* Use mosaics */ tmp1 = 2*theta; cs = cos(tmp1); sn = sin(tmp1); tmp2 = cs*vxp - sn*vzp; vyp = vyp; /* vz = cs*vz + sn*vx; diese Zeile wurde durch die folgende ersetzt */ tmp4 = vyp/vzp; /* korrigiert den schr?gen Einfall aufs Pl?ttchen */ vzp = cs*(-vyp*sin(tmp4)+vzp*cos(tmp4)) + sn*vxp; vxp = tmp2; /* Second: scatering out of plane. Approximation is that Debye-Scherrer cone is a plane */ phi = atan2(vyp,vzp); /* out-of plane angle */ dphi = (MIN2RAD*mosaicv)/(2*sqrt(2*log(2)))*randnorm(); /* MC choice: */ /* Vertical angle of the crystallite */ vyp = vzp*tan(phi+2*dphi*sin(theta)); vratio = v/sqrt(vxp*vxp+vyp*vyp+vzp*vzp); vzp = vzp*vratio; vyp = vyp*vratio; /* Renormalize v */ vxp = vxp*vratio; } /* rotate v coords back */ vx = vxp*csb*csa-vyp*snb*csa+vzp*sna; vy = vxp*snb+vyp*csb; vz = -vxp*csb*sna+vyp*snb*sna+vzp*csa; v=sqrt(vx*vx+vy*vy+vz*vz); } else { x = old_x; y = old_y; z = old_z; t = old_t; } } %} END From kristian.nielsen at risoe.dk Tue Sep 28 13:53:48 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 28 Sep 1999 13:53:48 +0200 Subject: Bug in Mon_2foc Component In-Reply-To: <37EF7833.BCB8E10D@physik.tu-muenchen.de> (message from Peter Link on Mon, 27 Sep 1999 15:59:16 +0200) Message-ID: > Date: Mon, 27 Sep 1999 15:59:16 +0200 > From: Peter Link > Hi Kristian, > I'm sorry about a stupid beginners bug that I made in the double > Please find the corrected version as attached file. Ok, thanks. I put the update on the web page. > P.S. What about this self optimizing source Kim talked to me about! Ok, here is my latest development version of McStas. I should warn you that this is all still in the development phase, so it may not be as stable as the proper releases. Just ask me if you have any problems. The new version includes - The resolution calculation stuff, with some documentation. - The adaptive importance sampling source Source_adapt.comp. There is a little bit of documentation in comments in the file and in postscript. You will need to install a new version of mcstas, called "mcstas-1.15 ALPHA". Since this is not of release-quality (yet!), I would like to know if you pass it on to others. The files you need are the new version itself: http://neutron.risoe.dk/mcstas/support/farhi/mcstas-1.15A.tar.gz The (sparse) documentation for the adaptive importance sampling (also see comments in Source_adapt.comp): http://neutron.risoe.dk/mcstas/support/farhi/adaptive.ps The documentation for the resolution calculation: http://neutron.risoe.dk/mcstas/support/farhi/resolution.ps - Kristian. -- Kristian Nielsen kristian.nielsen at risoe.dk Ris? National Laboratory Condensed Matter Physics and Chemistry Department Tel. +45 4677 5515 Fax +45 4677 4790 From kristian.nielsen at risoe.dk Tue Sep 28 13:56:01 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 28 Sep 1999 13:56:01 +0200 Subject: McStas adaptive importance sampling and resolution function Message-ID: Dear Philipp Bernhardt, Kim Lefmann told me that at the ECNS'99, you asked for the resolution function calculation and the adaptive importance sampling in McStas. I have therefore now made available my latest development version of McStas. I should warn you that this is all still in the development phase, so it may not be as stable as the proper releases. Just ask me if you have any problems. The new version includes - The resolution calculation stuff, with some documentation. - The adaptive importance sampling source Source_adapt.comp. There is a little bit of documentation in comments in the file and in postscript. You will need to install a new version of mcstas, called "mcstas-1.15 ALPHA". Since this is not of release-quality (yet!), I would like to know if you pass it on to others. The files you need are the new version itself: http://neutron.risoe.dk/mcstas/support/farhi/mcstas-1.15A.tar.gz The (sparse) documentation for the adaptive importance sampling (also see comments in Source_adapt.comp): http://neutron.risoe.dk/mcstas/support/farhi/adaptive.ps The documentation for the resolution calculation: http://neutron.risoe.dk/mcstas/support/farhi/resolution.ps - Kristian. -- Kristian Nielsen kristian.nielsen at risoe.dk Ris? National Laboratory Condensed Matter Physics and Chemistry Department Tel. +45 4677 5515 Fax +45 4677 4790 From horn at ill.fr Mon Sep 6 15:26:02 1999 From: horn at ill.fr (Pay H. Schulze Horn) Date: Mon, 06 Sep 1999 15:26:02 +0200 Subject: McStas: forgotten attachment References: <01JF7Y4FJTL89JEAIX@risoe.dk> Message-ID: <37D3C0EA.794B@ill.fr> /* This Monitor give the horizontal divergence in korrelation to the energy in a 2D McStas styled array out. If you want the vertikal divergence, turn it like you will. THERE IS NO SECTION FOR MCDISPLAY! * xmin: Lower x bound of detector opening (m) * xmax: Upper x bound of detector opening (m) * ymin: Lower y bound of detector opening (m) * ymax: Upper y bound of detector opening (m) * nenergy: Number of counting-rate-channels for the intervall [e_min;e_max] of the energy. * ndiv: Number of counting-rate-channels for the intervall [-maxdiv;maxdiv] of the horizontal divergence. * maxdiv: Maximum divergence to detect. * E_middle: The middle of the energy intervall [E_middle-E_delta;E_middle+E_delta] to detect. * E_delta: Gives the range of the energy intervall [E_middle-E_delta;E_middle+E_delta] to detect. This Monitor is component for McStas and written by Pay Schulze Horn at Institut Laue Langevin in August 1999. e-mail: horn at ill.fr until 26.10.99 stu32232 at mail.uni-kiel.de for the next 2 years McStas is written by Kim Lefmann and Kristian Nielsen at Risoe National Laboratory Danmark. The source-code is based on the component-source-code Divergence_monitor, which is written by: KL, Nov. 11, 1998 */ DEFINE COMPONENT Divenergymon DEFINITION PARAMETERS (xmin, xmax, ymin, ymax, nenergy, ndiv, maxdiv,E_middle,E_delta,filename) SETTING PARAMETERS () OUTPUT PARAMETERS (Div_N, Div_p, Div_p2) STATE PARAMETERS (x,y,z,vx,vy,vz,t,s1,s2,p) DECLARE %{ /* the 2D-arrays in which the data will be stored */ int Div_N[ndiv][nenergy]; double Div_p[ndiv][nenergy]; double Div_p2[ndiv][nenergy]; %} INITIALIZE %{ int i,j; for (i=0; ixmin && xymin && y E_middle-E_delta && neut_div < maxdiv && neut_div > -maxdiv) { /* counting at what space the datas will be stored */ i = floor(((neut_energy-E_middle+E_delta)/(2*E_delta))*nenergy); j = floor((neut_div + maxdiv)*ndiv/(2.0*maxdiv)); Div_N[i][j]++; Div_p[i][j] += p; Div_p2[i][j] += p*p; } } %} FINALLY %{ DETECTOR_OUT_2D( "horizontal divergence related to energy monitor", "Energy [meV]", "horizontal(y) divergence [deg]", E_middle-E_delta, E_middle+E_delta, -maxdiv, maxdiv, ndiv, nenergy, &Div_N[0][0],&Div_p[0][0],&Div_p2[0][0], filename); %} END From kristian.nielsen at risoe.dk Wed Sep 29 10:27:21 1999 From: kristian.nielsen at risoe.dk (Kristian Nielsen) Date: 29 Sep 1999 10:27:21 +0200 Subject: Mcstas In-Reply-To: <199908251839.NAA18982@black.pns.anl.gov> (eiverson@anl.gov) Message-ID: > Date: Wed, 25 Aug 1999 13:39:08 -0400 > From: eiverson at anl.gov > Unfortunately, I still cannot get perl-PGPLOT to successfully compile. It > will "make" without any errors, but "make test" fails completely. > black % make test > PERL_DL_NONLAZY=1 /usr/bin/perl -I./blib/arch -I./blib/lib -I/usr/lib/perl5/i386- > linux/5.00404 -I/usr/lib/perl5 test.pl > ============== Running test1.p ============== > Can't load './blib/arch/auto/PGPLOT/PGPLOT.so' for module PGPLOT: ./blib/arch/aut > o/PGPLOT/PGPLOT.so: undefined symbol: fstat at /usr/lib/perl5/i386-linux/5.00404/ > DynaLoader.pm line 166. > > at test1.p line 3 > BEGIN failed--compilation aborted at test1.p line 3. I managed to solve a similar problem on another linux machine. On this machine, the compiler has a new fortran library which is called "libg2c", but PgPerl picked up the old library "libf2c". Changing all occurences of "f2c" into "g2c" in the file "Makefile" before running make solved the problem. Perhaps you could try it and see if it solves your problem also? I will contact the PgPerl author to get a permanent solution. - Kristian. -- Kristian Nielsen kristian.nielsen at risoe.dk Ris? National Laboratory Condensed Matter Physics and Chemistry Department Tel. +45 4677 5515 Fax +45 4677 4790 From farhi at ill.fr Thu Sep 30 18:15:37 1999 From: farhi at ill.fr (Farhi) Date: Thu, 30 Sep 1999 18:15:37 +0200 Subject: Optimizer : Great Message-ID: <37F38CA9.BB8C504A@ill.fr> Hy Kristian I now have an optimizer that increases count numbers on detector by about a factor 40 to 50 ! It supposes that the neutrons from original source have uncorrelated state parameters. It identifies the 'good' neutrons going to the monitor, and then redirect the bad neutrons to 'good' state parameters. What's long in computation is the random generator. ABSORB comes after, and so do not affect drastically the computation time (perhaps a factor 2). A better solution is to use the 'bad' random numbers and to convert them to some more effective values. That's what I do. Flux is kept during those source optimizations redirections, but I'm now testing the 'quality' of optimized neutrons, and how are affected the different monitors... I send you all this when it's tested, un-bugged and reliable. EF. -- Emmanuel FARHI, http://www.ill.fr/tas/people/Farhi.html \|/ ____ \|/ TAS-Group, Institut Laue-Langevin (ILL) Grenoble ~@-/ oO \-@~ Avenue des Martyrs, BP 156, 38042 Grenoble Cedex 9,France /_( \__/ )_\ Work :Tel (33/0) 4 76 20 71 83. Fax (33/0) 4 76 48 39 06 \__U_/ La Grande Arche, Chateau d'Uriage, 38410 Saint Martin d'Uriage 04 76 59 73 94 -------------- next part -------------- An HTML attachment was scrubbed... URL: From farhi at ill.fr Wed Sep 29 17:45:31 1999 From: farhi at ill.fr (Farhi) Date: Wed, 29 Sep 1999 17:45:31 +0200 Subject: Optimizer Message-ID: <37F2341B.E39E8469@ill.fr> Hy Kristian, Well, I now have an optimizer that seems to work correctly. In just ABSORB all neutrons that are known not to reach the Monitor_optimizer. The problem is that nothing seems to occur about decreasing computation time. All is just like if ABSORB takes the same computation time as before. The final flux and counts on monitor are kept. At the end, 20 % of neutrons were used to determine limits of state parameters and optimized source distributions. Among the other neutrons, 78 % were ABSORBed (optimized source identifies them as non reaching monitor), but the computation time is unchanged. If you ever want to test some few things, I've attached all necessary components, instrument in14_6 (with optimizer) and in14_6n (no optimizer, same time). I now use mcstas 1.15A. Very strange... EF. -- Emmanuel FARHI, http://www.ill.fr/tas/people/Farhi.html \|/ ____ \|/ TAS-Group, Institut Laue-Langevin (ILL) Grenoble ~@-/ oO \-@~ Avenue des Martyrs, BP 156, 38042 Grenoble Cedex 9,France /_( \__/ )_\ Work :Tel (33/0) 4 76 20 71 83. Fax (33/0) 4 76 48 39 06 \__U_/ La Grande Arche, Chateau d'Uriage, 38410 Saint Martin d'Uriage 04 76 59 73 94 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- DEFINE COMPONENT Source_flux DEFINITION PARAMETERS (radius, dist, xw, yh, E0, dE, flux) SETTING PARAMETERS () OUTPUT PARAMETERS (hdiv, vdiv, p_in) STATE PARAMETERS (x,y,z,vx,vy,vz,t,s1,s2,p) DECLARE %{ double hdiv,vdiv; double p_in; %} INITIALIZE %{ double factor, lambda_min, lambda_max, delta_lambda, source_area; hdiv = atan(xw/(2.0*dist)); vdiv = atan(yh/(2.0*dist)); lambda_min = sqrt(81.81/(E0+dE)); /* AAngstroem */ lambda_max = sqrt(81.81/(E0-dE)); delta_lambda = lambda_max - lambda_min; source_area = radius*radius*PI*1e4; /* cm^2 */ factor = flux/mcget_ncount()*delta_lambda*source_area; p_in = (4*hdiv*vdiv)*factor; /* Small angle approx. */ %} TRACE %{ double theta0,phi0,chi,theta,phi,E,v,r; p=p_in; z=0; chi=2*PI*rand01(); /* Choose point on source */ r=sqrt(rand01())*radius; /* with uniform distribution. */ x=r*cos(chi); y=r*sin(chi); theta0= -atan(x/dist); /* Angles to aim at target centre */ phi0= -atan(y/dist); theta=theta0+hdiv*randpm1(); /* Small angle approx. */ phi=phi0+vdiv*randpm1(); E=E0+dE*randpm1(); /* Assume linear distribution */ v=sqrt(E)*SE2V; vz=v*cos(phi)*cos(theta); vy=v*sin(phi); vx=v*cos(phi)*sin(theta); %} END -------------- next part -------------- /******************************************************************************* * * McStas, version 1.1, released * Maintained by Kristian Nielsen and Kim Lefmann, * Risoe National Laboratory, Roskilde, Denmark * * Component: Source_Optimizer * * Written by: EF, 17 Sept 1999 * * A component that optimizes the neutron flux passing through the * Source_optimizer in order to have the maximum flux at the * Monitor_Optimizer position. Polarization is not optimized. * Source_optimizer should be placed just after the source. * Monitor_Optimizer should be placed at position to optimize. * * INPUT PARAMETERS: * * xmin: Lower x bound of optimizer opening (m) * xmax: Upper x bound of optimizer opening (m) * ymin: Lower y bound of optimizer opening (m) * ymax: Upper y bound of optimizer opening (m) * bins: Number of cells for sampling of neutron state distribution (10 is default) * step: Optimizer step (%, 10 is default) * The two first steps are not optimized. * keep: Percentage of initial source distribution kept (%, 1 is default) * file: Filename where to save optimized source distributions * * parameters bins, step, keep can be -1 for default values. * * OUTPUT PARAMETERS: * * distributions if filename is not empty ("") * *******************************************************************************/ DEFINE COMPONENT Source_Optimizer DEFINITION PARAMETERS (xmin, xmax, ymin, ymax, bins, step, keep,file) SETTING PARAMETERS () STATE PARAMETERS (x,y,z,vx,vy,vz,t,s1,s2,p) DECLARE %{ #ifndef MCSTAS_GEN_OPTIM /* McStas General optimizer ID */ #define MCSTAS_GEN_OPTIM #else #error McStas : Source_Optimizer should only be used once per instrument #endif #define OPTIM_MAX_ABSORB 10000 /* max number of ABSORB per bin */ #define OPTIM_PHASE_SET_LIMITS 0 /* set array limits to 0, then ask for GET_LIMITS */ #define OPTIM_PHASE_GET_LIMITS 1 /* compute array limits, then ask for SET_REF */ #define OPTIM_PHASE_SET_REF 2 /* set Ref and New_Source to to 0, then ask for GET_REF */ #define OPTIM_PHASE_GET_REF 3 /* compute Ref (and New_Source in Monitor), then ask for SET_SOURCE */ #define OPTIM_PHASE_SET_SOURCE 4 /* set Source to Ref*x%+New_Source, normalize to Ref, Passing to 0, then ask for OPTIM */ #define OPTIM_PHASE_OPTIM 5 /* Optimize and get New_Source (continuous optimization), then reask SET_SOURCE when required */ /* These are distribution arrays[bins] within limits * flux is kept during optimisation * NOT stored : z is the position of this component * t time (linked to z) */ /* initial Reference distribution arrays (for weights) */ long *Optim_Reference_x; long *Optim_Reference_y; long *Optim_Reference_vx; long *Optim_Reference_vy; long *Optim_Reference_vz; long *Optim_Reference_s1; long *Optim_Reference_s2; long *Optim_Reference_p; /* optimized Source distribution arrays (to reach) */ long *Optim_Source_x; long *Optim_Source_y; long *Optim_Source_vx; long *Optim_Source_vy; long *Optim_Source_vz; long *Optim_Source_s1; long *Optim_Source_s2; long *Optim_Source_p; /* optimized New_Source distribution arrays (to reach in next step, passed to Source) */ long *Optim_New_Source_x; long *Optim_New_Source_y; long *Optim_New_Source_vx; long *Optim_New_Source_vy; long *Optim_New_Source_vz; long *Optim_New_Source_s1; long *Optim_New_Source_s2; long *Optim_New_Source_p; /* Passing distribution arrays (should grow to reach Source) */ long *Optim_Passing_x; long *Optim_Passing_y; long *Optim_Passing_vx; long *Optim_Passing_vy; long *Optim_Passing_vz; long *Optim_Passing_s1; long *Optim_Passing_s2; long *Optim_Passing_p; /* limits for state parameters */ /* x and y are Optimizer dimensions (input parameters) */ double Optim_x_min, Optim_x_max; double Optim_y_min, Optim_y_max; double Optim_vx_min, Optim_vx_max; double Optim_vy_min, Optim_vy_max; double Optim_vz_min, Optim_vz_max; double Optim_s1_min, Optim_s1_max; double Optim_s2_min, Optim_s2_max; double Optim_p_min, Optim_p_max; int Optim_index=0; /* a running Optim_index */ int Optim_index_x=0; int Optim_index_y=0; int Optim_index_vx=0; int Optim_index_vy=0; int Optim_index_vz=0; int Optim_index_s1=0; int Optim_index_s2=0; int Optim_index_p=0; int Optim_bins; long Optim_n_absorb; /* number of consecutive ABSORB */ int Optim_Phase; /* Optimizer function */ long Optim_Phase_Counts =0; /* neutron counts to achieve in each Phase */ long Optim_Limits_Counts =0; /* passing neutron counts in each Optim_Phase */ long Optim_Reference_Counts =0; long Optim_Passing_Counts =0; long Optim_Monitor_Counts =0; double Optim_Limits_Flux =0; /* passing neutron flux in each Optim_Phase */ double Optim_Reference_Flux=0; double Optim_Passing_Flux =0; double Optim_Monitor_Flux =0; double tmp1, tmp2; float Optim_keep; float Optim_step; double Optim_vx; /* save neutron characteristics for Monitor */ double Optim_vy; double Optim_vz; double Optim_x; double Optim_y; double Optim_s1; double Optim_s2; double Optim_p; double Optim_Ratio = 0; FILE *hfile; /* end declare */ %} INITIALIZE %{ Optim_n_absorb = 0; Optim_Phase = OPTIM_PHASE_SET_LIMITS; Optim_x_min = xmin; Optim_x_max = xmax; Optim_y_min = ymin; Optim_y_max = ymax; Optim_bins = (int)bins; Optim_step = step; Optim_keep = keep; if (Optim_step < 0) Optim_step = .1; /* default values if -1 is given */ if (Optim_bins < 0) Optim_bins = 10; if (Optim_keep < 0) Optim_keep = .01; if (Optim_step > 1) Optim_step = Optim_step/100; /* in case user gives % in 1-100 */ if (Optim_step < .01) Optim_step = .01; if (Optim_step > 1) Optim_step = 1; if (Optim_keep > 1) Optim_keep = Optim_keep/100; /* in case user gives % in 1-100 */ if (Optim_keep < .01) Optim_keep = .01; if (Optim_keep > 1) Optim_keep = 1; Optim_Phase_Counts = mcget_ncount() * Optim_step; if (Optim_bins < 1) Optim_bins = 1; if (Optim_bins > 100) Optim_bins = 100; if ((Optim_Source_x = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Source_y = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Source_vx = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Source_vy = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Source_vz = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Source_s1 = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Source_s2 = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Source_p = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_New_Source_x = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_New_Source_y = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_New_Source_vx = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_New_Source_vy = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_New_Source_vz = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_New_Source_s1 = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_New_Source_s2 = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_New_Source_p = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Passing_x = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Passing_y = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Passing_vx = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Passing_vy = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Passing_vz = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Passing_s1 = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Passing_s2 = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Passing_p = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Reference_x = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Reference_y = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Reference_vx = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Reference_vy = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Reference_vz = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Reference_s1 = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Reference_s2 = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } if ((Optim_Reference_p = (long*)malloc(Optim_bins * sizeof(long*))) == NULL) { fprintf(stderr,"Optimizer : not enough memory\n"); exit(-1); } /* end initialize */ %} TRACE %{ PROP_Z0; if (x>Optim_x_min && xOptim_y_min && y OPTIM_MAX_ABSORB*Optim_bins) { Optim_Phase = OPTIM_PHASE_SET_SOURCE; printf("ABSORB : OPTIM_PHASE_SET_SOURCE\n"); } /* handle Phase sequence */ if ((Optim_Phase == OPTIM_PHASE_GET_LIMITS) && (Optim_Limits_Counts >= Optim_Phase_Counts)) { Optim_Phase = OPTIM_PHASE_SET_REF; printf("OPTIM_PHASE_SET_REF\n"); } if ((Optim_Phase == OPTIM_PHASE_GET_REF) && (Optim_Reference_Counts >= Optim_Phase_Counts)) { Optim_Phase = OPTIM_PHASE_SET_SOURCE; printf("OPTIM_PHASE_SET_SOURCE\n"); } if ((Optim_Phase == OPTIM_PHASE_OPTIM) && (Optim_Passing_Counts >= Optim_Phase_Counts)) { if (Optim_Ratio == 0) Optim_Ratio = (double)Optim_Monitor_Counts /Optim_Reference_Counts; if (Optim_Reference_Counts*Optim_Ratio) printf("Optimizer efficiency is : %.1f \% \n", ((double)Optim_Monitor_Counts * 100/Optim_Reference_Counts)/Optim_Ratio); printf("Number of ABSORB : %i\n",Optim_n_absorb); printf("Counts : reference = %i, passing = %i, monitor = %i\n", Optim_Reference_Counts, Optim_Passing_Counts, Optim_Monitor_Counts); printf("Flux : reference = %.2g, passing = %.2g, monitor = %.2g\n", Optim_Reference_Flux, Optim_Passing_Flux, Optim_Monitor_Flux); Optim_Phase = OPTIM_PHASE_SET_SOURCE; printf("OPTIM_PHASE_SET_SOURCE update\n"); } /* handle Optim_Phase functions */ if (Optim_Phase == OPTIM_PHASE_SET_LIMITS) /* init : need to compute limits and flux */ { Optim_Limits_Counts = 0; Optim_Limits_Flux = 0; Optim_vx_min = FLT_MAX; Optim_vx_max = -FLT_MAX; Optim_vy_min = FLT_MAX; Optim_vy_max = -FLT_MAX; Optim_vz_min = FLT_MAX; Optim_vz_max = -FLT_MAX; Optim_s1_min = FLT_MAX; Optim_s1_max = -FLT_MAX; Optim_s2_min = FLT_MAX; Optim_s2_max = -FLT_MAX; Optim_p_min = FLT_MAX; Optim_p_max = -FLT_MAX; Optim_Phase = OPTIM_PHASE_GET_LIMITS; } /* end OPTIM_PHASE_SET_LIMITS */ if (Optim_Phase == OPTIM_PHASE_GET_LIMITS) /* init : need to compute limits and flux */ { Optim_Limits_Counts++; Optim_Limits_Flux += p; if (x < Optim_x_min) Optim_x_min = x; if (y < Optim_y_min) Optim_y_min = y; if (x > Optim_x_max) Optim_x_max = x; if (y > Optim_y_max) Optim_y_max = y; if (vx < Optim_vx_min) Optim_vx_min = vx; if (vx > Optim_vx_max) Optim_vx_max = vx; if (vy < Optim_vy_min) Optim_vy_min = vy; if (vy > Optim_vy_max) Optim_vy_max = vy; if (vz < Optim_vz_min) Optim_vz_min = vz; if (vz > Optim_vz_max) Optim_vz_max = vz; if (p < Optim_p_min) Optim_p_min = p; if (p > Optim_p_max) Optim_p_max = p; if (s1 < Optim_s1_min) Optim_s1_min = s1; if (s1 > Optim_s1_max) Optim_s1_max = s1; if (s2 < Optim_s2_min) Optim_s2_min = s2; if (s2 > Optim_s2_max) Optim_s2_max = s2; } /* end if OPTIM_PHASE_GET_LIMITS */ if (Optim_Phase == OPTIM_PHASE_SET_REF) /* Set Ref and New_Source to 0 */ { Optim_Reference_Counts = 0; Optim_Reference_Flux = 0; Optim_Monitor_Counts = 0; /* also counted as New_Source */ Optim_Monitor_Flux = 0; for (Optim_index=0; Optim_index < Optim_bins; Optim_index++) { Optim_Reference_x[Optim_index] = 0; /* initial distribution will be recorded first */ Optim_Reference_y[Optim_index] = 0; Optim_Reference_vx[Optim_index] = 0; Optim_Reference_vy[Optim_index] = 0; Optim_Reference_vz[Optim_index] = 0; Optim_Reference_s1[Optim_index] = 0; Optim_Reference_s2[Optim_index] = 0; Optim_Reference_p[Optim_index] = 0; Optim_New_Source_x[Optim_index] = 0; /* Monitor_Optimizer will compute the */ Optim_New_Source_y[Optim_index] = 0; /* optimized New_Source distribution */ Optim_New_Source_vx[Optim_index] = 0; /* that will become Source for Optim Optim_step */ Optim_New_Source_vy[Optim_index] = 0; Optim_New_Source_vz[Optim_index] = 0; Optim_New_Source_s1[Optim_index] = 0; Optim_New_Source_s2[Optim_index] = 0; Optim_New_Source_p[Optim_index] = 0; } /* end for */ Optim_Phase = OPTIM_PHASE_GET_REF; } /* end OPTIM_PHASE_SET_REF */ if (Optim_Phase == OPTIM_PHASE_GET_REF) /* now build the Reference in limits */ { /* New_Source is set by Monitor_Optimizer */ Optim_Reference_Counts++; Optim_Reference_Flux += p; if (Optim_vx_max-Optim_vx_min) Optim_index = (int)rint(Optim_bins * (vx -Optim_vx_min)/(Optim_vx_max-Optim_vx_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; Optim_Reference_vx[Optim_index]++; if (Optim_vy_max-Optim_vy_min) Optim_index = (int)rint(Optim_bins * (vy -Optim_vy_min)/(Optim_vy_max-Optim_vy_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; Optim_Reference_vy[Optim_index]++; if (Optim_vz_max-Optim_vz_min) Optim_index = (int)rint(Optim_bins * (vz -Optim_vz_min)/(Optim_vz_max-Optim_vz_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; Optim_Reference_vz[Optim_index]++; if (Optim_x_max-Optim_x_min) Optim_index = (int)rint(Optim_bins * (x -Optim_x_min)/(Optim_x_max-Optim_x_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; Optim_Reference_x[Optim_index]++; if (Optim_y_max-Optim_y_min) Optim_index = (int)rint(Optim_bins * (y -Optim_y_min)/(Optim_y_max-Optim_y_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; Optim_Reference_y[Optim_index]++; if (Optim_s1_max-Optim_s1_min) Optim_index = (int)rint(Optim_bins * (s1 -Optim_s1_min)/(Optim_s1_max-Optim_s1_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; Optim_Reference_s1[Optim_index]++; if (Optim_s2_max-Optim_s2_min) Optim_index = (int)rint(Optim_bins * (s2 -Optim_s2_min)/(Optim_s2_max-Optim_s2_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; Optim_Reference_s2[Optim_index]++; if (Optim_p_max-Optim_p_min) Optim_index = (int)rint(Optim_bins * (p -Optim_p_min)/(Optim_p_max-Optim_p_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; Optim_Reference_p[Optim_index]++; } /* end if OPTIM_PHASE_GET_REF */ if (Optim_Phase == OPTIM_PHASE_SET_SOURCE) /* Define optimized Source */ { if (Optim_Monitor_Counts) tmp1 = (1 - Optim_keep) * Optim_Reference_Counts/Optim_Monitor_Counts; else tmp1 = 0; Optim_Passing_Counts = 0; Optim_Passing_Flux = 0; Optim_Monitor_Counts = 0; /* also counted as New_Source */ Optim_Monitor_Flux = 0; for (Optim_index = 0; Optim_index < Optim_bins; Optim_index++) { /* get Optim_keep % of Reference, and 1-Optim_keep% of New_Source normalized to Reference Counts */ Optim_Source_x[Optim_index] = (long)(rint(Optim_keep * Optim_Reference_x[Optim_index]) + tmp1 * Optim_New_Source_x[Optim_index] ); Optim_Source_y[Optim_index] = (long)(rint(Optim_keep * Optim_Reference_y[Optim_index]) + tmp1 * Optim_New_Source_y[Optim_index] ); Optim_Source_vx[Optim_index] = (long)(rint(Optim_keep * Optim_Reference_vx[Optim_index]) + tmp1 * Optim_New_Source_vx[Optim_index] ); Optim_Source_vy[Optim_index] = (long)(rint(Optim_keep * Optim_Reference_vy[Optim_index]) + tmp1 * Optim_New_Source_vy[Optim_index] ); Optim_Source_vz[Optim_index] = (long)(rint(Optim_keep * Optim_Reference_vz[Optim_index]) + tmp1 * Optim_New_Source_vz[Optim_index] ); Optim_Source_s1[Optim_index] = (long)(rint(Optim_keep * Optim_Reference_s1[Optim_index]) + tmp1 * Optim_New_Source_s1[Optim_index] ); Optim_Source_s2[Optim_index] = (long)(rint(Optim_keep * Optim_Reference_s2[Optim_index]) + tmp1 * Optim_New_Source_s2[Optim_index] ); Optim_Source_p[Optim_index] = (long)(rint(Optim_keep * Optim_Reference_p[Optim_index]) + tmp1 * Optim_New_Source_p[Optim_index] ); Optim_Passing_x[Optim_index] = 0; /* Passing neutrons will then reach Source */ Optim_Passing_y[Optim_index] = 0; /* weights will be adapted to match Reference */ Optim_Passing_vx[Optim_index] = 0; Optim_Passing_vy[Optim_index] = 0; Optim_Passing_vz[Optim_index] = 0; Optim_Passing_s1[Optim_index] = 0; Optim_Passing_s2[Optim_index] = 0; Optim_Passing_p[Optim_index] = 0; Optim_New_Source_x[Optim_index] = 0; /* Init of next Source */ Optim_New_Source_y[Optim_index] = 0; Optim_New_Source_vx[Optim_index] = 0; Optim_New_Source_vy[Optim_index] = 0; Optim_New_Source_vz[Optim_index] = 0; Optim_New_Source_s1[Optim_index] = 0; Optim_New_Source_s2[Optim_index] = 0; Optim_New_Source_p[Optim_index] = 0; } /* end for */ Optim_Phase = OPTIM_PHASE_OPTIM; } /* end OPTIM_PHASE_SET_SOURCE */ if (Optim_Phase == OPTIM_PHASE_OPTIM) /* Use optimized Source */ { if (Optim_vx_max-Optim_vx_min) Optim_index = (int)rint(Optim_bins * (vx -Optim_vx_min)/(Optim_vx_max-Optim_vx_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; if (Optim_Passing_vx[Optim_index] >= Optim_Source_vx[Optim_index]) /* distribution achieved : ABSORB */ { Optim_n_absorb++; ABSORB; } else Optim_index_vx = Optim_index; if (Optim_vy_max-Optim_vy_min) Optim_index = (int)rint(Optim_bins * (vy -Optim_vy_min)/(Optim_vy_max-Optim_vy_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; if (Optim_Passing_vy[Optim_index] >= Optim_Source_vy[Optim_index]) /* distribution achieved : ABSORB */ { Optim_n_absorb++; ABSORB; } else Optim_index_vy = Optim_index; if (Optim_vz_max-Optim_vz_min) Optim_index = (int)rint(Optim_bins * (vz -Optim_vz_min)/(Optim_vz_max-Optim_vz_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; if (Optim_Passing_vz[Optim_index] >= Optim_Source_vz[Optim_index]) /* distribution achieved : ABSORB */ { Optim_n_absorb++; ABSORB; } else Optim_index_vz = Optim_index; if (Optim_x_max-Optim_x_min) Optim_index = (int)rint(Optim_bins * (x -Optim_x_min)/(Optim_x_max-Optim_x_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; if (Optim_Passing_x[Optim_index] >= Optim_Source_x[Optim_index]) /* distribution achieved : ABSORB */ { Optim_n_absorb++; ABSORB; } else Optim_index_x = Optim_index; if (Optim_y_max-Optim_y_min) Optim_index = (int)rint(Optim_bins * (y -Optim_y_min)/(Optim_y_max-Optim_y_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; if (Optim_Passing_y[Optim_index] >= Optim_Source_y[Optim_index]) /* distribution achieved : ABSORB */ { Optim_n_absorb++; ABSORB; } else Optim_index_y = Optim_index; if (Optim_s1_max-Optim_s1_min) Optim_index = (int)rint(Optim_bins * (s1 -Optim_s1_min)/(Optim_s1_max-Optim_s1_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; if (Optim_Passing_s1[Optim_index] >= Optim_Source_s1[Optim_index]) /* distribution achieved : ABSORB */ { Optim_n_absorb++; ABSORB; } else Optim_index_s1 = Optim_index; if (Optim_s2_max-Optim_s2_min) Optim_index = (int)rint(Optim_bins * (s2 -Optim_s2_min)/(Optim_s2_max-Optim_s2_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; if (Optim_Passing_s2[Optim_index] >= Optim_Source_s2[Optim_index]) /* distribution achieved : ABSORB */ { Optim_n_absorb++; ABSORB; } else Optim_index_s2 = Optim_index; if (Optim_p_max-Optim_p_min) Optim_index = (int)rint(Optim_bins * (p -Optim_p_min)/(Optim_p_max-Optim_p_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; if (Optim_Passing_p[Optim_index] >= Optim_Source_p[Optim_index]) /* distribution achieved : ABSORB */ { Optim_n_absorb++; ABSORB; } else Optim_index_p = Optim_index; /* neutron is passed ! */ Optim_Passing_vx[Optim_index_vx]++; Optim_Passing_vy[Optim_index_vy]++; Optim_Passing_vz[Optim_index_vz]++; Optim_Passing_x[Optim_index_x]++; Optim_Passing_y[Optim_index_y]++; Optim_Passing_s1[Optim_index_s1]++; Optim_Passing_s2[Optim_index_s2]++; Optim_Passing_p[Optim_index_p]++; /* if (Optim_Source_vx[Optim_index_vx]) p *= Optim_Reference_vx[Optim_index_vx]/Optim_Source_vx[Optim_index_vx]; if (Optim_Source_vy[Optim_index_vy]) p *= Optim_Reference_vy[Optim_index_vy]/Optim_Source_vy[Optim_index_vy]; if (Optim_Source_vz[Optim_index_vz]) p *= Optim_Reference_vz[Optim_index_vz]/Optim_Source_vz[Optim_index_vz]; if (Optim_Source_x[Optim_index_x]) p *= Optim_Reference_x[Optim_index_x]/Optim_Source_x[Optim_index_x]; if (Optim_Source_y[Optim_index_y]) p *= Optim_Reference_y[Optim_index_y]/Optim_Source_y[Optim_index_y]; if (Optim_Source_s1[Optim_index_s1]) p *= Optim_Reference_s1[Optim_index_s1]/Optim_Source_s1[Optim_index_s1]; if (Optim_Source_s2[Optim_index_s2]) p *= Optim_Reference_s2[Optim_index_s2]/Optim_Source_s2[Optim_index_s2]; if (Optim_Source_p[Optim_index_p]) p *= Optim_Reference_p[Optim_index_p]/Optim_Source_p[Optim_index_p]; */ Optim_Passing_Counts++; Optim_Passing_Flux += p; } /* end if OPTIM_PHASE_OPTIM */ /* if we reach here, n_absorb is set to 0 */ /* Optim_n_absorb = 0; */ } /* end if xy in optimizer */ else ABSORB; /* end trace */ %} FINALLY %{ if (strlen(file) > 0) { hfile = fopen(file, "w"); if(!hfile) { fprintf(stderr, "Error: %s : could not open output file '%s'\n", mccompcurname, file); } else { fprintf(hfile,"# Instrument-source: %s\n", mcinstrument_source); mcruninfo_out("# ", hfile); fprintf(hfile,"# type: array_2d(%i,6) \n",Optim_bins); fprintf(hfile,"# component: %s\n", mccompcurname); fprintf(hfile,"# title: General Optimizer distributions\n"); fprintf(hfile,"# filename: '%s'\n",file); fprintf(hfile,"# variables: x dx y dy vx dvx vy dvy vz dvz s1 ds1 s2 ds2 p dp\n"); fprintf(hfile,"# xvar: (x y vx vy vz s1 s2 p)\n"); fprintf(hfile,"# yvar: (dx dy dvx dvy dvz ds1 ds2 dp)\n"); fprintf(hfile,"# xlabel: 'Distributions'\n"); fprintf(hfile,"# ylabel: 'Counts'\n"); if (Optim_Ratio != 0) fprintf(hfile,"# Optimizer speedup : %.3g \% \n", ((double)Optim_Monitor_Counts * 100/Optim_Reference_Counts)/Optim_Ratio); fprintf(hfile,"# Absorbed neutrons : %i\n",Optim_n_absorb); fprintf(hfile,"# data: Optimzed Source\n"); for (Optim_index = 0; Optim_index < Optim_bins; Optim_index++) { fprintf(hfile,"%10.4g ",(Optim_x_min+((Optim_index+0.5)/Optim_bins)*(Optim_x_max - Optim_x_min))); fprintf(hfile,"%10i\t",Optim_Source_x[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_y_min+((Optim_index+0.5)/Optim_bins)*(Optim_y_max - Optim_y_min))); fprintf(hfile,"%10i\t",Optim_Source_y[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_vx_min+((Optim_index+0.5)/Optim_bins)*(Optim_vx_max - Optim_vx_min))); fprintf(hfile,"%10i\t",Optim_Source_vx[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_vy_min+((Optim_index+0.5)/Optim_bins)*(Optim_vy_max - Optim_vy_min))); fprintf(hfile,"%10i\t",Optim_Source_vy[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_vz_min+((Optim_index+0.5)/Optim_bins)*(Optim_vz_max - Optim_vz_min))); fprintf(hfile,"%10i\t",Optim_Source_vz[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_s1_min+((Optim_index+0.5)/Optim_bins)*(Optim_s1_max - Optim_s1_min))); fprintf(hfile,"%10i\t",Optim_Source_s1[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_s2_min+((Optim_index+0.5)/Optim_bins)*(Optim_s2_max - Optim_s2_min))); fprintf(hfile,"%10i\t",Optim_Source_s2[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_p_min+((Optim_index+0.5)/Optim_bins)*(Optim_p_max - Optim_p_min))); fprintf(hfile,"%10i\t",Optim_Source_p[Optim_index]); fprintf(hfile,"\n"); } fprintf(hfile,"# data: Reference Source\n"); for (Optim_index = 0; Optim_index < Optim_bins; Optim_index++) { fprintf(hfile,"%10.4g ",(Optim_x_min+((Optim_index+0.5)/Optim_bins)*(Optim_x_max - Optim_x_min))); fprintf(hfile,"%10i\t",Optim_Reference_x[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_y_min+((Optim_index+0.5)/Optim_bins)*(Optim_y_max - Optim_y_min))); fprintf(hfile,"%10i\t",Optim_Reference_y[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_vx_min+((Optim_index+0.5)/Optim_bins)*(Optim_vx_max - Optim_vx_min))); fprintf(hfile,"%10i\t",Optim_Reference_vx[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_vy_min+((Optim_index+0.5)/Optim_bins)*(Optim_vy_max - Optim_vy_min))); fprintf(hfile,"%10i\t",Optim_Reference_vy[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_vz_min+((Optim_index+0.5)/Optim_bins)*(Optim_vz_max - Optim_vz_min))); fprintf(hfile,"%10i\t",Optim_Reference_vz[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_s1_min+((Optim_index+0.5)/Optim_bins)*(Optim_s1_max - Optim_s1_min))); fprintf(hfile,"%10i\t",Optim_Reference_s1[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_s2_min+((Optim_index+0.5)/Optim_bins)*(Optim_s2_max - Optim_s2_min))); fprintf(hfile,"%10i\t",Optim_Reference_s2[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_p_min+((Optim_index+0.5)/Optim_bins)*(Optim_p_max - Optim_p_min))); fprintf(hfile,"%10i\t",Optim_Reference_p[Optim_index]); fprintf(hfile,"\n"); } fprintf(hfile,"# data: Passing\n"); for (Optim_index = 0; Optim_index < Optim_bins; Optim_index++) { fprintf(hfile,"%10.4g ",(Optim_x_min+((Optim_index+0.5)/Optim_bins)*(Optim_x_max - Optim_x_min))); fprintf(hfile,"%10i\t",Optim_Passing_x[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_y_min+((Optim_index+0.5)/Optim_bins)*(Optim_y_max - Optim_y_min))); fprintf(hfile,"%10i\t",Optim_Passing_y[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_vx_min+((Optim_index+0.5)/Optim_bins)*(Optim_vx_max - Optim_vx_min))); fprintf(hfile,"%10i\t",Optim_Passing_vx[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_vy_min+((Optim_index+0.5)/Optim_bins)*(Optim_vy_max - Optim_vy_min))); fprintf(hfile,"%10i\t",Optim_Passing_vy[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_vz_min+((Optim_index+0.5)/Optim_bins)*(Optim_vz_max - Optim_vz_min))); fprintf(hfile,"%10i\t",Optim_Passing_vz[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_s1_min+((Optim_index+0.5)/Optim_bins)*(Optim_s1_max - Optim_s1_min))); fprintf(hfile,"%10i\t",Optim_Passing_s1[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_s2_min+((Optim_index+0.5)/Optim_bins)*(Optim_s2_max - Optim_s2_min))); fprintf(hfile,"%10i\t",Optim_Passing_s2[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_p_min+((Optim_index+0.5)/Optim_bins)*(Optim_p_max - Optim_p_min))); fprintf(hfile,"%10i\t",Optim_Passing_p[Optim_index]); fprintf(hfile,"\n"); } fprintf(hfile,"# data: New_Source\n"); for (Optim_index = 0; Optim_index < Optim_bins; Optim_index++) { fprintf(hfile,"%10.4g ",(Optim_x_min+((Optim_index+0.5)/Optim_bins)*(Optim_x_max - Optim_x_min))); fprintf(hfile,"%10i\t",Optim_New_Source_x[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_y_min+((Optim_index+0.5)/Optim_bins)*(Optim_y_max - Optim_y_min))); fprintf(hfile,"%10i\t",Optim_New_Source_y[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_vx_min+((Optim_index+0.5)/Optim_bins)*(Optim_vx_max - Optim_vx_min))); fprintf(hfile,"%10i\t",Optim_New_Source_vx[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_vy_min+((Optim_index+0.5)/Optim_bins)*(Optim_vy_max - Optim_vy_min))); fprintf(hfile,"%10i\t",Optim_New_Source_vy[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_vz_min+((Optim_index+0.5)/Optim_bins)*(Optim_vz_max - Optim_vz_min))); fprintf(hfile,"%10i\t",Optim_New_Source_vz[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_s1_min+((Optim_index+0.5)/Optim_bins)*(Optim_s1_max - Optim_s1_min))); fprintf(hfile,"%10i\t",Optim_New_Source_s1[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_s2_min+((Optim_index+0.5)/Optim_bins)*(Optim_s2_max - Optim_s2_min))); fprintf(hfile,"%10i\t",Optim_New_Source_s2[Optim_index]); fprintf(hfile,"%10.4g ",(Optim_p_min+((Optim_index+0.5)/Optim_bins)*(Optim_p_max - Optim_p_min))); fprintf(hfile,"%10i\t",Optim_New_Source_p[Optim_index]); fprintf(hfile,"\n"); } fclose(hfile); if (Optim_Reference_Counts*Optim_Ratio) printf("Optimizer efficiency is : %.1f \% \n", ((double)Optim_Monitor_Counts * 100/Optim_Reference_Counts)/Optim_Ratio); printf("Number of ABSORB : %i\n",Optim_n_absorb); printf("Counts : reference = %i, passing = %i, monitor = %i\n", Optim_Reference_Counts, Optim_Passing_Counts, Optim_Monitor_Counts); printf("Flux : reference = %.2g, passing = %.2g, monitor = %.2g\n", Optim_Reference_Flux, Optim_Passing_Flux, Optim_Monitor_Flux); } } %} END -------------- next part -------------- /******************************************************************************* * * McStas, version 1.0, released October 26, 1998 * Maintained by Kristian Nielsen and Kim Lefmann, * Risoe National Laboratory, Roskilde, Denmark * * Component: Guide. * * Written by: KN, September 2 1998 * Modified by: KL, October 6, 1998 * * Models a rectangular guide tube centered on the Z axis. The entrance lies * in the X-Y plane. * For details on the geometry calculation see the description in the McStas * reference manual. * * INPUT PARAMETERS: * * w1: (m) Width at the guide entry * h1: (m) Height at the guide entry * w2: (m) Width at the guide exit * h2: (m) Height at the guide exit * l: (m) length of guide * R0: (1) Low-angle reflectivity * Qc: (AA-1) Critical scattering vector * alpha: (AA) Slope of reflectivity * m: (1) m-value of material. Zero means completely absorbing. * W: (AA-1) Width of supermirror cut-off * * Example values: m=4 Qc=0.02 W=1/300 alpha=6.49 R0=1 *******************************************************************************/ DEFINE COMPONENT Guide DEFINITION PARAMETERS (w1, h1, w2, h2, l, R0, Qc, alpha, m, W) SETTING PARAMETERS () STATE PARAMETERS (x,y,z,vx,vy,vz,t,s1,s2,p) TRACE %{ double t1,t2; /* Intersection times. */ double av,ah,bv,bh,cv1,cv2,ch1,ch2,d; /* Intermediate values */ double vdotn_v1,vdotn_v2,vdotn_h1,vdotn_h2; /* Dot products. */ int i; /* Which mirror hit? */ double q; /* Q [1/AA] of reflection */ double vlen2,nlen2; /* Vector lengths squared */ /* ToDo: These could be precalculated. */ double ww = .5*(w2 - w1), hh = .5*(h2 - h1); double whalf = .5*w1, hhalf = .5*h1; double lwhalf = l*whalf, lhhalf = l*hhalf; /* Propagate neutron to guide entrance. */ PROP_Z0; if(x <= -whalf || x >= whalf || y <= -hhalf || y >= hhalf) ABSORB; for(;;) { /* Compute the dot products of v and n for the four mirrors. */ av = l*vx; bv = ww*vz; ah = l*vy; bh = hh*vz; vdotn_v1 = bv + av; /* Left vertical */ vdotn_v2 = bv - av; /* Right vertical */ vdotn_h1 = bh + ah; /* Lower horizontal */ vdotn_h2 = bh - ah; /* Upper horizontal */ /* Compute the dot products of (O - r) and n as c1+c2 and c1-c2 */ cv1 = -whalf*l - z*ww; cv2 = x*l; ch1 = -hhalf*l - z*hh; ch2 = y*l; /* Compute intersection times. */ t1 = (l - z)/vz; i = 0; if(vdotn_v1 < 0 && (t2 = (cv1 - cv2)/vdotn_v1) < t1) { t1 = t2; i = 1; } if(vdotn_v2 < 0 && (t2 = (cv1 + cv2)/vdotn_v2) < t1) { t1 = t2; i = 2; } if(vdotn_h1 < 0 && (t2 = (ch1 - ch2)/vdotn_h1) < t1) { t1 = t2; i = 3; } if(vdotn_h2 < 0 && (t2 = (ch1 + ch2)/vdotn_h2) < t1) { t1 = t2; i = 4; } if(i == 0) break; /* Neutron left guide. */ PROP_DT(t1); switch(i) { case 1: /* Left vertical mirror */ nlen2 = l*l + ww*ww; q = V2Q*(-2)*vdotn_v1/sqrt(nlen2); d = 2*vdotn_v1/nlen2; vx = vx - d*l; vz = vz - d*ww; break; case 2: /* Right vertical mirror */ nlen2 = l*l + ww*ww; q = V2Q*(-2)*vdotn_v2/sqrt(nlen2); d = 2*vdotn_v2/nlen2; vx = vx + d*l; vz = vz - d*ww; break; case 3: /* Lower horizontal mirror */ nlen2 = l*l + hh*hh; q = V2Q*(-2)*vdotn_h1/sqrt(nlen2); d = 2*vdotn_h1/nlen2; vy = vy - d*l; vz = vz - d*hh; break; case 4: /* Upper horizontal mirror */ nlen2 = l*l + hh*hh; q = V2Q*(-2)*vdotn_h2/sqrt(nlen2); d = 2*vdotn_h2/nlen2; vy = vy + d*l; vz = vz - d*hh; break; } /* Now compute reflectivity. */ if(m == 0) ABSORB; if(q > Qc) { double arg = (q-m*Qc)/W; if(arg < 10) p *= .5*(1-tanh(arg))*(1-alpha*(q-Qc)); else ABSORB; /* Cutoff ~ 1E-10 */ } p *= R0; } %} MCDISPLAY %{ double x; int i; magnify("xy"); multiline(5, -w1/2.0, -h1/2.0, 0.0, w1/2.0, -h1/2.0, 0.0, w1/2.0, h1/2.0, 0.0, -w1/2.0, h1/2.0, 0.0, -w1/2.0, -h1/2.0, 0.0); multiline(5, -w2/2.0, -h2/2.0, (double)l, w2/2.0, -h2/2.0, (double)l, w2/2.0, h2/2.0, (double)l, -w2/2.0, h2/2.0, (double)l, -w2/2.0, -h2/2.0, (double)l); line(-w1/2.0, -h1/2.0, 0, -w2/2.0, -h2/2.0, (double)l); line( w1/2.0, -h1/2.0, 0, w2/2.0, -h2/2.0, (double)l); line( w1/2.0, h1/2.0, 0, w2/2.0, h2/2.0, (double)l); line(-w1/2.0, h1/2.0, 0, -w2/2.0, h2/2.0, (double)l); %} END -------------- next part -------------- /******************************************************************************* * * McStas, version 1.0, released October 26, 1998 * Maintained by Kristian Nielsen and Kim Lefmann, * Risoe National Laboratory, Roskilde, Denmark * * Component: Guide2. * * Written by: KN, September 2 1998 * Modified by: KL, October 6, 1998 * * Models a rectangular guide tube centered on the Z axis. The entrance lies * in the X-Y plane. * For details on the geometry calculation see the description in the McStas * reference manual. * * INPUT PARAMETERS: * * w1: (m) Width at the guide entry * h1: (m) Height at the guide entry * w2: (m) Width at the guide exit * h2: (m) Height at the guide exit * l: (m) length of guide * R0: (1) Low-angle reflectivity * Qc: (AA-1) Critical scattering vector * alpha: (AA) Slope of reflectivity * mh: (1) m-horizontal value of material * mv: (1) m-vertical value of material * W: (AA-1) Width of supermirror cut-off * * Example values: m=4 Qc=0.02 W=1/300 alpha=6.49 R0=1 */ DEFINE COMPONENT Guide2 DEFINITION PARAMETERS (w1, h1, w2, h2, l, R0, Qc, alpha, mh, mv, W) SETTING PARAMETERS () STATE PARAMETERS (x,y,z,vx,vy,vz,t,s1,s2,p) TRACE %{ double t1,t2; /* Intersection times. */ double av,ah,bv,bh,cv1,cv2,ch1,ch2,d; /* Intermediate values */ double vdotn_v1,vdotn_v2,vdotn_h1,vdotn_h2; /* Dot products. */ int i; /* Which mirror hit? */ double q; /* Q [1/AA] of reflection */ double vlen2,nlen2; /* Vector lengths squared */ /* ToDo: These could be precalculated. */ double ww = .5*(w2 - w1), hh = .5*(h2 - h1); double whalf = .5*w1, hhalf = .5*h1; double lwhalf = l*whalf, lhhalf = l*hhalf; /* Propagate neutron to guide entrance. */ PROP_Z0; if(x <= -whalf || x >= whalf || y <= -hhalf || y >= hhalf) ABSORB; for(;;) { /* Compute the dot products of v and n for the four mirrors. */ av = l*vx; bv = ww*vz; ah = l*vy; bh = hh*vz; vdotn_v1 = bv + av; /* Left vertical */ vdotn_v2 = bv - av; /* Right vertical */ vdotn_h1 = bh + ah; /* Lower horizontal */ vdotn_h2 = bh - ah; /* Upper horizontal */ /* Compute the dot products of (O - r) and n as c1+c2 and c1-c2 */ cv1 = -whalf*l - z*ww; cv2 = x*l; ch1 = -hhalf*l - z*hh; ch2 = y*l; /* Compute intersection times. */ t1 = (l - z)/vz; i = 0; if(vdotn_v1 < 0 && (t2 = (cv1 - cv2)/vdotn_v1) < t1) { t1 = t2; i = 1; } if(vdotn_v2 < 0 && (t2 = (cv1 + cv2)/vdotn_v2) < t1) { t1 = t2; i = 2; } if(vdotn_h1 < 0 && (t2 = (ch1 - ch2)/vdotn_h1) < t1) { t1 = t2; i = 3; } if(vdotn_h2 < 0 && (t2 = (ch1 + ch2)/vdotn_h2) < t1) { t1 = t2; i = 4; } if(i == 0) break; /* Neutron left guide. */ PROP_DT(t1); switch(i) { case 1: /* Left vertical mirror */ nlen2 = l*l + ww*ww; q = V2Q*(-2)*vdotn_v1/sqrt(nlen2); d = 2*vdotn_v1/nlen2; vx = vx - d*l; vz = vz - d*ww; break; case 2: /* Right vertical mirror */ nlen2 = l*l + ww*ww; q = V2Q*(-2)*vdotn_v2/sqrt(nlen2); d = 2*vdotn_v2/nlen2; vx = vx + d*l; vz = vz - d*ww; break; case 3: /* Lower horizontal mirror */ nlen2 = l*l + hh*hh; q = V2Q*(-2)*vdotn_h1/sqrt(nlen2); d = 2*vdotn_h1/nlen2; vy = vy - d*l; vz = vz - d*hh; break; case 4: /* Upper horizontal mirror */ nlen2 = l*l + hh*hh; q = V2Q*(-2)*vdotn_h2/sqrt(nlen2); d = 2*vdotn_h2/nlen2; vy = vy + d*l; vz = vz - d*hh; break; } /* Now compute reflectivity. */ if(q > Qc) { double arg = (q - (i <= 2 ? mv : mh)*Qc)/W; if(arg < 10) p *= .5*(1-tanh(arg))*(1-alpha*(q-Qc)); else ABSORB; /* Cutoff ~ 1E-10 */ } p *= R0; } %} END -------------- next part -------------- /*********************************************************************** * * McStas, version 1.0, released October 26, 1998 * Maintained by Kristian Nielsen and Kim Lefmann, * Risoe National Laboratory, Roskilde, Denmark * * Component: Arm * * Written by: KL, KN, September 1997 * * An arm does not actually do anything, it is just there to set * up a new coordinate system. * * Input parameters: * * (none) * ***********************************************************************/ DEFINE COMPONENT Arm DEFINITION PARAMETERS () SETTING PARAMETERS () STATE PARAMETERS () TRACE %{ %} MCDISPLAY %{ /* A bit ugly; hard-coded dimensions. */ magnify(""); line(0,0,0,0.2,0,0); line(0,0,0,0,0.2,0); line(0,0,0,0,0,0.2); %} END -------------- next part -------------- /******************************************************************************* * * McStas, version 1.0, released October 26, 1998 * Maintained by Kristian Nielsen and Kim Lefmann, * Risoe National Laboratory, Roskilde, Denmark * * Component: Mon_2foc * * Written by: KL, HMR June 16, 1997 * Rewritten by: KL Oct. 16, 1997 * Added double bent feature by: Peter Link Feb. 12,1999 * * Double bent monochromator which uses a small-mosaicity approximation as well as * the approximation vy^2 << vz^2 + vx^2. * Second order scattering is neglected. * For an unrotated monochromator component, the crystal plane lies in the y-z * plane (ie. parallel to the beam). * * INPUT PARAMETERS: * * zwidth: (horizontal) width of an individual slab * ywidth: (vertical) heigth of an individual slab * gap : typical gap between adjacent slabs * NH : number of slabs horizontal ( columns ) * NV : number of slabs vertical ( rows ) * mosaich: Horisontal mosaic (FWHM) (arc minutes) * mosaicv: Vertical mosaic (FWHM) (arc minutes) * R0: Maximum reflectivity (1) * Q: Scattering vector (AA-1) * RV : radius of vertical focussing (m) * RH : radius of horizontal focussing (m) * *******************************************************************************/ DEFINE COMPONENT Mon_2foc DEFINITION PARAMETERS (zwidth, ywidth, gap, NH, NV, mosaich, mosaicv, r0, Q, RV, RH) SETTING PARAMETERS () STATE PARAMETERS (x,y,z,vx,vy,vz,t,s1,s2,p) DECLARE %{ #define DIV_CUTOFF 2 /* ~ 10^-5 cutoff. */ %} TRACE %{ double dphi,tmp1,tmp2,tmp3,vratio,phi,theta0,theta,v,cs,sn; double zmin,zmax,ymin,ymax,zp,yp,row,col; double tilth,tiltv; /* used to calculate tilt angle of slab */ double sna,snb,csa,csb; double old_x = x, old_y = y, old_z = z, old_t = t; double dt; if(vx != 0.0 && (dt = -x/vx) >= 0.0) { zmax = ((NH*(zwidth+gap))-gap)/2; zmin = -1*zmax; ymax = ((NV*(ywidth+gap))-gap)/2; ymin = -1*ymax; y += vy*dt; z += vz*dt; t += dt; x = 0.0; zp = fmod ( (z-zmin),(zwidth+gap) ); yp = fmod ( (y-ymin),(ywidth+gap) ); /* hit a slab or a gap ? */ if (z>zmin && zymin && y DIV_CUTOFF) { x = old_x; y = old_y; z = old_z; t = old_t; } else { p *= r0*exp(-tmp3*tmp3*4*log(2)); /* Use mosaics */ tmp1 = 2*theta; cs = cos(tmp1); sn = sin(tmp1); tmp2 = cs*vx - sn*vz; vy = vy; vz = cs*vz + sn*vx; vx = tmp2; /* Second: scatering out of plane. Approximation is that Debye-Scherrer cone is a plane */ phi = atan2(vy,vz); /* out-of plane angle */ dphi = (MIN2RAD*mosaicv)/(2*sqrt(2*log(2)))*randnorm(); /* MC choice: */ /* Vertical angle of the crystallite */ vy = vz*tan(phi+2*dphi*sin(theta)); vratio = v/sqrt(vx*vx+vy*vy+vz*vz); vz = vz*vratio; vy = vy*vratio; /* Renormalize v */ vx = vx*vratio; } /* rotate v coords back */ vx = vx*csb*csa-vy*snb*csa+vz*sna; vy = vx*snb+vy*csb; vz = -vx*csb*sna+vy*snb*sna+vz*csa; } else { x = old_x; y = old_y; z = old_z; t = old_t; } } %} END -------------- next part -------------- /******************************************************************************* * * McStas, version 1.1, released * Maintained by Kristian Nielsen and Kim Lefmann, * Risoe National Laboratory, Roskilde, Denmark * * Component: Monitor_Optimizer * * Written by: EF, 17 Sept 1999 * * A component that optimizes the neutron flux passing through the * Source_optimizer in order to have the maximum flux at the * Monitor_Optimizer position. * Source_optimizer should be placed just after the source. * Monitor_Optimizer should be placed at position to optimize. * * INPUT PARAMETERS: * * xmin: Lower x bound of detector opening (m) * xmax: Upper x bound of detector opening (m) * ymin: Lower y bound of detector opening (m) * ymax: Upper y bound of detector opening (m) * * OUTPUT PARAMETERS: * * distributions, optimizer efficiency * *******************************************************************************/ DEFINE COMPONENT Monitor_Optimizer DEFINITION PARAMETERS (xmin, xmax, ymin, ymax) SETTING PARAMETERS () STATE PARAMETERS (x,y,z,vx,vy,vz,t,s1,s2,p) DECLARE %{ #ifndef MCSTAS_GEN_OPTIM #error McStas : Source_Optimizer component has to be used before Monitor_Optimizer #endif %} INITIALIZE %{ %} TRACE %{ PROP_Z0; if (x>xmin && xymin && y= Optim_bins) Optim_index = Optim_bins - 1; Optim_New_Source_vx[Optim_index]++; if (Optim_vy_max-Optim_vy_min) Optim_index = (int)rint(Optim_bins * (Optim_vy -Optim_vy_min)/(Optim_vy_max-Optim_vy_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; Optim_New_Source_vy[Optim_index]++; if (Optim_vz_max-Optim_vz_min) Optim_index = (int)rint(Optim_bins * (Optim_vz -Optim_vz_min)/(Optim_vz_max-Optim_vz_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; Optim_New_Source_vz[Optim_index]++; if (Optim_x_max-Optim_x_min) Optim_index = (int)rint(Optim_bins * (Optim_x -Optim_x_min)/(Optim_x_max-Optim_x_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; Optim_New_Source_x[Optim_index]++; if (Optim_y_max-Optim_y_min) Optim_index = (int)rint(Optim_bins * (Optim_y -Optim_y_min)/(Optim_y_max-Optim_y_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; Optim_New_Source_y[Optim_index]++; if (Optim_s1_max-Optim_s1_min) Optim_index = (int)rint(Optim_bins * (Optim_s1 -Optim_s1_min)/(Optim_s1_max-Optim_s1_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; Optim_New_Source_s1[Optim_index]++; if (Optim_s2_max-Optim_s2_min) Optim_index = (int)rint(Optim_bins * (Optim_s2 -Optim_s2_min)/(Optim_s2_max-Optim_s2_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; Optim_New_Source_s2[Optim_index]++; if (Optim_p_max-Optim_p_min) Optim_index = (int)rint(Optim_bins * (Optim_p -Optim_p_min)/(Optim_p_max-Optim_p_min)); else Optim_index = 0; if (Optim_index < 0) Optim_index = 0; if (Optim_index >= Optim_bins) Optim_index = Optim_bins - 1; Optim_New_Source_p[Optim_index]++; } /* end if Optim_Phase */ } /* end if xy in optimizer */ /* end trace */ %} FINALLY %{ /* initial Reference distribution arrays (for weights) */ free(Optim_Reference_x); free(Optim_Reference_y); free(Optim_Reference_vx); free(Optim_Reference_vy); free(Optim_Reference_vz); free(Optim_Reference_s1); free(Optim_Reference_s2); free(Optim_Reference_p); /* optimized Source distribution arrays (to reach) */ free(Optim_Source_x); free(Optim_Source_y); free(Optim_Source_vx); free(Optim_Source_vy); free(Optim_Source_vz); free(Optim_Source_s1); free(Optim_Source_s2); free(Optim_Source_p); /* optimized New_Source distribution arrays (to reach in next step, passed to Source) */ free(Optim_New_Source_x); free(Optim_New_Source_y); free(Optim_New_Source_vx); free(Optim_New_Source_vy); free(Optim_New_Source_vz); free(Optim_New_Source_s1); free(Optim_New_Source_s2); free(Optim_New_Source_p); /* Passing distribution arrays (should grow to reach Source) */ free(Optim_Passing_x); free(Optim_Passing_y); free(Optim_Passing_vx); free(Optim_Passing_vy); free(Optim_Passing_vz); free(Optim_Passing_s1); free(Optim_Passing_s2); free(Optim_Passing_p); %} END -------------- next part -------------- /******************************************************************************* * * McStas, version 1.0, released October 26, 1998 * Maintained by Kristian Nielsen and Kim Lefmann, * Risoe National Laboratory, Roskilde, Denmark * * Component: PSD_monitor * * Written by: KL, Feb 3, 1998 * * An (n times m) pixel PSD monitor. This component may also be used as a beam * detector. * * INPUT PARAMETERS: * * xmin: Lower x bound of detector opening (m) * xmax: Upper x bound of detector opening (m) * ymin: Lower y bound of detector opening (m) * ymax: Upper y bound of detector opening (m) * nx: Number of pixel columns (1) * ny: Number of pixel rows (1) * filename: Name of file in which to store the detector image (text) * * OUTPUT PARAMETERS: * * PSD_N: Array of neutron counts * PSD_p: Array of neutron weight counts * PSD_p2: Array of second moments * *******************************************************************************/ DEFINE COMPONENT PSD_monitor DEFINITION PARAMETERS (xmin, xmax, ymin, ymax, nx, ny, filename) SETTING PARAMETERS () OUTPUT PARAMETERS (PSD_N, PSD_p, PSD_p2) STATE PARAMETERS (x,y,z,vx,vy,vz,t,s1,s2,p) DECLARE %{ int PSD_N[nx][ny]; double PSD_p[nx][ny]; double PSD_p2[nx][ny]; %} INITIALIZE %{ int i,j; for (i=0; ixmin && xymin && yxmin && xymin && y= 0 && i < nchan) { E_N[i]++; E_p[i] += p; E_p2[i] += p*p; } } %} FINALLY %{ DETECTOR_OUT_1D( "Energy monitor", "Energy [meV]", "Intensity", "E", Emin, Emax, nchan, &E_N[0],&E_p[0],&E_p2[0], filename); %} MCDISPLAY %{ magnify("xy"); multiline(5, (double)xmin, (double)ymin, 0.0, (double)xmax, (double)ymin, 0.0, (double)xmax, (double)ymax, 0.0, (double)xmin, (double)ymax, 0.0, (double)xmin, (double)ymin, 0.0); %} END -------------- next part -------------- /******************************************************************************* * * McStas, version 1.1, released * Maintained by Kristian Nielsen and Kim Lefmann, * Risoe National Laboratory, Roskilde, Denmark * * Component: Divergence_monitor * * Written by: KL, Nov. 11, 1998 * * A divergence sensitive monitor. The counts are distributed in * (n times m) pixels. * * INPUT PARAMETERS: * * xmin: Lower x bound of detector opening (m) * xmax: Upper x bound of detector opening (m) * ymin: Lower y bound of detector opening (m) * ymax: Upper y bound of detector opening (m) * nv: Number of pixel columns (1) * nh: Number of pixel rows (1) * v_maxdiv Maximal vertical divergence detected (degrees) * h_maxdiv Maximal vertical divergence detected (degrees) * filename: Name of file in which to store the detector image (text) * * OUTPUT PARAMETERS: * * Div_N: Array of neutron counts * Div_p: Array of neutron weight counts * Div_p2: Array of second moments * *******************************************************************************/ DEFINE COMPONENT Divergence_monitor DEFINITION PARAMETERS (xmin, xmax, ymin, ymax, nh, nv, h_maxdiv, v_maxdiv, filename) SETTING PARAMETERS () OUTPUT PARAMETERS (Div_N, Div_p, Div_p2) STATE PARAMETERS (x,y,z,vx,vy,vz,t,s1,s2,p) DECLARE %{ int Div_N[nh][nv]; double Div_p[nh][nv]; double Div_p2[nh][nv]; %} INITIALIZE %{ int i,j; for (i=0; ixmin && xymin && y -h_maxdiv && v_div < v_maxdiv && v_div > -v_maxdiv) { i = floor((h_div + h_maxdiv)*nh/(2.0*h_maxdiv)); j = floor((v_div + v_maxdiv)*nv/(2.0*v_maxdiv)); Div_N[i][j]++; Div_p[i][j] += p; Div_p2[i][j] += p*p; } } %} FINALLY %{ DETECTOR_OUT_2D( "Divergence monitor", "X divergence [deg]", "Y divergence [deg]", -h_maxdiv, h_maxdiv, -v_maxdiv, v_maxdiv, nh, nv, &Div_N[0][0],&Div_p[0][0],&Div_p2[0][0], filename); %} MCDISPLAY %{ magnify("xy"); multiline(5, (double)xmin, (double)ymin, 0.0, (double)xmax, (double)ymin, 0.0, (double)xmax, (double)ymax, 0.0, (double)xmin, (double)ymax, 0.0, (double)xmin, (double)ymin, 0.0); %} END -------------- next part -------------- /******************************************************************************* * * McStas, version 1.1, released * Maintained by Kristian Nielsen and Kim Lefmann, * Risoe National Laboratory, Roskilde, Denmark * * Component: kw_monitor * * Written by: EF, 17 Sept 1999 * * A monitor that list all neutron (k,w). * Output is a 2D matrix of lines [ kx ky kz Omega Intensity DeltaIntensity ] * stored if a file. The integrated flux is also measured. * * INPUT PARAMETERS: * * xmin: Lower x bound of detector opening (m) * xmax: Upper x bound of detector opening (m) * ymin: Lower y bound of detector opening (m) * ymax: Upper y bound of detector opening (m) * filename: Name of file in which to store the counts (text) * * OUTPUT PARAMETERS: * * Nsum: Integrated neutron counts * psum: Integrated neutron weight counts * p2sum: Integrated second moments * *******************************************************************************/ DEFINE COMPONENT kw_monitor DEFINITION PARAMETERS (xmin, xmax, ymin, ymax, filename) SETTING PARAMETERS () OUTPUT PARAMETERS (Nsum, psum, p2sum) STATE PARAMETERS (x,y,z,vx,vy,vz,t,s1,s2,p) DECLARE %{ int nlines; int Nsum; double psum, p2sum; FILE *file; double kx, ky, kz, E; %} INITIALIZE %{ psum = 0; p2sum = 0; Nsum = 0; nlines = 0; file = fopen(filename, "w"); if(!file) { fprintf(stderr, "Error: %s : could not open output file '%s'\n", mccompcurname, filename); exit(-1); } else { fprintf(file,"# Instrument-source: %s\n", mcinstrument_source); mcruninfo_out("# ", file); fprintf(file,"# type: array_2d(-1,6) (See end of file for exact dimensions)\n"); fprintf(file,"# component: %s\n", mccompcurname); fprintf(file,"# title: Resolution (\\vec{k},omega) Monitor\n"); fprintf(file,"# filename: '%s'\n",filename); fprintf(file,"# variables: Kx Ky Kz E I I_err\n"); fprintf(file,"# xvar: (Kx Ky Kz E)\n"); fprintf(file,"# yvar: (I,I_err)\n"); fprintf(file,"# xlabel: 'Wavevector [Angs-1], Energie [meV]'\n"); fprintf(file,"# ylabel: 'Intensity'\n"); } %} TRACE %{ PROP_Z0; if (x>xmin && xymin && y Message-ID: <37E0D1CC.151E518E@ill.fr> An HTML attachment was scrubbed... URL: