Code Monkey home page Code Monkey logo

Comments (4)

lfarv avatar lfarv commented on July 20, 2024

Hi @T-Nicholls. Are you sure that:

  • you use the last version of AT
  • you call the python get_mcf with ddp=1.E-6, which is what Matlab uses
  • you run on the same machine

I get an agreement with 15 digits for dp=0, and with 10 digits for dp!= 0

 0.00  8.506669244225616e-05
 0.01  8.820785279e-05
-0.01  8.2317973893e-05

Which agrees with your Matlab results !!!

(running on MacOSX 10.14, python 2.7 and 3.6, Matlab R2018a)

from at.

T-Nicholls avatar T-Nicholls commented on July 20, 2024

@lfarv my apologies, a change I made caused the difference.

Ok, I have found the source of the problem:

  • I was using a branch where the py_hmba fixture had a scope session, i.e.
    @pytest.fixture(scope='session')
    def py_hmba():
        return Lattice(load_mat(utils.hmba_ring, key='RING'), keep_all=True)
    
  • We turn on radiation in the lattice in test_ohmi_envelope:
    # Python call
    py_lattice.radiation_on()
    py_emit0, py_beamdata, py_emit = physics.ohmi_envelope(py_lattice, refpts)
    
  • The same lattice is used and the radiation is not turned off. Adding a line to turn it off fixes the issue:
    # test momentum compaction factor
    py_lattice.radiation_off()
    py_mcf = py_lattice.get_mcf(dp, ddp=1.E-6)  # Matlab uses ddp=1.E-6
    

Should we be ensuring the radiation state of the lattice, as we do for linopt and ohmi_envelope, or is get_mcf designed to be run in both states and the difference to be expected?

from at.

lfarv avatar lfarv commented on July 20, 2024

get_mcf is based on find_orbit4. Strictly speaking, this is valid if there is no longitudinal motion (radiation off), though many people use it in any condition (as you could see, the results are not very different). The get_mcf function works for any sequence of elements and cannot be protected, but the get_mcf method of the Lattice object could be, as it is done for linopt.

from at.

T-Nicholls avatar T-Nicholls commented on July 20, 2024

@lfarv thank you for the clarification, I will protect the get_mcf method on Lattice then.

from at.

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.