Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Travelling wave issue #5

Open
hayg25 opened this issue Mar 29, 2021 · 17 comments
Open

Travelling wave issue #5

hayg25 opened this issue Mar 29, 2021 · 17 comments

Comments

@hayg25
Copy link

hayg25 commented Mar 29, 2021

Dear All,
we are facing an error using travelling wave. We use an ascii file that describe the Real part of the Ez field. (Astra creates Ez amplitude. )
here is the beginning of the field file :

0.0463882 0.146368 1.0 3.0
0 0.000460828
0.0019328 0.000520359
0.0038657 0.000713513
0.0057985 0.001090399
0.0077314 0.001747379
0.0096642 0.002854052
0.011597 0.004693939
0.0135299 0.007738147
0.0154627 0.012756721
0.0173956 0.021017368
0.0193284 0.034547562
0.0212612 0.05652299
0.0231941 0.091638022
0.0251269 0.146182363
0.0270598 0.226647868
0.0289926 0.335974245
0.0309254 0.468011834
0.0328583 0.606172101
0.0347911 0.730979055
0.036724 0.830228453
0.0386568 0.90186113
0.0405896 0.949887063
0.0425225 0.979679013

So in lume-astra I am facing an error concerning the first line which has 4 rows ...

see the error when trying the fieldplot :

~/opt/anaconda3/envs/Astra/lib/python3.9/site-packages/astra/fieldmaps.py in load_fieldmaps(astra_input, search_paths, fieldmap_dict, sections, verbose, strip_path)
     84                     astra_input[sec][k] = file
     85 
---> 86                 fmap[file] = np.loadtxt(file)
     87 
     88     # Loop again

~/opt/anaconda3/envs/Astra/lib/python3.9/site-packages/numpy/lib/npyio.py in loadtxt(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin, encoding, max_rows, like)
   1144         # converting the data
   1145         X = None
-> 1146         for x in read_data(_loadtxt_chunksize):
   1147             if X is None:
   1148                 X = np.array(x, dtype)

~/opt/anaconda3/envs/Astra/lib/python3.9/site-packages/numpy/lib/npyio.py in read_data(chunk_size)
    991             if len(vals) != N:
    992                 line_num = i + skiprows + 1
--> 993                 raise ValueError("Wrong number of columns at line %d"
    994                                  % line_num)
    995 

ValueError: Wrong number of columns at line 2

Thanks for the feedback.

@ChristopherMayes
Copy link
Owner

@hayg25 Thank you for pointing this out, I never noticed the TWS type cavity in the manual.

I update the code to better handle fieldmaps, including archiving. Could you test if this works for you?

@hayg25
Copy link
Author

hayg25 commented Mar 29, 2021

Hi @ChristopherMayes ,
yes please tell me when the code is updated so I can test it.

@ChristopherMayes
Copy link
Owner

@hayg25 I already updated it. Or, are you using conda-forge?

@hayg25
Copy link
Author

hayg25 commented Mar 29, 2021

Yes conda forge but I will install using pip.

@hayg25
Copy link
Author

hayg25 commented Mar 29, 2021

ok I will wait for the conda update, I am somehow facing an error after installation :

ImportError                               Traceback (most recent call last)
<ipython-input-1-7824a10e5180> in <module>
----> 1 from astra import Astra

~/Astra/Lume_Astra/lume-astra/astra/__init__.py in <module>
      2 from .generator import AstraGenerator
      3 from .evaluate import evaluate_astra_with_generator
----> 4 from .astra_distgen import run_astra_with_distgen, evaluate_astra_with_distgen
      5 
      6 from ._version import __version__

~/Astra/Lume_Astra/lume-astra/astra/astra_distgen.py in <module>
      7 from .evaluate import default_astra_merit
      8 
----> 9 from distgen import Generator
     10 from distgen.writers import write_astra
     11 from distgen.tools import update_nested_dict

ImportError: cannot import name 'Generator' from 'distgen' (/home/guler/anaconda3/envs/astra/lib/python3.9/site-packages/distgen-1.7-py3.9.egg/distgen/__init__.py)

@ChristopherMayes
Copy link
Owner

@hayg25 distgen is a dependancy. Install via conda:

conda install -c conda-forge distgen

@hayg25
Copy link
Author

hayg25 commented Mar 30, 2021

Hi @ChristopherMayes,
thanks, there is no error remains.
I cannot see the field plot but I know that Astra uses the periodic solutions to create the Electric Field amplitude.
Is there a way to get that method into Lume-Astra ?

Thanks again

@ChristopherMayes
Copy link
Owner

@hayg25 Could you send me a minimal (but complete) example for me to debug?

@hayg25
Copy link
Author

hayg25 commented Mar 30, 2021

Hi @ChristopherMayes ,
here is my example files. Please tell me if something is missing.

astra_example.tar.gz

@hayg25
Copy link
Author

hayg25 commented Apr 6, 2021

Hi @ChristopherMayes ,
have you tried / succeeded to treat TWS structures in Lume-Astra ?

Cheers,
Hayg

@ChristopherMayes
Copy link
Owner

@hayg25 I added code to correctly plot the periodic field map, and adapted your example:
https://github.com/ChristopherMayes/lume-astra/blob/master/examples/elements/tws.ipynb

Please let me know if this works for you.

@hayg25
Copy link
Author

hayg25 commented Apr 8, 2021

Hi @ChristopherMayes ,
yes it works fine now thanks !
the length of the cavity is not taken into account, may be the numbers could be taken from the astra file ?

      Nue(2)=2.99855 
      MaxE(2)=14.0 
      Phi(2)=0 
      C_pos(2)=1.528 
      C_Smooth(2)=0
      C_numb(2)=135

other question :
do you understand why it says

Path does not exist for symlink: RAD

Thanks again

@ChristopherMayes
Copy link
Owner

@hayg25 It actually does read C_numb = 135. Your period (in the fieldmap file) is about 0.1 m, which gives a 13.5 m long cavity.

You can ignore the RAD warning for now. This is because Astra lets you put in a keyword in place of a file, and LUME-Astra looks at file keys for real files. I will fix this in the future.

@hayg25
Copy link
Author

hayg25 commented Apr 9, 2021

Dear @ChristopherMayes,
I see. You should divide by 3 to get the cell length due to the period (see attached description).
4cellprototype.pptx
In reality, the TWS cavity is around 4.8 m including the beam pipes.

many thanks

@ChristopherMayes
Copy link
Owner

@hayg25 Thank you, I fixed the code. Would you mind if I use your digram in the example?

@hayg25
Copy link
Author

hayg25 commented Apr 9, 2021

Hi @ChristopherMayes ,
Yes of course use it and thanks Alain for all your effort !

@hayg25
Copy link
Author

hayg25 commented May 3, 2021

Dear @ChristopherMayes ,
thanks again for all your efforts. Concerning the E-field of the cavity you plotted, we would like to also plot the complex magnitude component as displayed by the Astra fieldplot program.
See the attached plots.
Astra_Efiled_End
Astra_Efiled_Start

Many thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants