stentfit.artery
Classes
A test artery: a wall surface, its centreline, and the 3D solid meshed from them. |
Module Contents
- class stentfit.artery.Artery(stent: stentfit.stent.Stent, artery_type: str = 'straight', inner_margin: float = 0.5, wall_thickness: float = 0.5, noise_amplitude: float = 0.05, noise_seed: float = 0, bend_angle_deg: float = 180.0, mesh_type: str = 'HEX8', artery_youngs: float = 2.0, n_circumference: int = 64, n_axial: int = 150)
A test artery: a wall surface, its centreline, and the 3D solid meshed from them.
The geometry is parametric and generated to fit a given stent, rather than imported from imaging — enough to exercise the whole mixed-dimensional chain end to end. The shape is a parameter, not a separate constructor:
artery = Artery(stent, artery_type="curved", inner_margin=0.5) sim = Simulation(stent, artery, sim_input_dir) sim.setup()
Everything is resolved and built at construction, so
radius,geometryandcentrelineare real the moment the object exists. Note this builds only the wall surface (atrimeshtube); the 3D finite-element solid 4C actually solves on is a separate step,mesh_solid(), whichsetup()runs for you.Every dimension is derived from the stent: the lumen radius is the stent’s outer radius plus
inner_marginclearance, the length a multiple of the stent length (so the stent always sits well inside), and any bend radius is picked so the arc roughly spans that length at the given bend angle. There is deliberately no way to set those dimensions by hand — a hand-sized tube is still a synthetic artery, and the real use for a specific geometry is importing patient anatomy, which is a different construction path.- Parameters:
stent – The stent this artery is sized to hold. Its skeletonisation must have run, so its features are populated.
artery_type – Shape:
'straight','curved', or's_bend'.inner_margin – Clearance, in mm, between the stent’s outer radius and the lumen wall.
wall_thickness – Wall thickness, in mm.
0builds the lumen surface only, with no separate wall.noise_amplitude – Fractional wall-roughness noise, as a fraction of the radius.
0gives a smooth pipe.noise_seed – Seed for the wall noise, for repeatable runs.
bend_angle_deg – Total bend angle, in degrees. Used only by
'curved'and's_bend'.mesh_type – GMSH element type for the solid:
'TET4','TET10', or'HEX8'. Used bymesh_solid().artery_youngs – Wall Young’s modulus, in MPa (placeholder StVenantKirchhoff material). Used by
mesh_solid().n_circumference – Number of vertices around each cross-section.
n_axial – Number of cross-sections along the length.
- Raises:
ValueError – If
artery_typeis unknown, or the stent has not been skeletonised yet.
- stent
- artery_type = 'straight'
- inner_margin = 0.5
- wall_thickness
- noise_amplitude = 0.05
- noise_seed = 0
- bend_angle_deg = 180.0
- mesh_type = 'HEX8'
- artery_youngs = 2.0
- radius
- length
- bend_radius = None
- solid_yaml: pathlib.Path | None = None
- _stent_features() dict
Read the stent’s geometry features, checking it has been skeletonised.
- Raises:
ValueError – If the stent’s pipeline has not run yet.
- Returns:
The stent’s features dict.
- _resolve_bend_radius(cap: float | None) float | None
Work out the arc radius for a bent artery.
Picked so the arc spans about 90% of the artery’s own length at the given bend angle, then limited by
capso a shallow angle cannot produce an arc so wide the artery looks straight. An S-bend splits its length across two arcs.- Parameters:
cap – Widest arc radius allowed, in mm.
Nonefor a straight artery, which has no arc.- Returns:
The arc radius in mm, or
Nonefor a straight artery.
- _build(n_circumference: int, n_axial: int) tuple
Build the wall surface mesh and the centreline it is swept along.
- Parameters:
n_circumference – Number of vertices around each cross-section.
n_axial – Number of cross-sections along the length.
- Returns:
(geometry, centreline)— thetrimeshwall surface and the(n, 3)centreline points.
- _print_summary() None
Print the built artery’s dimensions, matching the old pipeline’s output.
- mesh_solid(out_path: str | pathlib.Path, element_size: float, mesh_type: str | None = None, youngs_modulus: float | None = None, poisson_ratio: float = 0.3, density: float = 1.0, material_id: int = 1) pathlib.Path
Mesh the artery wall as a hollow 3D solid with GMSH and write a 4C
.yaml.This is the finite-element mesh 4C solves on, as opposed to the wall surface built at construction. Meshes the annulus between
radiusandradius + wall_thicknessas a straight tube, classifies its boundary nodes intoDSURFACEsets (1= lumen,2= inlet,3= outlet), then warps the whole tube ontocentrelineusing the same frame convention as the stent warp, so beam and solid stay aligned. Writes the mesh with a placeholderMAT_Struct_StVenantKirchhoffmaterial.Stores the written path on
solid_yaml, whichassemble()reads back.- Parameters:
out_path – File path the 4C
.yamlsolid is written to.element_size – Target element size, in mm.
mesh_type – Element type:
'TET4','TET10', or'HEX8'.Noneusesmesh_typefrom the constructor.youngs_modulus – Material Young’s modulus, in MPa.
Noneusesartery_youngsfrom the constructor.poisson_ratio – Placeholder material Poisson’s ratio.
density – Placeholder material density.
material_id – Material ID written into the 4C input.
- Raises:
ValueError – If the wall has no thickness, or the element type is not supported.
- Returns:
The path written, also stored on
solid_yaml.
- __repr__() str
- Returns:
A short summary of the artery’s shape and size.