7. API
There is work presently going on to decouple the functionality from the interface, some of the basic classes can be used to input processing
- file: input.py
to manipulate input files
import deck deck.init([database])
to initialize the database of cards
- Most commonly used classes:
Card
:containing the description of each card
Input
:manipulating the FLUKA input file
- file: Project.py
to manipulate project files
7.1. Card class
Constructor:
input.Card(tag, what [,comment [,extra]])
what is a list starting with what[0]=name=sdum
- Important Methods:
setWhat(n,value)
:set value to what#n
nwhats()
:return number of whats
what(n)
:return value of what#n
numWhat(n)
:return numeric value of what#n
intWhat(n)
:return integer value of what#n
clone()
:return a copy of the card
setEnable(e)
:enable/disable card
7.2. Input class
Constructor:
input.Input([filename])
initialize the structure to hold an input file and optionally read the input filename
- Important Variables:
cardlist
:a list with pointers to cards
cards
:a dictionary with pointers to cards grouped per tag
- Important Methods:
read(filename)
:read input from file filename
write(filename)
:write input to file filename
addCard(card,pos)
:add card to position pos (or end of file)
delCard(pos)
:delete card from position pos
preprocess()
:pre-process input to check for active cards
setEnable(e)
:enable/disable card
7.3. Project class
Constructor:
Project.Project()
Initialize the structure to hold a project file
- Important Methods:
clear()
:to re-initialize project
load(filename)
:load project from file filename
save([filename])
:save project to filename
runCmd(run)
:create run command
7.4. .flair file structure
# comments Variable: Value Notes: multi-line values are terminated with Ctrl-L Run: name ... Block of Run related information Data: ... ... Including Data processing information EndData EndRun Plot: name ... Plot related informations EndPlot
7.5. Example
Read an input file and modify the random number seed
import deck
deck.init()
inp = deck.Input("test.inp")
try:
rndcard = inp["RANDOMIZ"][0]
rndcard.setWhat(2, 5723)
except:
print "No RANDOMIZe card found"
sys.exit(0)
inp.write("test2.inp")