docs: def structure_to_abivars(structure, **kwargs):
      """
      Receives a structure and returns a dictionary with the ABINIT variables.
      """
      if not structure.is_ordered:
          raise ValueError("""\
  Received disordered structure with partial occupancies that cannot be converted into an Abinit input
  Please use OrderDisorderedStructureTransformation or EnumerateStructureTransformation
  to build an appropriate supercell from partial occupancies or alternatively use the Virtual Crystal Approximation.""")
  
      types_of_specie = structure.types_of_specie
      natom = structure.num_sites
  
      znucl_type = [specie.number for specie in types_of_specie]
      znucl_atoms = structure.atomic_numbers
  
      typat = np.zeros(natom, np.int)
      for atm_idx, site in enumerate(structure):
          typat[atm_idx] = types_of_specie.index(site.specie) + 1
  
      rprim = ArrayWithUnit(structure.lattice.matrix, "ang").to("bohr")
      angdeg = structure.lattice.angles
      xred = np.reshape([site.frac_coords for site in structure], (-1, 3))
  
      # Set small values to zero. This usually happens when the CIF file
      # does not give structure parameters with enough digits.
      rprim = np.where(np.abs(rprim) > 1e-8, rprim, 0.0)
      xred = np.where(np.abs(xred) > 1e-8, xred, 0.0)
  
      # Info on atoms.
      d = dict(
          natom=natom,
          ntypat=len(types_of_specie),
          typat=typat,
          znucl=znucl_type,
          xred=xred,
      )
  
      # Add info on the lattice.
      # Should we use (rprim, acell) or (angdeg, acell) to specify the lattice?
      geomode = kwargs.pop("geomode", "rprim")
      if geomode == "automatic":
          geomode = "rprim"
          if structure.lattice.is_hexagonal: # or structure.lattice.is_rhombohedral
              geomode = "angdeg"
              angdeg = structure.lattice.angles
              # Here one could polish a bit the numerical values if they are not exact.
              # Note that in pmg the angles are 12, 20, 01 while in Abinit 12, 02, 01
              # One should make sure that the orientation is preserved (see Curtarolo's settings)
  
      if geomode == "rprim":
          d.update(
              acell=3 * [1.0],
              rprim=rprim,
          )
  
      elif geomode == "angdeg":
          d.update(
              acell=ArrayWithUnit(structure.lattice.abc, "ang").to("bohr"),
              angdeg=angdeg,
          )
      else:
          raise ValueError("Wrong value for geomode: %s" % geomode)
  
      return d