HeartModel#

class ansys.health.heart.models.HeartModel(working_directory: pathlib.Path | str = None)#

Parent class for heart models.

Overview#

assign_conduction_paths

Assign conduction paths to the model.

create_part_by_ids

Create a part by element IDs.

load_input

Load an input model.

mesh_volume

Remesh the input model and fill the volume.

get_part

Get a specific part based on a part name.

add_part

Dynamically add a part as an attribute to the object.

remove_part

Remove a part with a specific name from the model.

summary

Get summary information of the model as a dictionary.

plot_mesh

Plot the volume mesh of the heart model.

plot_part

Plot a part in the mesh.

plot_fibers

Plot the mesh and fibers as streamlines.

plot_surfaces

Plot all surfaces in the model.

plot_purkinje

Plot the mesh and Purkinje network.

save_model

Save the model and necessary information to reconstruct.

load_model_from_mesh

Load a model from an existing VTU file and part information dictionary.

update

Update the model and add required features.

get_apex_node_set

Get a nodeset around the apex point.

create_stiff_ventricle_base

Use universal coordinates to generate a stiff base region.

create_atrial_stiff_ring

Create a part for solids close to the atrial caps.

parts

List of parts.

part_names

List of part names.

part_ids

List of used part IDs.

surfaces

List of all defined surfaces.

surface_names

List of all defined surface names.

surface_ids

List of all defined surface IDs.

cavities

List of all cavities in the model.

part_name_to_part_id

Dictionary that maps the part name to the part ID.

part_id_to_part_name

Dictionary that maps the part ID to the part name.

surface_name_to_surface_id

Dictionary that maps the surface name to the surface ID.

surface_id_to_surface_name

Dictionary that maps the surface ID to the surface name.

l4cv_axis

l4cv axis.

l2cv_axis

l2cv axis.

short_axis

l2cv axis.

cap_centroids

List of cap centroids.

conduction_paths

List of conduction paths.

conduction_mesh

Conduction mesh.

workdir

Working directory.

mesh

Computational mesh.

fluid_mesh

Generated fluid mesh.

electrodes

Electrodes positions for ECG computing.

__str__

Represent self as string.

Import detail#

from ansys.health.heart.models import HeartModel

Property detail#

property HeartModel.parts: List[ansys.health.heart.objects.Part]#

List of parts.

property HeartModel.part_names: List[str]#

List of part names.

property HeartModel.part_ids: List[int]#

List of used part IDs.

property HeartModel.surfaces: List[ansys.health.heart.objects.SurfaceMesh]#

List of all defined surfaces.

property HeartModel.surface_names: List[str]#

List of all defined surface names.

property HeartModel.surface_ids: List[str]#

List of all defined surface IDs.

property HeartModel.cavities: List[ansys.health.heart.objects.Cavity]#

List of all cavities in the model.

property HeartModel.part_name_to_part_id: dict#

Dictionary that maps the part name to the part ID.

property HeartModel.part_id_to_part_name: dict#

Dictionary that maps the part ID to the part name.

property HeartModel.surface_name_to_surface_id: dict#

Dictionary that maps the surface name to the surface ID.

property HeartModel.surface_id_to_surface_name: dict#

Dictionary that maps the surface ID to the surface name.

property HeartModel.l4cv_axis: dict#

l4cv axis.

property HeartModel.l2cv_axis: dict#

l2cv axis.

property HeartModel.short_axis: dict#

l2cv axis.

property HeartModel.cap_centroids#

List of cap centroids.

property HeartModel.conduction_paths#

List of conduction paths.

property HeartModel.conduction_mesh#

Conduction mesh.

Attribute detail#

HeartModel.workdir#

Working directory.

HeartModel.mesh#

Computational mesh.

HeartModel.fluid_mesh#

Generated fluid mesh.

HeartModel.electrodes: List[ansys.health.heart.objects.Point] = []#

Electrodes positions for ECG computing.

Method detail#

HeartModel.assign_conduction_paths(paths: ansys.health.heart.pre.conduction_path.ConductionPath | list[ansys.health.heart.pre.conduction_path.ConductionPath])#

