File: Derotator.comp

package info (click to toggle)
mccode 3.5.19%2Bds5-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,113,256 kB
  • sloc: ansic: 40,697; python: 25,137; yacc: 8,438; sh: 5,405; javascript: 4,596; lex: 1,632; cpp: 742; perl: 296; lisp: 273; makefile: 226; fortran: 132
file content (61 lines) | stat: -rw-r--r-- 1,692 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*******************************************************************************
*
* McStas, neutron ray-tracing package
*         Copyright (C) 1997-2007, All rights reserved
*         Risoe National Laboratory, Roskilde, Denmark
*         Institut Laue Langevin, Grenoble, France
*
* Component: Derotator
*
* %I
*
* Date: June 20th 2013
* Written by: Emmanuel Farhi
* Origin: <a href="http://www.ill.fr">ILL</a>
*
* The counterpart of the Rotator component.
*
* %Description
* A component which stops the rotative frame set by the Rotator component.
* Its position should better coincide with the Rotator instance.
* Components preceding the Derotator are rotating, all following are steady.
*
* Example:
*   R=Rotator(nu=14, phase=0)
*   ...
*   DR=Derotator(rotator="R")
*   AT (0,0,0) RELATIVE R
*
* %Parameters
* INPUT PARAMETERS:
* rotator: [string]  the name of the Rotator component used to initiate the rotation
*
* CALCULATED PARAMETERS:
* angle: [deg]          rotation angle
*
* %End
*******************************************************************************/

DEFINE COMPONENT Derotator
SETTING PARAMETERS (string rotator)
/* Neutron parameters: (x,y,z,vx,vy,vz,t,sx,sy,sz,p) */

TRACE
%{
  Rotation R;

  /* Name of Rotation uservar */
  char* Rot_varptr = *COMP_GETPAR3(Rotator, rotator, rot_var);

  /* Invert rotation matrix for use in derotation */
  rot_transpose(*(Rotation *) particle_getvar_void(_particle, Rot_varptr, NULL), R);

  /* apply rotation to centered coordinates */
  Coords tmp = coords_set(x,y,z);
  coords_get(rot_apply(R, tmp), &x, &y, &z);
  /* rotate speed */
  tmp = coords_set(vx,vy,vz);
  coords_get(rot_apply(R, tmp), &vx, &vy, &vz);
%}

END