RE: [fluka-discuss]: Read external file in source.f for source information

From: Francesco Cerutti <Francesco.Cerutti_at_cern.ch>
Date: Wed, 30 Jul 2014 20:57:56 +0200

Dear Zi-Yi Yang,

in addition to Joachim's considerations, note that your source.f does not
work as intended due to a couple of mistakes: in order to load two
particles in the same primary event, the WHILE condition should be (i<3)
and not (i<2), and the final RETURN statement must go outside the cycle
(after END DO).
Moreover, your REAL array declaration should be replaced by a DIMENSION
one, not to spoil your own variable precision wrt implicit double
precision.
Note also that, according to your strategy, if you run N (=1E6) events
(each loading two primary particles), results will be normalized per
primary particle and not per event, since the total weight will be 2N.

Ciao

Francesco

**************************************************
Francesco Cerutti
CERN-EN/STI
CH-1211 Geneva 23
Switzerland
tel. ++41 22 7678962
fax ++41 22 7668854

On Wed, 30 Jul 2014, Joachim Vollaire wrote:

> Dear Zi-Yi Yang
>
> Is your problem a test or a real case ? If it is a real case (you want to samples from two locations with two energies) using a source routine is maybe not the most efficient way CPU wise as you will do a call to the source routine each time you generate a particle (which at low energy could end-up being a non-negligible fraction of your transport time....). An alternative could be using the standard BEAM definition card and run two different calculations and merge the results (be careful to run the same number of primary for the two cases) / or post process the results of the two cases separately and average the results with the same weight.
>
> If you want to read from a data file, a few years ago I gave a presentation in a technical FLUKA meeting where I did this for a specific source shape, I was reading the coordinate and direction from an external data file. You find the link to the presentation below if this can help, the routine must have been updated but the principle is still the same:
>
> http://info-fluka-discussion.web.cern.ch/info-fluka-discussion/talks/Vollaire_Activation_ApplicationDump_150307.pdf
>
> Note that in my case I find more elegant to load the position during initialization and then sample randomly the starting point for each primary rather than going sequentially through the file. In the latter case there is always a chance that your distribution is not properly sample as it would depend on the number of primary run....
> Hoping this help
> Joachim
>
>
> -----Original Message-----
> From: owner-fluka-discuss_at_mi.infn.it [mailto:owner-fluka-discuss_at_mi.infn.it] On Behalf Of Rong-Jiun Sheu
> Sent: 30 July 2014 11:46
> To: fluka-discuss_at_fluka.org
> Subject: [fluka-discuss]: Read external file in source.f for source information
>
> Dear FLUKA experts,
>
> I am trying to use source.f to read some information from the .txt file which including four variables (energy, xposition, yposition, zposition) in each line. When the FLUKA runs, I hope to get the results that it will calculate 1E6 particles using first line information from the file.
> And another 1E6 particles using the second line. So I used a do while cycle but it didnąt work. Is there someone could help me ? Thanks in advance .
>
> Zi-Yi Yang
> NTHU, Taiwan
>
Received on Wed Jul 30 2014 - 22:27:04 CEST

This archive was generated by hypermail 2.3.0 : Wed Jul 30 2014 - 22:27:09 CEST