Skip to content

Draft: Support for loading charge NEP models

This MR adds support for parsing charge NEP models. The latter can be identified by name in the first line of the nep.txt file, which reads, e.g.,

nep4_charge1 2 Si O

They contain additional parameters, specifically there are twice as many w1 parameters, i.e., weights that connect the hidden layer to the output, as well as one additional scalar parameter sqrt_epsilon_inf, which is the square root of the electronic dielectric constant \sqrt{\epsilon_\infty}. The order of the parameters in the nep.txt can be inferred from this code block.

void NEP_Charge::update_potential(Parameters& para, float* parameters, ANN& ann)
{
  const int num_outputs = (para.charge_mode >= 4) ? 3 : 2;   # <-- HERE: num_outputs = 2 for charge NEP models
  float* pointer = parameters;
  for (int t = 0; t < paramb.num_types; ++t) {
    ann.w0[t] = pointer;
    pointer += ann.num_neurons1 * ann.dim;
    ann.b0[t] = pointer;
    pointer += ann.num_neurons1;
    ann.w1[t] = pointer;
    pointer += ann.num_neurons1 * num_outputs;   # <-- HERE
  }
  ann.sqrt_epsilon_inf = pointer;   # <-- HERE
  pointer += 1;
  ann.b1 = pointer;
  pointer += 1;
  ann.c = pointer;
}

This partially addresses #113.

Edited by Paul Erhart

Merge request reports

Loading