pyissm.model.classes.autodiff

class pyissm.model.classes.autodiff(other=None)

Bases: manage_state

Automatic differentiation class for ISSM.

This class contains parameters for automatic differentiation (AD) functionality in the ISSM framework. It allows users to configure AD settings including dependent and independent variables, memory buffer sizes, and optimization parameters for sensitivity analysis and gradient-based optimization.

Parameters:

other (any, optional) – Any other class object that contains common fields to inherit from. If values in other differ from default values, they will override the default values.

isautodiff

Indicates if automatic differentiation is activated.

Type:

float, default=0.0

dependents

List of dependent variables for AD.

Type:

str, default=’List dependents’

independents

List of independent variables for AD.

Type:

str, default=’List independents’

driver

ADOLC driver (‘fos_forward’ or ‘fov_forward’).

Type:

str, default=’fos_forward’

obufsize

Number of operations per buffer (== OBUFSIZE in usrparms.h).

Type:

float, default=524288

lbufsize

Number of locations per buffer (== LBUFSIZE in usrparms.h).

Type:

float, default=524288

cbufsize

Number of values per buffer (== CBUFSIZE in usrparms.h).

Type:

float, default=524288

tbufsize

Number of taylors per buffer (<=TBUFSIZE in usrparms.h).

Type:

float, default=524288

gcTriggerMaxSize

Free location block sorting/consolidation triggered if allocated locations exceed this value.

Type:

float, default=65536

gcTriggerRatio

Free location block sorting/consolidation triggered if the ratio between allocated and used locations exceeds this value.

Type:

float, default=2.0

tapeAlloc

Iteration count of a priori memory allocation of the AD tape.

Type:

float, default=15000000

outputTapeMemory

Write AD tape memory statistics to file ad_mem.dat.

Type:

float, default=0.0

outputTime

Write AD recording and evaluation times to file ad_time.dat.

Type:

float, default=0.0

enablePreaccumulation

Enable CoDiPack preaccumulation in augmented places.

Type:

float, default=0.0

Examples

>>> md.autodiff = pyissm.model.classes.autodiff()
>>> md.autodiff.isautodiff = 1
>>> md.autodiff.dependents = ['Vel']
>>> md.autodiff.independents = ['MaterialsRheologyBbar']
__init__(other=None)

Initialize the instance with optional field inheritance.

Parameters:

other (object, optional) – Another instance to inherit field values from. If provided, any fields in the current instance that differ from the default values and exist in ‘other’ will be replaced with the values from ‘other’.

Notes

The inheritance process:

  1. Iterates through all attributes of the current instance

  2. Checks if the same attribute exists in the ‘other’ instance

  3. Compares field values using _fields_equal()

  4. If different, replaces the current value with the ‘other’ value

This enables the common ISSM pattern where classes can inherit configurations from existing instances while maintaining their default values for unspecified fields.

Methods

__init__([other])

Initialize the instance with optional field inheritance.

check_consistency(md, solution, analyses)

Check consistency of the [autodiff] parameters.

issm_enum_string()

Default ISSM C++ enum string used during marshalling.

marshall_class(fid, prefix[, md])

Marshall [autodiff.autodiff] parameters to a binary file.

check_consistency(md, solution, analyses)

Check consistency of the [autodiff] parameters.

Parameters:
  • md (pyissm.model.Model) – The model object to check.

  • solution (str) – The solution name to check.

  • analyses (list of str) – List of analyses to check consistency for.

Returns:

md – The model object with any consistency errors noted.

Return type:

pyissm.model.Model

marshall_class(fid, prefix, md=None)

Marshall [autodiff.autodiff] parameters to a binary file.

Parameters:
  • fid (file object) – The file object to write the binary data to.

  • prefix (str) – Prefix string used for data identification in the binary file.

  • md (pyissm.model.Model, optional) – ISSM model object needed in some cases.

Return type:

None