Coder Social home page Coder Social logo

madx set_value has a odd output about cpymad HOT 9 CLOSED

hibtc avatar hibtc commented on July 29, 2024
madx set_value has a odd output

from cpymad.

Comments (9)

coldfix avatar coldfix commented on July 29, 2024

Post full minimal example.

Specify set value argument as number, not as string.

from cpymad.

coldfix avatar coldfix commented on July 29, 2024

Ah you just took the example from set_value docstring and executed it without even defining a quadrupole element named R1QS1, right? ...

Sorry for being rude, but you are really asking for a lot of stuff, that should be obvious if you had some knowledge about python + madx. If you don't have that, I don't see any reason for you to use this library, and you really should start using plain MAD-X first without cpymad / madgui.

from cpymad.

Landau1908 avatar Landau1908 commented on July 29, 2024

Hi,
still don't work.

In [46]: madx.set_value('R1QS1->K1', 42)

In [47]: madx.evaluate('R1QS1->K1')
Out[47]: 
0.0

from cpymad.

coldfix avatar coldfix commented on July 29, 2024

Still didn't post a full example.

from cpymad.

Landau1908 avatar Landau1908 commented on July 29, 2024

I have learned madx and python for 3 months, but I don't know a lot of cpymad. So, if I trouble you very much, very sorry for that.
I really want to understand cpymad.

from cpymad.

Landau1908 avatar Landau1908 commented on July 29, 2024

sorry, it is just a simple example from set_value docstring.

from cpymad.

coldfix avatar coldfix commented on July 29, 2024

Okay, then please focus more on providing full information, i.e. all the code/files that is needed to reproduce your problem. In this particular case, the example should start with from cpymad.madx import Madx and end with madx.evaluate(...). I don't want to ask you back for all the necessary information everytime.

Initially, I thought, you were working on some sequence, which you didn't post. Now I have to assume, you are executing this without a sequence. But this is still just guessing.

This specific example shows how to set the K1 attribute of a quadrupole named R1QS1. If you want to set a constant value, just use an identifier name, e.g.:

madx.set_value('EULER', 2.718)
madx.evaluate('EULER')

from cpymad.

Landau1908 avatar Landau1908 commented on July 29, 2024

If replace R1QS1->K1 with R1QS1, it works. Why?

In [48]: madx.set_value('R1QS1', 42)

In [49]: madx.evaluate('R1QS1')
Out[49]: 

42.0

from cpymad.

coldfix avatar coldfix commented on July 29, 2024

From now on, please follow the guidelines here https://github.com/hibtc/cpymad#reporting-issues and you will be fine. Otherwise I will limit my responses to you to only one in a few days, so make sure that your questions can be fully understood without asking back.

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.