ocelot-collab / ocelot

OCELOT is a multiphysics simulation toolkit designed for studying FEL and storage ring-based light sources.
GNU General Public License v3.0
84 stars 58 forks source link

Error with injector_lattice #168

Closed dmargarone closed 1 year ago

dmargarone commented 1 year ago

Hi,

When I am trying to follow the "tutorial N2: Tracking" I received an error message as follows:

*from injector_lattice import ModuleNotFoundError: No module named 'injector_lattice'**

I did not encountered any error with "tutorial N1: Linear optics" but from tutorial N2 onwards error starts appearing.

Could you please help me to fix the error.

Thanks a lot.

st-walker commented 1 year ago

From which directory are you running it? injector_lattice.py is in ocelot/demos/ipython_tutorials, if you are running the jupyter notebooks from elsewhere it won't be able to find this file. I just tried it and it works for me.

dmargarone commented 1 year ago

Hi @st-walker , thanks your quick reply.

Actually, I am using my old computer with Mac OS big-sur. In this, I can install Ocelot using conda.

I am running all these tutorials in "Spyder". I am just copying the example tutorials step-by-step and running it. In this way I am trying to follow what happens. Normally, I run all installed python based programs on "Spyder" and its works always. The installed packages are automatically imported by "Spyder" when invoked by "import" command.

Still it is a puzzle, why this error appear ....

Tutorial N1 runs fine. Do you thinks I should re-install with conda again.

Tomorrow, I will also try to install Ocelot from repository on my ubuntu (ver. 22.04).

dmargarone commented 1 year ago

Hi @st-walker ,

I searched for "injector_lattice" and found that it is in the "ipython_tutorials" folder. Please, see the attached figure.

I am using the following lines in the "Spyder":

===================================

from copy import deepcopy import time from ocelot import from ocelot.gui.accelerator import from injector_lattice import *

lat = MagneticLattice(cell, stop=None)

tws0 = Twiss()

tws0.beta_x = 29.171 tws0.beta_y = 29.171 tws0.alpha_x = 10.955 tws0.alpha_y = 10.955

tws0.E = 0.005

tws = twiss(lat, tws0, nPoints=None)

===================================

screen_shot
st-walker commented 1 year ago

To be honest I don't have any experience with the conda installation. @sergey-tomin is the expert on this. My workflow is to clone the github repository and run the notebooks thence. If you do this it will work. I have no experience with spyder either. Otherwise you should wait for @sergey-tomin to reply.

I know why it's not working for you, it's simply that injector_lattice.py isn't installed by conda because it's not part of the library, just the examples. If you really want to go down the copy/paste route, the file is here: https://github.com/ocelot-collab/ocelot/blob/master/demos/ipython_tutorials/injector_lattice.py

dmargarone commented 1 year ago

Hi @st-walker , thank you so much for your kind reply.

Do you think, Ocelot can be installed on Ubuntu 22.04 through repository ?

I guess, it will be easy to use Ocelot in Ubuntu or Windows ....

st-walker commented 1 year ago

Cloning the repository and installing with the setup.py is the most guaranteed way to work. I only ever do it this way but I change ocelot a lot so this makes sense for me anyway. ocelot definitely works on any linux or mac distribution. I have no experience with windows. I am using it on a macbook right now.

like this:

https://github.com/ocelot-collab/ocelot#github

dmargarone commented 1 year ago

Hi @st-walker thank you so much. Tomorrow, I will try to install it on Linux (Ubuntu). I hope I will be able to install and run it.

If there will be any issue, I will let your know.

Thank you once again.

st-walker commented 1 year ago

no problem just follow these simple instructions:

https://github.com/ocelot-collab/ocelot#github

It's how anyone developing ocelot will install ocelot. I know it works.

dmargarone commented 1 year ago

Thank you @st-walker , I will let you know the status tomorrow.

dmargarone commented 1 year ago

Hi @st-walker , good news .... I found the way. I just need to include the corresponding folders as follows:

=============================

from ocelot.demos.ipython_tutorials.injector_lattice import *

=============================

Now, I know how to do with conda. ( However, I will also try to install in linux with cloning the repository).

st-walker commented 1 year ago

OK good to hear and know that the demos work with conda too