Topologie (pyna.topo)#
Das Paket pyna.topo stellt Algorithmen zur Analyse der topologischen
Struktur von Poincaré-Karten bereit: magnetische Inseln, X/O-Zyklen, stabile
und instabile Mannigfaltigkeiten sowie heterokline Verflechtungen.
Das zentrale Design ist eine zweischichtige Hierarchie:
pyna.topo.coreendlichdimensionale, domänenunabhängige Geometrie:
Trajectory,Orbit,PeriodicOrbit,Cycle,Island,IslandChain,TubeundTubeChain.pyna.topo.toroidalSpezialisierungen für magnetische Einschließung, die
R/Z/phi, Windungszahlen, Monodromy-Nutzdaten, cyna-gestützte Schnitte und toroidale Diagnostik hinzufügen.
Poincaré-Karten#
Geometrieobjekt-Hierarchie#
pyna.topo._base – Base classes for topology / geometry objects.
Extracted to a separate module to avoid circular imports between island_chain.py and invariant.py.
Hierarchy#
- GeometricObject — root ABC for sampled or exact geometric objects
- InvariantSet — root ABC for mathematically invariant objects
InvariantManifold — invariant set with a well-defined intrinsic dimension
Trajectory — sampled continuous curve (not assumed invariant) Orbit — periodic orbit of a discrete map (invariant)
- SectionCuttable — mixin protocol for objects that can be sliced by a
Poincaré section
Design principle#
Finite sampled geometry should not automatically be promoted to an invariant
object. In particular, a numerically traced open trajectory is useful
geometry, but it is not an InvariantSet merely because it came from a
flow integration. Established periodic objects such as Cycle and
PeriodicOrbit remain in the invariant hierarchy.
InvariantObject remains available as a backward-compatible alias that
points to InvariantSet so that existing subclass declarations keep working.
- class pyna.topo._base.GeometricObject[source]
Bases:
ABCAbstract base for sampled or exact geometric/topological objects.
This is intentionally broader than
InvariantSet: it covers both mathematically invariant objects and finite numerical representations such as sampled trajectories.
- class pyna.topo._base.InvariantManifold[source]
Bases:
InvariantSetAn invariant set with a well-defined intrinsic dimension.
InvariantManifoldsits between the abstractInvariantSetand the concrete geometry types (FixedPoint,PeriodicOrbit,InvariantTorus,StableManifold, …).The key additional concept is intrinsic dimension:
FixedPoint→ intrinsic_dim = 0Orbit/PeriodicOrbit→ intrinsic_dim = 0 (finite set of map points)Trajectory/Cycle→ intrinsic_dim = 1 (continuous curve)InvariantTorusof order k → intrinsic_dim = kStableManifoldof a hyperbolic orbit → intrinsic_dim = dim(E^s)
The codimension is
ambient_dim - intrinsic_dimwhenambient_dimis known.Subclasses must set intrinsic_dim (as a class attribute,
__init__argument, or@property). The default isNone(unknown).
- pyna.topo._base.InvariantObject
Backward-compatible alias. Prefer
InvariantSetin new code.
- class pyna.topo._base.InvariantSet[source]
Bases:
GeometricObjectAbstract base for any invariant geometric object of a dynamical system.
An invariant set S satisfies φ^t(S) ⊆ S for all t (continuous flow) or P(S) = S (discrete map).
Design: Pure interface — no
__init__, no state fields. Concrete subclasses (including dataclasses) provide their own fields and satisfy the interface via@propertyoverrides.section_cutanddiagnosticsare no longer abstract. Not every invariant set can be meaningfully cut by a section (e.g. a KAM torus in a 6N-dim N-body phase space may have no natural Poincaré section). Use theSectionCuttablemixin to mark objects that can be sectioned.- Optional interface (all have sensible defaults):
.label @property -> str | None .ambient_dim @property -> int | None .poincare_map @property -> PoincareMap | None .phase_space @property -> PhaseSpace | None .diagnostics() -> dict .section_cut(s) -> list (raises NotImplementedError by default)
- diagnostics()[source]
Return a structured diagnostic / debug dict.
The default implementation returns a minimal dict with just the class name. Subclasses are encouraged to override and add domain-specific information.
- property phase_space[source]
Phase space of the associated map (PhaseSpace | None).
- property poincare_map[source]
The Poincaré map this object lives in (PoincareMap | None).
- class pyna.topo._base.Orbit[source]
Bases:
InvariantManifoldA periodic orbit of a discrete map: a finite set of phase-space points.
Mathematically, an m-periodic orbit is a set
{x₁, …, xₘ}satisfyingP(xₖ) = xₖ₊₁(indices mod m) andP^m(xₖ) = xₖfor the map P.An
Orbitis fundamentally different from aTrajectory:Trajectory— solution of a continuous ODE (a curve, dim=1)Orbit— fixed-point set of a discrete map (finite points, dim=0)
Concrete subtype#
PeriodicOrbit— StoresmFixedPointobjects, one per map iteration.
intrinsic_dim = 0(a finite set of isolated points in the section).
- class pyna.topo._base.SectionCuttable(*args, **kwargs)[source]
Bases:
ProtocolProtocol / mixin marking objects that can be sliced by a Poincaré section.
Any class that implements
section_cut(section) -> listsatisfies this protocol. It is deliberately not a subclass of InvariantSet so that it can be mixed in freely (e.g.class Tube(InvariantSet, SectionCuttable)).Usage:
if isinstance(obj, SectionCuttable): pts = obj.section_cut(my_section)
- class pyna.topo._base.Trajectory[source]
Bases:
GeometricObjectA finite sampled trajectory: a 1-D curve representation in phase space.
A
Trajectoryis numerical geometry, not a proof of invariance. It may be an open finite-time integration, an approximate trace, or a sampled representation of a genuinely invariant object. Established periodic flow orbits should be represented byCycle, which may own aTrajectoryas one representation.
pyna.topo.core — Generic finite-dimensional topology objects.
This module is the canonical domain-agnostic core. Nothing here assumes toroidal geometry or uses hard-coded coordinate names such as R/Z/phi.
Class hierarchy#
- SectionPoint(InvariantManifold, intrinsic_dim=0)
→ toroidal.FixedPoint
- PeriodicOrbit(InvariantManifold, intrinsic_dim=0)
→ toroidal.PeriodicOrbit
- Cycle(InvariantManifold, intrinsic_dim=1)
→ toroidal.Cycle
- Island(InvariantSet)
→ toroidal.Island
- IslandChain(InvariantSet)
→ toroidal.IslandChain
- Tube(InvariantSet)
→ toroidal.Tube
- TubeChain(InvariantSet)
→ toroidal.TubeChain
- class pyna.topo.core.Cycle(trajectory=None, period_value=None, return_map_orbit=None, metadata=<factory>)[source]
Bases:
InvariantManifoldPeriodic orbit of a continuous-time flow in arbitrary finite dimension.
This is the generic root for toroidal.Cycle. The
trajectoryfield is optional — toroidal subclasses may represent the cycle via asectionsdict instead.- diagnostics()[source]
Return a structured diagnostic / debug dict.
The default implementation returns a minimal dict with just the class name. Subclasses are encouraged to override and add domain-specific information.
- property intrinsic_dim: int[source]
Intrinsic dimension of the invariant manifold (None if unknown).
- return_map_orbit: PeriodicOrbit | None = None[source]
- section_cut(section=None)[source]
Return the intersection of this invariant with a Poincaré section.
Raises
NotImplementedErrorby default. Subclasses that support sectioning should override (and ideally also derive fromSectionCuttable).- Return type:
- section_points(section_value=None, section_label=None, tol=1e-09)[source]
- Return type:
- trajectory: Trajectory | None = None[source]
- class pyna.topo.core.Island(O_orbit=<factory>, X_orbits=<factory>, child_chains=<factory>, parent_chain=None, label=None, metadata=<factory>)[source]
Bases:
InvariantManifoldOne island of a discrete Poincaré-map resonance structure.
This is the generic root for toroidal.Island.
Fields#
- O_orbitPeriodicOrbit
Elliptic periodic orbit at the island centre.
- X_orbitslist of PeriodicOrbit
Hyperbolic periodic orbit(s) bounding the island (may be empty).
- child_chainslist of IslandChain
Sub-chains nested inside this island.
- parent_chainIslandChain or None
The IslandChain that contains this island.
- O_orbit: PeriodicOrbit[source]
- property O_point: SectionPoint | None[source]
- X_orbits: List[PeriodicOrbit][source]
- property X_points: List[SectionPoint][source]
- child_chains: List[IslandChain][source]
- diagnostics()[source]
Return a structured diagnostic / debug dict.
The default implementation returns a minimal dict with just the class name. Subclasses are encouraged to override and add domain-specific information.
- property intrinsic_dim: int[source]
Intrinsic dimension of the invariant manifold (None if unknown).
- parent_chain: IslandChain | None = None[source]
- section_cut(section=None)[source]
Return the intersection of this invariant with a Poincaré section.
Raises
NotImplementedErrorby default. Subclasses that support sectioning should override (and ideally also derive fromSectionCuttable).- Return type:
- class pyna.topo.core.IslandChain(islands=<factory>, period=None, label=None, parent_island=None, metadata=<factory>)[source]
Bases:
InvariantManifoldDiscrete island chain obtained on a section of a flow or map.
This is the generic root for toroidal.IslandChain.
- property O_points: List[SectionPoint][source]
- property X_points: List[SectionPoint][source]
- diagnostics()[source]
Return a structured diagnostic / debug dict.
The default implementation returns a minimal dict with just the class name. Subclasses are encouraged to override and add domain-specific information.
- property intrinsic_dim: int[source]
Intrinsic dimension of the invariant manifold (None if unknown).
- section_cut(section=None)[source]
Return the intersection of this invariant with a Poincaré section.
Raises
NotImplementedErrorby default. Subclasses that support sectioning should override (and ideally also derive fromSectionCuttable).- Return type:
- class pyna.topo.core.LinearStabilityData(jacobian, eigenvalues=None, metadata=<factory>)[source]
Bases:
GeometricObjectLinearised stability payload for a periodic object or section point.
- class pyna.topo.core.Orbit(states, steps=None, coordinate_names=None, metadata=<factory>)[source]
Bases:
GeometricObjectFinite sampled orbit of a discrete-time map.
- class pyna.topo.core.PeriodicOrbit(points=<factory>, period=None, stability_data=None, representative_state=None, orbit_trace=None, metadata=<factory>)[source]
Bases:
InvariantManifoldPeriodic orbit of a discrete map in arbitrary finite dimension.
This is the generic root for toroidal.PeriodicOrbit.
- diagnostics()[source]
Return a structured diagnostic / debug dict.
The default implementation returns a minimal dict with just the class name. Subclasses are encouraged to override and add domain-specific information.
- property intrinsic_dim: int[source]
Intrinsic dimension of the invariant manifold (None if unknown).
- points: List[SectionPoint][source]
- section_cut(section=None)[source]
Return the intersection of this invariant with a Poincaré section.
Raises
NotImplementedErrorby default. Subclasses that support sectioning should override (and ideally also derive fromSectionCuttable).- Return type:
- stability_data: LinearStabilityData | None = None[source]
- class pyna.topo.core.SectionPoint(state=None, section_value=None, section_label=None, stability_data=None, metadata=<factory>)[source]
Bases:
InvariantManifoldA point on a section of a finite-dimensional dynamical system.
This is the generic root for toroidal.FixedPoint. The
statefield may be None when constructed by a subclass that fills it in__post_init__(e.g. FixedPoint from R,Z).- diagnostics()[source]
Return a structured diagnostic / debug dict.
The default implementation returns a minimal dict with just the class name. Subclasses are encouraged to override and add domain-specific information.
- stability_data: LinearStabilityData | None = None[source]
- class pyna.topo.core.Stability(*values)[source]
Bases:
Enum- ELLIPTIC = 1[source]
- HYPERBOLIC = 2[source]
- PARABOLIC = 3[source]
- UNKNOWN = 4[source]
- class pyna.topo.core.Trajectory(states, times, time_name='t', coordinate_names=None, metadata=<factory>)[source]
Bases:
GeometricObjectFinite sampled trajectory of a continuous-time system.
- section_cut(section, *, tol=1e-10)[source]
- Return type:
- class pyna.topo.core.Tube(O_cycle, X_cycles=<factory>, label=None, debug_info=<factory>)[source]
Bases:
InvariantManifoldA resonance zone surrounding an elliptic periodic orbit of a continuous flow.
A Tube is the continuous-time analogue of an Island: it consists of the nested family of invariant tori around an elliptic cycle (O_cycle), bounded by hyperbolic cycles (X_cycles).
For MCF field lines, this is a magnetic island tube. For Hamiltonian flows, it is a resonance zone bounded by separatrices.
This is the generic root for toroidal.Tube.
Fields#
- O_cycleCycle
The elliptic periodic orbit at the core.
- X_cycleslist of Cycle
Hyperbolic periodic orbit(s) bounding the resonance zone.
label : str or None
- diagnostics()[source]
Return a structured diagnostic / debug dict.
The default implementation returns a minimal dict with just the class name. Subclasses are encouraged to override and add domain-specific information.
- property intrinsic_dim: int[source]
Intrinsic dimension of the invariant manifold (None if unknown).
- section_cut(section)[source]
Cut this Tube with a section → IslandChain.
- Return type:
- class pyna.topo.core.TubeChain(tubes=<factory>, label=None, debug_info=<factory>)[source]
Bases:
InvariantManifoldAll Tubes sharing the same resonance in a continuous flow.
This is the generic root for toroidal.TubeChain.
- diagnostics()[source]
Return a structured diagnostic / debug dict.
The default implementation returns a minimal dict with just the class name. Subclasses are encouraged to override and add domain-specific information.
- property intrinsic_dim: int[source]
Intrinsic dimension of the invariant manifold (None if unknown).
- section_cut(section)[source]
Cut all Tubes with a section → merged IslandChain.
- Return type: