How do you define a photon source of a continuous energy spectrum

Dear fluka experts and colleagues:
I have tried to simulate directly the photons produced by the electron beam hitting the tungsten target, but since the photons produced by Bremsstrahl radiation are in all directions, only a few of them are useful to me. If I want to increase the number of effective photons, I have to keep increasing the number of primary electrons, which wastes a lot of calculation time.
So I now want to directly define a continuous spectrum photon source, or by simulating Bremsstrahl radiation, save the resulting continuous spectrum photon beam as a particle source to load into my other calculations
is there any advice?
Thanks

1 Like

You can define your own source using a source routine.
Have a look at the source routine lecture from the last Fluka course.

Dear @chen2019 !

For example, you can use SpekPy tool to create your desired X-ray spectrum and use it in the calculations. This is not mandatory, you can use spectrum from any other source, but they need to be in the format described below. Here I will try to describe the workflow with the SpekPy:

  1. Create three columns of the desired spectrum data in a format:
    | Emin (keV) | Emax (keV) | dF/dE (keV^-1 cm^-2) |
    These columns can be constructed from the SpekPy data spectrum. So, your data will look like this:
Spectrum data

1.0000000000000000 1.5000000000000000 0.0000000000000000
1.5000000000000000 2.0000000000000000 0.0000000000000000
2.0000000000000000 2.5000000000000000 1.9757000000000000
2.5000000000000000 3.0000000000000000 1656.1008000000000000
3.0000000000000000 3.5000000000000000 43670.4128000000000000
3.5000000000000000 4.0000000000000000 279827.1555000000000000
4.0000000000000000 4.5000000000000000 890151.8456000000000000
4.5000000000000000 5.0000000000000000 1937001.3897000000000000
5.0000000000000000 5.5000000000000000 3382464.3017000000000000
5.5000000000000000 6.0000000000000000 5143451.7939000000000000
6.0000000000000000 6.5000000000000000 7130016.0761000000000000
6.5000000000000000 7.0000000000000000 9246185.5274000000000000
7.0000000000000000 7.5000000000000000 21244870.5481000000000000
7.5000000000000000 8.0000000000000000 13805106.8076000000000000
8.0000000000000000 8.5000000000000000 272578006.4042000000000000
8.5000000000000000 9.0000000000000000 21200266.4049000000000000
9.0000000000000000 9.5000000000000000 19860595.1186000000000000
9.5000000000000000 10.0000000000000000 286486499.1570000000000000
10.0000000000000000 10.5000000000000000 16900535.1707000000000000
10.5000000000000000 11.0000000000000000 10681916.5609000000000000
11.0000000000000000 11.5000000000000000 29988987.1007000000000000
11.5000000000000000 12.0000000000000000 12365253.5117000000000000
12.0000000000000000 12.5000000000000000 8704918.9742000000000000
12.5000000000000000 13.0000000000000000 8420702.1348000000000000
13.0000000000000000 13.5000000000000000 8985752.1589000000000000
13.5000000000000000 14.0000000000000000 9538623.8427000000000000
14.0000000000000000 14.5000000000000000 10077277.6122000000000000
14.5000000000000000 15.0000000000000000 10598756.6847000000000000
15.0000000000000000 15.5000000000000000 11099369.5072000000000000
15.5000000000000000 16.0000000000000000 11576867.3372000000000000
16.0000000000000000 16.5000000000000000 12026689.0307000000000000
16.5000000000000000 17.0000000000000000 12443301.3943000000000000
17.0000000000000000 17.5000000000000000 12830034.8353000000000000
17.5000000000000000 18.0000000000000000 13186395.8500000000000000
18.0000000000000000 18.5000000000000000 13512386.6082000000000000
18.5000000000000000 19.0000000000000000 13806517.2359000000000000
19.0000000000000000 19.5000000000000000 14069264.7932000000000000
19.5000000000000000 20.0000000000000000 14301448.9968000000000000
20.0000000000000000 20.5000000000000000 14503010.9409000000000000
20.5000000000000000 21.0000000000000000 14675358.6329000000000000
21.0000000000000000 21.5000000000000000 14819905.6473000000000000
21.5000000000000000 22.0000000000000000 14937684.3251000000000000
22.0000000000000000 22.5000000000000000 15030275.2856000000000000
22.5000000000000000 23.0000000000000000 15098386.6362000000000000
23.0000000000000000 23.5000000000000000 15144101.2430000000000000
23.5000000000000000 24.0000000000000000 15169326.1310000000000000
24.0000000000000000 24.5000000000000000 15174652.6154000000000000
24.5000000000000000 25.0000000000000000 15162435.5522000000000000
25.0000000000000000 25.5000000000000000 15133130.2319000000000000
25.5000000000000000 26.0000000000000000 15088210.8515000000000000
26.0000000000000000 26.5000000000000000 15029811.1906000000000000
26.5000000000000000 27.0000000000000000 14957909.5346000000000000
27.0000000000000000 27.5000000000000000 14874545.8370000000000000
27.5000000000000000 28.0000000000000000 14779683.6120000000000000
28.0000000000000000 28.5000000000000000 14674665.0986000000000000
28.5000000000000000 29.0000000000000000 14561416.7918000000000000
29.0000000000000000 29.5000000000000000 14439644.1644000000000000
29.5000000000000000 30.0000000000000000 14311024.8460000000000000
30.0000000000000000 30.5000000000000000 14176752.1944000000000000
30.5000000000000000 31.0000000000000000 14036474.4489000000000000
31.0000000000000000 31.5000000000000000 13892214.1327000000000000
31.5000000000000000 32.0000000000000000 13743545.5852000000000000
32.0000000000000000 32.5000000000000000 13591564.3902000000000000
32.5000000000000000 33.0000000000000000 13437229.4468000000000000
33.0000000000000000 33.5000000000000000 13280010.3014000000000000
33.5000000000000000 34.0000000000000000 13121246.1998000000000000
34.0000000000000000 34.5000000000000000 12960641.4591000000000000
34.5000000000000000 35.0000000000000000 12798824.4094000000000000
35.0000000000000000 35.5000000000000000 12636439.6424000000000000
35.5000000000000000 36.0000000000000000 12472901.2393000000000000
36.0000000000000000 36.5000000000000000 12309328.9185000000000000
36.5000000000000000 37.0000000000000000 12146054.3857000000000000
37.0000000000000000 37.5000000000000000 11982778.9177000000000000
37.5000000000000000 38.0000000000000000 11820567.1214000000000000
38.0000000000000000 38.5000000000000000 11658643.3865000000000000
38.5000000000000000 39.0000000000000000 11497714.9369000000000000
39.0000000000000000 39.5000000000000000 11338172.9882000000000000
39.5000000000000000 40.0000000000000000 11179322.7121000000000000
40.0000000000000000 40.5000000000000000 11022083.5171000000000000
40.5000000000000000 41.0000000000000000 10865656.5992000000000000
41.0000000000000000 41.5000000000000000 10710727.8973000000000000
41.5000000000000000 42.0000000000000000 10557671.4388000000000000
42.0000000000000000 42.5000000000000000 10405782.9502000000000000
42.5000000000000000 43.0000000000000000 10255852.2548000000000000
43.0000000000000000 43.5000000000000000 10107618.8631000000000000
43.5000000000000000 44.0000000000000000 9961019.4533000000000000
44.0000000000000000 44.5000000000000000 9816609.8385000000000000
44.5000000000000000 45.0000000000000000 9673571.9426000000000000
45.0000000000000000 45.5000000000000000 9532414.7807000000000000
45.5000000000000000 46.0000000000000000 9393268.9884000000000000
46.0000000000000000 46.5000000000000000 9255725.5927000000000000
46.5000000000000000 47.0000000000000000 9120257.7057000000000000
47.0000000000000000 47.5000000000000000 8986351.7048000000000000
47.5000000000000000 48.0000000000000000 8854291.4770000000000000
48.0000000000000000 48.5000000000000000 8724352.1480000000000000
48.5000000000000000 49.0000000000000000 8595956.2968000000000000
49.0000000000000000 49.5000000000000000 8469558.6211000000000000
49.5000000000000000 50.0000000000000000 8344995.4951000000000000
50.0000000000000000 50.5000000000000000 8222112.6876000000000000
50.5000000000000000 51.0000000000000000 8101185.2336000000000000
51.0000000000000000 51.5000000000000000 7981840.7519000000000000
51.5000000000000000 52.0000000000000000 7864242.9842000000000000
52.0000000000000000 52.5000000000000000 7748730.2359000000000000
52.5000000000000000 53.0000000000000000 7634712.5055000000000000
53.0000000000000000 53.5000000000000000 7522516.4614000000000000
53.5000000000000000 54.0000000000000000 7411835.7858000000000000
54.0000000000000000 54.5000000000000000 7302798.0623000000000000
54.5000000000000000 55.0000000000000000 7195590.6012000000000000
55.0000000000000000 55.5000000000000000 7089802.3553000000000000
55.5000000000000000 56.0000000000000000 6985613.9985000000000000
56.0000000000000000 56.5000000000000000 6883062.5156000000000000
56.5000000000000000 57.0000000000000000 6781980.2488000000000000
57.0000000000000000 57.5000000000000000 6682481.9752000000000000
57.5000000000000000 58.0000000000000000 36934030.8749000000000000
58.0000000000000000 58.5000000000000000 6487647.8742000000000000
58.5000000000000000 59.0000000000000000 6392653.7471000000000000
59.0000000000000000 59.5000000000000000 59871502.7316000000000000
59.5000000000000000 60.0000000000000000 6206580.1297000000000000
60.0000000000000000 60.5000000000000000 6115689.5816000000000000
60.5000000000000000 61.0000000000000000 6026075.8798000000000000
61.0000000000000000 61.5000000000000000 5938118.5207000000000000
61.5000000000000000 62.0000000000000000 5851281.5881000000000000
62.0000000000000000 62.5000000000000000 5765568.6904000000000000
62.5000000000000000 63.0000000000000000 5681272.8744000000000000
63.0000000000000000 63.5000000000000000 5597999.8983000000000000
63.5000000000000000 64.0000000000000000 5516180.4437000000000000
64.0000000000000000 64.5000000000000000 5435448.0538000000000000
64.5000000000000000 65.0000000000000000 5355709.1629000000000000
65.0000000000000000 65.5000000000000000 5277417.7442000000000000
65.5000000000000000 66.0000000000000000 5200014.3488000000000000
66.0000000000000000 66.5000000000000000 5123805.0398000000000000
66.5000000000000000 67.0000000000000000 11294134.0640000000000000
67.0000000000000000 67.5000000000000000 17076688.6734000000000000
67.5000000000000000 68.0000000000000000 5208730.6628000000000000
68.0000000000000000 68.5000000000000000 4829233.4955000000000000
68.5000000000000000 69.0000000000000000 4758093.1716000000000000
69.0000000000000000 69.5000000000000000 9027096.8810000000000000
69.5000000000000000 70.0000000000000000 4777536.5975000000000000
70.0000000000000000 70.5000000000000000 4060639.5150000000000000
70.5000000000000000 71.0000000000000000 4008666.1404000000000000
71.0000000000000000 71.5000000000000000 3957113.1455000000000000
71.5000000000000000 72.0000000000000000 3906465.2741000000000000
72.0000000000000000 72.5000000000000000 3856034.4162000000000000
72.5000000000000000 73.0000000000000000 3806346.9478000000000000
73.0000000000000000 73.5000000000000000 3757021.1667000000000000
73.5000000000000000 74.0000000000000000 3707900.4731000000000000
74.0000000000000000 74.5000000000000000 3659469.7600000000000000
74.5000000000000000 75.0000000000000000 3611181.9226000000000000
75.0000000000000000 75.5000000000000000 3563426.0404000000000000
75.5000000000000000 76.0000000000000000 3516108.1878000000000000
76.0000000000000000 76.5000000000000000 3468955.5860000000000000
76.5000000000000000 77.0000000000000000 3422467.3319000000000000
77.0000000000000000 77.5000000000000000 3376162.8507000000000000
77.5000000000000000 78.0000000000000000 3330253.4713000000000000
78.0000000000000000 78.5000000000000000 3284877.4880000000000000
78.5000000000000000 79.0000000000000000 3239660.9268000000000000
79.0000000000000000 79.5000000000000000 3195039.3130000000000000
79.5000000000000000 80.0000000000000000 3150647.9457000000000000
80.0000000000000000 80.5000000000000000 3106556.8694000000000000
80.5000000000000000 81.0000000000000000 3063083.0869000000000000
81.0000000000000000 81.5000000000000000 3019765.1925000000000000
81.5000000000000000 82.0000000000000000 2976922.2239000000000000
82.0000000000000000 82.5000000000000000 2934443.8621000000000000
82.5000000000000000 83.0000000000000000 2892186.8717000000000000
83.0000000000000000 83.5000000000000000 2850503.0362000000000000
83.5000000000000000 84.0000000000000000 2809010.9934000000000000
84.0000000000000000 84.5000000000000000 2767905.6552000000000000
84.5000000000000000 85.0000000000000000 2727213.9515000000000000
85.0000000000000000 85.5000000000000000 2686753.9559000000000000
85.5000000000000000 86.0000000000000000 2646761.3125000000000000
86.0000000000000000 86.5000000000000000 2607019.6155000000000000
86.5000000000000000 87.0000000000000000 2567585.0069000000000000
87.0000000000000000 87.5000000000000000 2528573.6576000000000000
87.5000000000000000 88.0000000000000000 2489808.7370000000000000
88.0000000000000000 88.5000000000000000 2451403.8260000000000000
88.5000000000000000 89.0000000000000000 2413321.0667000000000000
89.0000000000000000 89.5000000000000000 2375495.6749000000000000
89.5000000000000000 90.0000000000000000 2338051.1775000000000000
90.0000000000000000 90.5000000000000000 2300892.8205000000000000
90.5000000000000000 91.0000000000000000 2264026.6595000000000000
91.0000000000000000 91.5000000000000000 2227493.6459000000000000
91.5000000000000000 92.0000000000000000 2191217.8465000000000000
92.0000000000000000 92.5000000000000000 2155241.7045000000000000
92.5000000000000000 93.0000000000000000 2119584.2057000000000000
93.0000000000000000 93.5000000000000000 2084178.8169000000000000
93.5000000000000000 94.0000000000000000 2049079.6699000000000000
94.0000000000000000 94.5000000000000000 2014270.8654000000000000
94.5000000000000000 95.0000000000000000 1979685.8786000000000000
95.0000000000000000 95.5000000000000000 1945443.2295000000000000
95.5000000000000000 96.0000000000000000 1911421.1880000000000000
96.0000000000000000 96.5000000000000000 1877645.6925000000000000
96.5000000000000000 97.0000000000000000 1844184.8390000000000000
97.0000000000000000 97.5000000000000000 1810910.0595000000000000
97.5000000000000000 98.0000000000000000 1777939.7601000000000000
98.0000000000000000 98.5000000000000000 1745208.3348000000000000
98.5000000000000000 99.0000000000000000 1712615.1090000000000000
99.0000000000000000 99.5000000000000000 1680387.4224000000000000
99.5000000000000000 100.0000000000000000 1648303.7088000000000000
100.0000000000000000 100.5000000000000000 1616462.8501000000000000
100.5000000000000000 101.0000000000000000 1584891.2950000000000000
101.0000000000000000 101.5000000000000000 1553458.7861000000000000
101.5000000000000000 102.0000000000000000 1522335.0942000000000000
102.0000000000000000 102.5000000000000000 1491390.9274000000000000
102.5000000000000000 103.0000000000000000 1460600.6841000000000000
103.0000000000000000 103.5000000000000000 1430095.8159000000000000
103.5000000000000000 104.0000000000000000 1399713.3386000000000000
104.0000000000000000 104.5000000000000000 1369589.3898000000000000
104.5000000000000000 105.0000000000000000 1339658.2267000000000000
105.0000000000000000 105.5000000000000000 1309817.6381000000000000
105.5000000000000000 106.0000000000000000 1280280.5385000000000000
106.0000000000000000 106.5000000000000000 1250847.0085000000000000
106.5000000000000000 107.0000000000000000 1221598.7383000000000000
107.0000000000000000 107.5000000000000000 1192540.1202000000000000
107.5000000000000000 108.0000000000000000 1163572.7160000000000000
108.0000000000000000 108.5000000000000000 1134837.1171000000000000
108.5000000000000000 109.0000000000000000 1106241.3455000000000000
109.0000000000000000 109.5000000000000000 1077764.3974000000000000
109.5000000000000000 110.0000000000000000 1049493.3715000000000000
110.0000000000000000 110.5000000000000000 1021302.5021000000000000
110.5000000000000000 111.0000000000000000 993290.7356000000000000
111.0000000000000000 111.5000000000000000 965426.9400000000000000
111.5000000000000000 112.0000000000000000 937592.9705000000000000
112.0000000000000000 112.5000000000000000 909990.4829000000000000
112.5000000000000000 113.0000000000000000 882454.7455000000000000
113.0000000000000000 113.5000000000000000 855039.4527000000000000
113.5000000000000000 114.0000000000000000 827766.3004000000000000
114.0000000000000000 114.5000000000000000 800516.4373000000000000
114.5000000000000000 115.0000000000000000 773441.4868000000000000
115.0000000000000000 115.5000000000000000 746455.0073000000000000
115.5000000000000000 116.0000000000000000 719524.4017000000000000
116.0000000000000000 116.5000000000000000 692748.9695000000000000
116.5000000000000000 117.0000000000000000 665992.7960000000000000
117.0000000000000000 117.5000000000000000 639371.5991000000000000
117.5000000000000000 118.0000000000000000 612872.8002000000000000
118.0000000000000000 118.5000000000000000 586371.3973000000000000
118.5000000000000000 119.0000000000000000 560076.7877000000000000
119.0000000000000000 119.5000000000000000 533805.8101000000000000
119.5000000000000000 120.0000000000000000 507639.1668000000000000
120.0000000000000000 120.5000000000000000 481629.8706000000000000
120.5000000000000000 121.0000000000000000 455625.9374000000000000
121.0000000000000000 121.5000000000000000 429834.3824000000000000
121.5000000000000000 122.0000000000000000 404153.7154000000000000
122.0000000000000000 122.5000000000000000 378591.6553000000000000
122.5000000000000000 123.0000000000000000 353264.4710000000000000
123.0000000000000000 123.5000000000000000 328016.8593000000000000
123.5000000000000000 124.0000000000000000 303020.8707000000000000
124.0000000000000000 124.5000000000000000 278208.4243000000000000
124.5000000000000000 125.0000000000000000 253504.1520000000000000
125.0000000000000000 125.5000000000000000 229178.1679000000000000
125.5000000000000000 126.0000000000000000 204974.5158000000000000
126.0000000000000000 126.5000000000000000 181173.4864000000000000
126.5000000000000000 127.0000000000000000 157657.9365000000000000
127.0000000000000000 127.5000000000000000 134199.1711000000000000
127.5000000000000000 128.0000000000000000 111901.0347000000000000
128.0000000000000000 128.5000000000000000 88964.4654000000000000
128.5000000000000000 129.0000000000000000 66548.3517000000000000
129.0000000000000000 129.5000000000000000 43183.7482000000000000
129.5000000000000000 130.0000000000000000 15054.0034000000000000

