Skip to content

Commit 40798b9

Browse files
committed
Rename python package from fenicsx_pulse to pulse
1 parent a8e933a commit 40798b9

49 files changed

Lines changed: 429 additions & 418 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

demo/benchmark/problem1.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import numpy as np
77
import dolfinx
88
from dolfinx import log
9-
import fenicsx_pulse
9+
import pulse
1010

1111
# Next we create the beam, which should have a length og 10 mm and a width of 1 mm
1212

@@ -20,43 +20,43 @@
2020
left = 1
2121
bottom = 2
2222
boundaries = [
23-
fenicsx_pulse.Marker(name="left", marker=left, dim=2, locator=lambda x: np.isclose(x[0], 0)),
24-
fenicsx_pulse.Marker(name="bottom", marker=bottom, dim=2, locator=lambda x: np.isclose(x[2], 0)),
23+
pulse.Marker(name="left", marker=left, dim=2, locator=lambda x: np.isclose(x[0], 0)),
24+
pulse.Marker(name="bottom", marker=bottom, dim=2, locator=lambda x: np.isclose(x[2], 0)),
2525
]
2626

2727
# and assemble the geometry
2828

29-
geo = fenicsx_pulse.Geometry(
29+
geo = pulse.Geometry(
3030
mesh=mesh,
3131
boundaries=boundaries,
3232
metadata={"quadrature_degree": 4},
3333
)
3434

35-
# The material model used in this benchmark is the {py:class}`Guccione <fenicsx_pulse.material_models.guccione.Guccione>` model.
35+
# The material model used in this benchmark is the {py:class}`Guccione <pulse.material_models.guccione.Guccione>` model.
3636

3737
material_params = {
38-
"C": fenicsx_pulse.Variable(dolfinx.fem.Constant(mesh, dolfinx.default_scalar_type(2.0)), "kPa"),
38+
"C": pulse.Variable(dolfinx.fem.Constant(mesh, dolfinx.default_scalar_type(2.0)), "kPa"),
3939
"bf": dolfinx.fem.Constant(mesh, dolfinx.default_scalar_type(8.0)),
4040
"bt": dolfinx.fem.Constant(mesh, dolfinx.default_scalar_type(2.0)),
4141
"bfs": dolfinx.fem.Constant(mesh, dolfinx.default_scalar_type(4.0)),
4242
}
4343
f0 = dolfinx.fem.Constant(mesh, dolfinx.default_scalar_type((1.0, 0.0, 0.0)))
4444
s0 = dolfinx.fem.Constant(mesh, dolfinx.default_scalar_type((0.0, 1.0, 0.0)))
4545
n0 = dolfinx.fem.Constant(mesh, dolfinx.default_scalar_type((0.0, 0.0, 1.0)))
46-
material = fenicsx_pulse.Guccione(f0=f0, s0=s0, n0=n0, **material_params)
46+
material = pulse.Guccione(f0=f0, s0=s0, n0=n0, **material_params)
4747

4848
# There are now active contraction, so we choose a pure passive model
4949

50-
active_model = fenicsx_pulse.active_model.Passive()
50+
active_model = pulse.active_model.Passive()
5151

5252
# and the model should be incompressible
5353

54-
comp_model = fenicsx_pulse.Incompressible()
54+
comp_model = pulse.Incompressible()
5555

5656
# We can now assemble the `CardiacModel`
5757
#
5858

59-
model = fenicsx_pulse.CardiacModel(
59+
model = pulse.CardiacModel(
6060
material=material,
6161
active=active_model,
6262
compressibility=comp_model,
@@ -79,15 +79,15 @@ def dirichlet_bc(
7979
# and the traction force
8080

8181
traction = dolfinx.fem.Constant(mesh, dolfinx.default_scalar_type(0.0))
82-
neumann = fenicsx_pulse.NeumannBC(traction=traction, marker=bottom)
82+
neumann = pulse.NeumannBC(traction=traction, marker=bottom)
8383

8484
# We assemble all the boundary conditions
8585

86-
bcs = fenicsx_pulse.BoundaryConditions(dirichlet=(dirichlet_bc,), neumann=(neumann,))
86+
bcs = pulse.BoundaryConditions(dirichlet=(dirichlet_bc,), neumann=(neumann,))
8787

8888
# and create a mechanics problem
8989

90-
problem = fenicsx_pulse.StaticProblem(model=model, geometry=geo, bcs=bcs)
90+
problem = pulse.StaticProblem(model=model, geometry=geo, bcs=bcs)
9191

9292
# Now let us turn on some more logging
9393

demo/benchmark/problem2.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import numpy as np
1111
import math
1212
import cardiac_geometries
13-
import fenicsx_pulse
13+
import pulse
1414

1515

1616
logging.basicConfig(level=logging.INFO)
@@ -40,34 +40,34 @@
4040
folder=geodir,
4141
)
4242

43-
# Now, lets convert the geometry to a `fenicsx_pulse.Geometry` object.
43+
# Now, lets convert the geometry to a `pulse.Geometry` object.
4444

45-
geometry = fenicsx_pulse.HeartGeometry.from_cardiac_geometries(geo, metadata={"quadrature_degree": 4})
45+
geometry = pulse.HeartGeometry.from_cardiac_geometries(geo, metadata={"quadrature_degree": 4})
4646

4747

48-
# The material model used in this benchmark is the {py:class}`Guccione <fenicsx_pulse.material_models.guccione.Guccione>` model.
48+
# The material model used in this benchmark is the {py:class}`Guccione <pulse.material_models.guccione.Guccione>` model.
4949

5050
material_params = {
5151
"C": dolfinx.fem.Constant(geometry.mesh, dolfinx.default_scalar_type(10.0)),
5252
"bf": dolfinx.fem.Constant(geometry.mesh, dolfinx.default_scalar_type(1.0)),
5353
"bt": dolfinx.fem.Constant(geometry.mesh, dolfinx.default_scalar_type(1.0)),
5454
"bfs": dolfinx.fem.Constant(geometry.mesh, dolfinx.default_scalar_type(1.0)),
5555
}
56-
material = fenicsx_pulse.Guccione(**material_params)
56+
material = pulse.Guccione(**material_params)
5757

5858

5959
# There are now active contraction, so we choose a pure passive model
6060

61-
active_model = fenicsx_pulse.active_model.Passive()
61+
active_model = pulse.active_model.Passive()
6262

6363
# and the model should be incompressible
6464

65-
comp_model = fenicsx_pulse.Incompressible()
65+
comp_model = pulse.Incompressible()
6666

6767

6868
# and assembles the `CardiacModel`
6969

70-
model = fenicsx_pulse.CardiacModel(
70+
model = pulse.CardiacModel(
7171
material=material,
7272
active=active_model,
7373
compressibility=comp_model,
@@ -78,19 +78,19 @@
7878
# We apply a traction in endocardium
7979

8080
traction = dolfinx.fem.Constant(geometry.mesh, dolfinx.default_scalar_type(0.0))
81-
neumann = fenicsx_pulse.NeumannBC(
82-
traction=fenicsx_pulse.Variable(traction, "kPa"),
81+
neumann = pulse.NeumannBC(
82+
traction=pulse.Variable(traction, "kPa"),
8383
marker=geo.markers["ENDO"][0],
8484
)
8585

8686
# and finally combine all the boundary conditions
8787

88-
bcs = fenicsx_pulse.BoundaryConditions(neumann=(neumann,))
88+
bcs = pulse.BoundaryConditions(neumann=(neumann,))
8989

9090
# and create a Mixed problem
9191

92-
problem = fenicsx_pulse.StaticProblem(
93-
model=model, geometry=geometry, bcs=bcs, parameters={"base_bc": fenicsx_pulse.BaseBC.fixed},
92+
problem = pulse.StaticProblem(
93+
model=model, geometry=geometry, bcs=bcs, parameters={"base_bc": pulse.BaseBC.fixed},
9494
)
9595

9696
# Now we can solve the problem
@@ -183,12 +183,12 @@
183183
U = dolfinx.fem.Function(problem.u.function_space)
184184
U.interpolate(lambda x: (x[0], x[1], x[2]))
185185

186-
endo_apex_coord = fenicsx_pulse.utils.evaluate_at_vertex_tag(U, geo.vfun, geo.markers["ENDOPT"][0])
187-
u_endo_apex = fenicsx_pulse.utils.evaluate_at_vertex_tag(problem.u, geo.vfun, geo.markers["ENDOPT"][0])
188-
endo_apex_pos = fenicsx_pulse.utils.gather_broadcast_array(geo.mesh.comm, endo_apex_coord + u_endo_apex)
186+
endo_apex_coord = pulse.utils.evaluate_at_vertex_tag(U, geo.vfun, geo.markers["ENDOPT"][0])
187+
u_endo_apex = pulse.utils.evaluate_at_vertex_tag(problem.u, geo.vfun, geo.markers["ENDOPT"][0])
188+
endo_apex_pos = pulse.utils.gather_broadcast_array(geo.mesh.comm, endo_apex_coord + u_endo_apex)
189189
print(f"\nGet longitudinal position of endocardial apex: {endo_apex_pos[0, 0]:4f} mm")
190190

191-
epi_apex_coord = fenicsx_pulse.utils.evaluate_at_vertex_tag(U, geo.vfun, geo.markers["EPIPT"][0])
192-
u_epi_apex = fenicsx_pulse.utils.evaluate_at_vertex_tag(problem.u, geo.vfun, geo.markers["EPIPT"][0])
193-
epi_apex_pos = fenicsx_pulse.utils.gather_broadcast_array(geo.mesh.comm, epi_apex_coord + u_epi_apex)
191+
epi_apex_coord = pulse.utils.evaluate_at_vertex_tag(U, geo.vfun, geo.markers["EPIPT"][0])
192+
u_epi_apex = pulse.utils.evaluate_at_vertex_tag(problem.u, geo.vfun, geo.markers["EPIPT"][0])
193+
epi_apex_pos = pulse.utils.gather_broadcast_array(geo.mesh.comm, epi_apex_coord + u_epi_apex)
194194
print(f"\nGet longitudinal position of epicardial apex: {epi_apex_pos[0, 0]:4f} mm")

demo/benchmark/problem3.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import numpy as np
1111
import math
1212
import cardiac_geometries
13-
import fenicsx_pulse
13+
import pulse
1414

1515
# Next we will create the geometry and save it in the folder called `lv_ellipsoid`. Now we will also generate fibers and use a sixth order quadrature space for the fibers
1616

@@ -43,35 +43,35 @@
4343
folder=geodir,
4444
)
4545

46-
# Now, lets convert the geometry to a `fenicsx_pulse.Geometry` object.
46+
# Now, lets convert the geometry to a `pulse.Geometry` object.
4747

48-
geometry = fenicsx_pulse.HeartGeometry.from_cardiac_geometries(geo, metadata={"quadrature_degree": 6})
48+
geometry = pulse.HeartGeometry.from_cardiac_geometries(geo, metadata={"quadrature_degree": 6})
4949

5050

51-
# The material model used in this benchmark is the {py:class}`Guccione <fenicsx_pulse.material_models.guccione.Guccione>` model.
51+
# The material model used in this benchmark is the {py:class}`Guccione <pulse.material_models.guccione.Guccione>` model.
5252

5353
material_params = {
5454
"C": dolfinx.fem.Constant(geometry.mesh, dolfinx.default_scalar_type(2.0)),
5555
"bf": dolfinx.fem.Constant(geometry.mesh, dolfinx.default_scalar_type(8.0)),
5656
"bt": dolfinx.fem.Constant(geometry.mesh, dolfinx.default_scalar_type(2.0)),
5757
"bfs": dolfinx.fem.Constant(geometry.mesh, dolfinx.default_scalar_type(4.0)),
5858
}
59-
material = fenicsx_pulse.Guccione(f0=geo.f0, s0=geo.s0, n0=geo.n0, **material_params)
59+
material = pulse.Guccione(f0=geo.f0, s0=geo.s0, n0=geo.n0, **material_params)
6060

6161

6262
# We use an active stress approach with 60% transverse active stress
6363

6464
Ta = dolfinx.fem.Constant(geometry.mesh, dolfinx.default_scalar_type(0.0))
65-
active_model = fenicsx_pulse.ActiveStress(geo.f0, activation=fenicsx_pulse.Variable(Ta, "kPa"))
65+
active_model = pulse.ActiveStress(geo.f0, activation=pulse.Variable(Ta, "kPa"))
6666

6767
# and the model should be incompressible
6868

69-
comp_model = fenicsx_pulse.Incompressible()
69+
comp_model = pulse.Incompressible()
7070

7171

7272
# and assembles the `CardiacModel`
7373

74-
model = fenicsx_pulse.CardiacModel(
74+
model = pulse.CardiacModel(
7575
material=material,
7676
active=active_model,
7777
compressibility=comp_model,
@@ -82,19 +82,19 @@
8282
# We apply a traction in endocardium
8383

8484
traction = dolfinx.fem.Constant(geometry.mesh, dolfinx.default_scalar_type(0.0))
85-
neumann = fenicsx_pulse.NeumannBC(
86-
traction=fenicsx_pulse.Variable(traction, "kPa"),
85+
neumann = pulse.NeumannBC(
86+
traction=pulse.Variable(traction, "kPa"),
8787
marker=geo.markers["ENDO"][0],
8888
)
8989

9090
# and finally combine all the boundary conditions
9191

92-
bcs = fenicsx_pulse.BoundaryConditions(neumann=(neumann,))
92+
bcs = pulse.BoundaryConditions(neumann=(neumann,))
9393

9494
# and create a Mixed problem
9595

96-
problem = fenicsx_pulse.StaticProblem(
97-
model=model, geometry=geometry, bcs=bcs, parameters={"base_bc": fenicsx_pulse.BaseBC.fixed},
96+
problem = pulse.StaticProblem(
97+
model=model, geometry=geometry, bcs=bcs, parameters={"base_bc": pulse.BaseBC.fixed},
9898
)
9999

100100
# Now we can solve the problem
@@ -153,12 +153,12 @@
153153
U = dolfinx.fem.Function(problem.u.function_space)
154154
U.interpolate(lambda x: (x[0], x[1], x[2]))
155155

156-
endo_apex_coord = fenicsx_pulse.utils.evaluate_at_vertex_tag(U, geo.vfun, geo.markers["ENDOPT"][0])
157-
u_endo_apex = fenicsx_pulse.utils.evaluate_at_vertex_tag(problem.u, geo.vfun, geo.markers["ENDOPT"][0])
158-
endo_apex_pos = fenicsx_pulse.utils.gather_broadcast_array(geo.mesh.comm, endo_apex_coord + u_endo_apex)
156+
endo_apex_coord = pulse.utils.evaluate_at_vertex_tag(U, geo.vfun, geo.markers["ENDOPT"][0])
157+
u_endo_apex = pulse.utils.evaluate_at_vertex_tag(problem.u, geo.vfun, geo.markers["ENDOPT"][0])
158+
endo_apex_pos = pulse.utils.gather_broadcast_array(geo.mesh.comm, endo_apex_coord + u_endo_apex)
159159
print(f"\nGet longitudinal position of endocardial apex: {endo_apex_pos[0, 0]:4f} mm")
160160

161-
epi_apex_coord = fenicsx_pulse.utils.evaluate_at_vertex_tag(U, geo.vfun, geo.markers["EPIPT"][0])
162-
u_epi_apex = fenicsx_pulse.utils.evaluate_at_vertex_tag(problem.u, geo.vfun, geo.markers["EPIPT"][0])
163-
epi_apex_pos = fenicsx_pulse.utils.gather_broadcast_array(geo.mesh.comm, epi_apex_coord + u_epi_apex)
161+
epi_apex_coord = pulse.utils.evaluate_at_vertex_tag(U, geo.vfun, geo.markers["EPIPT"][0])
162+
u_epi_apex = pulse.utils.evaluate_at_vertex_tag(problem.u, geo.vfun, geo.markers["EPIPT"][0])
163+
epi_apex_pos = pulse.utils.gather_broadcast_array(geo.mesh.comm, epi_apex_coord + u_epi_apex)
164164
print(f"\nGet longitudinal position of epicardial apex: {epi_apex_pos[0, 0]:4f} mm")

demo/biv_ellipsoid.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
from mpi4py import MPI
99
import dolfinx
1010
from dolfinx import log
11-
import fenicsx_pulse
1211
import ldrb
1312
import cardiac_geometries
1413
import cardiac_geometries.geometry
14+
import pulse
1515

1616
# and lets turn on logging so that we can see more info from `dolfinx`
1717

@@ -34,18 +34,18 @@
3434
folder=geodir,
3535
)
3636

37-
# In order to use the geometry with `pulse` we need to convert it to a `fenicsx_pulse.Geometry` object. We can do this by using the `from_cardiac_geometries` method. We also specify that we want to use a quadrature degree of 4
37+
# In order to use the geometry with `pulse` we need to convert it to a `pulse.Geometry` object. We can do this by using the `from_cardiac_geometries` method. We also specify that we want to use a quadrature degree of 4
3838
#
3939

40-
geometry = fenicsx_pulse.Geometry.from_cardiac_geometries(geo, metadata={"quadrature_degree": 4})
40+
geometry = pulse.Geometry.from_cardiac_geometries(geo, metadata={"quadrature_degree": 4})
4141

42-
# Next we create the material object, and we will use the transversely isotropic version of the {py:class}`Neo Hookean model <fenicsx_pulse.neo_hookean.NeoHookean>`
42+
# Next we create the material object, and we will use the transversely isotropic version of the {py:class}`Neo Hookean model <pulse.neo_hookean.NeoHookean>`
4343

44-
material = fenicsx_pulse.NeoHookean(mu=dolfinx.fem.Constant(geometry.mesh, dolfinx.default_scalar_type(15.0)))
44+
material = pulse.NeoHookean(mu=dolfinx.fem.Constant(geometry.mesh, dolfinx.default_scalar_type(15.0)))
4545
# and use an active stress approach
4646

4747
Ta = dolfinx.fem.Constant(geometry.mesh, dolfinx.default_scalar_type(0.0))
48-
active_model = fenicsx_pulse.ActiveStress(geo.f0, activation=Ta)
48+
active_model = pulse.ActiveStress(geo.f0, activation=Ta)
4949

5050
# Now we will also implement two different versions, one where we use a compressible model and one where we use an incompressible model. To do this we will introduce a flag
5151

@@ -54,14 +54,14 @@
5454
# And in both cases we will use different compressible models, mechanics problems and different ways to get the displacement.
5555

5656
if incompressible:
57-
comp_model: fenicsx_pulse.Compressibility = fenicsx_pulse.Incompressible()
57+
comp_model: pulse.Compressibility = pulse.Incompressible()
5858
else:
59-
comp_model = fenicsx_pulse.Compressible()
59+
comp_model = pulse.Compressible()
6060

6161

6262
# Now we can assemble the `CardiacModel`
6363

64-
model = fenicsx_pulse.CardiacModel(
64+
model = pulse.CardiacModel(
6565
material=material,
6666
active=active_model,
6767
compressibility=comp_model,
@@ -71,25 +71,25 @@
7171
# We will add a pressure on the LV endocarium
7272

7373
lvp = dolfinx.fem.Constant(geometry.mesh, dolfinx.default_scalar_type(0.0))
74-
neumann_lv = fenicsx_pulse.NeumannBC(traction=lvp, marker=geometry.markers["ENDO_LV"][0])
74+
neumann_lv = pulse.NeumannBC(traction=lvp, marker=geometry.markers["ENDO_LV"][0])
7575

7676
# and on the RV endocardium
7777

7878
rvp = dolfinx.fem.Constant(geometry.mesh, dolfinx.default_scalar_type(0.0))
79-
neumann_rv = fenicsx_pulse.NeumannBC(traction=lvp, marker=geometry.markers["ENDO_RV"][0])
79+
neumann_rv = pulse.NeumannBC(traction=lvp, marker=geometry.markers["ENDO_RV"][0])
8080

8181
# We will also add a Robin type spring on the epicardial surface to mimic the pericardium.
8282

8383
pericardium = dolfinx.fem.Constant(geometry.mesh, dolfinx.default_scalar_type(1.0))
84-
robin_per = fenicsx_pulse.RobinBC(value=pericardium, marker=geometry.markers["EPI"][0])
84+
robin_per = pulse.RobinBC(value=pericardium, marker=geometry.markers["EPI"][0])
8585

8686
# We collect all the boundary conditions
8787

88-
bcs = fenicsx_pulse.BoundaryConditions(neumann=(neumann_lv, neumann_rv), robin=(robin_per,))
88+
bcs = pulse.BoundaryConditions(neumann=(neumann_lv, neumann_rv), robin=(robin_per,))
8989

9090
# create the problem
9191

92-
problem = fenicsx_pulse.StaticProblem(model=model, geometry=geometry, bcs=bcs, parameters={"base_bc": fenicsx_pulse.BaseBC.fixed})
92+
problem = pulse.StaticProblem(model=model, geometry=geometry, bcs=bcs, parameters={"base_bc": pulse.BaseBC.fixed})
9393

9494
# and solve
9595

0 commit comments

Comments
 (0)