librascal icon indicating copy to clipboard operation
librascal copied to clipboard

Add a function to AtomicStructure to wrap a set of user-provided positions

Open max-veit opened this issue 5 years ago • 0 comments

Prototype implementation from a PR that ended up going unused (but may be useful in the future):

    /**
     * Wrap a set of explicitly provided positions into this structure's cell
     *
     * Like wrap(), but uses a set of user-specified positions instead of the
     * atomic positions of this structure.
     *
     * @param input_positions The positions to wrap
     */
    Positions_t wrap_explicit_positions(Positions_t input_positions) {
      Positions_t scaled_positions = this->cell.inverse() * input_positions;
      auto functor{math::MakePositivePyMod(1.)};

      for (int i_dim{0}; i_dim < Dim; ++i_dim) {
        if (this->pbc[i_dim]) {
          scaled_positions.row(i_dim) =
              scaled_positions.row(i_dim).unaryExpr(functor);
        }
      }
      return this->cell * scaled_positions;
    }

Needs tests (and while we're at it, is wrap() tested?) and maybe change input_positions to a const ref since we're not modifying it.

max-veit avatar Oct 30 '19 17:10 max-veit