QHAM 有限闭包¶
oracq.applications.qham.linearization
Lazily generate the QCL by HAM order and ordered tensor words; spatial matrices are not materialized.
- oracq.applications.qham.linearization.compositions(total, length)[源代码]¶
Lazily enumerate all ordered splits of
lengthnon-negative integers summing tototal, in increasing first-component order.- 参数:
total -- Target sum, a non-negative integer.
length -- Number of components in each split.
- 返回:
Lazy generator yielding one split at a time without materializing all splits.
- 返回类型:
Iterator[tuple[int, ...]]
- 生成器:
tuple[int, ...] --
- Ordered tuples of length
lengthwhose elements sum to
total; whenlengthis 0 the empty tuple is yielded only iftotalis 0.
- Ordered tuples of length
- class oracq.applications.qham.linearization.HomotopyWeight(kind='one', power=0)[源代码]¶
基类:
objectCoefficient on a QCL linear edge that varies with the homotopy parameter
eta.- 变量:
kind (str) -- Weight kind:
one(identically 1),correction, orphysical.power (int) -- Exponent used by the
correctionandphysicalkinds.
- kind = 'one'¶
- power = 0¶
- evaluate(eta)[源代码]¶
Evaluate the weight at the homotopy parameter
eta.- 参数:
eta -- Homotopy parameter value.
- 返回:
oneis identically 1,correctionis-eta*(1+eta)**power, andphysicalis1-(1+eta)**power.- 抛出:
ValidationError --
kindis not a supported weight kind.
- class oracq.applications.qham.linearization.Block(kind, orders=())[源代码]¶
基类:
objectOne block variable of the QCL finite closure.
- 变量:
kind (str) -- Block kind;
physicalis the physical output block, the sum of the HAM order components, andtensoris a tensor block on independent coordinates.orders (tuple[int, ...]) -- Tensor word, i.e. the ordered tuple of HAM orders of the factors; always the empty tuple for physical blocks, and the empty tuple with
tensordenotes the constant block introduced by forcing homogenization.
- kind¶
- orders = ()¶
- property rank¶
Number of tensor factors of the block; 1 for physical blocks and 0 for the empty-word constant block.
- property label¶
Return the human-readable label of the block.
Physical blocks are
u_sum, the empty-word constant block isone, and other tensor blocks areY_followed by the underscore-joined orders.
- class oracq.applications.qham.linearization.Coupling(row, column, operator, position, arity, weight=HomotopyWeight(kind='one', power=0))[源代码]¶
基类:
objectOne linear edge of the QCL closure, delivering a column block's contribution into the row block's equation.
- 变量:
row (oracq.applications.qham.linearization.Block) -- Target block of the edge (the owning equation row).
column (oracq.applications.qham.linearization.Block) -- Source block of the edge (the input variable).
operator (str) -- Name of the applied multilinear port, e.g.
L,F, orB_i.position (int) -- Which tensor factor of the row block the port acts on, replacing it; counted from 0.
arity (int) -- Number of port inputs.
weight (oracq.applications.qham.linearization.HomotopyWeight) -- Homotopy weight of this edge, identically 1 by default.
- row¶
- column¶
- operator¶
- position¶
- arity¶
- weight = HomotopyWeight(kind='one', power=0)¶
- class oracq.applications.qham.linearization.QHAMPlan(pde, order, version='0.1')[源代码]¶
基类:
objectQCL finite closure plan of a polynomial PDE at a HAM truncation order.
The closure is bounded by the weight criterion
p*sum(orders)+len(orders) <= p*m+1, wherep = max(1, D-1),Dis the PDE polynomial degree, andmis the truncation order. The block set and each row rule are enumerated lazily; the closure matrix is never materialized.- 变量:
pde (oracq.applications.qham.pde.PolynomialPDE) -- The
PolynomialPDE, validated at construction.order (int) -- HAM truncation order
m, must be a non-negative integer.version (str) -- Serialization format version, currently
0.1.
- 抛出:
ValidationError --
pdefails validation, ororderis not a non-negative integer, orversionis not0.1.
- pde¶
- order¶
- version = '0.1'¶
- property grade¶
Degree scaling of the closure weight criterion,
p = max(1, D-1), withDthe PDE polynomial degree.
- property max_rank¶
Closure weight bound
p*m+1, the maximum tensor rank allowed for tensor blocks.
- property has_forcing¶
Whether the PDE has a constant forcing term, i.e. port
Fexists and the closure needs the empty-word constant block.
- weight(word)[源代码]¶
Compute the closure weight
p*sum(word)+len(word)of a tensor word.- 参数:
word -- Tuple of the HAM orders of the factors.
- 返回:
The closure weight of this tensor word.
- 返回类型:
int
- contains(block)[源代码]¶
Test whether a block belongs to this plan's finite closure.
Physical blocks must carry no orders; the empty-word tensor block belongs only when forcing exists; other tensor blocks require every order to be a non-negative integer with closure weight within the bound; block kinds other than these never belong to the closure.
- 参数:
block -- The block to check.
- 返回:
True when the block belongs to the closure.
- 返回类型:
bool
- rank_count(rank)[源代码]¶
Count the closure tensor blocks of a given tensor rank.
- 参数:
rank -- Number of tensor factors, counted from 1.
- 返回:
Number of tensor words of this rank satisfying the weight constraint; 0 when the rank is below 1 or above the bound.
- 返回类型:
int
- property block_count¶
the physical block, the optional empty-word constant block, plus the tensor blocks of each rank.
- Type:
Total closure block count
- blocks(*, max_blocks=None)[源代码]¶
Lazily enumerate all blocks of the closure in canonical order.
The physical block comes first, tensor blocks follow by ascending rank and, within a rank, by ascending word sum (ties follow the
compositionsenumeration order), and the empty-word constant block, when forcing exists, comes last.- 参数:
max_blocks -- Budget for explicitly enumerated blocks; when the total block count exceeds it an error is raised immediately, pointing to lazy queries instead.
- 返回:
Lazy generator yielding closure blocks one at a time without materializing the full block list.
- 返回类型:
Iterator[Block]
- 生成器:
Block -- A block of the closure.
- 抛出:
ValidationError --
max_blocksis given and the closure block count exceeds the budget.
- row_terms(row)[源代码]¶
Enumerate all linear edges of a row block within the closure.
Three edge classes are covered: the same-word linear edge
L; forcing insertion edgesF(physical rows take the empty-word constant block, tensor rows take the word with that zero-order factor removed); and edges replacing a higher-order factor with a lower-order tuple and applying a nonlinear port, carrying aphysicalorcorrectionhomotopy weight. The row of the empty-word constant block has no edges.- 参数:
row -- Row block, must belong to the closure.
- 返回:
All edges of this row; each edge's
rowfield equals the input.- 返回类型:
tuple[Coupling, ...]
- 抛出:
ValidationError -- The row block is outside the finite closure.
AssertionError -- A generated column block escapes the closure, i.e. the closure construction invariant is broken.
- raw_dimension(dimension)[源代码]¶
Compute the total dimension of the closure linear system.
- 参数:
dimension -- Dimension of a single block's local state space.
- 返回:
Sum of the local dimensions of the physical block and each rank's tensor blocks (
dimension**rank), plus the single coordinate of the empty-word constant block when forcing exists.- 返回类型:
int
- offset(block, dimension)[源代码]¶
Return the global start index of local coordinate 0 of a block within the closure system.
Blocks are laid out in the canonical order of
blocks: the physical block first, each rank's tensor blocks occupyingdimension**rankconsecutive coordinates, and the empty-word constant block last with a single coordinate.- 参数:
block -- A block within the closure.
dimension -- Dimension of a single block's local state space.
- 返回:
The starting global index of this block.
- 返回类型:
int
- 抛出:
ValidationError -- The block is outside the closure.
- locate(index, dimension)[源代码]¶
Decompose a global index into its owning block and local index within the block; inverse of
offset.- 参数:
index -- Global index within the closure system.
dimension -- Dimension of a single block's local state space.
- 返回:
The block containing the index and the local index within it.
- 返回类型:
tuple[Block, int]
- 抛出:
ValidationError -- The index is outside the closure system's total dimension.
- summary()[源代码]¶
Summarize the plan's key quantities for reports and diagnostics.
- 返回:
Dictionary with the version, truncation order, PDE degree, maximum tensor rank, total block count, whether forcing exists, a description of the closure criterion, and each port's arity.
- 返回类型:
dict
- dumps()[源代码]¶
Serialize the plan to canonical JSON text.
- 返回:
JSON text with
version,order, andpdefields, keys sorted, indentation 2, ending with a newline.- 返回类型:
str
- classmethod loads(text)[源代码]¶
Rebuild a plan from the JSON text produced by
dumps.- 参数:
text -- JSON text.
- 返回:
The rebuilt plan; validation runs again at construction.
- 返回类型:
- 抛出:
ValidationError -- The JSON structure, field set, or data is invalid.