Hamiltonian Services

Services for Hamiltonian objects in the Hiten framework.

Hamiltonian Persistence Service

_HamiltonianPersistenceService()

Handle persistence for Hamiltonian objects.

class hiten.algorithms.types.services.hamiltonian._HamiltonianPersistenceService[source]

Bases: _PersistenceServiceBase

Encapsulate save/load helpers for Hamiltonian objects.

Parameters:
  • save_fn (Callable[..., Any]) – The function to save the object.

  • load_fn (Callable[..., Any]) – The function to load the object.

Lie Generating Function Persistence Service

_LieGeneratingFunctionPersistenceService()

Handle persistence for Lie generating function objects.

class hiten.algorithms.types.services.hamiltonian._LieGeneratingFunctionPersistenceService[source]

Bases: _PersistenceServiceBase

Encapsulate save/load helpers for LieGeneratingFunction objects.

Parameters:
  • save_fn (Callable[..., Any]) – The function to save the object.

  • load_fn (Callable[..., Any]) – The function to load the object.

Hamiltonian Dynamics Service

_HamiltonianDynamicsService()

Provide numerical operations for Hamiltonian computations.

class hiten.algorithms.types.services.hamiltonian._HamiltonianDynamicsService(domain_obj)[source]

Bases: _DynamicsServiceBase

Provide helper utilities for Hamiltonian construction.

Parameters:

domain_obj (Hamiltonian) – The domain object.

property registry: _PipelineService

Get the registry.

property ndof: int

Get the number of degrees of freedom.

property degree: int

Get the degree.

property name: str

Get the name.

property psi: ndarray

Get the combinatorial table.

property clmo: List[ndarray]

Get the coefficient-layout mapping objects.

property clmoH: List[ndarray]

Get the combinatorial table.

property encode_dict_list: List[dict]

Get the encode dictionary list.

property hamsys: _HamiltonianSystem

Get the Hamiltonian system.

property poly_H: List[ndarray]

Get the polynomial Hamiltonian.

property jac_H: List[List[ndarray]]

Get the Jacobian of the Hamiltonian.

evaluate(coords)[source]

Evaluate the Hamiltonian at the given coordinates.

Parameters:

coords (ndarray)

Return type:

float

init_tables(degree)[source]

Initialize the combinatorial table.

Parameters:

degree (int)

build_encode_dict(clmo)[source]

Build the encode dictionary.

build_hamsys(poly_H, degree, psi, clmo, encode_dict, ndof, name)[source]

Build the Hamiltonian system.

Parameters:
list_registered_forms()[source]

List the registered forms.

build_pipeline(point, degree, conversion)[source]

Build the Hamiltonian pipeline.

Parameters:
Return type:

HamiltonianPipeline

from_state(other, target_cls, **kwargs)[source]

Convert another Hamiltonian to the target class using shared conversion service.

Parameters:
  • other (Hamiltonian) – The other Hamiltonian.

  • target_cls (type[Hamiltonian]) – The target class.

  • **kwargs (dict) – The keyword arguments.

Returns:

The converted Hamiltonian.

Return type:

Hamiltonian

to_state(target_form, **kwargs)[source]

Convert this Hamiltonian to another form using shared conversion service.

Parameters:
  • target_form (Union[type[Hamiltonian], str]) – The target form.

  • **kwargs (dict) – The keyword arguments.

Returns:

The converted Hamiltonian.

Return type:

Hamiltonian

register_conversion(src, dst, converter, required_context, default_params)[source]

Register a conversion function in the shared conversion service.

Parameters:
  • src (str) – The source form.

  • dst (str) – The destination form.

  • converter (Callable) – The conversion function.

  • required_context (list) – The required context.

  • default_params (dict) – The default parameters.

Return type:

None

Lie Generating Function Dynamics Service

_LieGeneratingFunctionDynamicsService()

Provide helper utilities for Lie generating function construction.

class hiten.algorithms.types.services.hamiltonian._LieGeneratingFunctionDynamicsService(domain_obj)[source]

Bases: _DynamicsServiceBase

Provide helper utilities for Lie generating function construction.

Parameters:

domain_obj (LieGeneratingFunction)

property ndof: int

Get the number of degrees of freedom.

property degree: int

Get the degree.

property name: str

Get the name.

property psi: ndarray

Get the psi.

property clmo: List[ndarray]

Get the coefficient-layout mapping objects.

property encode_dict_list: List[dict]

Get the encode dictionary list.

property poly_G: List[ndarray]

Get the polynomial G.

property poly_elim: List[ndarray]

Get the polynomial elimination.

evaluate(coords)[source]

Evaluate the polynomial at the given coordinates.

Parameters:

coords (ndarray)

Return type:

float

init_tables(degree)[source]

Initialize the combinatorial table.

Parameters:

degree (int)