Assign conduction paths to the model.

Parameters:
beamsConductionBeams | list[ConductionBeams]

List of conduction beams.

Notes

If conduction paths are already defined, they are removed.

HeartModel.__str__()#

Represent self as string.

HeartModel.create_part_by_ids(eids: List[int], name: str) None | ansys.health.heart.objects.Part#

Create a part by element IDs.

Parameters:
eidsList[int]

List of element IDs.

namestr

Part name.

Returns:
Union[None, Part]

Part if successful.

HeartModel.load_input(input_vtp: pyvista.PolyData, part_definitions: dict, scalar: str)#

Load an input model.

Parameters:
input_vtppv.PolyData

Input surface mesh represented by a VTK PolyData object.

part_definitionsdict

Part definitions of the input model. Each part is enclosed by N number of boundaries.

scalarstr

Scalar used to identify boundaries.

HeartModel.mesh_volume(use_wrapper: bool = False, overwrite_existing_mesh: bool = True, global_mesh_size: float = 1.5, path_to_fluent_mesh: str = None, mesh_size_per_part: dict = None, _global_wrap_size: float = 1.5, _wrap_size_per_part: dict = None) ansys.health.heart.objects.Mesh#

Remesh the input model and fill the volume.

Parameters:
use_wrapperbool, default: False

Whether to use the non-manifold mesher.

overwrite_existing_meshbool, default: True

Whether to overwrite the existing MSH.H5 mesh.

global_mesh_sizefloat, default: 1.5

Global mesh size for the generated mesh.

path_to_fluent_meshstr, default: None

Path to the generated Fluent MSH.H5 mesh.

mesh_size_per_partdict, default: None

Dictionary specifying the target mesh size for each part.

_global_wrap_sizefloat, default: 1.5

Global size for setting up the size-field for the shrink-wrap algorithm.

_wrap_size_per_partdict, default: None

Per part size for setting up the size-field for the shrink-wrap algorithm.

Notes

When the input surfaces are non-manifold, the wrapper tries to reconstruct the surface and parts. Inevitably this leads to reconstruction errors. Nevertheless, in many instances, this approach is more robust than meshing from a manifold surface. Moreover, any clear interface between parts is potentially lost.

When the mesh_size_per_part attribute is incomplete, remaining part sizes default to the global mesh size. This is an experimental setting. Any wrap sizes given as input arguments are ignored when the wrapper is not used.

Examples

>>> from ansys.health.heart.models import HeartModel
>>> model = HeartModel()
>>> model.load_input(geom, part_definitions, scalar)
>>> # mesh the volume with a global size of 1.5 and size of 1 for the left ventricle.
>>> model.mesh_volume(
...     use_wrapper=True,
...     global_mesh_size=1.5,
...     path_to_fluent_mesh="simulation-mesh.msh.h5",
...     mesh_size_per_part={"Left ventricle": 1},
... )
HeartModel.get_part(name: str, by_substring: bool = False) ansys.health.heart.objects.Part | None#

Get a specific part based on a part name.

HeartModel.add_part(part_name: str) None#

Dynamically add a part as an attribute to the object.

HeartModel.remove_part(part_name: str) None#

Remove a part with a specific name from the model.

HeartModel.summary() dict#

Get summary information of the model as a dictionary.

HeartModel.plot_mesh(show_edges: bool = True, color_by: str = '_volume-id')#

Plot the volume mesh of the heart model.

Parameters:
show_edgesbool, default: True

Whether to plot the edges.

color_bystr, default: '_volume-id'

Color by cell/point data.

Examples

>>> import ansys.health.heart.models as models
>>> model = models.HeartModel.load_model("heart_model.pickle")
>>> model.plot_mesh(show_edges=True)
HeartModel.plot_part(part: ansys.health.heart.objects.Part)#

Plot a part in the mesh.

Parameters:
partPart

Part to highlight in the mesh.

Examples

>>> import ansys.health.heart.models as models
>>> model = models.HeartModel.load_model("my_model.pickle")
>>> model.part(model.left_ventricle)
HeartModel.plot_fibers(n_seed_points: int = 1000)#

