source: PSPA/madxPSPA/doc/usrguide/Introduction/parameter.html @ 430

Last change on this file since 430 was 430, checked in by touze, 11 years ago

import madx-5.01.00

File size: 2.3 KB
Line 
1<head>
2<title>Parameters</title>
3<!-- Changed by: Hans Grote, 17-Jun-2002 -->
4</head>
5
6<body bgcolor="#ffffff">
7
8<center>
9EUROPEAN ORGANIZATION FOR NUCLEAR RESEARCH
10<IMG SRC="http://cern.ch/madx/icons/mx7_25.gif" align=right>
11<h2>Parameter Statements</h2>
12</center>
13
14<h2><a name=relation>Relations between Variable Parameters</a></h2>
15A relation is established between variables by the statement
16<pre>
17parameter-name = expression;
18</pre>
19or
20<pre>
21parameter-name := expression;
22</pre>
23The first form evaluates the expression at the right immediately
24and assigns its value to the parameter. The second form assigns the value
25by evaluating  the expression at right every time the parameter is
26actually used.
27This holds as well for element parameters - beware ! If you want to modify
28e.g. the strength of a quadrupole later (e.g. in a match,
29or by entering a new value for a parameter on which it depends)
30then the defition has to be
31<pre>
32qd:quadrupole,k1:= ak1;
33</pre>
34and not
35<pre>
36qd:quadrupole,k1 = ak1;
37</pre>
38In the latter case, k1 will be set to the current value of ak1, and will
39not change when ak1 changes.
40<p>
41Parameters not yet defined have the value zero.
42<p>
43Example:
44<pre>
45gev = 100;
46beam,energy=gev;
47</pre>
48the parameter on the left may appear on the right as well:
49<pre>
50x = x+1;
51</pre>
52Increases the value of x by 1. As a result, the SET statement of MAD-8
53is no longer necessary and is not implemented.
54<pre>
55Circular definitions are allowed in the first form:
56<pre>
57a = b + 2;
58b = a * b;
59</pre>
60However, circular definitions in the second form are forbidden:
61<pre>
62a := b + 2;
63b := a * b;
64</pre>
65will result in an error.
66<h2><a name=par_output>VALUE: Output of Parameters</a></h2>
67The VALUE statement
68<pre>VALUE = expression;</pre>
69or
70<pre>VALUE = expression1, expression2, ...;</pre>
71evaluates the current value of "expression" resp. "expression1" etc. and
72prints the result on the standard output file.
73<p>
74Example:
75<pre>
76p1 = 5;
77p2 = 7;
78value,p1*p2-3;
79</pre>
80After echoing the command, this prints:
81<pre>
82p1*p2-3 = 32       ;
83</pre>
84Another example:
85<pre>
86option,-warn;
87while (x < 100) {x = x + 1;}
88value,x,x^2,log10(x);
89</pre>
90After echoing the command, this prints:
91<pre>
92x = 100        ;       
93x^2 = 10000      ;       
94log10(x) = 2      ;           
95</pre>
96<p>
97<address>
98<a href="http://www.cern.ch/Hans.Grote/hansg_sign.html">hansg</a>
9911.9.2000
100</address>
101
102</body>
Note: See TracBrowser for help on using the repository browser.