Name this file e.g. test.spec and put in the spectra directory along with your flair and input file.

  1. Link and compile executable with the attached source routine (18.7 KB)
  2. In the Flair define the preprocessor card as spec = "test"
  3. Define SOURCE card, where in the sdum field write: =spec
  4. In the BEAM card define your preferred location and direction of the source (divergence etc). Note, that energy will be sampled from the provided spectrum file!

If you wish to add other spectra data follow the same procedure, but change the spec value accordingly to sample from another spectrum.

Hope this will help!

Regards,
Ivan

1 Like

Dear @Ivan
Thank you very much for your advice,Meanwhile, I am very sorry for the late reply,because I have been studying the manual of source routine these days.
I believe your advice will be very effective and I will go back to practice and learn the SpekPy tool,But I am afraid that there will be something I don’t understand, so I may ask you for advice.In order to save resources for the community, I will close this post first.
Thank you again
Best regard

Thank you @amario
Yes, I have been studying the manual on the souce routine.However, it seems that I still need to find out whether fluka can preserve the photon spectrum generated by the electron beam hitting the tungsten target that I want, and how

Dear @chen2019 ,

you don’t necessarly need to use SpekPy to obtain spectra, you can also divide your problem on two steps: the first step is to calculate spectrum with FLUKA (or any preferred tool) bombarding electrons on tungsten, the second is to use this generated spectrum following my previously provided guide. To obtain this spectrum with FLUKA on a first step you need to define USRTRACK or USRYIELD cards. This is a general workflow, you can ask for specific question, but it is always better to study all the basics yourself first.

Kind regards,
Ivan

Dear @Ivan
I did a test where I generated a spectrum using SpekPy’s sample program and exported the spectral data, spectrum01.txt file.And then, i loaded the generated spectral data into the source_newgen.f program and scored the output spectra with a usrbdx card.
I got some results, but I have a question,although the spectral graph plot by usrbdx is similar to the spectral image generated by SpekPy, the longitudinal data of the two are still somewhat different,why?

image
image


The unit of usrbdx is part/Gev/cm²/pri, and the unit of SpekPy is photons/cm²/keV (mAs=1.0),I have tried for a long time to convert the two to the same unit, but always failed. Can you tell me why this spectrum difference is.
Thank you

spectrum01.txt (9.1 KB)
mysource_ng1.f (19.0 KB)
PhotonSpectrum003.flair (5.4 KB)

Dear @chen2019 !

The normalization case is a bit off-topic and usually it is up to user how to normalize the results (depending on your particular problem). But I will try to make a few comments below.

In your case FLUKA results of USRBDX are normalized per photon, in the SpekPy it is per mAs, so, if you know how many photons (for you specific setup) come after mAs electrons hit anode, then you can get the normalization factor. For your case the total normalization to compare with SpekPy is \approx 1.427568e5 (see pic below), from this value 1e-6 factor arises due to conversion from 1/GeV to 1/keV, after this, your photons/cm2/keV/primary multiplied by a factor of \approx 1.427568e11 will give photons/cm2/keV/mAs, in other words \approx 1.427568e11 photons/mAs are coming in your region of interest (1 mAs is a 1e-3/1.602e-19 \approx 6.242197e15 number of electrons striking anode per second). This was obtained from this calculation! And purpose is to only demonstrate relations. Originally, this norm factor is up to you to define!

However, going back to your initial post in this thread: from this calculation you can see why you need so huge amount of primary electrons to simulate spectrum of X ray photons directly. Only a tiny fraction of total electrons bombarding anode give us a desired photons (after filtering etc): 1.427568e11/6.242197e15*100 \approx 0.00228% — efficiency of production of X rays for your case (in terms of intensity). A more classical definition of production of X rays is energy efficiency = KV x Z x 10e-6, so, for your case is about 0.65% (briefly looking I can’t find efficiency in terms of intensity to compare).

Also, see a bit modified flair file attached (3.6 KB) where a few fixies were made (USRBDX area defined, bin number changed etc)

Hope this will be helpfull!

Regards,
Ivan

2 Likes

Dear @Ivan
Thank you again for your comments, which were very useful to me and helped me better understand the conversion efficiency of X-ray.By the way,I just want to make sure that ,the kv is the voltage of the tube and Z is the atomic number of the target material, right?
Regards,
chen

Dear @chen2019 !

This is a known formula you can find one here for example.

Regards,
Ivan

Dear @Ivan
I sincerely appreciate you. You have provided me with a lot of help and research references, all of which have been very valuable.
Thank you

1 Like