How to rotate a source in a macro file?

How do I rotate a source? I cannot figure out what exactly /gps/ang/rot1 and rot2 do. The documentation says they define a rotation matrix, but I’m not clear on how they do this.

For reference all I want to do is make a square planar source face 180 deg the other direction.

1 Like

try to redirect the source with the command

/gps/direction -1 0 0

or whatever axis you want to point it along. note that you also need to rotate the (square) plane, but for 180 degrees you can probably skip that. otherwise it would be the

/gps/pos/rot1 R1x R1y R1z
/gps/pos/rot2 R2x R2y R2z

commands. you probably want to have the two vectors perpendicular to the direction.

I am not sure on the /gps/ang/rot, but my guess is the 2 vectors again define a plane, with the third vector being perpendicular to the plane. my second guess is, this affects the angular distribution of the source.

So that seems to make all of the particles fire at the same angle. My goal is to fire a number of particles from a planar source at random angles, so that the angular distribution is isotropic (I’m not sure what iso does, but it doesn’t actually seem give you an isotropic distribution). So I thought I would use the histogram utility, but that didn’t initially seem to work. However, after running the following script this seems to do about what I want:
/gps/particle gamma
/gps/pos/type Plane
/gps/pos/shape Square
/gps/pos/centre 0 0 -35.0 cm
/gps/pos/halfx 12.0 cm
/gps/pos/halfy 12.0 cm

/gps/ang/type user
/gps/hist/type theta
/gps/hist/point 0. 0.
/gps/hist/point .25 0.
/gps/hist/point .5 0.
/gps/hist/point .75 0.
/gps/hist/point 1. 0.
/gps/hist/point 1.25 0.
/gps/hist/point 1.5707 0.
/gps/hist/point 1.6 1.
/gps/hist/point 2. 1.
/gps/hist/point 2.5 1.
/gps/hist/point 3.1415 1.

/gps/energy .001 MeV
/run/beamOn 10000

There is a weird spike in the angular distribution at 90 deg which I’m not sure how to get rid of, but other than that this works.

iso is supposed to give you an isotropic angular distribution, according to the manual: Geant4 General Particle Source — Book For Application Developers 10.7 documentation

your histogram looks like you intend to exclude certain angles? take a look at the


commands, in combination with iso.

In my experience iso has not resulted in isotropic theta distributions - rather, it seems that the cosine(theta) distribution winds up being isotropic. I don’t have any example plots on me, but these examples seem to support that: Geant4 GPS Examples .

I haven’t had too much success with mintheta and maxtheta, and I’m not sure why- I would think a minimum of 90 and maximum of 180 in theta would result in what I wanted, but particles still seemed to fire from all theta when I used these commands.

Update: I did some playing around with mintheta and maxtheta, and they appear to do nothing unless using the /gps/ang/type iso command.

Isotropic implies a distribution uniform in cos(theta). This is because the element of solid angle is sin(theta)*d(theta)*d(phi) = d(cos(theta))*d(phi). (A patch of the Earth’s surface of a given range of longitude and latitude gets smaller as you move to the poles; the lines of longitude converge.)

That is for a point source. A surface source - e.g., radiation emitted from a uniformly illuminated rough surface; a patch of the surface of the Sun; or radiation falling on the surface of a spacecraft - obeys Lambert’s Cosine Law, so the radiation into the element of solid angle is cos(theta)*d(cos(theta)*d(phi) proportional to d(cos(theta)^2)*d(phi), so is uniform in cos(theta)^2. I’m not sure what the General Particle Source does if you ask for iso for a surface, but I will look into it if you like.

Re the Sun, Lambert’s Cosine Law is why it looks like a flat disc (viewed through fog or a very dark filter). It is like the surface layers act as a rough diffuser. It is not like the surface is covered in lots of point sources. That would look brighter at the edges.

To mimic uniform radiation, as in a radiation belt or a nuclear reactor, you have to generate particles on the inside of a cavity surrounding your objects of interest with a distribution uniform in cos(theta)^2.

I see, I had assumed that iso meant uniform and that cos was referring to the solid angle stuff. Is there a reason mintheta and maxtheta don’t work for /ang/type cos, or is it likely I’ve just messed something else up?
Are there other ways to define sources and fire particles? The macro file way seems like it can be difficult to work with.

I think one has to first specify /gps/ang/type cos, and then define maxtheta/mintheta.