Author Topic: GMRFilm  (Read 5893 times)

Mike Matthews

  • Global Moderator
  • Professor
  • *****
  • Posts: 132
GMRFilm
« 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?

Ben Buse

  • Professor
  • ****
  • Posts: 441
Re: GMRFilm
« Reply #1 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
« Last Edit: January 14, 2016, 12:04:18 PM by Ben Buse »

Mike Matthews

  • Global Moderator
  • Professor
  • *****
  • Posts: 132
Re: GMRFilm
« Reply #2 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'

Probeman

  • Emeritus
  • *****
  • Posts: 2430
  • Never sleeps...
    • John Donovan
Re: GMRFilm
« Reply #3 on: January 19, 2016, 08:29:05 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://probesoftware.com/smf/index.php?topic=502.msg2753#msg2753

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

* © Copyright 1993-2016 SAMx
« Last Edit: February 06, 2016, 08:07:37 AM by John Donovan »
The only stupid question is the one not asked!

jon_wade

  • Professor
  • ****
  • Posts: 78
Re: GMRFilm
« Reply #4 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! 

Ben Buse

  • Professor
  • ****
  • Posts: 441
Re: GMRFilm
« Reply #5 on: May 21, 2018, 12:59:30 PM »
Using John Minter's compile script it works on ubuntu.

https://github.com/jrminter/gmrfilm

I just changed output from gmrfilm.exe to gmrfilm. And run using
Code: [Select]
./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

« Last Edit: May 21, 2018, 01:32:07 PM by Ben Buse »

Ben Buse

  • Professor
  • ****
  • Posts: 441
Re: GMRFilm
« Reply #6 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.

Code: [Select]
# 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

Code: [Select]
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

Code: [Select]
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



column B is pasted into textfile 'gmrfilm.in'

the sh script becomes

Code: [Select]
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

Code: [Select]
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()
« Last Edit: April 12, 2020, 08:55:48 AM by John Donovan »

Probeman

  • Emeritus
  • *****
  • Posts: 2430
  • Never sleeps...
    • John Donovan
Re: GMRFilm
« Reply #7 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:

Code: [Select]
' 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):

Code: [Select]
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
« Last Edit: June 20, 2018, 09:10:43 AM by Probeman »
The only stupid question is the one not asked!

Ben Buse

  • Professor
  • ****
  • Posts: 441
Re: GMRFilm
« Reply #8 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

Code: [Select]
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

Code: [Select]
H
N
F
Y
K
N
40
B
Y
15
2
1
1
H
AUMA
SIKA
19.3
a
10
« Last Edit: June 22, 2018, 01:06:38 AM by Ben Buse »

Probeman

  • Emeritus
  • *****
  • Posts: 2430
  • Never sleeps...
    • John Donovan
Re: GMRFilm
« Reply #9 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?    :)
The only stupid question is the one not asked!

Ben Buse

  • Professor
  • ****
  • Posts: 441
Re: GMRFilm
« Reply #10 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



this will work, gui are time consuming!

Ben
« Last Edit: April 12, 2020, 08:56:08 AM by John Donovan »

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 2936
  • Other duties as assigned...
    • Probe Software
Re: GMRFilm
« Reply #11 on: June 28, 2018, 12:26:25 PM »

this will work, gui are time consuming!

Ben

Tell me about it!     :)
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Ben Buse

  • Professor
  • ****
  • Posts: 441
Re: GMRFilm
« Reply #12 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

jrminter

  • Professor
  • ****
  • Posts: 72
Re: GMRFilm
« Reply #13 on: July 02, 2018, 05:42:29 PM »
Thanks for sharing this, Ben.

jrminter

  • Professor
  • ****
  • Posts: 72
Re: GMRFilm
« Reply #14 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.

« Last Edit: July 05, 2018, 04:16:23 AM by jrminter »