Probe Software Users Forum

General EPMA => Discussion of General EPMA Issues => Topic started by: Mike Matthews on January 14, 2016, 10:35:11 AM

Title: GMRFilm
Post by: Mike Matthews on January 14, 2016, 10:35:11 AM
I'm playing with GMRFilm at the moment and I'd like to be able to model uranium oxide films but, at least withe the version I've got, it won't go below Na or above Pa. Does anyone know if or how to extend the range? The only text readable field with the program is a standards file. Can this be added to?
Title: Re: GMRFilm
Post by: Ben Buse on January 14, 2016, 11:57:41 AM
Hi Mike,

The standards file can be added to, I often add mineral standards, but I'm not sure how this would help you - presumably it won't let you do pure metal U is that right? I sure I've modelled carbon before.

-------------
example entry to standard file

DIOP   6
O  0.44250   Mg 0.10750   Al 0.00300   Si 0.26020   Ca 0.18470   Fe 0.00520

[name: limited number of characters]   [number of elements]
key is keep right number spaces O [2 spaces] 0.44250 [3 spaces] Mg [1 space] 0.10750 etc.
-------------------------

Ben
Title: Re: GMRFilm
Post by: Mike Matthews on January 17, 2016, 04:00:38 AM
Thanks Ben,

Doesn't everyone want to do Uranium?

Turns out I was making a dumb error with the low end of the range, putting in 'OKa' instead of 'O Ka'
Title: Re: GMRFilm
Post by: Probeman on January 19, 2016, 08:29:05 AM
Quote from: Mike Matthews on January 17, 2016, 04:00:38 AM
Thanks Ben,

Doesn't everyone want to do Uranium?

Turns out I was making a dumb error with the low end of the range, putting in 'OKa' instead of 'O Ka'

Hi Mike,
It's a lot easier to process thin film geometry data using PFE and STRATAGem*- no typing required:

http://smf.probesoftware.com/index.php?topic=502.msg2753#msg2753

Let me know if you are interested in learning more.
john

* © Copyright 1993-2016 SAMx
Title: Re: GMRFilm
Post by: jon_wade on April 25, 2018, 02:19:58 AM
Like some dodgy Dr Frankenstein, I am resurrecting this old thread....

No idea if anyone is interested, but you never know.....
Here's a Makefile for GMRfilm to run on a mac (yes, yes, I hear you.....)

It does run, but it spits its dummy when it gets to doing a second calculation.  If I can find my 'Big Boys Book of Fortran77' I may get around to fixing this. Or I may hope some magical fortran fairy beats me to it.....

Things needed to run it:-

Convert the .for file endings to .f in the original downloaded gmrfilm source file.

put the makefile in the same directory
(you may need to change where your gfortran is located in the first line of the makefile - edit this line:-
FC=/usr/local/bin/gfortran
to the desired location)

open up a terminal window in the gmr directory

type make.

et volia.
gmrfilm.  It Lives, Igor! 
Title: Re: GMRFilm
Post by: Ben Buse on May 21, 2018, 12:59:30 PM
Using John Minter's compile script it works on ubuntu.

https://github.com/jrminter/gmrfilm (https://github.com/jrminter/gmrfilm)

I just changed output from gmrfilm.exe to gmrfilm. And run using ./gmrfilm

But like yours Jon, it aborts at new calcuation

Another calculation? (y):
At line 24 of file nextcalc.for (unit = 5, file = 'fort.5')
Fortran runtime error: End of file

Title: Re: GMRFilm
Post by: Ben Buse on June 20, 2018, 02:22:14 AM
Hi,

I found you can automate responses to gmrfilm as follows, it works but will questions will vary with number of elements, layers etc.

# questions
#n: print intensities
#f: film or bulk (b)
#y: include continuum flouresence
#c: kratio (k) or composition (c)
#n: change MACS
#40: take-off angle
#e: basin 1986(b); 1990(c) PAP(e) Packwood (p)
#y: single voltage
#15: specify kV
#2: number of layers
#1: number of elements in layer 1
#2: number of elements in layer 2
#AuMa: x-ray layer 1, element 1
#SiKa: x-ray layer 2, element 1
#O Ka: x-ray layer 2, element 2
#19.3: layer 1 density
#n: layer 1 fix composition & thickness
#n: substrate fix composition
#4: Si valence substrate
#2: oxygen valence substrate
#kratio layer 1 element Au
#kratio substrate element Si
cd '/home/ben/Downloads/gmrfilm-master/src'
./gmrfilm << EOF
n
f
y
c
n
40
e
y
15
2
1
2
AuMa
SiKa
O Ka,s
19.3
n
n
4
2
0.05
0.95


Or where the responses are in a separate file

cd '/home/ben/Downloads/gmrfilm-master/src'
./gmrfilm < gmrfilm.in


This could be used to batch, copying the ouput file to a new name between each

cp grmfout.txt grmfout1.txt

using a spreadsheet I can generate a form for 2 layers, with ox by stoichometry in substrate, for varying number of elements

