File: Focus.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 (106 lines) | stat: -rw-r--r-- 2,564 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*****************************************************************************
*
* McXtrace, x-ray tracing package
*         Copyright, All rights reserved
*         DTU Physics, Kgs. Lyngby, Denmark
*         Synchrotron SOLEIL, Saint-Aubin, France
*
* Component: Focus
*
* %Identification
* Written by: Carsten Detlefs, hacked from slit.comp
* Date: November 6, 2013
* Origin: ESRF
* Release: McXtrace 1.1
*
* Turn a photon into a Huygens wavelet. To be used with the SPLIT keyword.
* 
* %Description
* Changes direction of the photon to a random direction
* towards the specified target area.
* To be used in coherent simulations, preferably with
* the SPLIT keyword.
*
* %Parameters
* INPUT PARAMETERS
*
* dist: [m] distance to target
* focus_xw: [m] x-width of target
* focus_yh: [m] y-height of target
* focus_x0: [m] x-center of target
* focus_y0: [m] y-center of target
* focus_absolute: [ ] Flag - if non-zero, focus_x0 and focus_y0 are in absolute (lab) coordinates.
* %End
*******************************************************************************/
DEFINE COMPONENT Focus
SETTING PARAMETERS (dist=0.0, focus_xw=0.0, focus_yh=0.0, focus_x0=0.0, focus_y0=0.0, int focus_absolute=1) 

/* X-ray parameters: (x,y,z,kx,ky,kz,phi,t,Ex,Ey,Ez,p) */ 

DECLARE
%{
 // nothing to declare.
%}

INITIALIZE
%{
  if ((fabs(focus_xw) < 0) || (fabs(focus_yh) < 0)) {
    fprintf(stderr,"%s: you have to specify a target area\n", NAME_CURRENT_COMP); 
    exit(0);
  }
%}

TRACE
%{
  double k;
  double posx,posy,posz,pdir;

  PROP_Z0;

  /*
   * length of wave vector 
   */
  k = sqrt(kx*kx + ky*ky + kz*kz);

  /*
   * "focus" target code stolen from slit.comp
   */
  if (focus_absolute){
      /*x0,y0 are given in the laboratory system (default)*/
     /*
      * focusing occurs only through the phase shift introduced above
      */
     coords_get(POS_A_CURRENT_COMP,&posx,&posy,&posz);
  }else{
      /*x0,y0 are relative to the present component*/
      posx=0;posy=0;
  }

  /*
   * we have a target, so we now consider the 
   * ray a Huygens wavelet.
      */
  double xf,yf,zf;
  if (fabs(focus_xw)>DBL_EPSILON || fabs(focus_yh)>DBL_EPSILON){
      randvec_target_rect_real(&xf, &yf, &zf, &pdir,
              focus_x0-posx,focus_y0-posy,dist, focus_xw, focus_yh, 
              ROT_A_CURRENT_COMP, x, y, z, 0);
  }else{
      xf=focus_x0-posx;yf=focus_y0-posy;zf=dist;
  }
  kx=(xf-x); ky=(yf-y); kz=(zf-z);
  NORM(kx,ky,kz);
  kx*=k;ky*=k;kz*=k;

  SCATTER;
%}


MCDISPLAY
%{
 // nothing to display, really
  
  rectangle("xy",0,0,0,2.0,2.0);
%}

END