⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 keyval.dox

📁 大型并行量子化学软件;支持密度泛函(DFT)。可以进行各种量子化学计算。支持CHARMM并行计算。非常具有应用价值。
💻 DOX
字号:
/** \page keyval The KeyVal LibraryThe KeyVal class provides a means for users to associate keywords withvalues.  ParsedKeyVal is a specialization of KeyVal that permitskeyword/value associations in text such as an input file or a command linestring.The package is flexible enough to allow complex structures and arrays aswell as objects to be read from an input file.<ul>  <li> \ref keyvalass  <li> \ref keyvalgroup  <li> \ref keyvalarray  <li> \ref keyvaltab  <li> \ref keyvalexp  <li> \ref keyvalobj</ul>\section keyvalass AssignmentAs an example of the use of ParsedKeyVal, consider the followinginput:<pre>x_coordinate = 1.0y_coordinate = 2.0x_coordinate = 3.0</pre>Two assignements will be made.  The keyword <tt>x_coordinate</tt> will beassociated with the value <tt>1.0</tt> and the keyword <tt>y_coordinate</tt>will be assigned to <tt>2.0</tt>.  The third line in the above inputwill have no effect since <tt>x_coordinate</tt> was assigned previously.\section keyvalgroup Keyword GroupingLets imagine that we have a program which needs to read in thecharacteristics of animals.  There are lots of animals so it might benice to catagorize them by their family.  Here is a sample format forsuch an input file:<pre>reptile: (  alligator: (    legs = 4    extinct = no    )  python: (    legs = 0    extinct = no    )  )bird: (  owl: (    flys = yes    extinct = no    )  )</pre>This sample illustrates the use of keyword <tt>=</tt> valueassignments and the keyword grouping operators <tt>(</tt> and <tt>)</tt>.The keywords in this example are<pre>reptile:alligator:legsreptile:alligator:extinctreptile:alligator:legsreptile:python:sizereptile:python:extinctbird:owl:flysbird:owl:extinct</pre>The <tt>:</tt>'s occuring in these keywords break the keywords intosmaller logical units called keyword segments.  The sole purpose of thisis to allow persons writing input files to group the input into easy toread sections.  In the above example there are two main sections, thereptile section and the bird section.  The reptile section takes theform <tt>reptile</tt> <tt>:</tt> <tt>(</tt> keyword <tt>=</tt> valueassignments <tt>)</tt>.  Each of the keywords found between theparentheses has the <tt>reptile:</tt> prefix attached to it.  Within eachof these sections further keyword groupings can be used, as many and asdeeply nested as the user wants.Keyword grouping is also useful when you need many different programs toread from the same input file.  Each program can be assigned its ownunique section.\section keyvalarray Array ConstructionInput for an array is specified in the input by forming a keywordgroup.  The name of the group is the name of the array and thegrouped keywords are the integers $i$, such that $0 \leq i < n$, where $n$is the number of elements in the array.  For example, an array, called<tt>array</tt>, of length 3 could be given as follows:<pre>array: (  0 = 5.4  1 = 8.9  2 = 3.7  )</pre>The numbers <tt>0</tt>, <tt>1</tt>, and <tt>2</tt> in this example are keywordsegments which serve as indices of <tt>array</tt>.  However, this syntaxis somewhat awkward and array construction operators have been providedto simplify the input for this case.  The following input is equivalentto the above input:<pre>array = [ 5.4 8.9 3.7 ]</pre>More complex arrays than this can be imagined.  Suppose an array ofcomplex numbers is needed.  For example the input<pre>carray: (  0: ( r = 1.0  i = 0.0 )  1: ( r = 0.0  i = 1.0 )  )</pre>could be written as<pre>carray: [  (r = 1.0 i = 0.0)  (r = 0.0 i = 1.0)  ]</pre>which looks a bit nicer than the example without array constructionoperators.Furthermore, the array construction operators can be nested in aboutevery imaginable way.  This allows multidimensional arrays ofcomplicated data to be represented.  Here is an example ofinput for a lower triangular array:<pre>ltriarray = [ [ 5.4  ]              [ 0.0 2.8 ]              [ 0.1 0.0 3.7 ] ]</pre>\section keyvaltab Table ConstructionAlthough the array construction operators will suitmost requirements for enumerated lists of data, in some cases the input canstill look ugly.  This can, in some cases, be fixed with the tableconstruction operators, <tt>{</tt> and <tt>}</tt>.Suppose a few long vectors of the same length are needed and the data inthe <tt>i</tt>th element of each array is related or somehow belongtogether.  If the arrays are so long that the width of a page isexceeded, then data that should be seen next to each other are no longeradjacent.  The way this problem can be fixed is to arrange the datavertically side by side rather than horizontally.  The tableconstruction operators allows the user to achieve this in a very simplemanner.<pre>balls: (  color    = [  red      blue     red   ]  diameter = [   12       14       11   ]  material = [  rubber  vinyl   plastic ]  bounces  = [  yes      no       no    ]  coordinate = [[ 0.0  0.0  0.0]                [ 1.0  2.0 -1.0]                [ 1.0 -1.0  1.0]]  )</pre>can be written<pre>balls: (  { color diameter material bounces     coordinate} =  {  red     12    rubber    yes     [ 0.0  0.0  0.0]     blue    14    vinyl     no      [ 1.0  2.0 -1.0]     red     11    plastic   no      [ 1.0 -1.0  1.0] }  )</pre>The length and width of the table can be anything the user desires.<pre>Value Substitution</pre>Occasionally, a user may need to repeat some value several times in aninput file.  If the value must be changed, it would be nice to onlychange the value in one place.  The value substitution feature ofParsedKeyVal allows the user to do this.  Any place a value canoccur the user can place a <tt>$</tt>.  Following this a keyword must begiven.  This keyword must have been assigned before the attempt is madeto use its value in a value substitution.Here is an example illustrating most of the variable substitionfeatures:<pre>default:linewidth = 130testsub: (  ke: (    ke_1 = 1    ke_2 = 2    ke_3: (      ke_31 = 31      ke_32 = 32      )    )  kx = $ke  r1 = 3.0  r2 = $r1  linewidth = $:default:linewidth  )</pre>is the same as specifying<pre>testsub: (  ke: (    ke_1 = 1    ke_3: (      ke_31 = 31      ke_32 = 32      )    ke_2 = 2    )  linewidth = 130  r2 = 3.0  r1 = 3.0  kx: (    ke_1 = 1    ke_2 = 2    ke_3: (      ke_31 = 31      ke_32 = 32      )    )  )</pre>It can be seen from this that value substitution can result in entirekeyword segment hierarchies being copied, as well as simplesubstitutions.\section keyvalexp Expression EvaluationSuppose your program requires several parameters <tt>x1</tt>, <tt>x2</tt>,and <tt>x3</tt>.  Furthermore, suppose that their ratios remain fixed forall the runs of the program that you desire.  It would be best tospecify some scale factor in the input that would be the only thing thathas to be changed from run to run.  If you don't want to or cannotmodify the program, then this can be done directly withParsedKeyVal as follows<pre>scale = 1.234x1 = ( $:scale *  1.2 )x2 = ( $:scale *  9.2 )x3 = ( $:scale * -2.0 )</pre>So we see that to the right of the ``<tt>=</tt>'' the characters``<tt>(</tt>'' and ``<tt>)</tt>'' are the expression construction operators.This is in contrast to their function when they are to the left of the``<tt>=</tt>'', where they are the keyword grouping operators.The expression must be binary and the data is all convertedto double.  If you use the expression construction operators to producedata that the program expects to be integer, you will certainly get thewrong answers (unless the desired value happens to be zero).\section keyvalobj ObjectsAn instance of an object can be can be specified by surrounding it'sclassname with the ``<tt><</tt>'' and ``<tt>></tt>'' operators immediatelyafter the keyword naming the data.A pointer to a single object can be associated with multiple keywords byusing value substitution.This is accomplished by holding references to all objects once they areread in.Consider a linked list class, A, which reads from the keyword<tt>next</tt> a reference to an object of class A.  Input for such anobject, read from keyword <tt>a1</tt>, follows:<pre>a1\<A\>: (    next\<A\>: (        next\<B\>: (            bdata = 4            next\<A\>:()            )        )    )a2 = $:a</pre>The <tt>a1</tt> list would contain two <tt>A</tt> objects followed by a<tt>B</tt> object followed by another <tt>A</tt> object.  The <tt>a2</tt> listrefers to exactly the same object as <tt>a1</tt> (not a copy of<tt>a1</tt>).*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -