autopdex.models.ModelContext

class autopdex.models.ModelContext(mode: str, x_int: Any, trial_ansatz: Dict[str, Callable], test_ansatz: Dict[str, Callable] | None = None, internal_vars: Dict[str, Any] | None = None, local_solvers: Dict[str, Callable] | None = None, settings: Dict[str, Any] | None = None, static_settings: Any = None, elem_number: Any = None, int_point_number: Any = None, set: Any = None, t: Any = None, dt: Any = None)[source]

Argument passed to every high-level model function registered via SimState.add_model().

A single model function can serve several purposes; the requested one is signalled by mode and determines what has to be returned:

  • "weak form" or "potential": return a scalar integrand.

  • "internal variables": return the dict of updated internal variables.

  • "output": return {name: value, ...} for postprocessing.

mode

Requested evaluation mode (see above).

Type:

str

x_int

Coordinates of the current integration point in the reference domain; the ansatz callables are evaluated here. Derivatives w.r.t. x_int are computed w.r.t. initial configuration via a custom jvp rule.

Type:

Any

trial_ansatz

Dict field name -> ansatz(x_int, t) returning the trial field. The reserved key "physical coor" maps a reference point to its physical position, e.g. x = ctx.trial_ansatz["physical coor"](ctx.x_int).

Type:

Dict[str, Callable]

test_ansatz

Dict field name -> test(x_int) used to build the weak-form residual; None in "potential"/"output" mode.

Type:

Dict[str, Callable] | None

internal_vars

Internal variables at the integration point (e.g. plastic strain), read in "output" mode and forwarded to the local solvers.

Type:

Dict[str, Any] | None

local_solvers

Registered local subsystems; can be invoked through solve_local().

Type:

Dict[str, Callable] | None

settings, static_settings

Runtime and compile-time settings dicts (material parameters,user key words …).

elem_number, int_point_number, set

Index of the current element, integration point and domain/set.

t, dt

Current time and time increment.

__init__(mode: str, x_int: Any, trial_ansatz: Dict[str, Callable], test_ansatz: Dict[str, Callable] | None = None, internal_vars: Dict[str, Any] | None = None, local_solvers: Dict[str, Callable] | None = None, settings: Dict[str, Any] | None = None, static_settings: Any = None, elem_number: Any = None, int_point_number: Any = None, set: Any = None, t: Any = None, dt: Any = None) None

Methods

__delattr__(name)

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__(other)

Return self==value.

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__getstate__()

Helper for pickle.

__gt__(value, /)

Return self>value.

__hash__()

Return hash(self).

__init_subclass__

This method is called when a class is subclassed.

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__ne__(value, /)

Return self!=value.

__new__(*args, **kwargs)

__post_init__()

__reduce__()

Helper for pickle.

__reduce_ex__(protocol, /)

Helper for pickle.

__repr__()

Return repr(self).

__setattr__(name, value)

Implement setattr(self, name, value).

__sizeof__()

Size of object in memory, in bytes.

__str__()

Return str(self).

__subclasshook__

Abstract classes can override this to customize issubclass().

solve_local(key[, inputs])

Attributes

__annotations__

__dataclass_fields__

__dataclass_params__

__dict__

__doc__

__match_args__

__module__

__weakref__

list of weak references to the object

dt

elem_number

int_point_number

internal_vars

local_solvers

set

settings

static_settings

t

test_ansatz

mode

x_int

trial_ansatz