Skip to content

Default the bend actual field from g_ref#73

Merged
DavidSagan merged 1 commit into
mainfrom
bend-actual-field-default
Jul 23, 2026
Merged

Default the bend actual field from g_ref#73
DavidSagan merged 1 commit into
mainfrom
bend-actual-field-default

Conversation

@DavidSagan

Copy link
Copy Markdown
Member

Implements the Kn0_from_g_ref defaulting of bend.md, the behavior that replaced the g_actual / bend_field_actual pair retired in #72.

Unless the author says otherwise, a bend bends its own reference particle along the reference curve, so the actual bending field is the reference one: Kn0 = g_ref (equivalently Bn0 = Bn0_ref). resolve_bend_actual_field runs between the bend and multipole resolvers, seeding the dipole component that resolve_magnetic_multipoles then completes into all four forms.

b1:
  kind: Bend
  length: 1.5
  BendP:
    g_ref: 0.1
    Kn0_from_g_ref: true    # materialized default
    ...
  MagneticMultipoleP:       # created to hold the actual field
    Kn0: 0.1
    Kn0L: 0.15000000000000002
    Bn0: -0.33356405164803304
    Bn0L: -0.5003460774720496

The default stands down whenever the author has stated the field: any of Kn0, Kn0L, Bn0, Bn0L counts, since the integrated forms say the same thing over the length. A skew dipole does not — that is a different component. Kn0_from_g_ref: false declines the default outright, and a straight bend has no reference field to copy, so nothing is written and no group appears.

Two notes on where things land:

  • MagneticMultipoleP is created on a curved bend that carries none. That is a third exception to "an absent group is left untouched", after the parser-added ReferenceP and FloorP; without it the default would be unobservable, since the common bend writes no multipole group at all. The comment on kGroupDefaults and the "leaves absent parameter groups alone" test both now say so.
  • Kn0_from_g_ref: true joins kGroupDefaults, a non-false default of a group the element already carries, alongside ref_geometry: ARC.

Six new bookkeeper tests: the default itself, the false setting, an author-set Kn0 kept as-is, Kn0L counting as set, the field joining a group of other orders, and the straight bend. 174 tests pass.

🤖 Generated with Claude Code

Implements Kn0_from_g_ref (bend.md), the behavior that replaced the
retired g_actual/bend_field_actual pair: unless the author says
otherwise, a bend bends its own reference particle along the reference
curve, so Kn0 = g_ref and Bn0 = Bn0_ref. The seeded component is
completed into all four forms by the multipole resolver that runs next.

Any of Kn0, Kn0L, Bn0 or Bn0L already given stands the default down --
the integrated forms state the same field over the length -- as does
Kn0_from_g_ref: false, and a straight bend has no field to copy.

A curved bend carrying no MagneticMultipoleP gets one created for the
field to live in, a third exception to leaving absent groups untouched
after the parser-added ReferenceP and FloorP. Kn0_from_g_ref itself
joins the non-false group defaults.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@DavidSagan
DavidSagan merged commit 6448a0e into main Jul 23, 2026
3 checks passed
@DavidSagan
DavidSagan deleted the bend-actual-field-default branch July 23, 2026 03:12
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

Successfully merging this pull request may close these issues.

1 participant