Tensions and pressures together¶
Tensions and pressures in one call: infer_forces, and infer_tensions_then_pressures for front ends.
infer_forces runs infer_tensions then infer_pressures and raises when either refuses;
infer_tensions_then_pressures makes the same two calls, keeps the tensions when the pressure solve
refuses them, and returns the refusal as an InferenceOutcome instead of raising it.
Sacha Ichbiah 2021 Matthieu Perez 2024
InferenceOutcome
dataclass
¶
InferenceOutcome(tensions: dict[tuple[int, int], float] | None, pressures: dict[int, float] | None, records: list = list(), status: str = INFERENCE_COMPLETE, error: str | None = None, library_call: str = '')
What infer_tensions_then_pressures computed, and what the library refused.
Attributes:
| Name | Type | Description |
|---|---|---|
tensions |
dict[tuple[int, int], float] | None
|
interface -> tension, or |
pressures |
dict[int, float] | None
|
material -> pressure, or |
records |
list
|
the solve records ( |
status |
str
|
|
error |
str | None
|
the library's message when the status is not |
library_call |
str
|
the |
infer_forces ¶
infer_forces(mesh: DcelData, mean_tension: float = 1, base_pressure: float = 0, mode_tension: TensionComputationMethod = TensionComputationMethod.YoungDupre, mode_pressure: PressureComputationMethod = PressureComputationMethod.Variational, *, solver: str = 'auto', sparse_threshold: int | None = None, diagnostics: bool | str = False) -> tuple
Infer the relative tensions, then the pressures, of a 3D mesh.
infer_tensions(mesh, mean_tension, mode_tension, ...) then infer_pressures(mesh, tensions,
mode_pressure, base_pressure, ...), with the same solver options; see those two functions for
every convention, warning and failure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
DcelData
|
Mesh to analyze, in any length unit. |
required |
mean_tension
|
float
|
The normalisation: the tensions are normalised so that
their mean is |
1
|
base_pressure
|
float
|
Pressure of the exterior medium (label 0). Defaults to 0. |
0
|
mode_tension
|
TensionComputationMethod
|
Method for tension computation.
Defaults to |
YoungDupre
|
mode_pressure
|
PressureComputationMethod
|
Method for pressure computation.
Defaults to |
Variational
|
solver
|
str
|
|
'auto'
|
sparse_threshold
|
int | None
|
unknowns at which |
None
|
diagnostics
|
bool | str
|
|
False
|
Returns:
| Type | Description |
|---|---|
tuple
|
tuple[dict[tuple[int, int], float], dict[int, float]]:
- map of interface |
Raises:
| Type | Description |
|---|---|
UndeterminedTensionError
|
on an uncropped mesh, if any inferred tension is not finite,
which is the case on a mesh with an interface that has no triple line. The pressure
solve couples every cell to every tension, so such a tension would make nearly every
pressure non-finite; pressures are refused instead. Call |
ValueError
|
on an invalid solver option; as |
MalformedTripleLineError
|
as |
LinAlgError
|
as |
Warns:
| Type | Description |
|---|---|
JunctionGraphGaugeWarning
|
as |
DegenerateWedgeWarning
|
as |
UndeterminedPressureWarning
|
as |
CutCellPressureWarning
|
as |
SparseSolveFallbackWarning
|
as |
DenseSolveMemoryWarning
|
as |
infer_tensions_then_pressures ¶
infer_tensions_then_pressures(mesh: DcelData, mean_tension: float = 1, base_pressure: float = 0, mode_tension: TensionComputationMethod = TensionComputationMethod.YoungDupre, mode_pressure: PressureComputationMethod = PressureComputationMethod.Variational, *, solver: str = 'auto', diagnostics: bool | str = False, with_pressures: bool = True) -> InferenceOutcome
The tensions then the pressures, by the two calls infer_forces makes, keeping what succeeds.
infer_forces runs infer_tensions then infer_pressures with these arguments and raises when either is
refused. This function makes the same two calls itself, so that the tensions survive a pressure solve that
refuses them (UndeterminedTensionError), and returns the refusal instead of raising it: what the foambryo
infer command and the napari plugin need to report a partial result. The numbers are bitwise those of
infer_forces with the same arguments. Every default is infer_forces's.
With with_pressures=False only the first call is made (infer_tensions with the same arguments, so the
tensions are bitwise those of infer_forces), base_pressure and mode_pressure are not used, the outcome's
pressures is None with the status "complete", and library_call is that infer_tensions call.
sparse_threshold is not an argument: the default threshold (2 000 unknowns) always applies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
DcelData
|
the mesh, in any length unit. |
required |
mean_tension
|
float
|
the normalisation: the tensions are normalised so that their mean is
|
1
|
base_pressure
|
float
|
the pressure of the exterior medium, label 0. Defaults to 0. |
0
|
mode_tension
|
TensionComputationMethod
|
the tension method. Defaults to |
YoungDupre
|
mode_pressure
|
PressureComputationMethod
|
the pressure method. Defaults to |
Variational
|
solver
|
str
|
|
'auto'
|
diagnostics
|
bool | str
|
|
False
|
with_pressures
|
bool
|
|
True
|
Returns:
| Name | Type | Description |
|---|---|---|
InferenceOutcome |
InferenceOutcome
|
the tensions and pressures computed, the solve records, the status and the library call.
A |
Raises:
| Type | Description |
|---|---|
LinAlgError
|
if the variational pressure system is singular (not caught). |
Warns:
| Type | Description |
|---|---|
UserWarning
|
every warning |