(https://smf.probesoftware.com/gallery/453_20_06_18_4_37_34.png)

column B is pasted into textfile 'gmrfilm.in'

the sh script becomes

cd '/home/ben/Downloads/gmrfilm-master/src'
# remove blank lines from unentered entries
sed '/^$/d' 'gmrfilm.in' > 'gmrfilm2.in'
./gmrfilm < gmrfilm2.in
cp grmfout.txt grmfout1.txt


And a simple python script to combine results into single file for 1 element in film and 5 elements in substrate

def rd(gmrfile):
file=open(gmrfile,'r')
file1 = file.readlines()
for x in range(0,len(file1)-1):
if len(file1[x].split()) > 1:
if file1[x].split()[0] == 'Composition':
s=x
print(file1[s])
rd.fE1 = file1[s+3] # film element
rd.fT = file1[s+4] # film thickness & sum
rd.sE1 = file1[s+6] # substrate element 1
rd.sE2 = file1[s+7] # substrate element 2
rd.sE3 = file1[s+8] # substrate element 3
rd.sE4 = file1[s+9] # substrate element 4
rd.sE5 = file1[s+10] # substrate element 5
rd.sS = file1[s+11] # substrate sum
print(rd.fE1)
file.close()
return;

rd(gmrfile='/home/ben/Downloads/gmrfilm-master/src/grmfout1.txt')
#file=open('/home/ben/Downloads/gmrfilm-master/src/grmfout1.txt','r')

file2 = open('/home/ben/Downloads/gmrfilm-master/src/results1.txt','w')
file2.write("FEl,Wt%,thickness,SEl1,Wt%,SEl2,Wt%,SEl3,Wt%,SEl4,Wt%,SEl5,Wt%\n")
file2.write(rd.fE1.split()[2]+","+rd.fE1.split()[3]+","+rd.fT.split()[5]+","+rd.sE1.split()[1]+","+rd.sE1.split()[2]+","+rd.sE2.split()[1]+","+rd.sE2.split()[2]+","+rd.sE3.split()[1]+","+rd.sE3.split()[2]+","+rd.sE4.split()[1]+","+rd.sE4.split()[2]+","+rd.sE5.split()[1]+","+rd.sE5.split()[3]+"\n")
#second input file
rd(gmrfile='/home/ben/Downloads/gmrfilm-master/src/grmfout2.txt')
print("test")
file2.write(rd.fE1.split()[2]+","+rd.fE1.split()[3]+","+rd.fT.split()[5]+","+rd.sE1.split()[1]+","+rd.sE1.split()[2]+","+rd.sE2.split()[1]+","+rd.sE2.split()[2]+","+rd.sE3.split()[1]+","+rd.sE3.split()[2]+","+rd.sE4.split()[1]+","+rd.sE4.split()[2]+","+rd.sE5.split()[1]+","+rd.sE5.split()[3]+"\n")
file2.close()

raw_input()
Title: Re: GMRFilm
Post by: Probeman on June 20, 2018, 09:05:38 AM
Hi Ben,
Using a text file as a redirected input to an executable is a good trick. 

I use this same trick extensively when calling Penepma/Penfluor/Fanal, from the various PFE apps such as Standard.exe, CalcZAF.exe, etc.  e.g.,

Fanal.exe < Fanal.in

The nice thing about using command line execution with these apps is that the user doesn't even usually see this going on (though one can usually notice a command prompt being generated to run the FORTRAN if the FORTRAN takes more than a few seconds) because the app auto-generates the necessary input based on the user selections in the GUI.

Now all you need to do is create a GUI for GMRFILM!    :)

Maybe you know this additional trick for the command prompt:

' Start Penepma (/k executes but window remains, /c executes but terminates)
'PenepmaTaskID& = Shell("cmd.exe /k " & VbDquote$ & bfilename$ & VbDquote$, vbNormalFocus)
PenepmaTaskID& = Shell("cmd.exe /c " & VbDquote$ & bfilename$ & VbDquote$, vbNormalFocus)


Also by monitoring the returned "taskID" one can tell when the cmd prompt terminates (when using /c):

Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessID As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long

Private Const PROCESS_QUERY_INFORMATION& = &H400&
Private Const STILL_ACTIVE& = &H103&

Function IOIsProcessTerminated(currentPID As Variant) As Boolean
' Checks whether a shell process ID is still running (call within doevents loop or from timer event)

ierror = False
On Error GoTo IOIsProcessTerminatedError

Dim ProcHnd As Long, CurECode As Long

' Get the process handle
ProcHnd& = OpenProcess(PROCESS_QUERY_INFORMATION&, True, currentPID)

' Check for exit code
Call GetExitCodeProcess(ProcHnd&, CurECode&)

' Return true
If CurECode& = STILL_ACTIVE& Then
IOIsProcessTerminated = False
Else
IOIsProcessTerminated = True
End If

Exit Function

' Errors
IOIsProcessTerminatedError:
MsgBox Error$, vbOKOnly + vbCritical, "IOIsProcessTerminated"
ierror = True
Exit Function

