feat(python): Python Bindings

Python Bindings are working again
This commit is contained in:
2025-12-20 16:02:52 -05:00
parent d65c237b26
commit 11a596b75b
78 changed files with 4411 additions and 1110 deletions

View File

@@ -5,47 +5,113 @@ from __future__ import annotations
import collections.abc
import fourdst._phys.atomic
import gridfire._gridfire.engine
import gridfire._gridfire.engine.scratchpads
import gridfire._gridfire.type
import types
import typing
__all__: list[str] = ['CVODESolverStrategy', 'CVODETimestepContext', 'DynamicNetworkSolverStrategy', 'SolverContextBase']
class CVODESolverStrategy(DynamicNetworkSolverStrategy):
def __init__(self, engine: gridfire._gridfire.engine.DynamicEngine) -> None:
__all__: list[str] = ['GridSolver', 'GridSolverContext', 'MultiZoneDynamicNetworkSolver', 'PointSolver', 'PointSolverContext', 'PointSolverTimestepContext', 'SingleZoneDynamicNetworkSolver', 'SolverContextBase']
class GridSolver(MultiZoneDynamicNetworkSolver):
def __init__(self, engine: gridfire._gridfire.engine.DynamicEngine, solver: SingleZoneDynamicNetworkSolver) -> None:
"""
Initialize the CVODESolverStrategy object.
Initialize the GridSolver object.
"""
def evaluate(self, netIn: gridfire._gridfire.type.NetIn, display_trigger: bool = False) -> gridfire._gridfire.type.NetOut:
def evaluate(self, solver_ctx: SolverContextBase, netIns: collections.abc.Sequence[gridfire._gridfire.type.NetIn]) -> list[gridfire._gridfire.type.NetOut]:
"""
evaluate the dynamic engine using the dynamic engine class
"""
def get_absTol(self) -> float:
class GridSolverContext(SolverContextBase):
detailed_logging: bool
stdout_logging: bool
zone_completion_logging: bool
def __init__(self, ctx_template: gridfire._gridfire.engine.scratchpads.StateBlob) -> None:
...
@typing.overload
def clear_callback(self) -> None:
...
@typing.overload
def clear_callback(self, zone_idx: typing.SupportsInt) -> None:
...
def init(self) -> None:
...
def reset(self) -> None:
...
@typing.overload
def set_callback(self, callback: collections.abc.Callable[[...], None]) -> None:
...
@typing.overload
def set_callback(self, callback: collections.abc.Callable[[...], None], zone_idx: typing.SupportsInt) -> None:
...
class MultiZoneDynamicNetworkSolver:
def evaluate(self, solver_ctx: SolverContextBase, netIns: collections.abc.Sequence[gridfire._gridfire.type.NetIn]) -> list[gridfire._gridfire.type.NetOut]:
"""
Get the absolute tolerance for the CVODE solver.
evaluate the dynamic engine using the dynamic engine class for multiple zones (using openmp if available)
"""
def get_relTol(self) -> float:
class PointSolver(SingleZoneDynamicNetworkSolver):
def __init__(self, engine: gridfire._gridfire.engine.DynamicEngine) -> None:
"""
Get the relative tolerance for the CVODE solver.
Initialize the PointSolver object.
"""
def get_stdout_logging_enabled(self) -> bool:
def evaluate(self, solver_ctx: SolverContextBase, netIn: gridfire._gridfire.type.NetIn, display_trigger: bool = False, force_reinitialization: bool = False) -> gridfire._gridfire.type.NetOut:
"""
Check if solver logging to standard output is enabled.
evaluate the dynamic engine using the dynamic engine class
"""
def set_absTol(self, absTol: typing.SupportsFloat) -> None:
"""
Set the absolute tolerance for the CVODE solver.
"""
def set_callback(self, cb: collections.abc.Callable[[CVODETimestepContext], None]) -> None:
"""
Set a callback function which will run at the end of every successful timestep
"""
def set_relTol(self, relTol: typing.SupportsFloat) -> None:
"""
Set the relative tolerance for the CVODE solver.
"""
def set_stdout_logging_enabled(self, logging_enabled: bool) -> None:
"""
Enable logging to standard output.
"""
class CVODETimestepContext(SolverContextBase):
class PointSolverContext:
callback: collections.abc.Callable[[PointSolverTimestepContext], None] | None
detailed_logging: bool
stdout_logging: bool
def __init__(self, engine_ctx: gridfire._gridfire.engine.scratchpads.StateBlob) -> None:
...
def clear_context(self) -> None:
...
def has_context(self) -> bool:
...
def init(self) -> None:
...
def init_context(self) -> None:
...
def reset_all(self) -> None:
...
def reset_cvode(self) -> None:
...
def reset_user(self) -> None:
...
@property
def J(self) -> _generic_SUNMatrix:
...
@property
def LS(self) -> _generic_SUNLinearSolver:
...
@property
def Y(self) -> _generic_N_Vector:
...
@property
def YErr(self) -> _generic_N_Vector:
...
@property
def abs_tol(self) -> float:
...
@abs_tol.setter
def abs_tol(self, arg1: typing.SupportsFloat) -> None:
...
@property
def cvode_mem(self) -> types.CapsuleType:
...
@property
def engine_ctx(self) -> gridfire._gridfire.engine.scratchpads.StateBlob:
...
@property
def num_steps(self) -> int:
...
@property
def rel_tol(self) -> float:
...
@rel_tol.setter
def rel_tol(self, arg1: typing.SupportsFloat) -> None:
...
@property
def sun_ctx(self) -> SUNContext_:
...
class PointSolverTimestepContext:
@property
def T9(self) -> float:
...
@@ -77,16 +143,15 @@ class CVODETimestepContext(SolverContextBase):
def state(self) -> list[float]:
...
@property
def state_ctx(self) -> gridfire._gridfire.engine.scratchpads.StateBlob:
...
@property
def t(self) -> float:
...
class DynamicNetworkSolverStrategy:
def describe_callback_context(self) -> list[tuple[str, str]]:
class SingleZoneDynamicNetworkSolver:
def evaluate(self, solver_ctx: SolverContextBase, netIn: gridfire._gridfire.type.NetIn) -> gridfire._gridfire.type.NetOut:
"""
Get a structure representing what data is in the callback context in a human readable format
"""
def evaluate(self, netIn: gridfire._gridfire.type.NetIn) -> gridfire._gridfire.type.NetOut:
"""
evaluate the dynamic engine using the dynamic engine class
evaluate the dynamic engine using the dynamic engine class for a single zone
"""
class SolverContextBase:
pass