| from __future__ import annotations |
|
|
| from typing import Callable |
|
|
| from physix.systems.base import PhysicalSystem, SystemTier |
| from physix.systems.tier1 import FreeFall, FreeFallWithDrag, SimplePendulum |
| from physix.systems.tier2 import DampedPendulum, DampedSpring, SpringMass |
| from physix.systems.tier3 import ChargedInBField, ProjectileWithDrag |
|
|
|
|
| SystemFactory = Callable[[], PhysicalSystem] |
|
|
|
|
| SYSTEM_REGISTRY: dict[str, SystemFactory] = { |
| "free_fall": FreeFall, |
| "free_fall_drag": FreeFallWithDrag, |
| "simple_pendulum": SimplePendulum, |
| "damped_pendulum": DampedPendulum, |
| "spring_mass": SpringMass, |
| "damped_spring": DampedSpring, |
| "projectile_drag": ProjectileWithDrag, |
| "charged_b_field": ChargedInBField, |
| } |
|
|
| SUPPORTED_SYSTEMS: tuple[str, ...] = ( |
| "free_fall", |
| "damped_spring", |
| "simple_pendulum", |
| ) |
|
|
|
|
| def get_system(system_id: str) -> PhysicalSystem: |
| if system_id not in SYSTEM_REGISTRY: |
| valid = ", ".join(sorted(SYSTEM_REGISTRY)) |
| raise KeyError(f"Unknown system_id={system_id!r}. Valid: {valid}") |
| return SYSTEM_REGISTRY[system_id]() |
|
|
|
|
| def list_systems() -> list[str]: |
| return list(SYSTEM_REGISTRY) |
|
|
|
|
| def list_systems_by_tier(tier: SystemTier) -> list[str]: |
| return [sid for sid, cls in SYSTEM_REGISTRY.items() if cls().tier == tier] |
|
|
|
|
| def list_supported_systems() -> list[str]: |
| return [sid for sid in SUPPORTED_SYSTEMS if sid in SYSTEM_REGISTRY] |
|
|