Coder Social home page Coder Social logo

Comments (1)

coldfix avatar coldfix commented on July 29, 2024

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:

  • you can use .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}')
  • these commands can be executed more conveniently with cpymad methods:
m.set_value('k1_qp1', 2)
m.set_value('qp2->k1', 2)
m.command('mul', knl=[2, 2, 2])
  • the global parameters are also accessible via the Madx.globals attribute, so the first case could alternatively be written as:
m.globals['k1_qp1'] = 2
  • Also note that I have been planning for some time to create special support for this to cover all three cases in a more uniform and convenient manner, but this remains not implemented as of now, see #25.

from cpymad.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.