NEML2 1.4.0
Loading...
Searching...
No Matches
Naming Conventions

Reserved axis names

Recall that NEML2 models operates on labeled tensors, and that the collection of labels (with their corresponding layout) is called an labeled axis (LabeledAxis). NEML2 predefines 5 sub-axes to categorize all the input, output and intermediate variables:

  • State \(\mathcal{S}\) (axis name state): Variables collectively characterizing the current state of the material subject to given external forces. The state variables are usually the output of a physically meaningful material model.
  • Forces \(\mathcal{F}\) (axis name forces): Variables defining the external forces that drive the response of the material.
  • Old state \(\mathcal{S}_n\) (axis name old_state): The state variables prior to the current material update. In the time-discrete setting, these are the state variables from the previous time step.
  • Old forces \(\mathcal{F}_n\) (axis name old_forces): The external forces prior to the current material update. In the time-discrete setting, these are the forces from the previous time step.
  • Residual \(\mathcal{R}\) (axis name residual): The residual defines an implicit model/function. An implicit model is updated by solving for the state variables that result in zero residual.

Variable naming conventions

Variable names are used to access slices of the storage tensor. Variable names have the type neml2::VariableName which is an alias to neml2::LabeledAxisAccessor. The following characters are not allowed in variable names:

  • whitespace characters: input file parsing ambiguity
  • ,: input file parsing ambiguity
  • ;: input file parsing ambiguity
  • .: clash with PyTorch parameter/buffer naming convention
  • /: separator reserved for nested variable name

In the input file, the separator / is used to denote nested variable names. For example, A/B/foo specifies a variable named "foo" defined on the sub-axis named "B" which is a nested sub-axis of "A".

Source code naming conventions

In NEML2 source code, the following naming conventions are recommended:

  • User-facing variables and option names should be as descriptive as possible. For example, the equivalent plastic strain is named "equivalent_plastic_strain". Note that white spaces, quotes, and left slashes are not allowed in the names. Underscores are recommended as an replacement for white spaces.
  • Developer-facing variables and option names should use simple alphanumeric symbols. For example, the equivalent plastic strain is named "ep" in consistency with most of the existing literature.
  • Developner-facing member variables and option names should use the same alphanumeric symbols. For example, the member variable for the equivalent plastic strain is named ep. However, if the member variable is protected or private, it is recommended to prefix it with an underscore, i.e. _ep.
  • Struct names and class names should use PascalCase.
  • Function names should use snake_case.