Comments (4)
Hello
I want to use the flag "error" in cpymad, but I don't know how! I already use it in Madx and there was no problem. This is the error block in my madx file:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Select, flag=error, clear = true;
select, flag=error, class=quadrupole;
efcomp, order:=0, radius:=0.013,
dknr={tgauss(2)*1e-4,tgauss(2)*1e-3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
select, flag=error, class=quadrupole;
esave,file=efield.tab0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I have already checked the installed cpymad on my pc with the twiss example and everything works correctly. I was wondering if you could help me.
Thanks!
from cpymad.
Hey, welcome to github!
Two beginner tips first:
- please open new issues to discuss separate topics.
- you can fence off code blocks as shown here, so your formatting doesn't get lost.
Did you consider to just leave these commands in a .madx
file and madx.call()
that file from cpymad? This is much easier and recommended if you are only going to change parameters manually. In general, you probably don't need cpymad if you are not trying to write a program which generates commands automatically or adjusts parameters dynamically.
If you really do need python code to input these commands: Most MAD-X commands can be converted to python syntax pretty straight forward, e.g.:
# (assuming your Madx instance is called `madx`:)
madx.command.select(flag="error", clear=True)
# note the trailing underscore in 'class_' is needed because class is a python keyword:
madx.command.select(flag="error", class_="quadrupole")
# Now this command is a bit non-standard and currently cpymad does a bad job getting it right.
# But you can still generate your command string manually and input it to cpymad:
madx.input('efcomp, order:=0, radius:=0.013, dknr={tgauss(2)*1e-4,tgauss(2)*1e-3};')
madx.command.esave(file="efield.tab0")
I agree that many of this should be simplified and made more straight forward, but this is not on the top of my priority list right now;)
from cpymad.
Hi.
Sorry for discussing this issue here. I thought that I found the related topic for my issue.
Yes. I already used the madx.call() command. The main motivation for me for switching to cpymad was that I need to use different seeds for the errors and calculating twiss function for each error data. I used while loop in MADX to change the seed every time, add errors to magnets and calculating twiss function. The madx problem was that it rewrites the twiss file each time in loop, so I only have access to the twiss data of last turn in loop.
I tried to use cpymad, so I could save the error and twiss data for any individual seed in each turn of while loop.
Thanks for your informative response. That works, except the part 'class_="quadrupole"'. Cpymad didn't recognize the quadrupoles. Instead, I use "pattern" and call all of the quadrupoles by their names.
from cpymad.
Concerning the original issue: implemented in the branch merged in 24717d2.
from cpymad.
Related Issues (20)
- Differences in cpymad `table.twiss` and madx `table(twiss, X, X)` when running `use` HOT 7
- Twiss at certain positions HOT 13
- Element redefinition and twiss HOT 5
- Add support to release Linux AArch64 wheels HOT 7
- EMIT module output is displayed with "delay" HOT 2
- TWISS: no beta0 found HOT 1
- New functions
- Can't run madx instance. TypeError HOT 5
- Build error on Win10 Anaconda 2022.5 HOT 11
- What is the preferred way to retrieve the command (string) with which an Element was created? HOT 3
- libmadx error installing on M1/M2 Apple Silicon HOT 7
- Pitfalls on compiling libmadx/cpymad on Linux HOT 5
- Proposal: specialize tables HOT 8
- Wheel for M1 apple? HOT 2
- Python 3.11 Wheels HOT 4
- Error building cpymad on M1 Apple Silicon - "-march=core2" not supported HOT 5
- call does not work when double slash is present in file path HOT 2
- access default beam HOT 1
- ValueError: TypeError: write() argument must be str HOT 4
- Python 3.12 wheels HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpymad.