jintonic / gears

Geant4 Example Application with Rich features and Small footprints
http://physino.xyz/gears/
MIT License
78 stars 65 forks source link

GDML and scoring are missing #4

Closed sergeserge123 closed 4 years ago

sergeserge123 commented 4 years ago

/geometry/export gears.gdml command not found error

jintonic commented 4 years ago

The makefile or CMake file shipped together with gears checks if GDML is enabled in your Geant4 installation. If not, any GDML related functionality will not be compiled into the gears executable. An easy way to check if your Geant4 has GDML enabled is to do:

$ geant4-config --help | grep gdml

In a word, gears is a Geant4 application. It can only use functionalities enabled in Geant4.

sergeserge123 commented 4 years ago

Great, Thank you. Another feature that can be very helpful in GEARS is Energy by Position distribution (a three-dimensional matrix of cubic elements with the amount of energy lost by all the simulated particle trajectories). I didn't find an easy way to simulate and extract this information from the root in svc.

jintonic commented 4 years ago

try

$ root outputOfGEARS.root
root [] t->Draw("x:y:de", "", "surf1")

or

root[] t->Draw("y:x", "de*(pdg==11)")

Check http://physino.xyz/gears/examples/output/ for details.

sergeserge123 commented 4 years ago

Thanks, it works! 3D, t->Draw("x:y:z:de", "", "surf1"). Any idea how to extract the information to cvs or txt file in matrix form? It seems this is a problem for root

sergeserge123 commented 4 years ago

This is an examples to show how one can distribute source in a volume /gps/source/intensity 1 /gps/particle e- /gps/pos/type Volume /gps/pos/shape Para /gps/pos/centre 0 0 0 /gps/pos/halfx 0.00025 /gps/pos/halfy 0.00025 /gps/pos/halfz 0.00025 /gps/pos/paralp 0 /gps/pos/parthe 0 /gps/pos/parphi 0 /gps/pos/confine sourcePara #volume devided in tg file should match /gps/pos/shape Para /gps/ang/type iso /gps/ene/type User /gps/hist/type energy /gps/hist/point 0.398720205 0.023346662 /gps/hist/point ................

jintonic commented 4 years ago

Thanks, it works! 3D, t->Draw("x:y:z:de", "", "surf1"). Any idea how to extract the information to cvs or txt file in matrix form? It seems this is a problem for root

t->GetV1(); t->GetV2(); t->GetV3(); t->GetV4(); gives you arrays of x, y, z, and de. You can use ofstream to print them to a cvs file.

jintonic commented 4 years ago

This is an examples to show how one can distribute source in a volume /gps/source/intensity 1 /gps/particle e- /gps/pos/type Volume /gps/pos/shape Para /gps/pos/centre 0 0 0 /gps/pos/halfx 0.00025 /gps/pos/halfy 0.00025 /gps/pos/halfz 0.00025 /gps/pos/paralp 0 /gps/pos/parthe 0 /gps/pos/parphi 0 /gps/pos/confine sourcePara #volume devided in tg file should match /gps/pos/shape Para /gps/ang/type iso /gps/ene/type User /gps/hist/type energy /gps/hist/point 0.398720205 0.023346662 /gps/hist/point ................

Thanks. But if you define all the dimensions of your source here, there is no need to confine it in a volume defined in tg file again. I think your macro would work just fine without /gps/pos/confine sourcePara

sergeserge123 commented 4 years ago

Thank you again for your response! Though, I still can not get x,y,z,de data. I do the following t->Draw("x:y:z:de", "", "surf1") t->GetV1(); t->GetV2(); t->GetV3(); t->GetV4() t->SetScanField(0) t->Scan("*"); >output.txt

the output.txt has complete t data set.

Does "de" reflect total energy absorbed from all particles stopping/passing through the volume element and any way to control volume size (dxdydz) like in function PLACE_PARAM or scoring? Thank you.

On Tue, Sep 15, 2020 at 1:09 AM Jing Liu notifications@github.com wrote:

Thanks, it works! 3D, t->Draw("x:y:z:de", "", "surf1"). Any idea how to extract the information to cvs or txt file in matrix form? It seems this is a problem for root

