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
|