PairwiseAnisotropicGBEnergy

Evaluates anisotropic grain-boundary energy between a pair of grains from a TorchScript model, given the gradient buffers of each grain's order parameter.

PairwiseAnisotropicGBEnergy evaluates a TorchScript model on the normal between a pair of grains' order-parameter gradients, and stores both the resulting scalar grain-boundary energy and its derivatives with respect to each incoming gradient in output buffers.

Overview

The object takes two vector-valued gradient buffers, grad_grain1_buffer and grad_grain2_buffer (each with trailing component dimension 3, typically generated by GradientVector), and computes the interface normal

A point is only evaluated by the TorchScript model if all three of , , and clear a gradient-magnitude threshold derived from interface_width. The third condition matters at triple junctions, where two order parameters can rise together against a third grain and their difference nearly vanishes even though each gradient individually clears the threshold.

Outside this masked region, the derivative buffers (dsigma_dgrad_grain1, dsigma_dgrad_grain2) are zero, since there is no boundary to exert a torque. The energy buffer is instead filled with the largest energy value measured anywhere in the domain (or 1.0 if no interface point was found anywhere), to avoid introducing an artificial low-energy region in the bulk.

To bound peak memory usage on large grids, evaluation is chunked: the domain is processed chunk_size points at a time, with masking, TorchScript evaluation, and autograd all performed per chunk.

Example Input File Syntax

[TensorComputes<<<{"href": "../../syntax/TensorComputes/index.html"}>>>]
  [Solve<<<{"href": "../../syntax/TensorComputes/Solve/index.html"}>>>]
    [sigma_gr0_gr1]
      type = PairwiseAnisotropicGBEnergy<<<{"description": "Evaluates anisotropic grain-boundary energy between a pair of grains from a TorchScript model, given the gradient buffers of each grain's order parameter.", "href": "PairwiseAnisotropicGBEnergy.html"}>>>
      buffer<<<{"description": "The buffer this compute is writing to"}>>> = 'sigma_gr0_gr1'
      dsigma_dgrad_grain1<<<{"description": "Output tensor buffer for the derivative of GB energy with respect to the left grain gradient."}>>> = 'dsigma_gr0_gr1_dgrad_gr0'
      dsigma_dgrad_grain2<<<{"description": "Output tensor buffer for the derivative of GB energy with respect to the right grain gradient."}>>> = 'dsigma_gr0_gr1_dgrad_gr1'
      grad_grain1_buffer<<<{"description": "Input tensor buffer containing gradient vectors for left grain."}>>> = 'grad_gr0'
      grad_grain2_buffer<<<{"description": "Input tensor buffer containing gradient vectors for right grain."}>>> = 'grad_gr1'
      interface_width<<<{"description": "Coarsest interface width in model."}>>> = '${interface_width}'
      libtorch_model_file<<<{"description": "Path to the TorchScript file containing the GB energy model."}>>> = 'marlin:anisotropic_gb_energy/gb_energy_hull_2d.pt'
      chunk_size<<<{"description": "Maximum number of spatial points processed at once. Smaller values reduce peak GPU memory usage at the cost of additional TorchScript launches."}>>> = 256
    []
  []
[]
(test/tests/anisotropic_grain_growth/sigma3_circular_grain.i)

Input Parameters

  • bufferThe buffer this compute is writing to

    C++ Type:std::string

    Controllable:No

    Description:The buffer this compute is writing to

  • dsigma_dgrad_grain1Output tensor buffer for the derivative of GB energy with respect to the left grain gradient.

    C++ Type:std::string

    Controllable:No

    Description:Output tensor buffer for the derivative of GB energy with respect to the left grain gradient.

  • dsigma_dgrad_grain2Output tensor buffer for the derivative of GB energy with respect to the right grain gradient.

    C++ Type:std::string

    Controllable:No

    Description:Output tensor buffer for the derivative of GB energy with respect to the right grain gradient.

  • grad_grain1_bufferInput tensor buffer containing gradient vectors for left grain.

    C++ Type:std::string

    Controllable:No

    Description:Input tensor buffer containing gradient vectors for left grain.

  • grad_grain2_bufferInput tensor buffer containing gradient vectors for right grain.

    C++ Type:std::string

    Controllable:No

    Description:Input tensor buffer containing gradient vectors for right grain.

  • interface_widthCoarsest interface width in model.

    C++ Type:Real

    Unit:(no unit assumed)

    Range:interface_width > 0

    Controllable:No

    Description:Coarsest interface width in model.

  • libtorch_model_filePath to the TorchScript file containing the GB energy model.

    C++ Type:DataFileName

    Controllable:No

    Description:Path to the TorchScript file containing the GB energy model.

Required Parameters

  • chunk_size65536Maximum number of spatial points processed at once. Smaller values reduce peak GPU memory usage at the cost of additional TorchScript launches.

    Default:65536

    C++ Type:unsigned int

    Range:chunk_size > 0

    Controllable:No

    Description:Maximum number of spatial points processed at once. Smaller values reduce peak GPU memory usage at the cost of additional TorchScript launches.

Optional Parameters

  • control_tagsAdds user-defined labels for accessing object parameters via control logic.

    C++ Type:std::vector<std::string>

    Controllable:No

    Description:Adds user-defined labels for accessing object parameters via control logic.

  • enableTrueSet the enabled status of the MooseObject.

    Default:True

    C++ Type:bool

    Controllable:No

    Description:Set the enabled status of the MooseObject.

Advanced Parameters

Input Files