End Function
Title: Re: GMRFilm
Post by: Ben Buse on June 22, 2018, 01:02:07 AM
Thanks John I didn't,

_________________________

Above work was using gmrfilm recompiled with gfortran.

I've been testing it with the original gmrfilm version - it works in a odd fashion

gmrfilm < test2.txt

In text file, you have to print out the H (help information), for example an input file would be as below. Capitals are not necessary

H
N
F
Y
K
N
40
B
Y
15
2
1
1
H
AUMA
SIKA
19.3
a
10
Title: Re: GMRFilm
Post by: Probeman on June 22, 2018, 07:20:33 AM
Hi Ben,
I'd always thought someday I'd get around to adding file input/output to GMRFILM, but never did.

Once someone does that, adding an actual GUI to GMRFILM would be quite possible, and very cool.  Maybe that someone is you?    :)
Title: Re: GMRFilm
Post by: Ben Buse on June 28, 2018, 09:50:50 AM
I think other's are working on GUI, and I wish them luck,

Here is an example using an spreadsheet form input
'form for gmrfilm 2 layers ox stoic subs7 batch.ods'
Saved to csv

A python script to convert the csv into input files and input script to gmrfilm
'gmrf_csv_to_input2.py'

A script to run gmrfilm
'gmrfilm_run_batch.py'

And a python script to read the results into a single file
'python read gmrfilm3 comp subs7_batch.py'

I ran some analysis on a glass thin section, with two bands of Au sputtered, nominally 10nm and 20nm

The graph shows the results, a thickness traverse across the thin section

(https://smf.probesoftware.com/gallery/453_28_06_18_9_44_12.png)

this will work, gui are time consuming!

Ben
Title: Re: GMRFilm
Post by: John Donovan on June 28, 2018, 12:26:25 PM
Quote from: Ben Buse on June 28, 2018, 09:50:50 AM

this will work, gui are time consuming!

Ben

Tell me about it!     :)
Title: Re: GMRFilm
Post by: Ben Buse on July 02, 2018, 09:07:06 AM
I've now tidied up the scripts. So on ubuntu for a single element coat, and a substrate with between 2-7 elements.

Its:
(1) Fill in spreadsheet, save as csv.
(2) terminal cd to working directory (in which have csv, run scripts, and gmrfilm program)
(3) sh RunAll.sh

Latest scripts attached

Ben
Title: Re: GMRFilm
Post by: jrminter on July 02, 2018, 05:42:29 PM
Thanks for sharing this, Ben.
Title: Re: GMRFilm
Post by: jrminter on July 03, 2018, 04:25:23 AM
This is odd. There seems to be a difference between the same gmrfilm code (from my github repository) on MacOSX with the GNU Fortran (GCC) 6.1.0 compiler and Ubuntu with the GNU Fortran (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609 compiler. When I build with gfortran on MacOSX and use your example with O Ka,s the program hangs on the input. I created an Lubuntu 16.04 VM using Parallels and ran the same code it works, although it crashes at the end while trying to read a Y/N to continue. Haven't found the problem. Go figure...

Update: I also tried the pgi compiler. It just segfaults. Grrr.

Title: Re: GMRFilm
Post by: Ben Buse on September 30, 2019, 03:43:26 AM
Hi

This is the code for above routine adapted for windows cmd, using a 32-bit computer. The interesting bit is that GMRFILM date stamps the files with hours as letters. Including minutes. When batching the files, you create multiple results files within a minute, so the script renames files.

Ben

Title: Re: GMRFilm
Post by: Probing on October 21, 2021, 01:26:46 AM
HELP!2 questions!
1. what does "k-factor" means in GMRFilm? when the standard is pure element, you need input a "k-ratio"; when the standard is compound, the input item becomes "k-factor". so, how to define this "k-factor" here?
2. GMRFilm after all can handle the multi-layer film of which different layers have the same element(s)? if it can, how can I get the k-ratio or k-factor of the element for each layer? if it can't, why telling us in instructions to use "m" or "n" as switch to deal with the situation that there is an element which exists in more than one layer? I am confused.
Title: Re: GMRFilm
Post by: Mike Matthews on October 21, 2021, 10:41:02 AM
Hopefully someone can confirm but I'm pretty sure 'k-factor' is just the GMRFilm term for the k-ratio relative to the amount of element in the compound standard as opposed to a pure element. If you use GMRFilm to calculate k-ratios from known compositions and thicknesses it outputs 2 'k-ratio' values for elements where you've declared a compound standard, one 'compound' k-ratio and one 'pure-element' k-ratio. Hope that makes sense.
Title: Re: GMRFilm
Post by: Probing on October 21, 2021, 05:37:42 PM
Thanks, Mike

That is to say, the "k-factor" in GMRFilm is equivalent to the "k-raw" or "raw k-ratio" as "Probeman" mentioned in the following post:
https://smf.probesoftware.com/index.php?topic=239.msg9467#msg9467