Skip to content

Should be Twiss per element when calculating optics instead of Twiss per map #292

Description

@st-walker

Liebe Leute,

Here's the current function

def trace_obj(lattice, obj, nPoints=None, attach2elem=False):
    """
    track object through the lattice
    obj must be Twiss or Particle
    """

    if nPoints is None:
        obj_list = [obj]
        for e in lattice.sequence:
            for tm in e.first_order_tms:
                obj = tm * obj
                obj.id = e.id
                obj_list.append(obj)
            if attach2elem:
                e.tws = obj
    else:
        z_array = np.linspace(0, lattice.totalLen, nPoints, endpoint=True)
        obj_list = trace_z(lattice, obj, z_array)
    return obj_list

As you can see we return one twiss per map. We should perhaps consider returning one twiss per element instead. I think this would be better.

Like this:

        for e in lattice.sequence:
            for tm in e.first_order_tms:
                obj = tm * obj

            obj.id = e.id
            obj_list.append(obj)
 
            if attach2elem:
                e.tws = obj

What do you think? Or make it an option?

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions