pyfebiopt.optimize.feb_bindings
Simplified FEBio template helpers.
Classes
Formatting options applied while writing FEBio templates. |
|
Map a single theta value onto an XML element's text content. |
|
Bind an XPath to a value derived from multiple θ parameters. |
|
FEBio template plus bindings applied during rendering. |
|
Render FEBio input files under a dedicated case subfolder. |
Module Contents
- class pyfebiopt.optimize.feb_bindings.BuildContext
Formatting options applied while writing FEBio templates.
- Parameters:
fmt –
printf-style format string used for numeric values.namespaces – Optional mapping passed to
xml.etree.ElementTree.findall().
- fmt: str = '%.20e'
- namespaces: dict[str, str]
- format_value(value: Number) str
Format a scalar value according to the
fmtpattern.- Returns:
String representation suitable for FEBio XML content.
- class pyfebiopt.optimize.feb_bindings.ParameterBinding
Map a single theta value onto an XML element’s text content.
The XPath is evaluated with
ElementTree.findall(). All matching nodes are updated; setrequiredtoFalseto ignore missing nodes.- theta_name: str
- xpath: str
- required: bool = True
- apply(root: xml.etree.ElementTree.Element, theta: collections.abc.Mapping[str, Number], ctx: BuildContext) None
Insert formatted values into all nodes matched by
xpath.
- class pyfebiopt.optimize.feb_bindings.EvaluationBinding
Bind an XPath to a value derived from multiple θ parameters.
- Parameters:
xpath – XPath targeting the XML node(s) to update.
value – Expression or callable producing either a numeric value or plain text. String expressions remain numeric-only; callable values may return preformatted text for complex XML nodes such as vectors.
required – Same semantics as
ParameterBinding.text_template – Optional
str.format()template receiving the formatted value via thevalueplaceholder, useful for nodes that contain mixed text such as"2,{value}"in load curves.
- xpath: str
- value: str | collections.abc.Callable[[collections.abc.Mapping[str, Number]], ScalarOrText]
- required: bool = True
- text_template: str | None = None
- __post_init__() None
- apply(root: xml.etree.ElementTree.Element, theta: collections.abc.Mapping[str, Number], ctx: BuildContext) None
Apply the evaluated value to all matching nodes.
- class pyfebiopt.optimize.feb_bindings.FebTemplate
FEBio template plus bindings applied during rendering.
- template_path: pathlib.Path | str
- bindings: list[Binding] = []
- __post_init__() None
- add_binding(binding: Binding) None
Register an additional binding for this template.
- render(theta: collections.abc.Mapping[str, Number], ctx: BuildContext | None = None) xml.etree.ElementTree.ElementTree
Render the template into an XML tree using the supplied parameters.
- Returns:
Parsed
xml.etree.ElementTree.ElementTreeready for saving.
- write(theta: collections.abc.Mapping[str, Number], out_path: pathlib.Path | str, ctx: BuildContext | None = None) pathlib.Path
Render and write the template to
out_path.- Returns:
Path to the written FEB file.
- class pyfebiopt.optimize.feb_bindings.FebBuilder
Render FEBio input files under a dedicated case subfolder.
- template: FebTemplate
- subfolder: str
- build(theta: collections.abc.Mapping[str, Number], out_root: pathlib.Path | str, out_name: str | None = None, ctx: BuildContext | None = None) pathlib.Path
Render the template into the case subfolder and return the FEB path.
- Returns:
Full path to the generated FEB document.