PDE 模型与适配

oracq.algorithms.input_model.pde

Composable spatial and initial-state inputs for quantum PDE methods.

class oracq.algorithms.input_model.pde.PDEGrid(*args, **kwargs)[源代码]

基类:SpatialGrid, Protocol

Spatial rows, quantum derivative encodings, and their memory snapshots.

property qrams

QRAM snapshots backing the grid's derivative encodings.

derivative_encoding(derivative)[源代码]

Return a block encoding of the sparse derivative operator.

class oracq.algorithms.input_model.pde.UniformGrid1D(start, stop, points, boundary='periodic', axis='x')[源代码]

基类:object

Uniform spatial samples with an explicit interval and boundary convention.

Periodic samples cover [start, stop) with spacing (stop-start)/points. Zero Dirichlet samples are interior points with spacing (stop-start)/(points+1). Power-of-two periodic grids use shift circuits; other grids use a bounded spatial Pauli expansion of at most five qubits. Only spatial derivatives are materialized, never multilinear PDE ports.

start
stop
points
boundary = 'periodic'
axis = 'x'
property axes

Spatial axis names.

property size

Number of physical samples, excluding register padding.

property spatial_width

Address register width, retaining padding for arbitrary point counts.

property spacing

Physical sample spacing.

property qrams

Uniform grids do not require a memory bank.

coordinate(index)[源代码]

Physical coordinate of a sample.

derivative_row(derivative, row)[源代码]

Finite-difference row, with padding outside the physical grid zero.

derivative_encoding(derivative)[源代码]

Encode a derivative while preserving the physical grid size.

class oracq.algorithms.input_model.pde.UnstructuredGridConfig(size, derivative_offsets, value_scale=1.0, axes=('x',))[源代码]

基类:object

Layout of real discrete derivative matrices in a QRAM angle bank.

Each derivative key maps to a base address. A matrix uses base + row * 2**spatial_width + column and has entries value_scale*cos(pi*word/2**word_length). Thus a zero entry is an angle word 2**(word_length-1), not a zero word. Boundary conditions and geometric discretization are already incorporated in these matrices.

size
derivative_offsets
value_scale = 1.0
axes = ('x',)
encode_matrices(matrices, word_length, *, max_words=1048576)[源代码]

Encode physical derivative matrices in this layout, including zero padding.

The amplitude error per entry is at most value_scale*pi/2**word_length. The negative endpoint is saturated to the largest word instead of wrapping a full turn to zero.

class oracq.algorithms.input_model.pde.UnstructuredGrid(qram, config)[源代码]

基类:object

A spatial discretization supplied as QRAM derivative matrices.

The quantum adapter uses uniform row/column projection and QRAM angle transduction. Its normalization is 2**spatial_width * value_scale; it supports nonsymmetric real matrices and makes no sparse-access speedup claim. A different storage model can implement PDEGrid directly.

qram
config
property axes

Spatial axis names.

property size

Number of physical nodes.

property spatial_width

Node address width.

property qrams

The registered operator memory.

derivative_row(derivative, row)[源代码]

Decode a physical row for reference evaluation and known coefficients.

derivative_encoding(derivative)[源代码]

Query the configured table coherently and project both padding spaces.

class oracq.algorithms.input_model.pde.InitialLayout(grid, fields, max_words=4096)[源代码]

基类:object

Physical fields and grid nodes, with field-major register padding.

grid
fields
max_words = 4096
property width

Combined component and spatial register width.

property size

Number of physical samples across all fields.

encode(values)[源代码]

Pad physical samples without treating padded addresses as grid nodes.

class oracq.algorithms.input_model.pde.PDEProblem(grid, initial=<factory>, type='burgers', final_time=1.0, viscosity=0.1, known=<factory>)[源代码]

基类:object

A PDE recipe whose grid and physical initial input can be composed independently.

type accepts burgers, heat, or an existing PolynomialPDE. Presets use one field u and the grid's first axis. known holds physical coefficient/forcing samples. Solver approximations belong to the method configuration, not this problem object.

grid
initial
type = 'burgers'
final_time = 1.0
viscosity = 0.1
known
equation