Constraints syntax

The syntax for the constraints is based on the C programming language, with a few modifications.

The following statements are valid:

    /* comment */
    int VAR
    double VAR
    VAR = EXPRESSION
    if ( EXPRESSION ) {
        STATEMENTS
    } else {
        STATEMENTS
    }
    for (VAR=START;VAR<STOP;VAR++) {
        STATEMENTS
    }
    while (EXPRESSION) {
        STATEMENTS
    }

Note the position of the braces. The opening brace must be on the same line as the control structure. If there is only one statement in the control structure body, you may skip the braces and include it on the same line as the control structure. Statements spanning multiple lines must end every line with a backslash (\\).

The declaration statements (int and double) must precede all other statements. Variables beginning with underscore (_) are reserved.

Some macro commands are permitted. These are useful for commenting out blocks of code.

    #define MACRO
    #ifdef MACRO
    #else
    #endif

A number of parameter variables are predefined. The variable names are given as specified on the fit screen. The layer number for a parameter p may be specified indirectly as p(i), where i is an integer variable. Parameters are not case sensitive.

The following are valid parameters for reflfit:

    ntl - number of top layers
    nml - number of middle layers
    nbl - number of bottom layers
    nmr - number of repeats
    bk  - background 
    bi  - beam intensity
    vqc - vacuum scattering length density (16 pi N b units)
    tdi troi tmui tqci for i in 1 to 9
    mdi mroi mmui mqci for i in 1 to 9
    bdi broi bmui bqci for i in 1 to 9

The following are valid parameters for reflpol:

    nl  - number of layers
    bk  - background
    bi  - beam intensity
    vqc - vacuum scattering length density (16 pi N b units)
    di  roi mui qci for i > 0
    dmi rmi thi qmi for i > 0

Example 1:

    /* set depth of layer T2 to be equal to layer M1 */
    td2=md1

Example 2:

    /* set roughness to 1/2 the layer depth for all layers */
    int i
    for(i=1;i<ntl;i++) tro(i) = td(i)/2
    for(i=1;i<nml;i++) mro(i) = md(i)/2
    for(i=1;i<nbl;i++) bro(i) = bd(i)/2

Example 3:

    /* set the total depth of the middle layers to be equal 
     * to the total depth of the top layers while preserving
     * the relative depths of the middle layers
     */
    double sumt=0, summ=0., scale
    int i
    for (i=1; i < ntl; i++) sumt += td(i)
    set summ 0
    for (i=1; i < nml; i++) summ += tm(i)
    scale=sumt/summ
    for (i=1; i < nml; i++) {
	tm(i) = tm(i)*scale
    }

2004-05-18


Browse Index