FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
0255 — Newton matrix leaves out the feedthrough of stateful SimObjects
ID 0255
Class KNOWN-LIMITATION
Severity 1
Status blocked

Models: —

Found: 2026-11-25, feature me-fish-open-issues (ruling D9), by MF (MARE-0467, FISH-0143)

Decision needed: whether to allow InputOutputJacobian on stateful SimObjects, or to add a separate feedthrough callback.

Evidence

The API has one feedthrough callback, and it is limited to stateless objects. include/fhsim/simobject/SimObjectInclude.h:302-319 documents InputOutputJacobian as "the direct feedthrough term" and says that it "is only ever called on a SimObject with no states". X is nullptr or not offset to the object. There is no feedthrough term for a stateful object. OutputPortJacobian and InputPortJacobian only give d(output)/d(state) and d(state derivative)/d(input).

The engine calls it only for a stateless intermediate S of an A->S->B coupling.

  • src/engine/model/PortCouplingEvaluator.cpp:86 calls intermediateObject->InputOutputJacobian(...) with nullptr for X.
  • src/engine/model/SensitivityAnalyzer.cpp:227 and :635 call it on producerObj, the stateless producer.
  • src/engine/model/ModelAssemblyWiring.cpp:414-471 (BuildPortJacobianLinks) skips any object without states (the simObjectStateOffsets.contains guards at :437-439). The stateless chains are built at :484-545 (statelessIn, statelessOut). No link carries the input->output term of a stateful object.

Consumers that need the term (both on local main):

  • fhsim_marine_elements/src/cable/CableBranched.h:280-297: the port Jacobian section. The Force, Tension and Length outputs depend directly on the Pos, Vel and Length inputs. InputPortJacobian gives only the effect on the states.
  • fhsim_fishery/src/trawl/TrawlVessel.h:46-48: "The outputs `Vel` and `WarpVel<n>` also read the command ports directly (the speed, the yaw rate). The SimObject API has no term for that feedthrough of a stateful object, so a command that comes from another object's state is not carried through to a consumer of those outputs."

Effect

In a chain such as door -> warp Force -> door, the term d(Force)/d(door position input) is missing from the Newton (implicit solver) matrix. The same holds for Trawl/Vessel: a Vel or Heading command that comes from another object's state does not reach the consumers of its Vel and WarpVel outputs. The results do not change. Newton converges more slowly (more iterations or more step rejections). Low severity, a performance cost only.

Possible fix

For the owner to rule:

  • Allow InputOutputJacobian on stateful objects. The doc comment and the "X is not usable" rule change, and the engine must pass the object's own state slice. Wiring must then build links for stateful objects too.
  • Add a separate feedthrough callback for stateful objects and leave InputOutputJacobian as the stateless-intermediate callback.

Either way the wiring in ModelAssemblyWiring.cpp and the sparsity pattern must get the new input->output entries.

Test that would prove it

A model with a stateful object whose output depends directly on its input, in a loop with another stateful object. The analytical Newton matrix must equal the numerical one, and the Newton iteration count must fall.

Risk

Low for results. A change to the callback contract touches every SimObject that overrides InputOutputJacobian (contract C-list in the workspace) and the testtools block checker (src/testtools/PortJacobianBlockChecker.cpp).