QODE 组装接口¶
oracq.algorithms.qode.ode
Problem objects, replaceable protocols, and history assembly for linear QODEs.
- class oracq.algorithms.qode.ode.QODEProblem(generator, initial, dissipative=None, initial_norm=None, evidence='caller_declared_unverified')[源代码]¶
基类:
objectThe u'=Gu problem; dissipative is a mathematical declaration, not a language proof.
- generator¶
- initial¶
- dissipative = None¶
- initial_norm = None¶
- evidence = 'caller_declared_unverified'¶
- class oracq.algorithms.qode.ode.QODESolver(name, kernel, requires_dissipative=False)[源代码]¶
基类:
objectLinear QODE solve-protocol wrapper with contract checking.
- 变量:
provides -- Set of protocols the output is declared to satisfy.
name (str) -- Protocol name, used in contracts, attributes, and error messages.
kernel (collections.abc.Callable[[...], oracq.algorithms.input_model.oracles.StateOracle]) -- The actual kernel; a callable of the form
(generator, initial, time) -> StateOracle.requires_dissipative (bool) -- When True, the problem-level
solvemust receive adissipative=Truedeclaration.
- provides = (<class 'oracq.algorithms.input_model.interfaces.StateOracleProtocol'>,)¶
- name¶
- kernel¶
- requires_dissipative = False¶
- property contract¶
Return the operator-state contract of this protocol.
The preconditions include the autonomous homogeneous
u'=Gu; whenrequires_dissipativeis True the requirementHermitian(G)<=0is appended, and the Schrödingerization protocol additionally appends the validation responsibility for the auxiliary window and the recovery region.- 返回:
The protocol contract;
assumptionsis the tuple of protocol-specific preconditions.- 返回类型:
- check(generator, initial=None, time=None)[源代码]¶
Check whether the inputs satisfy this protocol's contract, collecting unsatisfied items into a report.
- 参数:
generator -- Generator block encoding; a
QODEProblemmay also be passed directly, in which case the generator and initial state inside the problem object are used instead.initial -- Initial state preparation; ignored when a
QODEProblemis passed.time -- Evolution duration; when given, it is also checked to be a finite non-negative real number.
- 返回:
The check report;
issuescollects all unsatisfied items regarding layout, invocation capabilities, and precondition declarations.- 返回类型:
- solve(problem, time)[源代码]¶
Problem-level solve entry: check the contract, evolve, and write the declaration provenance into the output attributes.
- 参数:
problem -- A
QODEProblemproblem object.time -- Evolution duration; must be a finite non-negative real number.
- 返回:
The output state oracle; module attributes store
evidence, the dissipativity declaration, and the initial norm when provided, without adding a fabricated norm recovery capability.- 返回类型:
- 抛出:
ContractError -- The contract check failed (including an undeclared dissipativity precondition).
ValidationError --
problemis not aQODEProblem, ortimeis not a finite non-negative real number.
- oracq.algorithms.qode.ode.QODEProtocol¶
QODESolver的别名
- oracq.algorithms.qode.ode.make_euler_history_qode(qlss, *, steps=2)[源代码]¶
Wrap a QLSS solver into an implicit-Euler time-discretized QODE generation function.
It assembles, on the history register, a single linear system solving all time steps at once: the matrix is
I - dt*(Q⊗G) - S(Q selects all nonzero times, S is the truncated step shift), the right-hand side places the initial state at time zero, thenqlssis invoked to solve and the final-time subspace is selected.- 参数:
qlss -- A linear-system solve protocol that takes a matrix and a right-hand-side preparation and returns a
StateOracle.steps -- Number of time steps; must be a positive integer.
- 返回:
A generation function of the form
(generator, initial, final_time) -> StateOraclewhose output is the final-time state.- 返回类型:
callable
- 抛出:
ValidationError --
stepsis not a positive integer; or the input layout or time is invalid at generation time.
- oracq.algorithms.qode.ode.linear_qode(method, *, hamiltonian_function=<function taylor_hamiltonian>, **options)[源代码]¶
Generic u'=Gu interface that can be injected directly into existing QHAM / make_qpde.
- 参数:
method -- Solve method; one of
schrodingerization,lchs, orcbmd.hamiltonian_function -- Hamiltonian simulation implementation of the form (BE, time) returning a BlockEncoding; defaults to truncated Taylor.
**options -- Method configuration; only
planis accepted, and its type must match the chosen method.
- 返回:
The solve protocol wrapping the chosen method's kernel; the lchs/cbmd paths require a dissipativity declaration.
- 返回类型: