Author Topic: Getting Started With CalcZAF  (Read 22533 times)

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3341
  • Other duties as assigned...
    • Probe Software
Getting Started With CalcZAF
« on: October 17, 2013, 04:31:51 PM »
A very nice tutorial for quantitative calculations in CalcZAF can be performed using the default CalcZAF.dat input file.  The following post is a step by step exercise discussing the various data types in this input file and options for the quantitative calculations.

If you do not have CalcZAF already installed on your computer, you can download it for free here:

https://www.probesoftware.com/download/CalcZAF.msi

Assuming you already have CalcZAF installed, you should first check that it is up to date by running the Help | Update CalcZAF menu and clicking the Download Update button and following the on-screen directions.

When finished updating CalcZAF we can start by running CalcZAF.exe, and clicking the File | Open menu and selecting the default CalcZAF.DAT file as seen here:



Note that the format of this file is documented in the Probe for EPMA User Reference manual which can be accessed by hitting the F1 key in CalcZAF. You can also output CalcZAF format files from Probe for EPMA for test purposes. The first "sample" which is MgO will be loaded to the Calculate ZAF Corrections window as seen here:



Note that the first calculation option "Calculate Intensities From Concentrations" is automatically selected because that is specified in the CalcZAF.dat file. Note that if you enter a composition from a formula or the standard database, this is the default option for calculation. Next click the Calculate button and the results will be output to the ZAF Calculations and log windows as seen here:



Note the calculated k-ratios along with a number of other useful parameters. You can click on the element row to change the element concentrations or the Analytical | Operating Conditions menu to change the keV and then click the Calculate button again as desired.

We can now load the next "sample" in the CalcZAF.Dat file by clicking the Load Next Dataset From Input File as shown here:



and see that it is a calculation of concentrations from Fe, Si and O unknown *and* standard intensities and of course the standard compositions. When the Calculate button is again clicked we see the following results:



Now an interesting option is the ability to compare the results of the 10 different matrix corrections (and 6 different mass absorption coefficient tables) in CalcZAF- courtesy of John Armstrong who wrote the original CITZAF code. This is performed by simply checking the Use All Matrix Corrections checkbox shown here and again clicking the Calculate button:



The tabulated results can be seen listed in the log window after clicking OK and then exporting the results to Excel (if available):



The next sample is an alloy steel, again unknown and standard intensities with pure element standards:



This next sample is an iron oxide calculated from raw k-ratios and standard compositions only:



This example is again MgO, but compositions calculated from unknown k-ratios normalized to pure elements:



This next sample is magnetite (Fe3O4) calculated from unknown and standard counts (and standard compositions) with oxygen calculated by stoichiometry:



The excess oxygen when Fe is displayed as FeO is visible here:



This next example is Si calculated by difference. The calculation by difference and other calculation options in CalcZAF are accessed with the Calculation Options button shown here:



This is a slightly more complicated calculation where oxygen is calculated by stoichiometry and Fe is calculated by stoichiometry to the stoichiometric oxygen. Therefore the only element actually measured in this example was Si!



Note that the above type of calculation is often applied to carbonates where only the cations (Ca, Mg, Fe, Mn, etc) are measured, oxygen is calculated by stoichiometry and carbon is calculated by stoichiometry to the calculated oxygen by the rule 0.333 carbon atoms for each oxygen atom.

The remaining examples are similar to what we have already looked at above, but a few others deserve additional explanation.  This example of calculating stoichiometric oxygen in a matrix where some of the oxygen is replaced by a halogen element is interesting:



Because the matrix correction was calculated with the assumption of stoichiometric oxygen as shown above, the absorption correction of F ka by oxygen is over calculated. Particularly since the absorption of F ka by oxygen is quite severe. However, by simply applying a correction for oxygen equivalent of halogen in the matrix iteration we can rigorously calculate the proper absorption correction for F ka by stoichiometric oxygen as seen here:



The modified absorption correction and results are seen here and it is worth noting that without the subtraction of the oxygen equivalent of fluorine from the calculated oxygen during the matrix correction, the fluorine values will be in error by over 20% relative (9.252 wt% without the halogen equivalent correction and 9.023 wt% with the halogen equivalent correction in the matrix correction)!



Finally note that the standard used for fluorine should be entered properly into the standard composition database (Standard.mdb) with the oxygen equivalent of halogen applied as seen here:



