MCNPX Transformation

  • #1
ifa23
4
1
Hello, I doing my thesis, I'm beginner in MCNPX. I want to ask about transformation in MCNPX, I want to transform this head phantom in inside and outside field ( radiation using LINAC from face to ear) in angle 90° and 270 °. Can anyone help me to solve this problem with transformation code?
 

Attachments

  • IMG_20240504_142905.jpg
    IMG_20240504_142905.jpg
    30.9 KB · Views: 5
Engineering news on Phys.org
  • #2
Hi @ifa23 ,
Welcome to physicsforums. If you can share your input file, or a simplified version of the file, you can add .txt to the name and attach to a post. If not that is also fine, but our answers will be more general.

Do you understand rotation matrices?

If you create a TR card, which has a translation vector (three numbers) followed by a rotation matrix (nine numbers) you can put TRCL keywords into the cell definitions of the head. If the head is in it's own universe you can just rotate that.

Those angles are multiples of 90 degrees, so the rotation matrix cosines will be +/-1's and 0's. The translation vector will depend on where the cells of the head are relative to the origin.

Does that make sense?
 
  • Informative
Likes berkeman
  • #3
Here it is. Before I write this problem to forum. i have tried but got the wrong transformation, head phantom has rotate to right/left side like this not in inside/outside, please check my code, i guess wrote the wrong code in TR code
 
  • #4
ifa23 said:
Here it is.
Is it invisible?
 
  • Like
Likes Alex A
  • #5
sorry, here it is. thankyou
 

Attachments

  • TA_SSD_100_15_90.txt
    16.1 KB · Views: 3
  • Like
Likes Alex A
  • #6
So the basic 2D rotation matrix is,
Code:
cos  sin
-sin cos
So the do nothing rotation by 0 degrees is
Code:
1 0
0 1

In 3D we have a 3x3 matrix and we can think of it as,
Code:
xx yx zx
xy yy zy
xz yz zz
I have a symmetry error with my explanation, and it turns out I need to review matrix transforms, whoops.

Our subject with no tr card is facing the +z direction, into the beam with eyes on the x=17.9 plane. To rotate right by 90 degrees is the same as multiplying y by -1 and calling it z', and multiplying z by 1 and calling it y'. (and also multiplying x by 1 and calling it x').

Code:
1 0 0
0 0 1
0 -1 0
(except this actually rotates the head left)

Because this swings everything around the origin, we need a displacement vector. So let's keep the cancer cell in the same position and if you want something different, you can recalculate.

It starts at,
15 0 -100.595
and ends at,
15 100.595 0
(I had to fudge this to match what is happening)
Subtracting the destination we don't want from the original we do want gives us the displacement vector,
0 -100.595 -100.595
and that gets us the tr card,
Code:
tr1 0 -100.595 -100.595 1 0 0 0 0 1 0 -1 0

Doing a tr in degrees doesn't help much in this case because the angles are really simple cos 90 = 0, cos 0 = 1, and you still have to understand how a matrix transform works.

Edit,
I've done a double check and do not know why there is a symmetry error in what I've done.
It turns left, not right and I will review tomorrow.
 
Last edited:
  • Informative
  • Like
Likes PSRB191921 and berkeman
  • #7
It seems logical that TR would take the transform we want MCNP to do on the alternative coordinate system to convert it to the global one. It doesn't. It takes the transform that creates the alternative coordinate from the global one. The program inverts the matrix by transposition (rotation matrices are orthogonal so this is correct) and that is the transform that is applied.

Or to put it another way, this is the transform that is applied to the surface coordinates,
Code:
x',x  x',y  x',z
y',x  y',y  y',z
z',x  z',y  z',z

Where x' y' z' are the surface card numbers in 'alternative coordinates' which get transformed into x y z global coordinates before the translation vector is applied.

If you haven't been taught any matrix maths, this will look awful, please do ask if if you want more help. The example in my last post succeeds because a left turn by 90 degrees is the inverse of a right turn by 90 degrees.

Edit, transposed matrix twice.
 
Last edited:
  • #8
Ok, thank you for the explanation. I have learned matrix rotation before that. So, if i want to rotate the head phantom in 270 degrees, the rotation matrix will seems like that right?
Code:
[0  1  0]
[-1  0  0]
[0  0 -1]

the TR code
Code:
tr1 0 -100.595 -100.595 0 1 0 -1 0 0 0 0 -1

I have tried in MCNPX, but any error, the phantom not appear, may i wrong when doing rotation matrix?
 
  • #9
That is -y' maps to x, x' becomes y and -z' becomes z.

With +y axis up and +x axis to the right that is a 90 degree anticlockwise (or 270 clockwise) rotation in the xy plane, and a mirror flip in z.

The translation needed is then Original - Destination, because if you start with something at 2 and it ends up at 15, if you subtract 15 and then add 2 it ends up back where it was.

Start point of cancer cell is,
15 0 -100.595
End point after rotation,
0 -15 100.595
Original - Destination is,
15 15 -201.19

I don't don't know that the cancer cell is in the right place to start with, or that you want to keep it in that place, but we need some part of the phantom to do the calculation on. It makes the TR card,
Code:
tr1 15 15 -201.19 0 1 0 -1 0 0 0 0 -1

Edit, rechecked and I'd transposed the matrix twice in my post above so I had the direction of rotation wrong. Both posts are fixed. Hopefully.
 
Last edited:

Similar threads

  • Nuclear Engineering
Replies
5
Views
1K
Replies
3
Views
2K
  • Nuclear Engineering
Replies
1
Views
1K
  • New Member Introductions
Replies
1
Views
308
Replies
4
Views
868
Replies
19
Views
1K
  • Introductory Physics Homework Help
2
Replies
36
Views
912
  • Engineering and Comp Sci Homework Help
Replies
1
Views
876
  • Programming and Computer Science
Replies
1
Views
3K
  • Nuclear Engineering
Replies
2
Views
2K
Back
Top