MCNPX Transformation

In summary, "MCNPX Transformation" refers to the advancements and enhancements made to the MCNPX (Monte Carlo N-Particle Transport Code) software, which is widely used for simulating the interaction of radiation with matter. The transformation involves updates that improve its computational efficiency, accuracy, and usability for a variety of applications, including medical physics, nuclear engineering, and radiation protection. Key features may include enhanced algorithms, user-friendly interfaces, and expanded capabilities for modeling complex systems.
  • #1
ifa23
8
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: 44
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: 37
  • 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:
  • #10
Sorry, after i try to learn more to rotate 270 degree, i'm still confused and got stuck to code
Alex A said:
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.
Sorry, after i try to learn more to rotate 270 degree, i'm still confused and got stuck to code. For example in your TR code above is 90 degree rotation anticlockwise, so if i want to make 270 degree it's mean that i doing rotate 90 degree clockwise, right? this code that you write is right, i want to cancer cell same at the position, only rotate the phantom. with your code here, if i want to rotate in 270 degree how it works? i followed your step above, but nothing change in phantom, can you give me solution, please? thankyou
 
  • #11
Ok, you have tried "tr1 0 -100.595 -100.595 1 0 0 0 0 1 0 -1 0" and that works as a left turn by 90 degrees?

Show me every step you did to get an anticlockwise 270 degree turn (a 90 degree turn right).
 
  • #12
Alex A said:
Ok, you have tried "tr1 0 -100.595 -100.595 1 0 0 0 0 1 0 -1 0" and that works as a left turn by 90 degrees?

Show me every step you did to get an anticlockwise 270 degree turn (a 90 degree turn right).
"tr1 0 -100.595 -100.595 1 0 0 0 0 1 0 -1 0" the code works as a right turn by 90 degrees ( in front of the screen). then i want to rotate this phantom turn left by 90 degrees (behind of screen), so if turn right by 90 degrees, eyes organ is visible, but if turn left by 90 degrees, eyes organ invisible. I have succeeded in turning the phantom 90 degrees to the right, but have not succeeded in turning it 90 degrees to the left (270). This file is the result of rotating the phantom 90 degrees to the right. I really hope for your help. Thankyou
 

Attachments

  • TA_SSD_100_15_90 - MAT1.txt
    18.2 KB · Views: 25
  • #13
That file does "tr1 0 100.595 -100.595 1 0 0 0 0 1 0 1 0 ". If you copied that from me it looks like one of my mistakes. It looks like a left turn and a mirror flip in y, not a true right turn.

Try the left turn quoted, and if you switch the signs of y and z in the matrix (and fix the vector) it will turn the other way.
 
  • #14
OK thankyou, But the code you demonstrated is exactly what I want, let's say the code in the file is a 90 degree rotation to the left, I also want to make it 90 degrees to the right, the opposite of the phantom image of the file, how do I solve it? because I've tried changing the coordinates ( x y z) and changing the vector matrix but it still doesn't work, instead the phantom doesn't appear, I don't know what else to do.
 
  • #15
If the phantom doesn't appear you have made a mistake calculating the vector. Show me the steps you did and let's find out why it didn't work.
 

FAQ: MCNPX Transformation

What is MCNPX Transformation?

MCNPX Transformation refers to the process of converting input files and data from the MCNPX (Monte Carlo N-Particle Transport Code) format to other formats or adapting it for specific applications, such as radiation transport simulations in various environments. This transformation is essential for integrating MCNPX with other software tools or for preparing data for analysis.

Why is MCNPX Transformation important?

MCNPX Transformation is important because it allows researchers and engineers to utilize the powerful Monte Carlo simulation capabilities of MCNPX in conjunction with other modeling tools, facilitating more comprehensive analyses. It also helps in optimizing input data for specific scenarios, improving accuracy and efficiency in simulations.

What are common applications of MCNPX Transformation?

Common applications include medical physics for radiation therapy planning, nuclear engineering for reactor design and safety analysis, radiation shielding studies, and particle transport simulations in various fields such as astrophysics and environmental science.

What tools are available for MCNPX Transformation?

Several tools and scripts are available for MCNPX Transformation, including custom-built Python scripts, software packages like Geant4 for particle simulations, and other data processing tools that can handle MCNPX output. Some users also create their own conversion scripts to meet specific needs.

How can I learn more about MCNPX Transformation?

To learn more about MCNPX Transformation, you can refer to the official MCNPX documentation, participate in forums and user groups, attend workshops and conferences related to Monte Carlo simulations, and explore academic papers that discuss case studies and methodologies involving MCNPX.

Similar threads

Back
Top