There are many other calculation options available in CalcZAF, but this post should get you started. As always, please let us know if you have any questions related to this post.

A couple of documents that you might find useful:

http://epmalab.uoregon.edu/pdfs/JTA-1988-ZAF.pdf

http://epmalab.uoregon.edu/pdfs/CalcZAF,%20TryZAF%20and%20CITZAF.pdf
« Last Edit: May 21, 2020, 01:00:04 PM by John Donovan »
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3341
  • Other duties as assigned...
    • Probe Software
Re: Getting Started With CalcZAF
« Reply #1 on: December 23, 2013, 09:15:56 AM »
Here's a different approach to getting started with CalcZAF, that explains the output in some detail.

After launching CalcZAF, first click the Enter Composition as Formula String and enter any compound formula, for example, CaMgSi2O6:



Then enter the formula in the formula field as shown here:



After clicking OK, you will see the following the the Calculate ZAF Corrections window:



Note that the formula you entered has been converted automatically to concentrations (normalized to 100% of course).  One can modify the conditions (take off angle, keV, etc, using the Analytical | Operating Conditions menu or the calculation options using the Analytical | ZAF, Phi-Rho-Z, Alpha Factor and Calibrations Curve Selections menu as seen here:



Now click the Calculate button and you will see the Std K-fac. output in the Calculate ZAF Corrections window as seen here:



Because you entered a composition, the program assumes you want to calculate intensities (k-ratios) from concentrations (mole formulas or concentration strings, or from the standard database).

If you want to calculate a composition from intensities, simply click on each element and enter the appropriate intensities and standard information.

In the meantime let's examine the log window output in more detail as seen here:



If you have further questions please post them here...
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

jared.wesley.singer

  • Post Doc
  • ***
  • Posts: 17
Re: Getting Started With CalcZAF
« Reply #2 on: October 29, 2014, 08:49:00 AM »
Hello World,

I have a further question:

Has anyone created a CalcZAF input file or process for mixed carbonate, sulfate, and phosphate?  Can the "Use Oxygen From Halogens Correction" be rigged for oxyanions? 

In this case I measured minor S and P in forams.  For each sulfur I'll get SO3C, and there will be excess oxygen because the SO42- should replace CO32- as do halogens; similar for phosphorus:

3,7,15,40,"foram6",0,0,0
 1            ""            "c"            0.3333       ""            ""             0
"Mg"          "ka"           1             1             32767         0             0.006504      1
"Ca"          "ka"           1             1             32767         0             0.357064      1
"Sr"          "la"           1             1             32767         0             0.000967      1
"S"           "ka"           1             3             32767         0             0.000114      1
"P"           "ka"           2             5             32767         0             0.001124      1
"O"           ""             1             0             0             0             0             0
"C"           ""             1             2             0             0             0             0

Thanks for any ideas on how to improve this kind of analysis,

Jared
« Last Edit: October 29, 2014, 09:47:06 AM by John Donovan »

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3341
  • Other duties as assigned...
    • Probe Software
Re: Getting Started With CalcZAF
« Reply #3 on: October 29, 2014, 09:47:57 AM »
Has anyone created a CalcZAF input file or process for mixed carbonate, sulfate, and phosphate?  Can the "Use Oxygen From Halogens Correction" be rigged for oxyanions? 

In this case I measured minor S and P in forams.  For each sulfur I'll get SO3C, and there will be excess oxygen because the SO42- should replace CO32- as do halogens; similar for phosphorus...

I guess you could just "specify" a fixed concentration for the matrix effects- it isn't that important for trace and often minor elements...  also check out this fun post:

https://probesoftware.com/smf/index.php?topic=92.msg520#msg520
 
« Last Edit: August 24, 2018, 05:05:03 PM by John Donovan »
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Probeman

  • Emeritus
  • *****
  • Posts: 2878
  • Never sleeps...
    • John Donovan
Re: Getting Started With CalcZAF
« Reply #4 on: December 04, 2014, 01:50:54 PM »
On certain Win7 computers (but only on some of them!), when you perform an update from the Help menu, you follow the msi installer prompts to update CalcZAF and you will sometimes get this error after clicking the Install button:



After much investigation we have to admit we do not understand this error (we tried all the suggestions we found after googling this error and nothing seems to fix the issue).

However, if you simply browse to the Probe for EPMA application folder (usually C:\Probe Software\Probe for EPMA) and just double-click the CalcZAF.msi installer that you downloaded, the msi installer  will run fine the 2nd time.

This might be related to recent reports of other Windows installer errors for Skype and Adobe. If you figure out what Microsoft did and know how to fix it, please tell us!
The only stupid question is the one not asked!

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3341
  • Other duties as assigned...
    • Probe Software
Re: Getting Started With CalcZAF
« Reply #5 on: August 21, 2015, 08:23:23 AM »
I recently modified the app registration process in CalcZAF (and PFE), so with v. 10.9.9 the software can now install and run properly under Japanese and Chinese (Unicode) Windows OS.
john
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Probeman

  • Emeritus
  • *****
  • Posts: 2878
  • Never sleeps...
    • John Donovan
Re: Getting Started With CalcZAF
« Reply #6 on: August 26, 2015, 12:58:22 PM »
I made some slight changes to the default xline.dat, xedge.dat and xflur.dat emission, edge energy and fluorescent yield files, which resulted in some slight differences in the calculations as shown in the attached images for the Henke and FFAST MACs.  These changes will not affect your current version (this goes to!) 11 PFE installation as the xline.dat, xedge.dat and xflur.dat files are not overwritten.
« Last Edit: May 08, 2020, 12:02:30 PM by John Donovan »
The only stupid question is the one not asked!

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3341
  • Other duties as assigned...
    • Probe Software
Re: Getting Started With CalcZAF
« Reply #7 on: May 08, 2020, 12:03:12 PM »
To edit the emission (and edge) energy tables in CalcZAF (or Probe for EPMA), start CalcZAF and utilize these two menus.  The emission line energies (in eV) are in XLINE.DAT and the edge energies (also in eV) are in XEDGE.DAT, both found in the C:\ProgramData\Probe Software\Probe for EPMA folder.



Note that because the CalcZAF/PFE installer tags these files (and the fluorescent yield XFLUR.DAT file) as NeverOverwrite="yes" and Permanent="yes", they will never get overwritten or removed by the subsequent updates by CalcZAF or PFE.  But you should back up any edited files yourself of course!
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

jrminter

  • Professor
  • ****
  • Posts: 72
Re: Getting Started With CalcZAF
« Reply #8 on: July 10, 2020, 01:04:35 AM »
I spent some time trying to recall how to write input files for CalcZAF. I found lots of ways that did not work. I recorded what did.

John Donovan encouraged me to add my observations here.  Karl Broman, a statistician I admire, wrote: "Your closest collaborator is you, six months from now. You don't respond to email."  In that spirit, I recorded these instructions in case anot to help myself later and perhaps others who read this will find it helpful. One can also process several datasets sequentially in a single text file...

1. Open "Standard"

2. Choose "standard.mdb"  (Date-stamp 2020-07-02) from   
   `C:\\ProgramData\\Probe Software\\Probe for EPMA`

3. Open CacZAF

4. `File` -> `Open CalcZaf input` (1st menu option)

5. Choose the data file. In this case: `mgo_test.dat` (see contents below)

```
0,2,15,40.,"MgO K-ratio"
2,"","",0.0,"","",0.0
"mg","ka",1,1,0,60.0,0.0,0.0
"o","ka",1,0,0,40.0,0.0,0.0
```

6. Press `Calculate`

7. Copy and save the results (see below) Also note that you can include several different analyses in a single (plain text) file. Be careful to use standard quotes in the file: "" 


MgO K-ratio

Current Mass Absorption Coefficients From:
LINEMU   Henke (LBL, 1985) < 10KeV / CITZMU > 10KeV

  Z-LINE   X-RAY Z-ABSOR     MAC
      Mg      ka      Mg  4.8748e+02
      Mg      ka      O   2.5312e+03
      O       ka      Mg  5.1854e+03
      O       ka      O   1.1999e+03

 ELEMENT  ABSFAC  ZEDFAC  FINFAC STP-POW BKS-COR   F(x)e
   Mg ka  1.1541  3.9877  4.6021   .2317   .9240   .8665
   O  ka  1.4270  3.9154  5.5873   .2438   .9546   .7008

SAMPLE: 32767, TOA: 40, ITERATIONS: 0, Z-BAR: 10.4

 ELEMENT  ABSCOR  FLUCOR  ZEDCOR  ZAFCOR STP-POW BKS-COR   F(x)u      Ec   Eo/Ec    MACs
   Mg ka  1.2478  1.0000  1.0213  1.2744  1.0339   .9878   .6944  1.3050 11.4943 1304.97
   O  ka  1.7573   .9979   .9664  1.6948   .9518  1.0153   .3988   .5317 28.2114 3591.16

 ELEMENT   K-RAW K-VALUE ELEMWT% OXIDWT% ATOMIC% FORMULA KILOVOL                                       
   Mg ka  .00000  .47081  60.000   -----  49.684   1.000   15.00                                       
   O  ka  .00000  .23602  40.000   -----  50.316   1.013   15.00                                       
   TOTAL:                100.000   ----- 100.000   2.013

« Last Edit: July 10, 2020, 09:11:22 AM by John Donovan »

jrminter

  • Professor
  • ****
  • Posts: 72
Re: Getting Started With CalcZAF
« Reply #9 on: July 10, 2020, 01:12:32 AM »
And here I attach the properly formatted dataset with 4 use cases

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3341
  • Other duties as assigned...
    • Probe Software
Re: Getting Started With CalcZAF
« Reply #10 on: July 10, 2020, 11:55:45 AM »
Hi John,
Yes, this is correct. I should document this better on the forum here.  Here is an explanation of the first parameter (zero in your example for calculating intensities (k-ratios) from composition taken from the PFE User Reference manual:

Quote
CalcZAF allows the user to perform various types of calculations for concentrations to intensities or intensities to concentrations:

Mode 0. Concentrations to intensities- this option calculates the elemental k-factors for the specified concentrations. This is similar to the normal standard k-factor calculation performed for the primary standards by Probe for EPMA. Note that although Probe for EPMA only performs an "elemental" standard k-factor calculation, CalcZAF can also perform an "oxide" standard k-factor calculation. Requires elemental concentrations.

Mode 1. Count intensities to concentrations- this calculation calculates elemental concentrations using both unknown and standard intensities and an assigned standard to calculate the standard k-factor for each "analyzed" element. Intensities for the standard and unknown must be in the same units.

The program will automatically calculate the standard k-factors for each element, however the correct standard must first be assigned from the list of standards in the run. See the Standards | Add/Remove Standards To/From Run menu item to add standards to the run that can be assigned to the "analyzed" elements.

Mode 2. Raw k-ratio intensities to concentrations- this calculation is similar to the above, except that the standard intensity is not required to be entered as it is already "included" in the raw unknown k-ratio. Note that a standard must still be assigned to each "analyzed" element.

Mode 3. K-ratio intensities to concentrations- this calculation is based on an already "normalized" elemental k-ratio (to 1.000). Therefore, only the element, x-ray and unknown "intensity" must be entered for the calculation to be performed. No standard assignments are required, however the program will assign a "dummy" standard assignment of 32767 to each analyzed element.

This "mode" parameter is also the index for the options in the Calculate ZAF and Phi-Rho-Z Corrections window. So the first line of each sample in the input data file contains the "mode", number of elements and the operating voltage and takeoff-angle as seen here:

Quote
' Read calculation mode (0, 1, 2, or 3), number of elements, kilovolts and takeoff, (optional sample name)
Input #3, CalcMode%, LastChan%, Kilovolts!, Takeoff!, (SampleName$)

' Read oxide/elemental mode, difference, stoichiometry, relative
Input #3, OxideOrElemental%, DifferenceElement$, StoichiometryElement$, StoichiometryRatio!, RelativeElement$, RelativeToElement$, RelativeRatio!

' Loop on each element
For i% = 1 To LastChan%
Input #3, Elsyms$(i%), Xrsyms$(i%), NumCat%(i%), NumOxd%(i%), StdAssigns%(i%), ElmPercents!(i%), UnkCounts!(i%), StdCounts!(i%)
next i%

Note:
CalcMode% = 0 for calculation of k-ratios from concentrations
CalcMode% = 1 for calculation of concentrations from unknown and standard intensities
CalcMode% = 2 for calculation of concentrations from "raw" k-ratios (no standard intensities necessary)
CalcMode% = 3 for calculation of concentrations from "normalized" k-ratios (no standards necessary)

Note:
OxideorElemental%=1 calculate oxide output based on stoichiometry
OxideorElemental%=2 calculate as elemental output (default)

The code for reading a sample from the input is shown here:

Code: [Select]
' Check for end of file
If EOF(ImportDataFileNumber%) Then GoTo CalcZAFImportNextEOF

' Initialize
Call CalcZAFInit
If ierror Then Exit Sub

' Init sample
Call InitSample(CalcZAFOldSample())
If ierror Then Exit Sub
Call InitSample(CalcZAFTmpSample())
If ierror Then Exit Sub
Call InitSample(CalcZAFNewSample())
If ierror Then Exit Sub

' Load particle parameters
CalcZAFOldSample(1).iptc% = iptc%
CalcZAFOldSample(1).PTCModel% = PTCModel%
CalcZAFOldSample(1).PTCDiameter! = PTCDiameter!
CalcZAFOldSample(1).PTCDensity! = PTCDensity!
CalcZAFOldSample(1).PTCThicknessFactor! = PTCThicknessFactor!
CalcZAFOldSample(1).PTCNumericalIntegrationStep! = PTCNumericalIntegrationStep!

' Increment sample count
CalcZAFSampleCount% = CalcZAFSampleCount% + 1

' Read first line and parse
CalcZAFLineCount& = CalcZAFLineCount& + 1
Line Input #ImportDataFileNumber%, astring$

' Check for wrong format in file (wrong .dat file!)
If Left$(astring$, 1) <> "0" And Left$(astring$, 1) <> "1" And Left$(astring$, 1) <> "2" And Left$(astring$, 1) <> "3" Then GoTo CalcZAFImportNextWrongFile
If InStr(astring$, ",") = 0 Then GoTo CalcZAFImportNextWrongFile

' Parse mode using comma delimiter
Call MiscParseStringToStringA(astring$, ",", bstring$)
If ierror Then Exit Sub
CalcZAFMode% = Val(bstring$)

' Parse lastchan
Call MiscParseStringToStringA(astring$, ",", bstring$)
If ierror Then Exit Sub
CalcZAFOldSample(1).LastChan% = Val(bstring$)

' Parse kilovolts
Call MiscParseStringToStringA(astring$, ",", bstring$)
If ierror Then Exit Sub
CalcZAFOldSample(1).kilovolts! = Val(bstring$)

' Parse takeoff
Call MiscParseStringToStringA(astring$, ",", bstring$)
If ierror Then Exit Sub
CalcZAFOldSample(1).takeoff! = Val(bstring$)

' Check for sample name
If Trim$(astring$) = vbNullString Then
CalcZAFOldSample(1).Name$ = UCase$(MiscGetFileNameOnly$(ImportDataFile$)) & ", Sample" & Str$(CalcZAFSampleCount%)
CalcZAFOldSample(1).StagePositions!(1, 1) = 0#      ' X
CalcZAFOldSample(1).StagePositions!(1, 2) = 0#      ' Y
CalcZAFOldSample(1).StagePositions!(1, 3) = 0#      ' Z

' Sample name string found
Else

' Remove commas between double quotes enclosing sample name
ip% = InStr(astring$, VbDquote & VbComma)   ' find end of sample name string
If ip% = 0 Then ip% = Len(astring$)     ' no sample coordinates
For i% = 1 To ip%
If Mid$(astring$, i%, 1) = VbComma Then
Mid$(astring$, i%, 1) = Space(1)
End If
Next i%

' Parse the sameple name string (now without enclosed commas)
Call MiscParseStringToStringA(astring$, ",", bstring$)
If ierror Then Exit Sub
CalcZAFOldSample(1).Name$ = Trim$(bstring$)

' Check for sample coordinates
If Trim$(astring$) = vbNullString Then
CalcZAFOldSample(1).StagePositions!(1, 1) = 0#      ' X
CalcZAFOldSample(1).StagePositions!(1, 2) = 0#      ' Y
CalcZAFOldSample(1).StagePositions!(1, 3) = 0#      ' Z

' Sample coordinates string found
Else
Call MiscParseStringToStringA(astring$, ",", bstring$)
If ierror Then Exit Sub
CalcZAFOldSample(1).StagePositions!(1, 1) = Val(bstring$)      ' X

Call MiscParseStringToStringA(astring$, ",", bstring$)
If ierror Then Exit Sub
CalcZAFOldSample(1).StagePositions!(1, 2) = Val(bstring$)      ' Y

Call MiscParseStringToStringA(astring$, ",", bstring$)
If ierror Then Exit Sub
CalcZAFOldSample(1).StagePositions!(1, 3) = Val(bstring$)      ' Z

End If
End If

' Check for valid mode and number of elements, kilovolts and takeoff
If CalcZAFMode% < 0 Or CalcZAFMode% > 3 Then GoTo CalcZAFImportNextBadMode
If CalcZAFOldSample(1).kilovolts! < 1# Or CalcZAFOldSample(1).kilovolts! > 100# Then GoTo CalcZAFImportNextBadKeV
If CalcZAFOldSample(1).takeoff! < 1# Or CalcZAFOldSample(1).takeoff! > 90# Then GoTo CalcZAFImportNextBadTakeoff
If CalcZAFOldSample(1).LastChan% < 1 Or CalcZAFOldSample(1).LastChan% > MAXCHAN% Then GoTo CalcZAFImportNextTooMany

' Update defaults
DefaultTakeOff! = CalcZAFOldSample(1).takeoff!
DefaultKiloVolts! = CalcZAFOldSample(1).kilovolts!

' Read oxide, difference, stoichiometry, relative parameters
CalcZAFLineCount& = CalcZAFLineCount& + 1
Input #ImportDataFileNumber%, CalcZAFOldSample(1).OxideOrElemental%, CalcZAFOldSample(1).DifferenceElement$, CalcZAFOldSample(1).StoichiometryElement$, CalcZAFOldSample(1).StoichiometryRatio!, CalcZAFOldSample(1).RelativeElement$, CalcZAFOldSample(1).RelativeToElement$, CalcZAFOldSample(1).RelativeRatio!

' Set calculation flags
If CalcZAFOldSample(1).DifferenceElement$ <> vbNullString Then CalcZAFOldSample(1).DifferenceElementFlag% = True
If CalcZAFOldSample(1).StoichiometryElement$ <> vbNullString Then CalcZAFOldSample(1).StoichiometryElementFlag% = True
If CalcZAFOldSample(1).RelativeElement$ <> vbNullString Then CalcZAFOldSample(1).RelativeElementFlag% = True
CalcZAFLineCount& = CalcZAFLineCount& + 1

' Loop on each element
NumberofStandards% = 0
For i% = 1 To CalcZAFOldSample(1).LastChan%
CalcZAFLineCount& = CalcZAFLineCount& + 1
Input #ImportDataFileNumber%, CalcZAFOldSample(1).Elsyms$(i%), CalcZAFOldSample(1).Xrsyms$(i%)
Input #ImportDataFileNumber%, CalcZAFOldSample(1).numcat%(i%), CalcZAFOldSample(1).numoxd%(i%)
Input #ImportDataFileNumber%, CalcZAFOldSample(1).StdAssigns%(i%), CalcZAFOldSample(1).ElmPercents!(i%), UnkCounts!(i%), StdCounts!(i%)

' Add standard to run
If CalcZAFOldSample(1).StdAssigns%(i%) > 0 And CalcZAFOldSample(1).StdAssigns%(i%) <> MAXINTEGER% Then
ip% = IPOS2(NumberofStandards%, CalcZAFOldSample(1).StdAssigns%(i%), StandardNumbers%())
If ip% = 0 Then
Call AddStdSaveStd(CalcZAFOldSample(1).StdAssigns%(i%))
If ierror Then Exit Sub
End If
End If
Next i%

' Update sample number
CalcZAFOldSample(1).number% = CalcZAFSampleCount%           ' for standard (k-ratio calculation)
CalcZAFOldSample(1).Linenumber&(1) = CalcZAFSampleCount%    ' for unknown (other calculations)

' Always a single line
CalcZAFOldSample(1).Datarows = 1
CalcZAFOldSample(1).GoodDataRows = 1
CalcZAFOldSample(1).LineStatus(1) = True

' Sort elements
Call CalcZAFSave
If ierror Then Exit Sub

' Load combined conditions for all elements
For i% = 1 To CalcZAFOldSample(1).LastElm%
CalcZAFOldSample(1).TakeoffArray!(i%) = CalcZAFOldSample(1).takeoff!
CalcZAFOldSample(1).KilovoltsArray!(i%) = CalcZAFOldSample(1).kilovolts!
CalcZAFOldSample(1).BeamCurrentArray!(i%) = DefaultBeamCurrent!
CalcZAFOldSample(1).BeamSizeArray!(i%) = DefaultBeamSize!
Next i%

' Set the mode
FormZAF.OptionCalculate(CalcZAFMode%).Value = True

' Re-load grid
Call CalcZAFLoadList
If ierror Then Exit Sub

' Display sample name
FormZAF.Caption = "Calculate ZAF Corrections    [" & CalcZAFOldSample(1).Name$ & "]"
If CalcZAFOldSample(1).StagePositions!(1, 1) <> 0# Or CalcZAFOldSample(1).StagePositions!(1, 2) <> 0# Then
FormZAF.Caption = FormZAF.Caption & " [" & Format$(CalcZAFOldSample(1).StagePositions!(1, 1)) & ", " & Format$(CalcZAFOldSample(1).StagePositions!(1, 2)) & "]"
End If

Exit Sub

The complete source code for CalcZAF is also found on GitHub in the OpenMicroanalysis repository:

https://github.com/openmicroanalysis/calczaf
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3341
  • Other duties as assigned...
    • Probe Software
Re: Getting Started With CalcZAF
« Reply #11 on: July 10, 2020, 12:24:15 PM »
I should also note that the first line of parameters (mode, lastchan, kilovolts, takeoff), can also contain a sample name (in double quotes), and followed optionally by the X, Y and Z coordinates. These stage coordinates can be used simply for documentation, but can also be used to calculate the distance to a boundary for performing secondary fluorescence from phase boundary calculations in the Analytical | Correct Secondary Boundary Fluorescence Effects menu in CalcZAF.

Attached below is an example of one of these files that is also included with the CalcZAF distribution.  Here is the first sample in the file:

3,2,15,40., "SiO2 adjacent to TiO2 (Elemental K-ratios)", -25,  0., 0.
1,"si","",0.0,"","",0.0
"ti","ka",1,1,0,0.,.00075,0.0
"si","",1,2,0,0.,.0,0.0
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3341
  • Other duties as assigned...
    • Probe Software
Re: Getting Started With CalcZAF
« Reply #12 on: April 04, 2024, 08:43:18 AM »
One of the Athens EPMA Workshop participants wrote Ioannis a question:

Quote
How big is the difference between ZAF- and PRZ- matrix correction on measuring major elements in silicates?

It's a good question, and in case anyone else is wondering the same, here is my answer:

It depends entirely on the composition so there is only one way to find out and that is to model it. For example using CalcZAF (or Probe for EPMA) and checking the "Use All Matrix Corrections" checkbox in either software:

https://probesoftware.com/smf/index.php?topic=81.0

Here's an example of k-ratios for CaMgSiO3 using CalcZAF:

CaMgSiO3, sample 1
40 degrees and 15 keV
LINEMU   Henke (LBL, 1985) < 10KeV / CITZMU > 10KeV
       "Ca K-RAT"  "Si K-RAT"  "Mg K-RAT" "O K-RAT"
     1    .264379    .156549    .120706    .087811   Armstrong/Love Scott prZ (default)
     2    .259904    .156914    .122337    .092386   Philibert/Duncumb-Reed
     3    .263911    .152818    .118200    .093984   Heinrich/Duncumb-Reed
     4    .264017    .156354    .120483    .090835   Love-Scott I
     5    .264208    .157000    .121289    .085220   Love-Scott II
     6    .253921    .156936    .124326    .097338   Packwood Phi(prZ) (EPQ-91)
     7    .242578    .148795    .118126    .087365   Bastin (original) (prZ)
     8    .257182    .151893    .117424    .084745   Bastin PROZA Phi (prZ) (EPQ-91)
     9    .257940    .153218    .118622    .084122   Pouchou and Pichoir-Full (PAP)
    10    .257682    .153806    .119706    .088394   Pouchou and Pichoir-Simplified (XPP)
    11    .263825    .156658    .120845    .087103   Donovan and Moy BSC/BKS (prZ)

AVER:     .259050    .154631    .120188    .089028
SDEV:     .006566    .002728    .002056    .004165
SERR:     .001980    .000822    .000620    .001256

MIN:      .242578    .148795    .117424    .084122
MAX:      .264379    .157000    .124326    .097338

So a few percent for these elements.  Try a few compositions in CalcZAF and see for one's self.

Note that one can calculate k-ratios or concentrations using all 11 matrix corrections in CalcZAF or Probe for EPMA.
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"