The ep_material_factory.py module#
Summary#
Create default active EP material for myocardium tissue. |
|
Create default passive EP material for non-excitable tissue. |
|
Create default active beam EP material for conduction system elements. |
|
Assign default EP materials to all model components without existing materials. |
Description#
Factory functions for creating electrophysiology material models.
This module provides factory functions for creating EP material instances with appropriate default parameters for different cardiac tissue types and solver configurations. The factory functions handle solver-specific parameter selection, unit conversion from Quantity objects, and proper material instantiation using the existing Pydantic-based material models.
The module supports three main EP material types: - Active materials for excitable myocardium with cell models - Passive materials for non-excitable cardiac tissue - ActiveBeam materials for specialized conduction system elements
All factory functions are optimized for PyAnsys Heart simulation workflows and follow cardiac electrophysiology modeling best practices.
Examples#
>>> from ansys.health.heart.settings.material.ep_material import EPSolverType
>>> from ansys.health.heart.settings.material.ep_material_factory import (
... get_default_myocardium_material,
... get_default_passive_material,
... assign_default_ep_materials,
... )
>>> import ansys.health.heart.models as models
>>> # Create materials for different solver types
>>> active_mono = get_default_myocardium_material(EPSolverType.MONODOMAIN)
>>> active_eik = get_default_myocardium_material("Eikonal")
>>> passive = get_default_passive_material(EPSolverType.MONODOMAIN)
>>> # Assign materials to a complete model
>>> model = models.BiVentricle()
>>> assign_default_ep_materials(model, EPSolverType.MONODOMAIN)
Module detail#
- ep_material_factory.get_default_myocardium_material(ep_solver_type: ansys.health.heart.settings.material.ep_material.EPSolverType | Literal['Monodomain', 'Eikonal', 'ReactionEikonal']) ansys.health.heart.settings.material.ep_material.Active#
Create default active EP material for myocardium tissue.
This function creates an Active EP material instance with solver-specific default parameters appropriate for myocardium tissue simulation. The material includes cell model properties and conductivity values optimized for the specified EP solver type.
- Parameters:
- ep_solver_type
EPSolverTypeorLiteral[“Monodomain”, “Eikonal”, “ReactionEikonal”] The electrophysiology solver type to configure material for. Determines conductivity units and parameter values.
- ep_solver_type
- Returns:
ActiveConfigured active EP material with solver-specific defaults and associated Tentusscher cell model.
- Raises:
ValueErrorIf ep_solver_type is not one of the supported solver types.
RuntimeErrorIf material creation or parameter processing fails.
Examples
>>> from ansys.health.heart.settings.material.ep_material import EPSolverType >>> material = get_default_myocardium_material(EPSolverType.MONODOMAIN) >>> print(material.sigma_fiber) 0.5 >>> print(type(material.cell_model))
>>> # Using string literal >>> material_eik = get_default_myocardium_material("Eikonal") >>> print(material_eik.sigma_fiber) 0.7
- ep_material_factory.get_default_passive_material(ep_solver_type: ansys.health.heart.settings.material.ep_material.EPSolverType | Literal['Monodomain', 'Eikonal', 'ReactionEikonal']) ansys.health.heart.settings.material.ep_material.Passive#
Create default passive EP material for non-excitable tissue.
This function creates a Passive EP material instance with solver-specific default parameters appropriate for passive cardiac tissue. Passive materials do not have cell models or sheet conductivities, representing tissue that does not actively generate electrical activity.
- Parameters:
- ep_solver_type
EPSolverTypeorLiteral[“Monodomain”, “Eikonal”, “ReactionEikonal”] The electrophysiology solver type to configure material for. Determines conductivity units and parameter values.
- ep_solver_type
- Returns:
PassiveConfigured passive EP material with solver-specific defaults. Sheet conductivities are automatically excluded for passive materials.
- Raises:
ValueErrorIf ep_solver_type is not one of the supported solver types.
RuntimeErrorIf material creation or parameter processing fails.
Examples
>>> from ansys.health.heart.settings.material.ep_material import EPSolverType >>> material = get_default_passive_material(EPSolverType.EIKONAL) >>> print(material.sigma_fiber) 0.7 >>> print(hasattr(material, "cell_model")) False
>>> # Using string literal >>> material_mono = get_default_passive_material("Monodomain") >>> print(material_mono.sigma_fiber) 0.5
- ep_material_factory.get_default_conduction_system_material(ep_solver_type: ansys.health.heart.settings.material.ep_material.EPSolverType | Literal['Monodomain', 'Eikonal', 'ReactionEikonal'] = EPSolverType.MONODOMAIN) ansys.health.heart.settings.material.ep_material.ActiveBeam#
Create default active beam EP material for conduction system elements.
This function creates an ActiveBeam EP material instance optimized for specialized conduction system components such as Purkinje fibers, bundle branches, and AV node pathways. These materials are isotropic (fiber-only conduction) and have enhanced conductivity properties.
- Parameters:
- ep_solver_type
EPSolverTypeorLiteral[“Monodomain”, “Eikonal”, “ReactionEikonal”], default:EPSolverType.MONODOMAIN The electrophysiology solver type to configure material for. Determines conductivity units and parameter values for beam elements.
- ep_solver_type
- Returns:
ActiveBeamConfigured active beam EP material with enhanced conduction properties. Sheet conductivities are automatically set to None for isotropic behavior.
- Raises:
ValueErrorIf ep_solver_type is not one of the supported solver types.
RuntimeErrorIf material creation or parameter processing fails.
Examples
>>> from ansys.health.heart.settings.material.ep_material import EPSolverType >>> material = get_default_conduction_system_material(EPSolverType.MONODOMAIN) >>> print(material.sigma_fiber) 1.0 >>> print(material.sigma_sheet is None) True
>>> # Default solver type >>> material_default = get_default_conduction_system_material() >>> print(material_default.sigma_fiber) 1.0
>>> # Using string literal for Eikonal >>> material_eik = get_default_conduction_system_material("Eikonal") >>> print(material_eik.sigma_fiber) 1.0
- ep_material_factory.assign_default_ep_materials(model: ansys.health.heart.models.HeartModel | ansys.health.heart.models.FourChamber | ansys.health.heart.models.FullHeart | ansys.health.heart.models.BiVentricle | ansys.health.heart.models.LeftVentricle, solver_type: ansys.health.heart.settings.material.ep_material.EPSolverType | Literal['Monodomain', 'Eikonal', 'ReactionEikonal'] = EPSolverType.MONODOMAIN) None#
Assign default EP materials to all model components without existing materials.
This function performs in-place assignment of appropriate EP materials to all parts and conduction paths in a heart model that do not already have valid EP materials assigned. The material selection follows cardiac physiology principles and is optimized for the specified solver type.
- Parameters:
- model
HeartModelorFourChamberorFullHeartorBiVentricleorLeftVentricle Heart model instance to assign materials to. The model is modified in-place with new material assignments.
- solver_type
EPSolverTypeorLiteral[“Monodomain”, “Eikonal”, “ReactionEikonal”], default:EPSolverType.MONODOMAIN Electrophysiology solver type for material parameter selection. Determines conductivity units and optimization.
- model
- Raises:
ValueErrorIf solver_type is not one of the supported EP solver types.
RuntimeErrorIf material assignment fails for any model component.
Notes
Material Assignment Rules:
Active parts (contractile myocardium): Receive Active materials with Tentusscher cell models and solver-specific conductivities
Passive parts (non-contractile tissue): Receive Passive materials without cell models or sheet conductivities
Conduction paths (Purkinje system, bundles): Receive ActiveBeam materials with enhanced fiber conductivity
Arteries and veins: Receive Insulator materials with zero conductivity
Solver-Specific Optimizations:
Monodomain: Uses conductivity values in mS/mm units
Eikonal/ReactionEikonal: Uses velocity values in mm/ms units
The function logs all material assignments and provides a summary of the assignment process. Parts with existing valid EP materials are skipped.
Examples
>>> import ansys.health.heart.models as models >>> from ansys.health.heart.settings.material.ep_material import EPSolverType >>> >>> # Create model and assign materials >>> model = models.BiVentricle() >>> assign_default_ep_materials(model, EPSolverType.MONODOMAIN) >>> >>> # Verify all parts have materials >>> all_parts_assigned = all(part.ep_material is not None for part in model.parts) >>> print(all_parts_assigned) True >>> >>> # Check material types >>> active_parts = [p for p in model.parts if p.active] >>> passive_parts = [ ... p for p in model.parts ... if not p.active and not isinstance(p, models.Artery) ... ] >>> arteries = [p for p in model.parts if isinstance(p, models.Artery)] >>> >>> print(f"Active parts: {len(active_parts)}") >>> print(f"Passive parts: {len(passive_parts)}") >>> print(f"Insulator parts: {len(arteries)}")