Closed Landau1908 closed 8 years ago
EDIT: Sorry for being harsh.
For reference, here are the most relevant ways to achieve this. Assume, you have MAD-X elements, defined like this:
k1_qp1 = 1;
qp1: quadrupole, l=1, k1:=k1_qp1;
qp2: quadrupole, l=1, k1=1;
mul: multipole, knl={1, 1, 1}; ! a list
in MAD-X, you can change their values as follows:
K1_QP1 = 2;
qp2->k1 = 2; ! also works for qp1
mul, knl={2, 2, 2}; ! this is the only method that works for lists
! (but it also works for qp1,qp2 as well!)
where the syntax at the bottom is the most generic, i.e. can be used to modify the values for all cases, and the syntax in the middle can be used to modify either of the first two elements.
Now in cpymad, you have several options:
.input()
to directly execute commands that would work in MAD-X itself, so if you know the MAD-X command, you can do in cpymad, e.g.:m.input('k1_qp1 = 2;')
m.input('qp2->k1 = 2;')
m.input('mul, knl={2, 2, 2}')
m.set_value('k1_qp1', 2)
m.set_value('qp2->k1', 2)
m.command('mul', knl=[2, 2, 2])
Madx.globals
attribute, so the first case could alternatively be written as:m.globals['k1_qp1'] = 2
Hi, Thomas
How to change the value of a magnet in a sequence in cpymad? I want to change the value (i.e. angle) of some corrector, and to read the closed orbit of each BPM locations.