Spaces:
Sleeping
Sleeping
Download src/models.py from Sierpinksi-Project/NGF_on_Fractale: direct link, hf CLI and curl.
- Browser
- Download file 4.8 kB
-
https://huggingface.co/spaces/Sierpinksi-Project/NGF_on_Fractale/resolve/main/src/models.py
- Command line
-
hf download hf://spaces/Sierpinksi-Project/NGF_on_Fractale/src/models.py
-
curl -L -o models.py https://huggingface.co/spaces/Sierpinksi-Project/NGF_on_Fractale/resolve/main/src/models.py
4.8 kB
| from __future__ import annotations | |
| from dataclasses import dataclass, field | |
| from typing import Any, Dict, List, Optional | |
| import numpy as np | |
| import scipy.sparse as sp | |
| class BoundaryInfo: | |
| """Information über eine bestimmte Randkomponente eines Graphen.""" | |
| node_ids: np.ndarray # 1D-Array von Knoten-IDs (int64) | |
| kind: str # z.B. "outer", "inner", "interface", "infinity" | |
| description: str = "" | |
| class GraphGeometry: | |
| """Geometrische Zusatzinformationen für einen Graphen.""" | |
| coords: Optional[np.ndarray] = None # Shape (N, d) | |
| edge_lengths: Optional[np.ndarray] = None # Shape (E,) | |
| metric: Optional[str] = None # z.B. "euclidean", "hyperbolic" | |
| class IdealGraph: | |
| """IDEAL-Graph inklusive Randinformationen und Geometrie.""" | |
| adjacency: sp.csr_matrix | |
| boundary_infos: List[BoundaryInfo] | |
| geometry: GraphGeometry | |
| metadata: Dict[str, Any] | |
| class CStarAlgebraSpec: | |
| """ | |
| Abstrakte Spezifikation einer C*-Algebra. | |
| generators: Liste von Objekten (z.B. Dicts) mit Minimalinfos zu den Generatoren. | |
| relations: Liste von Relationen als Strings (symbolisch). | |
| representation: Optionale konkrete Darstellung, z.B. Operator-Matrizen (hier Platzhalter). | |
| """ | |
| generators: List[Dict[str, Any]] | |
| relations: List[str] | |
| representation: Optional[Dict[str, Any]] = None | |
| metadata: Dict[str, Any] = field(default_factory=dict) | |
| def __post_init__(self) -> None: | |
| """Initialisiere eine C*-Dynamik-Metadatenstruktur, falls sinnvoll. | |
| Die App legt hier nur symbolische Metadaten zu C*-dynamischen Systemen fest; | |
| es werden keine kontinuierlichen Automorphismengruppen numerisch ausgewertet. | |
| """ | |
| alg_type = self.metadata.get("algebra_type") | |
| # Graph-basierte C*-Algebren: kanonische Zeitentwicklung über einen (symbolischen) | |
| # inneren Generator H, der mit dem Laplace-Operator bzw. der Dirichlet-Form | |
| # identifiziert wird (Fallback: Adjazenzoperator). | |
| if "dynamics" not in self.metadata: | |
| if alg_type == "graph_Cstar": | |
| underlying = self.metadata.get("underlying_graph_family") | |
| ideal_object = self.metadata.get("ideal_object") | |
| self.metadata["dynamics"] = { | |
| "type": "one_parameter_automorphism_group", | |
| "label": "canonical_graph_time_evolution", | |
| "implementation": "inner_derivation", | |
| "symbolic_generator": "δ(A) = i[H, A]", | |
| "generator": { | |
| "preferred_operator": "dirichlet_form", | |
| "fallback_operator": "adjacency", | |
| "role": "graph_laplacian_as_H", | |
| "status": "symbolic_reference", | |
| }, | |
| "domain": { | |
| "underlying_graph_family": underlying, | |
| "ideal_object": ideal_object, | |
| }, | |
| } | |
| elif alg_type == "CAR": | |
| self.metadata["dynamics"] = { | |
| "type": "one_parameter_automorphism_group", | |
| "label": "canonical_gauge_action", | |
| "implementation": "pointwise_automorphisms", | |
| "gauge_group": "U(1)", | |
| "symbolic_generator": "δ(c_j) = i c_j, δ(c_j^*) = -i c_j^*", | |
| "status": "symbolic_reference", | |
| } | |
| elif alg_type == "UHF(2^∞)": | |
| self.metadata["dynamics"] = { | |
| "type": "one_parameter_automorphism_group", | |
| "label": "canonical_shift_action", | |
| "implementation": "outer_automorphisms", | |
| "symbolic_generator": "δ = limit of inner commutators on finite tensor factors", | |
| "status": "symbolic_placeholder", | |
| } | |
| elif alg_type == "AF_graph_limit": | |
| self.metadata["dynamics"] = { | |
| "type": "unspecified", | |
| "label": "no_canonical_dynamics_fixed", | |
| "status": "not_provided", | |
| } | |
| else: | |
| # Fallback: nur Minimalangabe ohne inhaltliche Festlegung | |
| self.metadata["dynamics"] = { | |
| "type": "one_parameter_automorphism_group", | |
| "symbolic_generator": "δ", | |
| } | |
| class SubstratePackage: | |
| """Gesamtpaket eines IDEAL-Substrats, wie es exportiert werden soll.""" | |
| graph: Optional[IdealGraph] = None | |
| cstar: Optional[CStarAlgebraSpec] = None | |
| additional_structures: Dict[str, Any] = field(default_factory=dict) | |
| metadata: Dict[str, Any] = field(default_factory=dict) |