build_encode_dict(clmo)[source]

Build the encode dictionary.

Hamiltonian Conversion Service

_HamiltonianConversionService()

Handle conversion between different Hamiltonian forms.

class hiten.algorithms.types.services.hamiltonian._HamiltonianConversionService[source]

Bases: object

Maintain conversion registry and apply transformations.

Parameters:

registry (Dict[Tuple[str, str], Tuple[Callable, list, dict]]) – The registry.

items()[source]

Get the items.

Return type:

Iterable[Tuple[Tuple[str, str], Tuple[Callable, list, dict]]]

register(src, dst, converter, required_context, default_params)[source]

Register a conversion.

Parameters:
Return type:

None

get(src, dst)[source]

Get a conversion.

Parameters:
convert(ham, target_form, **kwargs)[source]

Convert a Hamiltonian to another form.

available_targets(src)[source]

Get the available targets.

Parameters:

src (str)

Return type:

Iterable[str]

all_forms()[source]

Get all the forms.

Return type:

Iterable[str]

Hamiltonian Pipeline Service

_HamiltonianPipelineService()

Manage Hamiltonian pipeline instances.

class hiten.algorithms.types.services.hamiltonian._HamiltonianPipelineService(conversion)[source]

Bases: object

Construct and cache HamiltonianPipeline instance

Parameters:

conversion (_HamiltonianConversionService) – The conversion service.

pipeline

The pipeline.

Type:

HamiltonianPipeline

get(point, degree)[source]

Get a pipeline.

Parameters:
Returns:

The pipeline.

Return type:

HamiltonianPipeline

set(point, degree)[source]

Set a pipeline.

Parameters:
Returns:

The pipeline.

Return type:

HamiltonianPipeline

clear()[source]

Clear the pipelines.

Return type:

None

clear_point(point)[source]

Clear the pipelines for a point.

Return type:

None

Pipeline Service

_PipelineService()

Registry for shared Hamiltonian services that don’t depend on specific instances.

class hiten.algorithms.types.services.hamiltonian._PipelineService[source]

Bases: object

Registry for shared Hamiltonian services that don’t depend on specific instances.

conversion

The conversion service.

Type:

_HamiltonianConversionService

pipeline

The pipeline service.

Type:

_HamiltonianPipelineService

property conversion: _HamiltonianConversionService

Get the conversion service.

property pipeline: _HamiltonianPipelineService

Get the pipeline service.

register_conversion(src, dst, converter, required_context, default_params)[source]

Register a conversion function in the local registry.

Parameters:
  • src (str) – The source form.

  • dst (str) – The destination form.

  • converter (Callable) – The conversion function.

  • required_context (list) – The required context.

  • default_params (dict) – The default parameters.

Return type:

None

Hamiltonian Services

_HamiltonianServices()

Encapsulate services for Hamiltonian objects.

class hiten.algorithms.types.services.hamiltonian._HamiltonianServices(domain_obj, dynamics, persistence, conversion, pipeline)[source]

Bases: _ServiceBundleBase

Encapsulate services for Hamiltonian.

Parameters:
dynamics

The dynamics service.

Type:

_HamiltonianDynamicsService

persistence

The persistence service.

Type:

_HamiltonianPersistenceService

conversion

The conversion service.

Type:

_HamiltonianConversionService

pipeline

The pipeline service.

Type:

_HamiltonianPipelineService

classmethod default(domain_obj)[source]

Create a default service bundle.

Parameters:

domain_obj (Hamiltonian) – The domain object.

Returns:

The service bundle.

Return type:

_HamiltonianServices

classmethod with_shared_dynamics(dynamics)[source]

Create a service bundle with a shared dynamics service.

Parameters:

dynamics (_HamiltonianDynamicsService) – The dynamics service.

Returns:

The service bundle.

Return type:

_HamiltonianServices

Lie Generating Function Services

_LieGeneratingFunctionServices()

Encapsulate services for Lie generating function objects.

class hiten.algorithms.types.services.hamiltonian._LieGeneratingFunctionServices(domain_obj, dynamics, persistence)[source]

Bases: _ServiceBundleBase

Encapsulate services for Lie generating function.

Parameters:
dynamics

The dynamics service.

Type:

_LieGeneratingFunctionDynamicsService

persistence

The persistence service.

Type:

_LieGeneratingFunctionPersistenceService

classmethod default(domain_obj)[source]

Create a default service bundle.

Parameters:

domain_obj (LieGeneratingFunction) – The domain object.

Returns:

The service bundle.

Return type:

_LieGeneratingFunctionServices

classmethod with_shared_dynamics(dynamics)[source]

Create a service bundle with a shared dynamics service.

Parameters:

dynamics (_LieGeneratingFunctionDynamicsService) – The dynamics service.

Returns:

The service bundle.

Return type:

_LieGeneratingFunctionServices