hibtc / cpymad

Cython binding to MAD-X
http://hibtc.github.io/cpymad/
Other
27 stars 18 forks source link

Add property to access current beam #123

Closed coldfix closed 1 year ago

coldfix commented 1 year ago

Resolves #122

@rdemaria This will change the property madx.beam to return the current beam (instead of deferring to madx.command.beam as was done until now), e.g.:

mad = Madx()
mad.beam(particle='electron')
assert mad.beam.particle == 'electron'
rdemaria commented 1 year ago

That was quick! I also thought it could be useful to have access to the list of beams. See https://github.com/hibtc/cpymad/compare/master...rdemaria:cpymad:beam-list

coldfix commented 1 year ago

That was quick! I also thought it could be useful to have access to the list of beams. See master...rdemaria:cpymad:beam-list

Sure, makes sense. Post a PR when ready.

fsoubelet commented 1 year ago

Resolves #122

@rdemaria This will change the property madx.beam to return the current beam (instead of deferring to madx.command.beam as was done until now), e.g.:

mad = Madx()
mad.beam(particle='electron')
assert mad.beam.particle == 'electron'

Hello! Very nice to get this. Do I understand correctly that this would behave similarly to how madx.twiss() does compared to madx.command.twiss()?

coldfix commented 1 year ago

Resolves #122 @rdemaria This will change the property madx.beam to return the current beam (instead of deferring to madx.command.beam as was done until now), e.g.:

mad = Madx()
mad.beam(particle='electron')
assert mad.beam.particle == 'electron'

Hello! Very nice to get this. Do I understand correctly that this would behave similarly to how madx.twiss() does compared to madx.command.twiss()?

In a way. Both mad.twiss and mad.beam will be overloads of mad.command.XXX with some specialized behaviour.