Plot the mesh and fibers as streamlines.

Parameters:
plot_raw_meshbool, default: False

Whether to plot the streamlines on the raw mesh.

n_seed_pointsint, default: 1000

Number of seed points. While the default is 1000, using 5000 is recommended.

Examples

>>> import ansys.health.heart.models as models
>>> model = models.HeartModel.load_model("my_model.pickle")
>>> model.plot_fibers(n_seed_points=5000)
HeartModel.plot_surfaces(show_edges: bool = True)#

Plot all surfaces in the model.

Examples

Import modules and load model.

>>> import ansys.health.heart.models as models
>>> model = models.HeartModel.load_model("my_model.pickle")

Plot the model.

>>> model.plot(show_edges=True)
HeartModel.plot_purkinje()#

Plot the mesh and Purkinje network.

HeartModel.save_model(filename: str)#

Save the model and necessary information to reconstruct.

Parameters:
filenamestr

Path to the model.

Notes

The mesh of the heart model is saved as a VTU file. An additional partinfo.json file is written to reconstruct the heart model from the VTU file.

Examples

>>> model.save_model("my-heart-model.vtu")
HeartModel.load_model_from_mesh(filename_mesh: str, filename_part_info: str)#

Load a model from an existing VTU file and part information dictionary.

Parameters:
filename_meshstr

Path to the VTU file containing the mesh.

filename_part_infostr

Path to the JSON file that contains the part information for reconstructing the model.

Examples

>>> from ansys.health.heart.models import FullHeart
>>> model: FullHeart = FullHeart()
>>> model.load_model_from_mesh("mesh.vtu", "mesh.partinfo.json")
HeartModel.update()#

Update the model and add required features.

Notes

  • Synchronize input parts to model parts.

  • Extract septum elements from the left ventricle.

  • Assign elements to parts.

  • Assign surfaces to each part.

  • Validate parts and surfaces.

  • Assign cavities to parts.

  • Update cap types.

  • Validate cap names.

  • Extract apical points.

  • Compute heart axis.

  • Add placeholder data for fiber and sheet directions.

HeartModel.get_apex_node_set(part: Literal['left', 'right'] = 'left', option: Literal['endocardium', 'epicardium', 'myocardium'] = 'epicardium', radius: float = 3) numpy.ndarray#

Get a nodeset around the apex point.

Parameters:
partLiteral[“left”, “right”], default: “left”

On which part.

optionLiteral[“endocardium”, “epicardium”, “myocardium”], default: “epicardium”

On surface or in mesh.

radiusfloat, default: 3

Search in radius.

Returns:
np.ndarray

Apex nodeset

HeartModel.create_stiff_ventricle_base(threshold_left_ventricle: float = 0.9, threshold_right_ventricle: float = 0.95, stiff_material: ansys.health.heart.settings.material.material.MechanicalMaterialModel = Mat295(rho=0.001, iso=ISO(itype=1, beta=2, kappa=10, mu1=0.1, alpha1=2))) None | ansys.health.heart.objects.Part#

Use universal coordinates to generate a stiff base region.

Parameters:
threshold_left_ventriclefloat, default: 0.9

If the uvc_l value is larger than this threshold in the left ventricle, it is set as stiff material.

threshold_right_ventriclefloat, default: 0.95

If the uvc_l value is larger than this threshold in the right ventricle, it is set to a stiff material.

stiff_materialMechanicalMaterialModel, default: MAT295(rho=0.001,

iso=ISO(itype=1, beta=2, kappa=10, mu1=0.1, alpha1=2) Material to assign.

Returns:
Part

Part associated with the stiff base region.

HeartModel.create_atrial_stiff_ring(radius: float = 2) None | ansys.health.heart.objects.Part#

Create a part for solids close to the atrial caps.

Parameters:
radiusfoat, default: 2

Influence region.

Returns:
Union[None, Part]

Part of atrial rings if created.

Notes

Part created is passive and isotropic. The material must be defined.