Probe Software Users Forum

Software => CalcZAF and Standard => Topic started by: Probeman on March 09, 2014, 03:17:26 pm

Title: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on March 09, 2014, 03:17:26 pm
Chad Parish asks:

Quote
I've recently found a very nice parameterization of K-shell electron-impact ionization cross-sections (Talukder et al., Int. J. Mass Spec., V269 (2008) P. 118 and V309 (2012) P. 212) which are very convenient to code into the computer.

I'm not finding similar good (or even fair) parameterizations for L or M-shells. Can anyone recommend good references from which to write code for X-ray cross-sections?

Xavier Llovet responds:

Quote
...might be interest in the attached paper. The complete cross section database will be available from NIST very soon (I'll let you know when). If he's interested in an analytical paramaterization, then Fortran subroutines are available from the on-line version of Ref.[31] (Bote et al. ATNDT 95, 871-909, 2009). As easy as it gets.

http://scitation.aip.org/content/aip/journal/jpcrd/43/1/10.1063/1.4832851
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on March 10, 2014, 12:21:53 pm
Chad,
For modeling thin films in for TEM at 80 to 300 keV you'll want to check this topic also:

http://probesoftware.com/smf/index.php?topic=57.0

To extract the k-ratios from the Penepma calculations I suggest using the "Batch Mode" dialog  as seen here:

(https://probesoftware.com/smf/proxy.php?request=http%3A%2F%2Fprobesoftware.com%2Fsmf%2Foldpics%2Fi62.tinypic.com%2F2rpxv0g.jpg&hash=3ac0379ffb16ce0c06e289569457ddaf)

and have all your calculations saved automatically as seen here (for a slightly different example):

(https://probesoftware.com/smf/proxy.php?request=http%3A%2F%2Fprobesoftware.com%2Fsmf%2Foldpics%2Fi61.tinypic.com%2F33jtox1.jpg&hash=1e5c45580e2f8903daf446b80142040e)

Finally, to *manually* extract your intensities to create k-ratios, see this post here:

http://probesoftware.com/smf/index.php?topic=59.msg221#msg221

The above link is best for understanding the gritty details, but the next post describes a new feature which allows one to simply specify the element, x-ray, a folder containing the standard intensity and the folder containing the unknown samples (a separate sub folder for each Penepma batch run).

Easy!
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on July 16, 2014, 12:45:17 pm
Here I describe a new feature which allows the user to simply specify a few parameters and the program will automatically extract k-ratios from multiple Penepma batch runs...

Starting from the Penepma Batch Mode window as seen here:

(https://probesoftware.com/smf/proxy.php?request=http%3A%2F%2Fprobesoftware.com%2Fsmf%2Foldpics%2Fi59.tinypic.com%2Fapjy1y.jpg&hash=041ef3b18f6170560097a244729d3cbb)

specify the element and x-ray to extract k-ratios for and click the Extract K-Ratios button.  The program will then ask for two folders, the first for the folder containing the (usually bulk geometry) standard intensity calculation from Penepma for that element as seen here:

(https://probesoftware.com/smf/proxy.php?request=http%3A%2F%2Fprobesoftware.com%2Fsmf%2Foldpics%2Fi60.tinypic.com%2Fs62gsm.jpg&hash=d193a7a126a0872a3436a6184c142a4e)

Note that the current standard intensity folder containing the pe-intens-01.dat file is empty (indicated by the two closed parentheses), and the program first starts in the C:\UserData\Penepma12\Batch folder to begin with. Therefore the user must browse to the actual folder containing the standard intensity file as seen here:

(https://probesoftware.com/smf/proxy.php?request=http%3A%2F%2Fprobesoftware.com%2Fsmf%2Foldpics%2Fi58.tinypic.com%2F2cs991y.jpg&hash=76792ca568c1b2c11ef54d2b6f146b2d)

Next the program will ask for the folder containing the unknown samples, and again it will start in the C:\UserData\Penepma12\Batch folder to begin with, so again, the user must browse to the actual folder containing the unknown intensities as seen here:

(https://probesoftware.com/smf/proxy.php?request=http%3A%2F%2Fprobesoftware.com%2Fsmf%2Foldpics%2Fi57.tinypic.com%2F2usudk8.jpg&hash=a9d6d93d33e17cdf406b5d51a0bb2ac0)

After specifying the unknown intensity folder (which contains sub folders created by the Penepma batch mode), the program will automatically output the calculated k-ratios for all samples to a tab delimited text file which can be edited further as necessary. An example of the output is shown here and attached below:

(https://probesoftware.com/smf/proxy.php?request=http%3A%2F%2Fprobesoftware.com%2Fsmf%2Foldpics%2Fi58.tinypic.com%2Fr0ba7p.jpg&hash=d8d07d6a41a11c7fc7866823cca9736e)

Note that if the user clicks the Extract K-ratios button a second time, the application will start at the last folder specified as seen here:

(https://probesoftware.com/smf/proxy.php?request=http%3A%2F%2Fprobesoftware.com%2Fsmf%2Foldpics%2Fi61.tinypic.com%2F34g69s5.jpg&hash=43f880aa29d4d2a296545ce949d8c590)
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on July 23, 2014, 11:51:13 am
A new method for Penepma compositional input has been added as seen here:

(https://probesoftware.com/smf/proxy.php?request=http%3A%2F%2Fprobesoftware.com%2Fsmf%2Foldpics%2Fi60.tinypic.com%2Fc3xhv.jpg&hash=925866222a39f47e7fe66ca196c857a1)

Using this method one can specify a "weight percent string" such as Fe1Ni99 to get 1 wt.% Fe and 99 wt.% Ni in a composition as seen here:

(https://probesoftware.com/smf/proxy.php?request=http%3A%2F%2Fprobesoftware.com%2Fsmf%2Foldpics%2Fi61.tinypic.com%2Fi294b4.jpg&hash=386e41363c3001a2c62b2261679e7ad7)

To differentiate this compositional name from a "formula string" such as Mg2SiO4, the program will automatically append the string "_atom" to formula composition names and the string "_weight" for weight percent string names as seen here:

(https://probesoftware.com/smf/proxy.php?request=http%3A%2F%2Fprobesoftware.com%2Fsmf%2Foldpics%2Fi57.tinypic.com%2F2yx3nl1.jpg&hash=e5142830c449958bd8aef6ebf5e83d97)

I should also mention that I have a number of pure elements calculated by Penepma at 10, 15 and 20 keV for use as standards for k-ratio calculations if anyone needs them.
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: John Donovan on July 25, 2014, 11:03:40 am
As mentioned previously I have calculated a number of pure bulk element intensities at 10, 15 and 20 keV for use as standard intensities for typical Penepma k-ratio calculations. The current version of this ZIP file is here:

http://probesoftware.com/download/BulkPureElements.ZIP

It can be extracted to the Penepma folder (usually C:\UserData\Penepma12\Penepma), for example "C:\UserData\Penepma12\Penepma\BulkPureElements" and utilized in the above Extract K-Ratios button in the Penepma Batch Mode window.

Let me know if there are other pure elements we should pre-calculate and have available to save time...
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on July 29, 2014, 02:02:17 pm
A complete set of binary alpha factors is still being calculated, but the PAR files for the specific compositions in the POUCHOU2.DAT data set are complete and I thought I would show where we are so far...

Using the default JTA/Reed phi-rho-z as a starting point we get the following reasonable results:

(https://probesoftware.com/smf/proxy.php?request=http%3A%2F%2Fprobesoftware.com%2Fsmf%2Foldpics%2Fi60.tinypic.com%2F10igrhk.jpg&hash=41987e8fdb7830a399ae13332a88f674)

Now using the Penfluor PAR files calculated for the specific compositions in the Pouchou data set, we obtain this result which includes a complete fluorescence correction with continuum:

(https://probesoftware.com/smf/proxy.php?request=http%3A%2F%2Fprobesoftware.com%2Fsmf%2Foldpics%2Fi61.tinypic.com%2Fqqab6r.jpg&hash=4ec30400c1ff199d649e5d4edeb0f033)

Now, running the same calculation using the currently available binary PAR files and fitting them as a hyperbolic relationship we obtain this result:

(https://probesoftware.com/smf/proxy.php?request=http%3A%2F%2Fprobesoftware.com%2Fsmf%2Foldpics%2Fi62.tinypic.com%2F2d8eib.jpg&hash=2c45898186566d1860e8172ea2d595c1)

Again, this is still using some phi-rho-z for the remaining uncalculated binaries, but it is showing promise!
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on September 16, 2014, 11:53:48 am
Sheri Singerling at UNM has created an excellent document on how to run Penepma to obtain k-ratios to compare with experimental measurements and this can be downloaded here:

http://probesoftware.com/smf/index.php?topic=322.msg1641#msg1641

Note that although Sheri is absolutely correct on how to locate the appropriate x-ray intensities for producing your k-ratios, there is now an automated method if you would prefer which is described here:

http://probesoftware.com/smf/index.php?topic=202.msg1506#msg1506
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on September 24, 2014, 12:45:12 pm
As mentioned previously I have calculated a number of pure bulk element intensities at 10, 15 and 20 keV for use as standard intensities for typical Penepma k-ratio calculations. The current version of this ZIP file is here:

http://probesoftware.com/download/BulkPureElements.ZIP

It can be extracted to the Penepma folder (usually C:\UserData\Penepma12\Penepma), for example "C:\UserData\Penepma12\Penepma\BulkPureElements" and utilized in the above Extract K-Ratios button in the Penepma Batch Mode window.

Let me know if there are other pure elements we should pre-calculate and have available to save time...

I have updated the BulkPureElements ZIP file with many more pure element calculations (now 75 MB) for use in extracting k-ratios from Penepma calculations as described here:

http://probesoftware.com/smf/index.php?topic=202.msg1506#msg1506

Download the update ZIP file here:

http://probesoftware.com/download/BulkPureElements.ZIP
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on October 13, 2014, 05:54:26 pm
I've updated the Bulk Pure Element ZIP file for Penepma. There are now 98 MB of pure elements calculated (at 40 degrees takeoff) and for 10, 15 and 20 keV.

These files can be utilized to automatically load intensities for "standards" for k-ratio extractions in Standard.exe. Download from here:

http://probesoftware.com/download/BulkPureElements.ZIP

Edit by John: Updated again Oct 28 2014 and now containing 102 MB of compressed Penepma pure element simulations for quant.
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on November 19, 2014, 01:55:50 pm
I've been recalculating a large number of light element binaries (to include MC modeling down to the lowest energy edge emitter) and pure elements (at twice the precision as previously, i.e., 7200 sec per beam energy versus 3600 sec per beam energy) and the results look very encouraging.

As an example of "spurious accuracy" (that is, too good to be true, but happens to be the case) I tested the N-Cr binary (seriously, it was the first one I tested!), and the results calculated using the 1% N 99% Cr in Standard.exe are seen here:

(https://probesoftware.com/smf/proxy.php?request=http%3A%2F%2Fprobesoftware.com%2Fsmf%2Foldpics%2Fi57.tinypic.com%2F2v0l7op.jpg&hash=b910561ba3b09b0c12f33d618eed1df2)

Looks pretty good for such as large matrix correction (compare the k-ratio% to the wt%), but zooming in further reveals the "spurious accuracy" mentioned previously:

(https://probesoftware.com/smf/proxy.php?request=http%3A%2F%2Fprobesoftware.com%2Fsmf%2Foldpics%2Fi58.tinypic.com%2F2nhotbq.jpg&hash=f57b3bf9519b94374461acf5e8dc54c6)

Edit by John: Note that Xavier Llovet and Cesc Salvat are fixing a bug in Penepma/Penfluor for calculation of B Ka intensities, so stay away from boron as an emitter until the new version is released.
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on December 11, 2014, 11:51:45 am
Again, remember that you should avoid modeling B Ka until the Penepma bug is fixed by Salvat and Llovet, but in the meantime you can easily model other low energy lines such as Cu La by following the instructions here:

http://probesoftware.com/smf/index.php?topic=47.msg2098#msg2098
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: John Donovan on December 19, 2014, 04:52:55 pm
Xavier Llovet reports the following on the B ka issue in Penepma/Penfluor:

Quote
Just to let you know that actually you didn't find a bug in the program. The problem comes from the database that PENELOPE uses for X-rays (EADL from Lawrence Livermore lab) that starts at Z=6, i.e. for Carbon!!

This database contains the radiative and non-radiative probabilities for all possible electron transitions so we're now trying to find these data for B, Be and Li.

I'll keep you posted.
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on June 24, 2015, 12:34:33 pm
Here's something to think about.

Here are two plots of the k-ratio (%) for Cr ka in N for both 99% Cr and 1% Cr. Interesting in the 99% plot how much difference there is between the Penfluor/Fanal Monte-Carlo output and the CalcZAF analytical expressions. See the graph attachments (you need to log in to see attachments!).

I don't think the large difference at low overvoltages is due to precision issues as the curve is very smooth.  By the way, the standard (pure Cr) was calculated at 14400 sec per beam energy. Yes, 40 hours!
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on September 05, 2015, 03:07:38 pm
I've calculated pure elements from V to Cu down to 500 eV (40 hours each simulation time) in the latest penepma12.zip file:

http://probesoftware.com/download/PENEPMA12.ZIP

These PAR files will be useful as standards for those that want to model L lines for these transition elements.
john
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: John Donovan on May 19, 2016, 05:38:44 am
In case anyone is interested, I've attached a pdf of the Penepma/Penfluor tutorial presentation I gave at the EPMA 2016 topical conference this week in Madison (remember, you have to be logged in to see attachments).

The CalcZAF and Standard apps can be downloaded here:

http://www.probesoftware.com/download/CalcZAF.msi
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: John Donovan on December 03, 2016, 06:11:31 pm
In v. 11.7.2 of CalcZAF (and Standard) I added three new parameter fields to the Penepma GUI. These are for the minimum and maximum energy range and the number of energy channels.  This required a re-compile of the Penepma.f to allow for more than 1000 energy channels.

(https://probesoftware.com/smf/proxy.php?request=http%3A%2F%2Fprobesoftware.com%3A80%2Fsmf%2Fgallery%2F1_03_12_16_6_07_14.png&hash=e50ea20588171cf1f1b9373e50e95944)

The reason for doing this is also to allow me to synthesize WDS spectra for "demo" as described here:

http://probesoftware.com/smf/index.php?topic=837.0

where we will require some 10,000 to 20,000 energy channels for simulating WDS spectral resolution...
john

PS if you specify more than 1000 energy channels in the Penpma GUI, the software will remind you that you will need to utilize the CalcZAF Help | Update CalcZAF menu as seen here:

(https://probesoftware.com/smf/proxy.php?request=http%3A%2F%2Fprobesoftware.com%3A80%2Fsmf%2Fgallery%2F1_03_12_16_6_14_44.png&hash=4b0a36f7f23d783106069ea0dd70791e)

to update your Penepma distribution.
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on May 13, 2017, 09:26:23 am
Cesc Salvat gave me the Java app that his son developed for creating Penepma geometry (*.geo) files for Penepma calculations. See attached ZIP file below (remember to login to see attachments).

I tried to run it on my laptop but didn't have Java installed.  Apparently if you have the Firefox web browser you will already have Java installed.  Nicholas Ritchie says if you do download the Java installer from Oracle, you need to:

Quote
Either double click on the jar file or "javaw -jar salvats.jar" from the cmd window having "cd”d to the jar path. You will have to complete some paths to get this to work.

Again I haven't tried this yet but wanted to get it out there ASAP for people who want to create specialized geometries that aren't included in the CalcZAF/Standard distribution.

Of course please feel free to post any .geo files you have created if you think they might be useful to the general community. 
john
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on May 29, 2017, 03:31:01 pm
After I saw Xavier's poster on optimizing the "interaction forcing factors" in the Penepma input, I had him help me modify the default forcing factors in the input files in the Penepma12.zip distribution. Use the Update Penepma12.zip option in the CalcZAF (or PFE) Help menu to get these new forcing factor input files. 

As an example here are the forcing factors in the original input file for characteristic x-ray production:

       >>>>>>>> Interaction forcing.
IFORCE 1 1 4 -10    0.1 1.0           [KB,KPAR,ICOL,FORCER,WLOW,WHIG]
IFORCE 1 1 5 -400   0.1 1.0           [KB,KPAR,ICOL,FORCER,WLOW,WHIG]

And here are the new forcing factors that Xavier implemented:

       >>>>>>>> Interaction forcing.
IFORCE 1 1 4 -10     0.9 1.0           [KB,KPAR,ICOL,FORCER,WLOW,WHIG]
IFORCE 1 1 5 -100    0.9 1.0           [KB,KPAR,ICOL,FORCER,WLOW,WHIG]

One should be able to get better precision in less time with these new parameters.
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Ben Buse on May 21, 2018, 06:31:28 am
Does anyone have a feel as to whether the number of elements slows down simulations. If I include trace elements do I reduce the precision on the majors for a given time.

Ben
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Nabil on July 11, 2018, 03:09:51 pm
Please, I am on the PENEPMA code and I would like to calculate the efficiency of the detector.

Is there information about the efficiency in the output file and how to extract them?
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on July 13, 2018, 12:21:31 pm
Please, I am on the PENEPMA code and I would like to calculate the efficiency of the detector.

Is there information about the efficiency in the output file and how to extract them?

Hi Nabil,
I am not sure I understand the question.

Are you refering to the efficiency of a real detector or the efficiency of the simulated detector?  Or are you asking about the geometric efficiency of the simulated detector (subtended angle)?

I asked Xavier Llovet about your question and he responded with this which he asked me to post for him:

Quote
PENEPMA detectors are assumed to have an intrinsic efficiency of 100% (i.e. all photons crossing the detector surface are counted) and there's no need to worry about the geometric efficiency because X-ray intensities are given in units of photons/sr/electron, so the detector size is already accounted for.

Does this answer your question?
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Nabil on July 28, 2018, 10:10:19 am
Thank you Probeman.

No my question is for the intrinsic detection efficiency, ie the number of events detected per those emitted.
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on July 28, 2018, 10:41:20 am
Thank you Probeman.

No my question is for the intrinsic detection efficiency, ie the number of events detected per those emitted.

Ah.

So the answer to that is simply the geometric efficiency of the specified detector geometry. The default in the Standard GUI for Penepma is an annular detector (360 degrees).   This is specified in this line of the .in (input) file:

PDANGL 45.0 55.0 0.0 360.0 0           [Angular window, in deg, IPSF]
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Nabil on July 28, 2018, 11:47:27 am
Good evening.
My work on this code is to calculate the intrinsic efficiency of a detector, the problem is that this detector needs at least four materials but the standard.exe interface gives the possibility to use two materials only.
Can you help me ?
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on July 28, 2018, 12:29:20 pm
Good evening.
My work on this code is to calculate the intrinsic efficiency of a detector, the problem is that this detector needs at least four materials but the standard.exe interface gives the possibility to use two materials only.
Can you help me ?

Maybe.  But can you explain what you mean by "intrinsic efficiency"?   Every photon that hits the specified Penepma detector geometry is counted, so to me that means that the "intrinsic efficiency" of the Penepma detector is 100%.  Of course since the Penepma detector is not a sphere (though one could define it as such!), some emitted photons will miss the detector. Again, as Xavier previously stated the output intensities are normalized to area so this really should not matter.

As for more than utilizing more than two materials, Standard is designed for the most common situations of a bulk material, a couple (boundary) with two materials or a thin film on a substrate. If you want to utilize more than two materials you will have to edit the Penepma .in file using a text editor.  Here is an example for using three materials in Penepma:

http://probesoftware.com/smf/index.php?topic=57.msg478#msg478

You will need to add a 4th material in your case, again using any text editor on the .in file.
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: jrminter on July 28, 2018, 05:47:58 pm
Probeman,

I appreciate the source code for the penepma-16 release. I noticed that this version is limited to 1000 energy bins. The penepma-12 version happily computes 4096. I'm guessing you modified the code. I noticed many of the variables were limited to 1000 channels. I'd be interested in  knowing what changes you made... I have the -16 release running on my Win 7 box and my macbook. Given the large code base of simulations with the -12 release, I'd like to get that to run on my mac. It is the fastest box I have... I have learned a lot getting into the code over the last few days...

Best regards,
John
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on July 28, 2018, 06:48:34 pm
Hi John,
I have not touched the 2016 FORTRAN code I sent you- it came directly from Xavier.

The default number of bins in Penepma was 1000. I changed the 2012 code to 4096. It was originally intended for EDS simulations in my Standard app. In fact in the simulation mode in Probe for EPMA the default is 1 EV per channel just so I can synthesize WDS scans!

I'm pretty sure I added comments where ever I made a change in the 2012 FORTRAN.  Most of my changes were in the Fanal code to get output of more parameters for the calculations of secondary fluorescence from boundaries.
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on July 28, 2018, 08:03:08 pm
I should also mention that Xavier asked me not to distribute any modified FORTRAN code.  That is why the Penepma FORTRAN files are not found in the CalcZAF Github site.

But below I've attached my batch files for compiling the FORTRAN using GNU.
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: jrminter on July 28, 2018, 08:13:13 pm
Thanks. I did a search and replace and changed the limits in penepma16 to permit 4096 channel spectra. It compiled as expected and I just started a run. I took a peek at the first pe-spect-01.dat file and I am indeed getting 4096 channels. Woo. Hoo!  It is late here in Rochester, so I will let this run tonight and see what I get in the morning.

The advantage of the penepma2012 code is that all the users of CalcZaf can use it. Maybe I should standardize on that and consider building the 2012 code on the mac. If you zip and send the unmodified source I will make the changes for 4096 channels and build it on the mac. I would offer to send the binaries back to you, but given Xavier's wishes, I understand why I should not send them back...

Best regards,
John
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on July 29, 2018, 08:19:57 am
Thanks. I did a search and replace and changed the limits in penepma16 to permit 4096 channel spectra. It compiled as expected and I just started a run. I took a peek at the first pe-spect-01.dat file and I am indeed getting 4096 channels. Woo. Hoo!  It is late here in Rochester, so I will let this run tonight and see what I get in the morning.

The advantage of the penepma2012 code is that all the users of CalcZaf can use it. Maybe I should standardize on that and consider building the 2012 code on the mac. If you zip and send the unmodified source I will make the changes for 4096 channels and build it on the mac. I would offer to send the binaries back to you, but given Xavier's wishes, I understand why I should not send them back...

Best regards,
John

Hi John,
I don't think Xavier cares if I send you the modified FORTRAN codes, just that I don't generally distribute them publicly.  I will send them as ZIP files to your email, and hopefully they won't get rejected by your mail server.
john
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Nabil on July 29, 2018, 08:25:58 am
But after adding the 4th material, how can you read this .in input file?
And as far as efficiency is concerned, I'm talking about the efficiency of non-geometric detection, ie the photon detection capability.
With all my respectful greetings.
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on July 29, 2018, 09:45:15 am
But after adding the 4th material, how can you read this .in input file?

Using Penepma from the Standard GUI or from the command prompt, e.g., Penepma.exe < inputfile.in

I think you should sit down with the Penepma documentation and read through it carefully.  See the file penepma.pdf and work through the section titled "An example".

And as far as efficiency is concerned, I'm talking about the efficiency of non-geometric detection, ie the photon detection capability.
With all my respectful greetings.

As Xavier and I already said, 100% of the photons that intersect the Penepma detector geometry are counted and normalized to area.
john
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Nabil on July 29, 2018, 10:31:38 am
Thank you very much my brother Probeman.
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on July 29, 2018, 02:29:26 pm
Thank you very much my brother Probeman.

You are most welcome.
john
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on July 29, 2018, 02:40:32 pm
Thanks. I did a search and replace and changed the limits in penepma16 to permit 4096 channel spectra. It compiled as expected and I just started a run. I took a peek at the first pe-spect-01.dat file and I am indeed getting 4096 channels. Woo. Hoo!  It is late here in Rochester, so I will let this run tonight and see what I get in the morning.

The advantage of the penepma2012 code is that all the users of CalcZaf can use it. Maybe I should standardize on that and consider building the 2012 code on the mac. If you zip and send the unmodified source I will make the changes for 4096 channels and build it on the mac. I would offer to send the binaries back to you, but given Xavier's wishes, I understand why I should not send them back...

Hi John,
I have to admit that I haven't had a chance to play with the Penepma 2016 code yet, but I would be very interested to learn if the input/output file formats have changed enough to break our Penepma 2012 GUI code in our Standard app.  That would be the .in input file and the Penepma output files here:

PENEPMA_DAT_File$ = PENEPMA_Path$ & "\PENEPMA.DAT"
PENEPMA_SPEC_File$ = PENEPMA_Path$ & "\PE-SPECT-01.DAT"
PENEPMA_CHAR_File$ = PENEPMA_Path$ & "\PE-CHARACT-01.DAT"

If you get a chance and compile the Penepma 2016 FORTRAN for a PC, please feel free to drop a copy of the Penepma.exe into the C:\UserData\Penepma12\Penepma folder and see if our Standard GUI still works.  I suspect it won't but it's worth a try.
john
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: jrminter on July 30, 2018, 12:01:14 pm
This was actually fun and was yet another learning opportunity. The only modification I made to Prof. Llovet's 2016 code was to increase the limit on the number of channels from 1024 to 4096. The orthoclase.in example from the 2012 version ran (using material files I created from the 2016 version of material.exe), but stopped after the first dump of the simulation. This may be a "feature" but was unexpected based on the information in the input file. I am attaching a modified input file that works as expected and is chugging along at the moment.

There are some incompatibilities between the two versions, so I would not mix the two versions in the same folder in C:\UserData\Penepma\Penepma. Note that in the standard installation, the material.exe file for the 2012 version is in the Pendbase folder. I did not want to disturb this standard set-up so I created a pair of folders in my user space.

C:\Users\username\Documents\work\penepma12

and

C:\Users\username\Documents\work\penepma16

Each of these folder has a pendbase folder that contains the appropriate material.exe and pdfiles folder for that version of the software. This keeps material files separate. The user needs to create the materials file for the 2016 version from the command line.

For a given simulation I create a subfolder with a meaningful name in the folder for the version to be used. This is where we store the .in file for the simulation, the material files to support the simulation, and the appropriate geometry file. I also include a batch file that looks like this:


cd "C:\Users\username\Documents\work\penepma16"
REM Start clean...
del /f *.dat
del /f *.rep
penepma16 < "orthoclase.in"

pause


I then have penepma executables named penepma12.exe and penepma16.exe that I put in a folder in system path. The batch file calls the appropriate exe for the simulation...

I'd be willing to zip up the files you need and get them to you. Hope this helps...

Update 6:52 pm EST: The simulation finished. I am attaching a png of the spectrum on a log scale and the pe-spect-01.dat and pe-intens-01.dat files from a 5 hr simulation.

Best regards,
John
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: jon_wade on August 07, 2018, 03:59:57 pm
Purely from recollection, for an epma with a take off angle of 40degrees, the .in takeoff angle may need to be amended (measured from the vertical)
And, personally speaking, I think, rather than running for a set time, its better to use the REFLIN option to specify an error on a line if interest.

Other things of note  - c1 and c2 should be checked to see if they influence the results.  Experience says maybe not, but depending on what your trying to achieve, they should be checked with short runs.  Efficiency is definitely optimised by choosing the input parameters - especially the cutoffs -  in this line carefully.

Actually, is anyone interested in an 'end users' guide to penepma?  Once I fully understand some of the more esoteric details of the new version, I don't mind putting something together detailing this, .geo and a basic guide to Penelope for xrf and the like (this will mean I have to bribe Xavier with a beer for three!).  But only if there's interest.....

The PENELOPE family, together with the Salvat database on cross sections are excellent resources for  things as diverse as BSE and X-ray yield across a range of analytical techniques.  The authors really cannot be given enough credit for a serious contribution and  should be both applauded and supported.


Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on August 07, 2018, 04:25:45 pm
Actually, is anyone interested in an 'end users' guide to penepma?  Once I fully understand some of the more esoteric details of the new version, I don't mind putting something together detailing this, .geo and a basic guide to Penelope for xrf and the like (this will mean I have to bribe Xavier with a beer for three!).  But only if there's interest.....

The PENELOPE family, together with the Salvat database on cross sections are excellent resources for  things as diverse as BSE and X-ray yield across a range of analytical techniques.  The authors really cannot be given enough credit for a serious contribution and  should be both applauded and supported.

Hi Jon,
I could not agree more with you. What Cesc and Xavier have done is very impressive.  They deserve enormous credit for what they have accomplished.

On the basic guide thing, one user here did start a short tutorial here (see attached pdf):

http://probesoftware.com/smf/index.php?topic=322.msg1641#msg1641

But there would be value in different approaches as you suggest and I would strongly encourage you to proceed.  I think the learning curve for Penepma is pretty steep (which is why I created a basic GUI for it in CalcZAF/Standard), so any sort of instructional manual would be very helpful. 

Maybe some "case studies"?
john
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: jrminter on August 07, 2018, 04:56:25 pm
I am very interested in your "end user guide."  I have currently been exploring the effects of changing the MSIMPA parameters for trilayer simulations where I have something like a thin C coating on ZnO on silica. I'm also interested in a case where one might replace the ZnO with a more dense material like Ag where one has something light like silica underneath.

I am aware of Sherri Singerling's document. I have been working on a R package to process the output. My goal is to run the analysis in code chunks in a Rmarkdown document for a reproducible report that could be shared with others and easily modified to extend the analysis.
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: jrminter on August 07, 2018, 07:12:42 pm
Jon Wade,

I am trying to figure out the code for the REFLIN syntax and make sure
I understand the rationale for the choices. A while ago you sent me this
example for a simulation with Ir:

REFLIN 77081500 2 1.E-2          [IZ*1e6+S1*1e4+S2*1e2,detector,tol.]

The handy code suggests it will compute IZ*1e6+S1*1e4+S2*1e2,detector,tol..

I needed the code for the shells and found table 7.2 in the
Penelope-2014 NEA document by Salvat (attached for those who are interested.)

So S1 would be 08  (M4) and S2 would be 15 (N6).

I checked the transitions with DTSA-II listTransitions('Ir') function, I get
the table below that I cropped to the transitions with a large weight.

IUPAC     Weight  Energy  Wavelength
                  (keV)     (Å)
Ir M5-N6  1.0000  1.977   6.27133
Ir M5-N7  1.0000  1.9799  6.26214
Ir M4-N6  0.5944  2.0527  6.04005
Ir L3-M5  1.0000  9.1748  1.35136
Ir L2-M4  0.4168  10.708  1.15787


I am assuming you choose the lower weighted M4-N6 because if
those statistics were good, the higher weighted L3-M5 would be better.

Did I miss anything? Do you have any other helpful hints for how to
optimize a simulation using REFLIN?

Thanks for all your help. This is a great community.

Best Regards,
John Minter
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: jon_wade on August 24, 2018, 04:25:47 am
Hi John

Can't remember why I picked M4-N6 - its possible I  didn't really care too much about which line I chose (typically, I'm not interested in Ir - we use its Fe content as a redox sensor - hence I'm usually more interested in the Fe it contains).

The REFLIN function is really nice to use if you want the same precision across a number of runs, or if you batch-up runs and want to run the next as soon as you hit a reasonable precision on an element of interest.

When the kids go back to school I'll start on an end-users guide.  I'm not sure about the change in 'channels' when binning  - the newer version merely reports intensity on lines, with the background subtracted (Pe-intens_xx.dat), and a list from the detector in pe-spect-xx.dat. I am unsure if the number of channels significantly effects the former.  I'll buy Xavier a beer and find out......

 
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: John Donovan on August 24, 2018, 05:17:16 pm
We fixed a small bug in the Penepma GUI that was not setting the WCC and WCR parameters to the same minimum energy values as the electron and photon limits.  Thank-you to Philippe Pinard who pointed this out.

We also are now setting the *position* minimum energy parameter to the same value as the electron and photon minimum energy parameters, just for those of you working with anti-matter samples!   :D
Title: Generating a convolved spectrum file with penepma
Post by: jrminter on August 24, 2018, 05:51:26 pm
The 2008 paper by Llovet and Salvat show an example in Figure 5 on p. 24 of  a "Measured spectrum from detector number 1 (see the penepma input file epma2.in) calculated by convolving the simulated spectrum with the energy resolution function of a Si(Li) detector."

I have been unable to figure out how they actually created that spectrum. I checked the CalcZAF code on github and noticed that there are references in penepma8a.bas to "PENEPMA_CONVOLG_File" but I can't see how to create this in the input file or that it is actually used. Many of you have wrestled with this code more than I have. Any chance you can explain what I am missing?

Llovett and Salvat have done great work putting this program together. It would be much easier for people to use it if the .in files for key examples were in a github repository someplace - arranged by release because the best practices have changed over time. I am assembling some examples of my own. I'd be willing to help maintain such a github repository. I have both time and interest. I suspect Jon Wade could and would contribute as well.  Do you think Llovet and Salvat would be interested is supplying some of their examples?

Best Regards,
John Minter
Title: Convolution solved...
Post by: jrminter on August 24, 2018, 08:08:02 pm
Guess I should start with a Homer Simpson Doh! I just needed to look in the right place. I noticed that CalcZAF has the programs convolg.exe, convolg_LDE.exe convolg_LIF.exe convolg_PET.exe and convolg_TAP.exe alongside penepma.exe. The first lets you input a spectrum name and an eV for convolution.  Assuming that the others are for the typical crystals. Guessing I could wrap these in batch files. For the moment I put convolg.exe in my path... Update: found the Fortran code and built these on the Mac as well...

Title: Re: Convolution solved...
Post by: Probeman on August 24, 2018, 09:31:09 pm
Guess I should start with a Homer Simpson Doh! I just needed to look in the right place. I noticed that CalcZAF has the programs convolg.exe, convolg_LDE.exe convolg_LIF.exe convolg_PET.exe and convolg_TAP.exe alongside penepma.exe. The first lets you input a spectrum name and an eV for convolution.  Assuming that the others are for the typical crystals. Guessing I could wrap these in batch files. For the moment I put convolg.exe in my path... Update: found the Fortran code and built these on the Mac as well...

Hi John,
This post has the convolution equation codes for the various WDS crystals that I modified the convolg FORTRAN with for the WDS convolg exes that you listed above:

https://probesoftware.com/smf/index.php?topic=837.msg6187#msg6187

I use the default convolg program for simulating EDS spectra and the modified codes for simulating WDS spectra, in Probe for EPMA for demonstration and teaching.  It is quite realistic.  That is correct: you don't need an actual microprobe to perform micro-analysis in PFE!    :)
john
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: jrminter on August 27, 2018, 06:42:28 am
This has been an interesting project over the weekend. I have been working with penepma16 using the REFLIN parameter to stop a simulation when it reaches a desired tolerance (relative uncertainty).  The key problem I encountered is finding suitable tolerance value that will be reached in a reasonable simulation time.

I simulated a simple example of a 100 nm Al film on Fe at 20 kV using the Fe K-L3 line for the REFLIN parameter. This is a long simulation because of the deep penetration of the electron beam into the Fe substrate at 20 kV. My objective was to be able to predict the simulation time based on the tolerance criterion.


I set up the simulation with a dump time of 120 sec. I wrote a function in R to read the penepma-res.dat file that is produced and extract the simulation time, the number of showers (trajectories) and the current value for the tolerance (relative uncertainty). I (manually) recorded the tolerance value after each dump time and stored the data file for later modeling. It ran for 2.7 hrs to get just over 25000 trajectories.

It turns out that one can predict the time to reach a given relative uncertainty (tolerance) by fitting the data to a model where the simulation time in sec is fit to (1/tolerance)^2 (see the attached plot). The coefficient for this transition was 384.5 with a standard error of 1.068. Running the simulation to a tolerance of 0.2 required 2.7 hrs. Running the simulation to a tolerance of 0.05 would require 42.7 hrs!

I suspect that the time to reach a given tolerance would be lower for measurements at lower accelerating voltages because each trajectory would be shorter.

This is a work-in-progress. The function call will fail if penepma is writing the penepma-res.dat file at the time the query is made. I am still figuring out how to automatically run the query in a loop and write the results to a file for later analysis.
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: neko on September 05, 2018, 04:20:43 pm
I'm curious if anyone knows whether or not this problem could also be solved via a GPU platform. My understanding is that they're great when you have the same starting data but not necessarily efficient if you have to keep loading in new operations, and I don't know enough about how these things are calculated to even make a guess as to whether or not it would be useful to look in to.

Any thoughts? I've done a bit of spot reading, and it looks like if enough data can be loaded into the initial set (eg you're not constantly sending and retrieving the data through the PCIe bus) and the process is parallelizable it *might* work. Of course, might also be cheaper to just rent some Amazon EC2 time and do several days of computing in an hour.
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: jrminter on September 05, 2018, 05:38:30 pm
Neko, I suspect a port to use a GPU would be a major undertaking. The base penelope/penepma code only uses a single core. There is a provision for using different random number seeds, running multiple simulations on different cores and combining the results. There is also a multi-core version developed by Oak Ridge National Laboratories. I understand that there are differences in input because of this. I have not heard any one on this forum claim to use it.

My main purpose in running the experiment to understand how the required simulation time varied with the desired precision was to get an idea how to manage an uncertainty budget in an analysis and to be able to predict how long a simulation with a desired uncertainty would take based on a trial simulation.

More of my effort has been dedicated to designing a R package to automate analysis of the output and make it easier to write a reproducible report. I found myself repeatedly writing similar code, which is a key sign that one needs to package functions under version control and use unit tests.

Hope this helps,
John
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: John Donovan on September 20, 2018, 01:59:01 pm
Philippe Pinard, Hendrix Demers and I recently noticed that the x-ray intensities calculated from using a few of the pure element PAR files in the Standard GUI for Penefluor/Fanal were not correct.  This was only the case for the gaseous elements: N, O, F, Ne, Cl, Ar, Kr, Xe and Rn.  Now I don't suppose that many of you actually utilize pure gases as standards, even for your simulations, but we discovered the issue while writing up a paper on the use of alpha factors from Monte Carlo generated intensities

This was because I had assumed the room temperature densities for calculating the material files for these gaseous elements (if we had evolved on Pluto this would not have been an issue!).   :D

The gaseous densities (~10^-3) were problematic because the default "bulk" geometry file (bulk.geo), specifies a thickness of only 0.1 cm or 1 mm. This makes these gaseous pure elements essentially a thin film experiment where some of the incident electrons actually transmit through the specimen geometry resulting in too low a generated x-ray intensity!  Our solution was to simply force the pure gaseous element densities to 1.0 if they were less than 1.0.  Obviously you can modify the densities from the GUI to whatever values you want and re-calculate them, and/or edit the bulk.geo file geometry, if you prefer.

So we re-calculated these gaseous pure elements (N, O, F, Ne, Cl, Ar, Kr, Xe and Rn) and they are now available for download by using the Help | Update menu in either CalcZAF or Probe for EPMA, by checking the Update Penepma Monte Carlo Files as seen here:

(https://probesoftware.com/smf/gallery/1_03_12_16_6_14_44.png)

Remember, if you haven't updated CalcZAF and/or Probe for EPMA since we switched to secure https connections in August this year, you will need to manually download the CalcZAF.msi and/or ProbeForEPMA.msi installers on this page:

https://probesoftware.com/Update.html

and run the installer manually once.  After this, you can continue to update CalcZAF and/or Probe for EPMA from the Help | Update menu again.

Or you can manually download the Penepma12.zip file from the various download sites if you prefer and unzip it to your user data folder (usually C:\UserData\Penepma12). The actual pure element PAR files are in the \Penfluor\Pure sub folder.
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on December 21, 2018, 12:57:15 pm
Attached is a plot of some BSE simulations I did recently for pure elements in Penepma (Penelope) 2012 (please login to see attachments).

My question is: are these BSE fluctuations for these pure elements, e.g., around Z = 35 or so, we are seeing in the Penepma calculations, confirmed by empirical measurements?  What I mean, is there a physical basis for these BSE fluctuations in the Penepma modeling?  Or is it an artifact of the elastic scatter modeling in Penepma?

I asked Xavier Llovet and he said: good question!

As he also pointed out, it would be difficult to get enough sensitivity to see this empirically, but I might give it a try. Does anyone have any thoughts on whether this is just a modeling artifact?  Has any one tried to see this with other MC software?
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on January 07, 2019, 04:54:33 pm
I posted an image in the previous post as an attachment a few days before Christmas so not sure how many people saw it.  Here it is again as an in-line image:

(https://probesoftware.com/smf/gallery/395_07_01_19_4_45_28.png)

At that time I asked if anyone had noticed whether any other MC software packages show the same discontinuous trends (e.g., around Z=35), for the pure elements. 

I haven't had a chance to try other MC programs, but I wondered (because this data was calculated from several different computers), if these discontinuities were just an artifact of statistics, so I ran a longer calculation on a single computer over the holidays and obtain this for pure elements between Z = 30 to 40:

(https://probesoftware.com/smf/gallery/395_07_01_19_4_46_48.jpeg)

The variances are shown as the tiny errors bars.  So at least Penepma is consistent.  But why these discontinuities occur, for example between Se (34) and Br (35), I have no idea.
john
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on January 08, 2019, 11:04:20 am
So in addition to the small increase in BSE from atomic number 34 to 35 (Se to Br):

34   0.3389
35   0.3393

There is also a small change (actually a decrease!) from 58 to 59 (Ce to Pr):

58   0.4277
59   0.4276

Does this make any sense to anyone?
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: JonF on January 10, 2019, 08:12:25 am
Yeah, it does make sense in my head at least - this is what I was thinking about back in August on the brain teaser thread (assuming I'm right, of course - something which should never be assumed!). Link to the brain teaser thread:https://probesoftware.com/smf/index.php?topic=1111.msg7468#msg7468 (https://probesoftware.com/smf/index.php?topic=1111.msg7468#msg7468).

To paraphrase Goldstein et al*, the elastic scattering events that combine to form the BSE emission result from an interaction of the primary electron beam with the electrical field of an atom i.e. the positive nuclear charge of an atom as shielded by the electron cloud.   

It is this effect of the electron shielding that I think you are seeing here.

I've pulled some numbers off the web for the effective nuclear charge at the valence shell (which shell is valence? discussed briefly below) and plotted these up in the attached images - I hope you agree the plot for the effective nuclear charge, Zeff, as a function of atomic number for the elements Z= 30 to 40 looks similar to the plot of BSE coefficient vs Z. What I haven't figured out is why it appears to be offset by 1 compared to your data?

The plot of the 6s subshell for Z = 55 to 61 also show the decrease you were referring to (and in the right place this time!). I've plotted up the 6s and 4f subshells for Caesium (Cs) to Promethium (Pm) (no 4f for Cs and Ba - the 4f energy level is higher than the 6s and so 6s fills first). Why does the 6s subshell show the BSE pattern whereas the 4f doesn't if the 4f is higher energy and so shouldn't it be further from the nucleus and therefore the valence orbital? Not quite... Despite the 4f being higher energy than the 6s, the 4f electrons have a higher probability of being closer to the nucleus than the 6s owing to the shape of the orbitals. The Encyclopedia Britannica actually has a nice diagram of the probability of electron position for Gadolinium (Z= 64) with electron configuration [Xe].4f7.5d1.6s2:
(https://www.britannica.com/science/rare-earth-element/media/491579/187149)
(link for if the image doesn't work: https://www.britannica.com/science/rare-earth-element/media/491579/187149 (https://www.britannica.com/science/rare-earth-element/media/491579/187149))

Further to this, the filling of the subshells in the lanthanide series also unusual: the electron configurations of Cs and Ba are as expected [Xe].6s1 and [Xe].6s2; but La skips the 4f subshell and starts filling up the higher energy 5d subshell [Xe].5d1.6s2; Ce starts filling up the 4f subshell [Xe].4f1.5d1.6s2; and then Pr dumps the 5d subshell and moves the electron in to the 4f to get [Xe].4f3.6s2 (no 5d electrons).

I think all the wobbles and fluctuations you see through the BSE vs Z model that has been posted are mostly caused by these electron subshell filling/nuclear screening artefacts. If so, I'm actually quite impressed that the MC simulations show it.

*Scanning Electron Microscopy and X-Ray Microanalysis, 4th Ed., Chapter 1, page 4

Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on January 10, 2019, 11:20:39 am
Hi Jon,
Wow, this is super interesting!

First of all the BSE brain teaser that Ben and you and I were discussing is a slightly different issue (in my mind anyway), as that is more related I think to how one should calculate average Z for compounds.  Hence the Z fraction to the 0.7 exponent model. The value of 0.7 for the exponent is necessary to calculate the effect of nuclear screening by inner orbitals in higher atomic number elements (it's why the BSE coefficient tends to increase less as Z increases). That and the fact that the number of neutrons tends to increase faster than the number of electrons and protons as the atomic number increases is why using mass fraction skews the average zbar calculation at higher atomic numbers.  See a plot of A/Z for the periodic table and it will make sense.

If it wasn't for this nuclear screening, we could just use a simple z fraction for compounds.  By the way, if you'd like to compare a number of average Z calculations, simply check the Calculate Alternative Zbars in the Output menu of the Standard application. 

Now as for these wriggles in the plot of the pure elements I think you nailed it.  I would never have guessed that the outer electron shells would have that much effect on elastic scattering.   Though I agree that it's odd about the change in BSE coefficient from 34 to 35, versus the change from 35 to 36 in the effective charge.  But I double checked the Penepma calculations and I did seemingly type them into the spreadsheet correctly from the penempa.dat files. Here is a section:

Atomic Number   BSE Coefficient   BSE variance   Zbar (mass)   Zbar (zfrac)   Zbar (zfrac^0.7)
29   0.3130   0.00015   29   29   29
30   0.3175   0.00015   30   30   30
31   0.3233   0.00015   31   31   31
32   0.3308   0.00016   32   32   32
33   0.3346   0.00016   33   33   33
34   0.3389   0.00016   34   34   34
35   0.3393   0.00008   35   35   35
36   0.3445   0.00008   36   36   36
37   0.3492   0.00009   37   37   37
38   0.3527   0.00009   38   38   38

Attached below is the complete Excel spreadsheet with the Penepma pure element values.
john
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: JonF on January 11, 2019, 12:09:58 am

Hi John,


First of all the BSE brain teaser that Ben and you and I were discussing is a slightly different issue (in my mind anyway), as that is more related I think to how one should calculate average Z for compounds.


Yeah, I realised at the time that I'd wandered off on a tangent. The thing that got me started there wasn't the average atomic number, but rather why were we using the atomic number at all - integer values always seem a bit too convenient! That said, trying to determine the average Z[eff] to account for bonded atoms in an unknown material might be challenging!


The value of 0.7 for the exponent is necessary to calculate the effect of nuclear screening by inner orbitals in higher atomic number elements (it's why the BSE coefficient tends to increase less as Z increases).


I assume this is in addition to the decreasing proportional effect of adding one more proton to the nucleus e.g. adding 1 proton to H will double the proton number, add 1 proton to La makes less of a proportional difference (1/57)?


Now as for these wriggles in the plot of the pure elements I think you nailed it.  I would never have guessed that the outer electron shells would have that much effect on elastic scattering.   Though I agree that it's odd about the change in BSE coefficient from 34 to 35, versus the change from 35 to 36 in the effective charge.  But I double checked the Penepma calculations and I did seemingly type them into the spreadsheet correctly from the penempa.dat files. Here is a section:
Atomic Number   BSE Coefficient   BSE variance   Zbar (mass)   Zbar (zfrac)   Zbar (zfrac^0.7)
29   0.3130   0.00015   29   29   29
30   0.3175   0.00015   30   30   30
31   0.3233   0.00015   31   31   31
32   0.3308   0.00016   32   32   32
33   0.3346   0.00016   33   33   33
34   0.3389   0.00016   34   34   34
35   0.3393   0.00008   35   35   35
36   0.3445   0.00008   36   36   36
37   0.3492   0.00009   37   37   37
38   0.3527   0.00009   38   38   38



That is strange - I'm wondering whether we're looking at a spatial effect as well as a screening effect ie the probability of where the primary beam electron would interact with the atom and whether this occurs between shells or is considered only outside of the atom (and hence would experience the complete shielding effect as seen by the valence shell).
Or whether the numbers either penepma - or more likely I - used are wrong - there was a bit of variation in the numbers I found..
Either way, there's obviously something else going on here that I haven't figured out yet...
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on May 03, 2019, 10:10:10 am
This question came up off-line so I thought I would mention it here.

When running Penepma from the GUI in the Standard application, the random seed is *not* varied. This is for reproducibility of results.

However when running Penepma from Probe for EPMA to simulate EDS spectra, the random seed *is* varied.

To add a random seed in the Penepma input file simply add a line like this to your .in file:

RSEED  1 2                  [Seeds of the random-number generator]

The defaults are 1 and 2 so you should change them if you want to simulate random statistics, though the Penepma documentation does not explain exactly how they are utilized that I can find. Except for this bit of code:

Code: [Select]
C *********************************************************************
C FUNCTION RAND
C *********************************************************************
FUNCTION RAND(DUMMY)
C
C This is an adapted version of subroutine RANECU written by F. James C (Comput. Phys. Commun. 60 (1990) 329-344), which has been modified to
C give a single random number at each call.
C
C The 'seeds' ISEED1 and ISEED2 must be initialised in the main program
C and transferred through the named common block /RSEED/.
C
IMPLICIT DOUBLE PRECISION (A-H,O-Z), INTEGER*4 (I-N)
PARAMETER (USCALE=1.0D0/2.147483563D9)
COMMON/RSEED/ISEED1,ISEED2
C
I1=ISEED1/53668
ISEED1=40014*(ISEED1-I1*53668)-I1*12211
IF(ISEED1.LT.0) ISEED1=ISEED1+2147483563
C
I2=ISEED2/52774
ISEED2=40692*(ISEED2-I2*52774)-I2*3791
IF(ISEED2.LT.0) ISEED2=ISEED2+2147483399
C
IZ=ISEED1-ISEED2
IF(IZ.LT.1) IZ=IZ+2147483562
RAND=IZ*USCALE
C
RETURN
END

and the following text:

Quote
1.2.1 Random-number generator
In general, random-sampling algorithms are based on the use of random numbers » uniformly distributed in the interval (0,1). These random numbers can be easily generated on the computer (see, e.g., Kalos and Whitlock, 1986; James, 1990). Among the \good" random-number generators currently available, the simplest ones are the so-called multiplicative congruential generators (Press and Teukolsky, 1992). A popular example of this kind of generator is the following,

Rn = 75Rn¡1 (mod 231 ¡ 1); »n = Rn=(231 ¡ 1); (1.30)

which produces a sequence of random numbers »n uniformly distributed in (0,1) from a given \seed" R0 (< 231 ¡ 1). Actually, the generated sequence is not truly random, because it is obtained from a deterministic algorithm (the term \pseudo-random" would be more appropriate), but it is very unlikely that the subtle correlations between the values in the sequence have an appreciable e®ect on the simulation results. The generator (1.30) is known to have good random properties (Press and Teukolsky, 1992).

However, the sequence is periodic, with a period of the order of 109. With present-day computational facilities, this value is not large enough to prevent re-initiation in a single simulation run. An excellent critical review of random-number generators has been published by James (1990), where he recommends using algorithms that are more sophisticated than simple congruential ones. The generator implemented in the Fortran 77 function RAND (Table 1.1) is due to L'Ecuyer (1988); it produces 32-bit floating-point numbers uniformly distributed in the open interval between zero and one. Its period is of the order of 1018, which is virtually inexhaustible in practical simulations.
Title: Re: Penelope/Penepma/Penfluor/Fanal Monte-Carlo Software and Physics
Post by: Probeman on June 11, 2019, 03:38:19 pm
The small "steps" in the calculated BSE that I saw in Penepma 2012 appear to simply be statistical in nature. Varying the random seed for 4 different simulations I got this:

(https://probesoftware.com/smf/gallery/395_11_06_19_3_33_39.jpeg)

This is using these 4 seed statements:

RSEED  1 1                     [Seeds of the random-number generator]
RSEED  2 2                     [Seeds of the random-number generator]
RSEED  3 2                     [Seeds of the random-number generator]
RSEED  4 2                     [Seeds of the random-number generator]

I still find it odd that the variation doesn't appear totally random, but I'm guessing that these "steps" are not significant.