Skip to content

Commit 8e1ee83

Browse files
refactor: use pydantic-based modules for EP materials (#1242)
Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent 12d1eb7 commit 8e1ee83

File tree

14 files changed

+825
-1076
lines changed

14 files changed

+825
-1076
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use pydantic-based modules for materials

examples/preprocessor/demo-material_pr.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535

3636
import matplotlib.pyplot as plt
3737

38-
from ansys.health.heart.settings.material.cell_models import Tentusscher
38+
import ansys.health.heart.settings.material.cell_models as cell_models
3939
from ansys.health.heart.settings.material.curve import kumaraswamy_active
40-
from ansys.health.heart.settings.material.ep_material import EPMaterial
40+
import ansys.health.heart.settings.material.ep_material as ep_materials
4141
from ansys.health.heart.settings.material.material_pyd import (
4242
ACTIVE,
4343
ANISO,
@@ -133,10 +133,10 @@
133133
###############################################################################
134134
# Create EP materials
135135
# ~~~~~~~~~~~~~~~~~~~
136-
ep_mat_active = EPMaterial.Active(
137-
sigma_fiber=1, sigma_sheet=0.5, beta=140, cm=0.01, cell_model=Tentusscher()
136+
ep_mat_active = ep_materials.Active(
137+
sigma_fiber=1, sigma_sheet=0.5, beta=140, cm=0.01, cell_model=cell_models.Tentusscher()
138138
)
139-
epinsulator = EPMaterial.Insulator()
139+
epinsulator = ep_materials.Insulator()
140140

141141
# import pyvista as pv
142142

examples/simulator/ep-mechanics-simulator-fullheart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
from ansys.health.heart.examples import get_preprocessed_fullheart
5252
import ansys.health.heart.models as models
53-
from ansys.health.heart.settings.material.ep_material import EPMaterial
53+
import ansys.health.heart.settings.material.ep_material as ep_materials
5454
from ansys.health.heart.settings.material.material import ISO, Mat295
5555
from ansys.health.heart.simulator import DynaSettings, EPMechanicsSimulator
5656

@@ -133,7 +133,7 @@
133133
ring.meca_material = stiff_iso
134134

135135
# Assign the default EP material
136-
ring.ep_material = EPMaterial.Active()
136+
ring.ep_material = ep_materials.Active()
137137

138138
# plot the mesh
139139
simulator.model.plot_mesh()

src/ansys/health/heart/models.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
)
5555
from ansys.health.heart.pre.input import _InputModel
5656
import ansys.health.heart.pre.mesher as mesher
57-
from ansys.health.heart.settings.material.ep_material import EPMaterial
57+
import ansys.health.heart.settings.material.ep_material as ep_materials
5858
from ansys.health.heart.settings.material.material import (
5959
ISO,
6060
Mat295,
@@ -1689,7 +1689,7 @@ def create_stiff_ventricle_base(
16891689
part.active = False
16901690
part.meca_material = stiff_material
16911691
# assign default EP material as for ventricles
1692-
part.ep_material = EPMaterial.Active()
1692+
part.ep_material = ep_materials.Active()
16931693

16941694
return part
16951695

@@ -1830,7 +1830,7 @@ def _create_atrioventricular_isolation(self) -> None | anatomy.Part:
18301830
# Assign a new part ID to the isolation part
18311831
isolation.fiber = True
18321832
isolation.active = False
1833-
isolation.ep_material = EPMaterial.Insulator()
1833+
isolation.ep_material = ep_materials.Insulator()
18341834

18351835
return isolation
18361836

@@ -1891,7 +1891,7 @@ def create_atrial_stiff_ring(self, radius: float = 2) -> None | anatomy.Part:
18911891
ring.fiber = False
18921892
ring.active = False
18931893
# assign default EP material
1894-
ring.ep_material = EPMaterial.Active()
1894+
ring.ep_material = ep_materials.Active()
18951895

18961896
return ring
18971897

@@ -1932,7 +1932,7 @@ def __init__(self, working_directory: pathlib.Path | str = None) -> None:
19321932
self.pulmonary_artery.fiber = False
19331933
self.pulmonary_artery.active = False
19341934

1935-
self.aorta.ep_material = EPMaterial.Insulator()
1936-
self.pulmonary_artery.ep_material = EPMaterial.Insulator()
1935+
self.aorta.ep_material = ep_materials.Insulator()
1936+
self.pulmonary_artery.ep_material = ep_materials.Insulator()
19371937

19381938
super().__init__(working_directory=working_directory)

src/ansys/health/heart/parts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
from ansys.health.heart import LOG as LOGGER, __version__
3838
from ansys.health.heart.objects import Cap, CapType, Cavity, Mesh, Point, SurfaceMesh
39-
from ansys.health.heart.settings.material.ep_material import EPMaterial
39+
import ansys.health.heart.settings.material.ep_material as ep_materials
4040
from ansys.health.heart.settings.material.material import MechanicalMaterialModel
4141

4242

@@ -140,7 +140,7 @@ def __init__(self, name: str = None, part_type: _PartType = _PartType.UNDEFINED)
140140
self.meca_material: MechanicalMaterialModel = MechanicalMaterialModel.DummyMaterial()
141141
"""Material model to assign in the simulator."""
142142

143-
self.ep_material: EPMaterial = EPMaterial.DummyMaterial()
143+
self.ep_material: ep_materials.EPMaterialModel = None
144144
"""EP material model to assign in the simulator."""
145145

146146
def __str__(self) -> str:
@@ -336,7 +336,7 @@ def __init__(self, name: str = None) -> None:
336336

337337
self.wall: SurfaceMesh = SurfaceMesh(name="{0} wall".format(self.name))
338338

339-
self.ep_material = EPMaterial.Insulator()
339+
self.ep_material = ep_materials.Insulator()
340340
"""EP material model for the artery part."""
341341

342342

src/ansys/health/heart/pre/conduction_path.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
from ansys.health.heart import LOG as LOGGER
3535
from ansys.health.heart.objects import Mesh, SurfaceMesh
36-
from ansys.health.heart.settings.material.ep_material import EPMaterial
36+
from ansys.health.heart.settings.material.ep_material import EPMaterialModel, Insulator
3737

3838

3939
class ConductionPathType(Enum):
@@ -84,7 +84,7 @@ def __init__(
8484
id: int,
8585
is_connected: np.ndarray,
8686
relying_surface: pv.PolyData,
87-
material: EPMaterial = EPMaterial.DummyMaterial(),
87+
material: EPMaterialModel | Insulator | None = None,
8888
up_path: ConductionPath | None = None,
8989
down_path: ConductionPath | None = None,
9090
):
@@ -103,7 +103,7 @@ def __init__(
103103
Mask array of points connected to the solid mesh.
104104
relying_surface : pv.PolyData
105105
Surface mesh that the conduction path relies on.
106-
material : EPMaterial, default: EPMaterial.DummyMaterial()
106+
material : EPMaterial, default: None
107107
EP Material property.
108108
up_path : ConductionPath | None, default: None
109109
Upstream conduction path. Its closest point connects to the first point of this path.

0 commit comments

Comments
 (0)