t->GetV1(); t->GetV2(); t->GetV3(); t->GetV4(); gives you arrays of x, y, z, and de. You can use ofstream to print them to a cvs file.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jintonic/gears/issues/4#issuecomment-692467698, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUC73NE3DOMNMQYTDGHAZTSF3ZJPANCNFSM4Q7FJJIA .

sergeserge123 commented 4 years ago

Thanks for the tip! In this particular case, an intention was to reflect the self-absorption effect in the source.

On Tue, Sep 15, 2020 at 1:12 AM Jing Liu notifications@github.com wrote:

This is an examples to show how one can distribute source in a volume /gps/source/intensity 1 /gps/particle e- /gps/pos/type Volume /gps/pos/shape Para /gps/pos/centre 0 0 0 /gps/pos/halfx 0.00025 /gps/pos/halfy 0.00025 /gps/pos/halfz 0.00025 /gps/pos/paralp 0 /gps/pos/parthe 0 /gps/pos/parphi 0 /gps/pos/confine sourcePara #volume devided in tg file should match /gps/pos/shape Para /gps/ang/type iso /gps/ene/type User /gps/hist/type energy /gps/hist/point 0.398720205 0.023346662 /gps/hist/point ................

Thanks. But if you define all the dimensions of your source here, there is no need to confine it in a volume defined in tg file again. I think your macro would work just fine without /gps/pos/confine sourcePara

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jintonic/gears/issues/4#issuecomment-692468402, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUC73PAXGEKXRMKYORJCDTSF3ZSPANCNFSM4Q7FJJIA .

jintonic commented 4 years ago

ofstream output("output.txt");
for (int i=0; i<t->GetSelectedRows(); i++) {
  output<<t->GetV1()[i]<<", "<<t->GetV2()[i]<<........<<endl;
}
output.close();

`de` is the energy deposited at that step by that particle. The total energy deposited in a particular volume by all particles is saved in et[i], et means energy total, i is the copy number of that volume. See http://physino.xyz/gears/examples/output/#total-energy

I know you are checking the self-absorption effect. For some reason `/gps/pos/confine` does not work as I expected. I thought it can homogeneously distribute the primary vertices in the volume specified in this macro command, but nothing happens. I had to specify the geometry of the source in my macro, which makes `/gps/pos/confine` useless. If you find the right way to use this command, please let me know. Thanks, Jing
sergeserge123 commented 4 years ago

Thank you for the code! Getting error though like "end with '}', '@':abort

"

