How to improve the efficiency of program operation

I’ve been running a program recently, but when the program was put on the server to run I found that the program was taking too long to run. I have used 96 threads, but according to my estimation it takes about 10 days to run, so I would like to ask you all what I can do to improve the running efficiency of the program. Thank you all for your answers.

What are you simulating? It is possible that you don’t need 10 days worth of simulating to learn what you want to learn

If you haven’t done so already, try profiling the application with something like perf or similar. That will help identify if there are any bottlenecks or opportunities for improvement in the application itself, or just to reassure that it’s running as best it can.

What I am doing is using a radioactive source filled with I125 and then placing this source in the center of the tank to detect the absorbed dose of radioactive seeds in this tank. I used G4PVParameterised to place 50*50*50 microelements inside the water tank. Then I emitted 180,000,000 particles using /run/beamOn. I would like to ask you if this number of emitted particles is necessary?

180,000,000/125,000 = 1440 hits per cell assuming uniform coverage, so RMS ~ 40, or relative uncertainly ~3%. Since the source falls off like 1/r^2 (naively), you’ll get much less than 1440 hits in the outer cells, and many more near the center. Is 3-10% precision sufficient for your needs?

Thank you for your answer, this 180000000 is because I am simulating the decay process of I125. As a student in the medical field I lacked expertise in the field of physics.

I am planning to use a 5mci aqueous solution of I125. According to the formula: 1mCi = 3.7*10^7 times/s. I calculated the result of 180000000. I want to simulate the radiation results of this I125 source in one second.

I would like to ask if there is something unreasonable in my calculation, is it that I don’t need to emit so many number of particles if I want to simulate the radiation result of 5mCi I125 in one second. Thank you for your answer.

You could always simulate the number at 1/2 a second or 1/10 of a second and just multiply by a factor, your results should be time independent.

Thank you for explaining! That helps a lot, and also helps me to know how to “aim” my response. So Geant4 works “event by event.” It doesn’t worry about real-world time.

What you can do very effectively with Geant4 is simulate whatever number of events you want or need (to get good statistical reach), and you can translate that number of events into real-world time as you did above. As @lodydms said, you can simulate, e.g., 1800000 events and multiply by 100 to see the effect of “one second.”

So my question was about “how many events do you think you need.” If you need high statistics all the way out to the edge of your phantom, you might need a whole lot more events. If you just want to see how much of your phantom gets irradiated at all, you might be able to simulate many fewer events and still get a good estmate of the spatial distribution.

Thank you for your answer. The main experiment I’m doing now is to test the radiation range of my radioactive seeds after they decay in a tank.

I used the B4c example as a base and made changes on the B4c source code. A 50cm by 50cm by 50cm tank is defined and 125000 microcells are parameterised through G4PVParameterised. In addition, I created a table with each pixel viewed as a coordinate point.

In EventAction: : EndOfEventAction I traverse all Hit, to get each Hit the energy deposition, and determine when energy is not zero when I calculated by Hit the ID of the Xid, Yid, Zid. This way I know which element is triggered in this experiment, and I input these ids into the tuple as coordinates. What I want to do now is to look at the energy distribution and energy size of these particles. I use the Origin software to draw the following diagram:

Based on your answer, I now have two questions. The first question is: if I just want to do this now, don’t I have to shoot 18 million particles, I can shoot fewer particles and get a more accurate energy profile. The second question is whether I have calculated from the formula 1mCi = 3.7*10^7 times/s that a 5mCi aqueous solution should emit 180000000 I-125 particles per second.

Thank you again for your reply, which helped me a lot.

Thanks for your answer. I think I can try the method you said in combination with @mkelsey reply

Very close. 1 mCi = 3.7e+7 decays/s is correct, but 37*5 = 185, not 180. However, that’s only a 3% error :wink:

Thank you for your reply I think it is feasible for me to reduce the number of particles :grinning: