How to define particle source geometry?

Hi all,
I use G4GeneralParticleSource() and UI command to define the geometry of particle source in shape of square. The UI commnads are

/gps/pos/type Plane
/gps/pos/shape Square
/gps/pos/centre 0. 2. 3. mm
/gps/pos/halfz 1. mm
/gps/pos/halfx 1. mm

But it returns a line insteads of square as the picture shown. from the picture we can see that /gps/pos/halfx 1. mm works, but /gps/pos/halfz 1. mm didn’t work.
How can I fix this?

Hi

I think, i.e., a bit of a guess…because you specified “Square”, the relevant parameters are:
/gps/pos/halfx 1. mm
/gps/pos/halfy 1. mm
which refers to the x and y in the square. You may then have to orient the square to be perpendiculer to the x-axis.

Give it a try. Hope that helps.

John

Hi @allison,
I want a square in the XZ plane. I thought my code would work, but it doesn’t. Shoud I first create the square in the XY plane and then rotate it? But how to rotate the square?

Yes, I think that’s the way - define it in its x-y plane then rotate it. How to do that? I think it can be done but all I can suggest is to look at the GPS documentation and figure out out. Just try a few things.

Hi @allison,
Now I can make in Square in the XZ plane, but the source direction also changed. It’s very complicated. I want the the square in the XZ plane and the source goes towards XZ plane, but now the source goes towards XY plane.
My UI commands are

/gps/particle gamma
/gps/ang/mintheta  0.785 rad
/gps/ang/maxtheta 2.355 rad
/gps/ang/minphi 0.785 rad
/gps/ang/maxphi 2.355 rad
#user defined angle distribution(hist)
/gps/ang/type user
/gps/hist/type theta
/control/execute theta_command.mac
/gps/pos/type Plane
/gps/pos/centre 0. 2. 3. mm
/gps/pos/shape Square
/gps/pos/halfx 1. mm
/gps/pos/halfy 1. mm
/gps/pos/rot1 1 0 0
/gps/pos/rot2 0 0 1
#energy hist
/gps/ene/type Arb
/gps/hist/type arb
/gps/hist/point 0.01 2.
/gps/hist/point 0.02 5.
/gps/hist/point 0.06 1.
/gps/hist/point 0.09 1.
/gps/hist/inter Log

The original direction is right, but now the source direction is wrong.

I solved this problem by myself. After rotate the square plane, the source direction will also be changed since the inside XYZ axises have been changed. In my case x->x’, y->z’,z->y’. So the UI commands should be

#define particle source
/gps/particle gamma
/gps/ang/mintheta  2.355 rad
/gps/ang/maxtheta 3.14 rad
/gps/ang/minphi 0. rad
/gps/ang/maxphi 6.28 rad
#user defined angle distribution(hist)
/gps/ang/type user
/gps/hist/type theta
/control/execute theta_command.mac
/gps/pos/type Plane
/gps/pos/centre 0. 0. 3. mm
/gps/pos/shape Square
/gps/pos/halfx 7. um
/gps/pos/halfy 7. um
/gps/pos/rot1 1 0 0
/gps/pos/rot2 0 0 1

:+1: Well done.

John

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.