t->Draw("x:y:z: et[0]", "", "box"); t->GetV1(); t->GetV2(); t->GetV3(); t->GetV4(); ofstream output("output3D.txt"); for (int i=0; iGetSelectedRows(); i++) { output<GetV1()[i]<<", "<GetV2()[i]<<", "<GetV3()[i]<<", "<GetV4()[i]<<"<<endl; } output.close();


Regarding the source, it seems it works for me (wrl file is attached). example geometry file .tg solid Ni63Para PARA 2.5um 2.5um 2.5um 0 0 0 :volu sourcePara elementPara G4_Al :place sourcePara -2 world r000 0um 0um 0um

macro file /gps/source/add 1 /gps/particle e- /gps/pos/type Volume /gps/pos/shape Para /gps/pos/centre -0.0005 0.00125 0 /gps/pos/halfx 0.00025 /gps/pos/halfy 0.00025 /gps/pos/halfz 0.00025 /gps/pos/paralp 0 /gps/pos/parthe 0 /gps/pos/parphi 0 /gps/pos/confine sourcePara2 /gps/ang/type iso

On Wed, Sep 16, 2020 at 1:29 PM Jing Liu notifications@github.com wrote:

ofstream output("output.txt"); for (int i=0; iGetSelectedRows(); i++) { output<GetV1()[i]<<", "<GetV2()[i]<<........<<endl; } output.close();

de is the energy deposited at that step by that particle. The total energy deposited in a particular volume by all particles is saved in et[i], et means energy total, i is the copy number of that volume. See http://physino.xyz/gears/examples/output/#total-energy

I know you are checking the self-absorption effect. For some reason /gps/pos/confine does not work as I expected. I thought it can homogeneously distribute the primary vertices in the volume specified in this macro command, but nothing happens. I had to specify the geometry of the source in my macro, which makes /gps/pos/confine useless. If you find the right way to use this command, please let me know. Thanks, Jing

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jintonic/gears/issues/4#issuecomment-693550937, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUC73MPUBURW2PPNEPBKD3SGDYWTANCNFSM4Q7FJJIA .

jintonic commented 4 years ago

There is a single " that is not closed right before <<endl; The following should work:

output<<t->GetV1()[i]<<", "<<t->GetV2()[i]<<", "<<t->GetV3()[i]<<", "<<t->GetV4()[i]<<endl;
sergeserge123 commented 4 years ago

Thanks! I missed it works now. One more question, I wonder if the Geant4 scoring mesh function implemented in GEARS. I think it's more convenient to extract data in matrix form rather than hit map. example of code /score/create/boxMesh boxMesh_1 /score/mesh/boxSize 0.25 0.25 0.25 /score/mesh/nBin 10 10 10 /score/quantity/energyDeposit

On Thu, Sep 17, 2020 at 6:00 PM Jing Liu notifications@github.com wrote:

There is a single " that is not closed right before <<endl; The following should work:

output<GetV1()[i]<<", "<GetV2()[i]<<", "<GetV3()[i]<<", "<GetV4()[i]<<endl;

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jintonic/gears/issues/4#issuecomment-694522039, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUC73JCYUDJ3U23Q6SSTU3SGKBJTANCNFSM4Q7FJJIA .

jintonic commented 4 years ago

Download the newest release. Scoring is enabled there.

sergeserge123 commented 4 years ago

Hi Jing,

Thank you for the update. I couldnt manage to try it in windows, for some reasons getting error compiling it in visual studio "CMake error", didn't have in the past with an old version. Also, it can be a great feature to add in addition to scoring option an output log file to track errors in the code.

On Fri, Sep 18, 2020 at 12:14 AM Jing Liu notifications@github.com wrote:

Download the newest release. Scoring is enabled there.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jintonic/gears/issues/4#issuecomment-694639529, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUC73NLJTHCE2ZBJ7TA65TSGLNB7ANCNFSM4Q7FJJIA .

jintonic commented 4 years ago

I compiled it for you. You can download the compiled gears.exe in the latest release page. I don't understand what you mean by "adding an output log file to track errors in the code". Have you tried macros in /control/cout/? Can your terminal handle its output?

sergeserge123 commented 4 years ago

Thank you! Scoring is working. I mean to save/dump process/step log from the terminal, to track down errors if any. I didn't try /control/cout/.

On Sun, Sep 20, 2020 at 9:14 AM Jing Liu notifications@github.com wrote:

I compiled it for you. You can download the compiled gears.exe in the latest release page. I don't understand what you mean by "adding an output log file to track errors in the code". Have you tried macros in /control/cout/? Can your terminal handle its output?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jintonic/gears/issues/4#issuecomment-695785911, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUC73KPPYLFMY4BIHXANDDSGX52JANCNFSM4Q7FJJIA .

sergeserge123 commented 4 years ago

I'm trying to use Multithreading commands /run/numberOfThreads [n] or /run/useMaximumLogicalCores. Both don't work with GEARS. Is there any way to enable it? Thank you

On Sun, Sep 20, 2020 at 9:14 AM Jing Liu notifications@github.com wrote:

I compiled it for you. You can download the compiled gears.exe in the latest release page. I don't understand what you mean by "adding an output log file to track errors in the code". Have you tried macros in /control/cout/? Can your terminal handle its output?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jintonic/gears/issues/4#issuecomment-695785911, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUC73KPPYLFMY4BIHXANDDSGX52JANCNFSM4Q7FJJIA .

jintonic commented 4 years ago

I have not checked if GEARS is multi-thread safe yet. I will need sometime to check it. Meanwhile, I think your need is to simply save the output of GEARS from the terminal to a file. Is that right? If that is the case, you can try powershell: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_redirection?view=powershell-7

sergeserge123 commented 4 years ago

Thanks! The problem is that terminal window is closing aromatically as soon as simulation is done. So I don’t have an option to get log out by command

On Fri, Oct 23, 2020 at 3:53 PM Jing Liu notifications@github.com wrote:

I have not checked if GEARS is multi-thread safe yet. I will need sometime to check it. Meanwhile, I think your need is to simply save the output of GEARS from the terminal to a file. Is that right. If that is the case, you can try powershell: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_redirection?view=powershell-7

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jintonic/gears/issues/4#issuecomment-715559064, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUC73IJZKAO4GLY4FY6B73SMHNMLANCNFSM4Q7FJJIA .

jintonic commented 4 years ago

That's easy. Go to the folder that contains the macro file you'd like to execute using your file browser. Highlight the address bar, type powershell and return. A powershell terminal will be opened, where you can type gears simulation.mac > output.txt.

sergeserge123 commented 4 years ago

Great, thank you! For some reason this approach ( .\ filename.mac > log.txt ) gives empty log file.

On Sat, Oct 24, 2020 at 2:20 PM Jing Liu notifications@github.com wrote:

That's easy. Go to the folder that contains the macro file you'd like to execute using your file browser. Highlight the address bar, type powershell and return. A powershell terminal will be opened, where you can type gears simulation.mac > output.txt.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jintonic/gears/issues/4#issuecomment-716034603, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUC73MXPJLEWFZ5TZ3PZYDSMMLHBANCNFSM4Q7FJJIA .

jintonic commented 4 years ago

filename.mac is not an executable program. You need to run a program in a terminal. gears.exe is a program. filename.mac is its input argument. As shown in my previous post, you need to run gears filename.mac > output.txt

sergeserge123 commented 4 years ago

Thank you for your correction.

On Mon, Oct 26, 2020 at 1:55 PM Jing Liu notifications@github.com wrote:

filename.mac is not an executable program. You need to run a program in a terminal. gears.exe is a program. filename.mac is its input argument. As shown in my previous post, you need to run gears filename.mac > output.txt

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jintonic/gears/issues/4#issuecomment-716721747, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUC73PCGN5JYQR2WUHUIXTSMWZYFANCNFSM4Q7FJJIA .

sergeserge123 commented 4 years ago

Another question is regarding boundary conditions in GEARS. Is it possible to implement 100% specular reflection of particles for specific surfaces of interest (for example one side of solid volume)? Thank you

On Mon, Oct 26, 2020 at 1:55 PM Jing Liu notifications@github.com wrote:

filename.mac is not an executable program. You need to run a program in a terminal. gears.exe is a program. filename.mac is its input argument. As shown in my previous post, you need to run gears filename.mac > output.txt

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jintonic/gears/issues/4#issuecomment-716721747, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUC73PCGN5JYQR2WUHUIXTSMWZYFANCNFSM4Q7FJJIA .

jintonic commented 4 years ago

Yes, please read http://physino.xyz/gears/examples/physics/#optical-processes

sergeserge123 commented 4 years ago

Thanks! it seems it's applied for optical processes only. What about other types of particles; ions, electrons for example?

On Tue, Oct 27, 2020 at 4:40 PM Jing Liu notifications@github.com wrote:

Yes, please read http://physino.xyz/gears/examples/physics/#optical-processes

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jintonic/gears/issues/4#issuecomment-717525392, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUC73K7VBJM6EOR2YALR4DSM4V2LANCNFSM4Q7FJJIA .

jintonic commented 4 years ago

I don't understand how an ion can be reflected by a surface. Are you talking about EM field simulation?

sergeserge123 commented 4 years ago

This is just an assumption to introduce periodic boundary conditions, remove "leakage" of particles for approximating a large system.

On Tue, Oct 27, 2020 at 5:42 PM Jing Liu notifications@github.com wrote:

I don't understand how an ion can be reflected by a surface. Are you talking about EM field simulation?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jintonic/gears/issues/4#issuecomment-717557354, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUC73KLJHN67ES6EK5AQHDSM45DRANCNFSM4Q7FJJIA .

jintonic commented 4 years ago

I don't know if Geant4 can do that. Can you send me some references showing this was done using Geant4?

sergeserge123 commented 4 years ago

Thank you, I didn't find it as well. This option may be not implemented in GEANT.

On Tue, Oct 27, 2020 at 9:06 PM Jing Liu notifications@github.com wrote:

I don't know if Geant4 can do that. Can you send me some references showing this was done using Geant4?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jintonic/gears/issues/4#issuecomment-717631672, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUC73JP2E4YXMEZJFB2LH3SM5VB3ANCNFSM4Q7FJJIA .

sergeserge123 commented 4 years ago

Another question, if GEARS has the capability to estimate the total energy of reflected particles from the detector (backscatter) and total particle energy that deposit in the detector. Thank you

On Tue, Oct 27, 2020 at 9:06 PM Jing Liu notifications@github.com wrote:

I don't know if Geant4 can do that. Can you send me some references showing this was done using Geant4?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jintonic/gears/issues/4#issuecomment-717631672, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUC73JP2E4YXMEZJFB2LH3SM5VB3ANCNFSM4Q7FJJIA .

jintonic commented 4 years ago

Yes, please check http://physino.xyz/gears/examples/output/#total-energy

sergeserge123 commented 4 years ago

Great, thank you. I still can not figure out how to get the total energy of particles entering the detector boundary (point 1).

On Wed, Nov 4, 2020 at 8:31 PM Jing Liu notifications@github.com wrote:

Yes, please check http://physino.xyz/gears/examples/output/#total-energy

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jintonic/gears/issues/4#issuecomment-722068182, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUC73PA3BOGLE6S5T2PA5TSOH553ANCNFSM4Q7FJJIA .

jintonic commented 4 years ago

I cannot give you further instruction without knowing exactly what you'd like to achieve. If I take what you said literally, you need to sum "k", the kinetic energy, in the output file at the first step point, which is right on the boundary since Geant4 forces to create a step point when a particle changes volume. Many particles do not deposit their total energy in one step.

sergeserge123 commented 4 years ago

Thank you for the tip. I would like to estimate losses of energy in detector volume due to backscattering etc. It will give "energy deposition efficiency" for the specific detector material. It seems the optimal way to do it to estimate the total energy of particles at the boundary of the detector (entering detector) "k" versus the total energy deposited in the detector "et". The particles emitted by iso source confined in solid volume placed at the front of the detector.

On Fri, Nov 6, 2020 at 9:16 AM Jing Liu notifications@github.com wrote:

I cannot give you further instruction without knowing exactly what you'd like to achieve. If I take what you said literally, you need to sum "k", the kinetic energy, in the output file at the first step point, which is right on the boundary since Geant4 forces to create a step point when a particle changes volume. Many particles do not deposit their total energy in one step.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jintonic/gears/issues/4#issuecomment-723103197, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUC73PRFADEM3UOOM547KDSOQALHANCNFSM4Q7FJJIA .

jintonic commented 4 years ago

Which particles do you detect? What kind of detector do you use? Do you work on this project alone?

sergeserge123 commented 4 years ago

Electrons/alpha, detector is bulk semiconductor vary. I’m doing it myself, geant4 is rather new for me. So I have novice questions. Thank you for helping me out. Gears is great.

On Sun, Nov 8, 2020 at 6:09 PM Jing Liu notifications@github.com wrote:

Which particles do you detect? What kind of detector do you use? Do you work on this project alone?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jintonic/gears/issues/4#issuecomment-723680027, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUC73KRWESQIQCAXAVUPV3SO4QL5ANCNFSM4Q7FJJIA .

jintonic commented 4 years ago

What is the energy range of your electrons and alphas? Are they from a point source or a beam? What is the thickness of your detector? What is the material of your detector? What is your research field or business?

sergeserge123 commented 4 years ago

Hi Jing, This is reference on my paper. I’m trying to verify our model and do 3D geant4 modeling, sources are vary but most shown in the paper

https://www.nature.com/articles/s41598-019-47371-6

On Mon, Nov 9, 2020 at 11:58 AM Jing Liu notifications@github.com wrote:

What is the energy range of your electrons and alphas? Are they from a point source or a beam? What is the thickness of your detector? What is the material of your detector? What is your research field or business?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jintonic/gears/issues/4#issuecomment-724141308, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQUC73PKRUO5JHNBDHLKVTLSPANSVANCNFSM4Q7FJJIA .

jintonic commented 4 years ago

Very interesting! GEARS is perfect for your research. In short, the approach described in http://physino.xyz/gears/examples/output/#total-energy would solve your problem easily. You need to give your beta source and detector positive volume number, say, 1 and 2, attach (S) to the end of their volume names. GEARS will then sum all energy depositions in these two volumes in "et[1]" and "et[2]".

We can also collaborate. I can ask my student to do the simulation for you. She is very good at it, and should be able to get what you want in a day.

Out of my curiosity, could you please explain why the e-h pairs don't recombine in your detector? I guess that's the basic working principle of betavoltaic. I don't quite understand why they can separate without external E-field.