Skip to content

crashmetrics.doe

doe

Design of experiments: sample design variables for CAE studies.

Functions:

  • latin_hypercube: Latin hypercube sample (random, space-filling).
  • halton: Halton low-discrepancy sequence (deterministic).
  • full_factorial: Every combination of the given levels.
  • morris_design: Trajectories for Morris elementary-effects screening (analysed with crashmetrics.sensitivity.morris_effects).
  • lsdyna_parameters: *PARAMETER keyword text for one run, to include in an LS-DYNA deck.

Every sampler returns a Design: variable names, bounds, the sample in the unit cube and in physical units, and rows() for crashmetrics.features.feature_table / write_csv.

Random designs take seed (an int or a numpy.random.Generator) so a study can be repeated exactly.

Design dataclass

Design(
    names: tuple[str, ...],
    bounds: tuple[tuple[float, float], ...],
    unit: NDArray[float64],
    values: NDArray[float64],
    method: str,
)

A sample of design variables.

unit instance-attribute

unit: NDArray[float64]

Sample in the unit cube, shape (n_runs, n_variables).

values instance-attribute

values: NDArray[float64]

Sample in physical units (bounds applied).

column

column(name: str) -> NDArray[float64]

Values of one variable.

rows

rows(
    prefix: str = "run", start: int = 1, digits: int = 3
) -> list[dict[str, float | str]]

One dict per run: {"run": "run001", name: value, ...}.

latin_hypercube

latin_hypercube(
    bounds: Bounds,
    n: int,
    seed: Seed = None,
    centered: bool = False,
) -> Design

Latin hypercube sample of n runs.

Each variable's range is cut into n equal strata and every stratum is used exactly once, in random order. The point within a stratum is random, or its centre with centered=True.

halton

halton(bounds: Bounds, n: int, skip: int = 1) -> Design

Halton sequence of n runs (bases 2, 3, 5, ... per variable).

Deterministic and evenly spread; good for up to about 10 variables. skip leaves out the first points (the default drops the origin).

full_factorial

full_factorial(
    levels: Mapping[str, Sequence[float]],
) -> Design

Every combination of the given levels per variable.

The last variable changes fastest. unit holds the levels mapped to 0..1 within each variable's range.

morris_design

morris_design(
    bounds: Bounds,
    trajectories: int = 10,
    levels: int = 4,
    seed: Seed = None,
) -> Design

Trajectories for Morris elementary-effects screening.

Each trajectory has k + 1 runs (k variables): a random start on a levels-level grid, then one variable at a time moved by delta = levels / (2 (levels - 1)) (Morris 1991). Runs are ordered trajectory by trajectory; analyse the outputs with crashmetrics.sensitivity.morris_effects.

lsdyna_parameters

lsdyna_parameters(
    values: Mapping[str, float], title: str = ""
) -> str

*PARAMETER cards defining real parameters for one run.

Names must be at most 7 characters (LS-DYNA fields are 10 characters wide, the first holding the type R). Put the result in a file included by the deck (*INCLUDE) and refer to the parameters as &name.