流场与 QRAM 数据

oracq.applications.flow_data

Classical Roe Riemann local updates and a queryable QRAM data structure; no matrix element table is stored.

class oracq.applications.flow_data.MemoryPatch(version, changes, recomputed_faces=(), recomputed_cells=())[源代码]

基类:object

Immutable write record returned by an update.

变量:
  • version (int) -- Storage version after applying the writes; unchanged when nothing is actually written.

  • changes (dict[str, dict[int, int]]) -- Storage items that actually changed, mapping addresses to integer values by bank name.

  • recomputed_faces (tuple[int, ...]) -- Face indices whose Riemann fluxes were recomputed by this update; empty for direct storage-layer writes.

  • recomputed_cells (tuple[int, ...]) -- Cell indices whose residuals were recomputed by this update; empty for direct storage-layer writes.

version
changes
recomputed_faces = ()
recomputed_cells = ()
class oracq.applications.flow_data.QRAMStore[源代码]

基类:object

Versioned multi-bank classical integer storage serving as the data source of a queryable QRAM.

变量:
  • banks -- Storage contents organized by bank name; each bank maps addresses to integer values.

  • version -- The version number; incremented once per apply call that produces actual writes.

banks
version
apply(changes)[源代码]

Apply a batch of updates and return the record of writes that actually happened.

Items equal to the current stored value (unwritten addresses count as zero) are not recorded in the result; the version increments when actual writes exist.

参数:

changes -- Writes to apply, mapping addresses to integer values by bank name.

返回:

The post-write version and actual writes, excluding recomputation ranges.

返回类型:

MemoryPatch

snapshot()[源代码]

Return an independent copy of all bank contents.

返回:

A copy of each bank's address-to-value mapping; modifying the snapshot does not affect the store.

返回类型:

dict

materialize_changed(patch, factory)[源代码]

PySparQ currently exposes no write interface: only the bank objects that changed are rebuilt, with no claim of physical in-place writes.

参数:
  • patch -- The incremental write record; only banks touched by its changes are rebuilt.

  • factory -- Factory that builds a host-side bank object from a bank name and its address-to-value mapping.

返回:

Mapping of rebuilt bank names to new bank objects; unchanged banks are absent.

返回类型:

dict[str, object]

oracq.applications.flow_data.riemann_flux(left, right, *, gamma=1.4, entropy_delta=0.125)[源代码]

Compute the classical Roe approximate Riemann flux on a single face.

The eigenvector matrix R is built from the Roe average of the left and right conserved states; the eigenvalues u-c, u and u+c take entropy-fixed absolute values, and |A| = R*diag(|lambda|)*R**-1 is assembled into the flux formula.

参数:
  • left -- The conserved variable triple of the left cell: density, momentum then energy.

  • right -- The conserved variable triple of the right cell, ordered as in left.

  • gamma -- Ratio of specific heats.

  • entropy_delta -- Harten entropy fix threshold; eigenvalues with smaller absolute value use the smoothed value instead.

返回:

The numerical flux of the three conserved components 0.5*(f_l+f_r) - 0.5*|A|*(u_r-u_l).

返回类型:

tuple

抛出:

ValidationError -- Density non-positive on either side, or the Roe-averaged squared sound speed non-positive.

class oracq.applications.flow_data.RoeFlowData(states, *, fmt=None, gamma=1.4, entropy_delta=0.125, angle_width=10, dx=1.0)[源代码]

基类:object

Periodic one-dimensional grid; three components padded to four; sign leaves plus a squared-norm and angle binary tree.

states
fmt
gamma
delta
angle_width
dx
n
store
fluxes
residuals
tree
last_patch
update(changed, *, initialize=False)[源代码]

Perform one local update with the given new cell values and write it into the QRAM store.

Only the Riemann fluxes on affected faces (including periodic neighbors) and the residuals of their adjacent cells are recomputed; the conserved-variable, sign, right-hand-side squared-norm tree and angle banks are maintained in sync.

参数:
  • changed -- Mapping of cell indices to new conserved variable triples.

  • initialize -- When True, residuals are recomputed for all cells; used only for the initial fill at construction.

返回:

The actual writes and recomputation ranges of this call, also saved as last_patch.

返回类型:

MemoryPatch

抛出:

ValidationError -- Cell index out of range or component count not equal to three.

property rhs_norm

L2 norm of the residual field, i.e. the square root of the squared-sum tree root.