# tree_d_3d.reference

*module*

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.

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L1-L1)

## tree_d_3d.reference.ReferenceNode

*class*

```python
class ReferenceNode
```

Bucket node with signed moments about its geometric centre.

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L20-L40)

### tree_d_3d.reference.ReferenceNode.NE

*attribute* · *instance attribute*

```python
NE = None
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L33-L33)

### tree_d_3d.reference.ReferenceNode.NW

*attribute* · *instance attribute*

```python
NW = None
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L33-L33)

### tree_d_3d.reference.ReferenceNode.SE

*attribute* · *instance attribute*

```python
SE = None
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L33-L33)

### tree_d_3d.reference.ReferenceNode.SW

*attribute* · *instance attribute*

```python
SW = None
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L33-L33)

### tree_d_3d.reference.ReferenceNode.bodies

*attribute* · *instance attribute*

```python
bodies = []
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L26-L26)

### tree_d_3d.reference.ReferenceNode.body

*attribute* · *instance attribute*

```python
body = None
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L25-L25)

### tree_d_3d.reference.ReferenceNode.center_of_charge

*attribute* · *instance attribute*

```python
center_of_charge = np.zeros(2)
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L30-L30)

### tree_d_3d.reference.ReferenceNode.count

*attribute* · *instance attribute*

```python
count = 0
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L27-L27)

### tree_d_3d.reference.ReferenceNode.dipole

*attribute* · *instance attribute*

```python
dipole = np.zeros(2)
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L31-L31)

### tree_d_3d.reference.ReferenceNode.quad

*attribute* · *instance attribute*

```python
quad = quad
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L24-L24)

### tree_d_3d.reference.ReferenceNode.second_moment

*attribute* · *instance attribute*

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

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L32-L32)

### tree_d_3d.reference.ReferenceNode.total_abs_charge

*attribute* · *instance attribute*

```python
total_abs_charge = 0.0
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L29-L29)

### tree_d_3d.reference.ReferenceNode.total_charge

*attribute* · *instance attribute*

```python
total_charge = 0.0
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L28-L28)

### tree_d_3d.reference.ReferenceNode.children

*property*

```python
children
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L39-L40)

### tree_d_3d.reference.ReferenceNode.is_external

*method*

```python
def is_external() -> bool
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L35-L36)

## tree_d_3d.reference.ReferenceQuadtree

*class*

```python
class ReferenceQuadtree
```

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.

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L43-L216)

### tree_d_3d.reference.ReferenceQuadtree.leaf_capacity

*attribute* · *instance attribute*

```python
leaf_capacity = int(leaf_capacity)
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L61-L61)

### tree_d_3d.reference.ReferenceQuadtree.max_depth

*attribute* · *instance attribute*

```python
max_depth = int(max_depth)
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L62-L62)

### tree_d_3d.reference.ReferenceQuadtree.root

*attribute* · *instance attribute*

```python
root = ReferenceNode(root_quad)
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L60-L60)

### tree_d_3d.reference.ReferenceQuadtree.collect_nodes

*method*

```python
def collect_nodes() -> list[ReferenceNode]
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L206-L216)

### tree_d_3d.reference.ReferenceQuadtree.compute_lorentz_force_on

*method*

```python
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.

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L186-L204)

### tree_d_3d.reference.ReferenceQuadtree.field_at

*method*

```python
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.

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L158-L184)

### tree_d_3d.reference.ReferenceQuadtree.insert

*method*

```python
def insert(body: ChargedBody) -> None
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/reference.py#L95-L103)
