code: def _fadn_orth(vec, geom):
      import numpy as np
      from scipy import linalg as spla
      from ..const import PRM
      from ..error import InertiaError
      from .vector import orthonorm_check as onchk
      if not (len(geom.shape) == 1 and geom.shape[0] % 3 == 0):
          raise ValueError("Geometry is not length 3N")
      if not vec.shape == (3,):
          raise ValueError("Reference vector is not length 3")
      if spla.norm(vec) < PRM.ZERO_VEC_TOL:
          raise ValueError("Reference vector norm is too small")
      vec = vec / spla.norm(vec)
      for disp in geom.reshape((geom.shape[0]//3, 3)):
          if spla.norm(disp) >= PRM.ZERO_VEC_TOL and not onchk(
                  np.column_stack((disp / spla.norm(disp),
                  vec / spla.norm(vec))))[0]:
              out_vec = disp / spla.norm(disp)
              return out_vec
      else:
          raise InertiaError(InertiaError.BAD_GEOM,
                      "No suitable atomic displacement found", "")