initfile.tex 4.4 KB
Newer Older
Praetorius, Simon's avatar
Praetorius, Simon committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
\documentclass[10pt,a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage{ucs}
\usepackage{xcolor}         % Extended colors
\usepackage{color}

% colors
\definecolor{light-gray}{gray}{0.95}
\definecolor{dark-gray}{gray}{0.3}

\definecolor{light-red}{HTML}{FFE9E9}
\definecolor{light-yellow}{HTML}{FFFAE9}
\definecolor{light-blue}{HTML}{EFF5FF} %E9F1FF

\newsavebox{\mybox}
\newenvironment{codebox}
{\newcommand\colboxcolor{light-blue}%
	\vspace{-0.5cm}\begin{lrbox}{\mybox}%
	\begin{minipage}{\textwidth}
\ttfamily }
{\end{minipage}\end{lrbox}%
\begin{center}
  	\colorbox{\colboxcolor}{\usebox{\mybox}}
\end{center}}

\newcommand{\kommentar}[1]{\textit{\textcolor{dark-gray}{\% #1}}}


\title{The Initfile Manual}
\author{Simon Praetorius}
\date{\today}

\begin{document}
\maketitle
AMDiS is equipped with a parser for parameter files to control simulations, e.g. set material parameters, define the timestep length, set meshes for each problem and configure the number of global refinements. These parameter files (or init-files) are simple text files in a special syntax, that is described here.

The .xml-file \texttt{amdis.xml} in the \texttt{tools/misc} sub-directory of AMDiS is a syntax-file for the Kate editor, that should be copied to the user directory \\\texttt{$\sim$/.kde/share/apps/katepart/syntax} in order to activate the highlighting scheme.

\section{General notation}
Init-files\marginpar{\texttt{\%\ldots}} have the suffix \texttt{.dat.Xd}, where \texttt{X} is in $\{1,2,3\}$. The general definition of a parameter is done by
\begin{codebox}
parameter\_name: parameter\_value\quad\kommentar{a comment}
\end{codebox}
where the '\texttt{:}' sign is the delimiter between parameter name and its value and the '\texttt{\%}' sign indicates a starting comment and is not allowed as part of a parameter-name or value.

You\marginpar{\texttt{\#include}} can include other init-files by 
\begin{codebox}
\#include $<$filename$>$\quad\kommentar{or}\\
\#include "filename"
\end{codebox}
where \texttt{filename} must be relative to the path of the calling program. All parameters in the included init-file overwrites the parameters with the same name defined before the include statement.

One\marginpar{\texttt{\$\{\ldots\}}} can use parameters, defined previously, as variables:
\begin{codebox}
parameter1: value1\\
parameter2: \$parameter1\\
parameter3: \$\{parameter1\}\\
parameter4\_\$\{parameter1\}: value2\quad\kommentar{variable in parameter-name}\\
\kommentar{$\Rightarrow$ parameter4\_value1 = value2}
\end{codebox}
where you have to use brackets '\{' and '\}', if the variable name contains signs other than \{a-z, A-Z, 0-9, \_\}. Variable replacement is simple string replacement, no cast or evaluation of the variable is performed before it is inserted!

If you set a parameter twice, the last value is the one that is return on evaluation:
\begin{codebox}
parameter1: value1\\
parameter1: value2\quad\kommentar{$\Rightarrow$ parameter1 = value2}
\end{codebox}

\section{Value format}
The values of the parameters can be numbers, strings, vectors or arithmetic expression, or some combination of that:
\begin{codebox}
parameter1: 1.0\quad\kommentar{double}\\
parameter2: 1\quad\kommentar{int}\\
parameter3: Hello World!\quad\kommentar{string}\\
parameter4: [1,2,3]\quad\kommentar{vector$<$int$>$}\\
parameter5: [1,2,3; 4,5,6; 7,8,9]\quad\kommentar{vector$<$vector$<$int$> >$}\\
parameter6: 1/2\quad\kommentar{arithmetic expression $\Rightarrow$ 0.5}\\
parameter7: 2*\$\{parameter6\}+sin(0.5)\quad\kommentar{complex arithmetic expr.}
parameter8: m\_pi+m\_e\quad\kommentar{some constants($\pi + e$)}\\
\kommentar{now all together:}\\
parameter9: [2*m\_pi, sin((\$\{parameter7\})*m\_e)/2]
\end{codebox}

Sometimes\marginpar{\texttt{\$(\ldots)}} it is necessary to evaluate an expression before it is used as variable in an other parameter, e.g. if you want to insert a numeric value into a string, e.g. a filename, it is better to use "0.5" than "1/2", since the last one is interpreted as sub-directory delimiter. To insert the value of "1/2" into a string it has to be evaluated before. This can be done, by:
\begin{codebox}
parameter1: 1/2 + 1/2\\
parameter2: Hello \$\{parameter1\} World!\\\kommentar{$\Rightarrow$ parameter2="Hallo 1/2 + 1/2 World!"}\\
parameter3: Hello \$(\$\{parameter1\}) World!\\\kommentar{$\Rightarrow$ parameter3="Hallo 1 World!"}\\
parameter4: Hello \$(1/2 + 1/2) World!\\\kommentar{$\Rightarrow$ parameter4="Hallo 1 World!"}
\end{codebox}
\end{document}