Skip to content

Move virial computation (_compute_virial) to EquivariantTensors atoms extension #319

@jameskermode

Description

@jameskermode

From PR #313 review (non-blocking comment by @cortner):

The _compute_virial function in src/et_models/et_calculators.jl computes the virial tensor from edge gradients:

function _compute_virial(G::ET.ETGraph, ∂G)
   # V = -∑ (∂E/∂𝐫ij) ⊗ 𝐫ij
   V = zeros(SMatrix{3,3,Float64,9})
   for (edge, ∂edge) in zip(G.edge_data, ∂G.edge_data)
      V -= ∂edge.𝐫 * edge.𝐫'
   end
   return V
end

This is essentially the pullback of the graph construction with respect to the cell vectors, and would be better placed in the EquivariantTensors atoms extension alongside forces_from_edge_grads.

Reference: #313 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions