Skip to content

feat: consume typed OperatorDescriptor from op_system in flepimop2-op_engine adapter #65

@jc-macdonald

Description

@jc-macdonald

Motivation

Companion to ACCIDDA/op_system#156.

Currently flepimop2-op_engine retrieves operator specs from system.option("operators", None) as an untyped dict and has to reverse-engineer the model axis structure before calling build_crank_nicolson_operator. There is no enforced contract between what op_system produces and what this adapter expects.

Proposal

Once ACCIDDA/op_system#156 lands a typed OperatorDescriptor dataclass in op_system's public API, update the flepimop2-op_engine adapter to:

  1. Read system.option("operators") as tuple[OperatorDescriptor, ...] rather than an opaque dict.
  2. Build CN (L, R) matrices from the typed descriptor fields:
    for desc in system.option("operators", ()):
        L, R = build_crank_nicolson_operator(desc.geometry, desc.coefficient, dt)
  3. Drop any internal parsing/coercion logic (_coerce_operator_specs) that currently normalises the untyped option.

What stays in op_engine

  • build_crank_nicolson_operator(geom, cfg, dt) — CN matrix construction at solve time (depends on dt, which is solver-side)
  • StageOperatorFactory and per-step factory calls for adaptive / TR-BDF2 schemes
  • LU factorisation caching in implicit_solve

All of this remains entirely correct. Only the source of the operator geometry changes from an untyped option to a typed descriptor.

Scope

  • Update OpEngineFlepimop2Engine in flepimop2-op_engine/src/flepimop2/engine/op_engine/__init__.py
  • Remove or simplify _coerce_operator_specs
  • Add a type annotation / isinstance guard on the incoming option value
  • Update tests in flepimop2-op_engine to pass OperatorDescriptor instances

Dependency

Blocked on ACCIDDA/op_system#156.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    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