Skip to content
Projects

tree_d_3d.reference

The object quadtree: a readable reference implementation of the flat tree.

It evaluates one target at a time in Python, with the same moments (through the quadrupole) and opening criterion as :class:tree_d_3d.flat_tree.FlatQuadtree; kept for inspection and tests.

Classes

NameDescription
ReferenceNodeBucket node with signed moments about its geometric centre.
ReferenceQuadtreeBounded-depth quadtree with signed moments through quadrupole order.

ReferenceNodeclass#

class ReferenceNode(quad: Quad)

Bucket node with signed moments about its geometric centre.

NEattributeinstance attribute#

NE = None

NWattributeinstance attribute#

NW = None

SEattributeinstance attribute#

SE = None

SWattributeinstance attribute#

SW = None

bodiesattributeinstance attribute#

bodies = []

bodyattributeinstance attribute#

body = None

center_of_chargeattributeinstance attribute#

center_of_charge = np.zeros(2)

countattributeinstance attribute#

count = 0

dipoleattributeinstance attribute#

dipole = np.zeros(2)

quadattributeinstance attribute#

quad = quad

second_momentattributeinstance attribute#

second_moment = np.zeros((2, 2))

total_abs_chargeattributeinstance attribute#

total_abs_charge = 0.0

total_chargeattributeinstance attribute#

total_charge = 0.0

childrenproperty#

children

is_externalmethod#

def is_external() -> bool

ReferenceQuadtreeclass#

class ReferenceQuadtree(root_quad: Quad, *, leaf_capacity: int = 8, max_depth: int = 48)

Bounded-depth quadtree with signed moments through quadrupole order.

Coincident particles remain in leaf buckets. Theta=0 evaluates all pairs. Cells containing the target are always opened. The opening criterion uses unsoftened distance so softening cannot make a nearby cell look distant.

leaf_capacityattributeinstance attribute#

leaf_capacity = int(leaf_capacity)

max_depthattributeinstance attribute#

max_depth = int(max_depth)

rootattributeinstance attribute#

root = ReferenceNode(root_quad)

collect_nodesmethod#

def collect_nodes() -> list[ReferenceNode]

compute_lorentz_force_onmethod#

def compute_lorentz_force_on(body: ChargedBody, theta: float = 0.5, k_e: float = K_E, softening: float = 0.0, B_z: float = 0.0) -> None

Store q(E + v cross B), with no self-force.

field_atmethod#

def field_at(position: Sequence[float], *, theta: float = 0.5, k_e: float = K_E, softening: float = 0.0, exclude: ChargedBody | None = None) -> tuple[float, np.ndarray]

Return (potential, electric field), excluding one source by identity.

Potential and field use the same softened multipole expansion. Rebuild the tree after moving or changing any source particle.

insertmethod#

def insert(body: ChargedBody) -> None