:py:mod:`aiida_hubbard.utils.general`
=====================================

.. py:module:: aiida_hubbard.utils.general

.. autoapi-nested-parse::

   General utilies.



Module Contents
---------------


Functions
~~~~~~~~~

.. autoapisummary::

   aiida_hubbard.utils.general.set_tot_magnetization
   aiida_hubbard.utils.general.is_perturb_only_atom
   aiida_hubbard.utils.general.distribute_base_workchains



.. py:function:: set_tot_magnetization(input_parameters: dict, tot_magnetization: float) -> bool

   Set the total magnetization based on its value and the input parameters.

   Set the `SYSTEM.tot_magnetization` parameters input equal to the round value of `tot_magnetization`.
   It returns whether the latter does not exceed within threshold from its original value.
   This is needed because `tot_magnetization` must be an integer for QuantumESPRESSO `pw.x`.


.. py:function:: is_perturb_only_atom(parameters: dict) -> int | None

   Return the index of the ``perturb_only_atom`` key associated with the ``INPUTHP`` dictionary.

   :return: atomic index (QuantumESPRESSO format), None if the key is not in parameters


.. py:function:: distribute_base_workchains(n_atoms: int, n_total: int) -> List[int]

   Distribute the maximum number of `BaseWorkChains` to be launched.

   The number of `BaseWorkChains` will be distributed over the number of atoms.
   The elements of the resulting list correspond to the number of q-point
   `BaseWorkChains` to be launched for each atom, in case q-point parallelization
   is used. Otherwise, the method will only take care of limitting the number
   of `HpParallelizeAtomsWorkChain` to be launched in parallel.

   :param n_atoms: The number of atoms.
   :param n_total: The number of base workchains to be launched.
   :return: The number of base workchains to be launched for each atom.


