Change starting position of source from phase-space file

Dear @samuel_grima,

Aiming to solve your question, I propose here an approach that uses as reference the example file included in your 2-step simulation post. The main differences are the following:

  1. This simulation has two fully independent steps, with two input files. The step 1 emulates and scores the photon spectrum in the output of the X-ray tube, while step 2 focuses on the interaction of the X rays on the detector.
  2. In the step 1 file, for simplicity, the whole geometry can be placed such that the detector centre is in (0,0,0). Besides, a new ‘OUTPUT’ region shall be defined where the photon fluence shall be scored. To my understanding, this should be placed inside the COLLIM hole.
  3. As in the example, the step 1 file requires the USERDUMP card, together with the mgdraw user routine. You only need to adjust the region numbers:
      IF (JTRACK .EQ. 7) THEN !Particle code for photon
         IF (MREG .EQ. 3 .AND. NEWREG .EQ. 2) THEN !Region number for TARGET and VOID
            !Particle ID, momentum, coordinate-x, -y, -z, direction-x,
            ! -y, -z, weight
            WRITE(90,*) JTRACK, PTRACK, XSCO, YSCO, ZSCO, CXTRCK,
     &                  CYTRCK, CZTRCK, WTRACK             
         END IF
      END IF
  1. The step 2 file shall contain only the detailed detector geometry, together with the scoring cards you may want to use. As in the example, the SOURCE card is needed to enable the user source routine, which will use the output file of first stage.
  2. A way to simplify the effect of changing the beam angle in the user routine is to rotate the detector, instead of rotating the beam. This can be parametrised with a single number since the detector is placed in (0,0,0) and can be simply done with the ROT-DEFI card and start_transform directive. If you use USRBIN/EVENTBIN scorings, these need to be rotated as well with the card ROTPRBIN.
  3. At the end, you have to combine the results with the proper normalisation. Last but not least, note that the two steps could be merged in a simple input file, as it is done in the example.

I hope this is clear enough. Please let me know if the approach makes sense to you and should you need further support to implement it.

Regards,
Mario Sacristan