From 5134fd2ad8e6d2d058ec44bff07421d5cd79a53f Mon Sep 17 00:00:00 2001 From: RandomDefaultUser Date: Thu, 18 Apr 2024 07:14:14 +0000 Subject: [PATCH] deploy: 8af3efe3933c82ce5b96b3ee4d22231ffd623385 --- CONTRIBUTE.html | 11 + _modules/mala/common/check_modules.html | 75 +- _modules/mala/common/json_serializable.html | 8 +- _modules/mala/common/parallelizer.html | 20 +- _modules/mala/common/parameters.html | 215 ++-- _modules/mala/common/physical_data.html | 254 +++-- .../datageneration/ofdft_initializer.html | 63 +- .../datageneration/trajectory_analyzer.html | 243 +++-- .../mala/datahandling/data_converter.html | 423 ++++---- _modules/mala/datahandling/data_handler.html | 568 +++++++---- .../mala/datahandling/data_handler_base.html | 121 ++- _modules/mala/datahandling/data_scaler.html | 110 +- _modules/mala/datahandling/data_shuffler.html | 526 ++++++---- .../datahandling/fast_tensor_dataset.html | 5 +- .../mala/datahandling/lazy_load_dataset.html | 130 ++- .../lazy_load_dataset_single.html | 113 ++- .../multi_lazy_load_data_loader.html | 159 +-- _modules/mala/datahandling/snapshot.html | 35 +- _modules/mala/descriptors/atomic_density.html | 177 ++-- _modules/mala/descriptors/bispectrum.html | 636 +++++++----- _modules/mala/descriptors/descriptor.html | 429 +++++--- _modules/mala/descriptors/lammps_utils.html | 12 +- .../descriptors/minterpy_descriptors.html | 150 +-- _modules/mala/interfaces/ase_calculator.html | 109 +- _modules/mala/network/acsd_analyzer.html | 776 ++++++++++----- _modules/mala/network/hyper_opt.html | 92 +- _modules/mala/network/hyper_opt_naswot.html | 136 ++- _modules/mala/network/hyper_opt_oat.html | 221 +++-- _modules/mala/network/hyper_opt_optuna.html | 225 +++-- _modules/mala/network/hyperparameter.html | 82 +- .../mala/network/hyperparameter_acsd.html | 19 +- .../mala/network/hyperparameter_naswot.html | 20 +- _modules/mala/network/hyperparameter_oat.html | 17 +- .../mala/network/hyperparameter_optuna.html | 26 +- .../mala/network/multi_training_pruner.html | 14 +- _modules/mala/network/naswot_pruner.html | 35 +- _modules/mala/network/network.html | 290 ++++-- _modules/mala/network/objective_base.html | 217 ++-- _modules/mala/network/objective_naswot.html | 62 +- _modules/mala/network/predictor.html | 159 +-- _modules/mala/network/runner.html | 189 ++-- _modules/mala/network/tester.html | 241 +++-- _modules/mala/network/trainer.html | 938 +++++++++++------- _modules/mala/targets/atomic_force.html | 3 +- .../mala/targets/calculation_helpers.html | 93 +- _modules/mala/targets/cube_parser.html | 75 +- _modules/mala/targets/density.html | 506 ++++++---- _modules/mala/targets/dos.html | 440 ++++---- _modules/mala/targets/ldos.html | 765 ++++++++------ _modules/mala/targets/target.html | 652 +++++++----- _modules/mala/targets/xsf_parser.html | 19 +- _sources/CONTRIBUTE.md.txt | 9 +- api/mala.targets.cube_parser.html | 2 +- objects.inv | Bin 6508 -> 6523 bytes searchindex.js | 2 +- 55 files changed, 6839 insertions(+), 4078 deletions(-) diff --git a/CONTRIBUTE.html b/CONTRIBUTE.html index 8b8356915..c0e662bab 100644 --- a/CONTRIBUTE.html +++ b/CONTRIBUTE.html @@ -55,6 +55,7 @@
  • Branching strategy
  • Developing code
  • @@ -183,6 +184,16 @@

    Developing codetest_examples.py

    +
    +

    Formatting code

    +
      +
    • MALA uses black for code formatting

    • +
    • The black configuration is located in pyproject.toml

    • +
    • Currently, no automatic code reformatting will be done in the CI, thus +please ensure that your code is properly formatted before creating a pull +request

    • +
    +

    Adding dependencies

    If you add additional dependencies, make sure to add them to requirements.txt diff --git a/_modules/mala/common/check_modules.html b/_modules/mala/common/check_modules.html index 004b69e2c..e8d219da7 100644 --- a/_modules/mala/common/check_modules.html +++ b/_modules/mala/common/check_modules.html @@ -75,6 +75,7 @@

    Source code for mala.common.check_modules

     """Function to check module availability in MALA."""
    +
     import importlib
     
     
    @@ -82,40 +83,62 @@ 

    Source code for mala.common.check_modules

         """Check whether/which optional modules MALA can access."""
         # The optional libs in MALA.
         optional_libs = {
    -        "mpi4py": {"available": False, "description":
    -                   "Enables inference parallelization."},
    -        "horovod": {"available": False, "description":
    -                    "Enables training parallelization."},
    -        "lammps": {"available": False, "description":
    -                   "Enables descriptor calculation for data preprocessing "
    -                   "and inference."},
    -        "oapackage": {"available": False, "description":
    -                      "Enables usage of OAT method for hyperparameter "
    -                      "optimization."},
    -        "total_energy": {"available": False, "description":
    -                         "Enables calculation of total energy."},
    -        "asap3": {"available": False, "description":
    -                  "Enables trajectory analysis."},
    -        "dftpy": {"available": False, "description":
    -                  "Enables OF-DFT-MD initialization."},
    -        "minterpy": {"available": False, "description":
    -            "Enables minterpy descriptor calculation for data preprocessing."}
    +        "mpi4py": {
    +            "available": False,
    +            "description": "Enables inference parallelization.",
    +        },
    +        "horovod": {
    +            "available": False,
    +            "description": "Enables training parallelization.",
    +        },
    +        "lammps": {
    +            "available": False,
    +            "description": "Enables descriptor calculation for data preprocessing "
    +            "and inference.",
    +        },
    +        "oapackage": {
    +            "available": False,
    +            "description": "Enables usage of OAT method for hyperparameter "
    +            "optimization.",
    +        },
    +        "total_energy": {
    +            "available": False,
    +            "description": "Enables calculation of total energy.",
    +        },
    +        "asap3": {
    +            "available": False,
    +            "description": "Enables trajectory analysis.",
    +        },
    +        "dftpy": {
    +            "available": False,
    +            "description": "Enables OF-DFT-MD initialization.",
    +        },
    +        "minterpy": {
    +            "available": False,
    +            "description": "Enables minterpy descriptor calculation for data preprocessing.",
    +        },
         }
     
         # Find out if libs are available.
         for lib in optional_libs:
    -        optional_libs[lib]["available"] = importlib.util.find_spec(lib) \
    -                                          is not None
    +        optional_libs[lib]["available"] = (
    +            importlib.util.find_spec(lib) is not None
    +        )
     
         # Print info about libs.
         print("The following optional modules are available in MALA:")
         for lib in optional_libs:
    -        available_string = "installed" if optional_libs[lib]["available"] \
    -            else "not installed"
    -        print("{0}: \t {1} \t {2}".format(lib, available_string,
    -                                          optional_libs[lib]["description"]))
    -        optional_libs[lib]["available"] = \
    -            importlib.util.find_spec(lib) is not None
    + available_string = ( + "installed" if optional_libs[lib]["available"] else "not installed" + ) + print( + "{0}: \t {1} \t {2}".format( + lib, available_string, optional_libs[lib]["description"] + ) + ) + optional_libs[lib]["available"] = ( + importlib.util.find_spec(lib) is not None + )
    diff --git a/_modules/mala/common/json_serializable.html b/_modules/mala/common/json_serializable.html index a078747c4..ea75acd41 100644 --- a/_modules/mala/common/json_serializable.html +++ b/_modules/mala/common/json_serializable.html @@ -124,14 +124,14 @@

    Source code for mala.common.json_serializable

    def _standard_serializer(self): data = {} - members = inspect.getmembers(self, - lambda a: not (inspect.isroutine(a))) + members = inspect.getmembers( + self, lambda a: not (inspect.isroutine(a)) + ) for member in members: # Filter out all private members, builtins, etc. if member[0][0] != "_": data[member[0]] = member[1] - json_dict = {"object": type(self).__name__, - "data": data} + json_dict = {"object": type(self).__name__, "data": data} return json_dict @classmethod diff --git a/_modules/mala/common/parallelizer.html b/_modules/mala/common/parallelizer.html index 265978c96..f2cafdcb4 100644 --- a/_modules/mala/common/parallelizer.html +++ b/_modules/mala/common/parallelizer.html @@ -75,6 +75,7 @@

    Source code for mala.common.parallelizer

     """Functions for operating MALA in parallel."""
    +
     from collections import defaultdict
     import platform
     import warnings
    @@ -122,8 +123,10 @@ 

    Source code for mala.common.parallelizer

     
         """
         if use_mpi is True and new_value is True:
    -        raise Exception("Cannot use horovod and inference-level MPI at "
    -                        "the same time yet.")
    +        raise Exception(
    +            "Cannot use horovod and inference-level MPI at "
    +            "the same time yet."
    +        )
         global use_horovod
         use_horovod = new_value
    @@ -142,8 +145,10 @@

    Source code for mala.common.parallelizer

     
         """
         if use_horovod is True and new_value is True:
    -        raise Exception("Cannot use horovod and inference-level MPI at "
    -                        "the same time yet.")
    +        raise Exception(
    +            "Cannot use horovod and inference-level MPI at "
    +            "the same time yet."
    +        )
         global use_mpi
         use_mpi = new_value
         if use_mpi:
    @@ -172,6 +177,7 @@ 

    Source code for mala.common.parallelizer

     
         """
         import lammps
    +
         global lammps_instance
         if isinstance(new_instance, lammps.core.lammps):
             lammps_instance = new_instance
    @@ -238,7 +244,7 @@

    Source code for mala.common.parallelizer

                 ranks_nodes = comm.allgather((comm.Get_rank(), this_node))
                 node2rankssofar = defaultdict(int)
                 local_rank = None
    -            for (rank, node) in ranks_nodes:
    +            for rank, node in ranks_nodes:
                     if rank == comm.Get_rank():
                         local_rank = node2rankssofar[node]
                     node2rankssofar[node] += 1
    @@ -280,13 +286,13 @@ 

    Source code for mala.common.parallelizer

     
    [docs]def barrier(): """General interface for a barrier.""" if use_horovod: - hvd.allreduce(torch.tensor(0), name='barrier') + hvd.allreduce(torch.tensor(0), name="barrier") if use_mpi: comm.Barrier() return
    -
    [docs]def printout(*values, sep=' ', min_verbosity=0): +
    [docs]def printout(*values, sep=" ", min_verbosity=0): """ Interface to built-in "print" for parallel runs. Can be used like print. diff --git a/_modules/mala/common/parameters.html b/_modules/mala/common/parameters.html index a0abd18c2..665e2c379 100644 --- a/_modules/mala/common/parameters.html +++ b/_modules/mala/common/parameters.html @@ -75,6 +75,7 @@

    Source code for mala.common.parameters

     """Collection of all parameter related classes and functions."""
    +
     import importlib
     import inspect
     import json
    @@ -85,15 +86,22 @@ 

    Source code for mala.common.parameters

     horovod_available = False
     try:
         import horovod.torch as hvd
    +
         horovod_available = True
     except ModuleNotFoundError:
         pass
     import numpy as np
     import torch
     
    -from mala.common.parallelizer import printout, set_horovod_status, \
    -    set_mpi_status, get_rank, get_local_rank, set_current_verbosity, \
    -    parallel_warn
    +from mala.common.parallelizer import (
    +    printout,
    +    set_horovod_status,
    +    set_mpi_status,
    +    get_rank,
    +    get_local_rank,
    +    set_current_verbosity,
    +    parallel_warn,
    +)
     from mala.common.json_serializable import JSONSerializable
     
     DEFAULT_NP_DATA_DTYPE = np.float32
    @@ -102,11 +110,19 @@ 

    Source code for mala.common.parameters

     
    [docs]class ParametersBase(JSONSerializable): """Base parameter class for MALA.""" - def __init__(self,): + def __init__( + self, + ): super(ParametersBase, self).__init__() - self._configuration = {"gpu": False, "horovod": False, "mpi": False, - "device": "cpu", "openpmd_configuration": {}, - "openpmd_granularity": 1, "lammps": True} + self._configuration = { + "gpu": False, + "horovod": False, + "mpi": False, + "device": "cpu", + "openpmd_configuration": {}, + "openpmd_granularity": 1, + "lammps": True, + } pass
    [docs] def show(self, indent=""): @@ -123,11 +139,15 @@

    Source code for mala.common.parameters

             for v in vars(self):
                 if v != "_configuration":
                     if v[0] == "_":
    -                    printout(indent + '%-15s: %s' % (v[1:], getattr(self, v)),
    -                             min_verbosity=0)
    +                    printout(
    +                        indent + "%-15s: %s" % (v[1:], getattr(self, v)),
    +                        min_verbosity=0,
    +                    )
                     else:
    -                    printout(indent + '%-15s: %s' % (v, getattr(self, v)),
    -                             min_verbosity=0)
    + printout( + indent + "%-15s: %s" % (v, getattr(self, v)), + min_verbosity=0, + )
    def _update_gpu(self, new_gpu): self._configuration["gpu"] = new_gpu @@ -168,8 +188,9 @@

    Source code for mala.common.parameters

     
             """
             json_dict = {}
    -        members = inspect.getmembers(self,
    -                                     lambda a: not (inspect.isroutine(a)))
    +        members = inspect.getmembers(
    +            self, lambda a: not (inspect.isroutine(a))
    +        )
             for member in members:
                 # Filter out all private members, builtins, etc.
                 if member[0][0] != "_":
    @@ -217,8 +238,9 @@ 

    Source code for mala.common.parameters

                 else:
                     # If it is not an elementary builtin type AND not an object
                     # dictionary, something is definitely off.
    -                raise Exception("Could not decode JSON file, error in",
    -                                json_value)
    +                raise Exception(
    +                    "Could not decode JSON file, error in", json_value
    +                )
     
     
    [docs] @classmethod def from_json(cls, json_dict): @@ -249,8 +271,9 @@

    Source code for mala.common.parameters

                         if len(json_dict[key]) > 0:
                             _member = []
                             for m in json_dict[key]:
    -                            _member.append(deserialized_object.
    -                                           _json_to_member(m))
    +                            _member.append(
    +                                deserialized_object._json_to_member(m)
    +                            )
                             setattr(deserialized_object, key, _member)
                         else:
                             setattr(deserialized_object, key, json_dict[key])
    @@ -259,16 +282,20 @@ 

    Source code for mala.common.parameters

                         if len(json_dict[key]) > 0:
                             _member = {}
                             for m in json_dict[key].keys():
    -                            _member[m] = deserialized_object.\
    -                                _json_to_member(json_dict[key][m])
    +                            _member[m] = deserialized_object._json_to_member(
    +                                json_dict[key][m]
    +                            )
                             setattr(deserialized_object, key, _member)
     
                         else:
                             setattr(deserialized_object, key, json_dict[key])
     
                     else:
    -                    setattr(deserialized_object, key, deserialized_object.
    -                            _json_to_member(json_dict[key]))
    +                    setattr(
    +                        deserialized_object,
    +                        key,
    +                        deserialized_object._json_to_member(json_dict[key]),
    +                    )
             return deserialized_object
    @@ -813,7 +840,7 @@

    Source code for mala.common.parameters

             self.use_mixed_precision = False
             self.use_graphs = False
             self.training_report_frequency = 1000
    -        self.profiler_range = None #[1000, 2000]
    +        self.profiler_range = None  # [1000, 2000]
     
         def _update_horovod(self, new_horovod):
             super(ParametersRunning, self)._update_horovod(new_horovod)
    @@ -839,8 +866,10 @@ 

    Source code for mala.common.parameters

         def during_training_metric(self, value):
             if value != "ldos":
                 if self._configuration["horovod"]:
    -                raise Exception("Currently, MALA can only operate with the "
    -                                "\"ldos\" metric for horovod runs.")
    +                raise Exception(
    +                    "Currently, MALA can only operate with the "
    +                    '"ldos" metric for horovod runs.'
    +                )
             self._during_training_metric = value
     
         @property
    @@ -862,16 +891,20 @@ 

    Source code for mala.common.parameters

         def after_before_training_metric(self, value):
             if value != "ldos":
                 if self._configuration["horovod"]:
    -                raise Exception("Currently, MALA can only operate with the "
    -                                "\"ldos\" metric for horovod runs.")
    +                raise Exception(
    +                    "Currently, MALA can only operate with the "
    +                    '"ldos" metric for horovod runs.'
    +                )
             self._after_before_training_metric = value
     
         @during_training_metric.setter
         def during_training_metric(self, value):
             if value != "ldos":
                 if self._configuration["horovod"]:
    -                raise Exception("Currently, MALA can only operate with the "
    -                                "\"ldos\" metric for horovod runs.")
    +                raise Exception(
    +                    "Currently, MALA can only operate with the "
    +                    '"ldos" metric for horovod runs.'
    +                )
             self._during_training_metric = value
     
         @property
    @@ -887,14 +920,18 @@ 

    Source code for mala.common.parameters

         @use_graphs.setter
         def use_graphs(self, value):
             if value is True:
    -            if self._configuration["gpu"] is False or \
    -                    torch.version.cuda is None:
    +            if (
    +                self._configuration["gpu"] is False
    +                or torch.version.cuda is None
    +            ):
                     parallel_warn("No CUDA or GPU found, cannot use CUDA graphs.")
                     value = False
                 else:
                     if float(torch.version.cuda) < 11.0:
    -                    raise Exception("Cannot use CUDA graphs with a CUDA"
    -                                    " version below 11.0")
    +                    raise Exception(
    +                        "Cannot use CUDA graphs with a CUDA"
    +                        " version below 11.0"
    +                    )
             self._use_graphs = value
    @@ -1030,7 +1067,7 @@

    Source code for mala.common.parameters

     
         def __init__(self):
             super(ParametersHyperparameterOptimization, self).__init__()
    -        self.direction = 'minimize'
    +        self.direction = "minimize"
             self.n_trials = 100
             self.hlist = []
             self.hyper_opt_method = "optuna"
    @@ -1110,18 +1147,24 @@ 

    Source code for mala.common.parameters

                 if v != "_configuration":
                     if v != "hlist":
                         if v[0] == "_":
    -                        printout(indent + '%-15s: %s' %
    -                                 (v[1:], getattr(self, v)), min_verbosity=0)
    +                        printout(
    +                            indent + "%-15s: %s" % (v[1:], getattr(self, v)),
    +                            min_verbosity=0,
    +                        )
                         else:
                             printout(
    -                            indent + '%-15s: %s' % (v, getattr(self, v)),
    -                            min_verbosity=0)
    +                            indent + "%-15s: %s" % (v, getattr(self, v)),
    +                            min_verbosity=0,
    +                        )
                     if v == "hlist":
                         i = 0
                         for hyp in self.hlist:
    -                        printout(indent + '%-15s: %s' %
    -                                 ("hyperparameter #"+str(i), hyp.name),
    -                                 min_verbosity=0)
    +                        printout(
    +                            indent
    +                            + "%-15s: %s"
    +                            % ("hyperparameter #" + str(i), hyp.name),
    +                            min_verbosity=0,
    +                        )
                             i += 1
    @@ -1285,7 +1328,9 @@

    Source code for mala.common.parameters

             self.targets._update_openpmd_granularity(self._openpmd_granularity)
             self.data._update_openpmd_granularity(self._openpmd_granularity)
             self.running._update_openpmd_granularity(self._openpmd_granularity)
    -        self.hyperparameters._update_openpmd_granularity(self._openpmd_granularity)
    +        self.hyperparameters._update_openpmd_granularity(
    +            self._openpmd_granularity
    +        )
     
         @property
         def verbosity(self):
    @@ -1320,8 +1365,10 @@ 

    Source code for mala.common.parameters

                 if torch.cuda.is_available():
                     self._use_gpu = True
                 else:
    -                parallel_warn("GPU requested, but no GPU found. MALA will "
    -                              "operate with CPU only.")
    +                parallel_warn(
    +                    "GPU requested, but no GPU found. MALA will "
    +                    "operate with CPU only."
    +                )
     
             # Invalidate, will be updated in setter.
             self.device = None
    @@ -1355,9 +1402,10 @@ 

    Source code for mala.common.parameters

                     self.running._update_horovod(self.use_horovod)
                     self.hyperparameters._update_horovod(self.use_horovod)
                 else:
    -                parallel_warn("Horovod requested, but not installed found. "
    -                              "MALA will operate without horovod only.")
    -
    +                parallel_warn(
    +                    "Horovod requested, but not installed found. "
    +                    "MALA will operate without horovod only."
    +                )
     
         @property
         def device(self):
    @@ -1368,8 +1416,7 @@ 

    Source code for mala.common.parameters

         def device(self, value):
             device_id = get_local_rank()
             if self.use_gpu:
    -            self._device = "cuda:"\
    -                           f"{device_id}"
    +            self._device = "cuda:" f"{device_id}"
             else:
                 self._device = "cpu"
             self.network._update_device(self._device)
    @@ -1413,11 +1460,15 @@ 

    Source code for mala.common.parameters

         def openpmd_configuration(self, value):
             self._openpmd_configuration = value
             self.network._update_openpmd_configuration(self.openpmd_configuration)
    -        self.descriptors._update_openpmd_configuration(self.openpmd_configuration)
    +        self.descriptors._update_openpmd_configuration(
    +            self.openpmd_configuration
    +        )
             self.targets._update_openpmd_configuration(self.openpmd_configuration)
             self.data._update_openpmd_configuration(self.openpmd_configuration)
             self.running._update_openpmd_configuration(self.openpmd_configuration)
    -        self.hyperparameters._update_openpmd_configuration(self.openpmd_configuration)
    +        self.hyperparameters._update_openpmd_configuration(
    +            self.openpmd_configuration
    +        )
     
         @property
         def use_lammps(self):
    @@ -1436,8 +1487,9 @@ 

    Source code for mala.common.parameters

     
     
    [docs] def show(self): """Print name and values of all attributes of this object.""" - printout("--- " + self.__doc__.split("\n")[1] + " ---", - min_verbosity=0) + printout( + "--- " + self.__doc__.split("\n")[1] + " ---", min_verbosity=0 + ) # Two for-statements so that global parameters are shown on top. for v in vars(self): @@ -1445,16 +1497,21 @@

    Source code for mala.common.parameters

                     pass
                 else:
                     if v[0] == "_":
    -                    printout('%-15s: %s' % (v[1:], getattr(self, v)),
    -                             min_verbosity=0)
    +                    printout(
    +                        "%-15s: %s" % (v[1:], getattr(self, v)),
    +                        min_verbosity=0,
    +                    )
                     else:
    -                    printout('%-15s: %s' % (v, getattr(self, v)),
    -                             min_verbosity=0)
    +                    printout(
    +                        "%-15s: %s" % (v, getattr(self, v)), min_verbosity=0
    +                    )
             for v in vars(self):
                 if isinstance(getattr(self, v), ParametersBase):
                     parobject = getattr(self, v)
    -                printout("--- " + parobject.__doc__.split("\n")[1] + " ---",
    -                         min_verbosity=0)
    +                printout(
    +                    "--- " + parobject.__doc__.split("\n")[1] + " ---",
    +                    min_verbosity=0,
    +                )
                     parobject.show("\t")
    [docs] def save(self, filename, save_format="json"): @@ -1477,14 +1534,15 @@

    Source code for mala.common.parameters

             if save_format == "pickle":
                 if filename[-3:] != "pkl":
                     filename += ".pkl"
    -            with open(filename, 'wb') as handle:
    +            with open(filename, "wb") as handle:
                     pickle.dump(self, handle, protocol=4)
             elif save_format == "json":
                 if filename[-4:] != "json":
                     filename += ".json"
                 json_dict = {}
    -            members = inspect.getmembers(self,
    -                                         lambda a: not (inspect.isroutine(a)))
    +            members = inspect.getmembers(
    +                self, lambda a: not (inspect.isroutine(a))
    +            )
     
                 # Two for loops so global properties enter the dict first.
                 for member in members:
    @@ -1556,7 +1614,7 @@ 

    Source code for mala.common.parameters

             self.use_gpu = True
             self.use_mpi = True
             device_temp = self.device
    -        sleep(get_rank()*wait_time)
    +        sleep(get_rank() * wait_time)
     
             # Now we can turn of MPI and set the device manually.
             self.use_mpi = False
    @@ -1569,8 +1627,7 @@ 

    Source code for mala.common.parameters

             self.hyperparameters._update_device(device_temp)
    [docs] @classmethod - def load_from_file(cls, file, save_format="json", - no_snapshots=False): + def load_from_file(cls, file, save_format="json", no_snapshots=False): """ Load a Parameters object from a file. @@ -1595,7 +1652,7 @@

    Source code for mala.common.parameters

             """
             if save_format == "pickle":
                 if isinstance(file, str):
    -                loaded_parameters = pickle.load(open(file, 'rb'))
    +                loaded_parameters = pickle.load(open(file, "rb"))
                 else:
                     loaded_parameters = pickle.load(file)
                 if no_snapshots is True:
    @@ -1608,19 +1665,23 @@ 

    Source code for mala.common.parameters

     
                 loaded_parameters = cls()
                 for key in json_dict:
    -                if isinstance(json_dict[key], dict) and key \
    -                        != "openpmd_configuration":
    +                if (
    +                    isinstance(json_dict[key], dict)
    +                    and key != "openpmd_configuration"
    +                ):
                         # These are the other parameter classes.
    -                    sub_parameters =\
    -                        globals()[json_dict[key]["_parameters_type"]].\
    -                        from_json(json_dict[key])
    +                    sub_parameters = globals()[
    +                        json_dict[key]["_parameters_type"]
    +                    ].from_json(json_dict[key])
                         setattr(loaded_parameters, key, sub_parameters)
     
                 # We iterate a second time, to set global values, so that they
                 # are properly forwarded.
                 for key in json_dict:
    -                if not isinstance(json_dict[key], dict) or key == \
    -                        "openpmd_configuration":
    +                if (
    +                    not isinstance(json_dict[key], dict)
    +                    or key == "openpmd_configuration"
    +                ):
                         setattr(loaded_parameters, key, json_dict[key])
                 if no_snapshots is True:
                     loaded_parameters.data.snapshot_directories_list = []
    @@ -1649,8 +1710,9 @@ 

    Source code for mala.common.parameters

                 The loaded Parameters object.
     
             """
    -        return Parameters.load_from_file(file, save_format="pickle",
    -                                         no_snapshots=no_snapshots)
    + return Parameters.load_from_file( + file, save_format="pickle", no_snapshots=no_snapshots + )
    [docs] @classmethod def load_from_json(cls, file, no_snapshots=False): @@ -1672,8 +1734,9 @@

    Source code for mala.common.parameters

                 The loaded Parameters object.
     
             """
    -        return Parameters.load_from_file(file, save_format="json",
    -                                         no_snapshots=no_snapshots)
    + return Parameters.load_from_file( + file, save_format="json", no_snapshots=no_snapshots + )
    diff --git a/_modules/mala/common/physical_data.html b/_modules/mala/common/physical_data.html index 5f496a5d4..dfcf1776a 100644 --- a/_modules/mala/common/physical_data.html +++ b/_modules/mala/common/physical_data.html @@ -75,6 +75,7 @@

    Source code for mala.common.physical_data

     """Base class for all calculators that deal with physical data."""
    +
     from abc import ABC, abstractmethod
     import os
     
    @@ -143,7 +144,9 @@ 

    Source code for mala.common.physical_data

         #   because there is no need to.
         ##############################
     
    -
    [docs] def read_from_numpy_file(self, path, units=None, array=None, reshape=False): +
    [docs] def read_from_numpy_file( + self, path, units=None, array=None, reshape=False + ): """ Read the data from a numpy file. @@ -168,17 +171,19 @@

    Source code for mala.common.physical_data

     
             """
             if array is None:
    -            loaded_array = np.load(path)[:, :, :, self._feature_mask():]
    +            loaded_array = np.load(path)[:, :, :, self._feature_mask() :]
                 self._process_loaded_array(loaded_array, units=units)
                 return loaded_array
             else:
                 if reshape:
                     array_dims = np.shape(array)
    -                array[:, :] = np.load(path)[:, :, :, self._feature_mask() :].reshape(
    -                    array_dims
    -                )
    +                array[:, :] = np.load(path)[
    +                    :, :, :, self._feature_mask() :
    +                ].reshape(array_dims)
                 else:
    -                array[:, :, :, :] = np.load(path)[:, :, :, self._feature_mask() :]
    +                array[:, :, :, :] = np.load(path)[
    +                    :, :, :, self._feature_mask() :
    +                ]
                 self._process_loaded_array(array, units=units)
    [docs] def read_from_openpmd_file(self, path, units=None, array=None): @@ -216,15 +221,19 @@

    Source code for mala.common.physical_data

             #                         {"defer_iteration_parsing": True} |
             #                         self.parameters.
             #                             _configuration["openpmd_configuration"]))
    -        options = self.parameters._configuration["openpmd_configuration"].copy()
    +        options = self.parameters._configuration[
    +            "openpmd_configuration"
    +        ].copy()
             options["defer_iteration_parsing"] = True
    -        series = io.Series(path, io.Access.read_only,
    -                           options=json.dumps(options))
    +        series = io.Series(
    +            path, io.Access.read_only, options=json.dumps(options)
    +        )
     
             # Check if this actually MALA compatible data.
             if series.get_attribute("is_mala_data") != 1:
    -            raise Exception("Non-MALA data detected, cannot work with this "
    -                            "data.")
    +            raise Exception(
    +                "Non-MALA data detected, cannot work with this data."
    +            )
     
             # A bit clanky, but this way only the FIRST iteration is loaded,
             # which is what we need for loading from a single file that
    @@ -243,24 +252,35 @@ 

    Source code for mala.common.physical_data

             # the feature dimension with 0,1,... ? I can't think of one.
             # But there may be in the future, and this'll break
             if array is None:
    -            data = np.zeros((mesh["0"].shape[0], mesh["0"].shape[1],
    -                             mesh["0"].shape[2], len(mesh)-self._feature_mask()),
    -                            dtype=mesh["0"].dtype)
    +            data = np.zeros(
    +                (
    +                    mesh["0"].shape[0],
    +                    mesh["0"].shape[1],
    +                    mesh["0"].shape[2],
    +                    len(mesh) - self._feature_mask(),
    +                ),
    +                dtype=mesh["0"].dtype,
    +            )
             else:
    -            if array.shape[0] != mesh["0"].shape[0] or \
    -               array.shape[1] != mesh["0"].shape[1] or \
    -               array.shape[2] != mesh["0"].shape[2] or \
    -               array.shape[3] != len(mesh)-self._feature_mask():
    -                raise Exception("Cannot load data into array, wrong "
    -                                "shape provided.")
    +            if (
    +                array.shape[0] != mesh["0"].shape[0]
    +                or array.shape[1] != mesh["0"].shape[1]
    +                or array.shape[2] != mesh["0"].shape[2]
    +                or array.shape[3] != len(mesh) - self._feature_mask()
    +            ):
    +                raise Exception(
    +                    "Cannot load data into array, wrong shape provided."
    +                )
     
             # Only check this once, since we do not save arrays with different
             # units throughout the feature dimension.
             # Later, we can merge this unit check with the unit conversion
             # MALA does naturally.
             if not np.isclose(mesh[str(0)].unit_SI, self.si_unit_conversion):
    -            raise Exception("MALA currently cannot operate with OpenPMD "
    -                            "files with non-MALA units.")
    +            raise Exception(
    +                "MALA currently cannot operate with OpenPMD "
    +                "files with non-MALA units."
    +            )
     
             # Deal with `granularity` items of the vectors at a time
             # Or in the openPMD layout: with `granularity` record components
    @@ -272,21 +292,35 @@ 

    Source code for mala.common.physical_data

             else:
                 array_shape = array.shape
                 data_type = array.dtype
    -        for base in range(self._feature_mask(), array_shape[3]+self._feature_mask(),
    -                          granularity):
    -            end = min(base + granularity, array_shape[3]+self._feature_mask())
    +        for base in range(
    +            self._feature_mask(),
    +            array_shape[3] + self._feature_mask(),
    +            granularity,
    +        ):
    +            end = min(
    +                base + granularity, array_shape[3] + self._feature_mask()
    +            )
                 transposed = np.empty(
                     (end - base, array_shape[0], array_shape[1], array_shape[2]),
    -                dtype=data_type)
    +                dtype=data_type,
    +            )
                 for i in range(base, end):
                     mesh[str(i)].load_chunk(transposed[i - base, :, :, :])
                 series.flush()
                 if array is None:
    -                data[:, :, :, base-self._feature_mask():end-self._feature_mask()] \
    -                    = np.transpose(transposed, axes=[1, 2, 3, 0])[:, :, :, :]
    +                data[
    +                    :,
    +                    :,
    +                    :,
    +                    base - self._feature_mask() : end - self._feature_mask(),
    +                ] = np.transpose(transposed, axes=[1, 2, 3, 0])[:, :, :, :]
                 else:
    -                array[:, :, :, base-self._feature_mask():end-self._feature_mask()] \
    -                    = np.transpose(transposed, axes=[1, 2, 3, 0])[:, :, :, :]
    +                array[
    +                    :,
    +                    :,
    +                    :,
    +                    base - self._feature_mask() : end - self._feature_mask(),
    +                ] = np.transpose(transposed, axes=[1, 2, 3, 0])[:, :, :, :]
     
             if array is None:
                 self._process_loaded_array(data, units=units)
    @@ -308,13 +342,16 @@ 

    Source code for mala.common.physical_data

             """
             loaded_array = np.load(path, mmap_mode="r")
             if read_dtype:
    -            return self._process_loaded_dimensions(np.shape(loaded_array)), \
    -                   loaded_array.dtype
    +            return (
    +                self._process_loaded_dimensions(np.shape(loaded_array)),
    +                loaded_array.dtype,
    +            )
             else:
                 return self._process_loaded_dimensions(np.shape(loaded_array))
    -
    [docs] def read_dimensions_from_openpmd_file(self, path, comm=None, - read_dtype=False): +
    [docs] def read_dimensions_from_openpmd_file( + self, path, comm=None, read_dtype=False + ): """ Read only the dimensions from a openPMD file. @@ -328,6 +365,7 @@

    Source code for mala.common.physical_data

             """
             if comm is None or comm.rank == 0:
                 import openpmd_api as io
    +
                 # The union operator for dicts is only supported starting with
                 # python 3.9. Currently, MALA works down to python 3.8; For now,
                 # I think it is good to keep it that way.
    @@ -339,17 +377,18 @@ 

    Source code for mala.common.physical_data

                 #                         self.parameters.
                 #                             _configuration["openpmd_configuration"]))
                 options = self.parameters._configuration[
    -                "openpmd_configuration"].copy()
    +                "openpmd_configuration"
    +            ].copy()
                 options["defer_iteration_parsing"] = True
    -            series = io.Series(path,
    -                               io.Access.read_only,
    -                               options=json.dumps(options))
    +            series = io.Series(
    +                path, io.Access.read_only, options=json.dumps(options)
    +            )
     
                 # Check if this actually MALA compatible data.
                 if series.get_attribute("is_mala_data") != 1:
                     raise Exception(
    -                    "Non-MALA data detected, cannot work with this "
    -                    "data.")
    +                    "Non-MALA data detected, cannot work with this data."
    +                )
     
                 # A bit clanky, but this way only the FIRST iteration is loaded,
                 # which is what we need for loading from a single file that
    @@ -359,8 +398,12 @@ 

    Source code for mala.common.physical_data

                 # and no others.
                 for current_iteration in series.read_iterations():
                     mesh = current_iteration.meshes[self.data_name]
    -                tuple_from_file = [mesh["0"].shape[0], mesh["0"].shape[1],
    -                                   mesh["0"].shape[2], len(mesh)]
    +                tuple_from_file = [
    +                    mesh["0"].shape[0],
    +                    mesh["0"].shape[1],
    +                    mesh["0"].shape[2],
    +                    len(mesh),
    +                ]
                     loaded_dtype = mesh["0"].dtype
                     break
                 series.close()
    @@ -370,8 +413,10 @@ 

    Source code for mala.common.physical_data

             if comm is not None:
                 tuple_from_file = comm.bcast(tuple_from_file, root=0)
             if read_dtype:
    -            return self._process_loaded_dimensions(tuple(tuple_from_file)), \
    -                   loaded_dtype
    +            return (
    +                self._process_loaded_dimensions(tuple(tuple_from_file)),
    +                loaded_dtype,
    +            )
             else:
                 return self._process_loaded_dimensions(tuple(tuple_from_file))
    @@ -418,8 +463,13 @@

    Source code for mala.common.physical_data

                 self.dataset = dataset
                 self.feature_size = feature_size
    -
    [docs] def write_to_openpmd_file(self, path, array, additional_attributes={}, - internal_iteration_number=0): +
    [docs] def write_to_openpmd_file( + self, + path, + array, + additional_attributes={}, + internal_iteration_number=0, + ): """ Write data to an OpenPMD file. @@ -449,21 +499,24 @@

    Source code for mala.common.physical_data

                 if file_name == file_ending:
                     path += ".h5"
                 elif file_ending not in io.file_extensions:
    -                raise Exception("Invalid file ending selected: " +
    -                                file_ending)
    +                raise Exception("Invalid file ending selected: " + file_ending)
                 if self.parameters._configuration["mpi"]:
                     series = io.Series(
                         path,
                         io.Access.create,
                         get_comm(),
                         options=json.dumps(
    -                        self.parameters._configuration["openpmd_configuration"]))
    +                        self.parameters._configuration["openpmd_configuration"]
    +                    ),
    +                )
                 else:
                     series = io.Series(
                         path,
                         io.Access.create,
                         options=json.dumps(
    -                        self.parameters._configuration["openpmd_configuration"]))
    +                        self.parameters._configuration["openpmd_configuration"]
    +                    ),
    +                )
             elif isinstance(path, io.Series):
                 series = path
     
    @@ -478,18 +531,24 @@ 

    Source code for mala.common.physical_data

             # This function may be called without the feature dimension
             # explicitly set (i.e. during testing or post-processing).
             # We have to check for that.
    -        if self.feature_size == 0 and not isinstance(array,
    -                                                     self.SkipArrayWriting):
    +        if self.feature_size == 0 and not isinstance(
    +            array, self.SkipArrayWriting
    +        ):
                 self._set_feature_size_from_array(array)
     
             self.write_to_openpmd_iteration(iteration, array)
             return series
    -
    [docs] def write_to_openpmd_iteration(self, iteration, array, - local_offset=None, - local_reach=None, - additional_metadata=None, - feature_from=0, feature_to=None): +
    [docs] def write_to_openpmd_iteration( + self, + iteration, + array, + local_offset=None, + local_reach=None, + additional_metadata=None, + feature_from=0, + feature_to=None, + ): """ Write a file within an OpenPMD iteration. @@ -532,39 +591,50 @@

    Source code for mala.common.physical_data

                 atomic_numbers = atoms_ase.get_atomic_numbers()
                 positions = io.Dataset(
                     # Need bugfix https://github.com/openPMD/openPMD-api/pull/1357
    -                atomic_positions[0].dtype if io.__version__ >= '0.15.0' else
    -                io.Datatype.DOUBLE,
    -                atomic_positions[0].shape)
    -            numbers = io.Dataset(atomic_numbers[0].dtype,
    -                                 [1])
    -            iteration.set_attribute("periodic_boundary_conditions_x",
    -                                    atoms_ase.pbc[0])
    -            iteration.set_attribute("periodic_boundary_conditions_y",
    -                                    atoms_ase.pbc[1])
    -            iteration.set_attribute("periodic_boundary_conditions_z",
    -                                    atoms_ase.pbc[2])
    +                (
    +                    atomic_positions[0].dtype
    +                    if io.__version__ >= "0.15.0"
    +                    else io.Datatype.DOUBLE
    +                ),
    +                atomic_positions[0].shape,
    +            )
    +            numbers = io.Dataset(atomic_numbers[0].dtype, [1])
    +            iteration.set_attribute(
    +                "periodic_boundary_conditions_x", atoms_ase.pbc[0]
    +            )
    +            iteration.set_attribute(
    +                "periodic_boundary_conditions_y", atoms_ase.pbc[1]
    +            )
    +            iteration.set_attribute(
    +                "periodic_boundary_conditions_z", atoms_ase.pbc[2]
    +            )
                 # atoms_openpmd["position"].time_offset = 0.0
                 # atoms_openpmd["positionOffset"].time_offset = 0.0
                 for atom in range(0, len(atoms_ase)):
                     atoms_openpmd["position"][str(atom)].reset_dataset(positions)
                     atoms_openpmd["number"][str(atom)].reset_dataset(numbers)
    -                atoms_openpmd["positionOffset"][str(atom)].reset_dataset(positions)
    +                atoms_openpmd["positionOffset"][str(atom)].reset_dataset(
    +                    positions
    +                )
     
                     atoms_openpmd_position = atoms_openpmd["position"][str(atom)]
                     atoms_openpmd_number = atoms_openpmd["number"][str(atom)]
                     if get_rank() == 0:
                         atoms_openpmd_position.store_chunk(atomic_positions[atom])
                         atoms_openpmd_number.store_chunk(
    -                        np.array([atomic_numbers[atom]]))
    +                        np.array([atomic_numbers[atom]])
    +                    )
                     atoms_openpmd["positionOffset"][str(atom)].make_constant(0)
     
                     # Positions are stored in Angstrom.
                     atoms_openpmd["position"][str(atom)].unit_SI = 1.0e-10
                     atoms_openpmd["positionOffset"][str(atom)].unit_SI = 1.0e-10
     
    -        dataset = array.dataset if isinstance(
    -            array, self.SkipArrayWriting) else io.Dataset(
    -                array.dtype, self.grid_dimensions)
    +        dataset = (
    +            array.dataset
    +            if isinstance(array, self.SkipArrayWriting)
    +            else io.Dataset(array.dtype, self.grid_dimensions)
    +        )
     
             # Global feature sizes:
             feature_global_from = 0
    @@ -592,11 +662,14 @@ 

    Source code for mala.common.physical_data

                 feature_to = array.shape[3]
     
             if feature_to - feature_from != array.shape[3]:
    -            raise RuntimeError("""\
    -[write_to_openpmd_iteration] Internal error, called function with
    -wrong parameters. Specification of features ({} - {}) on rank {} does not
    -match the array dimensions (extent {} in the feature dimension)""".format(
    -                feature_from, feature_to, get_rank(), array.shape[3]))
    +            raise RuntimeError(
    +                """\
    +[write_to_openpmd_iteration] Internal error, called function with
    +wrong parameters. Specification of features ({} - {}) on rank {} does not
    +match the array dimensions (extent {} in the feature dimension)""".format(
    +                    feature_from, feature_to, get_rank(), array.shape[3]
    +                )
    +            )
     
             # See above - will currently break for density of states,
             # which is something we never do though anyway.
    @@ -614,9 +687,11 @@ 

    Source code for mala.common.physical_data

             #    features are written from all ranks.
             if self.parameters._configuration["mpi"]:
                 from mpi4py import MPI
    +
                 my_iteration_count = len(range(0, array.shape[3], granularity))
    -            highest_iteration_count = get_comm().allreduce(my_iteration_count,
    -                                                           op=MPI.MAX)
    +            highest_iteration_count = get_comm().allreduce(
    +                my_iteration_count, op=MPI.MAX
    +            )
                 extra_flushes = highest_iteration_count - my_iteration_count
             else:
                 extra_flushes = 0
    @@ -624,8 +699,9 @@ 

    Source code for mala.common.physical_data

             # Second loop: Write heavy data
             for base in range(0, array.shape[3], granularity):
                 end = min(base + granularity, array.shape[3])
    -            transposed = \
    -                np.transpose(array[:, :, :, base:end], axes=[3, 0, 1, 2]).copy()
    +            transposed = np.transpose(
    +                array[:, :, :, base:end], axes=[3, 0, 1, 2]
    +            ).copy()
                 for i in range(base, end):
                     # i is the index within the array passed to this function.
                     # The feature corresponding to this index is offset
    @@ -633,8 +709,9 @@ 

    Source code for mala.common.physical_data

                     current_feature = i + feature_from
                     mesh_component = mesh[str(current_feature)]
     
    -                mesh_component[x_from:x_to, y_from:y_to, z_from:z_to] = \
    +                mesh_component[x_from:x_to, y_from:y_to, z_from:z_to] = (
                         transposed[i - base, :, :, :]
    +                )
     
                 iteration.series_flush()
     
    @@ -679,9 +756,9 @@ 

    Source code for mala.common.physical_data

             # MALA internally operates in Angstrom (10^-10 m)
             mesh.grid_unit_SI = 1e-10
     
    -        mesh.comment = \
    -            "This is a special geometry, " \
    -            "based on the cartesian geometry."
    +        mesh.comment = (
    +            "This is a special geometry, based on the cartesian geometry."
    +        )
     
             # Fill geometry information (if provided)
             self._set_geometry_info(mesh)
    @@ -698,8 +775,9 @@ 

    Source code for mala.common.physical_data

             return None
     
         @staticmethod
    -    def _get_attribute_if_attribute_exists(iteration, attribute,
    -                                           default_value=None):
    +    def _get_attribute_if_attribute_exists(
    +        iteration, attribute, default_value=None
    +    ):
             if attribute in iteration.attributes:
                 return iteration.get_attribute(attribute)
             else:
    diff --git a/_modules/mala/datageneration/ofdft_initializer.html b/_modules/mala/datageneration/ofdft_initializer.html
    index 9844edf9c..24882061a 100644
    --- a/_modules/mala/datageneration/ofdft_initializer.html
    +++ b/_modules/mala/datageneration/ofdft_initializer.html
    @@ -75,6 +75,7 @@
                  
       

    Source code for mala.datageneration.ofdft_initializer

     """Tools for initializing a (ML)-DFT trajectory with OF-DFT."""
    +
     from warnings import warn
     
     from ase import units
    @@ -83,6 +84,7 @@ 

    Source code for mala.datageneration.ofdft_initializer

    from ase.md.langevin import Langevin from ase.io.trajectory import Trajectory from ase.md.velocitydistribution import MaxwellBoltzmannDistribution + try: from dftpy.api.api4ase import DFTpyCalculator from dftpy.config import DefaultOption, OptionFormat @@ -105,25 +107,29 @@

    Source code for mala.datageneration.ofdft_initializer

    """ def __init__(self, parameters, atoms): - warn("The class OFDFTInitializer is experimental. The algorithms " - "within have been tested, but the API may still be subject to " - "large changes.") + warn( + "The class OFDFTInitializer is experimental. The algorithms " + "within have been tested, but the API may still be subject to " + "large changes." + ) self.atoms = atoms self.params = parameters.datageneration # Check that only one element is used in the atoms. number_of_elements = len(set([x.symbol for x in self.atoms])) if number_of_elements > 1: - raise Exception("OF-DFT-MD initialization can only work with one" - " element.") + raise Exception( + "OF-DFT-MD initialization can only work with one element." + ) self.dftpy_configuration = DefaultOption() - self.dftpy_configuration['PATH']['pppath'] = self.params.local_psp_path - self.dftpy_configuration['PP'][self.atoms[0].symbol] = \ - self.params.local_psp_name - self.dftpy_configuration['OPT']['method'] = self.params.ofdft_kedf - self.dftpy_configuration['KEDF']['kedf'] = 'WT' - self.dftpy_configuration['JOB']['calctype'] = 'Energy Force' + self.dftpy_configuration["PATH"]["pppath"] = self.params.local_psp_path + self.dftpy_configuration["PP"][ + self.atoms[0].symbol + ] = self.params.local_psp_name + self.dftpy_configuration["OPT"]["method"] = self.params.ofdft_kedf + self.dftpy_configuration["KEDF"]["kedf"] = "WT" + self.dftpy_configuration["JOB"]["calctype"] = "Energy Force"
    [docs] def get_equilibrated_configuration(self, logging_period=None): """ @@ -143,20 +149,33 @@

    Source code for mala.datageneration.ofdft_initializer

    self.atoms.set_calculator(calc) # Create the initial velocities, and dynamics object. - MaxwellBoltzmannDistribution(self.atoms, - temperature_K= - self.params.ofdft_temperature, - force_temp=True) - dyn = Langevin(self.atoms, self.params.ofdft_timestep * units.fs, - temperature_K=self.params.ofdft_temperature, - friction=self.params.ofdft_friction) + MaxwellBoltzmannDistribution( + self.atoms, + temperature_K=self.params.ofdft_temperature, + force_temp=True, + ) + dyn = Langevin( + self.atoms, + self.params.ofdft_timestep * units.fs, + temperature_K=self.params.ofdft_temperature, + friction=self.params.ofdft_friction, + ) # If logging is desired, do the logging. if logging_period is not None: - dyn.attach(MDLogger(dyn, self.atoms, 'mala_of_dft_md.log', - header=False, stress=False, peratom=True, - mode="w"), interval=logging_period) - traj = Trajectory('mala_of_dft_md.traj', 'w', self.atoms) + dyn.attach( + MDLogger( + dyn, + self.atoms, + "mala_of_dft_md.log", + header=False, + stress=False, + peratom=True, + mode="w", + ), + interval=logging_period, + ) + traj = Trajectory("mala_of_dft_md.traj", "w", self.atoms) dyn.attach(traj.write, interval=logging_period) diff --git a/_modules/mala/datageneration/trajectory_analyzer.html b/_modules/mala/datageneration/trajectory_analyzer.html index aa82df007..d3ac61840 100644 --- a/_modules/mala/datageneration/trajectory_analyzer.html +++ b/_modules/mala/datageneration/trajectory_analyzer.html @@ -75,6 +75,7 @@

    Source code for mala.datageneration.trajectory_analyzer

     """Tools for analyzing a trajectory."""
    +
     from functools import cached_property
     import os
     from warnings import warn
    @@ -106,12 +107,20 @@ 

    Source code for mala.datageneration.trajectory_analyzer

    one will be generated ad-hoc (recommended). """ - def __init__(self, parameters, trajectory, temperatures=None, - target_calculator=None, target_temperature=None, - malada_compatability=False): - warn("The class TrajectoryAnalyzer is experimental. The algorithms " - "within have been tested, but the API may still be subject to " - "large changes.") + def __init__( + self, + parameters, + trajectory, + temperatures=None, + target_calculator=None, + target_temperature=None, + malada_compatability=False, + ): + warn( + "The class TrajectoryAnalyzer is experimental. The algorithms " + "within have been tested, but the API may still be subject to " + "large changes." + ) self.params: ParametersDataGeneration = parameters.datageneration @@ -187,8 +196,9 @@

    Source code for mala.datageneration.trajectory_analyzer

    """Cutoff for the snapshot correlation analysis.""" return self.get_snapshot_correlation_cutoff() -
    [docs] def get_first_snapshot(self, equilibrated_snapshot=None, - distance_threshold=None): +
    [docs] def get_first_snapshot( + self, equilibrated_snapshot=None, distance_threshold=None + ): """ Calculate distance metrics/first equilibrated timestep on a trajectory. @@ -220,39 +230,55 @@

    Source code for mala.datageneration.trajectory_analyzer

    if equilibrated_snapshot is None: equilibrated_snapshot = self.trajectory[-1] for idx, step in enumerate(self.trajectory): - self.distance_metrics.append(self. - _calculate_distance_between_snapshots - (equilibrated_snapshot, step, "rdf", - "cosine_distance", save_rdf1=True)) + self.distance_metrics.append( + self._calculate_distance_between_snapshots( + equilibrated_snapshot, + step, + "rdf", + "cosine_distance", + save_rdf1=True, + ) + ) # Now, we denoise the distance metrics. self.distance_metrics_denoised = self.__denoise(self.distance_metrics) # Which snapshots are considered depends on how we denoise the # distance metrics. - self.first_considered_snapshot = \ - self.params.trajectory_analysis_denoising_width - self.last_considered_snapshot = \ - np.shape(self.distance_metrics_denoised)[0]-\ + self.first_considered_snapshot = ( self.params.trajectory_analysis_denoising_width - considered_length = self.last_considered_snapshot - \ - self.first_considered_snapshot + ) + self.last_considered_snapshot = ( + np.shape(self.distance_metrics_denoised)[0] + - self.params.trajectory_analysis_denoising_width + ) + considered_length = ( + self.last_considered_snapshot - self.first_considered_snapshot + ) # Next, the average of the presumed equilibrated part is calculated, # and then the first N number of times teps which are below this # average is calculated. self.average_distance_equilibrated = distance_threshold if self.average_distance_equilibrated is None: - self.average_distance_equilibrated = \ - np.mean(self.distance_metrics_denoised[considered_length - - int(self.params.trajectory_analysis_estimated_equilibrium * considered_length): - self.last_considered_snapshot]) + self.average_distance_equilibrated = np.mean( + self.distance_metrics_denoised[ + considered_length + - int( + self.params.trajectory_analysis_estimated_equilibrium + * considered_length + ) : self.last_considered_snapshot + ] + ) is_below = True counter = 0 first_snapshot = None for idx, dist in enumerate(self.distance_metrics_denoised): - if self.first_considered_snapshot <= idx \ - <= self.last_considered_snapshot: + if ( + self.first_considered_snapshot + <= idx + <= self.last_considered_snapshot + ): if is_below: counter += 1 if dist < self.average_distance_equilibrated: @@ -260,12 +286,16 @@

    Source code for mala.datageneration.trajectory_analyzer

    if dist >= self.average_distance_equilibrated: counter = 0 is_below = False - if counter == self.params.\ - trajectory_analysis_below_average_counter: + if ( + counter + == self.params.trajectory_analysis_below_average_counter + ): first_snapshot = idx break - printout("First equilibrated timestep of trajectory is", first_snapshot) + printout( + "First equilibrated timestep of trajectory is", first_snapshot + ) return first_snapshot
    [docs] def get_snapshot_correlation_cutoff(self): @@ -307,100 +337,134 @@

    Source code for mala.datageneration.trajectory_analyzer

    filename_uncorrelated_snapshots : string Name of the file in which to save the uncorrelated snapshots. """ - filename_base = \ - os.path.basename(filename_uncorrelated_snapshots).split(".")[0] - allowed_temp_diff_K = (self.params. - trajectory_analysis_temperature_tolerance_percent - / 100) * self.target_calculator.temperature + filename_base = os.path.basename( + filename_uncorrelated_snapshots + ).split(".")[0] + allowed_temp_diff_K = ( + self.params.trajectory_analysis_temperature_tolerance_percent / 100 + ) * self.target_calculator.temperature current_snapshot = self.first_snapshot - begin_snapshot = self.first_snapshot+1 + begin_snapshot = self.first_snapshot + 1 end_snapshot = len(self.trajectory) j = 0 md_iteration = [] for i in range(begin_snapshot, end_snapshot): - if self.__check_if_snapshot_is_valid(self.trajectory[i], - self.temperatures[i], - self.trajectory[current_snapshot], - self.temperatures[current_snapshot], - self.snapshot_correlation_cutoff, - allowed_temp_diff_K): + if self.__check_if_snapshot_is_valid( + self.trajectory[i], + self.temperatures[i], + self.trajectory[current_snapshot], + self.temperatures[current_snapshot], + self.snapshot_correlation_cutoff, + allowed_temp_diff_K, + ): current_snapshot = i md_iteration.append(current_snapshot) j += 1 np.random.shuffle(md_iteration) for i in range(0, len(md_iteration)): if i == 0: - traj_writer = TrajectoryWriter(filename_base+".traj", mode='w') + traj_writer = TrajectoryWriter( + filename_base + ".traj", mode="w" + ) else: - traj_writer = TrajectoryWriter(filename_base+".traj", mode='a') - atoms_to_write = Descriptor.enforce_pbc(self.trajectory[md_iteration[i]]) + traj_writer = TrajectoryWriter( + filename_base + ".traj", mode="a" + ) + atoms_to_write = Descriptor.enforce_pbc( + self.trajectory[md_iteration[i]] + ) traj_writer.write(atoms=atoms_to_write) - np.save(filename_base+"_numbers.npy", md_iteration) + np.save(filename_base + "_numbers.npy", md_iteration) printout(j, "possible snapshots found in MD trajectory.")
    def _analyze_distance_metric(self, trajectory): # distance metric usefdfor the snapshot parsing (realspace similarity # of the snapshot), we first find the center of the equilibrated part # of the trajectory and calculate the differences w.r.t to to it. - center = int((np.shape(self.distance_metrics_denoised)[ - 0] - self.first_snapshot) / 2) + self.first_snapshot + center = ( + int( + ( + np.shape(self.distance_metrics_denoised)[0] + - self.first_snapshot + ) + / 2 + ) + + self.first_snapshot + ) width = int( - self.params.trajectory_analysis_estimated_equilibrium * - np.shape(self.distance_metrics_denoised)[0]) + self.params.trajectory_analysis_estimated_equilibrium + * np.shape(self.distance_metrics_denoised)[0] + ) self.distances_realspace = [] self.__saved_rdf = None for i in range(center - width, center + width): self.distances_realspace.append( self._calculate_distance_between_snapshots( - trajectory[center], trajectory[i], - "realspace", "minimal_distance", save_rdf1=True)) + trajectory[center], + trajectory[i], + "realspace", + "minimal_distance", + save_rdf1=True, + ) + ) # From these metrics, we assume mean - 2.576 std as limit. # This translates to a confidence interval of ~99%, which should # make any coincidental similarites unlikely. cutoff = np.mean(self.distances_realspace) - 2.576 * np.std( - self.distances_realspace) + self.distances_realspace + ) printout("Distance metric cutoff is", cutoff) return cutoff - def _calculate_distance_between_snapshots(self, snapshot1, snapshot2, - distance_metric, reduction, - save_rdf1=False): + def _calculate_distance_between_snapshots( + self, + snapshot1, + snapshot2, + distance_metric, + reduction, + save_rdf1=False, + ): if distance_metric == "realspace": positions1 = snapshot1.get_positions() positions2 = snapshot2.get_positions() if reduction == "minimal_distance": - result = np.amin(distance.cdist(positions1, positions2), - axis=0) + result = np.amin( + distance.cdist(positions1, positions2), axis=0 + ) result = np.mean(result) elif reduction == "cosine_distance": number_of_atoms = snapshot1.get_number_of_atoms() - result = distance.cosine(np.reshape(positions1, - [number_of_atoms*3]), - np.reshape(positions2, - [number_of_atoms*3])) + result = distance.cosine( + np.reshape(positions1, [number_of_atoms * 3]), + np.reshape(positions2, [number_of_atoms * 3]), + ) else: raise Exception("Unknown distance metric reduction.") elif distance_metric == "rdf": if save_rdf1 is True: if self.__saved_rdf is None: - self.__saved_rdf = self.target_calculator.\ - get_radial_distribution_function(snapshot1, - method="asap3")[0] + self.__saved_rdf = self.target_calculator.get_radial_distribution_function( + snapshot1, method="asap3" + )[ + 0 + ] rdf1 = self.__saved_rdf else: - rdf1 = self.target_calculator.\ - get_radial_distribution_function(snapshot1, - method="asap3")[0] - rdf2 = self.target_calculator.\ - get_radial_distribution_function(snapshot2, - method="asap3")[0] + rdf1 = self.target_calculator.get_radial_distribution_function( + snapshot1, method="asap3" + )[0] + rdf2 = self.target_calculator.get_radial_distribution_function( + snapshot2, method="asap3" + )[0] if reduction == "minimal_distance": - raise Exception("Combination of distance metric and reduction " - "not supported.") + raise Exception( + "Combination of distance metric and reduction " + "not supported." + ) elif reduction == "cosine_distance": result = distance.cosine(rdf1, rdf2) @@ -413,29 +477,34 @@

    Source code for mala.datageneration.trajectory_analyzer

    return result def __denoise(self, signal): - denoised_signal = np.convolve(signal, np.ones( - self.params.trajectory_analysis_denoising_width) - / self.params. - trajectory_analysis_denoising_width, - mode='same') + denoised_signal = np.convolve( + signal, + np.ones(self.params.trajectory_analysis_denoising_width) + / self.params.trajectory_analysis_denoising_width, + mode="same", + ) return denoised_signal - def __check_if_snapshot_is_valid(self, snapshot_to_test, temp_to_test, - reference_snapshot, reference_temp, - distance_metric, - allowed_temp_diff): - distance = self.\ - _calculate_distance_between_snapshots(snapshot_to_test, - reference_snapshot, - "realspace", - "minimal_distance") - temp_diff = np.abs(temp_to_test-reference_temp) + def __check_if_snapshot_is_valid( + self, + snapshot_to_test, + temp_to_test, + reference_snapshot, + reference_temp, + distance_metric, + allowed_temp_diff, + ): + distance = self._calculate_distance_between_snapshots( + snapshot_to_test, + reference_snapshot, + "realspace", + "minimal_distance", + ) + temp_diff = np.abs(temp_to_test - reference_temp) if distance > distance_metric and temp_diff < allowed_temp_diff: return True else: return False
    - -
    diff --git a/_modules/mala/datahandling/data_converter.html b/_modules/mala/datahandling/data_converter.html index 9a6c42bba..bfef50be1 100644 --- a/_modules/mala/datahandling/data_converter.html +++ b/_modules/mala/datahandling/data_converter.html @@ -75,6 +75,7 @@

    Source code for mala.datahandling.data_converter

     """DataConverter class for converting snapshots into numpy arrays."""
    +
     import os
     
     import json
    @@ -85,15 +86,9 @@ 

    Source code for mala.datahandling.data_converter

    from mala.targets.target import Target from mala.version import __version__ as mala_version -descriptor_input_types = [ - "espresso-out" -] -target_input_types = [ - ".cube", ".xsf" -] -additional_info_input_types = [ - "espresso-out" -] +descriptor_input_types = ["espresso-out"] +target_input_types = [".cube", ".xsf"] +additional_info_input_types = ["espresso-out"]
    [docs]class DataConverter: @@ -126,8 +121,9 @@

    Source code for mala.datahandling.data_converter

    Target calculator used for parsing/converting target data. """ - def __init__(self, parameters, descriptor_calculator=None, - target_calculator=None): + def __init__( + self, parameters, descriptor_calculator=None, target_calculator=None + ): self.parameters: ParametersData = parameters.data self.parameters_full = parameters self.target_calculator = target_calculator @@ -140,8 +136,9 @@

    Source code for mala.datahandling.data_converter

    if parameters.descriptors.use_z_splitting: parameters.descriptors.use_z_splitting = False - printout("Disabling z-splitting for preprocessing.", - min_verbosity=0) + printout( + "Disabling z-splitting for preprocessing.", min_verbosity=0 + ) self.__snapshots_to_convert = [] self.__snapshot_description = [] @@ -152,16 +149,19 @@

    Source code for mala.datahandling.data_converter

    self.process_targets = False self.process_additional_info = False -
    [docs] def add_snapshot(self, descriptor_input_type=None, - descriptor_input_path=None, - target_input_type=None, - target_input_path=None, - additional_info_input_type=None, - additional_info_input_path=None, - descriptor_units=None, - metadata_input_type=None, - metadata_input_path=None, - target_units=None): +
    [docs] def add_snapshot( + self, + descriptor_input_type=None, + descriptor_input_path=None, + target_input_type=None, + target_input_path=None, + additional_info_input_type=None, + additional_info_input_path=None, + descriptor_units=None, + metadata_input_type=None, + metadata_input_path=None, + target_units=None, + ): """ Add a snapshot to be processed. @@ -215,17 +215,17 @@

    Source code for mala.datahandling.data_converter

    if descriptor_input_type is not None: if descriptor_input_path is None: raise Exception( - "Cannot process descriptor data with no path " - "given.") + "Cannot process descriptor data with no path given." + ) if descriptor_input_type not in descriptor_input_types: - raise Exception( - "Cannot process this type of descriptor data.") + raise Exception("Cannot process this type of descriptor data.") self.process_descriptors = True if target_input_type is not None: if target_input_path is None: - raise Exception("Cannot process target data with no path " - "given.") + raise Exception( + "Cannot process target data with no path given." + ) if target_input_type not in target_input_types: raise Exception("Cannot process this type of target data.") self.process_targets = True @@ -233,48 +233,63 @@

    Source code for mala.datahandling.data_converter

    if additional_info_input_type is not None: metadata_input_type = additional_info_input_type if additional_info_input_path is None: - raise Exception("Cannot process additional info data with " - "no path given.") + raise Exception( + "Cannot process additional info data with " + "no path given." + ) if additional_info_input_type not in additional_info_input_types: raise Exception( - "Cannot process this type of additional info " - "data.") + "Cannot process this type of additional info data." + ) self.process_additional_info = True metadata_input_path = additional_info_input_path if metadata_input_type is not None: if metadata_input_path is None: - raise Exception("Cannot process additional info data with " - "no path given.") + raise Exception( + "Cannot process additional info data with " + "no path given." + ) if metadata_input_type not in additional_info_input_types: raise Exception( - "Cannot process this type of additional info " - "data.") + "Cannot process this type of additional info data." + ) # Assign info. - self.__snapshots_to_convert.append({"input": descriptor_input_path, - "output": target_input_path, - "additional_info": - additional_info_input_path, - "metadata": metadata_input_path}) - self.__snapshot_description.append({"input": descriptor_input_type, - "output": target_input_type, - "additional_info": - additional_info_input_type, - "metadata": metadata_input_type}) - self.__snapshot_units.append({"input": descriptor_units, - "output": target_units})
    - -
    [docs] def convert_snapshots(self, complete_save_path=None, - descriptor_save_path=None, - target_save_path=None, - additional_info_save_path=None, - naming_scheme="ELEM_snapshot*.npy", starts_at=0, - file_based_communication=False, - descriptor_calculation_kwargs=None, - target_calculator_kwargs=None, - use_fp64=False): + self.__snapshots_to_convert.append( + { + "input": descriptor_input_path, + "output": target_input_path, + "additional_info": additional_info_input_path, + "metadata": metadata_input_path, + } + ) + self.__snapshot_description.append( + { + "input": descriptor_input_type, + "output": target_input_type, + "additional_info": additional_info_input_type, + "metadata": metadata_input_type, + } + ) + self.__snapshot_units.append( + {"input": descriptor_units, "output": target_units} + )
    + +
    [docs] def convert_snapshots( + self, + complete_save_path=None, + descriptor_save_path=None, + target_save_path=None, + additional_info_save_path=None, + naming_scheme="ELEM_snapshot*.npy", + starts_at=0, + file_based_communication=False, + descriptor_calculation_kwargs=None, + target_calculator_kwargs=None, + use_fp64=False, + ): """ Convert the snapshots in the list to numpy arrays. @@ -333,8 +348,9 @@

    Source code for mala.datahandling.data_converter

    import openpmd_api as io if file_ending not in io.file_extensions: - raise Exception("Invalid file ending selected: " + - file_ending) + raise Exception( + "Invalid file ending selected: " + file_ending + ) else: file_ending = "npy" @@ -360,14 +376,24 @@

    Source code for mala.datahandling.data_converter

    additional_info_save_path = complete_save_path else: if self.process_targets is True and target_save_path is None: - raise Exception("No target path specified, cannot process " - "data.") - if self.process_descriptors is True and descriptor_save_path is None: - raise Exception("No descriptor path specified, cannot " - "process data.") - if self.process_additional_info is True and additional_info_save_path is None: - raise Exception("No additional info path specified, cannot " - "process data.") + raise Exception( + "No target path specified, cannot process data." + ) + if ( + self.process_descriptors is True + and descriptor_save_path is None + ): + raise Exception( + "No descriptor path specified, cannot process data." + ) + if ( + self.process_additional_info is True + and additional_info_save_path is None + ): + raise Exception( + "No additional info path specified, cannot " + "process data." + ) if file_ending != "npy": snapshot_name = naming_scheme @@ -376,19 +402,27 @@

    Source code for mala.datahandling.data_converter

    if self.process_descriptors: if self.parameters._configuration["mpi"]: input_series = io.Series( - os.path.join(descriptor_save_path, - series_name + ".in." + file_ending), + os.path.join( + descriptor_save_path, + series_name + ".in." + file_ending, + ), io.Access.create, get_comm(), options=json.dumps( - self.parameters_full.openpmd_configuration)) + self.parameters_full.openpmd_configuration + ), + ) else: input_series = io.Series( - os.path.join(descriptor_save_path, - series_name + ".in." + file_ending), + os.path.join( + descriptor_save_path, + series_name + ".in." + file_ending, + ), io.Access.create, options=json.dumps( - self.parameters_full.openpmd_configuration)) + self.parameters_full.openpmd_configuration + ), + ) input_series.set_attribute("is_mala_data", 1) input_series.set_software(name="MALA", version="x.x.x") input_series.author = "..." @@ -396,19 +430,27 @@

    Source code for mala.datahandling.data_converter

    if self.process_targets: if self.parameters._configuration["mpi"]: output_series = io.Series( - os.path.join(target_save_path, - series_name + ".out." + file_ending), + os.path.join( + target_save_path, + series_name + ".out." + file_ending, + ), io.Access.create, get_comm(), options=json.dumps( - self.parameters_full.openpmd_configuration)) + self.parameters_full.openpmd_configuration + ), + ) else: output_series = io.Series( - os.path.join(target_save_path, - series_name + ".out." + file_ending), + os.path.join( + target_save_path, + series_name + ".out." + file_ending, + ), io.Access.create, options=json.dumps( - self.parameters_full.openpmd_configuration)) + self.parameters_full.openpmd_configuration + ), + ) output_series.set_attribute("is_mala_data", 1) output_series.set_software(name="MALA", version=mala_version) @@ -421,8 +463,9 @@

    Source code for mala.datahandling.data_converter

    # Create the paths as needed. if self.process_additional_info: - info_path = os.path.join(additional_info_save_path, - snapshot_name + ".info.json") + info_path = os.path.join( + additional_info_save_path, snapshot_name + ".info.json" + ) else: info_path = None input_iteration = None @@ -431,22 +474,27 @@

    Source code for mala.datahandling.data_converter

    if file_ending == "npy": # Create the actual paths, if needed. if self.process_descriptors: - descriptor_path = os.path.join(descriptor_save_path, - snapshot_name + ".in." + - file_ending) + descriptor_path = os.path.join( + descriptor_save_path, + snapshot_name + ".in." + file_ending, + ) else: descriptor_path = None memmap = None if self.process_targets: - target_path = os.path.join(target_save_path, - snapshot_name + ".out."+ - file_ending) + target_path = os.path.join( + target_save_path, + snapshot_name + ".out." + file_ending, + ) # A memory mapped file is used as buffer for distributed cases. - if self.parameters._configuration["mpi"] and \ - file_based_communication: - memmap = os.path.join(target_save_path, snapshot_name + - ".out.npy_temp") + if ( + self.parameters._configuration["mpi"] + and file_based_communication + ): + memmap = os.path.join( + target_save_path, snapshot_name + ".out.npy_temp" + ) else: target_path = None else: @@ -454,27 +502,36 @@

    Source code for mala.datahandling.data_converter

    target_path = None memmap = None if self.process_descriptors: - input_iteration = input_series.write_iterations()[i + starts_at] + input_iteration = input_series.write_iterations()[ + i + starts_at + ] input_iteration.dt = i + starts_at input_iteration.time = 0 if self.process_targets: - output_iteration = output_series.write_iterations()[i + starts_at] + output_iteration = output_series.write_iterations()[ + i + starts_at + ] output_iteration.dt = i + starts_at output_iteration.time = 0 - self.__convert_single_snapshot(i, descriptor_calculation_kwargs, - target_calculator_kwargs, - input_path=descriptor_path, - output_path=target_path, - use_memmap=memmap, - input_iteration=input_iteration, - output_iteration=output_iteration, - additional_info_path=info_path, - use_fp64=use_fp64) + self.__convert_single_snapshot( + i, + descriptor_calculation_kwargs, + target_calculator_kwargs, + input_path=descriptor_path, + output_path=target_path, + use_memmap=memmap, + input_iteration=input_iteration, + output_iteration=output_iteration, + additional_info_path=info_path, + use_fp64=use_fp64, + ) if get_rank() == 0: - if self.parameters._configuration["mpi"] \ - and file_based_communication: + if ( + self.parameters._configuration["mpi"] + and file_based_communication + ): os.remove(memmap) # Properly close series @@ -484,16 +541,19 @@

    Source code for mala.datahandling.data_converter

    if self.process_targets: del output_series
    - def __convert_single_snapshot(self, snapshot_number, - descriptor_calculation_kwargs, - target_calculator_kwargs, - input_path=None, - output_path=None, - additional_info_path=None, - use_memmap=None, - output_iteration=None, - input_iteration=None, - use_fp64=False): + def __convert_single_snapshot( + self, + snapshot_number, + descriptor_calculation_kwargs, + target_calculator_kwargs, + input_path=None, + output_path=None, + additional_info_path=None, + use_memmap=None, + output_iteration=None, + input_iteration=None, + use_fp64=False, + ): """ Convert single snapshot from the conversion lists. @@ -557,39 +617,49 @@

    Source code for mala.datahandling.data_converter

    descriptor_calculation_kwargs["units"] = original_units["input"] descriptor_calculation_kwargs["use_fp64"] = use_fp64 - tmp_input, local_size = self.descriptor_calculator. \ - calculate_from_qe_out(snapshot["input"], - **descriptor_calculation_kwargs) + tmp_input, local_size = ( + self.descriptor_calculator.calculate_from_qe_out( + snapshot["input"], **descriptor_calculation_kwargs + ) + ) elif description["input"] is None: # In this case, only the output is processed. pass else: - raise Exception("Unknown file extension, cannot convert descriptor") + raise Exception( + "Unknown file extension, cannot convert descriptor." + ) if description["input"] is not None: # Save data and delete, if not requested otherwise. if input_path is not None and input_iteration is None: if self.parameters._configuration["mpi"]: - tmp_input = self.descriptor_calculator. \ - gather_descriptors(tmp_input) + tmp_input = self.descriptor_calculator.gather_descriptors( + tmp_input + ) if get_rank() == 0: - self.descriptor_calculator.\ - write_to_numpy_file(input_path, tmp_input) + self.descriptor_calculator.write_to_numpy_file( + input_path, tmp_input + ) else: if self.parameters._configuration["mpi"]: - tmp_input, local_offset, local_reach = \ - self.descriptor_calculator.convert_local_to_3d(tmp_input) - self.descriptor_calculator. \ - write_to_openpmd_iteration(input_iteration, - tmp_input, - local_offset=local_offset, - local_reach=local_reach) + tmp_input, local_offset, local_reach = ( + self.descriptor_calculator.convert_local_to_3d( + tmp_input + ) + ) + self.descriptor_calculator.write_to_openpmd_iteration( + input_iteration, + tmp_input, + local_offset=local_offset, + local_reach=local_reach, + ) else: - self.descriptor_calculator. \ - write_to_openpmd_iteration(input_iteration, - tmp_input) + self.descriptor_calculator.write_to_openpmd_iteration( + input_iteration, tmp_input + ) del tmp_input ########### @@ -601,25 +671,27 @@

    Source code for mala.datahandling.data_converter

    # Parse and/or calculate the output descriptors. if description["output"] == ".cube": target_calculator_kwargs["units"] = original_units[ - "output"] + "output" + ] target_calculator_kwargs["use_memmap"] = use_memmap target_calculator_kwargs["use_fp64"] = use_fp64 # If no units are provided we just assume standard units. - tmp_output = self.target_calculator. \ - read_from_cube(snapshot["output"], - **target_calculator_kwargs) + tmp_output = self.target_calculator.read_from_cube( + snapshot["output"], **target_calculator_kwargs + ) elif description["output"] == ".xsf": target_calculator_kwargs["units"] = original_units[ - "output"] + "output" + ] target_calculator_kwargs["use_memmap"] = use_memmap target_calculator_kwargs["use_fp664"] = use_fp64 # If no units are provided we just assume standard units. - tmp_output = self.target_calculator. \ - read_from_xsf(snapshot["output"], - **target_calculator_kwargs) + tmp_output = self.target_calculator.read_from_xsf( + snapshot["output"], **target_calculator_kwargs + ) elif description["output"] is None: # In this case, only the input is processed. @@ -627,37 +699,39 @@

    Source code for mala.datahandling.data_converter

    else: raise Exception( - "Unknown file extension, cannot convert target" - "data.") + "Unknown file extension, cannot convert target data." + ) if get_rank() == 0: - self.target_calculator.write_to_numpy_file(output_path, - tmp_output) + self.target_calculator.write_to_numpy_file( + output_path, tmp_output + ) else: metadata = None if description["metadata"] is not None: - metadata = [snapshot["metadata"], - description["metadata"]] + metadata = [snapshot["metadata"], description["metadata"]] # Parse and/or calculate the output descriptors. if self.parameters._configuration["mpi"]: target_calculator_kwargs["return_local"] = True if description["output"] == ".cube": target_calculator_kwargs["units"] = original_units[ - "output"] + "output" + ] target_calculator_kwargs["use_memmap"] = use_memmap # If no units are provided we just assume standard units. - tmp_output = self.target_calculator. \ - read_from_cube(snapshot["output"], - **target_calculator_kwargs) + tmp_output = self.target_calculator.read_from_cube( + snapshot["output"], **target_calculator_kwargs + ) elif description["output"] == ".xsf": target_calculator_kwargs["units"] = original_units[ - "output"] + "output" + ] target_calculator_kwargs["use_memmap"] = use_memmap # If no units are provided we just assume standard units. - tmp_output = self.target_calculator. \ - read_from_xsf(snapshot["output"], - **target_calculator_kwargs) + tmp_output = self.target_calculator.read_from_xsf( + snapshot["output"], **target_calculator_kwargs + ) elif description["output"] is None: # In this case, only the input is processed. @@ -665,31 +739,34 @@

    Source code for mala.datahandling.data_converter

    else: raise Exception( - "Unknown file extension, cannot convert target" - "data.") + "Unknown file extension, cannot convert target data." + ) if self.parameters._configuration["mpi"]: - self.target_calculator. \ - write_to_openpmd_iteration(output_iteration, - tmp_output[0], - feature_from=tmp_output[1], - feature_to=tmp_output[2], - additional_metadata=metadata) + self.target_calculator.write_to_openpmd_iteration( + output_iteration, + tmp_output[0], + feature_from=tmp_output[1], + feature_to=tmp_output[2], + additional_metadata=metadata, + ) else: - self.target_calculator. \ - write_to_openpmd_iteration(output_iteration, - tmp_output, - additional_metadata=metadata) + self.target_calculator.write_to_openpmd_iteration( + output_iteration, + tmp_output, + additional_metadata=metadata, + ) del tmp_output # Parse and/or calculate the additional info. if description["additional_info"] is not None: # Parsing and saving is done using the target calculator. - self.target_calculator. \ - read_additional_calculation_data(snapshot["additional_info"], - description["additional_info"]) - self.target_calculator. \ - write_additional_calculation_data(additional_info_path)
    + self.target_calculator.read_additional_calculation_data( + snapshot["additional_info"], description["additional_info"] + ) + self.target_calculator.write_additional_calculation_data( + additional_info_path + )
    diff --git a/_modules/mala/datahandling/data_handler.html b/_modules/mala/datahandling/data_handler.html index 48c167b85..1c02e9c93 100644 --- a/_modules/mala/datahandling/data_handler.html +++ b/_modules/mala/datahandling/data_handler.html @@ -75,13 +75,9 @@

    Source code for mala.datahandling.data_handler

     """DataHandler class that loads and scales data."""
    +
     import os
     
    -try:
    -    import horovod.torch as hvd
    -except ModuleNotFoundError:
    -    # Warning is thrown by Parameters class
    -    pass
     import numpy as np
     import torch
     from torch.utils.data import TensorDataset
    @@ -133,25 +129,34 @@ 

    Source code for mala.datahandling.data_handler

    # Constructors ############################## - def __init__(self, parameters: Parameters, target_calculator=None, - descriptor_calculator=None, input_data_scaler=None, - output_data_scaler=None, clear_data=True): - super(DataHandler, self).__init__(parameters, - target_calculator=target_calculator, - descriptor_calculator= - descriptor_calculator) - # Data will be scaled per user specification. + def __init__( + self, + parameters: Parameters, + target_calculator=None, + descriptor_calculator=None, + input_data_scaler=None, + output_data_scaler=None, + clear_data=True, + ): + super(DataHandler, self).__init__( + parameters, + target_calculator=target_calculator, + descriptor_calculator=descriptor_calculator, + ) + # Data will be scaled per user specification. self.input_data_scaler = input_data_scaler if self.input_data_scaler is None: - self.input_data_scaler \ - = DataScaler(self.parameters.input_rescaling_type, - use_horovod=self.use_horovod) + self.input_data_scaler = DataScaler( + self.parameters.input_rescaling_type, + use_horovod=self.use_horovod, + ) self.output_data_scaler = output_data_scaler if self.output_data_scaler is None: - self.output_data_scaler \ - = DataScaler(self.parameters.output_rescaling_type, - use_horovod=self.use_horovod) + self.output_data_scaler = DataScaler( + self.parameters.output_rescaling_type, + use_horovod=self.use_horovod, + ) # Actual data points in the different categories. self.nr_training_data = 0 @@ -233,8 +238,10 @@

    Source code for mala.datahandling.data_handler

    # Do a consistency check of the snapshots so that we don't run into # an error later. If there is an error, check_snapshots() will raise # an exception. - printout("Checking the snapshots and your inputs for consistency.", - min_verbosity=1) + printout( + "Checking the snapshots and your inputs for consistency.", + min_verbosity=1, + ) self._check_snapshots() printout("Consistency check successful.", min_verbosity=0) @@ -243,22 +250,30 @@

    Source code for mala.datahandling.data_handler

    # than we can definitely not reparametrize the DataScalers. if self.nr_training_data == 0: reparametrize_scaler = False - if self.input_data_scaler.cantransform is False or \ - self.output_data_scaler.cantransform is False: - raise Exception("In inference mode, the DataHandler needs " - "parametrized DataScalers, " - "while you provided unparametrized " - "DataScalers.") + if ( + self.input_data_scaler.cantransform is False + or self.output_data_scaler.cantransform is False + ): + raise Exception( + "In inference mode, the DataHandler needs " + "parametrized DataScalers, " + "while you provided unparametrized " + "DataScalers." + ) # Parametrize the scalers, if needed. if reparametrize_scaler: printout("Initializing the data scalers.", min_verbosity=1) self.__parametrize_scalers() printout("Data scalers initialized.", min_verbosity=0) - elif self.parameters.use_lazy_loading is False and \ - self.nr_training_data != 0: - printout("Data scalers already initilized, loading data to RAM.", - min_verbosity=0) + elif ( + self.parameters.use_lazy_loading is False + and self.nr_training_data != 0 + ): + printout( + "Data scalers already initilized, loading data to RAM.", + min_verbosity=0, + ) self.__load_data("training", "inputs") self.__load_data("training", "outputs") @@ -325,17 +340,21 @@

    Source code for mala.datahandling.data_handler

    """ # get the snapshot from the snapshot number snapshot = self.parameters.snapshot_directories_list[snapshot_number] - + if self.parameters.use_lazy_loading: # This fails if an incorrect snapshot was loaded. if self.test_data_sets[0].currently_loaded_file != snapshot_number: - raise Exception("Cannot calculate gradients, wrong file " - "was lazily loaded.") + raise Exception( + "Cannot calculate gradients, wrong file " + "was lazily loaded." + ) return self.test_data_sets[0].input_data.grad else: - return self.test_data_inputs.\ - grad[snapshot.grid_size*snapshot_number: - snapshot.grid_size*(snapshot_number+1)]

    + return self.test_data_inputs.grad[ + snapshot.grid_size + * snapshot_number : snapshot.grid_size + * (snapshot_number + 1) + ]
    [docs] def get_snapshot_calculation_output(self, snapshot_number): """ @@ -352,14 +371,16 @@

    Source code for mala.datahandling.data_handler

    Path to the calculation output for this snapshot. """ - return self.parameters.snapshot_directories_list[snapshot_number].\ - calculation_output

    + return self.parameters.snapshot_directories_list[ + snapshot_number + ].calculation_output
    # Debugging ###################### - -
    [docs] def raw_numpy_to_converted_scaled_tensor(self, numpy_array, data_type, - units, convert3Dto1D=False): + +
    [docs] def raw_numpy_to_converted_scaled_tensor( + self, numpy_array, data_type, units, convert3Dto1D=False + ): """ Transform a raw numpy array into a scaled torch tensor. @@ -386,12 +407,14 @@

    Source code for mala.datahandling.data_handler

    """ # Check parameters for consistency. if data_type != "in" and data_type != "out": - raise Exception("Please specify either \"in\" or \"out\" as " - "data_type.") + raise Exception( + 'Please specify either "in" or "out" as ' "data_type." + ) # Convert units of numpy array. - numpy_array = self.__raw_numpy_to_converted_numpy(numpy_array, - data_type, units) + numpy_array = self.__raw_numpy_to_converted_numpy( + numpy_array, data_type, units + ) # If desired, the dimensions can be changed. if convert3Dto1D: @@ -405,16 +428,17 @@

    Source code for mala.datahandling.data_handler

    desired_dimensions = None # Convert numpy array to scaled tensor a network can work with. - numpy_array = self.\ - __converted_numpy_to_scaled_tensor(numpy_array, desired_dimensions, - data_type) + numpy_array = self.__converted_numpy_to_scaled_tensor( + numpy_array, desired_dimensions, data_type + ) return numpy_array

    -
    [docs] def resize_snapshots_for_debugging(self, directory="./", - naming_scheme_input= - "test_Al_debug_2k_nr*.in", - naming_scheme_output= - "test_Al_debug_2k_nr*.out"): +
    [docs] def resize_snapshots_for_debugging( + self, + directory="./", + naming_scheme_input="test_Al_debug_2k_nr*.in", + naming_scheme_output="test_Al_debug_2k_nr*.out", + ): """ Resize all snapshots in the list. @@ -433,18 +457,22 @@

    Source code for mala.datahandling.data_handler

    i = 0 snapshot: Snapshot for snapshot in self.parameters.snapshot_directories_list: - tmp_array = self.descriptor_calculator.\ - read_from_numpy_file(os.path.join(snapshot.input_npy_directory, - snapshot.input_npy_file), - units=snapshot.input_units) + tmp_array = self.descriptor_calculator.read_from_numpy_file( + os.path.join( + snapshot.input_npy_directory, snapshot.input_npy_file + ), + units=snapshot.input_units, + ) tmp_file_name = naming_scheme_input tmp_file_name = tmp_file_name.replace("*", str(i)) np.save(os.path.join(directory, tmp_file_name) + ".npy", tmp_array) - tmp_array = self.target_calculator.\ - read_from_numpy_file(os.path.join(snapshot.output_npy_directory, - snapshot.output_npy_file), - units=snapshot.output_units) + tmp_array = self.target_calculator.read_from_numpy_file( + os.path.join( + snapshot.output_npy_directory, snapshot.output_npy_file + ), + units=snapshot.output_units, + ) tmp_file_name = naming_scheme_output tmp_file_name = tmp_file_name.replace("*", str(i)) np.save(os.path.join(directory, tmp_file_name + ".npy"), tmp_array) @@ -478,29 +506,36 @@

    Source code for mala.datahandling.data_handler

    self.nr_validation_snapshots += 1 self.nr_validation_data += snapshot.grid_size else: - raise Exception("Unknown option for snapshot splitting " - "selected.") + raise Exception( + "Unknown option for snapshot splitting selected." + ) # Now we need to check whether or not this input is believable. nr_of_snapshots = len(self.parameters.snapshot_directories_list) - if nr_of_snapshots != (self.nr_training_snapshots + - self.nr_test_snapshots + - self.nr_validation_snapshots): - raise Exception("Cannot split snapshots with specified " - "splitting scheme, " - "too few or too many options selected") + if nr_of_snapshots != ( + self.nr_training_snapshots + + self.nr_test_snapshots + + self.nr_validation_snapshots + ): + raise Exception( + "Cannot split snapshots with specified " + "splitting scheme, " + "too few or too many options selected" + ) # MALA can either be run in training or test-only mode. # But it has to be run in either of those! # So either training AND validation snapshots can be provided # OR only test snapshots. if self.nr_test_snapshots != 0: if self.nr_training_snapshots == 0: - printout("DataHandler prepared for inference. No training " - "possible with this setup. If this is not what " - "you wanted, please revise the input script. " - "Validation snapshots you may have entered will" - "be ignored.", - min_verbosity=0) + printout( + "DataHandler prepared for inference. No training " + "possible with this setup. If this is not what " + "you wanted, please revise the input script. " + "Validation snapshots you may have entered will" + "be ignored.", + min_verbosity=0, + ) else: if self.nr_training_snapshots == 0: raise Exception("No training snapshots provided.") @@ -510,38 +545,44 @@

    Source code for mala.datahandling.data_handler

    raise Exception("Wrong parameter for data splitting provided.") if not self.parameters.use_lazy_loading: - self.__allocate_arrays() + self.__allocate_arrays() # Reordering the lists. - snapshot_order = {'tr': 0, 'va': 1, 'te': 2} - self.parameters.snapshot_directories_list.sort(key=lambda d: - snapshot_order - [d.snapshot_function]) + snapshot_order = {"tr": 0, "va": 1, "te": 2} + self.parameters.snapshot_directories_list.sort( + key=lambda d: snapshot_order[d.snapshot_function] + ) def __allocate_arrays(self): if self.nr_training_data > 0: - self.training_data_inputs = np.zeros((self.nr_training_data, - self.input_dimension), - dtype=DEFAULT_NP_DATA_DTYPE) - self.training_data_outputs = np.zeros((self.nr_training_data, - self.output_dimension), - dtype=DEFAULT_NP_DATA_DTYPE) + self.training_data_inputs = np.zeros( + (self.nr_training_data, self.input_dimension), + dtype=DEFAULT_NP_DATA_DTYPE, + ) + self.training_data_outputs = np.zeros( + (self.nr_training_data, self.output_dimension), + dtype=DEFAULT_NP_DATA_DTYPE, + ) if self.nr_validation_data > 0: - self.validation_data_inputs = np.zeros((self.nr_validation_data, - self.input_dimension), - dtype=DEFAULT_NP_DATA_DTYPE) - self.validation_data_outputs = np.zeros((self.nr_validation_data, - self.output_dimension), - dtype=DEFAULT_NP_DATA_DTYPE) + self.validation_data_inputs = np.zeros( + (self.nr_validation_data, self.input_dimension), + dtype=DEFAULT_NP_DATA_DTYPE, + ) + self.validation_data_outputs = np.zeros( + (self.nr_validation_data, self.output_dimension), + dtype=DEFAULT_NP_DATA_DTYPE, + ) if self.nr_test_data > 0: - self.test_data_inputs = np.zeros((self.nr_test_data, - self.input_dimension), - dtype=DEFAULT_NP_DATA_DTYPE) - self.test_data_outputs = np.zeros((self.nr_test_data, - self.output_dimension), - dtype=DEFAULT_NP_DATA_DTYPE) + self.test_data_inputs = np.zeros( + (self.nr_test_data, self.input_dimension), + dtype=DEFAULT_NP_DATA_DTYPE, + ) + self.test_data_outputs = np.zeros( + (self.nr_test_data, self.output_dimension), + dtype=DEFAULT_NP_DATA_DTYPE, + ) def __load_data(self, function, data_type): """ @@ -556,21 +597,27 @@

    Source code for mala.datahandling.data_handler

    data_type : string Can be "input" or "output". """ - if function != "training" and function != "test" and \ - function != "validation": + if ( + function != "training" + and function != "test" + and function != "validation" + ): raise Exception("Unknown snapshot type detected.") if data_type != "outputs" and data_type != "inputs": raise Exception("Unknown data type detected.") # Extracting all the information pertaining to the data set. - array = function+"_data_"+data_type + array = function + "_data_" + data_type if data_type == "inputs": calculator = self.descriptor_calculator else: calculator = self.target_calculator - feature_dimension = self.input_dimension if data_type == "inputs" \ + feature_dimension = ( + self.input_dimension + if data_type == "inputs" else self.output_dimension + ) snapshot_counter = 0 gs_old = 0 @@ -581,25 +628,32 @@

    Source code for mala.datahandling.data_handler

    # Data scaling is only performed on the training data sets. if snapshot.snapshot_function == function[0:2]: if data_type == "inputs": - file = os.path.join(snapshot.input_npy_directory, - snapshot.input_npy_file) + file = os.path.join( + snapshot.input_npy_directory, snapshot.input_npy_file + ) units = snapshot.input_units else: - file = os.path.join(snapshot.output_npy_directory, - snapshot.output_npy_file) + file = os.path.join( + snapshot.output_npy_directory, + snapshot.output_npy_file, + ) units = snapshot.output_units if snapshot.snapshot_type == "numpy": calculator.read_from_numpy_file( file, units=units, - array=getattr(self, array)[gs_old : gs_old + gs_new, :], + array=getattr(self, array)[ + gs_old : gs_old + gs_new, : + ], reshape=True, ) elif snapshot.snapshot_type == "openpmd": - getattr(self, array)[gs_old : gs_old + gs_new] = \ - calculator.read_from_openpmd_file(file, units=units) \ - .reshape([gs_new, feature_dimension]) + getattr(self, array)[gs_old : gs_old + gs_new] = ( + calculator.read_from_openpmd_file( + file, units=units + ).reshape([gs_new, feature_dimension]) + ) else: raise Exception("Unknown snapshot file type.") snapshot_counter += 1 @@ -615,61 +669,91 @@

    Source code for mala.datahandling.data_handler

    # all ears. if data_type == "inputs": if function == "training": - self.training_data_inputs = torch.\ - from_numpy(self.training_data_inputs).float() + self.training_data_inputs = torch.from_numpy( + self.training_data_inputs + ).float() if function == "validation": - self.validation_data_inputs = torch.\ - from_numpy(self.validation_data_inputs).float() + self.validation_data_inputs = torch.from_numpy( + self.validation_data_inputs + ).float() if function == "test": - self.test_data_inputs = torch.\ - from_numpy(self.test_data_inputs).float() + self.test_data_inputs = torch.from_numpy( + self.test_data_inputs + ).float() if data_type == "outputs": if function == "training": - self.training_data_outputs = torch.\ - from_numpy(self.training_data_outputs).float() + self.training_data_outputs = torch.from_numpy( + self.training_data_outputs + ).float() if function == "validation": - self.validation_data_outputs = torch.\ - from_numpy(self.validation_data_outputs).float() + self.validation_data_outputs = torch.from_numpy( + self.validation_data_outputs + ).float() if function == "test": - self.test_data_outputs = torch.\ - from_numpy(self.test_data_outputs).float() - + self.test_data_outputs = torch.from_numpy( + self.test_data_outputs + ).float() + def __build_datasets(self): """Build the DataSets that are used during training.""" - if self.parameters.use_lazy_loading and not self.parameters.use_lazy_loading_prefetch: + if ( + self.parameters.use_lazy_loading + and not self.parameters.use_lazy_loading_prefetch + ): # Create the lazy loading data sets. - self.training_data_sets.append(LazyLoadDataset( - self.input_dimension, self.output_dimension, - self.input_data_scaler, self.output_data_scaler, - self.descriptor_calculator, self.target_calculator, - self.use_horovod)) - self.validation_data_sets.append(LazyLoadDataset( - self.input_dimension, self.output_dimension, - self.input_data_scaler, self.output_data_scaler, - self.descriptor_calculator, self.target_calculator, - self.use_horovod)) - - if self.nr_test_data != 0: - self.test_data_sets.append(LazyLoadDataset( + self.training_data_sets.append( + LazyLoadDataset( + self.input_dimension, + self.output_dimension, + self.input_data_scaler, + self.output_data_scaler, + self.descriptor_calculator, + self.target_calculator, + self.use_horovod, + ) + ) + self.validation_data_sets.append( + LazyLoadDataset( self.input_dimension, self.output_dimension, - self.input_data_scaler, self.output_data_scaler, - self.descriptor_calculator, self.target_calculator, + self.input_data_scaler, + self.output_data_scaler, + self.descriptor_calculator, + self.target_calculator, self.use_horovod, - input_requires_grad=True)) + ) + ) + + if self.nr_test_data != 0: + self.test_data_sets.append( + LazyLoadDataset( + self.input_dimension, + self.output_dimension, + self.input_data_scaler, + self.output_data_scaler, + self.descriptor_calculator, + self.target_calculator, + self.use_horovod, + input_requires_grad=True, + ) + ) # Add snapshots to the lazy loading data sets. for snapshot in self.parameters.snapshot_directories_list: if snapshot.snapshot_function == "tr": - self.training_data_sets[0].add_snapshot_to_dataset(snapshot) + self.training_data_sets[0].add_snapshot_to_dataset( + snapshot + ) if snapshot.snapshot_function == "va": - self.validation_data_sets[0].add_snapshot_to_dataset(snapshot) + self.validation_data_sets[0].add_snapshot_to_dataset( + snapshot + ) if snapshot.snapshot_function == "te": self.test_data_sets[0].add_snapshot_to_dataset(snapshot) @@ -679,33 +763,57 @@

    Source code for mala.datahandling.data_handler

    # self.training_data_set.mix_datasets() # self.validation_data_set.mix_datasets() # self.test_data_set.mix_datasets() - elif self.parameters.use_lazy_loading and self.parameters.use_lazy_loading_prefetch: + elif ( + self.parameters.use_lazy_loading + and self.parameters.use_lazy_loading_prefetch + ): printout("Using lazy loading pre-fetching.", min_verbosity=2) # Create LazyLoadDatasetSingle instances per snapshot and add to # list. for snapshot in self.parameters.snapshot_directories_list: if snapshot.snapshot_function == "tr": - self.training_data_sets.append(LazyLoadDatasetSingle( - self.mini_batch_size, snapshot, - self.input_dimension, self.output_dimension, - self.input_data_scaler, self.output_data_scaler, - self.descriptor_calculator, self.target_calculator, - self.use_horovod)) + self.training_data_sets.append( + LazyLoadDatasetSingle( + self.mini_batch_size, + snapshot, + self.input_dimension, + self.output_dimension, + self.input_data_scaler, + self.output_data_scaler, + self.descriptor_calculator, + self.target_calculator, + self.use_horovod, + ) + ) if snapshot.snapshot_function == "va": - self.validation_data_sets.append(LazyLoadDatasetSingle( - self.mini_batch_size, snapshot, - self.input_dimension, self.output_dimension, - self.input_data_scaler, self.output_data_scaler, - self.descriptor_calculator, self.target_calculator, - self.use_horovod)) + self.validation_data_sets.append( + LazyLoadDatasetSingle( + self.mini_batch_size, + snapshot, + self.input_dimension, + self.output_dimension, + self.input_data_scaler, + self.output_data_scaler, + self.descriptor_calculator, + self.target_calculator, + self.use_horovod, + ) + ) if snapshot.snapshot_function == "te": - self.test_data_sets.append(LazyLoadDatasetSingle( - self.mini_batch_size, snapshot, - self.input_dimension, self.output_dimension, - self.input_data_scaler, self.output_data_scaler, - self.descriptor_calculator, self.target_calculator, - self.use_horovod, - input_requires_grad=True)) + self.test_data_sets.append( + LazyLoadDatasetSingle( + self.mini_batch_size, + snapshot, + self.input_dimension, + self.output_dimension, + self.input_data_scaler, + self.output_data_scaler, + self.descriptor_calculator, + self.target_calculator, + self.use_horovod, + input_requires_grad=True, + ) + ) else: if self.nr_training_data != 0: @@ -713,14 +821,20 @@

    Source code for mala.datahandling.data_handler

    self.output_data_scaler.transform(self.training_data_outputs) if self.parameters.use_fast_tensor_data_set: printout("Using FastTensorDataset.", min_verbosity=2) - self.training_data_sets.append( \ - FastTensorDataset(self.mini_batch_size, - self.training_data_inputs, - self.training_data_outputs)) + self.training_data_sets.append( + FastTensorDataset( + self.mini_batch_size, + self.training_data_inputs, + self.training_data_outputs, + ) + ) else: - self.training_data_sets.append( \ - TensorDataset(self.training_data_inputs, - self.training_data_outputs)) + self.training_data_sets.append( + TensorDataset( + self.training_data_inputs, + self.training_data_outputs, + ) + ) if self.nr_validation_data != 0: self.__load_data("validation", "inputs") @@ -730,14 +844,20 @@

    Source code for mala.datahandling.data_handler

    self.output_data_scaler.transform(self.validation_data_outputs) if self.parameters.use_fast_tensor_data_set: printout("Using FastTensorDataset.", min_verbosity=2) - self.validation_data_sets.append( \ - FastTensorDataset(self.mini_batch_size, - self.validation_data_inputs, - self.validation_data_outputs)) + self.validation_data_sets.append( + FastTensorDataset( + self.mini_batch_size, + self.validation_data_inputs, + self.validation_data_outputs, + ) + ) else: - self.validation_data_sets.append( \ - TensorDataset(self.validation_data_inputs, - self.validation_data_outputs)) + self.validation_data_sets.append( + TensorDataset( + self.validation_data_inputs, + self.validation_data_outputs, + ) + ) if self.nr_test_data != 0: self.__load_data("test", "inputs") @@ -746,9 +866,11 @@

    Source code for mala.datahandling.data_handler

    self.__load_data("test", "outputs") self.output_data_scaler.transform(self.test_data_outputs) - self.test_data_sets.append( \ - TensorDataset(self.test_data_inputs, - self.test_data_outputs)) + self.test_data_sets.append( + TensorDataset( + self.test_data_inputs, self.test_data_outputs + ) + ) # Scaling ###################### @@ -773,14 +895,22 @@

    Source code for mala.datahandling.data_handler

    # Data scaling is only performed on the training data sets. if snapshot.snapshot_function == "tr": if snapshot.snapshot_type == "numpy": - tmp = self.descriptor_calculator. \ - read_from_numpy_file(os.path.join(snapshot.input_npy_directory, - snapshot.input_npy_file), - units=snapshot.input_units) + tmp = self.descriptor_calculator.read_from_numpy_file( + os.path.join( + snapshot.input_npy_directory, + snapshot.input_npy_file, + ), + units=snapshot.input_units, + ) elif snapshot.snapshot_type == "openpmd": - tmp = self.descriptor_calculator. \ - read_from_openpmd_file(os.path.join(snapshot.input_npy_directory, - snapshot.input_npy_file)) + tmp = ( + self.descriptor_calculator.read_from_openpmd_file( + os.path.join( + snapshot.input_npy_directory, + snapshot.input_npy_file, + ) + ) + ) else: raise Exception("Unknown snapshot file type.") @@ -792,8 +922,9 @@

    Source code for mala.datahandling.data_handler

    tmp = np.array(tmp) if tmp.dtype != DEFAULT_NP_DATA_DTYPE: tmp = tmp.astype(DEFAULT_NP_DATA_DTYPE) - tmp = tmp.reshape([snapshot.grid_size, - self.input_dimension]) + tmp = tmp.reshape( + [snapshot.grid_size, self.input_dimension] + ) tmp = torch.from_numpy(tmp).float() self.input_data_scaler.incremental_fit(tmp) @@ -825,14 +956,20 @@

    Source code for mala.datahandling.data_handler

    # Data scaling is only performed on the training data sets. if snapshot.snapshot_function == "tr": if snapshot.snapshot_type == "numpy": - tmp = self.target_calculator.\ - read_from_numpy_file(os.path.join(snapshot.output_npy_directory, - snapshot.output_npy_file), - units=snapshot.output_units) + tmp = self.target_calculator.read_from_numpy_file( + os.path.join( + snapshot.output_npy_directory, + snapshot.output_npy_file, + ), + units=snapshot.output_units, + ) elif snapshot.snapshot_type == "openpmd": - tmp = self.target_calculator. \ - read_from_openpmd_file(os.path.join(snapshot.output_npy_directory, - snapshot.output_npy_file)) + tmp = self.target_calculator.read_from_openpmd_file( + os.path.join( + snapshot.output_npy_directory, + snapshot.output_npy_file, + ) + ) else: raise Exception("Unknown snapshot file type.") @@ -844,8 +981,9 @@

    Source code for mala.datahandling.data_handler

    tmp = np.array(tmp) if tmp.dtype != DEFAULT_NP_DATA_DTYPE: tmp = tmp.astype(DEFAULT_NP_DATA_DTYPE) - tmp = tmp.reshape([snapshot.grid_size, - self.output_dimension]) + tmp = tmp.reshape( + [snapshot.grid_size, self.output_dimension] + ) tmp = torch.from_numpy(tmp).float() self.output_data_scaler.incremental_fit(tmp) i += 1 @@ -855,30 +993,35 @@

    Source code for mala.datahandling.data_handler

    self.__load_data("training", "outputs") self.output_data_scaler.fit(self.training_data_outputs) - printout("Output scaler parametrized.", min_verbosity=1) + printout("Output scaler parametrized.", min_verbosity=1) - def __raw_numpy_to_converted_numpy(self, numpy_array, data_type="in", - units=None): + def __raw_numpy_to_converted_numpy( + self, numpy_array, data_type="in", units=None + ): """Convert a raw numpy array containing into the correct units.""" if data_type == "in": - if data_type == "in" and self.descriptor_calculator.\ - descriptors_contain_xyz: + if ( + data_type == "in" + and self.descriptor_calculator.descriptors_contain_xyz + ): numpy_array = numpy_array[:, :, :, 3:] if units is not None: - numpy_array *= self.descriptor_calculator.convert_units(1, - units) + numpy_array *= self.descriptor_calculator.convert_units( + 1, units + ) return numpy_array elif data_type == "out": if units is not None: numpy_array *= self.target_calculator.convert_units(1, units) return numpy_array else: - raise Exception("Please choose either \"in\" or \"out\" for " - "this function.") + raise Exception( + 'Please choose either "in" or "out" for ' "this function." + ) - def __converted_numpy_to_scaled_tensor(self, numpy_array, - desired_dimensions=None, - data_type="in"): + def __converted_numpy_to_scaled_tensor( + self, numpy_array, desired_dimensions=None, data_type="in" + ): """ Transform a numpy array containing into a scaled torch tensor. @@ -894,8 +1037,9 @@

    Source code for mala.datahandling.data_handler

    elif data_type == "out": self.output_data_scaler.transform(numpy_array) else: - raise Exception("Please choose either \"in\" or \"out\" for " - "this function.") + raise Exception( + 'Please choose either "in" or "out" for ' "this function." + ) return numpy_array

    diff --git a/_modules/mala/datahandling/data_handler_base.html b/_modules/mala/datahandling/data_handler_base.html index 26c8ff0cd..78641f5c2 100644 --- a/_modules/mala/datahandling/data_handler_base.html +++ b/_modules/mala/datahandling/data_handler_base.html @@ -75,6 +75,7 @@

    Source code for mala.datahandling.data_handler_base

     """Base class for all data handling (loading, shuffling, etc.)."""
    +
     from abc import ABC
     import os
     
    @@ -105,8 +106,12 @@ 

    Source code for mala.datahandling.data_handler_base

    be created by this class. """ - def __init__(self, parameters: Parameters, target_calculator=None, - descriptor_calculator=None): + def __init__( + self, + parameters: Parameters, + target_calculator=None, + descriptor_calculator=None, + ): self.parameters: ParametersData = parameters.data self.use_horovod = parameters.use_horovod @@ -152,11 +157,18 @@

    Source code for mala.datahandling.data_handler_base

    # Adding/Deleting data ######################## -
    [docs] def add_snapshot(self, input_file, input_directory, - output_file, output_directory, - add_snapshot_as, - output_units="1/(eV*A^3)", input_units="None", - calculation_output_file="", snapshot_type="numpy"): +
    [docs] def add_snapshot( + self, + input_file, + input_directory, + output_file, + output_directory, + add_snapshot_as, + output_units="1/(eV*A^3)", + input_units="None", + calculation_output_file="", + snapshot_type="numpy", + ): """ Add a snapshot to the data pipeline. @@ -195,13 +207,17 @@

    Source code for mala.datahandling.data_handler_base

    Either "numpy" or "openpmd" based on what kind of files you want to operate on. """ - snapshot = Snapshot(input_file, input_directory, - output_file, output_directory, - add_snapshot_as, - input_units=input_units, - output_units=output_units, - calculation_output=calculation_output_file, - snapshot_type=snapshot_type) + snapshot = Snapshot( + input_file, + input_directory, + output_file, + output_directory, + add_snapshot_as, + input_units=input_units, + output_units=output_units, + calculation_output=calculation_output_file, + snapshot_type=snapshot_type, + ) self.parameters.snapshot_directories_list.append(snapshot)
    [docs] def clear_data(self): @@ -230,18 +246,29 @@

    Source code for mala.datahandling.data_handler_base

    # Descriptors. #################### - printout("Checking descriptor file ", snapshot.input_npy_file, - "at", snapshot.input_npy_directory, min_verbosity=1) + printout( + "Checking descriptor file ", + snapshot.input_npy_file, + "at", + snapshot.input_npy_directory, + min_verbosity=1, + ) if snapshot.snapshot_type == "numpy": - tmp_dimension = self.descriptor_calculator. \ - read_dimensions_from_numpy_file( - os.path.join(snapshot.input_npy_directory, - snapshot.input_npy_file)) + tmp_dimension = ( + self.descriptor_calculator.read_dimensions_from_numpy_file( + os.path.join( + snapshot.input_npy_directory, + snapshot.input_npy_file, + ) + ) + ) elif snapshot.snapshot_type == "openpmd": - tmp_dimension = self.descriptor_calculator. \ - read_dimensions_from_openpmd_file( - os.path.join(snapshot.input_npy_directory, - snapshot.input_npy_file), comm=comm) + tmp_dimension = self.descriptor_calculator.read_dimensions_from_openpmd_file( + os.path.join( + snapshot.input_npy_directory, snapshot.input_npy_file + ), + comm=comm, + ) else: raise Exception("Unknown snapshot file type.") @@ -255,24 +282,40 @@

    Source code for mala.datahandling.data_handler_base

    self.input_dimension = tmp_input_dimension else: if self.input_dimension != tmp_input_dimension: - raise Exception("Invalid snapshot entered at ", snapshot. - input_npy_file) + raise Exception( + "Invalid snapshot entered at ", + snapshot.input_npy_file, + ) #################### # Targets. #################### - printout("Checking targets file ", snapshot.output_npy_file, "at", - snapshot.output_npy_directory, min_verbosity=1) + printout( + "Checking targets file ", + snapshot.output_npy_file, + "at", + snapshot.output_npy_directory, + min_verbosity=1, + ) if snapshot.snapshot_type == "numpy": - tmp_dimension = self.target_calculator. \ - read_dimensions_from_numpy_file( - os.path.join(snapshot.output_npy_directory, - snapshot.output_npy_file)) + tmp_dimension = ( + self.target_calculator.read_dimensions_from_numpy_file( + os.path.join( + snapshot.output_npy_directory, + snapshot.output_npy_file, + ) + ) + ) elif snapshot.snapshot_type == "openpmd": - tmp_dimension = self.target_calculator. \ - read_dimensions_from_openpmd_file( - os.path.join(snapshot.output_npy_directory, - snapshot.output_npy_file), comm=comm) + tmp_dimension = ( + self.target_calculator.read_dimensions_from_openpmd_file( + os.path.join( + snapshot.output_npy_directory, + snapshot.output_npy_file, + ), + comm=comm, + ) + ) else: raise Exception("Unknown snapshot file type.") @@ -283,8 +326,10 @@

    Source code for mala.datahandling.data_handler_base

    self.output_dimension = tmp_output_dimension else: if self.output_dimension != tmp_output_dimension: - raise Exception("Invalid snapshot entered at ", snapshot. - output_npy_file) + raise Exception( + "Invalid snapshot entered at ", + snapshot.output_npy_file, + ) if np.prod(tmp_dimension[0:3]) != snapshot.grid_size: raise Exception("Inconsistent snapshot data provided.") diff --git a/_modules/mala/datahandling/data_scaler.html b/_modules/mala/datahandling/data_scaler.html index c5b88eb2b..424520e4c 100644 --- a/_modules/mala/datahandling/data_scaler.html +++ b/_modules/mala/datahandling/data_scaler.html @@ -75,6 +75,7 @@

    Source code for mala.datahandling.data_scaler

     """DataScaler class for scaling DFT data."""
    +
     import pickle
     
     try:
    @@ -129,8 +130,8 @@ 

    Source code for mala.datahandling.data_scaler

    self.mins = torch.empty(0) self.total_mean = torch.tensor(0) self.total_std = torch.tensor(0) - self.total_max = torch.tensor(float('-inf')) - self.total_min = torch.tensor(float('inf')) + self.total_max = torch.tensor(float("-inf")) + self.total_min = torch.tensor(float("inf")) self.total_data_count = 0 @@ -193,24 +194,29 @@

    Source code for mala.datahandling.data_scaler

    old_std = self.stds if list(self.means.size())[0] > 0: - self.means = \ - self.total_data_count /\ - (self.total_data_count + current_data_count) \ - * old_mean + current_data_count / \ - (self.total_data_count + current_data_count)\ + self.means = ( + self.total_data_count + / (self.total_data_count + current_data_count) + * old_mean + + current_data_count + / (self.total_data_count + current_data_count) * new_mean + ) else: self.means = new_mean if list(self.stds.size())[0] > 0: - self.stds = \ - self.total_data_count / \ - (self.total_data_count + current_data_count) \ - * old_std ** 2 + current_data_count / \ - (self.total_data_count + current_data_count) *\ - new_std ** 2 + \ - (self.total_data_count * current_data_count)\ - / (self.total_data_count + current_data_count)\ - ** 2 * (old_mean - new_mean) ** 2 + self.stds = ( + self.total_data_count + / (self.total_data_count + current_data_count) + * old_std**2 + + current_data_count + / (self.total_data_count + current_data_count) + * new_std**2 + + (self.total_data_count * current_data_count) + / (self.total_data_count + current_data_count) + ** 2 + * (old_mean - new_mean) ** 2 + ) self.stds = torch.sqrt(self.stds) else: @@ -241,8 +247,9 @@

    Source code for mala.datahandling.data_scaler

    ########################## if self.scale_standard: - current_data_count = list(unscaled.size())[0]\ - * list(unscaled.size())[1] + current_data_count = ( + list(unscaled.size())[0] * list(unscaled.size())[1] + ) new_mean = torch.mean(unscaled) new_std = torch.std(unscaled) @@ -250,28 +257,31 @@

    Source code for mala.datahandling.data_scaler

    old_mean = self.total_mean old_std = self.total_std - self.total_mean = \ - self.total_data_count / \ - (self.total_data_count + current_data_count) * \ - old_mean + current_data_count / \ - (self.total_data_count + current_data_count) *\ - new_mean + self.total_mean = ( + self.total_data_count + / (self.total_data_count + current_data_count) + * old_mean + + current_data_count + / (self.total_data_count + current_data_count) + * new_mean + ) # This equation is taken from the Sandia code. It # presumably works, but it gets slighly different # results. # Maybe we should check it at some point . # I think it is merely an issue of numerical accuracy. - self.total_std = \ - self.total_data_count / \ - (self.total_data_count + current_data_count) * \ - old_std ** 2 + \ - current_data_count / \ - (self.total_data_count + current_data_count) \ - * new_std ** 2 + \ - (self.total_data_count * current_data_count) / \ - (self.total_data_count + current_data_count) \ - ** 2 * (old_mean - new_mean) ** 2 + self.total_std = ( + self.total_data_count + / (self.total_data_count + current_data_count) + * old_std**2 + + current_data_count + / (self.total_data_count + current_data_count) + * new_std**2 + + (self.total_data_count * current_data_count) + / (self.total_data_count + current_data_count) ** 2 + * (old_mean - new_mean) ** 2 + ) self.total_std = torch.sqrt(self.total_std) self.total_data_count += current_data_count @@ -359,8 +369,10 @@

    Source code for mala.datahandling.data_scaler

    pass elif self.cantransform is False: - raise Exception("Transformation cannot be done, this DataScaler " - "was never initialized") + raise Exception( + "Transformation cannot be done, this DataScaler " + "was never initialized" + ) # Perform the actual scaling, but use no_grad to make sure # that the next couple of iterations stay untracked. @@ -377,7 +389,7 @@

    Source code for mala.datahandling.data_scaler

    if self.scale_normal: unscaled -= self.mins - unscaled /= (self.maxs - self.mins) + unscaled /= self.maxs - self.mins else: @@ -391,7 +403,7 @@

    Source code for mala.datahandling.data_scaler

    if self.scale_normal: unscaled -= self.total_min - unscaled /= (self.total_max - self.total_min)
    + unscaled /= self.total_max - self.total_min
    [docs] def inverse_transform(self, scaled, as_numpy=False): """ @@ -420,8 +432,10 @@

    Source code for mala.datahandling.data_scaler

    else: if self.cantransform is False: - raise Exception("Backtransformation cannot be done, this " - "DataScaler was never initialized") + raise Exception( + "Backtransformation cannot be done, this " + "DataScaler was never initialized" + ) # Perform the actual scaling, but use no_grad to make sure # that the next couple of iterations stay untracked. @@ -436,8 +450,9 @@

    Source code for mala.datahandling.data_scaler

    unscaled = (scaled * self.stds) + self.means if self.scale_normal: - unscaled = (scaled*(self.maxs - - self.mins)) + self.mins + unscaled = ( + scaled * (self.maxs - self.mins) + ) + self.mins else: @@ -449,9 +464,10 @@

    Source code for mala.datahandling.data_scaler

    unscaled = (scaled * self.total_std) + self.total_mean if self.scale_normal: - unscaled = (scaled*(self.total_max - - self.total_min)) + self.total_min -# + unscaled = ( + scaled * (self.total_max - self.total_min) + ) + self.total_min + # if as_numpy: return unscaled.detach().numpy().astype(np.float64) else: @@ -474,7 +490,7 @@

    Source code for mala.datahandling.data_scaler

    if hvd.rank() != 0: return if save_format == "pickle": - with open(filename, 'wb') as handle: + with open(filename, "wb") as handle: pickle.dump(self, handle, protocol=4) else: raise Exception("Unsupported parameter save format.")
    @@ -499,7 +515,7 @@

    Source code for mala.datahandling.data_scaler

    """ if save_format == "pickle": if isinstance(file, str): - loaded_scaler = pickle.load(open(file, 'rb')) + loaded_scaler = pickle.load(open(file, "rb")) else: loaded_scaler = pickle.load(file) else: diff --git a/_modules/mala/datahandling/data_shuffler.html b/_modules/mala/datahandling/data_shuffler.html index 52c7075b5..87ee629e6 100644 --- a/_modules/mala/datahandling/data_shuffler.html +++ b/_modules/mala/datahandling/data_shuffler.html @@ -75,12 +75,15 @@

    Source code for mala.datahandling.data_shuffler

     """Mixes data between snapshots for improved lazy-loading training."""
    +
     import os
     
     import numpy as np
     
    -import mala
    -from mala.common.parameters import ParametersData, Parameters, DEFAULT_NP_DATA_DTYPE
    +from mala.common.parameters import (
    +    Parameters,
    +    DEFAULT_NP_DATA_DTYPE,
    +)
     from mala.common.parallelizer import printout
     from mala.common.physical_data import PhysicalData
     from mala.datahandling.data_handler_base import DataHandlerBase
    @@ -107,21 +110,34 @@ 

    Source code for mala.datahandling.data_shuffler

    < be created by this class. """ - def __init__(self, parameters: Parameters, target_calculator=None, - descriptor_calculator=None): - super(DataShuffler, self).__init__(parameters, - target_calculator=target_calculator, - descriptor_calculator= - descriptor_calculator) + def __init__( + self, + parameters: Parameters, + target_calculator=None, + descriptor_calculator=None, + ): + super(DataShuffler, self).__init__( + parameters, + target_calculator=target_calculator, + descriptor_calculator=descriptor_calculator, + ) if self.descriptor_calculator.parameters.descriptors_contain_xyz: - printout("Disabling XYZ-cutting from descriptor data for " - "shuffling. If needed, please re-enable afterwards.") - self.descriptor_calculator.parameters.descriptors_contain_xyz = \ + printout( + "Disabling XYZ-cutting from descriptor data for " + "shuffling. If needed, please re-enable afterwards." + ) + self.descriptor_calculator.parameters.descriptors_contain_xyz = ( False - -
    [docs] def add_snapshot(self, input_file, input_directory, - output_file, output_directory, - snapshot_type="numpy"): + ) + +
    [docs] def add_snapshot( + self, + input_file, + input_directory, + output_file, + output_directory, + snapshot_type="numpy", + ): """ Add a snapshot to the data pipeline. @@ -143,100 +159,151 @@

    Source code for mala.datahandling.data_shuffler

    < Either "numpy" or "openpmd" based on what kind of files you want to operate on. """ - super(DataShuffler, self).\ - add_snapshot(input_file, input_directory, - output_file, output_directory, - add_snapshot_as="te", - output_units="None", input_units="None", - calculation_output_file="", - snapshot_type=snapshot_type)
    - - def __shuffle_numpy(self, number_of_new_snapshots, shuffle_dimensions, - descriptor_save_path, save_name, target_save_path, - permutations, file_ending): + super(DataShuffler, self).add_snapshot( + input_file, + input_directory, + output_file, + output_directory, + add_snapshot_as="te", + output_units="None", + input_units="None", + calculation_output_file="", + snapshot_type=snapshot_type, + )
    + + def __shuffle_numpy( + self, + number_of_new_snapshots, + shuffle_dimensions, + descriptor_save_path, + save_name, + target_save_path, + permutations, + file_ending, + ): # Load the data (via memmap). descriptor_data = [] target_data = [] - for idx, snapshot in enumerate(self.parameters. - snapshot_directories_list): + for idx, snapshot in enumerate( + self.parameters.snapshot_directories_list + ): # TODO: Use descriptor and target calculator for this. - descriptor_data.append(np.load(os.path.join(snapshot. - input_npy_directory, - snapshot.input_npy_file), - mmap_mode="r")) - target_data.append(np.load(os.path.join(snapshot. - output_npy_directory, - snapshot.output_npy_file), - mmap_mode="r")) + descriptor_data.append( + np.load( + os.path.join( + snapshot.input_npy_directory, snapshot.input_npy_file + ), + mmap_mode="r", + ) + ) + target_data.append( + np.load( + os.path.join( + snapshot.output_npy_directory, + snapshot.output_npy_file, + ), + mmap_mode="r", + ) + ) # Do the actual shuffling. for i in range(0, number_of_new_snapshots): - new_descriptors = np.zeros((int(np.prod(shuffle_dimensions)), - self.input_dimension), - dtype=DEFAULT_NP_DATA_DTYPE) - new_targets = np.zeros((int(np.prod(shuffle_dimensions)), - self.output_dimension), - dtype=DEFAULT_NP_DATA_DTYPE) + new_descriptors = np.zeros( + (int(np.prod(shuffle_dimensions)), self.input_dimension), + dtype=DEFAULT_NP_DATA_DTYPE, + ) + new_targets = np.zeros( + (int(np.prod(shuffle_dimensions)), self.output_dimension), + dtype=DEFAULT_NP_DATA_DTYPE, + ) last_start = 0 - descriptor_name = os.path.join(descriptor_save_path, - save_name.replace("*", str(i))) - target_name = os.path.join(target_save_path, - save_name.replace("*", str(i))) + descriptor_name = os.path.join( + descriptor_save_path, save_name.replace("*", str(i)) + ) + target_name = os.path.join( + target_save_path, save_name.replace("*", str(i)) + ) # Each new snapshot gets an number_of_new_snapshots-th from each # snapshot. for j in range(0, self.nr_snapshots): - current_grid_size = self.parameters.\ - snapshot_directories_list[j].grid_size - current_chunk = int(current_grid_size / - number_of_new_snapshots) - new_descriptors[last_start:current_chunk+last_start] = \ - descriptor_data[j].reshape(current_grid_size, - self.input_dimension) \ - [i*current_chunk:(i+1)*current_chunk, :] - new_targets[last_start:current_chunk+last_start] = \ - target_data[j].reshape(current_grid_size, - self.output_dimension) \ - [i*current_chunk:(i+1)*current_chunk, :] + current_grid_size = self.parameters.snapshot_directories_list[ + j + ].grid_size + current_chunk = int( + current_grid_size / number_of_new_snapshots + ) + new_descriptors[ + last_start : current_chunk + last_start + ] = descriptor_data[j].reshape( + current_grid_size, self.input_dimension + )[ + i * current_chunk : (i + 1) * current_chunk, : + ] + new_targets[ + last_start : current_chunk + last_start + ] = target_data[j].reshape( + current_grid_size, self.output_dimension + )[ + i * current_chunk : (i + 1) * current_chunk, : + ] last_start += current_chunk # Randomize and save to disk. new_descriptors = new_descriptors[permutations[i]] new_targets = new_targets[permutations[i]] - new_descriptors = new_descriptors.reshape([shuffle_dimensions[0], - shuffle_dimensions[1], - shuffle_dimensions[2], - self.input_dimension]) - new_targets = new_targets.reshape([shuffle_dimensions[0], - shuffle_dimensions[1], - shuffle_dimensions[2], - self.output_dimension]) + new_descriptors = new_descriptors.reshape( + [ + shuffle_dimensions[0], + shuffle_dimensions[1], + shuffle_dimensions[2], + self.input_dimension, + ] + ) + new_targets = new_targets.reshape( + [ + shuffle_dimensions[0], + shuffle_dimensions[1], + shuffle_dimensions[2], + self.output_dimension, + ] + ) if file_ending == "npy": - self.descriptor_calculator.\ - write_to_numpy_file(descriptor_name+".in.npy", - new_descriptors) - self.target_calculator.\ - write_to_numpy_file(target_name+".out.npy", - new_targets) + self.descriptor_calculator.write_to_numpy_file( + descriptor_name + ".in.npy", new_descriptors + ) + self.target_calculator.write_to_numpy_file( + target_name + ".out.npy", new_targets + ) else: # We check above that in the non-numpy case, OpenPMD will work. - self.descriptor_calculator.grid_dimensions = \ - list(shuffle_dimensions) - self.target_calculator.grid_dimensions = \ - list(shuffle_dimensions) - self.descriptor_calculator.\ - write_to_openpmd_file(descriptor_name+".in."+file_ending, - new_descriptors, - additional_attributes={"global_shuffling_seed": self.parameters.shuffling_seed, - "local_shuffling_seed": i*self.parameters.shuffling_seed}, - internal_iteration_number=i) - self.target_calculator.\ - write_to_openpmd_file(target_name+".out."+file_ending, - array=new_targets, - additional_attributes={"global_shuffling_seed": self.parameters.shuffling_seed, - "local_shuffling_seed": i*self.parameters.shuffling_seed}, - internal_iteration_number=i) + self.descriptor_calculator.grid_dimensions = list( + shuffle_dimensions + ) + self.target_calculator.grid_dimensions = list( + shuffle_dimensions + ) + self.descriptor_calculator.write_to_openpmd_file( + descriptor_name + ".in." + file_ending, + new_descriptors, + additional_attributes={ + "global_shuffling_seed": self.parameters.shuffling_seed, + "local_shuffling_seed": i + * self.parameters.shuffling_seed, + }, + internal_iteration_number=i, + ) + self.target_calculator.write_to_openpmd_file( + target_name + ".out." + file_ending, + array=new_targets, + additional_attributes={ + "global_shuffling_seed": self.parameters.shuffling_seed, + "local_shuffling_seed": i + * self.parameters.shuffling_seed, + }, + internal_iteration_number=i, + ) # The function __shuffle_openpmd can be used to shuffle descriptor data and # target data. @@ -244,8 +311,15 @@

    Source code for mala.datahandling.data_shuffler

    < # Use this class to parameterize which of both should be shuffled. class __DescriptorOrTarget: - def __init__(self, save_path, npy_directory, npy_file, calculator, - name_infix, dimension): + def __init__( + self, + save_path, + npy_directory, + npy_file, + calculator, + name_infix, + dimension, + ): self.save_path = save_path self.npy_directory = npy_directory self.npy_file = npy_file @@ -259,10 +333,15 @@

    Source code for mala.datahandling.data_shuffler

    < self.rank = 0 self.size = 1 - - def __shuffle_openpmd(self, dot: __DescriptorOrTarget, - number_of_new_snapshots, shuffle_dimensions, - save_name, permutations, file_ending): + def __shuffle_openpmd( + self, + dot: __DescriptorOrTarget, + number_of_new_snapshots, + shuffle_dimensions, + save_name, + permutations, + file_ending, + ): import openpmd_api as io if self.parameters._configuration["mpi"]: @@ -271,18 +350,21 @@

    Source code for mala.datahandling.data_shuffler

    < comm = self.__MockedMPIComm() import math + items_per_process = math.ceil(number_of_new_snapshots / comm.size) my_items_start = comm.rank * items_per_process - my_items_end = min((comm.rank + 1) * items_per_process, - number_of_new_snapshots) + my_items_end = min( + (comm.rank + 1) * items_per_process, number_of_new_snapshots + ) my_items_count = my_items_end - my_items_start if self.parameters._configuration["mpi"]: # imagine we have 20 new snapshots to create, but 100 ranks # it's sufficient to let only the first 20 ranks participate in the # following code - num_of_participating_ranks = math.ceil(number_of_new_snapshots / - items_per_process) + num_of_participating_ranks = math.ceil( + number_of_new_snapshots / items_per_process + ) color = comm.rank < num_of_participating_ranks comm = comm.Split(color=int(color), key=comm.rank) if not color: @@ -291,20 +373,30 @@

    Source code for mala.datahandling.data_shuffler

    < # Load the data input_series_list = [] for idx, snapshot in enumerate( - self.parameters.snapshot_directories_list): + self.parameters.snapshot_directories_list + ): # TODO: Use descriptor and target calculator for this. if isinstance(comm, self.__MockedMPIComm): input_series_list.append( io.Series( - os.path.join(dot.npy_directory(snapshot), - dot.npy_file(snapshot)), - io.Access.read_only)) + os.path.join( + dot.npy_directory(snapshot), + dot.npy_file(snapshot), + ), + io.Access.read_only, + ) + ) else: input_series_list.append( io.Series( - os.path.join(dot.npy_directory(snapshot), - dot.npy_file(snapshot)), - io.Access.read_only, comm)) + os.path.join( + dot.npy_directory(snapshot), + dot.npy_file(snapshot), + ), + io.Access.read_only, + comm, + ) + ) # Peek into the input snapshots to determine the datatypes. for series in input_series_list: @@ -331,8 +423,10 @@

    Source code for mala.datahandling.data_shuffler

    < extent_dim_0 = dset[slice_dimension] if extent_dim_0 % n != 0: raise Exception( - "Dataset {} cannot be split into {} chunks on dimension {}." - .format(dset, n, slice_dimension)) + "Dataset {} cannot be split into {} chunks on dimension {}.".format( + dset, n, slice_dimension + ) + ) single_chunk_len = extent_dim_0 // n offset[slice_dimension] = i * single_chunk_len extent[slice_dimension] = single_chunk_len @@ -344,36 +438,48 @@

    Source code for mala.datahandling.data_shuffler

    < for i in range(my_items_start, my_items_end): # We check above that in the non-numpy case, OpenPMD will work. dot.calculator.grid_dimensions = list(shuffle_dimensions) - name_prefix = os.path.join(dot.save_path, - save_name.replace("*", str(i))) + name_prefix = os.path.join( + dot.save_path, save_name.replace("*", str(i)) + ) # do NOT open with MPI shuffled_snapshot_series = io.Series( name_prefix + dot.name_infix + file_ending, io.Access.create, options=json.dumps( - self.parameters._configuration["openpmd_configuration"])) - dot.calculator.\ - write_to_openpmd_file(shuffled_snapshot_series, - PhysicalData.SkipArrayWriting(dataset, feature_size), - additional_attributes={"global_shuffling_seed": self.parameters.shuffling_seed, - "local_shuffling_seed": i*self.parameters.shuffling_seed}, - internal_iteration_number=i) + self.parameters._configuration["openpmd_configuration"] + ), + ) + dot.calculator.write_to_openpmd_file( + shuffled_snapshot_series, + PhysicalData.SkipArrayWriting(dataset, feature_size), + additional_attributes={ + "global_shuffling_seed": self.parameters.shuffling_seed, + "local_shuffling_seed": i * self.parameters.shuffling_seed, + }, + internal_iteration_number=i, + ) mesh_out = shuffled_snapshot_series.write_iterations()[i].meshes[ - dot.calculator.data_name] + dot.calculator.data_name + ] new_array = np.zeros( (dot.dimension, int(np.prod(shuffle_dimensions))), - dtype=dataset.dtype) + dtype=dataset.dtype, + ) # Need to add to these in the loop as the single chunks might have # different sizes to_chunk_offset, to_chunk_extent = 0, 0 for j in range(0, self.nr_snapshots): - extent_in = self.parameters.snapshot_directories_list[j].grid_dimension + extent_in = self.parameters.snapshot_directories_list[ + j + ].grid_dimension if len(input_series_list[j].iterations) != 1: raise Exception( - "Input Series '{}' has {} iterations (needs exactly one)." - .format(input_series_list[j].name, - len(input_series_list[j].iterations))) + "Input Series '{}' has {} iterations (needs exactly one).".format( + input_series_list[j].name, + len(input_series_list[j].iterations), + ) + ) for iteration in input_series_list[j].read_iterations(): mesh_in = iteration.meshes[dot.calculator.data_name] break @@ -384,19 +490,23 @@

    Source code for mala.datahandling.data_shuffler

    < # in openPMD, to_chunk_extent describes the upper coordinate of # the slice, as is usual in Python. from_chunk_offset, from_chunk_extent = from_chunk_i( - i, number_of_new_snapshots, extent_in) + i, number_of_new_snapshots, extent_in + ) to_chunk_offset = to_chunk_extent to_chunk_extent = to_chunk_offset + np.prod(from_chunk_extent) for dimension in range(len(mesh_in)): mesh_in[str(dimension)].load_chunk( new_array[dimension, to_chunk_offset:to_chunk_extent], - from_chunk_offset, from_chunk_extent) + from_chunk_offset, + from_chunk_extent, + ) mesh_in.series_flush() for k in range(feature_size): rc = mesh_out[str(k)] rc[:, :, :] = new_array[k, :][permutations[i]].reshape( - shuffle_dimensions) + shuffle_dimensions + ) shuffled_snapshot_series.close() # Ensure consistent parallel destruction @@ -404,12 +514,14 @@

    Source code for mala.datahandling.data_shuffler

    < for series in input_series_list: series.close() -
    [docs] def shuffle_snapshots(self, - complete_save_path=None, - descriptor_save_path=None, - target_save_path=None, - save_name="mala_shuffled_snapshot*", - number_of_shuffled_snapshots=None): +
    [docs] def shuffle_snapshots( + self, + complete_save_path=None, + descriptor_save_path=None, + target_save_path=None, + save_name="mala_shuffled_snapshot*", + number_of_shuffled_snapshots=None, + ): """ Shuffle the snapshots into new snapshots. @@ -452,8 +564,9 @@

    Source code for mala.datahandling.data_shuffler

    < import openpmd_api as io if file_ending not in io.file_extensions: - raise Exception("Invalid file ending selected: " + - file_ending) + raise Exception( + "Invalid file ending selected: " + file_ending + ) else: file_ending = "npy" @@ -469,12 +582,15 @@

    Source code for mala.datahandling.data_shuffler

    < if len(snapshot_types) > 1: raise Exception( "[data_shuffler] Can only deal with one type of input snapshot" - + " at once (openPMD or numpy).") + + " at once (openPMD or numpy)." + ) snapshot_type = snapshot_types.pop() del snapshot_types - snapshot_size_list = [snapshot.grid_size for snapshot in - self.parameters.snapshot_directories_list] + snapshot_size_list = [ + snapshot.grid_size + for snapshot in self.parameters.snapshot_directories_list + ] number_of_data_points = np.sum(snapshot_size_list) if number_of_shuffled_snapshots is None: @@ -483,8 +599,9 @@

    Source code for mala.datahandling.data_shuffler

    < # If all snapshots have the same size, we can just replicate the # snapshot structure. if np.max(snapshot_size_list) == np.min(snapshot_size_list): - shuffle_dimensions = self.parameters.\ - snapshot_directories_list[0].grid_dimension + shuffle_dimensions = self.parameters.snapshot_directories_list[ + 0 + ].grid_dimension number_of_new_snapshots = self.nr_snapshots else: # If the snapshots have different sizes we simply create @@ -494,30 +611,44 @@

    Source code for mala.datahandling.data_shuffler

    < number_of_new_snapshots += 1 # If they do have different sizes, we start with the smallest # snapshot, there is some padding down below anyhow. - shuffle_dimensions = [int(number_of_data_points / - number_of_new_snapshots), 1, 1] + shuffle_dimensions = [ + int(number_of_data_points / number_of_new_snapshots), + 1, + 1, + ] - if snapshot_type == 'openpmd': + if snapshot_type == "openpmd": import math import functools + number_of_new_snapshots = functools.reduce( - math.gcd, [ - snapshot.grid_dimension[0] for snapshot in - self.parameters.snapshot_directories_list - ], number_of_new_snapshots) + math.gcd, + [ + snapshot.grid_dimension[0] + for snapshot in self.parameters.snapshot_directories_list + ], + number_of_new_snapshots, + ) else: number_of_new_snapshots = number_of_shuffled_snapshots - if snapshot_type == 'openpmd': + if snapshot_type == "openpmd": import math import functools + specified_number_of_new_snapshots = number_of_new_snapshots number_of_new_snapshots = functools.reduce( - math.gcd, [ - snapshot.grid_dimension[0] for snapshot in - self.parameters.snapshot_directories_list - ], number_of_new_snapshots) - if number_of_new_snapshots != specified_number_of_new_snapshots: + math.gcd, + [ + snapshot.grid_dimension[0] + for snapshot in self.parameters.snapshot_directories_list + ], + number_of_new_snapshots, + ) + if ( + number_of_new_snapshots + != specified_number_of_new_snapshots + ): print( f"[openPMD shuffling] Reduced the number of output snapshots to " f"{number_of_new_snapshots} because of the dataset dimensions." @@ -525,14 +656,22 @@

    Source code for mala.datahandling.data_shuffler

    < del specified_number_of_new_snapshots if number_of_data_points % number_of_new_snapshots != 0: - raise Exception("Cannot create this number of snapshots " - "from data provided.") + raise Exception( + "Cannot create this number of snapshots " + "from data provided." + ) else: - shuffle_dimensions = [int(number_of_data_points / - number_of_new_snapshots), 1, 1] - - printout("Data shuffler will generate", number_of_new_snapshots, - "new snapshots.") + shuffle_dimensions = [ + int(number_of_data_points / number_of_new_snapshots), + 1, + 1, + ] + + printout( + "Data shuffler will generate", + number_of_new_snapshots, + "new snapshots.", + ) printout("Shuffled snapshot dimension will be ", shuffle_dimensions) # Prepare permutations. @@ -542,34 +681,57 @@

    Source code for mala.datahandling.data_shuffler

    < # This makes the shuffling deterministic, if specified by the user. if self.parameters.shuffling_seed is not None: - np.random.seed(i*self.parameters.shuffling_seed) - permutations.append(np.random.permutation( - int(np.prod(shuffle_dimensions)))) - - if snapshot_type == 'numpy': - self.__shuffle_numpy(number_of_new_snapshots, shuffle_dimensions, - descriptor_save_path, save_name, - target_save_path, permutations, file_ending) - elif snapshot_type == 'openpmd': + np.random.seed(i * self.parameters.shuffling_seed) + permutations.append( + np.random.permutation(int(np.prod(shuffle_dimensions))) + ) + + if snapshot_type == "numpy": + self.__shuffle_numpy( + number_of_new_snapshots, + shuffle_dimensions, + descriptor_save_path, + save_name, + target_save_path, + permutations, + file_ending, + ) + elif snapshot_type == "openpmd": descriptor = self.__DescriptorOrTarget( - descriptor_save_path, lambda x: x.input_npy_directory, - lambda x: x.input_npy_file, self.descriptor_calculator, ".in.", - self.input_dimension) - self.__shuffle_openpmd(descriptor, number_of_new_snapshots, - shuffle_dimensions, save_name, permutations, - file_ending) - target = self.__DescriptorOrTarget(target_save_path, - lambda x: x.output_npy_directory, - lambda x: x.output_npy_file, - self.target_calculator, ".out.", - self.output_dimension) - self.__shuffle_openpmd(target, number_of_new_snapshots, - shuffle_dimensions, save_name, permutations, - file_ending) + descriptor_save_path, + lambda x: x.input_npy_directory, + lambda x: x.input_npy_file, + self.descriptor_calculator, + ".in.", + self.input_dimension, + ) + self.__shuffle_openpmd( + descriptor, + number_of_new_snapshots, + shuffle_dimensions, + save_name, + permutations, + file_ending, + ) + target = self.__DescriptorOrTarget( + target_save_path, + lambda x: x.output_npy_directory, + lambda x: x.output_npy_file, + self.target_calculator, + ".out.", + self.output_dimension, + ) + self.__shuffle_openpmd( + target, + number_of_new_snapshots, + shuffle_dimensions, + save_name, + permutations, + file_ending, + ) else: raise Exception("Unknown snapshot type: {}".format(snapshot_type)) - # Since no training will be done with this class, we should always # clear the data at the end. self.clear_data()
    diff --git a/_modules/mala/datahandling/fast_tensor_dataset.html b/_modules/mala/datahandling/fast_tensor_dataset.html index da7dedb2f..115e91623 100644 --- a/_modules/mala/datahandling/fast_tensor_dataset.html +++ b/_modules/mala/datahandling/fast_tensor_dataset.html @@ -75,6 +75,7 @@

    Source code for mala.datahandling.fast_tensor_dataset

     """A special type of tensor data set for improved performance."""
    +
     import numpy as np
     import torch
     
    @@ -111,7 +112,9 @@ 

    Source code for mala.datahandling.fast_tensor_dataset

    batch : tuple The data tuple for this batch. """ - batch = self.indices[idx*self.batch_size:(idx+1)*self.batch_size] + batch = self.indices[ + idx * self.batch_size : (idx + 1) * self.batch_size + ] rv = tuple(t[batch, ...] for t in self.tensors) return rv diff --git a/_modules/mala/datahandling/lazy_load_dataset.html b/_modules/mala/datahandling/lazy_load_dataset.html index 0b86df65d..a8c914b21 100644 --- a/_modules/mala/datahandling/lazy_load_dataset.html +++ b/_modules/mala/datahandling/lazy_load_dataset.html @@ -75,6 +75,7 @@

    Source code for mala.datahandling.lazy_load_dataset

     """DataSet for lazy-loading."""
    +
     import os
     
     try:
    @@ -91,7 +92,7 @@ 

    Source code for mala.datahandling.lazy_load_dataset

    from mala.datahandling.snapshot import Snapshot -
    [docs]class LazyLoadDataset(torch.utils.data.Dataset): +
    [docs]class LazyLoadDataset(Dataset): """ DataSet class for lazy loading. @@ -129,10 +130,17 @@

    Source code for mala.datahandling.lazy_load_dataset

    If True, then the gradient is stored for the inputs. """ - def __init__(self, input_dimension, output_dimension, input_data_scaler, - output_data_scaler, descriptor_calculator, - target_calculator, use_horovod, - input_requires_grad=False): + def __init__( + self, + input_dimension, + output_dimension, + input_data_scaler, + output_data_scaler, + descriptor_calculator, + target_calculator, + use_horovod, + input_requires_grad=False, + ): self.snapshot_list = [] self.input_dimension = input_dimension self.output_dimension = output_dimension @@ -142,8 +150,9 @@

    Source code for mala.datahandling.lazy_load_dataset

    self.target_calculator = target_calculator self.number_of_snapshots = 0 self.total_size = 0 - self.descriptors_contain_xyz = self.descriptor_calculator.\ - descriptors_contain_xyz + self.descriptors_contain_xyz = ( + self.descriptor_calculator.descriptors_contain_xyz + ) self.currently_loaded_file = None self.input_data = np.empty(0) self.output_data = np.empty(0) @@ -205,44 +214,56 @@

    Source code for mala.datahandling.lazy_load_dataset

    """ # Load the data into RAM. if self.snapshot_list[file_index].snapshot_type == "numpy": - self.input_data = self.descriptor_calculator. \ - read_from_numpy_file( - os.path.join(self.snapshot_list[file_index].input_npy_directory, - self.snapshot_list[file_index].input_npy_file), - units=self.snapshot_list[file_index].input_units) - self.output_data = self.target_calculator. \ - read_from_numpy_file( - os.path.join(self.snapshot_list[file_index].output_npy_directory, - self.snapshot_list[file_index].output_npy_file), - units=self.snapshot_list[file_index].output_units) + self.input_data = self.descriptor_calculator.read_from_numpy_file( + os.path.join( + self.snapshot_list[file_index].input_npy_directory, + self.snapshot_list[file_index].input_npy_file, + ), + units=self.snapshot_list[file_index].input_units, + ) + self.output_data = self.target_calculator.read_from_numpy_file( + os.path.join( + self.snapshot_list[file_index].output_npy_directory, + self.snapshot_list[file_index].output_npy_file, + ), + units=self.snapshot_list[file_index].output_units, + ) elif self.snapshot_list[file_index].snapshot_type == "openpmd": - self.input_data = self.descriptor_calculator. \ - read_from_openpmd_file( - os.path.join(self.snapshot_list[file_index].input_npy_directory, - self.snapshot_list[file_index].input_npy_file)) - self.output_data = self.target_calculator. \ - read_from_openpmd_file( - os.path.join(self.snapshot_list[file_index].output_npy_directory, - self.snapshot_list[file_index].output_npy_file)) + self.input_data = ( + self.descriptor_calculator.read_from_openpmd_file( + os.path.join( + self.snapshot_list[file_index].input_npy_directory, + self.snapshot_list[file_index].input_npy_file, + ) + ) + ) + self.output_data = self.target_calculator.read_from_openpmd_file( + os.path.join( + self.snapshot_list[file_index].output_npy_directory, + self.snapshot_list[file_index].output_npy_file, + ) + ) # Transform the data. - self.input_data = \ - self.input_data.reshape([self.snapshot_list[file_index].grid_size, - self.input_dimension]) + self.input_data = self.input_data.reshape( + [self.snapshot_list[file_index].grid_size, self.input_dimension] + ) if self.input_data.dtype != DEFAULT_NP_DATA_DTYPE: self.input_data = self.input_data.astype(DEFAULT_NP_DATA_DTYPE) self.input_data = torch.from_numpy(self.input_data).float() self.input_data_scaler.transform(self.input_data) self.input_data.requires_grad = self.input_requires_grad - self.output_data = \ - self.output_data.reshape([self.snapshot_list[file_index].grid_size, - self.output_dimension]) + self.output_data = self.output_data.reshape( + [self.snapshot_list[file_index].grid_size, self.output_dimension] + ) if self.return_outputs_directly is False: self.output_data = np.array(self.output_data) if self.output_data.dtype != DEFAULT_NP_DATA_DTYPE: - self.output_data = self.output_data.astype(DEFAULT_NP_DATA_DTYPE) + self.output_data = self.output_data.astype( + DEFAULT_NP_DATA_DTYPE + ) self.output_data = torch.from_numpy(self.output_data).float() self.output_data_scaler.transform(self.output_data) @@ -258,9 +279,11 @@

    Source code for mala.datahandling.lazy_load_dataset

    file_index = i # From the end of previous file to beginning of new. - if index_in_file == self.snapshot_list[i].grid_size and \ - is_start: - file_index = i+1 + if ( + index_in_file == self.snapshot_list[i].grid_size + and is_start + ): + file_index = i + 1 index_in_file = 0 break else: @@ -297,35 +320,44 @@

    Source code for mala.datahandling.lazy_load_dataset

    # Find out if new data is needed. if file_index != self.currently_loaded_file: self.get_new_data(file_index) - return self.input_data[index_in_file], \ - self.output_data[index_in_file] + return ( + self.input_data[index_in_file], + self.output_data[index_in_file], + ) elif isinstance(idx, slice): # If a slice is requested, we have to find out if it spans files. - file_index_start, index_in_file_start = self.\ - _get_file_index(idx.start, is_slice=True, is_start=True) - file_index_stop, index_in_file_stop = self.\ - _get_file_index(idx.stop, is_slice=True) + file_index_start, index_in_file_start = self._get_file_index( + idx.start, is_slice=True, is_start=True + ) + file_index_stop, index_in_file_stop = self._get_file_index( + idx.stop, is_slice=True + ) # If it does, we cannot deliver. # Take care though, if a full snapshot is requested, # the stop index will point to the wrong file. if file_index_start != file_index_stop: if index_in_file_stop == 0: - index_in_file_stop = self.snapshot_list[file_index_stop].\ - grid_size + index_in_file_stop = self.snapshot_list[ + file_index_stop + ].grid_size else: - raise Exception("Lazy loading currently only supports " - "slices in one file. " - "You have requested a slice over two " - "files.") + raise Exception( + "Lazy loading currently only supports " + "slices in one file. " + "You have requested a slice over two " + "files." + ) # Find out if new data is needed. file_index = file_index_start if file_index != self.currently_loaded_file: self.get_new_data(file_index) - return self.input_data[index_in_file_start:index_in_file_stop], \ - self.output_data[index_in_file_start:index_in_file_stop] + return ( + self.input_data[index_in_file_start:index_in_file_stop], + self.output_data[index_in_file_start:index_in_file_stop], + ) else: raise Exception("Invalid idx provided.") diff --git a/_modules/mala/datahandling/lazy_load_dataset_single.html b/_modules/mala/datahandling/lazy_load_dataset_single.html index 7201b770c..88eab43e0 100644 --- a/_modules/mala/datahandling/lazy_load_dataset_single.html +++ b/_modules/mala/datahandling/lazy_load_dataset_single.html @@ -75,15 +75,16 @@

    Source code for mala.datahandling.lazy_load_dataset_single

     """DataSet for lazy-loading."""
    +
     import os
     from multiprocessing import shared_memory
     
     import numpy as np
     import torch
    -from torch.utils.data import Dataset, DataLoader
    +from torch.utils.data import Dataset
     
     
    -
    [docs]class LazyLoadDatasetSingle(torch.utils.data.Dataset): +
    [docs]class LazyLoadDatasetSingle(Dataset): """ DataSet class for lazy loading. @@ -121,10 +122,19 @@

    Source code for mala.datahandling.lazy_load_dataset_single

    If True, then the gradient is stored for the inputs. """ - def __init__(self, batch_size, snapshot, input_dimension, output_dimension, - input_data_scaler, output_data_scaler, descriptor_calculator, - target_calculator, use_horovod, - input_requires_grad=False): + def __init__( + self, + batch_size, + snapshot, + input_dimension, + output_dimension, + input_data_scaler, + output_data_scaler, + descriptor_calculator, + target_calculator, + use_horovod, + input_requires_grad=False, + ): self.snapshot = snapshot self.input_dimension = input_dimension self.output_dimension = output_dimension @@ -134,8 +144,9 @@

    Source code for mala.datahandling.lazy_load_dataset_single

    self.target_calculator = target_calculator self.number_of_snapshots = 0 self.total_size = 0 - self.descriptors_contain_xyz = self.descriptor_calculator.\ - descriptors_contain_xyz + self.descriptors_contain_xyz = ( + self.descriptor_calculator.descriptors_contain_xyz + ) self.currently_loaded_file = None self.input_data = np.empty(0) self.output_data = np.empty(0) @@ -159,25 +170,45 @@

    Source code for mala.datahandling.lazy_load_dataset_single

    """ # Get array shape and data types if self.snapshot.snapshot_type == "numpy": - self.input_shape, self.input_dtype = self.descriptor_calculator. \ - read_dimensions_from_numpy_file( - os.path.join(self.snapshot.input_npy_directory, - self.snapshot.input_npy_file), read_dtype=True) - - self.output_shape, self.output_dtype = self.target_calculator. \ - read_dimensions_from_numpy_file( - os.path.join(self.snapshot.output_npy_directory, - self.snapshot.output_npy_file), read_dtype=True) + self.input_shape, self.input_dtype = ( + self.descriptor_calculator.read_dimensions_from_numpy_file( + os.path.join( + self.snapshot.input_npy_directory, + self.snapshot.input_npy_file, + ), + read_dtype=True, + ) + ) + + self.output_shape, self.output_dtype = ( + self.target_calculator.read_dimensions_from_numpy_file( + os.path.join( + self.snapshot.output_npy_directory, + self.snapshot.output_npy_file, + ), + read_dtype=True, + ) + ) elif self.snapshot.snapshot_type == "openpmd": - self.input_shape, self.input_dtype = self.descriptor_calculator. \ - read_dimensions_from_openpmd_file( - os.path.join(self.snapshot.input_npy_directory, - self.snapshot.input_npy_file), read_dtype=True) - - self.output_shape, self.output_dtype = self.target_calculator. \ - read_dimensions_from_openpmd_file( - os.path.join(self.snapshot.output_npy_directory, - self.snapshot.output_npy_file), read_dtype=True) + self.input_shape, self.input_dtype = ( + self.descriptor_calculator.read_dimensions_from_openpmd_file( + os.path.join( + self.snapshot.input_npy_directory, + self.snapshot.input_npy_file, + ), + read_dtype=True, + ) + ) + + self.output_shape, self.output_dtype = ( + self.target_calculator.read_dimensions_from_openpmd_file( + os.path.join( + self.snapshot.output_npy_directory, + self.snapshot.output_npy_file, + ), + read_dtype=True, + ) + ) else: raise Exception("Invalid snapshot type selected.") @@ -185,8 +216,9 @@

    Source code for mala.datahandling.lazy_load_dataset_single

    # usage to data in FP32 type (which is a good idea anyway to save # memory) if self.input_dtype != np.float32 or self.output_dtype != np.float32: - raise Exception("LazyLoadDatasetSingle requires numpy data in " - "FP32.") + raise Exception( + "LazyLoadDatasetSingle requires numpy data in FP32." + ) # Allocate shared memory buffer input_bytes = self.input_dtype.itemsize * np.prod(self.input_shape) @@ -240,16 +272,22 @@

    Source code for mala.datahandling.lazy_load_dataset_single

    input_shm = shared_memory.SharedMemory(name=self.input_shm_name) output_shm = shared_memory.SharedMemory(name=self.output_shm_name) - input_data = np.ndarray(shape=[self.snapshot.grid_size, - self.input_dimension], - dtype=np.float32, buffer=input_shm.buf) - output_data = np.ndarray(shape=[self.snapshot.grid_size, - self.output_dimension], - dtype=np.float32, buffer=output_shm.buf) - if idx == self.len-1: - batch = self.indices[idx * self.batch_size:] + input_data = np.ndarray( + shape=[self.snapshot.grid_size, self.input_dimension], + dtype=np.float32, + buffer=input_shm.buf, + ) + output_data = np.ndarray( + shape=[self.snapshot.grid_size, self.output_dimension], + dtype=np.float32, + buffer=output_shm.buf, + ) + if idx == self.len - 1: + batch = self.indices[idx * self.batch_size :] else: - batch = self.indices[idx*self.batch_size:(idx+1)*self.batch_size] + batch = self.indices[ + idx * self.batch_size : (idx + 1) * self.batch_size + ] # print(batch.shape) input_batch = input_data[batch, ...] @@ -296,7 +334,6 @@

    Source code for mala.datahandling.lazy_load_dataset_single

    single dataset object is used back to back. """ np.random.shuffle(self.indices)
    -
    diff --git a/_modules/mala/datahandling/multi_lazy_load_data_loader.html b/_modules/mala/datahandling/multi_lazy_load_data_loader.html index e2b0060b0..b07bea729 100644 --- a/_modules/mala/datahandling/multi_lazy_load_data_loader.html +++ b/_modules/mala/datahandling/multi_lazy_load_data_loader.html @@ -75,6 +75,7 @@

    Source code for mala.datahandling.multi_lazy_load_data_loader

     """Class for loading multiple data sets with pre-fetching."""
    +
     import os
     
     import numpy as np
    @@ -98,26 +99,27 @@ 

    Source code for mala.datahandling.multi_lazy_load_data_loader

    self.datasets = datasets self.loaders = [] for d in datasets: - self.loaders.append(DataLoader(d, - batch_size=None, - **kwargs, - shuffle=False)) + self.loaders.append( + DataLoader(d, batch_size=None, **kwargs, shuffle=False) + ) # Create single process pool for prefetching # Can use ThreadPoolExecutor for debugging. - #self.pool = concurrent.futures.ThreadPoolExecutor(1) + # self.pool = concurrent.futures.ThreadPoolExecutor(1) self.pool = concurrent.futures.ProcessPoolExecutor(1) # Allocate shared memory and commence file load for first # dataset in list dset = self.datasets[0] dset.allocate_shared_mem() - self.load_future = self.pool.submit(self.load_snapshot_to_shm, - dset.snapshot, - dset.descriptor_calculator, - dset.target_calculator, - dset.input_shm_name, - dset.output_shm_name) + self.load_future = self.pool.submit( + self.load_snapshot_to_shm, + dset.snapshot, + dset.descriptor_calculator, + dset.target_calculator, + dset.input_shm_name, + dset.output_shm_name, + ) def __len__(self): """ @@ -169,13 +171,15 @@

    Source code for mala.datahandling.multi_lazy_load_data_loader

    # Prefetch next file (looping around epoch boundary) dset = self.datasets[self.count % len(self.loaders)] if not dset.loaded: - dset.allocate_shared_mem() - self.load_future = self.pool.submit(self.load_snapshot_to_shm, - dset.snapshot, - dset.descriptor_calculator, - dset.target_calculator, - dset.input_shm_name, - dset.output_shm_name) + dset.allocate_shared_mem() + self.load_future = self.pool.submit( + self.load_snapshot_to_shm, + dset.snapshot, + dset.descriptor_calculator, + dset.target_calculator, + dset.input_shm_name, + dset.output_shm_name, + ) # Return current return self.loaders[self.count - 1] @@ -193,8 +197,13 @@

    Source code for mala.datahandling.multi_lazy_load_data_loader

    # Worker function to load data into shared memory (limited to numpy files # only for now)
    [docs] @staticmethod - def load_snapshot_to_shm(snapshot, descriptor_calculator, target_calculator, - input_shm_name, output_shm_name): + def load_snapshot_to_shm( + snapshot, + descriptor_calculator, + target_calculator, + input_shm_name, + output_shm_name, + ): """ Load a snapshot into shared memory. @@ -222,61 +231,85 @@

    Source code for mala.datahandling.multi_lazy_load_data_loader

    output_shm = shared_memory.SharedMemory(name=output_shm_name) if snapshot.snapshot_type == "numpy": - input_shape, input_dtype = descriptor_calculator. \ - read_dimensions_from_numpy_file( - os.path.join(snapshot.input_npy_directory, - snapshot.input_npy_file), read_dtype=True) - - output_shape, output_dtype = target_calculator. \ - read_dimensions_from_numpy_file( - os.path.join(snapshot.output_npy_directory, - snapshot.output_npy_file), read_dtype=True) + input_shape, input_dtype = ( + descriptor_calculator.read_dimensions_from_numpy_file( + os.path.join( + snapshot.input_npy_directory, snapshot.input_npy_file + ), + read_dtype=True, + ) + ) + + output_shape, output_dtype = ( + target_calculator.read_dimensions_from_numpy_file( + os.path.join( + snapshot.output_npy_directory, + snapshot.output_npy_file, + ), + read_dtype=True, + ) + ) elif snapshot.snapshot_type == "openpmd": - input_shape, input_dtype = descriptor_calculator. \ - read_dimensions_from_openpmd_file( - os.path.join(snapshot.input_npy_directory, - snapshot.input_npy_file), read_dtype=True) - - output_shape, output_dtype = target_calculator. \ - read_dimensions_from_openpmd_file( - os.path.join(snapshot.output_npy_directory, - snapshot.output_npy_file), read_dtype=True) + input_shape, input_dtype = ( + descriptor_calculator.read_dimensions_from_openpmd_file( + os.path.join( + snapshot.input_npy_directory, snapshot.input_npy_file + ), + read_dtype=True, + ) + ) + + output_shape, output_dtype = ( + target_calculator.read_dimensions_from_openpmd_file( + os.path.join( + snapshot.output_npy_directory, + snapshot.output_npy_file, + ), + read_dtype=True, + ) + ) else: raise Exception("Invalid snapshot type selected.") # Form numpy arrays from shm buffers - input_data = np.ndarray(shape=input_shape, dtype=input_dtype, - buffer=input_shm.buf) - output_data = np.ndarray(shape=output_shape, dtype=output_dtype, - buffer=output_shm.buf) + input_data = np.ndarray( + shape=input_shape, dtype=input_dtype, buffer=input_shm.buf + ) + output_data = np.ndarray( + shape=output_shape, dtype=output_dtype, buffer=output_shm.buf + ) # Load numpy data into shm buffers if snapshot.snapshot_type == "numpy": - descriptor_calculator. \ - read_from_numpy_file( - os.path.join(snapshot.input_npy_directory, - snapshot.input_npy_file), + descriptor_calculator.read_from_numpy_file( + os.path.join( + snapshot.input_npy_directory, snapshot.input_npy_file + ), units=snapshot.input_units, - array=input_data) - target_calculator. \ - read_from_numpy_file( - os.path.join(snapshot.output_npy_directory, - snapshot.output_npy_file), + array=input_data, + ) + target_calculator.read_from_numpy_file( + os.path.join( + snapshot.output_npy_directory, snapshot.output_npy_file + ), units=snapshot.output_units, - array=output_data) - else : - descriptor_calculator. \ - read_from_openpmd_file( - os.path.join(snapshot.input_npy_directory, - snapshot.input_npy_file), + array=output_data, + ) + else: + descriptor_calculator.read_from_openpmd_file( + os.path.join( + snapshot.input_npy_directory, snapshot.input_npy_file + ), units=snapshot.input_units, - array=input_data) - target_calculator. \ - read_from_openpmd_file( - os.path.join(snapshot.output_npy_directory, - snapshot.output_npy_file), + array=input_data, + ) + target_calculator.read_from_openpmd_file( + os.path.join( + snapshot.output_npy_directory, snapshot.output_npy_file + ), units=snapshot.output_units, - array=output_data) + array=output_data, + ) # This function only loads the numpy data with scaling. Remaining data # preprocessing occurs in __getitem__ of LazyLoadDatasetSingle diff --git a/_modules/mala/datahandling/snapshot.html b/_modules/mala/datahandling/snapshot.html index e4ff830fe..289202789 100644 --- a/_modules/mala/datahandling/snapshot.html +++ b/_modules/mala/datahandling/snapshot.html @@ -75,9 +75,6 @@

    Source code for mala.datahandling.snapshot

     """Represents an entire atomic snapshot (including descriptor/target data)."""
    -from os.path import join
    -
    -import numpy as np
     
     from mala.common.json_serializable import JSONSerializable
     
    @@ -126,12 +123,18 @@ 

    Source code for mala.datahandling.snapshot

             Default is None.
         """
     
    -    def __init__(self, input_npy_file, input_npy_directory,
    -                 output_npy_file,  output_npy_directory,
    -                 snapshot_function,
    -                 input_units="", output_units="",
    -                 calculation_output="",
    -                 snapshot_type="openpmd"):
    +    def __init__(
    +        self,
    +        input_npy_file,
    +        input_npy_directory,
    +        output_npy_file,
    +        output_npy_directory,
    +        snapshot_function,
    +        input_units="",
    +        output_units="",
    +        calculation_output="",
    +        snapshot_type="openpmd",
    +    ):
             super(Snapshot, self).__init__()
     
             # Inputs.
    @@ -177,12 +180,14 @@ 

    Source code for mala.datahandling.snapshot

                 The object as read from the JSON file.
     
             """
    -        deserialized_object = cls(json_dict["input_npy_file"],
    -                                  json_dict["input_npy_directory"],
    -                                  json_dict["output_npy_file"],
    -                                  json_dict["output_npy_directory"],
    -                                  json_dict["snapshot_function"],
    -                                  json_dict["snapshot_type"])
    +        deserialized_object = cls(
    +            json_dict["input_npy_file"],
    +            json_dict["input_npy_directory"],
    +            json_dict["output_npy_file"],
    +            json_dict["output_npy_directory"],
    +            json_dict["snapshot_function"],
    +            json_dict["snapshot_type"],
    +        )
             for key in json_dict:
                 setattr(deserialized_object, key, json_dict[key])
             return deserialized_object
    diff --git a/_modules/mala/descriptors/atomic_density.html b/_modules/mala/descriptors/atomic_density.html index de3e79b06..1b1e30805 100644 --- a/_modules/mala/descriptors/atomic_density.html +++ b/_modules/mala/descriptors/atomic_density.html @@ -75,20 +75,12 @@

    Source code for mala.descriptors.atomic_density

     """Gaussian descriptor class."""
    +
     import os
     
     import ase
     import ase.io
    -try:
    -    from lammps import lammps
    -    # For version compatibility; older lammps versions (the serial version
    -    # we still use on some machines) do not have these constants.
    -    try:
    -        from lammps import constants as lammps_constants
    -    except ImportError:
    -        pass
    -except ModuleNotFoundError:
    -    pass
    +from importlib.util import find_spec
     import numpy as np
     from scipy.spatial import distance
     
    @@ -192,24 +184,30 @@ 

    Source code for mala.descriptors.atomic_density

    < optimal_sigma : float The optimal sigma value. """ - return (np.max(voxel) / reference_grid_spacing_aluminium) * \ - optimal_sigma_aluminium
    + return ( + np.max(voxel) / reference_grid_spacing_aluminium + ) * optimal_sigma_aluminium
    def _calculate(self, outdir, **kwargs): if self.parameters._configuration["lammps"]: - try: - from lammps import lammps - except ModuleNotFoundError: - printout("No LAMMPS found for descriptor calculation, " - "falling back to python.") + if find_spec("lammps") is None: + printout( + "No LAMMPS found for descriptor calculation, " + "falling back to python." + ) return self.__calculate_python(**kwargs) - - return self.__calculate_lammps(outdir, **kwargs) + else: + return self.__calculate_lammps(outdir, **kwargs) else: return self.__calculate_python(**kwargs) def __calculate_lammps(self, outdir, **kwargs): """Perform actual Gaussian descriptor calculation.""" + # For version compatibility; older lammps versions (the serial version + # we still use on some machines) have these constants as part of the + # general LAMMPS import. + from lammps import constants as lammps_constants + use_fp64 = kwargs.get("use_fp64", False) return_directly = kwargs.get("return_directly", False) @@ -224,16 +222,23 @@

    Source code for mala.descriptors.atomic_density

    < # Check if we have to determine the optimal sigma value. if self.parameters.atomic_density_sigma is None: self.grid_dimensions = [nx, ny, nz] - self.parameters.atomic_density_sigma = self.\ - get_optimal_sigma(self.voxel) + self.parameters.atomic_density_sigma = self.get_optimal_sigma( + self.voxel + ) # Create LAMMPS instance. lammps_dict = {} lammps_dict["sigma"] = self.parameters.atomic_density_sigma lammps_dict["rcutfac"] = self.parameters.atomic_density_cutoff lammps_dict["atom_config_fname"] = ase_out_path - lmp = self._setup_lammps(nx, ny, nz, outdir, lammps_dict, - log_file_name="lammps_ggrid_log.tmp") + lmp = self._setup_lammps( + nx, + ny, + nz, + outdir, + lammps_dict, + log_file_name="lammps_ggrid_log.tmp", + ) # For now the file is chosen automatically, because this is used # mostly under the hood anyway. @@ -248,18 +253,27 @@

    Source code for mala.descriptors.atomic_density

    < lmp.file(runfile) # Extract the data. - nrows_ggrid = extract_compute_np(lmp, "ggrid", - lammps_constants.LMP_STYLE_LOCAL, - lammps_constants.LMP_SIZE_ROWS) - ncols_ggrid = extract_compute_np(lmp, "ggrid", - lammps_constants.LMP_STYLE_LOCAL, - lammps_constants.LMP_SIZE_COLS) - - gaussian_descriptors_np = \ - extract_compute_np(lmp, "ggrid", - lammps_constants.LMP_STYLE_LOCAL, 2, - array_shape=(nrows_ggrid, ncols_ggrid), - use_fp64=use_fp64) + nrows_ggrid = extract_compute_np( + lmp, + "ggrid", + lammps_constants.LMP_STYLE_LOCAL, + lammps_constants.LMP_SIZE_ROWS, + ) + ncols_ggrid = extract_compute_np( + lmp, + "ggrid", + lammps_constants.LMP_STYLE_LOCAL, + lammps_constants.LMP_SIZE_COLS, + ) + + gaussian_descriptors_np = extract_compute_np( + lmp, + "ggrid", + lammps_constants.LMP_STYLE_LOCAL, + 2, + array_shape=(nrows_ggrid, ncols_ggrid), + use_fp64=use_fp64, + ) lmp.close() # In comparison to SNAP, the atomic density always returns @@ -283,21 +297,23 @@

    Source code for mala.descriptors.atomic_density

    < # Here, we want to do something else with the atomic density, # and thus have to properly reorder it. # We have to switch from x fastest to z fastest reordering. - gaussian_descriptors_np = \ - gaussian_descriptors_np.reshape((self.grid_dimensions[2], - self.grid_dimensions[1], - self.grid_dimensions[0], - 7)) - gaussian_descriptors_np = \ - gaussian_descriptors_np.transpose([2, 1, 0, 3]) + gaussian_descriptors_np = gaussian_descriptors_np.reshape( + ( + self.grid_dimensions[2], + self.grid_dimensions[1], + self.grid_dimensions[0], + 7, + ) + ) + gaussian_descriptors_np = gaussian_descriptors_np.transpose( + [2, 1, 0, 3] + ) if self.parameters.descriptors_contain_xyz: self.fingerprint_length = 4 - return gaussian_descriptors_np[:, :, :, 3:], \ - nx*ny*nz + return gaussian_descriptors_np[:, :, :, 3:], nx * ny * nz else: self.fingerprint_length = 1 - return gaussian_descriptors_np[:, :, :, 6:], \ - nx*ny*nz + return gaussian_descriptors_np[:, :, :, 6:], nx * ny * nz def __calculate_python(self, **kwargs): """ @@ -316,26 +332,42 @@

    Source code for mala.descriptors.atomic_density

    < - It only works for ONE chemical element - It has no MPI or GPU support """ - printout("Using python for descriptor calculation. " - "The resulting calculation will be slow for " - "large systems.") - - gaussian_descriptors_np = np.zeros((self.grid_dimensions[0], - self.grid_dimensions[1], - self.grid_dimensions[2], 4), - dtype=np.float64) + printout( + "Using python for descriptor calculation. " + "The resulting calculation will be slow for " + "large systems." + ) + + gaussian_descriptors_np = np.zeros( + ( + self.grid_dimensions[0], + self.grid_dimensions[1], + self.grid_dimensions[2], + 4, + ), + dtype=np.float64, + ) # Construct the hyperparameters to calculate the Gaussians. # This follows the implementation in the LAMMPS code. if self.parameters.atomic_density_sigma is None: - self.parameters.atomic_density_sigma = self.\ - get_optimal_sigma(self.voxel) - cutoff_squared = self.parameters.atomic_density_cutoff * \ + self.parameters.atomic_density_sigma = self.get_optimal_sigma( + self.voxel + ) + cutoff_squared = ( self.parameters.atomic_density_cutoff - prefactor = 1.0 / (np.power(self.parameters.atomic_density_sigma * - np.sqrt(2*np.pi),3)) - argumentfactor = 1.0 / (2.0 * self.parameters.atomic_density_sigma * - self.parameters.atomic_density_sigma) + * self.parameters.atomic_density_cutoff + ) + prefactor = 1.0 / ( + np.power( + self.parameters.atomic_density_sigma * np.sqrt(2 * np.pi), 3 + ) + ) + argumentfactor = 1.0 / ( + 2.0 + * self.parameters.atomic_density_sigma + * self.parameters.atomic_density_sigma + ) # Create a list of all potentially relevant atoms. all_atoms = self._setup_atom_list() @@ -351,25 +383,30 @@

    Source code for mala.descriptors.atomic_density

    < for j in range(0, self.grid_dimensions[1]): for k in range(0, self.grid_dimensions[2]): # Compute the grid. - gaussian_descriptors_np[i, j, k, 0:3] = \ + gaussian_descriptors_np[i, j, k, 0:3] = ( self._grid_to_coord([i, j, k]) + ) # Compute the Gaussian descriptors. - dm = np.squeeze(distance.cdist( - [gaussian_descriptors_np[i, j, k, 0:3]], - all_atoms)) - dm = dm*dm + dm = np.squeeze( + distance.cdist( + [gaussian_descriptors_np[i, j, k, 0:3]], all_atoms + ) + ) + dm = dm * dm dm_cutoff = dm[np.argwhere(dm < cutoff_squared)] - gaussian_descriptors_np[i, j, k, 3] += \ - np.sum(prefactor*np.exp(-dm_cutoff*argumentfactor)) + gaussian_descriptors_np[i, j, k, 3] += np.sum( + prefactor * np.exp(-dm_cutoff * argumentfactor) + ) if self.parameters.descriptors_contain_xyz: self.fingerprint_length = 4 return gaussian_descriptors_np, np.prod(self.grid_dimensions) else: self.fingerprint_length = 1 - return gaussian_descriptors_np[:, :, :, 3:], \ - np.prod(self.grid_dimensions)
    + return gaussian_descriptors_np[:, :, :, 3:], np.prod( + self.grid_dimensions + )
    diff --git a/_modules/mala/descriptors/bispectrum.html b/_modules/mala/descriptors/bispectrum.html index 3de9ba2a0..8de4820ae 100644 --- a/_modules/mala/descriptors/bispectrum.html +++ b/_modules/mala/descriptors/bispectrum.html @@ -75,20 +75,13 @@

    Source code for mala.descriptors.bispectrum

     """Bispectrum descriptor class."""
    +
     import os
     
     import ase
     import ase.io
    -try:
    -    from lammps import lammps
    -    # For version compatibility; older lammps versions (the serial version
    -    # we still use on some machines) do not have these constants.
    -    try:
    -        from lammps import constants as lammps_constants
    -    except ImportError:
    -        pass
    -except ModuleNotFoundError:
    -    pass
    +
    +from importlib.util import find_spec
     import numpy as np
     from scipy.spatial import distance
     
    @@ -196,16 +189,15 @@ 

    Source code for mala.descriptors.bispectrum

                 raise Exception("Unsupported unit for bispectrum descriptors.")
    def _calculate(self, outdir, **kwargs): - if self.parameters._configuration["lammps"]: - try: - from lammps import lammps - except ModuleNotFoundError: - printout("No LAMMPS found for descriptor calculation, " - "falling back to python.") + if find_spec("lammps") is None: + printout( + "No LAMMPS found for descriptor calculation, " + "falling back to python." + ) return self.__calculate_python(**kwargs) - - return self.__calculate_lammps(outdir, **kwargs) + else: + return self.__calculate_lammps(outdir, **kwargs) else: return self.__calculate_python(**kwargs) @@ -216,6 +208,11 @@

    Source code for mala.descriptors.bispectrum

             Creates a LAMMPS instance with appropriate call parameters and uses
             it for the calculation.
             """
    +        # For version compatibility; older lammps versions (the serial version
    +        # we still use on some machines) have these constants as part of the
    +        # general LAMMPS import.
    +        from lammps import constants as lammps_constants
    +
             use_fp64 = kwargs.get("use_fp64", False)
     
             lammps_format = "lammps-data"
    @@ -227,11 +224,19 @@ 

    Source code for mala.descriptors.bispectrum

             nz = self.grid_dimensions[2]
     
             # Create LAMMPS instance.
    -        lammps_dict = {"twojmax": self.parameters.bispectrum_twojmax,
    -                       "rcutfac": self.parameters.bispectrum_cutoff,
    -                       "atom_config_fname": ase_out_path}
    -        lmp = self._setup_lammps(nx, ny, nz, outdir, lammps_dict,
    -                                 log_file_name="lammps_bgrid_log.tmp")
    +        lammps_dict = {
    +            "twojmax": self.parameters.bispectrum_twojmax,
    +            "rcutfac": self.parameters.bispectrum_cutoff,
    +            "atom_config_fname": ase_out_path,
    +        }
    +        lmp = self._setup_lammps(
    +            nx,
    +            ny,
    +            nz,
    +            outdir,
    +            lammps_dict,
    +            log_file_name="lammps_bgrid_log.tmp",
    +        )
     
             # An empty string means that the user wants to use the standard input.
             # What that is differs depending on serial/parallel execution.
    @@ -239,15 +244,17 @@ 

    Source code for mala.descriptors.bispectrum

                 filepath = __file__.split("bispectrum")[0]
                 if self.parameters._configuration["mpi"]:
                     if self.parameters.use_z_splitting:
    -                    self.parameters.lammps_compute_file = \
    -                        os.path.join(filepath, "in.bgridlocal.python")
    +                    self.parameters.lammps_compute_file = os.path.join(
    +                        filepath, "in.bgridlocal.python"
    +                    )
                     else:
    -                    self.parameters.lammps_compute_file = \
    -                        os.path.join(filepath,
    -                                     "in.bgridlocal_defaultproc.python")
    +                    self.parameters.lammps_compute_file = os.path.join(
    +                        filepath, "in.bgridlocal_defaultproc.python"
    +                    )
                 else:
    -                self.parameters.lammps_compute_file = \
    -                    os.path.join(filepath, "in.bgrid.python")
    +                self.parameters.lammps_compute_file = os.path.join(
    +                    filepath, "in.bgrid.python"
    +                )
     
             # Do the LAMMPS calculation.
             lmp.file(self.parameters.lammps_compute_file)
    @@ -257,11 +264,13 @@ 

    Source code for mala.descriptors.bispectrum

             ncols0 = 3
     
             # Analytical relation for fingerprint length
    -        ncoeff = (self.parameters.bispectrum_twojmax + 2) * \
    -                 (self.parameters.bispectrum_twojmax + 3) * \
    -                 (self.parameters.bispectrum_twojmax + 4)
    -        ncoeff = ncoeff // 24   # integer division
    -        self.fingerprint_length = ncols0+ncoeff
    +        ncoeff = (
    +            (self.parameters.bispectrum_twojmax + 2)
    +            * (self.parameters.bispectrum_twojmax + 3)
    +            * (self.parameters.bispectrum_twojmax + 4)
    +        )
    +        ncoeff = ncoeff // 24  # integer division
    +        self.fingerprint_length = ncols0 + ncoeff
     
             # Extract data from LAMMPS calculation.
             # This is different for the parallel and the serial case.
    @@ -269,20 +278,29 @@ 

    Source code for mala.descriptors.bispectrum

             # the end of this function.
             # This is not necessarily true for the parallel case.
             if self.parameters._configuration["mpi"]:
    -            nrows_local = extract_compute_np(lmp, "bgridlocal",
    -                                             lammps_constants.LMP_STYLE_LOCAL,
    -                                             lammps_constants.LMP_SIZE_ROWS)
    -            ncols_local = extract_compute_np(lmp, "bgridlocal",
    -                                             lammps_constants.LMP_STYLE_LOCAL,
    -                                             lammps_constants.LMP_SIZE_COLS)
    +            nrows_local = extract_compute_np(
    +                lmp,
    +                "bgridlocal",
    +                lammps_constants.LMP_STYLE_LOCAL,
    +                lammps_constants.LMP_SIZE_ROWS,
    +            )
    +            ncols_local = extract_compute_np(
    +                lmp,
    +                "bgridlocal",
    +                lammps_constants.LMP_STYLE_LOCAL,
    +                lammps_constants.LMP_SIZE_COLS,
    +            )
                 if ncols_local != self.fingerprint_length + 3:
                     raise Exception("Inconsistent number of features.")
     
    -            snap_descriptors_np = \
    -                extract_compute_np(lmp, "bgridlocal",
    -                                   lammps_constants.LMP_STYLE_LOCAL, 2,
    -                                   array_shape=(nrows_local, ncols_local),
    -                                   use_fp64=use_fp64)
    +            snap_descriptors_np = extract_compute_np(
    +                lmp,
    +                "bgridlocal",
    +                lammps_constants.LMP_STYLE_LOCAL,
    +                2,
    +                array_shape=(nrows_local, ncols_local),
    +                use_fp64=use_fp64,
    +            )
                 lmp.close()
     
                 # Copy the grid dimensions only at the end.
    @@ -291,10 +309,14 @@ 

    Source code for mala.descriptors.bispectrum

     
             else:
                 # Extract data from LAMMPS calculation.
    -            snap_descriptors_np = \
    -                extract_compute_np(lmp, "bgrid", 0, 2,
    -                                   (nz, ny, nx, self.fingerprint_length),
    -                                   use_fp64=use_fp64)
    +            snap_descriptors_np = extract_compute_np(
    +                lmp,
    +                "bgrid",
    +                0,
    +                2,
    +                (nz, ny, nx, self.fingerprint_length),
    +                use_fp64=use_fp64,
    +            )
                 lmp.close()
     
                 # switch from x-fastest to z-fastest order (swaps 0th and 2nd
    @@ -303,9 +325,9 @@ 

    Source code for mala.descriptors.bispectrum

                 # Copy the grid dimensions only at the end.
                 self.grid_dimensions = [nx, ny, nz]
                 if self.parameters.descriptors_contain_xyz:
    -                return snap_descriptors_np, nx*ny*nz
    +                return snap_descriptors_np, nx * ny * nz
                 else:
    -                return snap_descriptors_np[:, :, :, 3:], nx*ny*nz
    +                return snap_descriptors_np[:, :, :, 3:], nx * ny * nz
     
         def __calculate_python(self, **kwargs):
             """
    @@ -329,14 +351,17 @@ 

    Source code for mala.descriptors.bispectrum

             hard codes them. Compared to the LAMMPS implementation, some
             essentially never used options are not maintained/optimized.
             """
    -        printout("Using python for descriptor calculation. "
    -                 "The resulting calculation will be slow for "
    -                 "large systems.")
    +        printout(
    +            "Using python for descriptor calculation. "
    +            "The resulting calculation will be slow for "
    +            "large systems."
    +        )
     
             # The entire bispectrum calculation may be extensively profiled.
             profile_calculation = kwargs.get("profile_calculation", False)
             if profile_calculation:
                 import time
    +
                 timing_distances = 0
                 timing_ui = 0
                 timing_zi = 0
    @@ -344,16 +369,22 @@ 

    Source code for mala.descriptors.bispectrum

                 timing_gridpoints = 0
     
             # Set up the array holding the bispectrum descriptors.
    -        ncoeff = (self.parameters.bispectrum_twojmax + 2) * \
    -                 (self.parameters.bispectrum_twojmax + 3) * \
    -                 (self.parameters.bispectrum_twojmax + 4)
    -        ncoeff = ncoeff // 24   # integer division
    +        ncoeff = (
    +            (self.parameters.bispectrum_twojmax + 2)
    +            * (self.parameters.bispectrum_twojmax + 3)
    +            * (self.parameters.bispectrum_twojmax + 4)
    +        )
    +        ncoeff = ncoeff // 24  # integer division
             self.fingerprint_length = ncoeff + 3
    -        bispectrum_np = np.zeros((self.grid_dimensions[0],
    -                                  self.grid_dimensions[1],
    -                                  self.grid_dimensions[2],
    -                                  self.fingerprint_length),
    -                                 dtype=np.float64)
    +        bispectrum_np = np.zeros(
    +            (
    +                self.grid_dimensions[0],
    +                self.grid_dimensions[1],
    +                self.grid_dimensions[2],
    +                self.fingerprint_length,
    +            ),
    +            dtype=np.float64,
    +        )
     
             # Create a list of all potentially relevant atoms.
             all_atoms = self._setup_atom_list()
    @@ -424,8 +455,9 @@ 

    Source code for mala.descriptors.bispectrum

                         # Compute the grid point.
                         if profile_calculation:
                             t_grid = time.time()
    -                    bispectrum_np[x, y, z, 0:3] = \
    -                        self._grid_to_coord([x, y, z])
    +                    bispectrum_np[x, y, z, 0:3] = self._grid_to_coord(
    +                        [x, y, z]
    +                    )
     
                         ########
                         # Distance matrix calculation.
    @@ -436,15 +468,30 @@ 

    Source code for mala.descriptors.bispectrum

     
                         if profile_calculation:
                             t0 = time.time()
    -                    distances = np.squeeze(distance.cdist(
    -                        [bispectrum_np[x, y, z, 0:3]],
    -                        all_atoms))
    -                    distances_cutoff = np.squeeze(np.abs(
    -                        distances[np.argwhere(
    -                            distances < self.parameters.bispectrum_cutoff)]))
    -                    atoms_cutoff = np.squeeze(all_atoms[np.argwhere(
    -                            distances < self.parameters.bispectrum_cutoff), :],
    -                                              axis=1)
    +                    distances = np.squeeze(
    +                        distance.cdist(
    +                            [bispectrum_np[x, y, z, 0:3]], all_atoms
    +                        )
    +                    )
    +                    distances_cutoff = np.squeeze(
    +                        np.abs(
    +                            distances[
    +                                np.argwhere(
    +                                    distances
    +                                    < self.parameters.bispectrum_cutoff
    +                                )
    +                            ]
    +                        )
    +                    )
    +                    atoms_cutoff = np.squeeze(
    +                        all_atoms[
    +                            np.argwhere(
    +                                distances < self.parameters.bispectrum_cutoff
    +                            ),
    +                            :,
    +                        ],
    +                        axis=1,
    +                    )
                         nr_atoms = np.shape(atoms_cutoff)[0]
                         if profile_calculation:
                             timing_distances += time.time() - t0
    @@ -458,10 +505,12 @@ 

    Source code for mala.descriptors.bispectrum

     
                         if profile_calculation:
                             t0 = time.time()
    -                    ulisttot_r, ulisttot_i = \
    -                        self.__compute_ui(nr_atoms, atoms_cutoff,
    -                                          distances_cutoff,
    -                                          bispectrum_np[x, y, z, 0:3])
    +                    ulisttot_r, ulisttot_i = self.__compute_ui(
    +                        nr_atoms,
    +                        atoms_cutoff,
    +                        distances_cutoff,
    +                        bispectrum_np[x, y, z, 0:3],
    +                    )
                         if profile_calculation:
                             timing_ui += time.time() - t0
     
    @@ -474,8 +523,9 @@ 

    Source code for mala.descriptors.bispectrum

     
                         if profile_calculation:
                             t0 = time.time()
    -                    zlist_r, zlist_i = \
    -                        self.__compute_zi(ulisttot_r, ulisttot_i)
    +                    zlist_r, zlist_i = self.__compute_zi(
    +                        ulisttot_r, ulisttot_i
    +                    )
                         if profile_calculation:
                             timing_zi += time.time() - t0
     
    @@ -487,9 +537,9 @@ 

    Source code for mala.descriptors.bispectrum

                         ########
                         if profile_calculation:
                             t0 = time.time()
    -                    bispectrum_np[x, y, z, 3:] = \
    -                        self.__compute_bi(ulisttot_r, ulisttot_i, zlist_r,
    -                                          zlist_i)
    +                    bispectrum_np[x, y, z, 3:] = self.__compute_bi(
    +                        ulisttot_r, ulisttot_i, zlist_r, zlist_i
    +                    )
                         if profile_calculation:
                             timing_gridpoints += time.time() - t_grid
                             timing_bi += time.time() - t0
    @@ -499,13 +549,27 @@ 

    Source code for mala.descriptors.bispectrum

                 print("Python-based bispectrum descriptor calculation timing: ")
                 print("Index matrix initialization [s]", timing_index_init)
                 print("Overall calculation time [s]", timing_total)
    -            print("Calculation time per gridpoint [s/gridpoint]",
    -                  timing_gridpoints / np.prod(self.grid_dimensions))
    +            print(
    +                "Calculation time per gridpoint [s/gridpoint]",
    +                timing_gridpoints / np.prod(self.grid_dimensions),
    +            )
                 print("Timing contributions per gridpoint: ")
    -            print("Distance matrix [s/gridpoint]", timing_distances/np.prod(self.grid_dimensions))
    -            print("Compute ui [s/gridpoint]", timing_ui/np.prod(self.grid_dimensions))
    -            print("Compute zi [s/gridpoint]", timing_zi/np.prod(self.grid_dimensions))
    -            print("Compute bi [s/gridpoint]", timing_bi/np.prod(self.grid_dimensions))
    +            print(
    +                "Distance matrix [s/gridpoint]",
    +                timing_distances / np.prod(self.grid_dimensions),
    +            )
    +            print(
    +                "Compute ui [s/gridpoint]",
    +                timing_ui / np.prod(self.grid_dimensions),
    +            )
    +            print(
    +                "Compute zi [s/gridpoint]",
    +                timing_zi / np.prod(self.grid_dimensions),
    +            )
    +            print(
    +                "Compute bi [s/gridpoint]",
    +                timing_bi / np.prod(self.grid_dimensions),
    +            )
     
             if self.parameters.descriptors_contain_xyz:
                 return bispectrum_np, np.prod(self.grid_dimensions)
    @@ -558,9 +622,12 @@ 

    Source code for mala.descriptors.bispectrum

     
             def deltacg(j1, j2, j):
                 sfaccg = np.math.factorial((j1 + j2 + j) // 2 + 1)
    -            return np.sqrt(np.math.factorial((j1 + j2 - j) // 2) *
    -                           np.math.factorial((j1 - j2 + j) // 2) *
    -                           np.math.factorial((-j1 + j2 + j) // 2) / sfaccg)
    +            return np.sqrt(
    +                np.math.factorial((j1 + j2 - j) // 2)
    +                * np.math.factorial((j1 - j2 + j) // 2)
    +                * np.math.factorial((-j1 + j2 + j) // 2)
    +                / sfaccg
    +            )
     
             ########
             # Indices for compute_ui.
    @@ -576,23 +643,40 @@ 

    Source code for mala.descriptors.bispectrum

                         idxu_count += 1
             self.__index_u_max = idxu_count
     
    -        rootpqarray = np.zeros((self.parameters.bispectrum_twojmax + 2,
    -                                self.parameters.bispectrum_twojmax + 2))
    +        rootpqarray = np.zeros(
    +            (
    +                self.parameters.bispectrum_twojmax + 2,
    +                self.parameters.bispectrum_twojmax + 2,
    +            )
    +        )
             for p in range(1, self.parameters.bispectrum_twojmax + 1):
    -            for q in range(1,
    -                           self.parameters.bispectrum_twojmax + 1):
    +            for q in range(1, self.parameters.bispectrum_twojmax + 1):
                     rootpqarray[p, q] = np.sqrt(p / q)
     
             # These are only for optimization purposes.
             self.__index_u_one_initialized = None
             for j in range(0, self.parameters.bispectrum_twojmax + 1):
    -            stop = self.__index_u_block[j + 1] if j < self.parameters.bispectrum_twojmax else self.__index_u_max
    +            stop = (
    +                self.__index_u_block[j + 1]
    +                if j < self.parameters.bispectrum_twojmax
    +                else self.__index_u_max
    +            )
                 if self.__index_u_one_initialized is None:
    -                self.__index_u_one_initialized = np.arange(self.__index_u_block[j], stop=stop, step=j + 2)
    +                self.__index_u_one_initialized = np.arange(
    +                    self.__index_u_block[j], stop=stop, step=j + 2
    +                )
                 else:
    -                self.__index_u_one_initialized = np.concatenate((self.__index_u_one_initialized,
    -                                                                 np.arange(self.__index_u_block[j], stop=stop, step=j + 2)))
    -        self.__index_u_one_initialized = self.__index_u_one_initialized.astype(np.int32)
    +                self.__index_u_one_initialized = np.concatenate(
    +                    (
    +                        self.__index_u_one_initialized,
    +                        np.arange(
    +                            self.__index_u_block[j], stop=stop, step=j + 2
    +                        ),
    +                    )
    +                )
    +        self.__index_u_one_initialized = self.__index_u_one_initialized.astype(
    +            np.int32
    +        )
             self.__index_u_full = []
             self.__index_u_symmetry_pos = []
             self.__index_u_symmetry_neg = []
    @@ -646,8 +730,11 @@ 

    Source code for mala.descriptors.bispectrum

             idxz_count = 0
             for j1 in range(self.parameters.bispectrum_twojmax + 1):
                 for j2 in range(j1 + 1):
    -                for j in range(j1 - j2, min(self.parameters.bispectrum_twojmax,
    -                                            j1 + j2) + 1, 2):
    +                for j in range(
    +                    j1 - j2,
    +                    min(self.parameters.bispectrum_twojmax, j1 + j2) + 1,
    +                    2,
    +                ):
                         for mb in range(j // 2 + 1):
                             for ma in range(j + 1):
                                 idxz_count += 1
    @@ -655,15 +742,22 @@ 

    Source code for mala.descriptors.bispectrum

             idxz = []
             for z in range(idxz_max):
                 idxz.append(self._ZIndices())
    -        self.__index_z_block = np.zeros((self.parameters.bispectrum_twojmax + 1,
    -                                         self.parameters.bispectrum_twojmax + 1,
    -                                         self.parameters.bispectrum_twojmax + 1))
    +        self.__index_z_block = np.zeros(
    +            (
    +                self.parameters.bispectrum_twojmax + 1,
    +                self.parameters.bispectrum_twojmax + 1,
    +                self.parameters.bispectrum_twojmax + 1,
    +            )
    +        )
     
             idxz_count = 0
             for j1 in range(self.parameters.bispectrum_twojmax + 1):
                 for j2 in range(j1 + 1):
    -                for j in range(j1 - j2, min(self.parameters.bispectrum_twojmax,
    -                                            j1 + j2) + 1, 2):
    +                for j in range(
    +                    j1 - j2,
    +                    min(self.parameters.bispectrum_twojmax, j1 + j2) + 1,
    +                    2,
    +                ):
                         self.__index_z_block[j1][j2][j] = idxz_count
     
                         for mb in range(j // 2 + 1):
    @@ -671,34 +765,55 @@ 

    Source code for mala.descriptors.bispectrum

                                 idxz[idxz_count].j1 = j1
                                 idxz[idxz_count].j2 = j2
                                 idxz[idxz_count].j = j
    -                            idxz[idxz_count].ma1min = max(0, (
    -                                        2 * ma - j - j2 + j1) // 2)
    -                            idxz[idxz_count].ma2max = (2 * ma - j - (2 * idxz[
    -                                idxz_count].ma1min - j1) + j2) // 2
    -                            idxz[idxz_count].na = min(j1, (
    -                                        2 * ma - j + j2 + j1) // 2) - idxz[
    -                                                      idxz_count].ma1min + 1
    -                            idxz[idxz_count].mb1min = max(0, (
    -                                        2 * mb - j - j2 + j1) // 2)
    -                            idxz[idxz_count].mb2max = (2 * mb - j - (2 * idxz[
    -                                idxz_count].mb1min - j1) + j2) // 2
    -                            idxz[idxz_count].nb = min(j1, (
    -                                        2 * mb - j + j2 + j1) // 2) - idxz[
    -                                                      idxz_count].mb1min + 1
    +                            idxz[idxz_count].ma1min = max(
    +                                0, (2 * ma - j - j2 + j1) // 2
    +                            )
    +                            idxz[idxz_count].ma2max = (
    +                                2 * ma
    +                                - j
    +                                - (2 * idxz[idxz_count].ma1min - j1)
    +                                + j2
    +                            ) // 2
    +                            idxz[idxz_count].na = (
    +                                min(j1, (2 * ma - j + j2 + j1) // 2)
    +                                - idxz[idxz_count].ma1min
    +                                + 1
    +                            )
    +                            idxz[idxz_count].mb1min = max(
    +                                0, (2 * mb - j - j2 + j1) // 2
    +                            )
    +                            idxz[idxz_count].mb2max = (
    +                                2 * mb
    +                                - j
    +                                - (2 * idxz[idxz_count].mb1min - j1)
    +                                + j2
    +                            ) // 2
    +                            idxz[idxz_count].nb = (
    +                                min(j1, (2 * mb - j + j2 + j1) // 2)
    +                                - idxz[idxz_count].mb1min
    +                                + 1
    +                            )
     
                                 jju = self.__index_u_block[j] + (j + 1) * mb + ma
                                 idxz[idxz_count].jju = jju
     
                                 idxz_count += 1
     
    -        idxcg_block = np.zeros((self.parameters.bispectrum_twojmax + 1,
    -                                     self.parameters.bispectrum_twojmax + 1,
    -                                     self.parameters.bispectrum_twojmax + 1))
    +        idxcg_block = np.zeros(
    +            (
    +                self.parameters.bispectrum_twojmax + 1,
    +                self.parameters.bispectrum_twojmax + 1,
    +                self.parameters.bispectrum_twojmax + 1,
    +            )
    +        )
             idxcg_count = 0
             for j1 in range(self.parameters.bispectrum_twojmax + 1):
                 for j2 in range(j1 + 1):
    -                for j in range(j1 - j2, min(self.parameters.bispectrum_twojmax,
    -                                            j1 + j2) + 1, 2):
    +                for j in range(
    +                    j1 - j2,
    +                    min(self.parameters.bispectrum_twojmax, j1 + j2) + 1,
    +                    2,
    +                ):
                         idxcg_block[j1][j2][j] = idxcg_count
                         for m1 in range(j1 + 1):
                             for m2 in range(j2 + 1):
    @@ -708,8 +823,11 @@ 

    Source code for mala.descriptors.bispectrum

             idxcg_count = 0
             for j1 in range(self.parameters.bispectrum_twojmax + 1):
                 for j2 in range(j1 + 1):
    -                for j in range(j1 - j2, min(self.parameters.bispectrum_twojmax,
    -                                            j1 + j2) + 1, 2):
    +                for j in range(
    +                    j1 - j2,
    +                    min(self.parameters.bispectrum_twojmax, j1 + j2) + 1,
    +                    2,
    +                ):
                         for m1 in range(j1 + 1):
                             aa2 = 2 * m1 - j1
                             for m2 in range(j2 + 1):
    @@ -720,27 +838,44 @@ 

    Source code for mala.descriptors.bispectrum

                                     idxcg_count += 1
                                     continue
                                 cgsum = 0.0
    -                            for z in range(max(0, max(-(j - j2 + aa2) // 2,
    -                                                      -(j - j1 - bb2) // 2)),
    -                                           min((j1 + j2 - j) // 2,
    -                                               min((j1 - aa2) // 2,
    -                                                   (j2 + bb2) // 2)) + 1):
    +                            for z in range(
    +                                max(
    +                                    0,
    +                                    max(
    +                                        -(j - j2 + aa2) // 2,
    +                                        -(j - j1 - bb2) // 2,
    +                                    ),
    +                                ),
    +                                min(
    +                                    (j1 + j2 - j) // 2,
    +                                    min((j1 - aa2) // 2, (j2 + bb2) // 2),
    +                                )
    +                                + 1,
    +                            ):
                                     ifac = -1 if z % 2 else 1
    -                                cgsum += ifac / (np.math.factorial(z) * np.math.factorial(
    -                                    (j1 + j2 - j) // 2 - z) * np.math.factorial(
    -                                    (j1 - aa2) // 2 - z) * np.math.factorial(
    -                                    (j2 + bb2) // 2 - z) * np.math.factorial(
    -                                    (j - j2 + aa2) // 2 + z) * np.math.factorial(
    -                                    (j - j1 - bb2) // 2 + z))
    +                                cgsum += ifac / (
    +                                    np.math.factorial(z)
    +                                    * np.math.factorial((j1 + j2 - j) // 2 - z)
    +                                    * np.math.factorial((j1 - aa2) // 2 - z)
    +                                    * np.math.factorial((j2 + bb2) // 2 - z)
    +                                    * np.math.factorial(
    +                                        (j - j2 + aa2) // 2 + z
    +                                    )
    +                                    * np.math.factorial(
    +                                        (j - j1 - bb2) // 2 + z
    +                                    )
    +                                )
                                 cc2 = 2 * m - j
                                 dcg = deltacg(j1, j2, j)
                                 sfaccg = np.sqrt(
    -                                np.math.factorial((j1 + aa2) // 2) * np.math.factorial(
    -                                    (j1 - aa2) // 2) * np.math.factorial(
    -                                    (j2 + bb2) // 2) * np.math.factorial(
    -                                    (j2 - bb2) // 2) * np.math.factorial(
    -                                    (j + cc2) // 2) * np.math.factorial(
    -                                    (j - cc2) // 2) * (j + 1))
    +                                np.math.factorial((j1 + aa2) // 2)
    +                                * np.math.factorial((j1 - aa2) // 2)
    +                                * np.math.factorial((j2 + bb2) // 2)
    +                                * np.math.factorial((j2 - bb2) // 2)
    +                                * np.math.factorial((j + cc2) // 2)
    +                                * np.math.factorial((j - cc2) // 2)
    +                                * (j + 1)
    +                            )
                                 self.__cglist[idxcg_count] = cgsum * dcg * sfaccg
                                 idxcg_count += 1
     
    @@ -772,8 +907,12 @@ 

    Source code for mala.descriptors.bispectrum

                     icga = ma1min * (j2 + 1) + ma2max
                     for ia in range(na):
                         self.__index_z_jjz.append(jjz)
    -                    self.__index_z_icgb.append(int(idxcg_block[j1][j2][j]) + icgb)
    -                    self.__index_z_icga.append(int(idxcg_block[j1][j2][j]) + icga)
    +                    self.__index_z_icgb.append(
    +                        int(idxcg_block[j1][j2][j]) + icgb
    +                    )
    +                    self.__index_z_icga.append(
    +                        int(idxcg_block[j1][j2][j]) + icga
    +                    )
                         self.__index_z_u1r.append(jju1 + ma1)
                         self.__index_z_u1i.append(jju1 + ma1)
                         self.__index_z_u2r.append(jju2 + ma2)
    @@ -801,8 +940,11 @@ 

    Source code for mala.descriptors.bispectrum

             idxb_count = 0
             for j1 in range(self.parameters.bispectrum_twojmax + 1):
                 for j2 in range(j1 + 1):
    -                for j in range(j1 - j2, min(self.parameters.bispectrum_twojmax,
    -                                            j1 + j2) + 1, 2):
    +                for j in range(
    +                    j1 - j2,
    +                    min(self.parameters.bispectrum_twojmax, j1 + j2) + 1,
    +                    2,
    +                ):
                         if j >= j1:
                             idxb_count += 1
             self.__index_b_max = idxb_count
    @@ -813,7 +955,11 @@ 

    Source code for mala.descriptors.bispectrum

             idxb_count = 0
             for j1 in range(self.parameters.bispectrum_twojmax + 1):
                 for j2 in range(j1 + 1):
    -                for j in range(j1 - j2, min(self.parameters.bispectrum_twojmax, j1 + j2) + 1, 2):
    +                for j in range(
    +                    j1 - j2,
    +                    min(self.parameters.bispectrum_twojmax, j1 + j2) + 1,
    +                    2,
    +                ):
                         if j >= j1:
                             self.__index_b[idxb_count].j1 = j1
                             self.__index_b[idxb_count].j2 = j2
    @@ -835,8 +981,12 @@ 

    Source code for mala.descriptors.bispectrum

             may help.
             """
             # Precompute and prepare ui stuff
    -        theta0 = (distances_cutoff - self.rmin0) * self.rfac0 * np.pi / (
    -                    self.parameters.bispectrum_cutoff - self.rmin0)
    +        theta0 = (
    +            (distances_cutoff - self.rmin0)
    +            * self.rfac0
    +            * np.pi
    +            / (self.parameters.bispectrum_cutoff - self.rmin0)
    +        )
             z0 = np.squeeze(distances_cutoff / np.tan(theta0))
     
             ulist_r_ij = np.zeros((nr_atoms, self.__index_u_max), dtype=np.float64)
    @@ -844,7 +994,9 @@ 

    Source code for mala.descriptors.bispectrum

             ulist_i_ij = np.zeros((nr_atoms, self.__index_u_max), dtype=np.float64)
             ulisttot_r = np.zeros(self.__index_u_max, dtype=np.float64)
             ulisttot_i = np.zeros(self.__index_u_max, dtype=np.float64)
    -        r0inv = np.squeeze(1.0 / np.sqrt(distances_cutoff*distances_cutoff + z0*z0))
    +        r0inv = np.squeeze(
    +            1.0 / np.sqrt(distances_cutoff * distances_cutoff + z0 * z0)
    +        )
             ulisttot_r[self.__index_u_one_initialized] = 1.0
             distance_vector = -1.0 * (atoms_cutoff - grid)
     
    @@ -863,36 +1015,48 @@ 

    Source code for mala.descriptors.bispectrum

                     if jju_outer in self.__index_u_full:
                         rootpq = self.__rootpq_full_1[jju1]
                         ulist_r_ij[:, self.__index_u_full[jju1]] += rootpq * (
    -                            a_r * ulist_r_ij[:, self.__index_u1_full[jju1]] +
    -                            a_i *
    -                            ulist_i_ij[:, self.__index_u1_full[jju1]])
    +                        a_r * ulist_r_ij[:, self.__index_u1_full[jju1]]
    +                        + a_i * ulist_i_ij[:, self.__index_u1_full[jju1]]
    +                    )
                         ulist_i_ij[:, self.__index_u_full[jju1]] += rootpq * (
    -                            a_r * ulist_i_ij[:, self.__index_u1_full[jju1]] -
    -                            a_i *
    -                            ulist_r_ij[:, self.__index_u1_full[jju1]])
    +                        a_r * ulist_i_ij[:, self.__index_u1_full[jju1]]
    +                        - a_i * ulist_r_ij[:, self.__index_u1_full[jju1]]
    +                    )
     
                         rootpq = self.__rootpq_full_2[jju1]
    -                    ulist_r_ij[:, self.__index_u_full[jju1] + 1] = -1.0 * rootpq * (
    -                            b_r * ulist_r_ij[:, self.__index_u1_full[jju1]] +
    -                            b_i *
    -                            ulist_i_ij[:, self.__index_u1_full[jju1]])
    -                    ulist_i_ij[:, self.__index_u_full[jju1] + 1] = -1.0 * rootpq * (
    -                            b_r * ulist_i_ij[:, self.__index_u1_full[jju1]] -
    -                            b_i *
    -                            ulist_r_ij[:, self.__index_u1_full[jju1]])
    +                    ulist_r_ij[:, self.__index_u_full[jju1] + 1] = (
    +                        -1.0
    +                        * rootpq
    +                        * (
    +                            b_r * ulist_r_ij[:, self.__index_u1_full[jju1]]
    +                            + b_i * ulist_i_ij[:, self.__index_u1_full[jju1]]
    +                        )
    +                    )
    +                    ulist_i_ij[:, self.__index_u_full[jju1] + 1] = (
    +                        -1.0
    +                        * rootpq
    +                        * (
    +                            b_r * ulist_i_ij[:, self.__index_u1_full[jju1]]
    +                            - b_i * ulist_r_ij[:, self.__index_u1_full[jju1]]
    +                        )
    +                    )
                         jju1 += 1
                     if jju_outer in self.__index_u1_symmetry_pos:
    -                    ulist_r_ij[:, self.__index_u1_symmetry_pos[jju2]] = ulist_r_ij[:,
    -                                                            self.__index_u_symmetry_pos[jju2]]
    -                    ulist_i_ij[:, self.__index_u1_symmetry_pos[jju2]] = -ulist_i_ij[:,
    -                                                             self.__index_u_symmetry_pos[jju2]]
    +                    ulist_r_ij[:, self.__index_u1_symmetry_pos[jju2]] = (
    +                        ulist_r_ij[:, self.__index_u_symmetry_pos[jju2]]
    +                    )
    +                    ulist_i_ij[:, self.__index_u1_symmetry_pos[jju2]] = (
    +                        -ulist_i_ij[:, self.__index_u_symmetry_pos[jju2]]
    +                    )
                         jju2 += 1
     
                     if jju_outer in self.__index_u1_symmetry_neg:
    -                    ulist_r_ij[:, self.__index_u1_symmetry_neg[jju3]] = -ulist_r_ij[:,
    -                                                             self.__index_u_symmetry_neg[jju3]]
    -                    ulist_i_ij[:, self.__index_u1_symmetry_neg[jju3]] = ulist_i_ij[:,
    -                                                            self.__index_u_symmetry_neg[jju3]]
    +                    ulist_r_ij[:, self.__index_u1_symmetry_neg[jju3]] = (
    +                        -ulist_r_ij[:, self.__index_u_symmetry_neg[jju3]]
    +                    )
    +                    ulist_i_ij[:, self.__index_u1_symmetry_neg[jju3]] = (
    +                        ulist_i_ij[:, self.__index_u_symmetry_neg[jju3]]
    +                    )
                         jju3 += 1
     
                 # This emulates add_uarraytot.
    @@ -901,15 +1065,20 @@ 

    Source code for mala.descriptors.bispectrum

                 if self.parameters.bispectrum_switchflag == 0:
                     sfac += 1.0
                 else:
    -                rcutfac = np.pi / (self.parameters.bispectrum_cutoff -
    -                                   self.rmin0)
    +                rcutfac = np.pi / (
    +                    self.parameters.bispectrum_cutoff - self.rmin0
    +                )
                     if nr_atoms > 1:
    -                    sfac = 0.5 * (np.cos(
    -                        (distances_cutoff - self.rmin0) * rcutfac)
    -                                  + 1.0)
    +                    sfac = 0.5 * (
    +                        np.cos((distances_cutoff - self.rmin0) * rcutfac) + 1.0
    +                    )
                         sfac[np.where(distances_cutoff <= self.rmin0)] = 1.0
    -                    sfac[np.where(distances_cutoff >
    -                                  self.parameters.bispectrum_cutoff)] = 0.0
    +                    sfac[
    +                        np.where(
    +                            distances_cutoff
    +                            > self.parameters.bispectrum_cutoff
    +                        )
    +                    ] = 0.0
                     else:
                         sfac = 1.0 if distances_cutoff <= self.rmin0 else sfac
                         sfac = 0.0 if distances_cutoff <= self.rmin0 else sfac
    @@ -948,24 +1117,36 @@ 

    Source code for mala.descriptors.bispectrum

             A different route that then may employ just-in-time compilation
             could be fruitful.
             """
    -        tmp_real = self.__cglist[self.__index_z_icgb] * \
    -                   self.__cglist[self.__index_z_icga] * \
    -                   (ulisttot_r[self.__index_z_u1r] * ulisttot_r[self.__index_z_u2r]
    -                    - ulisttot_i[self.__index_z_u1i] * ulisttot_i[self.__index_z_u2i])
    -        tmp_imag = self.__cglist[self.__index_z_icgb] * \
    -                   self.__cglist[self.__index_z_icga] * \
    -                   (ulisttot_r[self.__index_z_u1r] * ulisttot_i[self.__index_z_u2i]
    -                    + ulisttot_i[self.__index_z_u1i] * ulisttot_r[self.__index_z_u2r])
    +        tmp_real = (
    +            self.__cglist[self.__index_z_icgb]
    +            * self.__cglist[self.__index_z_icga]
    +            * (
    +                ulisttot_r[self.__index_z_u1r] * ulisttot_r[self.__index_z_u2r]
    +                - ulisttot_i[self.__index_z_u1i]
    +                * ulisttot_i[self.__index_z_u2i]
    +            )
    +        )
    +        tmp_imag = (
    +            self.__cglist[self.__index_z_icgb]
    +            * self.__cglist[self.__index_z_icga]
    +            * (
    +                ulisttot_r[self.__index_z_u1r] * ulisttot_i[self.__index_z_u2i]
    +                + ulisttot_i[self.__index_z_u1i]
    +                * ulisttot_r[self.__index_z_u2r]
    +            )
    +        )
     
             # Summation over an array based on indices stored in a different
             # array.
             # Taken from: https://stackoverflow.com/questions/67108215/how-to-get-sum-of-values-in-a-numpy-array-based-on-another-array-with-repetitive
             # Under "much better version".
    -        _, idx, _ = np.unique(self.__index_z_jjz, return_counts=True,
    -                              return_inverse=True)
    +        _, idx, _ = np.unique(
    +            self.__index_z_jjz, return_counts=True, return_inverse=True
    +        )
             zlist_r = np.bincount(idx, tmp_real)
    -        _, idx, _ = np.unique(self.__index_z_jjz, return_counts=True,
    -                              return_inverse=True)
    +        _, idx, _ = np.unique(
    +            self.__index_z_jjz, return_counts=True, return_inverse=True
    +        )
             zlist_i = np.bincount(idx, tmp_imag)
     
             # Commented out for efficiency reasons. May be commented in at a later
    @@ -991,8 +1172,8 @@ 

    Source code for mala.descriptors.bispectrum

             # This also has some implications for the rest of the function.
             # This currently really only works for one element.
             number_elements = 1
    -        number_element_pairs = number_elements*number_elements
    -        number_element_triples = number_element_pairs*number_elements
    +        number_element_pairs = number_elements * number_elements
    +        number_element_triples = number_element_pairs * number_elements
             ielem = 0
             blist = np.zeros(self.__index_b_max * number_element_triples)
             itriple = 0
    @@ -1000,7 +1181,7 @@ 

    Source code for mala.descriptors.bispectrum

     
             if self.bzero_flag:
                 wself = 1.0
    -            bzero = np.zeros(self.parameters.bispectrum_twojmax+1)
    +            bzero = np.zeros(self.parameters.bispectrum_twojmax + 1)
                 www = wself * wself * wself
                 for j in range(self.parameters.bispectrum_twojmax + 1):
                     if self.bnorm_flag:
    @@ -1018,35 +1199,50 @@ 

    Source code for mala.descriptors.bispectrum

                             jjz = int(self.__index_z_block[j1][j2][j])
                             jju = int(self.__index_u_block[j])
                             sumzu = 0.0
    -                        for mb in range(int(np.ceil(j/2))):
    +                        for mb in range(int(np.ceil(j / 2))):
                                 for ma in range(j + 1):
    -                                sumzu += ulisttot_r[elem3 * self.__index_u_max + jju] * \
    -                                         zlist_r[jjz] + ulisttot_i[
    -                                             elem3 * self.__index_u_max + jju] * zlist_i[
    -                                             jjz]
    +                                sumzu += (
    +                                    ulisttot_r[
    +                                        elem3 * self.__index_u_max + jju
    +                                    ]
    +                                    * zlist_r[jjz]
    +                                    + ulisttot_i[
    +                                        elem3 * self.__index_u_max + jju
    +                                    ]
    +                                    * zlist_i[jjz]
    +                                )
                                     jjz += 1
                                     jju += 1
                             if j % 2 == 0:
                                 mb = j // 2
                                 for ma in range(mb):
    -                                sumzu += ulisttot_r[elem3 * self.__index_u_max + jju] * \
    -                                         zlist_r[jjz] + ulisttot_i[
    -                                             elem3 * self.__index_u_max + jju] * zlist_i[
    -                                             jjz]
    +                                sumzu += (
    +                                    ulisttot_r[
    +                                        elem3 * self.__index_u_max + jju
    +                                    ]
    +                                    * zlist_r[jjz]
    +                                    + ulisttot_i[
    +                                        elem3 * self.__index_u_max + jju
    +                                    ]
    +                                    * zlist_i[jjz]
    +                                )
                                     jjz += 1
                                     jju += 1
                                 sumzu += 0.5 * (
    -                                    ulisttot_r[elem3 * self.__index_u_max + jju] *
    -                                    zlist_r[jjz] + ulisttot_i[
    -                                        elem3 * self.__index_u_max + jju] * zlist_i[
    -                                            jjz])
    +                                ulisttot_r[elem3 * self.__index_u_max + jju]
    +                                * zlist_r[jjz]
    +                                + ulisttot_i[elem3 * self.__index_u_max + jju]
    +                                * zlist_i[jjz]
    +                            )
                             blist[itriple * self.__index_b_max + jjb] = 2.0 * sumzu
                         itriple += 1
                     idouble += 1
     
             if self.bzero_flag:
                 if not self.wselfall_flag:
    -                itriple = (ielem * number_elements + ielem) * number_elements + ielem
    +                itriple = (
    +                    ielem * number_elements + ielem
    +                ) * number_elements + ielem
                     for jjb in range(self.__index_b_max):
                         j = self.__index_b[jjb].j
                         blist[itriple * self.__index_b_max + jjb] -= bzero[j]
    @@ -1057,23 +1253,21 @@ 

    Source code for mala.descriptors.bispectrum

                             for elem3 in range(number_elements):
                                 for jjb in range(self.__index_b_max):
                                     j = self.__index_b[jjb].j
    -                                blist[itriple * self.__index_b_max + jjb] -= bzero[j]
    +                                blist[
    +                                    itriple * self.__index_b_max + jjb
    +                                ] -= bzero[j]
                                 itriple += 1
     
             # Untested  & Unoptimized
             if self.quadraticflag:
    -            xyz_length = 3 if self.parameters.descriptors_contain_xyz \
    -                else 0
    +            xyz_length = 3 if self.parameters.descriptors_contain_xyz else 0
                 ncount = self.fingerprint_length - xyz_length
                 for icoeff in range(ncount):
                     bveci = blist[icoeff]
    -                blist[3 + ncount] = 0.5 * bveci * \
    -                                                     bveci
    +                blist[3 + ncount] = 0.5 * bveci * bveci
                     ncount += 1
                     for jcoeff in range(icoeff + 1, ncount):
    -                    blist[xyz_length + ncount] = bveci * \
    -                                                         blist[
    -                                                             jcoeff]
    +                    blist[xyz_length + ncount] = bveci * blist[jcoeff]
                         ncount += 1
     
             return blist
    diff --git a/_modules/mala/descriptors/descriptor.html b/_modules/mala/descriptors/descriptor.html index 2140378fa..e273d49aa 100644 --- a/_modules/mala/descriptors/descriptor.html +++ b/_modules/mala/descriptors/descriptor.html @@ -75,18 +75,26 @@

    Source code for mala.descriptors.descriptor

     """Base class for all descriptor calculators."""
    +
     from abc import abstractmethod
     import os
     
     import ase
     from ase.units import m
    -from ase.neighborlist import NeighborList
    +from ase.neighborlist import NeighborList, NewPrimitiveNeighborList
     import numpy as np
     from skspatial.objects import Plane
     
     from mala.common.parameters import ParametersDescriptors, Parameters
    -from mala.common.parallelizer import get_comm, printout, get_rank, get_size, \
    -    barrier, parallel_warn, set_lammps_instance
    +from mala.common.parallelizer import (
    +    get_comm,
    +    printout,
    +    get_rank,
    +    get_size,
    +    barrier,
    +    parallel_warn,
    +    set_lammps_instance,
    +)
     from mala.common.physical_data import PhysicalData
     from mala.descriptors.lammps_utils import set_cmdlinevars
     
    @@ -108,7 +116,7 @@ 

    Source code for mala.descriptors.descriptor

         # Constructors
         ##############################
     
    -    def __new__(cls, params: Parameters=None):
    +    def __new__(cls, params: Parameters = None):
             """
             Create a Descriptor instance.
     
    @@ -125,28 +133,38 @@ 

    Source code for mala.descriptors.descriptor

             # Check if we're accessing through base class.
             # If not, we need to return the correct object directly.
             if cls == Descriptor:
    -            if params.descriptors.descriptor_type == 'SNAP':
    +            if params.descriptors.descriptor_type == "SNAP":
                     from mala.descriptors.bispectrum import Bispectrum
    +
                     parallel_warn(
                         "Using 'SNAP' as descriptors will be deprecated "
                         "starting in MALA v1.3.0. Please use 'Bispectrum' "
    -                    "instead.",  min_verbosity=0, category=FutureWarning)
    +                    "instead.",
    +                    min_verbosity=0,
    +                    category=FutureWarning,
    +                )
                     descriptors = super(Descriptor, Bispectrum).__new__(Bispectrum)
     
    -            if params.descriptors.descriptor_type == 'Bispectrum':
    +            if params.descriptors.descriptor_type == "Bispectrum":
                     from mala.descriptors.bispectrum import Bispectrum
    +
                     descriptors = super(Descriptor, Bispectrum).__new__(Bispectrum)
     
                 if params.descriptors.descriptor_type == "AtomicDensity":
                     from mala.descriptors.atomic_density import AtomicDensity
    -                descriptors = super(Descriptor, AtomicDensity).\
    -                    __new__(AtomicDensity)
    +
    +                descriptors = super(Descriptor, AtomicDensity).__new__(
    +                    AtomicDensity
    +                )
     
                 if params.descriptors.descriptor_type == "MinterpyDescriptors":
    -                from mala.descriptors.minterpy_descriptors import \
    +                from mala.descriptors.minterpy_descriptors import (
    +                    MinterpyDescriptors,
    +                )
    +
    +                descriptors = super(Descriptor, MinterpyDescriptors).__new__(
                         MinterpyDescriptors
    -                descriptors = super(Descriptor, MinterpyDescriptors).\
    -                    __new__(MinterpyDescriptors)
    +                )
     
                 if descriptors is None:
                     raise Exception("Unsupported descriptor calculator.")
    @@ -169,7 +187,7 @@ 

    Source code for mala.descriptors.descriptor

             params : mala.Parameters
                 The parameters object with which this object was created.
             """
    -        return self.params_arg,
    +        return (self.params_arg,)
     
         def __init__(self, parameters):
             super(Descriptor, self).__init__(parameters)
    @@ -239,8 +257,10 @@ 

    Source code for mala.descriptors.descriptor

                 Data in MALA units.
     
             """
    -        raise Exception("No unit conversion method implemented for this"
    -                        " descriptor type.")
    + raise Exception( + "No unit conversion method implemented for this" + " descriptor type." + )
    [docs] @staticmethod def backconvert_units(array, out_units): @@ -261,8 +281,10 @@

    Source code for mala.descriptors.descriptor

                 Data in out_units.
     
             """
    -        raise Exception("No unit back conversion method implemented for "
    -                        "this descriptor type.")
    + raise Exception( + "No unit back conversion method implemented for " + "this descriptor type." + )
    # Calculations ############## @@ -296,16 +318,24 @@

    Source code for mala.descriptors.descriptor

             # metric here.
             rescaled_atoms = 0
             for i in range(0, len(atoms)):
    -            if False in (np.isclose(new_atoms[i].position,
    -                          atoms[i].position, atol=0.001)):
    +            if False in (
    +                np.isclose(
    +                    new_atoms[i].position, atoms[i].position, atol=0.001
    +                )
    +            ):
                     rescaled_atoms += 1
    -        printout("Descriptor calculation: had to enforce periodic boundary "
    -                 "conditions on", rescaled_atoms, "atoms before calculation.",
    -                 min_verbosity=2)
    +        printout(
    +            "Descriptor calculation: had to enforce periodic boundary "
    +            "conditions on",
    +            rescaled_atoms,
    +            "atoms before calculation.",
    +            min_verbosity=2,
    +        )
             return new_atoms
    -
    [docs] def calculate_from_qe_out(self, qe_out_file, working_directory=".", - **kwargs): +
    [docs] def calculate_from_qe_out( + self, qe_out_file, working_directory=".", **kwargs + ): """ Calculate the descriptors based on a Quantum Espresso outfile. @@ -327,8 +357,7 @@

    Source code for mala.descriptors.descriptor

     
             """
             self.in_format_ase = "espresso-out"
    -        printout("Calculating descriptors from", qe_out_file,
    -                 min_verbosity=0)
    +        printout("Calculating descriptors from", qe_out_file, min_verbosity=0)
             # We get the atomic information by using ASE.
             self.atoms = ase.io.read(qe_out_file, format=self.in_format_ase)
     
    @@ -362,8 +391,9 @@ 

    Source code for mala.descriptors.descriptor

     
             return self._calculate(working_directory, **kwargs)
    -
    [docs] def calculate_from_atoms(self, atoms, grid_dimensions, - working_directory=".", **kwargs): +
    [docs] def calculate_from_atoms( + self, atoms, grid_dimensions, working_directory=".", **kwargs + ): """ Calculate the bispectrum descriptors based on atomic configurations. @@ -427,12 +457,12 @@

    Source code for mala.descriptors.descriptor

     
             # Gather the descriptors into a list.
             if use_pickled_comm:
    -            all_descriptors_list = comm.gather(descriptors_np,
    -                                               root=0)
    +            all_descriptors_list = comm.gather(descriptors_np, root=0)
             else:
    -            sendcounts = np.array(comm.gather(np.shape(descriptors_np)[0],
    -                                              root=0))
    -            raw_feature_length = self.fingerprint_length+3
    +            sendcounts = np.array(
    +                comm.gather(np.shape(descriptors_np)[0], root=0)
    +            )
    +            raw_feature_length = self.fingerprint_length + 3
     
                 if get_rank() == 0:
                     # print("sendcounts: {}, total: {}".format(sendcounts,
    @@ -442,18 +472,21 @@ 

    Source code for mala.descriptors.descriptor

                     all_descriptors_list = []
                     for i in range(0, get_size()):
                         all_descriptors_list.append(
    -                        np.empty(sendcounts[i] * raw_feature_length,
    -                                 dtype=descriptors_np.dtype))
    +                        np.empty(
    +                            sendcounts[i] * raw_feature_length,
    +                            dtype=descriptors_np.dtype,
    +                        )
    +                    )
     
                     # No MPI necessary for first rank. For all the others,
                     # collect the buffers.
                     all_descriptors_list[0] = descriptors_np
                     for i in range(1, get_size()):
    -                    comm.Recv(all_descriptors_list[i], source=i,
    -                              tag=100+i)
    -                    all_descriptors_list[i] = \
    -                        np.reshape(all_descriptors_list[i],
    -                                   (sendcounts[i], raw_feature_length))
    +                    comm.Recv(all_descriptors_list[i], source=i, tag=100 + i)
    +                    all_descriptors_list[i] = np.reshape(
    +                        all_descriptors_list[i],
    +                        (sendcounts[i], raw_feature_length),
    +                    )
                 else:
                     comm.Send(descriptors_np, dest=0, tag=get_rank() + 100)
                 barrier()
    @@ -474,24 +507,29 @@ 

    Source code for mala.descriptors.descriptor

                 nx = self.grid_dimensions[0]
                 ny = self.grid_dimensions[1]
                 nz = self.grid_dimensions[2]
    -            descriptors_full = np.zeros(
    -                [nx, ny, nz, self.fingerprint_length])
    +            descriptors_full = np.zeros([nx, ny, nz, self.fingerprint_length])
                 # Fill the full SNAP descriptors array.
                 for idx, local_grid in enumerate(all_descriptors_list):
                     # We glue the individual cells back together, and transpose.
                     first_x = int(local_grid[0][0])
                     first_y = int(local_grid[0][1])
                     first_z = int(local_grid[0][2])
    -                last_x = int(local_grid[-1][0])+1
    -                last_y = int(local_grid[-1][1])+1
    -                last_z = int(local_grid[-1][2])+1
    -                descriptors_full[first_x:last_x,
    -                                 first_y:last_y,
    -                                 first_z:last_z] = \
    -                    np.reshape(local_grid[:, 3:],
    -                               [last_z-first_z, last_y-first_y, last_x-first_x,
    -                                self.fingerprint_length]).\
    -                    transpose([2, 1, 0, 3])
    +                last_x = int(local_grid[-1][0]) + 1
    +                last_y = int(local_grid[-1][1]) + 1
    +                last_z = int(local_grid[-1][2]) + 1
    +                descriptors_full[
    +                    first_x:last_x, first_y:last_y, first_z:last_z
    +                ] = np.reshape(
    +                    local_grid[:, 3:],
    +                    [
    +                        last_z - first_z,
    +                        last_y - first_y,
    +                        last_x - first_x,
    +                        self.fingerprint_length,
    +                    ],
    +                ).transpose(
    +                    [2, 1, 0, 3]
    +                )
     
                     # Leaving this in here for debugging purposes.
                     # This is the slow way to reshape the descriptors.
    @@ -535,10 +573,9 @@ 

    Source code for mala.descriptors.descriptor

     
             descriptors_full = np.zeros([nx, ny, nz, self.fingerprint_length])
     
    -        descriptors_full[0:nx, 0:ny, 0:nz] = \
    -            np.reshape(descriptors_np[:, 3:],
    -                       [nz, ny, nx, self.fingerprint_length]).\
    -                transpose([2, 1, 0, 3])
    +        descriptors_full[0:nx, 0:ny, 0:nz] = np.reshape(
    +            descriptors_np[:, 3:], [nz, ny, nx, self.fingerprint_length]
    +        ).transpose([2, 1, 0, 3])
             return descriptors_full, local_offset, local_reach
    # Private methods @@ -549,8 +586,12 @@

    Source code for mala.descriptors.descriptor

     
         def _process_loaded_dimensions(self, array_dimensions):
             if self.descriptors_contain_xyz:
    -            return (array_dimensions[0], array_dimensions[1],
    -                    array_dimensions[2], array_dimensions[3]-3)
    +            return (
    +                array_dimensions[0],
    +                array_dimensions[1],
    +                array_dimensions[2],
    +                array_dimensions[3] - 3,
    +            )
             else:
                 return array_dimensions
     
    @@ -577,8 +618,9 @@ 

    Source code for mala.descriptors.descriptor

             else:
                 return 0
     
    -    def _setup_lammps(self, nx, ny, nz, outdir, lammps_dict,
    -                      log_file_name="lammps_log.tmp"):
    +    def _setup_lammps(
    +        self, nx, ny, nz, outdir, lammps_dict, log_file_name="lammps_log.tmp"
    +    ):
             """
             Set up the lammps processor grid.
     
    @@ -586,14 +628,20 @@ 

    Source code for mala.descriptors.descriptor

             """
             from lammps import lammps
     
    -        parallel_warn("Using LAMMPS for descriptor calculation. "
    -                      "Do not initialize more than one pre-processing "
    -                      "calculation in the same directory at the same time. "
    -                      "Data may be over-written.")
    +        parallel_warn(
    +            "Using LAMMPS for descriptor calculation. "
    +            "Do not initialize more than one pre-processing "
    +            "calculation in the same directory at the same time. "
    +            "Data may be over-written."
    +        )
     
             # Build LAMMPS arguments from the data we read.
    -        lmp_cmdargs = ["-screen", "none", "-log",
    -                       os.path.join(outdir, log_file_name)]
    +        lmp_cmdargs = [
    +            "-screen",
    +            "none",
    +            "-log",
    +            os.path.join(outdir, log_file_name),
    +        ]
     
             if self.parameters._configuration["mpi"]:
                 size = get_size()
    @@ -621,67 +669,73 @@ 

    Source code for mala.descriptors.descriptor

                     # number of z processors is equal to total processors/nyfft is
                     # nyfft is used else zprocs = size
                     if size % yprocs == 0:
    -                    zprocs = int(size/yprocs)
    +                    zprocs = int(size / yprocs)
                     else:
    -                    raise ValueError("Cannot evenly divide z-planes "
    -                                     "in y-direction")
    +                    raise ValueError(
    +                        "Cannot evenly divide z-planes in y-direction"
    +                    )
     
                     # check if total number of processors is greater than number of
                     # grid sections produce error if number of processors is
                     # greater than grid partions - will cause mismatch later in QE
    -                mpi_grid_sections = yprocs*zprocs
    +                mpi_grid_sections = yprocs * zprocs
                     if mpi_grid_sections < size:
    -                    raise ValueError("More processors than grid sections. "
    -                                     "This will cause a crash further in the "
    -                                     "calculation. Choose a total number of "
    -                                     "processors equal to or less than the "
    -                                     "total number of grid sections requsted "
    -                                     "for the calculation (nyfft*nz).")
    +                    raise ValueError(
    +                        "More processors than grid sections. "
    +                        "This will cause a crash further in the "
    +                        "calculation. Choose a total number of "
    +                        "processors equal to or less than the "
    +                        "total number of grid sections requsted "
    +                        "for the calculation (nyfft*nz)."
    +                    )
                     # TODO not sure what happens when size/nyfft is not integer -
                     #  further testing required
     
                     # set the mpi processor grid for lammps
                     lammps_procs = f"1 {yprocs} {zprocs}"
    -                printout("mpi grid with nyfft: ", lammps_procs,
    -                         min_verbosity=2)
    +                printout(
    +                    "mpi grid with nyfft: ", lammps_procs, min_verbosity=2
    +                )
     
                     # prepare y plane cuts for balance command in lammps if not
                     # integer value
                     if int(ny / yprocs) == (ny / yprocs):
    -                    ycut = 1/yprocs
    -                    yint = ''
    -                    for i in range(0, yprocs-1):
    -                        yvals = ((i+1)*ycut)-0.00000001
    +                    ycut = 1 / yprocs
    +                    yint = ""
    +                    for i in range(0, yprocs - 1):
    +                        yvals = ((i + 1) * ycut) - 0.00000001
                             yint += format(yvals, ".8f")
    -                        yint += ' '
    +                        yint += " "
                     else:
                         # account for remainder with uneven number of
                         # planes/processors
    -                    ycut = 1/yprocs
    -                    yrem = ny - (yprocs*int(ny/yprocs))
    -                    yint = ''
    +                    ycut = 1 / yprocs
    +                    yrem = ny - (yprocs * int(ny / yprocs))
    +                    yint = ""
                         for i in range(0, yrem):
    -                        yvals = (((i+1)*2)*ycut)-0.00000001
    +                        yvals = (((i + 1) * 2) * ycut) - 0.00000001
                             yint += format(yvals, ".8f")
    -                        yint += ' '
    -                    for i in range(yrem, yprocs-1):
    -                        yvals = ((i+1+yrem)*ycut)-0.00000001
    +                        yint += " "
    +                    for i in range(yrem, yprocs - 1):
    +                        yvals = ((i + 1 + yrem) * ycut) - 0.00000001
                             yint += format(yvals, ".8f")
    -                        yint += ' '
    +                        yint += " "
                     # prepare z plane cuts for balance command in lammps
                     if int(nz / zprocs) == (nz / zprocs):
    -                    zcut = 1/nz
    -                    zint = ''
    -                    for i in range(0, zprocs-1):
    +                    zcut = 1 / nz
    +                    zint = ""
    +                    for i in range(0, zprocs - 1):
                             zvals = ((i + 1) * (nz / zprocs) * zcut) - 0.00000001
                             zint += format(zvals, ".8f")
    -                        zint += ' '
    +                        zint += " "
                     else:
                         # account for remainder with uneven number of
                         # planes/processors
    -                    raise ValueError("Cannot divide z-planes on processors"
    -                                     " without remainder. "
    -                                     "This is currently unsupported.")
    +                    raise ValueError(
    +                        "Cannot divide z-planes on processors"
    +                        " without remainder. "
    +                        "This is currently unsupported."
    +                    )
     
                         # zcut = 1/nz
                         # zrem = nz - (zprocs*int(nz/zprocs))
    @@ -694,8 +748,9 @@ 

    Source code for mala.descriptors.descriptor

                         #     zvals = ((i+1+zrem)*zcut)-0.00000001
                         #     zint += format(zvals, ".8f")
                         #     zint += ' '
    -                lammps_dict["lammps_procs"] = f"processors {lammps_procs} " \
    -                                              f"map xyz"
    +                lammps_dict["lammps_procs"] = (
    +                    f"processors {lammps_procs} " f"map xyz"
    +                )
                     lammps_dict["zbal"] = f"balance 1.0 y {yint} z {zint}"
                     lammps_dict["ngridx"] = nx
                     lammps_dict["ngridy"] = ny
    @@ -711,13 +766,15 @@ 

    Source code for mala.descriptors.descriptor

                         # processors. If more processors than planes calculation
                         # efficiency decreases
                         if nz < size:
    -                        raise ValueError("More processors than grid sections. "
    -                                         "This will cause a crash further in "
    -                                         "the calculation. Choose a total "
    -                                         "number of processors equal to or "
    -                                         "less than the total number of grid "
    -                                         "sections requsted for the "
    -                                         "calculation (nz).")
    +                        raise ValueError(
    +                            "More processors than grid sections. "
    +                            "This will cause a crash further in "
    +                            "the calculation. Choose a total "
    +                            "number of processors equal to or "
    +                            "less than the total number of grid "
    +                            "sections requsted for the "
    +                            "calculation (nz)."
    +                        )
     
                         # match lammps mpi grid to be 1x1x{zprocs}
                         lammps_procs = f"1 1 {zprocs}"
    @@ -726,49 +783,56 @@ 

    Source code for mala.descriptors.descriptor

                         # prepare z plane cuts for balance command in lammps
                         if int(nz / zprocs) == (nz / zprocs):
                             printout("No remainder in z")
    -                        zcut = 1/nz
    -                        zint = ''
    -                        for i in range(0, zprocs-1):
    -                            zvals = ((i+1)*(nz/zprocs)*zcut)-0.00000001
    +                        zcut = 1 / nz
    +                        zint = ""
    +                        for i in range(0, zprocs - 1):
    +                            zvals = (
    +                                (i + 1) * (nz / zprocs) * zcut
    +                            ) - 0.00000001
                                 zint += format(zvals, ".8f")
    -                            zint += ' '
    +                            zint += " "
                         else:
    -                        #raise ValueError("Cannot divide z-planes on processors"
    +                        # raise ValueError("Cannot divide z-planes on processors"
                             #                 " without remainder. "
                             #                 "This is currently unsupported.")
    -                        zcut = 1/nz
    -                        zrem = nz - (zprocs*int(nz/zprocs))
    -                        zint = ''
    +                        zcut = 1 / nz
    +                        zrem = nz - (zprocs * int(nz / zprocs))
    +                        zint = ""
                             for i in range(0, zrem):
    -                            zvals = (((i+1)*(int(nz/zprocs)+1))*zcut)-0.00000001
    +                            zvals = (
    +                                ((i + 1) * (int(nz / zprocs) + 1)) * zcut
    +                            ) - 0.00000001
                                 zint += format(zvals, ".8f")
    -                            zint += ' '
    -                        for i in range(zrem, zprocs-1):
    -                            zvals = (((i+1)*int(nz/zprocs)+zrem)*zcut)-0.00000001
    +                            zint += " "
    +                        for i in range(zrem, zprocs - 1):
    +                            zvals = (
    +                                ((i + 1) * int(nz / zprocs) + zrem) * zcut
    +                            ) - 0.00000001
                                 zint += format(zvals, ".8f")
    -                            zint += ' '
    +                            zint += " "
     
                         lammps_dict["lammps_procs"] = f"processors {lammps_procs}"
                         lammps_dict["zbal"] = f"balance 1.0 z {zint}"
                         lammps_dict["ngridx"] = nx
                         lammps_dict["ngridy"] = ny
                         lammps_dict["ngridz"] = nz
    -                    lammps_dict[
    -                        "switch"] = self.parameters.bispectrum_switchflag
    +                    lammps_dict["switch"] = (
    +                        self.parameters.bispectrum_switchflag
    +                    )
     
                     else:
                         lammps_dict["ngridx"] = nx
                         lammps_dict["ngridy"] = ny
                         lammps_dict["ngridz"] = nz
    -                    lammps_dict[
    -                        "switch"] = self.parameters.bispectrum_switchflag
    +                    lammps_dict["switch"] = (
    +                        self.parameters.bispectrum_switchflag
    +                    )
     
             else:
                 lammps_dict["ngridx"] = nx
                 lammps_dict["ngridy"] = ny
                 lammps_dict["ngridz"] = nz
    -            lammps_dict[
    -                "switch"] = self.parameters.bispectrum_switchflag
    +            lammps_dict["switch"] = self.parameters.bispectrum_switchflag
                 if self.parameters._configuration["gpu"]:
                     # Tell Kokkos to use one GPU.
                     lmp_cmdargs.append("-k")
    @@ -805,21 +869,34 @@ 

    Source code for mala.descriptors.descriptor

                 # To determine the list of relevant atoms we first take the edges
                 # of the simulation cell and use them to determine all cells
                 # which hold atoms that _may_ be relevant for the calculation.
    -            edges = list(np.array([
    -                [0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1],
    -                [1, 1, 1], [0, 1, 1], [1, 0, 1], [1, 1, 0]])*np.array(self.grid_dimensions))
    +            edges = list(
    +                np.array(
    +                    [
    +                        [0, 0, 0],
    +                        [1, 0, 0],
    +                        [0, 1, 0],
    +                        [0, 0, 1],
    +                        [1, 1, 1],
    +                        [0, 1, 1],
    +                        [1, 0, 1],
    +                        [1, 1, 0],
    +                    ]
    +                )
    +                * np.array(self.grid_dimensions)
    +            )
                 all_cells_list = None
     
                 # For each edge point create a neighborhoodlist to all cells
                 # given by the cutoff radius.
                 for edge in edges:
                     edge_point = self._grid_to_coord(edge)
    -                neighborlist = ase.neighborlist.NeighborList(
    -                    np.zeros(len(self.atoms)+1) +
    -                    [self.parameters.atomic_density_cutoff],
    +                neighborlist = NeighborList(
    +                    np.zeros(len(self.atoms) + 1)
    +                    + [self.parameters.atomic_density_cutoff],
                         bothways=True,
                         self_interaction=False,
    -                    primitive=ase.neighborlist.NewPrimitiveNeighborList)
    +                    primitive=NewPrimitiveNeighborList,
    +                )
     
                     atoms_with_grid_point = self.atoms.copy()
     
    @@ -833,9 +910,9 @@ 

    Source code for mala.descriptors.descriptor

                     if all_cells_list is None:
                         all_cells_list = np.unique(offsets, axis=0)
                     else:
    -                    all_cells_list = \
    -                        np.concatenate((all_cells_list,
    -                                        np.unique(offsets, axis=0)))
    +                    all_cells_list = np.concatenate(
    +                        (all_cells_list, np.unique(offsets, axis=0))
    +                    )
     
                 # Delete the original cell from the list of all cells.
                 # This is to avoid double checking of atoms below.
    @@ -853,32 +930,51 @@ 

    Source code for mala.descriptors.descriptor

                 all_atoms = None
                 for a in range(0, len(self.atoms)):
                     if all_atoms is None:
    -                    all_atoms = self.atoms.positions[
    -                                    a] + all_cells @ self.atoms.get_cell()
    +                    all_atoms = (
    +                        self.atoms.positions[a]
    +                        + all_cells @ self.atoms.get_cell()
    +                    )
                     else:
    -                    all_atoms = np.concatenate((all_atoms,
    -                                                self.atoms.positions[
    -                                                    a] + all_cells @ self.atoms.get_cell()))
    +                    all_atoms = np.concatenate(
    +                        (
    +                            all_atoms,
    +                            self.atoms.positions[a]
    +                            + all_cells @ self.atoms.get_cell(),
    +                        )
    +                    )
     
                 # Next, construct the planes forming the unit cell.
                 # Atoms from neighboring cells are only included in the list of
                 # all relevant atoms, if they have a distance to any of these
                 # planes smaller than the cutoff radius. Elsewise, they would
                 # not be included in the eventual calculation anyhow.
    -            planes = [[[0, 1, 0], [0, 0, 1], [0, 0, 0]],
    -                      [[self.grid_dimensions[0], 1, 0],
    -                       [self.grid_dimensions[0], 0, 1], self.grid_dimensions],
    -                      [[1, 0, 0], [0, 0, 1], [0, 0, 0]],
    -                      [[1, self.grid_dimensions[1], 0],
    -                       [0, self.grid_dimensions[1], 1], self.grid_dimensions],
    -                      [[1, 0, 0], [0, 1, 0], [0, 0, 0]],
    -                      [[1, 0, self.grid_dimensions[2]],
    -                       [0, 1, self.grid_dimensions[2]], self.grid_dimensions]]
    +            planes = [
    +                [[0, 1, 0], [0, 0, 1], [0, 0, 0]],
    +                [
    +                    [self.grid_dimensions[0], 1, 0],
    +                    [self.grid_dimensions[0], 0, 1],
    +                    self.grid_dimensions,
    +                ],
    +                [[1, 0, 0], [0, 0, 1], [0, 0, 0]],
    +                [
    +                    [1, self.grid_dimensions[1], 0],
    +                    [0, self.grid_dimensions[1], 1],
    +                    self.grid_dimensions,
    +                ],
    +                [[1, 0, 0], [0, 1, 0], [0, 0, 0]],
    +                [
    +                    [1, 0, self.grid_dimensions[2]],
    +                    [0, 1, self.grid_dimensions[2]],
    +                    self.grid_dimensions,
    +                ],
    +            ]
                 all_distances = []
                 for plane in planes:
    -                curplane = Plane.from_points(self._grid_to_coord(plane[0]),
    -                                             self._grid_to_coord(plane[1]),
    -                                             self._grid_to_coord(plane[2]))
    +                curplane = Plane.from_points(
    +                    self._grid_to_coord(plane[0]),
    +                    self._grid_to_coord(plane[1]),
    +                    self._grid_to_coord(plane[2]),
    +                )
                     distances = []
     
                     # TODO: This may be optimized, and formulated in an array
    @@ -888,9 +984,14 @@ 

    Source code for mala.descriptors.descriptor

                     all_distances.append(distances)
                 all_distances = np.array(all_distances)
                 all_distances = np.min(all_distances, axis=0)
    -            all_atoms = np.squeeze(all_atoms[np.argwhere(all_distances <
    -                                                         self.parameters.atomic_density_cutoff),
    -                                   :])
    +            all_atoms = np.squeeze(
    +                all_atoms[
    +                    np.argwhere(
    +                        all_distances < self.parameters.atomic_density_cutoff
    +                    ),
    +                    :,
    +                ]
    +            )
                 return np.concatenate((all_atoms, self.atoms.positions))
     
             else:
    @@ -909,11 +1010,15 @@ 

    Source code for mala.descriptors.descriptor

                 return np.diag(self.voxel) * [i, j, k]
             else:
                 ret = [0, 0, 0]
    -            ret[0] = i / self.grid_dimensions[0] * self.atoms.cell[0, 0] + \
    -                j / self.grid_dimensions[1] * self.atoms.cell[1, 0] + \
    -                k / self.grid_dimensions[2] * self.atoms.cell[2, 0]
    -            ret[1] = j / self.grid_dimensions[1] * self.atoms.cell[1, 1] + \
    -                k / self.grid_dimensions[2] * self.atoms.cell[1, 2]
    +            ret[0] = (
    +                i / self.grid_dimensions[0] * self.atoms.cell[0, 0]
    +                + j / self.grid_dimensions[1] * self.atoms.cell[1, 0]
    +                + k / self.grid_dimensions[2] * self.atoms.cell[2, 0]
    +            )
    +            ret[1] = (
    +                j / self.grid_dimensions[1] * self.atoms.cell[1, 1]
    +                + k / self.grid_dimensions[2] * self.atoms.cell[1, 2]
    +            )
                 ret[2] = k / self.grid_dimensions[2] * self.atoms.cell[2, 2]
                 return np.array(ret)
     
    diff --git a/_modules/mala/descriptors/lammps_utils.html b/_modules/mala/descriptors/lammps_utils.html
    index c371366c8..cb92e22f8 100644
    --- a/_modules/mala/descriptors/lammps_utils.html
    +++ b/_modules/mala/descriptors/lammps_utils.html
    @@ -75,6 +75,7 @@
                  
       

    Source code for mala.descriptors.lammps_utils

     """Collection of useful functions for working with LAMMPS."""
    +
     import ctypes
     
     import numpy as np
    @@ -103,12 +104,14 @@ 

    Source code for mala.descriptors.lammps_utils

    cmdargs += ["-var", key, f"{argdict[key]}"] return cmdargs
    + # def extract_commands(string): # return [x for x in string.splitlines() if x.strip() != ''] -
    [docs]def extract_compute_np(lmp, name, compute_type, result_type, array_shape=None, - use_fp64=False): +
    [docs]def extract_compute_np( + lmp, name, compute_type, result_type, array_shape=None, use_fp64=False +): """ Convert a lammps compute to a numpy array. @@ -146,8 +149,9 @@

    Source code for mala.descriptors.lammps_utils

    if result_type == 2: ptr = ptr.contents total_size = np.prod(array_shape) - buffer_ptr = ctypes.cast(ptr, ctypes.POINTER(ctypes.c_double * - total_size)) + buffer_ptr = ctypes.cast( + ptr, ctypes.POINTER(ctypes.c_double * total_size) + ) array_np = np.frombuffer(buffer_ptr.contents, dtype=float) array_np.shape = array_shape # If I directly return the descriptors, this sometimes leads diff --git a/_modules/mala/descriptors/minterpy_descriptors.html b/_modules/mala/descriptors/minterpy_descriptors.html index a3fd72765..ef569c06d 100644 --- a/_modules/mala/descriptors/minterpy_descriptors.html +++ b/_modules/mala/descriptors/minterpy_descriptors.html @@ -75,23 +75,15 @@

    Source code for mala.descriptors.minterpy_descriptors

     """Gaussian descriptor class."""
    +
     import os
     
     import ase
     import ase.io
    -try:
    -    from lammps import lammps
    -    # For version compatibility; older lammps versions (the serial version
    -    # we still use on some machines) do not have these constants.
    -    try:
    -        from lammps import constants as lammps_constants
    -    except ImportError:
    -        pass
    -except ModuleNotFoundError:
    -    pass
    +
     import numpy as np
     
    -from mala.descriptors.lammps_utils import set_cmdlinevars, extract_compute_np
    +from mala.descriptors.lammps_utils import extract_compute_np
     from mala.descriptors.descriptor import Descriptor
     from mala.descriptors.atomic_density import AtomicDensity
     
    @@ -170,7 +162,10 @@ 

    Source code for mala.descriptors.minterpy_descriptors

    raise Exception("Unsupported unit for Minterpy descriptors.")
    def _calculate(self, atoms, outdir, grid_dimensions, **kwargs): - from lammps import lammps + # For version compatibility; older lammps versions (the serial version + # we still use on some machines) have these constants as part of the + # general LAMMPS import. + from lammps import constants as lammps_constants nx = grid_dimensions[0] ny = grid_dimensions[1] @@ -183,8 +178,9 @@

    Source code for mala.descriptors.minterpy_descriptors

    voxel[0] = voxel[0] / (self.grid_dimensions[0]) voxel[1] = voxel[1] / (self.grid_dimensions[1]) voxel[2] = voxel[2] / (self.grid_dimensions[2]) - self.parameters.atomic_density_sigma = AtomicDensity.\ - get_optimal_sigma(voxel) + self.parameters.atomic_density_sigma = ( + AtomicDensity.get_optimal_sigma(voxel) + ) # Size of the local cube # self.parameters.minterpy_cutoff_cube_size @@ -202,28 +198,34 @@

    Source code for mala.descriptors.minterpy_descriptors

    # cells. self.parameters.minterpy_point_list = [] local_cube = atoms.cell.copy() - local_cube[0] = local_cube[0] * (self.parameters. - minterpy_cutoff_cube_size / - local_cube[0][0]) - local_cube[1] = local_cube[1] * (self.parameters. - minterpy_cutoff_cube_size / - local_cube[0][0]) - local_cube[2] = local_cube[2] * (self.parameters. - minterpy_cutoff_cube_size / - local_cube[0][0]) + local_cube[0] = local_cube[0] * ( + self.parameters.minterpy_cutoff_cube_size / local_cube[0][0] + ) + local_cube[1] = local_cube[1] * ( + self.parameters.minterpy_cutoff_cube_size / local_cube[0][0] + ) + local_cube[2] = local_cube[2] * ( + self.parameters.minterpy_cutoff_cube_size / local_cube[0][0] + ) for i in range(np.shape(unisolvent_nodes)[0]): - self.parameters.\ - minterpy_point_list.\ - append(np.matmul(local_cube, unisolvent_nodes[i])) + self.parameters.minterpy_point_list.append( + np.matmul(local_cube, unisolvent_nodes[i]) + ) # Array to hold descriptors. coord_length = 3 if self.parameters.descriptors_contain_xyz else 0 - minterpy_descriptors_np = \ - np.zeros([nx, ny, nz, - len(self.parameters.minterpy_point_list)+coord_length], - dtype=np.float64) - self.fingerprint_length = \ - len(self.parameters.minterpy_point_list)+coord_length + minterpy_descriptors_np = np.zeros( + [ + nx, + ny, + nz, + len(self.parameters.minterpy_point_list) + coord_length, + ], + dtype=np.float64, + ) + self.fingerprint_length = ( + len(self.parameters.minterpy_point_list) + coord_length + ) self.fingerprint_length = len(self.parameters.minterpy_point_list) # Perform one LAMMPS call for each point in the Minterpy point list. @@ -231,7 +233,7 @@

    Source code for mala.descriptors.minterpy_descriptors

    # Shift the atoms in negative direction of the point(s) we actually # want. atoms_copied = atoms.copy() - atoms_copied.set_positions(atoms.get_positions()-np.array(point)) + atoms_copied.set_positions(atoms.get_positions() - np.array(point)) # The rest is the stanfard LAMMPS atomic density stuff. lammps_format = "lammps-data" @@ -243,15 +245,23 @@

    Source code for mala.descriptors.minterpy_descriptors

    lammps_dict["sigma"] = self.parameters.atomic_density_sigma lammps_dict["rcutfac"] = self.parameters.atomic_density_cutoff lammps_dict["atom_config_fname"] = ase_out_path - lmp = self._setup_lammps(nx, ny, nz, outdir, lammps_dict, - log_file_name="lammps_mgrid_log.tmp") + lmp = self._setup_lammps( + nx, + ny, + nz, + outdir, + lammps_dict, + log_file_name="lammps_mgrid_log.tmp", + ) # For now the file is chosen automatically, because this is used # mostly under the hood anyway. filepath = __file__.split("minterpy")[0] if self.parameters._configuration["mpi"]: - raise Exception("Minterpy descriptors cannot be calculated " - "in parallel yet.") + raise Exception( + "Minterpy descriptors cannot be calculated " + "in parallel yet." + ) # if self.parameters.use_z_splitting: # runfile = os.path.join(filepath, "in.ggrid.python") # else: @@ -261,33 +271,48 @@

    Source code for mala.descriptors.minterpy_descriptors

    lmp.file(runfile) # Extract the data. - nrows_ggrid = extract_compute_np(lmp, "ggrid", - lammps_constants.LMP_STYLE_LOCAL, - lammps_constants.LMP_SIZE_ROWS) - ncols_ggrid = extract_compute_np(lmp, "ggrid", - lammps_constants.LMP_STYLE_LOCAL, - lammps_constants.LMP_SIZE_COLS) - - gaussian_descriptors_np = \ - extract_compute_np(lmp, "ggrid", - lammps_constants.LMP_STYLE_LOCAL, 2, - array_shape=(nrows_ggrid, ncols_ggrid)) + nrows_ggrid = extract_compute_np( + lmp, + "ggrid", + lammps_constants.LMP_STYLE_LOCAL, + lammps_constants.LMP_SIZE_ROWS, + ) + ncols_ggrid = extract_compute_np( + lmp, + "ggrid", + lammps_constants.LMP_STYLE_LOCAL, + lammps_constants.LMP_SIZE_COLS, + ) + + gaussian_descriptors_np = extract_compute_np( + lmp, + "ggrid", + lammps_constants.LMP_STYLE_LOCAL, + 2, + array_shape=(nrows_ggrid, ncols_ggrid), + ) lmp.close() - gaussian_descriptors_np = \ - gaussian_descriptors_np.reshape((grid_dimensions[2], - grid_dimensions[1], - grid_dimensions[0], - 7)) - gaussian_descriptors_np = \ - gaussian_descriptors_np.transpose([2, 1, 0, 3]) + gaussian_descriptors_np = gaussian_descriptors_np.reshape( + ( + grid_dimensions[2], + grid_dimensions[1], + grid_dimensions[0], + 7, + ) + ) + gaussian_descriptors_np = gaussian_descriptors_np.transpose( + [2, 1, 0, 3] + ) if self.parameters.descriptors_contain_xyz and idx == 0: - minterpy_descriptors_np[:, :, :, 0:3] = \ + minterpy_descriptors_np[:, :, :, 0:3] = ( gaussian_descriptors_np[:, :, :, 3:6].copy() + ) - minterpy_descriptors_np[:, :, :, coord_length+idx:coord_length+idx+1] = \ - gaussian_descriptors_np[:, :, :, 6:] + minterpy_descriptors_np[ + :, :, :, coord_length + idx : coord_length + idx + 1 + ] = gaussian_descriptors_np[:, :, :, 6:] return minterpy_descriptors_np, nx * ny * nz @@ -308,12 +333,13 @@

    Source code for mala.descriptors.minterpy_descriptors

    import minterpy as mp # Calculate the unisolvent nodes. - mi = mp.MultiIndexSet.from_degree(spatial_dimension=dimension, - poly_degree=self.parameters.minterpy_polynomial_degree, - lp_degree=self.parameters.minterpy_lp_norm) + mi = mp.MultiIndexSet.from_degree( + spatial_dimension=dimension, + poly_degree=self.parameters.minterpy_polynomial_degree, + lp_degree=self.parameters.minterpy_lp_norm, + ) unisolvent_nodes = mp.Grid(mi).unisolvent_nodes return unisolvent_nodes
    -
    diff --git a/_modules/mala/interfaces/ase_calculator.html b/_modules/mala/interfaces/ase_calculator.html index 4dda25b0a..d4fb6c866 100644 --- a/_modules/mala/interfaces/ase_calculator.html +++ b/_modules/mala/interfaces/ase_calculator.html @@ -77,11 +77,9 @@

    Source code for mala.interfaces.ase_calculator

    """ASE calculator for MALA predictions.""" from ase.calculators.calculator import Calculator, all_changes -import numpy as np -from mala import Parameters, Network, DataHandler, Predictor, LDOS, Density, \ - DOS -from mala.common.parallelizer import get_rank, get_comm, barrier +from mala import Parameters, Network, DataHandler, Predictor, LDOS +from mala.common.parallelizer import barrier

    [docs]class MALA(Calculator): @@ -114,34 +112,42 @@

    Source code for mala.interfaces.ase_calculator

    from the atomic positions. """ - implemented_properties = ['energy', 'forces'] + implemented_properties = ["energy", "forces"] - def __init__(self, params: Parameters, network: Network, - data: DataHandler, reference_data=None, - predictor=None): + def __init__( + self, + params: Parameters, + network: Network, + data: DataHandler, + reference_data=None, + predictor=None, + ): super(MALA, self).__init__() # Copy the MALA relevant objects. self.mala_parameters: Parameters = params if self.mala_parameters.targets.target_type != "LDOS": - raise Exception("The MALA calculator currently only works with the" - "LDOS.") + raise Exception( + "The MALA calculator currently only works with the LDOS." + ) self.network: Network = network self.data_handler: DataHandler = data # Prepare for prediction. if predictor is None: - self.predictor = Predictor(self.mala_parameters, self.network, - self.data_handler) + self.predictor = Predictor( + self.mala_parameters, self.network, self.data_handler + ) else: self.predictor = predictor if reference_data is not None: # Get critical values from a reference file (cutoff, # temperature, etc.) - self.data_handler.target_calculator.\ - read_additional_calculation_data(reference_data) + self.data_handler.target_calculator.read_additional_calculation_data( + reference_data + ) # Needed for e.g. Monte Carlo. self.last_energy_contributions = {} @@ -162,15 +168,20 @@

    Source code for mala.interfaces.ase_calculator

    path : str Path where the model is saved. """ - loaded_params, loaded_network, \ - new_datahandler, loaded_runner = Predictor.\ - load_run(run_name, path=path) - calculator = cls(loaded_params, loaded_network, new_datahandler, - predictor=loaded_runner) + loaded_params, loaded_network, new_datahandler, loaded_runner = ( + Predictor.load_run(run_name, path=path) + ) + calculator = cls( + loaded_params, + loaded_network, + new_datahandler, + predictor=loaded_runner, + ) return calculator

    -
    [docs] def calculate(self, atoms=None, properties=['energy'], - system_changes=all_changes): +
    [docs] def calculate( + self, atoms=None, properties=["energy"], system_changes=all_changes + ): """ Perform the calculations. @@ -199,24 +210,20 @@

    Source code for mala.interfaces.ase_calculator

    # If an MPI environment is detected, ASE will use it for writing. # Therefore we have to do this before forking. - self.data_handler.\ - target_calculator.\ - write_tem_input_file(atoms, - self.data_handler. - target_calculator.qe_input_data, - self.data_handler. - target_calculator.qe_pseudopotentials, - self.data_handler. - target_calculator.grid_dimensions, - self.data_handler. - target_calculator.kpoints) + self.data_handler.target_calculator.write_tem_input_file( + atoms, + self.data_handler.target_calculator.qe_input_data, + self.data_handler.target_calculator.qe_pseudopotentials, + self.data_handler.target_calculator.grid_dimensions, + self.data_handler.target_calculator.kpoints, + ) ldos_calculator: LDOS = self.data_handler.target_calculator ldos_calculator.read_from_array(ldos) - energy, self.last_energy_contributions \ - = ldos_calculator.get_total_energy(return_energy_contributions= - True) + energy, self.last_energy_contributions = ( + ldos_calculator.get_total_energy(return_energy_contributions=True) + ) barrier() # Use the LDOS determined DOS and density to get energy and forces. @@ -246,17 +253,27 @@

    Source code for mala.interfaces.ase_calculator

    # TODO: Check atoms. if "rdf" in properties: - self.results["rdf"] = self.data_handler.target_calculator.\ - get_radial_distribution_function(atoms) + self.results["rdf"] = ( + self.data_handler.target_calculator.get_radial_distribution_function( + atoms + ) + ) if "tpcf" in properties: - self.results["tpcf"] = self.data_handler.target_calculator.\ - get_three_particle_correlation_function(atoms) + self.results["tpcf"] = ( + self.data_handler.target_calculator.get_three_particle_correlation_function( + atoms + ) + ) if "static_structure_factor" in properties: - self.results["static_structure_factor"] = self.data_handler.\ - target_calculator.get_static_structure_factor(atoms) + self.results["static_structure_factor"] = ( + self.data_handler.target_calculator.get_static_structure_factor( + atoms + ) + ) if "ion_ion_energy" in properties: - self.results["ion_ion_energy"] = self.\ - last_energy_contributions["e_ewald"]

    + self.results["ion_ion_energy"] = self.last_energy_contributions[ + "e_ewald" + ]
    [docs] def save_calculator(self, filename, save_path="./"): """ @@ -273,9 +290,9 @@

    Source code for mala.interfaces.ase_calculator

    Path where the calculator should be saved. """ - self.predictor.save_run(filename, save_path=save_path, - additional_calculation_data=True)

    - + self.predictor.save_run( + filename, save_path=save_path, additional_calculation_data=True + )
    diff --git a/_modules/mala/network/acsd_analyzer.html b/_modules/mala/network/acsd_analyzer.html index 3a86e16d3..c7ed8f1be 100644 --- a/_modules/mala/network/acsd_analyzer.html +++ b/_modules/mala/network/acsd_analyzer.html @@ -75,13 +75,16 @@

    Source code for mala.network.acsd_analyzer

     """Class for performing a full ACSD analysis."""
    +
     import itertools
     import os
     
     import numpy as np
     
    -from mala.datahandling.data_converter import descriptor_input_types, \
    -    target_input_types
    +from mala.datahandling.data_converter import (
    +    descriptor_input_types,
    +    target_input_types,
    +)
     from mala.descriptors.descriptor import Descriptor
     from mala.targets.target import Target
     from mala.network.hyperparameter import Hyperparameter
    @@ -91,8 +94,8 @@ 

    Source code for mala.network.acsd_analyzer

     from mala.descriptors.atomic_density import AtomicDensity
     from mala.descriptors.minterpy_descriptors import MinterpyDescriptors
     
    -descriptor_input_types_acsd = descriptor_input_types+["numpy", "openpmd"]
    -target_input_types_acsd = target_input_types+["numpy", "openpmd"]
    +descriptor_input_types_acsd = descriptor_input_types + ["numpy", "openpmd"]
    +target_input_types_acsd = target_input_types + ["numpy", "openpmd"]
     
     
     
    [docs]class ACSDAnalyzer(HyperOpt): @@ -117,8 +120,9 @@

    Source code for mala.network.acsd_analyzer

             parameters provided. Default: None
         """
     
    -    def __init__(self, params, target_calculator=None,
    -                 descriptor_calculator=None):
    +    def __init__(
    +        self, params, target_calculator=None, descriptor_calculator=None
    +    ):
             super(ACSDAnalyzer, self).__init__(params)
             # Calculators used to parse data from compatible files.
             self.target_calculator = target_calculator
    @@ -127,11 +131,14 @@ 

    Source code for mala.network.acsd_analyzer

             self.descriptor_calculator = descriptor_calculator
             if self.descriptor_calculator is None:
                 self.descriptor_calculator = Descriptor(params)
    -        if not isinstance(self.descriptor_calculator, Bispectrum) and \
    -           not isinstance(self.descriptor_calculator, AtomicDensity) and \
    -           not isinstance(self.descriptor_calculator, MinterpyDescriptors):
    -            raise Exception("Cannot calculate ACSD for the selected "
    -                            "descriptors.")
    +        if (
    +            not isinstance(self.descriptor_calculator, Bispectrum)
    +            and not isinstance(self.descriptor_calculator, AtomicDensity)
    +            and not isinstance(self.descriptor_calculator, MinterpyDescriptors)
    +        ):
    +            raise Exception(
    +                "Cannot calculate ACSD for the selected descriptors."
    +            )
     
             # Internal variables.
             self.__snapshots = []
    @@ -144,12 +151,15 @@ 

    Source code for mala.network.acsd_analyzer

             self.reduced_study = None
             self.internal_hyperparam_list = None
     
    -
    [docs] def add_snapshot(self, descriptor_input_type=None, - descriptor_input_path=None, - target_input_type=None, - target_input_path=None, - descriptor_units=None, - target_units=None): +
    [docs] def add_snapshot( + self, + descriptor_input_type=None, + descriptor_input_path=None, + target_input_type=None, + target_input_path=None, + descriptor_units=None, + target_units=None, + ): """ Add a snapshot to be processed. @@ -181,30 +191,33 @@

    Source code for mala.network.acsd_analyzer

             if descriptor_input_type is not None:
                 if descriptor_input_path is None:
                     raise Exception(
    -                    "Cannot process descriptor data with no path "
    -                    "given.")
    +                    "Cannot process descriptor data with no path given."
    +                )
                 if descriptor_input_type not in descriptor_input_types_acsd:
    -                raise Exception(
    -                    "Cannot process this type of descriptor data.")
    +                raise Exception("Cannot process this type of descriptor data.")
             else:
                 raise Exception("Cannot calculate ACSD without descriptor data.")
     
             if target_input_type is not None:
                 if target_input_path is None:
    -                raise Exception("Cannot process target data with no path "
    -                                "given.")
    +                raise Exception(
    +                    "Cannot process target data with no path given."
    +                )
                 if target_input_type not in target_input_types_acsd:
                     raise Exception("Cannot process this type of target data.")
             else:
                 raise Exception("Cannot calculate ACSD without target data.")
     
             # Assign info.
    -        self.__snapshots.append({"input": descriptor_input_path,
    -                                            "output": target_input_path})
    -        self.__snapshot_description.append({"input": descriptor_input_type,
    -                                            "output": target_input_type})
    -        self.__snapshot_units.append({"input": descriptor_units,
    -                                      "output": target_units})
    + self.__snapshots.append( + {"input": descriptor_input_path, "output": target_input_path} + ) + self.__snapshot_description.append( + {"input": descriptor_input_type, "output": target_input_type} + ) + self.__snapshot_units.append( + {"input": descriptor_units, "output": target_units} + )
    [docs] def add_hyperparameter(self, name, choices): """ @@ -220,21 +233,29 @@

    Source code for mala.network.acsd_analyzer

             choices :
                 List of possible choices.
             """
    -        if name not in ["bispectrum_twojmax", "bispectrum_cutoff",
    -                        "atomic_density_sigma", "atomic_density_cutoff",
    -                        "minterpy_cutoff_cube_size",
    -                        "minterpy_polynomial_degree",
    -                        "minterpy_lp_norm"]:
    +        if name not in [
    +            "bispectrum_twojmax",
    +            "bispectrum_cutoff",
    +            "atomic_density_sigma",
    +            "atomic_density_cutoff",
    +            "minterpy_cutoff_cube_size",
    +            "minterpy_polynomial_degree",
    +            "minterpy_lp_norm",
    +        ]:
                 raise Exception("Unkown hyperparameter for ACSD analysis entered.")
     
    -        self.params.hyperparameters.\
    -            hlist.append(Hyperparameter(hotype="acsd",
    -                                        name=name,
    -                                        choices=choices,
    -                                        opttype="categorical"))
    - -
    [docs] def perform_study(self, file_based_communication=False, - return_plotting=False): + self.params.hyperparameters.hlist.append( + Hyperparameter( + hotype="acsd", + name=name, + choices=choices, + opttype="categorical", + ) + )
    + +
    [docs] def perform_study( + self, file_based_communication=False, return_plotting=False + ): """ Perform the study, i.e. the optimization. @@ -243,57 +264,71 @@

    Source code for mala.network.acsd_analyzer

             """
             # Prepare the hyperparameter lists.
             self._construct_hyperparam_list()
    -        hyperparameter_tuples = list(itertools.product(
    -            *self.internal_hyperparam_list))
    +        hyperparameter_tuples = list(
    +            itertools.product(*self.internal_hyperparam_list)
    +        )
     
             # Perform the ACSD analysis separately for each snapshot.
             best_acsd = None
             best_trial = None
             for i in range(0, len(self.__snapshots)):
    -            printout("Starting ACSD analysis of snapshot", str(i),
    -                     min_verbosity=1)
    +            printout(
    +                "Starting ACSD analysis of snapshot", str(i), min_verbosity=1
    +            )
                 current_list = []
    -            target = self._load_target(self.__snapshots[i],
    -                                       self.__snapshot_description[i],
    -                                       self.__snapshot_units[i],
    -                                       file_based_communication)
    +            target = self._load_target(
    +                self.__snapshots[i],
    +                self.__snapshot_description[i],
    +                self.__snapshot_units[i],
    +                file_based_communication,
    +            )
     
                 for idx, hyperparameter_tuple in enumerate(hyperparameter_tuples):
                     if isinstance(self.descriptor_calculator, Bispectrum):
    -                    self.params.descriptors.bispectrum_cutoff = \
    +                    self.params.descriptors.bispectrum_cutoff = (
                             hyperparameter_tuple[0]
    -                    self.params.descriptors.bispectrum_twojmax = \
    +                    )
    +                    self.params.descriptors.bispectrum_twojmax = (
                             hyperparameter_tuple[1]
    +                    )
                     elif isinstance(self.descriptor_calculator, AtomicDensity):
    -                    self.params.descriptors.atomic_density_cutoff = \
    +                    self.params.descriptors.atomic_density_cutoff = (
                             hyperparameter_tuple[0]
    -                    self.params.descriptors.atomic_density_sigma = \
    +                    )
    +                    self.params.descriptors.atomic_density_sigma = (
                             hyperparameter_tuple[1]
    -                elif isinstance(self.descriptor_calculator,
    -                              MinterpyDescriptors):
    -                    self.params.descriptors. \
    -                        atomic_density_cutoff = hyperparameter_tuple[0]
    -                    self.params.descriptors. \
    -                        atomic_density_sigma = hyperparameter_tuple[1]
    -                    self.params.descriptors. \
    -                        minterpy_cutoff_cube_size = \
    +                    )
    +                elif isinstance(
    +                    self.descriptor_calculator, MinterpyDescriptors
    +                ):
    +                    self.params.descriptors.atomic_density_cutoff = (
    +                        hyperparameter_tuple[0]
    +                    )
    +                    self.params.descriptors.atomic_density_sigma = (
    +                        hyperparameter_tuple[1]
    +                    )
    +                    self.params.descriptors.minterpy_cutoff_cube_size = (
                             hyperparameter_tuple[2]
    -                    self.params.descriptors. \
    -                        minterpy_polynomial_degree = \
    +                    )
    +                    self.params.descriptors.minterpy_polynomial_degree = (
                             hyperparameter_tuple[3]
    -                    self.params.descriptors. \
    -                        minterpy_lp_norm = \
    +                    )
    +                    self.params.descriptors.minterpy_lp_norm = (
                             hyperparameter_tuple[4]
    +                    )
     
    -                descriptor = \
    -                    self._calculate_descriptors(self.__snapshots[i],
    -                                                self.__snapshot_description[i],
    -                                                self.__snapshot_units[i])
    +                descriptor = self._calculate_descriptors(
    +                    self.__snapshots[i],
    +                    self.__snapshot_description[i],
    +                    self.__snapshot_units[i],
    +                )
                     if get_rank() == 0:
    -                    acsd = self._calculate_acsd(descriptor, target,
    -                                                self.params.hyperparameters.acsd_points,
    -                                                descriptor_vectors_contain_xyz=
    -                                                self.params.descriptors.descriptors_contain_xyz)
    +                    acsd = self._calculate_acsd(
    +                        descriptor,
    +                        target,
    +                        self.params.hyperparameters.acsd_points,
    +                        descriptor_vectors_contain_xyz=self.params.descriptors.descriptors_contain_xyz,
    +                    )
                         if not np.isnan(acsd):
                             if best_acsd is None:
                                 best_acsd = acsd
    @@ -301,25 +336,39 @@ 

    Source code for mala.network.acsd_analyzer

                             elif acsd < best_acsd:
                                 best_acsd = acsd
                                 best_trial = idx
    -                        current_list.append(list(hyperparameter_tuple) + [acsd])
    +                        current_list.append(
    +                            list(hyperparameter_tuple) + [acsd]
    +                        )
                         else:
    -                        current_list.append(list(hyperparameter_tuple) + [np.inf])
    +                        current_list.append(
    +                            list(hyperparameter_tuple) + [np.inf]
    +                        )
     
                         outstring = "["
                         for label_id, label in enumerate(self.labels):
    -                        outstring += label + ": " + \
    -                                     str(hyperparameter_tuple[label_id])
    +                        outstring += (
    +                            label + ": " + str(hyperparameter_tuple[label_id])
    +                        )
                             if label_id < len(self.labels) - 1:
                                 outstring += ", "
                         outstring += "]"
                         best_trial_string = ". No suitable trial found yet."
                         if best_acsd is not None:
    -                        best_trial_string = ". Best trial is "+str(best_trial) \
    -                                            + " with "+str(best_acsd)
    -
    -                    printout("Trial", idx, "finished with ACSD="+str(acsd),
    -                             "and parameters:", outstring+best_trial_string,
    -                             min_verbosity=1)
    +                        best_trial_string = (
    +                            ". Best trial is "
    +                            + str(best_trial)
    +                            + " with "
    +                            + str(best_acsd)
    +                        )
    +
    +                    printout(
    +                        "Trial",
    +                        idx,
    +                        "finished with ACSD=" + str(acsd),
    +                        "and parameters:",
    +                        outstring + best_trial_string,
    +                        min_verbosity=1,
    +                    )
     
                 if get_rank() == 0:
                     self.study.append(current_list)
    @@ -335,14 +384,22 @@ 

    Source code for mala.network.acsd_analyzer

                         len_second_dim = len(self.internal_hyperparam_list[1])
                         for i in range(0, len_first_dim):
                             results_to_plot.append(
    -                            self.study[i*len_second_dim:(i+1)*len_second_dim, 2:])
    +                            self.study[
    +                                i * len_second_dim : (i + 1) * len_second_dim,
    +                                2:,
    +                            ]
    +                        )
     
                         if isinstance(self.descriptor_calculator, Bispectrum):
    -                        return results_to_plot, {"twojmax": self.internal_hyperparam_list[1],
    -                                                 "cutoff": self.internal_hyperparam_list[0]}
    +                        return results_to_plot, {
    +                            "twojmax": self.internal_hyperparam_list[1],
    +                            "cutoff": self.internal_hyperparam_list[0],
    +                        }
                         if isinstance(self.descriptor_calculator, AtomicDensity):
    -                        return results_to_plot, {"sigma": self.internal_hyperparam_list[1],
    -                                                 "cutoff": self.internal_hyperparam_list[0]}
    + return results_to_plot, { + "sigma": self.internal_hyperparam_list[1], + "cutoff": self.internal_hyperparam_list[0], + }
    [docs] def set_optimal_parameters(self): """ @@ -356,174 +413,335 @@

    Source code for mala.network.acsd_analyzer

                 if len(self.internal_hyperparam_list) == 2:
                     if isinstance(self.descriptor_calculator, Bispectrum):
                         self.params.descriptors.bispectrum_cutoff = minimum_acsd[0]
    -                    self.params.descriptors.bispectrum_twojmax = int(minimum_acsd[1])
    -                    printout("ACSD analysis finished, optimal parameters: ", )
    -                    printout("Bispectrum twojmax: ", self.params.descriptors.
    -                             bispectrum_twojmax)
    -                    printout("Bispectrum cutoff: ", self.params.descriptors.
    -                             bispectrum_cutoff)
    +                    self.params.descriptors.bispectrum_twojmax = int(
    +                        minimum_acsd[1]
    +                    )
    +                    printout(
    +                        "ACSD analysis finished, optimal parameters: ",
    +                    )
    +                    printout(
    +                        "Bispectrum twojmax: ",
    +                        self.params.descriptors.bispectrum_twojmax,
    +                    )
    +                    printout(
    +                        "Bispectrum cutoff: ",
    +                        self.params.descriptors.bispectrum_cutoff,
    +                    )
                     if isinstance(self.descriptor_calculator, AtomicDensity):
    -                    self.params.descriptors.atomic_density_cutoff = minimum_acsd[0]
    -                    self.params.descriptors.atomic_density_sigma = minimum_acsd[1]
    -                    printout("ACSD analysis finished, optimal parameters: ", )
    -                    printout("Atomic density sigma: ", self.params.descriptors.
    -                             atomic_density_sigma)
    -                    printout("Atomic density cutoff: ", self.params.descriptors.
    -                             atomic_density_cutoff)
    +                    self.params.descriptors.atomic_density_cutoff = (
    +                        minimum_acsd[0]
    +                    )
    +                    self.params.descriptors.atomic_density_sigma = (
    +                        minimum_acsd[1]
    +                    )
    +                    printout(
    +                        "ACSD analysis finished, optimal parameters: ",
    +                    )
    +                    printout(
    +                        "Atomic density sigma: ",
    +                        self.params.descriptors.atomic_density_sigma,
    +                    )
    +                    printout(
    +                        "Atomic density cutoff: ",
    +                        self.params.descriptors.atomic_density_cutoff,
    +                    )
                 elif len(self.internal_hyperparam_list) == 5:
                     if isinstance(self.descriptor_calculator, MinterpyDescriptors):
    -                    self.params.descriptors.atomic_density_cutoff = minimum_acsd[0]
    -                    self.params.descriptors.atomic_density_sigma = minimum_acsd[1]
    -                    self.params.descriptors.minterpy_cutoff_cube_size = minimum_acsd[2]
    -                    self.params.descriptors.minterpy_polynomial_degree = int(minimum_acsd[3])
    -                    self.params.descriptors.minterpy_lp_norm = int(minimum_acsd[4])
    -                    printout("ACSD analysis finished, optimal parameters: ", )
    -                    printout("Atomic density sigma: ", self.params.descriptors.
    -                             atomic_density_sigma)
    -                    printout("Atomic density cutoff: ", self.params.descriptors.
    -                             atomic_density_cutoff)
    -                    printout("Minterpy cube cutoff: ", self.params.descriptors.
    -                             minterpy_cutoff_cube_size)
    -                    printout("Minterpy polynomial degree: ", self.params.descriptors.
    -                             minterpy_polynomial_degree)
    -                    printout("Minterpy LP norm degree: ", self.params.descriptors.
    -                             minterpy_lp_norm)
    + self.params.descriptors.atomic_density_cutoff = ( + minimum_acsd[0] + ) + self.params.descriptors.atomic_density_sigma = ( + minimum_acsd[1] + ) + self.params.descriptors.minterpy_cutoff_cube_size = ( + minimum_acsd[2] + ) + self.params.descriptors.minterpy_polynomial_degree = int( + minimum_acsd[3] + ) + self.params.descriptors.minterpy_lp_norm = int( + minimum_acsd[4] + ) + printout( + "ACSD analysis finished, optimal parameters: ", + ) + printout( + "Atomic density sigma: ", + self.params.descriptors.atomic_density_sigma, + ) + printout( + "Atomic density cutoff: ", + self.params.descriptors.atomic_density_cutoff, + ) + printout( + "Minterpy cube cutoff: ", + self.params.descriptors.minterpy_cutoff_cube_size, + ) + printout( + "Minterpy polynomial degree: ", + self.params.descriptors.minterpy_polynomial_degree, + ) + printout( + "Minterpy LP norm degree: ", + self.params.descriptors.minterpy_lp_norm, + )
    def _construct_hyperparam_list(self): if isinstance(self.descriptor_calculator, Bispectrum): - if list(map(lambda p: "bispectrum_cutoff" in p.name, - self.params.hyperparameters.hlist)).count(True) == 0: + if ( + list( + map( + lambda p: "bispectrum_cutoff" in p.name, + self.params.hyperparameters.hlist, + ) + ).count(True) + == 0 + ): first_dim_list = [self.params.descriptors.bispectrum_cutoff] else: - first_dim_list = \ - self.params.hyperparameters.hlist[ - list(map(lambda p: "bispectrum_cutoff" in p.name, - self.params.hyperparameters.hlist)).index( - True)].choices - - if list(map(lambda p: "bispectrum_twojmax" in p.name, - self.params.hyperparameters.hlist)).count(True) == 0: + first_dim_list = self.params.hyperparameters.hlist[ + list( + map( + lambda p: "bispectrum_cutoff" in p.name, + self.params.hyperparameters.hlist, + ) + ).index(True) + ].choices + + if ( + list( + map( + lambda p: "bispectrum_twojmax" in p.name, + self.params.hyperparameters.hlist, + ) + ).count(True) + == 0 + ): second_dim_list = [self.params.descriptors.bispectrum_twojmax] else: - second_dim_list = \ - self.params.hyperparameters.hlist[ - list(map(lambda p: "bispectrum_twojmax" in p.name, - self.params.hyperparameters.hlist)).index(True)].choices + second_dim_list = self.params.hyperparameters.hlist[ + list( + map( + lambda p: "bispectrum_twojmax" in p.name, + self.params.hyperparameters.hlist, + ) + ).index(True) + ].choices self.internal_hyperparam_list = [first_dim_list, second_dim_list] self.labels = ["cutoff", "twojmax"] elif isinstance(self.descriptor_calculator, AtomicDensity): - if list(map(lambda p: "atomic_density_cutoff" in p.name, - self.params.hyperparameters.hlist)).count(True) == 0: - first_dim_list = [self.params.descriptors.atomic_density_cutoff] + if ( + list( + map( + lambda p: "atomic_density_cutoff" in p.name, + self.params.hyperparameters.hlist, + ) + ).count(True) + == 0 + ): + first_dim_list = [ + self.params.descriptors.atomic_density_cutoff + ] else: - first_dim_list = \ - self.params.hyperparameters.hlist[ - list(map(lambda p: "atomic_density_cutoff" in p.name, - self.params.hyperparameters.hlist)).index( - True)].choices - - if list(map(lambda p: "atomic_density_sigma" in p.name, - self.params.hyperparameters.hlist)).count(True) == 0: - second_dim_list = [self.params.descriptors.atomic_density_sigma] + first_dim_list = self.params.hyperparameters.hlist[ + list( + map( + lambda p: "atomic_density_cutoff" in p.name, + self.params.hyperparameters.hlist, + ) + ).index(True) + ].choices + + if ( + list( + map( + lambda p: "atomic_density_sigma" in p.name, + self.params.hyperparameters.hlist, + ) + ).count(True) + == 0 + ): + second_dim_list = [ + self.params.descriptors.atomic_density_sigma + ] else: - second_dim_list = \ - self.params.hyperparameters.hlist[ - list(map(lambda p: "atomic_density_sigma" in p.name, - self.params.hyperparameters.hlist)).index( - True)].choices + second_dim_list = self.params.hyperparameters.hlist[ + list( + map( + lambda p: "atomic_density_sigma" in p.name, + self.params.hyperparameters.hlist, + ) + ).index(True) + ].choices self.internal_hyperparam_list = [first_dim_list, second_dim_list] self.labels = ["cutoff", "sigma"] elif isinstance(self.descriptor_calculator, MinterpyDescriptors): - if list(map(lambda p: "atomic_density_cutoff" in p.name, - self.params.hyperparameters.hlist)).count(True) == 0: - first_dim_list = [self.params.descriptors.atomic_density_cutoff] + if ( + list( + map( + lambda p: "atomic_density_cutoff" in p.name, + self.params.hyperparameters.hlist, + ) + ).count(True) + == 0 + ): + first_dim_list = [ + self.params.descriptors.atomic_density_cutoff + ] else: - first_dim_list = \ - self.params.hyperparameters.hlist[ - list(map(lambda p: "atomic_density_cutoff" in p.name, - self.params.hyperparameters.hlist)).index( - True)].choices - - if list(map(lambda p: "atomic_density_sigma" in p.name, - self.params.hyperparameters.hlist)).count(True) == 0: - second_dim_list = [self.params.descriptors.atomic_density_sigma] + first_dim_list = self.params.hyperparameters.hlist[ + list( + map( + lambda p: "atomic_density_cutoff" in p.name, + self.params.hyperparameters.hlist, + ) + ).index(True) + ].choices + + if ( + list( + map( + lambda p: "atomic_density_sigma" in p.name, + self.params.hyperparameters.hlist, + ) + ).count(True) + == 0 + ): + second_dim_list = [ + self.params.descriptors.atomic_density_sigma + ] else: - second_dim_list = \ - self.params.hyperparameters.hlist[ - list(map(lambda p: "atomic_density_sigma" in p.name, - self.params.hyperparameters.hlist)).index( - True)].choices - - if list(map(lambda p: "minterpy_cutoff_cube_size" in p.name, - self.params.hyperparameters.hlist)).count(True) == 0: - third_dim_list = [self.params.descriptors.minterpy_cutoff_cube_size] + second_dim_list = self.params.hyperparameters.hlist[ + list( + map( + lambda p: "atomic_density_sigma" in p.name, + self.params.hyperparameters.hlist, + ) + ).index(True) + ].choices + + if ( + list( + map( + lambda p: "minterpy_cutoff_cube_size" in p.name, + self.params.hyperparameters.hlist, + ) + ).count(True) + == 0 + ): + third_dim_list = [ + self.params.descriptors.minterpy_cutoff_cube_size + ] else: - third_dim_list = \ - self.params.hyperparameters.hlist[ - list(map(lambda p: "minterpy_cutoff_cube_size" in p.name, - self.params.hyperparameters.hlist)).index( - True)].choices - - if list(map(lambda p: "minterpy_polynomial_degree" in p.name, - self.params.hyperparameters.hlist)).count(True) == 0: - fourth_dim_list = [self.params.descriptors.minterpy_polynomial_degree] + third_dim_list = self.params.hyperparameters.hlist[ + list( + map( + lambda p: "minterpy_cutoff_cube_size" in p.name, + self.params.hyperparameters.hlist, + ) + ).index(True) + ].choices + + if ( + list( + map( + lambda p: "minterpy_polynomial_degree" in p.name, + self.params.hyperparameters.hlist, + ) + ).count(True) + == 0 + ): + fourth_dim_list = [ + self.params.descriptors.minterpy_polynomial_degree + ] else: - fourth_dim_list = \ - self.params.hyperparameters.hlist[ - list(map(lambda p: "minterpy_polynomial_degree" in p.name, - self.params.hyperparameters.hlist)).index( - True)].choices - - if list(map(lambda p: "minterpy_lp_norm" in p.name, - self.params.hyperparameters.hlist)).count(True) == 0: + fourth_dim_list = self.params.hyperparameters.hlist[ + list( + map( + lambda p: "minterpy_polynomial_degree" in p.name, + self.params.hyperparameters.hlist, + ) + ).index(True) + ].choices + + if ( + list( + map( + lambda p: "minterpy_lp_norm" in p.name, + self.params.hyperparameters.hlist, + ) + ).count(True) + == 0 + ): fifth_dim_list = [self.params.descriptors.minterpy_lp_norm] else: - fifth_dim_list = \ - self.params.hyperparameters.hlist[ - list(map(lambda p: "minterpy_lp_norm" in p.name, - self.params.hyperparameters.hlist)).index( - True)].choices - - self.internal_hyperparam_list = [first_dim_list, second_dim_list, - third_dim_list, fourth_dim_list, - fifth_dim_list] - self.labels = ["cutoff", "sigma", "minterpy_cutoff", - "minterpy_polynomial_degree", "minterpy_lp_norm"] + fifth_dim_list = self.params.hyperparameters.hlist[ + list( + map( + lambda p: "minterpy_lp_norm" in p.name, + self.params.hyperparameters.hlist, + ) + ).index(True) + ].choices + + self.internal_hyperparam_list = [ + first_dim_list, + second_dim_list, + third_dim_list, + fourth_dim_list, + fifth_dim_list, + ] + self.labels = [ + "cutoff", + "sigma", + "minterpy_cutoff", + "minterpy_polynomial_degree", + "minterpy_lp_norm", + ] else: - raise Exception("Unkown descriptor calculator selected. Cannot " - "calculate ACSD.") + raise Exception( + "Unkown descriptor calculator selected. Cannot " + "calculate ACSD." + ) def _calculate_descriptors(self, snapshot, description, original_units): descriptor_calculation_kwargs = {} tmp_input = None if description["input"] == "espresso-out": descriptor_calculation_kwargs["units"] = original_units["input"] - tmp_input, local_size = self.descriptor_calculator. \ - calculate_from_qe_out(snapshot["input"], - **descriptor_calculation_kwargs) + tmp_input, local_size = ( + self.descriptor_calculator.calculate_from_qe_out( + snapshot["input"], **descriptor_calculation_kwargs + ) + ) elif description["input"] is None: # In this case, only the output is processed. pass else: - raise Exception("Unknown file extension, cannot convert " - "descriptor") + raise Exception( + "Unknown file extension, cannot convert descriptor" + ) if self.params.descriptors._configuration["mpi"]: - tmp_input = self.descriptor_calculator. \ - gather_descriptors(tmp_input) + tmp_input = self.descriptor_calculator.gather_descriptors( + tmp_input + ) return tmp_input - def _load_target(self, snapshot, description, original_units, - file_based_communication): + def _load_target( + self, snapshot, description, original_units, file_based_communication + ): memmap = None - if self.params.descriptors._configuration["mpi"] and \ - file_based_communication: + if ( + self.params.descriptors._configuration["mpi"] + and file_based_communication + ): memmap = "acsd.out.npy_temp" target_calculator_kwargs = {} @@ -534,43 +752,48 @@

    Source code for mala.network.acsd_analyzer

                 target_calculator_kwargs["units"] = original_units["output"]
                 target_calculator_kwargs["use_memmap"] = memmap
                 # If no units are provided we just assume standard units.
    -            tmp_output = self.target_calculator. \
    -                read_from_cube(snapshot["output"],
    -            ** target_calculator_kwargs)
    +            tmp_output = self.target_calculator.read_from_cube(
    +                snapshot["output"], **target_calculator_kwargs
    +            )
     
             elif description["output"] == ".xsf":
                 target_calculator_kwargs["units"] = original_units["output"]
                 target_calculator_kwargs["use_memmap"] = memmap
                 # If no units are provided we just assume standard units.
    -            tmp_output = self.target_calculator. \
    -                read_from_xsf(snapshot["output"],
    -            ** target_calculator_kwargs)
    +            tmp_output = self.target_calculator.read_from_xsf(
    +                snapshot["output"], **target_calculator_kwargs
    +            )
     
             elif description["output"] == "numpy":
                 if get_rank() == 0:
    -                tmp_output = self.\
    -                    target_calculator.read_from_numpy_file(
    -                    snapshot["output"], units=original_units["output"])
    +                tmp_output = self.target_calculator.read_from_numpy_file(
    +                    snapshot["output"], units=original_units["output"]
    +                )
     
             elif description["output"] == "openpmd":
                 if get_rank() == 0:
    -                tmp_output = self.\
    -                    target_calculator.read_from_numpy_file(
    -                    snapshot["output"], units=original_units["output"])
    +                tmp_output = self.target_calculator.read_from_numpy_file(
    +                    snapshot["output"], units=original_units["output"]
    +                )
             else:
                 raise Exception("Unknown file extension, cannot convert target")
     
             if get_rank() == 0:
    -            if self.params.targets._configuration["mpi"] \
    -                    and file_based_communication:
    +            if (
    +                self.params.targets._configuration["mpi"]
    +                and file_based_communication
    +            ):
                     os.remove(memmap)
     
             return tmp_output
     
    -
         @staticmethod
    -    def _calculate_cosine_similarities(descriptor_data, ldos_data, nr_points,
    -                                       descriptor_vectors_contain_xyz=True):
    +    def _calculate_cosine_similarities(
    +        descriptor_data,
    +        ldos_data,
    +        nr_points,
    +        descriptor_vectors_contain_xyz=True,
    +    ):
             """
             Calculate the raw cosine similarities for descriptor and LDOS data.
     
    @@ -600,51 +823,62 @@ 

    Source code for mala.network.acsd_analyzer

             descriptor_dim = np.shape(descriptor_data)
             ldos_dim = np.shape(ldos_data)
             if len(descriptor_dim) == 4:
    -            descriptor_data = np.reshape(descriptor_data,
    -                                         (descriptor_dim[0] *
    -                                          descriptor_dim[1] *
    -                                          descriptor_dim[2],
    -                                          descriptor_dim[3]))
    +            descriptor_data = np.reshape(
    +                descriptor_data,
    +                (
    +                    descriptor_dim[0] * descriptor_dim[1] * descriptor_dim[2],
    +                    descriptor_dim[3],
    +                ),
    +            )
                 if descriptor_vectors_contain_xyz:
                     descriptor_data = descriptor_data[:, 3:]
             elif len(descriptor_dim) != 2:
                 raise Exception("Cannot work with this descriptor data.")
     
             if len(ldos_dim) == 4:
    -            ldos_data = np.reshape(ldos_data, (ldos_dim[0] * ldos_dim[1] *
    -                                               ldos_dim[2], ldos_dim[3]))
    +            ldos_data = np.reshape(
    +                ldos_data,
    +                (ldos_dim[0] * ldos_dim[1] * ldos_dim[2], ldos_dim[3]),
    +            )
             elif len(ldos_dim) != 2:
                 raise Exception("Cannot work with this LDOS data.")
     
             similarity_array = []
             # Draw nr_points at random from snapshot.
             rng = np.random.default_rng()
    -        points_i = rng.choice(np.shape(descriptor_data)[0],
    -                              size=np.shape(descriptor_data)[0],
    -                              replace=False)
    +        points_i = rng.choice(
    +            np.shape(descriptor_data)[0],
    +            size=np.shape(descriptor_data)[0],
    +            replace=False,
    +        )
             for i in range(0, nr_points):
                 # Draw another nr_points at random from snapshot.
                 rng = np.random.default_rng()
    -            points_j = rng.choice(np.shape(descriptor_data)[0],
    -                                  size=np.shape(descriptor_data)[0],
    -                                  replace=False)
    +            points_j = rng.choice(
    +                np.shape(descriptor_data)[0],
    +                size=np.shape(descriptor_data)[0],
    +                replace=False,
    +            )
     
                 for j in range(0, nr_points):
                     # Calculate similarities between these two pairs.
    -                descriptor_distance = \
    -                    ACSDAnalyzer.__calc_cosine_similarity(
    -                        descriptor_data[points_i[i]],
    -                        descriptor_data[points_j[j]])
    -                ldos_distance = ACSDAnalyzer.\
    -                    __calc_cosine_similarity(ldos_data[points_i[i]],
    -                                             ldos_data[points_j[j]])
    +                descriptor_distance = ACSDAnalyzer.__calc_cosine_similarity(
    +                    descriptor_data[points_i[i]], descriptor_data[points_j[j]]
    +                )
    +                ldos_distance = ACSDAnalyzer.__calc_cosine_similarity(
    +                    ldos_data[points_i[i]], ldos_data[points_j[j]]
    +                )
                     similarity_array.append([descriptor_distance, ldos_distance])
     
             return np.array(similarity_array)
     
         @staticmethod
    -    def _calculate_acsd(descriptor_data, ldos_data, acsd_points,
    -                        descriptor_vectors_contain_xyz=True):
    +    def _calculate_acsd(
    +        descriptor_data,
    +        ldos_data,
    +        acsd_points,
    +        descriptor_vectors_contain_xyz=True,
    +    ):
             """
             Calculate the ACSD for given descriptor and LDOS data.
     
    @@ -675,35 +909,45 @@ 

    Source code for mala.network.acsd_analyzer

                 The average cosine similarity distance.
     
             """
    +
             def distance_between_points(x1, y1, x2, y2):
                 return np.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
     
    -        similarity_data = ACSDAnalyzer.\
    -            _calculate_cosine_similarities(descriptor_data, ldos_data,
    -                                           acsd_points,
    -                                           descriptor_vectors_contain_xyz=
    -                                           descriptor_vectors_contain_xyz)
    +        similarity_data = ACSDAnalyzer._calculate_cosine_similarities(
    +            descriptor_data,
    +            ldos_data,
    +            acsd_points,
    +            descriptor_vectors_contain_xyz=descriptor_vectors_contain_xyz,
    +        )
             data_size = np.shape(similarity_data)[0]
             distances = []
             for i in range(0, data_size):
    -            distances.append(distance_between_points(similarity_data[i, 0],
    -                                                     similarity_data[i, 1],
    -                                                     similarity_data[i, 0],
    -                                                     similarity_data[i, 0]))
    +            distances.append(
    +                distance_between_points(
    +                    similarity_data[i, 0],
    +                    similarity_data[i, 1],
    +                    similarity_data[i, 0],
    +                    similarity_data[i, 0],
    +                )
    +            )
             return np.mean(distances)
     
         @staticmethod
         def __calc_cosine_similarity(vector1, vector2, norm=2):
             if np.shape(vector1)[0] != np.shape(vector2)[0]:
    -            raise Exception("Cannot calculate similarity between vectors "
    -                            "of different dimenstions.")
    +            raise Exception(
    +                "Cannot calculate similarity between vectors "
    +                "of different dimenstions."
    +            )
             if np.shape(vector1)[0] == 1:
    -            return np.min([vector1[0], vector2[0]]) / \
    -                   np.max([vector1[0], vector2[0]])
    +            return np.min([vector1[0], vector2[0]]) / np.max(
    +                [vector1[0], vector2[0]]
    +            )
             else:
    -            return np.dot(vector1, vector2) / \
    -                   (np.linalg.norm(vector1, ord=norm) *
    -                    np.linalg.norm(vector2, ord=norm))
    + return np.dot(vector1, vector2) / ( + np.linalg.norm(vector1, ord=norm) + * np.linalg.norm(vector2, ord=norm) + )
    diff --git a/_modules/mala/network/hyper_opt.html b/_modules/mala/network/hyper_opt.html index b534486e6..8f1dca0e6 100644 --- a/_modules/mala/network/hyper_opt.html +++ b/_modules/mala/network/hyper_opt.html @@ -75,6 +75,7 @@

    Source code for mala.network.hyper_opt

     """Base class for all hyperparameter optimizers."""
    +
     from abc import abstractmethod, ABC
     import os
     
    @@ -122,16 +123,20 @@ 

    Source code for mala.network.hyper_opt

             if cls == HyperOpt:
                 if params.hyperparameters.hyper_opt_method == "optuna":
                     from mala.network.hyper_opt_optuna import HyperOptOptuna
    -                hoptimizer = super(HyperOpt, HyperOptOptuna).\
    -                    __new__(HyperOptOptuna)
    +
    +                hoptimizer = super(HyperOpt, HyperOptOptuna).__new__(
    +                    HyperOptOptuna
    +                )
                 if params.hyperparameters.hyper_opt_method == "oat":
                     from mala.network.hyper_opt_oat import HyperOptOAT
    -                hoptimizer = super(HyperOpt, HyperOptOAT).\
    -                    __new__(HyperOptOAT)
    +
    +                hoptimizer = super(HyperOpt, HyperOptOAT).__new__(HyperOptOAT)
                 if params.hyperparameters.hyper_opt_method == "naswot":
                     from mala.network.hyper_opt_naswot import HyperOptNASWOT
    -                hoptimizer = super(HyperOpt, HyperOptNASWOT).\
    -                    __new__(HyperOptNASWOT)
    +
    +                hoptimizer = super(HyperOpt, HyperOptNASWOT).__new__(
    +                    HyperOptNASWOT
    +                )
     
                 if hoptimizer is None:
                     raise Exception("Unknown hyperparameter optimizer requested.")
    @@ -140,15 +145,17 @@ 

    Source code for mala.network.hyper_opt

     
             return hoptimizer
     
    -    def __init__(self, params: Parameters, data=None,
    -                 use_pkl_checkpoints=False):
    +    def __init__(
    +        self, params: Parameters, data=None, use_pkl_checkpoints=False
    +    ):
             self.params: Parameters = params
             self.data_handler = data
             self.objective = ObjectiveBase(self.params, self.data_handler)
             self.use_pkl_checkpoints = use_pkl_checkpoints
     
    -
    [docs] def add_hyperparameter(self, opttype="float", name="", low=0, high=0, - choices=None): +
    [docs] def add_hyperparameter( + self, opttype="float", name="", low=0, high=0, choices=None + ): """ Add a hyperparameter to the current investigation. @@ -181,15 +188,16 @@

    Source code for mala.network.hyper_opt

             choices :
                 List of possible choices (for categorical parameter).
             """
    -        self.params.\
    -            hyperparameters.hlist.append(
    -                Hyperparameter(self.params.hyperparameters.
    -                               hyper_opt_method,
    -                               opttype=opttype,
    -                               name=name,
    -                               low=low,
    -                               high=high,
    -                               choices=choices))
    + self.params.hyperparameters.hlist.append( + Hyperparameter( + self.params.hyperparameters.hyper_opt_method, + opttype=opttype, + name=name, + low=low, + high=high, + choices=choices, + ) + )
    [docs] def clear_hyperparameters(self): """Clear the list of hyperparameters that are to be investigated.""" @@ -225,22 +233,26 @@

    Source code for mala.network.hyper_opt

     
         def _save_params_and_scaler(self):
             # Saving the Scalers is straight forward.
    -        iscaler_name = self.params.hyperparameters.checkpoint_name \
    -            + "_iscaler.pkl"
    -        oscaler_name = self.params.hyperparameters.checkpoint_name \
    -            + "_oscaler.pkl"
    +        iscaler_name = (
    +            self.params.hyperparameters.checkpoint_name + "_iscaler.pkl"
    +        )
    +        oscaler_name = (
    +            self.params.hyperparameters.checkpoint_name + "_oscaler.pkl"
    +        )
             self.data_handler.input_data_scaler.save(iscaler_name)
             self.data_handler.output_data_scaler.save(oscaler_name)
     
             # For the parameters we have to make sure we choose the correct
             # format.
             if self.use_pkl_checkpoints:
    -            param_name = self.params.hyperparameters.checkpoint_name \
    -                         + "_params.pkl"
    +            param_name = (
    +                self.params.hyperparameters.checkpoint_name + "_params.pkl"
    +            )
                 self.params.save_as_pickle(param_name)
             else:
    -            param_name = self.params.hyperparameters.checkpoint_name \
    -                         + "_params.json"
    +            param_name = (
    +                self.params.hyperparameters.checkpoint_name + "_params.json"
    +            )
                 self.params.save_as_json(param_name)
     
     
    [docs] @classmethod @@ -271,12 +283,14 @@

    Source code for mala.network.hyper_opt

             else:
                 param_name = checkpoint_name + "_params.json"
     
    -        return all(map(os.path.isfile, [iscaler_name, oscaler_name,
    -                                        param_name]))
    + return all( + map(os.path.isfile, [iscaler_name, oscaler_name, param_name]) + )
    @classmethod - def _resume_checkpoint(cls, checkpoint_name, no_data=False, - use_pkl_checkpoints=False): + def _resume_checkpoint( + cls, checkpoint_name, no_data=False, use_pkl_checkpoints=False + ): """ Prepare resumption of hyperparameter optimization from a checkpoint. @@ -304,8 +318,10 @@

    Source code for mala.network.hyper_opt

             new_hyperopt : HyperOptOptuna
                 The hyperparameter optimizer reconstructed from the checkpoint.
             """
    -        printout("Loading hyperparameter optimization from checkpoint.",
    -                 min_verbosity=0)
    +        printout(
    +            "Loading hyperparameter optimization from checkpoint.",
    +            min_verbosity=0,
    +        )
             # The names are based upon the checkpoint name.
             iscaler_name = checkpoint_name + "_iscaler.pkl"
             oscaler_name = checkpoint_name + "_oscaler.pkl"
    @@ -325,10 +341,12 @@ 

    Source code for mala.network.hyper_opt

             # Create a new data handler and prepare the data.
             if no_data is True:
                 loaded_params.data.use_lazy_loading = True
    -        new_datahandler = DataHandler(loaded_params,
    -                                      input_data_scaler=loaded_iscaler,
    -                                      output_data_scaler=loaded_oscaler,
    -                                      clear_data=False)
    +        new_datahandler = DataHandler(
    +            loaded_params,
    +            input_data_scaler=loaded_iscaler,
    +            output_data_scaler=loaded_oscaler,
    +            clear_data=False,
    +        )
             new_datahandler.prepare_data(reparametrize_scaler=False)
     
             return loaded_params, new_datahandler, optimizer_name
    diff --git a/_modules/mala/network/hyper_opt_naswot.html b/_modules/mala/network/hyper_opt_naswot.html index 44ece5295..49fc7f05b 100644 --- a/_modules/mala/network/hyper_opt_naswot.html +++ b/_modules/mala/network/hyper_opt_naswot.html @@ -75,13 +75,19 @@

    Source code for mala.network.hyper_opt_naswot

     """Hyperparameter optimizer working without training."""
    +
     import itertools
     
     import optuna
     import numpy as np
     
    -from mala.common.parallelizer import printout, get_rank, get_size, get_comm, \
    -    barrier
    +from mala.common.parallelizer import (
    +    printout,
    +    get_rank,
    +    get_size,
    +    get_comm,
    +    barrier,
    +)
     from mala.network.hyper_opt import HyperOpt
     from mala.network.objective_naswot import ObjectiveNASWOT
     
    @@ -107,11 +113,14 @@ 

    Source code for mala.network.hyper_opt_naswot

    self.trial_losses = None self.best_trial = None self.trial_list = None - self.ignored_hyperparameters = ["learning_rate", "trainingtype", - "mini_batch_size", - "early_stopping_epochs", - "learning_rate_patience", - "learning_rate_decay"] + self.ignored_hyperparameters = [ + "learning_rate", + "trainingtype", + "mini_batch_size", + "early_stopping_epochs", + "learning_rate_patience", + "learning_rate_decay", + ] # For parallelization. self.first_trial = None @@ -134,18 +143,23 @@

    Source code for mala.network.hyper_opt_naswot

    # This check ensures that e.g. optuna results can be used. for idx, par in enumerate(self.params.hyperparameters.hlist): if par.name == "mini_batch_size": - printout("Removing mini batch size from hyperparameter list, " - "because NASWOT is used.", min_verbosity=0) + printout( + "Removing mini batch size from hyperparameter list, " + "because NASWOT is used.", + min_verbosity=0, + ) self.params.hyperparameters.hlist.pop(idx) # Ideally, this type of HO is called with a list of trials for which # the parameter has to be identified. self.trial_list = trial_list if self.trial_list is None: - printout("No trial list provided, one will be created using all " - "possible permutations of hyperparameters. " - "The following hyperparameters will be ignored:", - min_verbosity=0) + printout( + "No trial list provided, one will be created using all " + "possible permutations of hyperparameters. " + "The following hyperparameters will be ignored:", + min_verbosity=0, + ) printout(self.ignored_hyperparameters) # Please note for the parallel case: The trial list returned @@ -153,52 +167,72 @@

    Source code for mala.network.hyper_opt_naswot

    self.trial_list = self.__all_combinations() if self.params.use_mpi: - trials_per_rank = int(np.floor((len(self.trial_list) / - get_size()))) - self.first_trial = get_rank()*trials_per_rank - self.last_trial = (get_rank()+1)*trials_per_rank - if get_size() == get_rank()+1: + trials_per_rank = int( + np.floor((len(self.trial_list) / get_size())) + ) + self.first_trial = get_rank() * trials_per_rank + self.last_trial = (get_rank() + 1) * trials_per_rank + if get_size() == get_rank() + 1: trials_per_rank += len(self.trial_list) % get_size() self.last_trial += len(self.trial_list) % get_size() # We currently do not support checkpointing in parallel mode # for performance reasons. if self.params.hyperparameters.checkpoints_each_trial != 0: - printout("Checkpointing currently not supported for parallel " - "NASWOT runs, deactivating checkpointing function.") + printout( + "Checkpointing currently not supported for parallel " + "NASWOT runs, deactivating checkpointing function." + ) self.params.hyperparameters.checkpoints_each_trial = 0 else: self.first_trial = 0 self.last_trial = len(self.trial_list) # TODO: For now. Needs some refinements later. - if isinstance(self.trial_list[0], optuna.trial.FrozenTrial) or \ - isinstance(self.trial_list[0], optuna.trial.FixedTrial): + if isinstance( + self.trial_list[0], optuna.trial.FrozenTrial + ) or isinstance(self.trial_list[0], optuna.trial.FixedTrial): trial_type = "optuna" else: trial_type = "oat" - self.objective = ObjectiveNASWOT(self.params, self.data_handler, - trial_type) - printout("Starting NASWOT hyperparameter optimization,", - len(self.trial_list), "trials will be performed.", - min_verbosity=0) + self.objective = ObjectiveNASWOT( + self.params, self.data_handler, trial_type + ) + printout( + "Starting NASWOT hyperparameter optimization,", + len(self.trial_list), + "trials will be performed.", + min_verbosity=0, + ) self.trial_losses = [] - for idx, row in enumerate(self.trial_list[self.first_trial: - self.last_trial]): + for idx, row in enumerate( + self.trial_list[self.first_trial : self.last_trial] + ): trial_loss = self.objective(row) self.trial_losses.append(trial_loss) # Output diagnostic information. if self.params.use_mpi: - print("Trial number", idx+self.first_trial, - "finished with:", self.trial_losses[idx]) + print( + "Trial number", + idx + self.first_trial, + "finished with:", + self.trial_losses[idx], + ) else: best_trial = self.get_best_trial_results() - printout("Trial number", idx, - "finished with:", self.trial_losses[idx], - ", best is trial", best_trial[0], - "with", best_trial[1], min_verbosity=0) + printout( + "Trial number", + idx, + "finished with:", + self.trial_losses[idx], + ", best is trial", + best_trial[0], + "with", + best_trial[1], + min_verbosity=0, + ) barrier() @@ -209,13 +243,18 @@

    Source code for mala.network.hyper_opt_naswot

    """Get the best trial out of the list, including the value.""" if self.params.use_mpi: comm = get_comm() - local_result = \ - np.array([float(np.argmax(self.trial_losses) + - self.first_trial), np.max(self.trial_losses)]) + local_result = np.array( + [ + float(np.argmax(self.trial_losses) + self.first_trial), + np.max(self.trial_losses), + ] + ) all_results = comm.allgather(local_result) max_on_node = np.argmax(np.array(all_results)[:, 1]) - return [int(all_results[max_on_node][0]), - all_results[max_on_node][1]] + return [ + int(all_results[max_on_node][0]), + all_results[max_on_node][1], + ] else: return [np.argmax(self.trial_losses), np.max(self.trial_losses)]
    @@ -229,9 +268,12 @@

    Source code for mala.network.hyper_opt_naswot

    # Getting the best trial based on the test errors if self.params.use_mpi: comm = get_comm() - local_result = \ - np.array([float(np.argmax(self.trial_losses) + - self.first_trial), np.max(self.trial_losses)]) + local_result = np.array( + [ + float(np.argmax(self.trial_losses) + self.first_trial), + np.max(self.trial_losses), + ] + ) all_results = comm.allgather(local_result) max_on_node = np.argmax(np.array(all_results)[:, 1]) idx = int(all_results[max_on_node][0]) @@ -256,16 +298,18 @@

    Source code for mala.network.hyper_opt_naswot

    all_hyperparameters_choices.append(par.choices) # Calculate all possible combinations. - all_combinations = \ - list(itertools.product(*all_hyperparameters_choices)) + all_combinations = list( + itertools.product(*all_hyperparameters_choices) + ) # Now we use these combination to fill a list of FixedTrials. trial_list = [] for combination in all_combinations: params_dict = {} for idx, value in enumerate(combination): - params_dict[self.params.hyperparameters.hlist[idx].name] = \ + params_dict[self.params.hyperparameters.hlist[idx].name] = ( value + ) new_trial = optuna.trial.FixedTrial(params_dict) trial_list.append(new_trial) diff --git a/_modules/mala/network/hyper_opt_oat.html b/_modules/mala/network/hyper_opt_oat.html index d3a6a2387..cca093c35 100644 --- a/_modules/mala/network/hyper_opt_oat.html +++ b/_modules/mala/network/hyper_opt_oat.html @@ -75,12 +75,13 @@

    Source code for mala.network.hyper_opt_oat

     """Hyperparameter optimizer using orthogonal array tuning."""
    +
     from bisect import bisect
     import itertools
    -import os
     import pickle
     
     import numpy as np
    +
     try:
         import oapackage as oa
     except ModuleNotFoundError:
    @@ -110,9 +111,9 @@ 

    Source code for mala.network.hyper_opt_oat

         """
     
         def __init__(self, params, data, use_pkl_checkpoints=False):
    -        super(HyperOptOAT, self).__init__(params, data,
    -                                          use_pkl_checkpoints=
    -                                          use_pkl_checkpoints)
    +        super(HyperOptOAT, self).__init__(
    +            params, data, use_pkl_checkpoints=use_pkl_checkpoints
    +        )
             self.objective = None
             self.optimal_params = None
             self.checkpoint_counter = 0
    @@ -130,8 +131,9 @@ 

    Source code for mala.network.hyper_opt_oat

             self.current_trial = 0
             self.trial_losses = None
     
    -
    [docs] def add_hyperparameter(self, opttype="categorical", - name="", choices=None, **kwargs): +
    [docs] def add_hyperparameter( + self, opttype="categorical", name="", choices=None, **kwargs + ): """ Add hyperparameter. @@ -146,15 +148,17 @@

    Source code for mala.network.hyper_opt_oat

             """
             if not self.sorted_num_choices:  # if empty
                 super(HyperOptOAT, self).add_hyperparameter(
    -                opttype=opttype, name=name, choices=choices)
    +                opttype=opttype, name=name, choices=choices
    +            )
                 self.sorted_num_choices.append(len(choices))
     
             else:
                 index = bisect(self.sorted_num_choices, len(choices))
                 self.sorted_num_choices.insert(index, len(choices))
                 self.params.hyperparameters.hlist.insert(
    -                index, HyperparameterOAT(opttype=opttype, name=name,
    -                                         choices=choices))
    + index, + HyperparameterOAT(opttype=opttype, name=name, choices=choices), + )
    [docs] def perform_study(self): """ @@ -166,11 +170,15 @@

    Source code for mala.network.hyper_opt_oat

                 self.__OA = self.get_orthogonal_array()
             print(self.__OA)
             if self.trial_losses is None:
    -            self.trial_losses = np.zeros(self.__OA.shape[0])+float("inf")
    +            self.trial_losses = np.zeros(self.__OA.shape[0]) + float("inf")
     
    -        printout("Performing",self.N_runs,
    -                 "trials, starting with trial number", self.current_trial,
    -                 min_verbosity=0)
    +        printout(
    +            "Performing",
    +            self.N_runs,
    +            "trials, starting with trial number",
    +            self.current_trial,
    +            min_verbosity=0,
    +        )
     
             # The parameters could have changed.
             self.objective = ObjectiveBase(self.params, self.data_handler)
    @@ -182,10 +190,17 @@ 

    Source code for mala.network.hyper_opt_oat

     
                 # Output diagnostic information.
                 best_trial = self.get_best_trial_results()
    -            printout("Trial number", self.current_trial,
    -                     "finished with:", self.trial_losses[self.current_trial],
    -                     ", best is trial", best_trial[0],
    -                     "with", best_trial[1], min_verbosity=0)
    +            printout(
    +                "Trial number",
    +                self.current_trial,
    +                "finished with:",
    +                self.trial_losses[self.current_trial],
    +                ", best is trial",
    +                best_trial[0],
    +                "with",
    +                best_trial[1],
    +                min_verbosity=0,
    +            )
                 self.current_trial += 1
                 self.__create_checkpointing(row)
     
    @@ -200,22 +215,31 @@ 

    Source code for mala.network.hyper_opt_oat

             """
             printout("Performing Range Analysis.", min_verbosity=1)
     
    -        def indices(idx, val): return np.where(
    -            self.__OA[:, idx] == val)[0]
    -        R = [[self.trial_losses[indices(idx, l)].sum() for l in range(levels)]
    -             for (idx, levels) in enumerate(self.factor_levels)]
    +        def indices(idx, val):
    +            return np.where(self.__OA[:, idx] == val)[0]
     
    -        A = [[i/len(j) for i in j] for j in R]
    +        R = [
    +            [self.trial_losses[indices(idx, l)].sum() for l in range(levels)]
    +            for (idx, levels) in enumerate(self.factor_levels)
    +        ]
    +
    +        A = [[i / len(j) for i in j] for j in R]
     
             # Taking loss as objective to minimise
             self.optimal_params = np.array([i.index(min(i)) for i in A])
    -        self.importance = np.argsort([max(i)-min(i) for i in A])
    + self.importance = np.argsort([max(i) - min(i) for i in A])
    [docs] def show_order_of_importance(self): """Print the order of importance of the hyperparameters.""" printout("Order of Importance: ", min_verbosity=0) printout( - *[self.params.hyperparameters.hlist[idx].name for idx in self.importance], sep=" < ", min_verbosity=0)
    + *[ + self.params.hyperparameters.hlist[idx].name + for idx in self.importance + ], + sep=" < ", + min_verbosity=0 + )
    [docs] def set_optimal_parameters(self): """ @@ -236,8 +260,9 @@

    Source code for mala.network.hyper_opt_oat

             print("Sorted factor levels:", self.sorted_num_choices)
             self.n_factors = len(self.params.hyperparameters.hlist)
     
    -        self.factor_levels = [par.num_choices for par in self.params.
    -                              hyperparameters.hlist]
    +        self.factor_levels = [
    +            par.num_choices for par in self.params.hyperparameters.hlist
    +        ]
     
             self.strength = 2
             arraylist = None
    @@ -251,12 +276,12 @@ 

    Source code for mala.network.hyper_opt_oat

             # holds. x is unknown, but we can be confident that it should be
             # small. So simply trying 3 time should be fine for now.
             for i in range(1, 4):
    -            self.N_runs = self.number_of_runs()*i
    +            self.N_runs = self.number_of_runs() * i
                 print("Trying run size:", self.N_runs)
                 print("Generating Suitable Orthogonal Array.")
    -            arrayclass = oa.arraydata_t(self.factor_levels, self.N_runs,
    -                                        self.strength,
    -                                        self.n_factors)
    +            arrayclass = oa.arraydata_t(
    +                self.factor_levels, self.N_runs, self.strength, self.n_factors
    +            )
                 arraylist = [arrayclass.create_root()]
     
                 # extending the orthogonal array
    @@ -264,9 +289,9 @@ 

    Source code for mala.network.hyper_opt_oat

                 options.setAlgorithmAuto(arrayclass)
     
                 for _ in range(self.strength + 1, self.n_factors + 1):
    -                arraylist_extensions = oa.extend_arraylist(arraylist,
    -                                                           arrayclass,
    -                                                           options)
    +                arraylist_extensions = oa.extend_arraylist(
    +                    arraylist, arrayclass, options
    +                )
                     dd = np.array([a.Defficiency() for a in arraylist_extensions])
                     idxs = np.argsort(dd)
                     arraylist = [arraylist_extensions[ii] for ii in idxs]
    @@ -274,9 +299,11 @@ 

    Source code for mala.network.hyper_opt_oat

                     break
     
             if not arraylist:
    -            raise Exception("No orthogonal array exists with such a "
    -                            "parameter combination.")
    -            
    +            raise Exception(
    +                "No orthogonal array exists with such a "
    +                "parameter combination."
    +            )
    +
             else:
                 return np.unique(np.array(arraylist[0]), axis=0)
    @@ -288,8 +315,10 @@

    Source code for mala.network.hyper_opt_oat

             See also here:
             https://oapackage.readthedocs.io/en/latest/examples/example_minimal_number_of_runs_oa.html
             """
    -        runs = [np.prod(tt) for tt in itertools.combinations(
    -            self.factor_levels, self.strength)]
    +        runs = [
    +            np.prod(tt)
    +            for tt in itertools.combinations(self.factor_levels, self.strength)
    +        ]
     
             N = np.lcm.reduce(runs)
             return int(N)
    @@ -301,8 +330,9 @@

    Source code for mala.network.hyper_opt_oat

             elif self.params.hyperparameters.direction == "maximize":
                 return [np.argmax(self.trial_losses), np.max(self.trial_losses)]
             else:
    -            raise Exception("Invalid direction for hyperparameter optimization"
    -                            "selected.")
    + raise Exception( + "Invalid direction for hyperparameter optimization selected." + )
    def __check_factor_levels(self): """Check that the factors are in a decreasing order.""" @@ -315,12 +345,15 @@

    Source code for mala.network.hyper_opt_oat

                 # Factors are in decreasing order, we don't have to do anything.
                 pass
             else:
    -            raise Exception("Please use hyperparameters in increasing or "
    -                            "decreasing order of number of choices")
    +            raise Exception(
    +                "Please use hyperparameters in increasing or "
    +                "decreasing order of number of choices"
    +            )
     
     
    [docs] @classmethod - def resume_checkpoint(cls, checkpoint_name, no_data=False, - use_pkl_checkpoints=False): + def resume_checkpoint( + cls, checkpoint_name, no_data=False, use_pkl_checkpoints=False + ): """ Prepare resumption of hyperparameter optimization from a checkpoint. @@ -351,12 +384,16 @@

    Source code for mala.network.hyper_opt_oat

             new_hyperopt : HyperOptOAT
                 The hyperparameter optimizer reconstructed from the checkpoint.
             """
    -        loaded_params, new_datahandler, optimizer_name = \
    -            cls._resume_checkpoint(checkpoint_name, no_data=no_data,
    -                                   use_pkl_checkpoints=use_pkl_checkpoints)
    -        new_hyperopt = HyperOptOAT.load_from_file(loaded_params,
    -                                                  optimizer_name,
    -                                                  new_datahandler)
    +        loaded_params, new_datahandler, optimizer_name = (
    +            cls._resume_checkpoint(
    +                checkpoint_name,
    +                no_data=no_data,
    +                use_pkl_checkpoints=use_pkl_checkpoints,
    +            )
    +        )
    +        new_hyperopt = HyperOptOAT.load_from_file(
    +            loaded_params, optimizer_name, new_datahandler
    +        )
     
             return loaded_params, new_datahandler, new_hyperopt
    @@ -384,19 +421,21 @@

    Source code for mala.network.hyper_opt_oat

                 The hyperparameter optimizer that was loaded from the file.
             """
             # First, load the checkpoint.
    -        with open(file_path, 'rb') as handle:
    +        with open(file_path, "rb") as handle:
                 loaded_tracking_data = pickle.load(handle)
                 loaded_hyperopt = HyperOptOAT(params, data)
    -            loaded_hyperopt.sorted_num_choices = \
    -                loaded_tracking_data["sorted_num_choices"]
    -            loaded_hyperopt.current_trial = \
    -                loaded_tracking_data["current_trial"]
    -            loaded_hyperopt.trial_losses = \
    -                loaded_tracking_data["trial_losses"]
    +            loaded_hyperopt.sorted_num_choices = loaded_tracking_data[
    +                "sorted_num_choices"
    +            ]
    +            loaded_hyperopt.current_trial = loaded_tracking_data[
    +                "current_trial"
    +            ]
    +            loaded_hyperopt.trial_losses = loaded_tracking_data["trial_losses"]
                 loaded_hyperopt.importance = loaded_tracking_data["importance"]
                 loaded_hyperopt.n_factors = loaded_tracking_data["n_factors"]
    -            loaded_hyperopt.factor_levels = \
    -                loaded_tracking_data["factor_levels"]
    +            loaded_hyperopt.factor_levels = loaded_tracking_data[
    +                "factor_levels"
    +            ]
                 loaded_hyperopt.strength = loaded_tracking_data["strength"]
                 loaded_hyperopt.N_runs = loaded_tracking_data["N_runs"]
                 loaded_hyperopt.__OA = loaded_tracking_data["OA"]
    @@ -408,19 +447,31 @@ 

    Source code for mala.network.hyper_opt_oat

             self.checkpoint_counter += 1
             need_to_checkpoint = False
     
    -        if self.checkpoint_counter >= self.params.hyperparameters.\
    -                checkpoints_each_trial and self.params.hyperparameters.\
    -                checkpoints_each_trial > 0:
    +        if (
    +            self.checkpoint_counter
    +            >= self.params.hyperparameters.checkpoints_each_trial
    +            and self.params.hyperparameters.checkpoints_each_trial > 0
    +        ):
                 need_to_checkpoint = True
    -            printout(str(self.params.hyperparameters.
    -                     checkpoints_each_trial)+" trials have passed, creating a "
    -                                             "checkpoint for hyperparameter "
    -                                             "optimization.", min_verbosity=1)
    -        if self.params.hyperparameters.checkpoints_each_trial < 0 and \
    -                np.argmin(self.trial_losses) == self.current_trial-1:
    +            printout(
    +                str(self.params.hyperparameters.checkpoints_each_trial)
    +                + " trials have passed, creating a "
    +                "checkpoint for hyperparameter "
    +                "optimization.",
    +                min_verbosity=1,
    +            )
    +        if (
    +            self.params.hyperparameters.checkpoints_each_trial < 0
    +            and np.argmin(self.trial_losses) == self.current_trial - 1
    +        ):
                 need_to_checkpoint = True
    -            printout("Best trial is "+str(self.current_trial-1)+", creating a "
    -                     "checkpoint for it.", min_verbosity=1)
    +            printout(
    +                "Best trial is "
    +                + str(self.current_trial - 1)
    +                + ", creating a "
    +                "checkpoint for it.",
    +                min_verbosity=1,
    +            )
     
             if need_to_checkpoint is True:
                 # We need to create a checkpoint!
    @@ -436,19 +487,23 @@ 

    Source code for mala.network.hyper_opt_oat

                 #         return
                 # The study only has to be saved if the no RDB storage is used.
                 if self.params.hyperparameters.rdb_storage is None:
    -                hyperopt_name = self.params.hyperparameters.checkpoint_name \
    -                            + "_hyperopt.pth"
    -
    -                study = {"sorted_num_choices": self.sorted_num_choices,
    -                         "current_trial": self.current_trial,
    -                         "trial_losses": self.trial_losses,
    -                         "importance": self.importance,
    -                         "n_factors": self.n_factors,
    -                         "factor_levels": self.factor_levels,
    -                         "strength": self.strength,
    -                         "N_runs": self.N_runs,
    -                         "OA": self.__OA}
    -                with open(hyperopt_name, 'wb') as handle:
    +                hyperopt_name = (
    +                    self.params.hyperparameters.checkpoint_name
    +                    + "_hyperopt.pth"
    +                )
    +
    +                study = {
    +                    "sorted_num_choices": self.sorted_num_choices,
    +                    "current_trial": self.current_trial,
    +                    "trial_losses": self.trial_losses,
    +                    "importance": self.importance,
    +                    "n_factors": self.n_factors,
    +                    "factor_levels": self.factor_levels,
    +                    "strength": self.strength,
    +                    "N_runs": self.N_runs,
    +                    "OA": self.__OA,
    +                }
    +                with open(hyperopt_name, "wb") as handle:
                         pickle.dump(study, handle, protocol=4)
    diff --git a/_modules/mala/network/hyper_opt_optuna.html b/_modules/mala/network/hyper_opt_optuna.html index 272a77f47..c87ed564e 100644 --- a/_modules/mala/network/hyper_opt_optuna.html +++ b/_modules/mala/network/hyper_opt_optuna.html @@ -75,6 +75,7 @@

    Source code for mala.network.hyper_opt_optuna

     """Hyperparameter optimizer using optuna."""
    +
     import pickle
     
     import optuna
    @@ -103,16 +104,17 @@ 

    Source code for mala.network.hyper_opt_optuna

    """ def __init__(self, params, data, use_pkl_checkpoints=False): - super(HyperOptOptuna, self).__init__(params, data, - use_pkl_checkpoints= - use_pkl_checkpoints) + super(HyperOptOptuna, self).__init__( + params, data, use_pkl_checkpoints=use_pkl_checkpoints + ) self.params = params # Make the sample behave in a reproducible way, if so specified by # the user. - sampler = optuna.samplers.TPESampler(seed=params.manual_seed, - multivariate=params. - hyperparameters.use_multivariate) + sampler = optuna.samplers.TPESampler( + seed=params.manual_seed, + multivariate=params.hyperparameters.use_multivariate, + ) # See if the user specified a pruner. pruner = None @@ -123,43 +125,50 @@

    Source code for mala.network.hyper_opt_optuna

    if self.params.hyperparameters.number_training_per_trial > 1: pruner = MultiTrainingPruner(self.params) else: - printout("MultiTrainingPruner requested, but only one " - "training" - "per trial specified; Skipping pruner creation.") + printout( + "MultiTrainingPruner requested, but only one " + "training" + "per trial specified; Skipping pruner creation." + ) else: raise Exception("Invalid pruner type selected.") # Create the study. if self.params.hyperparameters.rdb_storage is None: - self.study = optuna.\ - create_study(direction=self.params.hyperparameters.direction, - sampler=sampler, - study_name=self.params.hyperparameters. - study_name, - pruner=pruner) + self.study = optuna.create_study( + direction=self.params.hyperparameters.direction, + sampler=sampler, + study_name=self.params.hyperparameters.study_name, + pruner=pruner, + ) else: if self.params.hyperparameters.study_name is None: - raise Exception("If RDB storage is used, a name for the study " - "has to be provided.") + raise Exception( + "If RDB storage is used, a name for the study " + "has to be provided." + ) if "sqlite" in self.params.hyperparameters.rdb_storage: - engine_kwargs = {"connect_args": {"timeout": self.params. - hyperparameters.sqlite_timeout}} + engine_kwargs = { + "connect_args": { + "timeout": self.params.hyperparameters.sqlite_timeout + } + } else: engine_kwargs = None rdb_storage = optuna.storages.RDBStorage( - url=self.params.hyperparameters.rdb_storage, - heartbeat_interval=self.params.hyperparameters. - rdb_storage_heartbeat, - engine_kwargs=engine_kwargs) - - self.study = optuna.\ - create_study(direction=self.params.hyperparameters.direction, - sampler=sampler, - study_name=self.params.hyperparameters. - study_name, - storage=rdb_storage, - load_if_exists=True, - pruner=pruner) + url=self.params.hyperparameters.rdb_storage, + heartbeat_interval=self.params.hyperparameters.rdb_storage_heartbeat, + engine_kwargs=engine_kwargs, + ) + + self.study = optuna.create_study( + direction=self.params.hyperparameters.direction, + sampler=sampler, + study_name=self.params.hyperparameters.study_name, + storage=rdb_storage, + load_if_exists=True, + pruner=pruner, + ) self.checkpoint_counter = 0
    [docs] def perform_study(self): @@ -177,9 +186,9 @@

    Source code for mala.network.hyper_opt_optuna

    if self.params.hyperparameters.checkpoints_each_trial != 0: callback_list.append(self.__create_checkpointing) - self.study.optimize(self.objective, - n_trials=None, - callbacks=callback_list) + self.study.optimize( + self.objective, n_trials=None, callbacks=callback_list + ) # Return the best lost value we could achieve. return self.study.best_value
    @@ -203,8 +212,9 @@

    Source code for mala.network.hyper_opt_optuna

    last_trials: list A list of optuna.FrozenTrial objects. """ - return self.study.get_trials(states=(optuna.trial. - TrialState.COMPLETE, ))
    + return self.study.get_trials( + states=(optuna.trial.TrialState.COMPLETE,) + )
    [docs] @staticmethod def requeue_zombie_trials(study_name, rdb_storage): @@ -230,24 +240,32 @@

    Source code for mala.network.hyper_opt_optuna

    study_name : string Name of the study in the storage. Same as the checkpoint name. """ - study_to_clean = optuna.load_study(study_name=study_name, - storage=rdb_storage) - parallel_warn("WARNING: Your about to clean/requeue a study." - " This operation should not be done to an already" - " running study.") + study_to_clean = optuna.load_study( + study_name=study_name, storage=rdb_storage + ) + parallel_warn( + "WARNING: Your about to clean/requeue a study." + " This operation should not be done to an already" + " running study." + ) trials = study_to_clean.get_trials() cleaned_trials = [] for trial in trials: if trial.state == optuna.trial.TrialState.RUNNING: - study_to_clean._storage.set_trial_state(trial._trial_id, - optuna.trial. - TrialState.WAITING) + study_to_clean._storage.set_trial_state( + trial._trial_id, optuna.trial.TrialState.WAITING + ) cleaned_trials.append(trial.number) printout("Cleaned trials: ", cleaned_trials, min_verbosity=0)
    [docs] @classmethod - def resume_checkpoint(cls, checkpoint_name, alternative_storage_path=None, - no_data=False, use_pkl_checkpoints=False): + def resume_checkpoint( + cls, + checkpoint_name, + alternative_storage_path=None, + no_data=False, + use_pkl_checkpoints=False, + ): """ Prepare resumption of hyperparameter optimization from a checkpoint. @@ -284,15 +302,20 @@

    Source code for mala.network.hyper_opt_optuna

    new_hyperopt : HyperOptOptuna The hyperparameter optimizer reconstructed from the checkpoint. """ - loaded_params, new_datahandler, optimizer_name = \ - cls._resume_checkpoint(checkpoint_name, no_data=no_data, - use_pkl_checkpoints=use_pkl_checkpoints) + loaded_params, new_datahandler, optimizer_name = ( + cls._resume_checkpoint( + checkpoint_name, + no_data=no_data, + use_pkl_checkpoints=use_pkl_checkpoints, + ) + ) if alternative_storage_path is not None: - loaded_params.hyperparameters.rdb_storage = \ + loaded_params.hyperparameters.rdb_storage = ( alternative_storage_path - new_hyperopt = HyperOptOptuna.load_from_file(loaded_params, - optimizer_name, - new_datahandler) + ) + new_hyperopt = HyperOptOptuna.load_from_file( + loaded_params, optimizer_name, new_datahandler + ) return loaded_params, new_datahandler, new_hyperopt
    @@ -321,7 +344,7 @@

    Source code for mala.network.hyper_opt_optuna

    """ # First, load the checkpoint. if params.hyperparameters.rdb_storage is None: - with open(file_path, 'rb') as handle: + with open(file_path, "rb") as handle: loaded_study = pickle.load(handle) # Now, create the Trainer class with it. @@ -341,15 +364,22 @@

    Source code for mala.network.hyper_opt_optuna

    # then RUNNING trials might be Zombie trials. # See if self.params.hyperparameters.rdb_storage_heartbeat is None: - return len([t for t in study.trials if - t.state == optuna.trial. - TrialState.COMPLETE]) + return len( + [ + t + for t in study.trials + if t.state == optuna.trial.TrialState.COMPLETE + ] + ) else: - return len([t for t in study.trials if - t.state == optuna.trial. - TrialState.COMPLETE or - t.state == optuna.trial. - TrialState.RUNNING]) + return len( + [ + t + for t in study.trials + if t.state == optuna.trial.TrialState.COMPLETE + or t.state == optuna.trial.TrialState.RUNNING + ] + ) def __check_stopping(self, study, trial): """Check if this trial was already the maximum number of trials.""" @@ -368,16 +398,21 @@

    Source code for mala.network.hyper_opt_optuna

    # Only check if there are trials to be checked. if completed_trials > 0: - if self.params.hyperparameters.number_bad_trials_before_stopping is \ - not None and self.params.hyperparameters.\ - number_bad_trials_before_stopping > 0: - if trial.number - self.study.best_trial.number >= \ - self.params.hyperparameters.\ - number_bad_trials_before_stopping: - printout("No new best trial found in", - self.params.hyperparameters. - number_bad_trials_before_stopping, - "attempts, stopping the study.") + if ( + self.params.hyperparameters.number_bad_trials_before_stopping + is not None + and self.params.hyperparameters.number_bad_trials_before_stopping + > 0 + ): + if ( + trial.number - self.study.best_trial.number + >= self.params.hyperparameters.number_bad_trials_before_stopping + ): + printout( + "No new best trial found in", + self.params.hyperparameters.number_bad_trials_before_stopping, + "attempts, stopping the study.", + ) self.study.stop() def __create_checkpointing(self, study, trial): @@ -385,20 +420,30 @@

    Source code for mala.network.hyper_opt_optuna

    self.checkpoint_counter += 1 need_to_checkpoint = False - if self.checkpoint_counter >= self.params.hyperparameters.\ - checkpoints_each_trial and self.params.hyperparameters.\ - checkpoints_each_trial > 0: + if ( + self.checkpoint_counter + >= self.params.hyperparameters.checkpoints_each_trial + and self.params.hyperparameters.checkpoints_each_trial > 0 + ): need_to_checkpoint = True - printout(str(self.params.hyperparameters. - checkpoints_each_trial)+" trials have passed, creating a " - "checkpoint for hyperparameter " - "optimization.", min_verbosity=0) - if self.params.hyperparameters.checkpoints_each_trial < 0 and \ - self.__get_number_of_completed_trials(study) > 0: - if trial.number == study.best_trial.number: - need_to_checkpoint = True - printout("Best trial is "+str(trial.number)+", creating a " - "checkpoint for it.", min_verbosity=0) + printout( + str(self.params.hyperparameters.checkpoints_each_trial) + + " trials have passed, creating a " + "checkpoint for hyperparameter " + "optimization.", + min_verbosity=0, + ) + if ( + self.params.hyperparameters.checkpoints_each_trial < 0 + and self.__get_number_of_completed_trials(study) > 0 + ): + if trial.number == study.best_trial.number: + need_to_checkpoint = True + printout( + "Best trial is " + str(trial.number) + ", creating a " + "checkpoint for it.", + min_verbosity=0, + ) if need_to_checkpoint is True: # We need to create a checkpoint! @@ -414,9 +459,11 @@

    Source code for mala.network.hyper_opt_optuna

    # return # The study only has to be saved if the no RDB storage is used. if self.params.hyperparameters.rdb_storage is None: - hyperopt_name = self.params.hyperparameters.checkpoint_name \ - + "_hyperopt.pth" - with open(hyperopt_name, 'wb') as handle: + hyperopt_name = ( + self.params.hyperparameters.checkpoint_name + + "_hyperopt.pth" + ) + with open(hyperopt_name, "wb") as handle: pickle.dump(self.study, handle, protocol=4)
    diff --git a/_modules/mala/network/hyperparameter.html b/_modules/mala/network/hyperparameter.html index 0b9e596e3..f834801b0 100644 --- a/_modules/mala/network/hyperparameter.html +++ b/_modules/mala/network/hyperparameter.html @@ -75,6 +75,7 @@

    Source code for mala.network.hyperparameter

     """Interface function to get the correct type of hyperparameter."""
    +
     from mala.common.json_serializable import JSONSerializable
     
     
    @@ -125,8 +126,15 @@ 

    Source code for mala.network.hyperparameter

             Hyperparameter in desired format.
         """
     
    -    def __new__(cls, hotype=None, opttype="float", name="", low=0, high=0,
    -                choices=None):
    +    def __new__(
    +        cls,
    +        hotype=None,
    +        opttype="float",
    +        name="",
    +        low=0,
    +        high=0,
    +        choices=None,
    +    ):
             """
             Create a Hyperparameter instance.
     
    @@ -172,29 +180,50 @@ 

    Source code for mala.network.hyperparameter

             hparam = None
             if cls == Hyperparameter:
                 if hotype == "optuna":
    -                from mala.network.hyperparameter_optuna import \
    -                    HyperparameterOptuna
    -                hparam = HyperparameterOptuna(hotype=hotype,
    -                                              opttype=opttype, name=name,
    -                                              low=low,
    -                                              high=high, choices=choices)
    +                from mala.network.hyperparameter_optuna import (
    +                    HyperparameterOptuna,
    +                )
    +
    +                hparam = HyperparameterOptuna(
    +                    hotype=hotype,
    +                    opttype=opttype,
    +                    name=name,
    +                    low=low,
    +                    high=high,
    +                    choices=choices,
    +                )
                 if hotype == "naswot":
    -                from mala.network.hyperparameter_naswot import \
    -                    HyperparameterNASWOT
    -                hparam = HyperparameterNASWOT(hotype=hotype,
    -                                              opttype=opttype, name=name,
    -                                              low=low,
    -                                              high=high, choices=choices)
    +                from mala.network.hyperparameter_naswot import (
    +                    HyperparameterNASWOT,
    +                )
    +
    +                hparam = HyperparameterNASWOT(
    +                    hotype=hotype,
    +                    opttype=opttype,
    +                    name=name,
    +                    low=low,
    +                    high=high,
    +                    choices=choices,
    +                )
                 if hotype == "oat":
                     from mala.network.hyperparameter_oat import HyperparameterOAT
    -                hparam = HyperparameterOAT(hotype=hotype,
    -                                           opttype=opttype, name=name,
    -                                           choices=choices)
    +
    +                hparam = HyperparameterOAT(
    +                    hotype=hotype, opttype=opttype, name=name, choices=choices
    +                )
                 if hotype == "acsd":
    -                from mala.network.hyperparameter_acsd import HyperparameterACSD
    -                hparam = HyperparameterACSD(hotype=hotype,
    -                                            opttype=opttype, name=name,
    -                                            low=low, high=high, choices=choices)
    +                from mala.network.hyperparameter_acsd import (
    +                    HyperparameterACSD,
    +                )
    +
    +                hparam = HyperparameterACSD(
    +                    hotype=hotype,
    +                    opttype=opttype,
    +                    name=name,
    +                    low=low,
    +                    high=high,
    +                    choices=choices,
    +                )
     
                 if hparam is None:
                     raise Exception("Unsupported hyperparameter.")
    @@ -202,8 +231,15 @@ 

    Source code for mala.network.hyperparameter

                 hparam = super(Hyperparameter, cls).__new__(cls)
             return hparam
     
    -    def __init__(self, hotype=None, opttype="float", name="", low=0, high=0,
    -                 choices=None):
    +    def __init__(
    +        self,
    +        hotype=None,
    +        opttype="float",
    +        name="",
    +        low=0,
    +        high=0,
    +        choices=None,
    +    ):
             super(Hyperparameter, self).__init__()
             self.opttype = opttype
             self.name = name
    diff --git a/_modules/mala/network/hyperparameter_acsd.html b/_modules/mala/network/hyperparameter_acsd.html
    index b791794f2..949063f2e 100644
    --- a/_modules/mala/network/hyperparameter_acsd.html
    +++ b/_modules/mala/network/hyperparameter_acsd.html
    @@ -75,7 +75,6 @@
                  
       

    Source code for mala.network.hyperparameter_acsd

     """Hyperparameter to use with optuna."""
    -from optuna.trial import Trial
     
     from mala.network.hyperparameter import Hyperparameter
     
    @@ -112,12 +111,18 @@ 

    Source code for mala.network.hyperparameter_acsd

    List of possible choices (for categorical parameter). """ - def __init__(self, hotype=None, opttype="float", name="", low=0, high=0, choices=None): - super(HyperparameterACSD, self).__init__(opttype=opttype, - name=name, - low=low, - high=high, - choices=choices) + def __init__( + self, + hotype=None, + opttype="float", + name="", + low=0, + high=0, + choices=None, + ): + super(HyperparameterACSD, self).__init__( + opttype=opttype, name=name, low=low, high=high, choices=choices + ) # For now, only three types of hyperparameters are allowed: # Lists, floats and ints. diff --git a/_modules/mala/network/hyperparameter_naswot.html b/_modules/mala/network/hyperparameter_naswot.html index 19e4aa15f..b578e2aba 100644 --- a/_modules/mala/network/hyperparameter_naswot.html +++ b/_modules/mala/network/hyperparameter_naswot.html @@ -75,6 +75,7 @@

    Source code for mala.network.hyperparameter_naswot

     """Hyperparameter to use with optuna."""
    +
     from mala.network.hyperparameter_optuna import HyperparameterOptuna
     
     
    @@ -112,13 +113,18 @@ 

    Source code for mala.network.hyperparameter_naswot

    List of possible choices (for categorical parameter). """ - def __init__(self, hotype=None, opttype="categorical", name="", low=0, high=0, - choices=None): - super(HyperparameterNASWOT, self).__init__(opttype=opttype, - name=name, - low=low, - high=high, - choices=choices) + def __init__( + self, + hotype=None, + opttype="categorical", + name="", + low=0, + high=0, + choices=None, + ): + super(HyperparameterNASWOT, self).__init__( + opttype=opttype, name=name, low=low, high=high, choices=choices + ) # For NASWOT, only categoricals are allowed. if self.opttype != "categorical": diff --git a/_modules/mala/network/hyperparameter_oat.html b/_modules/mala/network/hyperparameter_oat.html index e6ce762ba..8e1c1c1ab 100644 --- a/_modules/mala/network/hyperparameter_oat.html +++ b/_modules/mala/network/hyperparameter_oat.html @@ -105,11 +105,18 @@

    Source code for mala.network.hyperparameter_oat

    < List of possible choices (for categorical parameter). """ - def __init__(self, hotype=None, opttype="categorical", name="", choices=[], - low=0, high=0): - super(HyperparameterOAT, self).__init__(opttype=opttype, - name=name, - choices=choices) + def __init__( + self, + hotype=None, + opttype="categorical", + name="", + choices=[], + low=0, + high=0, + ): + super(HyperparameterOAT, self).__init__( + opttype=opttype, name=name, choices=choices + ) if self.opttype != "categorical": raise Exception("Unsupported Hyperparameter type.") diff --git a/_modules/mala/network/hyperparameter_optuna.html b/_modules/mala/network/hyperparameter_optuna.html index c572d7274..5d75eec88 100644 --- a/_modules/mala/network/hyperparameter_optuna.html +++ b/_modules/mala/network/hyperparameter_optuna.html @@ -75,6 +75,7 @@

    Source code for mala.network.hyperparameter_optuna

     """Hyperparameter to use with optuna."""
    +
     from optuna.trial import Trial
     
     from mala.network.hyperparameter import Hyperparameter
    @@ -112,17 +113,26 @@ 

    Source code for mala.network.hyperparameter_optuna

    List of possible choices (for categorical parameter). """ - def __init__(self, hotype=None, opttype="float", name="", low=0, high=0, choices=None): - super(HyperparameterOptuna, self).__init__(opttype=opttype, - name=name, - low=low, - high=high, - choices=choices) + def __init__( + self, + hotype=None, + opttype="float", + name="", + low=0, + high=0, + choices=None, + ): + super(HyperparameterOptuna, self).__init__( + opttype=opttype, name=name, low=low, high=high, choices=choices + ) # For now, only three types of hyperparameters are allowed: # Lists, floats and ints. - if self.opttype != "float" and self.opttype != "int" and self.opttype \ - != "categorical": + if ( + self.opttype != "float" + and self.opttype != "int" + and self.opttype != "categorical" + ): raise Exception("Unsupported Hyperparameter type.")
    [docs] def get_parameter(self, trial: Trial): diff --git a/_modules/mala/network/multi_training_pruner.html b/_modules/mala/network/multi_training_pruner.html index 0a2de38e3..e5e499bff 100644 --- a/_modules/mala/network/multi_training_pruner.html +++ b/_modules/mala/network/multi_training_pruner.html @@ -75,6 +75,7 @@

    Source code for mala.network.multi_training_pruner

     """Prunes a trial when one of the trainings returns infinite band energy."""
    +
     import numpy as np
     import optuna
     from optuna.pruners import BasePruner
    @@ -103,11 +104,14 @@ 

    Source code for mala.network.multi_training_pruner

    if self._trial_type != "optuna": raise Exception("This pruner only works for optuna at the moment.") if self._params.hyperparameters.number_training_per_trial == 1: - parallel_warn("This pruner has no effect if only one training per " - "trial is performed.") - -
    [docs] def prune(self, study: "optuna.study.Study", - trial: "optuna.trial.FrozenTrial") -> bool: + parallel_warn( + "This pruner has no effect if only one training per " + "trial is performed." + ) + +
    [docs] def prune( + self, study: "optuna.study.Study", trial: "optuna.trial.FrozenTrial" + ) -> bool: """ Judge whether the trial should be pruned based on the reported values. diff --git a/_modules/mala/network/naswot_pruner.html b/_modules/mala/network/naswot_pruner.html index 106091816..40605bbbd 100644 --- a/_modules/mala/network/naswot_pruner.html +++ b/_modules/mala/network/naswot_pruner.html @@ -75,6 +75,7 @@

    Source code for mala.network.naswot_pruner

     """Prunes a network when the score is above a user defined limit."""
    +
     import optuna
     from optuna.pruners import BasePruner
     
    @@ -100,25 +101,27 @@ 

    Source code for mala.network.naswot_pruner

     
         """
     
    -    def __init__(self, search_parameters: Parameters, data_handler:
    -                 DataHandler):
    +    def __init__(
    +        self, search_parameters: Parameters, data_handler: DataHandler
    +    ):
             self._data_handler = data_handler
             self._params = search_parameters
             self._trial_type = self._params.hyperparameters.hyper_opt_method
             if self._trial_type != "optuna":
                 raise Exception("This pruner only works for optuna at the moment.")
     
    -
    [docs] def prune(self, study: "optuna.study.Study", trial: - "optuna.trial.FrozenTrial") -> bool: +
    [docs] def prune( + self, study: "optuna.study.Study", trial: "optuna.trial.FrozenTrial" + ) -> bool: """ Judge whether the trial should be pruned based on the reported values. - Note that this method is not supposed to be called by library users. - Instead, :func:`optuna.trial.Trial.report` and + Note that this method is not supposed to be called by library users. + Instead, :func:`optuna.trial.Trial.report` and :func:`optuna.trial.Trial.should_prune` provide - user interfaces to implement pruning mechanism in an objective + user interfaces to implement pruning mechanism in an objective function. - + Parameters ---------- study : optuna.study.Study @@ -130,14 +133,16 @@

    Source code for mala.network.naswot_pruner

     
             Returns
             -------
    -        should_prune : bool 
    -            A boolean indicating whether this particular trial should be 
    -            pruned. 
    +        should_prune : bool
    +            A boolean indicating whether this particular trial should be
    +            pruned.
             """
    -        objective = ObjectiveNASWOT(self._params, self._data_handler,
    -                                    self._trial_type, batch_size=
    -                                        self._params.hyperparameters.
    -                                    naswot_pruner_batch_size)
    +        objective = ObjectiveNASWOT(
    +            self._params,
    +            self._data_handler,
    +            self._trial_type,
    +            batch_size=self._params.hyperparameters.naswot_pruner_batch_size,
    +        )
             surrogate_loss = objective(trial)
             if surrogate_loss < self._params.hyperparameters.naswot_pruner_cutoff:
                 return True
    diff --git a/_modules/mala/network/network.html b/_modules/mala/network/network.html
    index 61ee05e01..c1876b086 100644
    --- a/_modules/mala/network/network.html
    +++ b/_modules/mala/network/network.html
    @@ -75,6 +75,7 @@
                  
       

    Source code for mala.network.network

     """Neural network for MALA."""
    +
     from abc import abstractmethod
     import numpy as np
     import torch
    @@ -83,6 +84,7 @@ 

    Source code for mala.network.network

     
     from mala.common.parameters import Parameters
     from mala.common.parallelizer import printout
    +
     try:
         import horovod.torch as hvd
     except ModuleNotFoundError:
    @@ -161,7 +163,7 @@ 

    Source code for mala.network.network

                 "Sigmoid": nn.Sigmoid,
                 "ReLU": nn.ReLU,
                 "LeakyReLU": nn.LeakyReLU,
    -            "Tanh": nn.Tanh
    +            "Tanh": nn.Tanh,
             }
     
             # initialize the layers
    @@ -173,7 +175,6 @@ 

    Source code for mala.network.network

             else:
                 raise Exception("Unsupported loss function.")
     
    -
     
    [docs] @abstractmethod def forward(self, inputs): """Abstract method. To be implemented by the derived class.""" @@ -241,8 +242,11 @@

    Source code for mala.network.network

             if self.use_horovod:
                 if hvd.rank() != 0:
                     return
    -        torch.save(self.state_dict(), path_to_file,
    -                   _use_new_zipfile_serialization=False)
    + torch.save( + self.state_dict(), + path_to_file, + _use_new_zipfile_serialization=False, + )
    [docs] @classmethod def load_from_file(cls, params, file): @@ -266,8 +270,9 @@

    Source code for mala.network.network

                 The network that was loaded from the file.
             """
             loaded_network = Network(params)
    -        loaded_network.\
    -            load_state_dict(torch.load(file, map_location=params.device))
    +        loaded_network.load_state_dict(
    +            torch.load(file, map_location=params.device)
    +        )
             loaded_network.eval()
             return loaded_network
    @@ -290,26 +295,40 @@

    Source code for mala.network.network

             elif len(self.params.layer_activations) < self.number_of_layers:
                 raise Exception("Not enough activation layers provided.")
             elif len(self.params.layer_activations) > self.number_of_layers:
    -            printout("Too many activation layers provided. "
    -                     "The last",
    -                     str(len(self.params.layer_activations) -
    -                         self.number_of_layers),
    -                     "activation function(s) will be ignored.",
    -                     min_verbosity=1)
    +            printout(
    +                "Too many activation layers provided. The last",
    +                str(
    +                    len(self.params.layer_activations) - self.number_of_layers
    +                ),
    +                "activation function(s) will be ignored.",
    +                min_verbosity=1,
    +            )
     
             # Add the layers.
             # As this is a feedforward layer we always add linear layers, and then
             # an activation function
             for i in range(0, self.number_of_layers):
    -            self.layers.append((nn.Linear(self.params.layer_sizes[i],
    -                                          self.params.layer_sizes[i + 1])))
    +            self.layers.append(
    +                (
    +                    nn.Linear(
    +                        self.params.layer_sizes[i],
    +                        self.params.layer_sizes[i + 1],
    +                    )
    +                )
    +            )
                 try:
                     if use_only_one_activation_type:
    -                    self.layers.append(self.activation_mappings[self.params.
    -                                       layer_activations[0]]())
    +                    self.layers.append(
    +                        self.activation_mappings[
    +                            self.params.layer_activations[0]
    +                        ]()
    +                    )
                     else:
    -                    self.layers.append(self.activation_mappings[self.params.
    -                                       layer_activations[i]]())
    +                    self.layers.append(
    +                        self.activation_mappings[
    +                            self.params.layer_activations[i]
    +                        ]()
    +                    )
                 except KeyError:
                     raise Exception("Invalid activation type seleceted.")
     
    @@ -352,25 +371,31 @@ 

    Source code for mala.network.network

             print("initialising LSTM network")
     
             # First Layer
    -        self.first_layer = nn.Linear(self.params.layer_sizes[0],
    -                                     self.params.layer_sizes[1])
    +        self.first_layer = nn.Linear(
    +            self.params.layer_sizes[0], self.params.layer_sizes[1]
    +        )
     
             # size of lstm based on bidirectional or not:
             # https://en.wikipedia.org/wiki/Bidirectional_recurrent_neural_networks
             if self.params.bidirection:
    -            self.lstm_gru_layer = nn.LSTM(self.params.layer_sizes[1],
    -                                          int(self.hidden_dim / 2),
    -                                          self.params.num_hidden_layers,
    -                                          batch_first=True,
    -                                          bidirectional=True)
    +            self.lstm_gru_layer = nn.LSTM(
    +                self.params.layer_sizes[1],
    +                int(self.hidden_dim / 2),
    +                self.params.num_hidden_layers,
    +                batch_first=True,
    +                bidirectional=True,
    +            )
             else:
     
    -            self.lstm_gru_layer = nn.LSTM(self.params.layer_sizes[1],
    -                                          self.hidden_dim,
    -                                          self.params.num_hidden_layers,
    -                                          batch_first=True)
    -        self.activation = \
    -            self.activation_mappings[self.params.layer_activations[0]]()
    +            self.lstm_gru_layer = nn.LSTM(
    +                self.params.layer_sizes[1],
    +                self.hidden_dim,
    +                self.params.num_hidden_layers,
    +                batch_first=True,
    +            )
    +        self.activation = self.activation_mappings[
    +            self.params.layer_activations[0]
    +        ]()
     
             self.batch_size = None
             # Once everything is done, we can move the Network on the target
    @@ -395,27 +420,37 @@ 

    Source code for mala.network.network

             self.batch_size = x.shape[0]
     
             if self.params.no_hidden_state:
    -            self.hidden =\
    -                (self.hidden[0].fill_(0.0), self.hidden[1].fill_(0.0))
    +            self.hidden = (
    +                self.hidden[0].fill_(0.0),
    +                self.hidden[1].fill_(0.0),
    +            )
     
             self.hidden = (self.hidden[0].detach(), self.hidden[1].detach())
             x = self.activation(self.first_layer(x))
     
             if self.params.bidirection:
    -            x, self.hidden = self.lstm_gru_layer(x.view(self.batch_size,
    -                                                 self.params.num_hidden_layers,
    -                                                 self.params.layer_sizes[1]),
    -                                                 self.hidden)
    +            x, self.hidden = self.lstm_gru_layer(
    +                x.view(
    +                    self.batch_size,
    +                    self.params.num_hidden_layers,
    +                    self.params.layer_sizes[1],
    +                ),
    +                self.hidden,
    +            )
             else:
    -            x, self.hidden = self.lstm_gru_layer(x.view(self.batch_size,
    -                                                 self.params.num_hidden_layers,
    -                                                 self.params.layer_sizes[1]),
    -                                                 self.hidden)
    +            x, self.hidden = self.lstm_gru_layer(
    +                x.view(
    +                    self.batch_size,
    +                    self.params.num_hidden_layers,
    +                    self.params.layer_sizes[1],
    +                ),
    +                self.hidden,
    +            )
     
             x = x[:, -1, :]
             x = self.activation(x)
     
    -        return (x)
    + return x
    [docs] def init_hidden(self): """ @@ -429,19 +464,27 @@

    Source code for mala.network.network

                 initialised to zeros.
             """
             if self.params.bidirection:
    -            h0 = torch.empty(self.params.num_hidden_layers * 2,
    -                             self.mini_batch_size,
    -                             self.hidden_dim // 2)
    -            c0 = torch.empty(self.params.num_hidden_layers * 2,
    -                             self.mini_batch_size,
    -                             self.hidden_dim // 2)
    +            h0 = torch.empty(
    +                self.params.num_hidden_layers * 2,
    +                self.mini_batch_size,
    +                self.hidden_dim // 2,
    +            )
    +            c0 = torch.empty(
    +                self.params.num_hidden_layers * 2,
    +                self.mini_batch_size,
    +                self.hidden_dim // 2,
    +            )
             else:
    -            h0 = torch.empty(self.params.num_hidden_layers,
    -                             self.mini_batch_size,
    -                             self.hidden_dim)
    -            c0 = torch.empty(self.params.num_hidden_layers,
    -                             self.mini_batch_size,
    -                             self.hidden_dim)
    +            h0 = torch.empty(
    +                self.params.num_hidden_layers,
    +                self.mini_batch_size,
    +                self.hidden_dim,
    +            )
    +            c0 = torch.empty(
    +                self.params.num_hidden_layers,
    +                self.mini_batch_size,
    +                self.hidden_dim,
    +            )
             h0.zero_()
             c0.zero_()
     
    @@ -462,27 +505,33 @@ 

    Source code for mala.network.network

             self.hidden = self.init_hidden()
     
             # First Layer
    -        self.first_layer = nn.Linear(self.params.layer_sizes[0],
    -                                     self.params.layer_sizes[1])
    +        self.first_layer = nn.Linear(
    +            self.params.layer_sizes[0], self.params.layer_sizes[1]
    +        )
     
             # Similar to LSTM class replaced with nn.GRU
             if self.params.bidirection:
    -            self.lstm_gru_layer = nn.GRU(self.params.layer_sizes[1],
    -                                         int(self.hidden_dim / 2),
    -                                         self.params.num_hidden_layers,
    -                                         batch_first=True,
    -                                         bidirectional=True)
    +            self.lstm_gru_layer = nn.GRU(
    +                self.params.layer_sizes[1],
    +                int(self.hidden_dim / 2),
    +                self.params.num_hidden_layers,
    +                batch_first=True,
    +                bidirectional=True,
    +            )
             else:
     
    -            self.lstm_gru_layer = nn.GRU(self.params.layer_sizes[1],
    -                                         self.hidden_dim,
    -                                         self.params.num_hidden_layers,
    -                                         batch_first=True)
    -        self.activation = \
    -            self.activation_mappings[self.params.layer_activations[0]]()
    +            self.lstm_gru_layer = nn.GRU(
    +                self.params.layer_sizes[1],
    +                self.hidden_dim,
    +                self.params.num_hidden_layers,
    +                batch_first=True,
    +            )
    +        self.activation = self.activation_mappings[
    +            self.params.layer_activations[0]
    +        ]()
     
             if params.use_gpu:
    -            self.to('cuda')
    +            self.to("cuda")
     
     
    [docs] def forward(self, x): """ @@ -508,20 +557,28 @@

    Source code for mala.network.network

             x = self.activation(self.first_layer(x))
     
             if self.params.bidirection:
    -            x, self.hidden = self.lstm_gru_layer(x.view(self.batch_size,
    -                                                 self.params.num_hidden_layers,
    -                                                 self.params.layer_sizes[1]),
    -                                                 self.hidden)
    +            x, self.hidden = self.lstm_gru_layer(
    +                x.view(
    +                    self.batch_size,
    +                    self.params.num_hidden_layers,
    +                    self.params.layer_sizes[1],
    +                ),
    +                self.hidden,
    +            )
             else:
    -            x, self.hidden = self.lstm_gru_layer(x.view(self.batch_size,
    -                                                 self.params.num_hidden_layers,
    -                                                 self.params.layer_sizes[1]),
    -                                                 self.hidden)
    +            x, self.hidden = self.lstm_gru_layer(
    +                x.view(
    +                    self.batch_size,
    +                    self.params.num_hidden_layers,
    +                    self.params.layer_sizes[1],
    +                ),
    +                self.hidden,
    +            )
     
             x = x[:, -1, :]
             x = self.activation(x)
     
    -        return (x)
    + return x
    [docs] def init_hidden(self): """ @@ -533,13 +590,17 @@

    Source code for mala.network.network

                 initialised to zeros.
             """
             if self.params.bidirection:
    -            h0 = torch.empty(self.params.num_hidden_layers * 2,
    -                             self.mini_batch_size,
    -                             self.hidden_dim // 2)
    +            h0 = torch.empty(
    +                self.params.num_hidden_layers * 2,
    +                self.mini_batch_size,
    +                self.hidden_dim // 2,
    +            )
             else:
    -            h0 = torch.empty(self.params.num_hidden_layers,
    -                             self.mini_batch_size,
    -                             self.hidden_dim)
    +            h0 = torch.empty(
    +                self.params.num_hidden_layers,
    +                self.mini_batch_size,
    +                self.hidden_dim,
    +            )
             h0.zero_()
     
             return h0
    @@ -563,23 +624,32 @@

    Source code for mala.network.network

                 while self.params.layer_sizes[0] % self.params.num_heads != 0:
                     self.params.num_heads += 1
     
    -            printout("Adjusting number of heads from", old_num_heads,
    -                     "to", self.params.num_heads, min_verbosity=1)
    +            printout(
    +                "Adjusting number of heads from",
    +                old_num_heads,
    +                "to",
    +                self.params.num_heads,
    +                min_verbosity=1,
    +            )
     
             self.src_mask = None
    -        self.pos_encoder = PositionalEncoding(self.params.layer_sizes[0],
    -                                              self.params.dropout)
    -
    -        encoder_layers = nn.TransformerEncoderLayer(self.params.layer_sizes[0],
    -                                                    self.params.num_heads,
    -                                                    self.params.layer_sizes[1],
    -                                                    self.params.dropout)
    -        self.transformer_encoder =\
    -            nn.TransformerEncoder(encoder_layers,
    -                                  self.params.num_hidden_layers)
    -
    -        self.decoder = nn.Linear(self.params.layer_sizes[0],
    -                                 self.params.layer_sizes[-1])
    +        self.pos_encoder = PositionalEncoding(
    +            self.params.layer_sizes[0], self.params.dropout
    +        )
    +
    +        encoder_layers = nn.TransformerEncoderLayer(
    +            self.params.layer_sizes[0],
    +            self.params.num_heads,
    +            self.params.layer_sizes[1],
    +            self.params.dropout,
    +        )
    +        self.transformer_encoder = nn.TransformerEncoder(
    +            encoder_layers, self.params.num_hidden_layers
    +        )
    +
    +        self.decoder = nn.Linear(
    +            self.params.layer_sizes[0], self.params.layer_sizes[-1]
    +        )
     
             self.init_weights()
     
    @@ -598,8 +668,11 @@ 

    Source code for mala.network.network

                 size of the mask
             """
             mask = (torch.triu(torch.ones(size, size)) == 1).transpose(0, 1)
    -        mask = mask.float().masked_fill(mask == 0, float('-inf')).\
    -            masked_fill(mask == 1, float(0.0))
    +        mask = (
    +            mask.float()
    +            .masked_fill(mask == 0, float("-inf"))
    +            .masked_fill(mask == 1, float(0.0))
    +        )
     
             return mask
    @@ -620,7 +693,7 @@

    Source code for mala.network.network

                 mask = self.generate_square_subsequent_mask(x.size(0)).to(device)
                 self.src_mask = mask
     
    -    #        x = self.encoder(x) * math.sqrt(self.params.layer_sizes[0])
    +        #        x = self.encoder(x) * math.sqrt(self.params.layer_sizes[0])
             x = self.pos_encoder(x)
             output = self.transformer_encoder(x, self.src_mask)
             output = self.decoder(output)
    @@ -652,20 +725,23 @@ 

    Source code for mala.network.network

             position = torch.arange(0, max_len, dtype=torch.float).unsqueeze(1)
     
             # Need to develop better form here.
    -        div_term = torch.exp(torch.arange(0, d_model, 2).float() *
    -                             (-np.log(10000.0) / d_model))
    -        div_term2 = torch.exp(torch.arange(0, d_model - 1 , 2).float() *
    -                              (-np.log(10000.0) / d_model))
    +        div_term = torch.exp(
    +            torch.arange(0, d_model, 2).float() * (-np.log(10000.0) / d_model)
    +        )
    +        div_term2 = torch.exp(
    +            torch.arange(0, d_model - 1, 2).float()
    +            * (-np.log(10000.0) / d_model)
    +        )
             pe[:, 0::2] = torch.sin(position * div_term)
             pe[:, 1::2] = torch.cos(position * div_term2)
             pe = pe.unsqueeze(0).transpose(0, 1)
    -        self.register_buffer('pe', pe)
    +        self.register_buffer("pe", pe)
     
     
    [docs] def forward(self, x): """Perform a forward pass through the network.""" # add extra dimension for batch_size x = x.unsqueeze(dim=1) - x = x + self.pe[:x.size(0), :] + x = x + self.pe[: x.size(0), :] return self.dropout(x)
    diff --git a/_modules/mala/network/objective_base.html b/_modules/mala/network/objective_base.html index 0e13324c4..b60352b6c 100644 --- a/_modules/mala/network/objective_base.html +++ b/_modules/mala/network/objective_base.html @@ -75,6 +75,7 @@

    Source code for mala.network.objective_base

     """Objective function for all training based hyperparameter optimizations."""
    +
     import numpy as np
     from optuna import Trial, TrialPruned
     
    @@ -109,29 +110,39 @@ 

    Source code for mala.network.objective_base

     
             # We need to find out if we have to reparametrize the lists with the
             # layers and the activations.
    -        contains_single_layer = any(map(
    -            lambda p: "ff_neurons_layer" in p.name,
    -            self.params.hyperparameters.hlist
    -        ))
    -        contains_multiple_layer_neurons = any(map(
    -            lambda p: "ff_multiple_layers_neurons" in p.name,
    -            self.params.hyperparameters.hlist
    -        ))
    -        contains_multiple_layers_count = any(map(
    -            lambda p: "ff_multiple_layers_count" in p.name,
    -            self.params.hyperparameters.hlist
    -        ))
    +        contains_single_layer = any(
    +            map(
    +                lambda p: "ff_neurons_layer" in p.name,
    +                self.params.hyperparameters.hlist,
    +            )
    +        )
    +        contains_multiple_layer_neurons = any(
    +            map(
    +                lambda p: "ff_multiple_layers_neurons" in p.name,
    +                self.params.hyperparameters.hlist,
    +            )
    +        )
    +        contains_multiple_layers_count = any(
    +            map(
    +                lambda p: "ff_multiple_layers_count" in p.name,
    +                self.params.hyperparameters.hlist,
    +            )
    +        )
             if contains_multiple_layer_neurons != contains_multiple_layers_count:
    -            print("You selected multiple layers to be optimized, but either "
    -                  "the range of neurons or number of layers is missing. "
    -                  "This input will be ignored.")
    +            print(
    +                "You selected multiple layers to be optimized, but either "
    +                "the range of neurons or number of layers is missing. "
    +                "This input will be ignored."
    +            )
             self.optimize_layer_list = contains_single_layer or (
    -                    contains_multiple_layer_neurons and
    -                    contains_multiple_layers_count)
    -        self.optimize_activation_list = list(map(
    -            lambda p: "layer_activation" in p.name,
    -            self.params.hyperparameters.hlist
    -        )).count(True)
    +            contains_multiple_layer_neurons and contains_multiple_layers_count
    +        )
    +        self.optimize_activation_list = list(
    +            map(
    +                lambda p: "layer_activation" in p.name,
    +                self.params.hyperparameters.hlist,
    +            )
    +        ).count(True)
     
             self.trial_type = self.params.hyperparameters.hyper_opt_method
     
    @@ -147,23 +158,28 @@ 

    Source code for mala.network.objective_base

             """
             # Parse the parameters included in the trial.
             self.parse_trial(trial)
    -        if self.trial_type == "optuna" and self.params.hyperparameters.pruner\
    -                == "naswot":
    +        if (
    +            self.trial_type == "optuna"
    +            and self.params.hyperparameters.pruner == "naswot"
    +        ):
                 if trial.should_prune():
                     raise TrialPruned()
     
             # Train a network for as often as the user desires.
             final_validation_loss = []
    -        for i in range(0, self.params.hyperparameters.
    -                       number_training_per_trial):
    +        for i in range(
    +            0, self.params.hyperparameters.number_training_per_trial
    +        ):
                 test_network = Network(self.params)
    -            test_trainer = Trainer(self.params, test_network,
    -                                   self.data_handler)
    +            test_trainer = Trainer(
    +                self.params, test_network, self.data_handler
    +            )
                 test_trainer.train_network()
                 final_validation_loss.append(test_trainer.final_validation_loss)
    -            if self.trial_type == "optuna" and \
    -                    self.params.hyperparameters.pruner \
    -                    == "multi_training":
    +            if (
    +                self.trial_type == "optuna"
    +                and self.params.hyperparameters.pruner == "multi_training"
    +            ):
     
                     # This is a little bit hacky, since report is actually
                     # meant for values DURING training, but we instead
    @@ -180,19 +196,23 @@ 

    Source code for mala.network.objective_base

             if self.params.hyperparameters.trial_ensemble_evaluation == "mean":
                 return np.mean(final_validation_loss)
     
    -        elif self.params.hyperparameters.trial_ensemble_evaluation == \
    -                "mean_std":
    +        elif (
    +            self.params.hyperparameters.trial_ensemble_evaluation == "mean_std"
    +        ):
                 mean = np.mean(final_validation_loss)
     
                 # Cannot calculate the standar deviation of a bunch of infinities.
                 if np.isinf(mean):
                     return mean
                 else:
    -                return np.mean(final_validation_loss) + \
    -                       np.std(final_validation_loss)
    +                return np.mean(final_validation_loss) + np.std(
    +                    final_validation_loss
    +                )
             else:
    -            raise Exception("No way to estimate the trial metric from ensemble"
    -                            " training provided.")
    +            raise Exception(
    +                "No way to estimate the trial metric from ensemble"
    +                " training provided."
    +            )
     
     
    [docs] def parse_trial(self, trial): """ @@ -209,8 +229,10 @@

    Source code for mala.network.objective_base

             elif self.trial_type == "oat":
                 self.parse_trial_oat(trial)
             else:
    -            raise Exception("Cannot parse trial, unknown hyperparameter"
    -                            " optimization method.")
    + raise Exception( + "Cannot parse trial, unknown hyperparameter" + " optimization method." + )
    [docs] def parse_trial_optuna(self, trial: Trial): """ @@ -222,8 +244,9 @@

    Source code for mala.network.objective_base

                 A set of hyperparameters encoded by optuna.
             """
             if self.optimize_layer_list:
    -            self.params.network.layer_sizes = \
    -                [self.data_handler.input_dimension]
    +            self.params.network.layer_sizes = [
    +                self.data_handler.input_dimension
    +            ]
             if self.optimize_activation_list > 0:
                 self.params.network.layer_activations = []
     
    @@ -252,8 +275,9 @@ 

    Source code for mala.network.objective_base

                     if number_layers > 0:
                         for i in range(0, number_layers):
                             if neurons_per_layer > 0:
    -                            self.params.network.layer_sizes. \
    -                                append(neurons_per_layer)
    +                            self.params.network.layer_sizes.append(
    +                                neurons_per_layer
    +                            )
                             else:
                                 turned_off_layers.append(layer_counter)
                             layer_counter += 1
    @@ -276,8 +300,9 @@ 

    Source code for mala.network.objective_base

                         # that can be left out.
                         layer_size = par.get_parameter(trial)
                         if layer_size > 0:
    -                        self.params.network.layer_sizes.\
    -                            append(par.get_parameter(trial))
    +                        self.params.network.layer_sizes.append(
    +                            par.get_parameter(trial)
    +                        )
                         else:
                             turned_off_layers.append(layer_counter)
                         layer_counter += 1
    @@ -289,23 +314,29 @@ 

    Source code for mala.network.objective_base

                     self.params.running.mini_batch_size = par.get_parameter(trial)
     
                 elif "early_stopping_epochs" == par.name:
    -                self.params.running.early_stopping_epochs = par.\
    -                    get_parameter(trial)
    +                self.params.running.early_stopping_epochs = par.get_parameter(
    +                    trial
    +                )
     
                 elif "learning_rate_patience" == par.name:
    -                self.params.running.learning_rate_patience = par.\
    -                    get_parameter(trial)
    +                self.params.running.learning_rate_patience = par.get_parameter(
    +                    trial
    +                )
     
                 elif "learning_rate_decay" == par.name:
    -                self.params.running.learning_rate_decay = par.\
    -                    get_parameter(trial)
    +                self.params.running.learning_rate_decay = par.get_parameter(
    +                    trial
    +                )
     
                 elif "layer_activation" in par.name:
                     pass
     
                 else:
    -                raise Exception("Optimization of hyperparameter ", par.name,
    -                                "not supported at the moment.")
    +                raise Exception(
    +                    "Optimization of hyperparameter ",
    +                    par.name,
    +                    "not supported at the moment.",
    +                )
     
             # We have to process the activations separately, because they depend on
             # the results of the layer lists.
    @@ -314,13 +345,15 @@ 

    Source code for mala.network.objective_base

             for par in self.params.hyperparameters.hlist:
                 if "layer_activation" in par.name:
                     if layer_counter not in turned_off_layers:
    -                    self.params.network.layer_activations.\
    -                        append(par.get_parameter(trial))
    +                    self.params.network.layer_activations.append(
    +                        par.get_parameter(trial)
    +                    )
                     layer_counter += 1
     
             if self.optimize_layer_list:
    -            self.params.network.layer_sizes.\
    -                append(self.data_handler.output_dimension)
    + self.params.network.layer_sizes.append( + self.data_handler.output_dimension + )
    [docs] def parse_trial_oat(self, trial): """ @@ -332,8 +365,9 @@

    Source code for mala.network.objective_base

                 Row in an orthogonal array which respresents current trial.
             """
             if self.optimize_layer_list:
    -            self.params.network.layer_sizes = \
    -                [self.data_handler.input_dimension]
    +            self.params.network.layer_sizes = [
    +                self.data_handler.input_dimension
    +            ]
     
             if self.optimize_activation_list:
                 self.params.network.layer_activations = []
    @@ -347,8 +381,9 @@ 

    Source code for mala.network.objective_base

             par: HyperparameterOAT
             for factor_idx, par in enumerate(self.params.hyperparameters.hlist):
                 if "learning_rate" == par.name:
    -                self.params.running.learning_rate = \
    -                    par.get_parameter(trial, factor_idx)
    +                self.params.running.learning_rate = par.get_parameter(
    +                    trial, factor_idx
    +                )
                     # If the user wants to optimize multiple layers simultaneously,
                     # we have to parse to parameters at the same time.
                 elif par.name == "ff_multiple_layers_neurons":
    @@ -356,17 +391,20 @@ 

    Source code for mala.network.objective_base

                     number_layers = 0
                     max_number_layers = 0
                     other_par: HyperparameterOAT
    -                for other_idx, other_par in enumerate(self.params.
    -                                                      hyperparameters.hlist):
    +                for other_idx, other_par in enumerate(
    +                    self.params.hyperparameters.hlist
    +                ):
                         if other_par.name == "ff_multiple_layers_count":
    -                        number_layers = other_par.get_parameter(trial,
    -                                                                other_idx)
    +                        number_layers = other_par.get_parameter(
    +                            trial, other_idx
    +                        )
                             max_number_layers = max(other_par.choices)
                     if number_layers > 0:
                         for i in range(0, number_layers):
                             if neurons_per_layer > 0:
    -                            self.params.network.layer_sizes. \
    -                                append(neurons_per_layer)
    +                            self.params.network.layer_sizes.append(
    +                                neurons_per_layer
    +                            )
                             else:
                                 turned_off_layers.append(layer_counter)
                             layer_counter += 1
    @@ -389,36 +427,45 @@ 

    Source code for mala.network.objective_base

                         # that can be left out.
                         layer_size = par.get_parameter(trial, factor_idx)
                         if layer_size > 0:
    -                        self.params.network.layer_sizes. \
    -                            append(par.get_parameter(trial, factor_idx))
    +                        self.params.network.layer_sizes.append(
    +                            par.get_parameter(trial, factor_idx)
    +                        )
                         else:
                             turned_off_layers.append(layer_counter)
                         layer_counter += 1
     
                 elif "trainingtype" == par.name:
    -                self.params.running.trainingtype = par.\
    -                    get_parameter(trial, factor_idx)
    +                self.params.running.trainingtype = par.get_parameter(
    +                    trial, factor_idx
    +                )
                 elif "mini_batch_size" == par.name:
    -                self.params.running.mini_batch_size = \
    -                    par.get_parameter(trial, factor_idx)
    +                self.params.running.mini_batch_size = par.get_parameter(
    +                    trial, factor_idx
    +                )
                 elif "early_stopping_epochs" == par.name:
    -                self.params.running.early_stopping_epochs = par.\
    -                    get_parameter(trial, factor_idx)
    +                self.params.running.early_stopping_epochs = par.get_parameter(
    +                    trial, factor_idx
    +                )
     
                 elif "learning_rate_patience" == par.name:
    -                self.params.running.learning_rate_patience = par.\
    -                    get_parameter(trial, factor_idx)
    +                self.params.running.learning_rate_patience = par.get_parameter(
    +                    trial, factor_idx
    +                )
     
                 elif "learning_rate_decay" == par.name:
    -                self.params.running.learning_rate_decay = par.\
    -                    get_parameter(trial,factor_idx)
    +                self.params.running.learning_rate_decay = par.get_parameter(
    +                    trial, factor_idx
    +                )
     
                 elif "layer_activation" in par.name:
                     pass
     
                 else:
    -                raise Exception("Optimization of hyperparameter ", par.name,
    -                                "not supported at the moment.")
    +                raise Exception(
    +                    "Optimization of hyperparameter ",
    +                    par.name,
    +                    "not supported at the moment.",
    +                )
     
             # We have to process the activations separately, because they depend on
             # the results of the layer lists.
    @@ -428,13 +475,15 @@ 

    Source code for mala.network.objective_base

             for factor_idx, par in enumerate(self.params.hyperparameters.hlist):
                 if "layer_activation" in par.name:
                     if layer_counter not in turned_off_layers:
    -                    self.params.network.layer_activations.\
    -                        append(par.get_parameter(trial, factor_idx))
    +                    self.params.network.layer_activations.append(
    +                        par.get_parameter(trial, factor_idx)
    +                    )
                     layer_counter += 1
     
             if self.optimize_layer_list:
    -            self.params.network.layer_sizes.\
    -                append(self.data_handler.output_dimension)
    + self.params.network.layer_sizes.append( + self.data_handler.output_dimension + )
    diff --git a/_modules/mala/network/objective_naswot.html b/_modules/mala/network/objective_naswot.html index bf7ca4265..c71a60dbc 100644 --- a/_modules/mala/network/objective_naswot.html +++ b/_modules/mala/network/objective_naswot.html @@ -75,6 +75,7 @@

    Source code for mala.network.objective_naswot

     """Objective functions for hyperparameter optimizations without training."""
    +
     import numpy as np
     import torch
     from torch import Tensor
    @@ -113,10 +114,14 @@ 

    Source code for mala.network.objective_naswot

    applications it might make sense to specify something different. """ - def __init__(self, search_parameters: Parameters, data_handler: - DataHandler, trial_type, batch_size=None): - super(ObjectiveNASWOT, self).__init__(search_parameters, - data_handler) + def __init__( + self, + search_parameters: Parameters, + data_handler: DataHandler, + trial_type, + batch_size=None, + ): + super(ObjectiveNASWOT, self).__init__(search_parameters, data_handler) self.trial_type = trial_type self.batch_size = batch_size if self.batch_size is None: @@ -137,29 +142,35 @@

    Source code for mala.network.objective_naswot

    # Build the network. surrogate_losses = [] - for i in range(0, self.params.hyperparameters. - number_training_per_trial): + for i in range( + 0, self.params.hyperparameters.number_training_per_trial + ): net = Network(self.params) device = self.params.device # Load the batchesand get the jacobian. do_shuffle = self.params.running.use_shuffling_for_samplers - if self.data_handler.parameters.use_lazy_loading or \ - self.params.use_horovod: + if ( + self.data_handler.parameters.use_lazy_loading + or self.params.use_horovod + ): do_shuffle = False if self.params.running.use_shuffling_for_samplers: self.data_handler.mix_datasets() - loader = DataLoader(self.data_handler.training_data_sets[0], - batch_size=self.batch_size, - shuffle=do_shuffle) + loader = DataLoader( + self.data_handler.training_data_sets[0], + batch_size=self.batch_size, + shuffle=do_shuffle, + ) jac = ObjectiveNASWOT.__get_batch_jacobian(net, loader, device) # Loss = - score! - surrogate_loss = float('inf') + surrogate_loss = float("inf") try: - surrogate_loss = - ObjectiveNASWOT.__calc_score(jac) - surrogate_loss = surrogate_loss.cpu().detach().numpy().astype( - np.float64) + surrogate_loss = -ObjectiveNASWOT.__calc_score(jac) + surrogate_loss = ( + surrogate_loss.cpu().detach().numpy().astype(np.float64) + ) except RuntimeError: print("Got a NaN, ignoring sample.") surrogate_losses.append(surrogate_loss) @@ -171,23 +182,26 @@

    Source code for mala.network.objective_naswot

    if self.params.hyperparameters.trial_ensemble_evaluation == "mean": return np.mean(surrogate_losses) - elif self.params.hyperparameters.trial_ensemble_evaluation == \ - "mean_std": + elif ( + self.params.hyperparameters.trial_ensemble_evaluation == "mean_std" + ): mean = np.mean(surrogate_losses) # Cannot calculate the standar deviation of a bunch of infinities. if np.isinf(mean): return mean else: - return np.mean(surrogate_losses) + \ - np.std(surrogate_losses) + return np.mean(surrogate_losses) + np.std(surrogate_losses) else: - raise Exception("No way to estimate the trial metric from ensemble" - " training provided.") + raise Exception( + "No way to estimate the trial metric from ensemble" + " training provided." + ) @staticmethod - def __get_batch_jacobian(net: Network, loader: DataLoader, device) \ - -> Tensor: + def __get_batch_jacobian( + net: Network, loader: DataLoader, device + ) -> Tensor: """Calculate the jacobian of the batch.""" x: Tensor (x, _) = next(iter(loader)) @@ -236,7 +250,7 @@

    Source code for mala.network.objective_naswot

    # seems to have bigger rounding errors than numpy, resulting in # slightly larger negative Eigenvalues k = 1e-4 - v = -torch.sum(torch.log(eigen_values + k) + 1. / (eigen_values+k)) + v = -torch.sum(torch.log(eigen_values + k) + 1.0 / (eigen_values + k)) return v
    diff --git a/_modules/mala/network/predictor.html b/_modules/mala/network/predictor.html index 5065a833f..113448795 100644 --- a/_modules/mala/network/predictor.html +++ b/_modules/mala/network/predictor.html @@ -75,12 +75,7 @@

    Source code for mala.network.predictor

     """Tester class for testing a network."""
    -import ase.io
    -try:
    -    import horovod.torch as hvd
    -except ModuleNotFoundError:
    -    # Warning is thrown by Parameters class
    -    pass
    +
     import numpy as np
     import torch
     
    @@ -111,9 +106,11 @@ 

    Source code for mala.network.predictor

             # copy the parameters into the class.
             super(Predictor, self).__init__(params, network, data)
             self.data.grid_dimension = self.parameters.inference_data_grid
    -        self.data.grid_size = self.data.grid_dimension[0] * \
    -                              self.data.grid_dimension[1] * \
    -                              self.data.grid_dimension[2]
    +        self.data.grid_size = (
    +            self.data.grid_dimension[0]
    +            * self.data.grid_dimension[1]
    +            * self.data.grid_dimension[2]
    +        )
             self.test_data_loader = None
             self.number_of_batches_per_snapshot = 0
             self.target_calculator = data.target_calculator
    @@ -139,14 +136,18 @@ 

    Source code for mala.network.predictor

                 Precicted LDOS for these atomic positions.
             """
             self.data.grid_dimension = self.parameters.inference_data_grid
    -        self.data.grid_size = self.data.grid_dimension[0] * \
    -                              self.data.grid_dimension[1] * \
    -                              self.data.grid_dimension[2]
    -
    -        self.data.target_calculator.\
    -            read_additional_calculation_data(path_to_file, "espresso-out")
    -        return self.predict_for_atoms(self.data.target_calculator.atoms,
    -                                      gather_ldos=gather_ldos)
    + self.data.grid_size = ( + self.data.grid_dimension[0] + * self.data.grid_dimension[1] + * self.data.grid_dimension[2] + ) + + self.data.target_calculator.read_additional_calculation_data( + path_to_file, "espresso-out" + ) + return self.predict_for_atoms( + self.data.target_calculator.atoms, gather_ldos=gather_ldos + )
    [docs] def predict_for_atoms(self, atoms, gather_ldos=False, temperature=None): """ @@ -186,10 +187,11 @@

    Source code for mala.network.predictor

                 new_cell = atoms.get_cell()
     
                 # We only need the diagonal elements.
    -            factor = np.diag(new_cell)/np.diag(old_cell)
    +            factor = np.diag(new_cell) / np.diag(old_cell)
                 factor = factor.astype(int)
    -            self.data.grid_dimension = \
    +            self.data.grid_dimension = (
                     factor * self.data.target_calculator.grid_dimensions
    +            )
     
             self.data.grid_size = np.prod(self.data.grid_dimension)
     
    @@ -201,13 +203,16 @@ 

    Source code for mala.network.predictor

             self.data.target_calculator.invalidate_target()
     
             # Calculate descriptors.
    -        snap_descriptors, local_size = self.data.descriptor_calculator.\
    -            calculate_from_atoms(atoms, self.data.grid_dimension)
    +        snap_descriptors, local_size = (
    +            self.data.descriptor_calculator.calculate_from_atoms(
    +                atoms, self.data.grid_dimension
    +            )
    +        )
     
             # Provide info from current snapshot to target calculator.
    -        self.data.target_calculator.\
    -            read_additional_calculation_data([atoms, self.data.grid_dimension],
    -                                             "atoms+grid")
    +        self.data.target_calculator.read_additional_calculation_data(
    +            [atoms, self.data.grid_dimension], "atoms+grid"
    +        )
             feature_length = self.data.descriptor_calculator.fingerprint_length
     
             # The actual calculation of the LDOS from the descriptors depends
    @@ -216,8 +221,11 @@ 

    Source code for mala.network.predictor

             # case, everything is forwarded at once.
             if self.parameters._configuration["mpi"]:
                 if gather_ldos is True:
    -                snap_descriptors = self.data.descriptor_calculator. \
    -                    gather_descriptors(snap_descriptors)
    +                snap_descriptors = (
    +                    self.data.descriptor_calculator.gather_descriptors(
    +                        snap_descriptors
    +                    )
    +                )
     
                     # Just entering the forwarding function to wait for the
                     # main rank further down.
    @@ -227,41 +235,44 @@ 

    Source code for mala.network.predictor

     
                 else:
                     if self.data.descriptor_calculator.descriptors_contain_xyz:
    -                    self.data.target_calculator.local_grid = \
    -                        snap_descriptors[:, 0:3].copy()
    -                    self.data.target_calculator.y_planes = \
    -                        self.data.descriptor_calculator.parameters.\
    -                        use_y_splitting
    +                    self.data.target_calculator.local_grid = snap_descriptors[
    +                        :, 0:3
    +                    ].copy()
    +                    self.data.target_calculator.y_planes = (
    +                        self.data.descriptor_calculator.parameters.use_y_splitting
    +                    )
                         snap_descriptors = snap_descriptors[:, 6:]
                         feature_length -= 3
                     else:
    -                    raise Exception("Cannot calculate the local grid without "
    -                                    "calculating the xyz positions of the "
    -                                    "descriptors. Please revise your "
    -                                    "script. The local grid is crucial"
    -                                    " for parallel inference")
    -
    -                snap_descriptors = \
    -                    torch.from_numpy(snap_descriptors).float()
    +                    raise Exception(
    +                        "Cannot calculate the local grid without "
    +                        "calculating the xyz positions of the "
    +                        "descriptors. Please revise your "
    +                        "script. The local grid is crucial"
    +                        " for parallel inference"
    +                    )
    +
    +                snap_descriptors = torch.from_numpy(snap_descriptors).float()
                     self.data.input_data_scaler.transform(snap_descriptors)
    -                return self. \
    -                    _forward_snap_descriptors(snap_descriptors, local_size)
    +                return self._forward_snap_descriptors(
    +                    snap_descriptors, local_size
    +                )
     
             if get_rank() == 0:
                 if self.data.descriptor_calculator.descriptors_contain_xyz:
                     snap_descriptors = snap_descriptors[:, :, :, 3:]
                     feature_length -= 3
     
    -            snap_descriptors = \
    -                snap_descriptors.reshape(
    -                    [self.data.grid_size, feature_length])
    -            snap_descriptors = \
    -                torch.from_numpy(snap_descriptors).float()
    +            snap_descriptors = snap_descriptors.reshape(
    +                [self.data.grid_size, feature_length]
    +            )
    +            snap_descriptors = torch.from_numpy(snap_descriptors).float()
                 self.data.input_data_scaler.transform(snap_descriptors)
                 return self._forward_snap_descriptors(snap_descriptors)
    - def _forward_snap_descriptors(self, snap_descriptors, - local_data_size=None): + def _forward_snap_descriptors( + self, snap_descriptors, local_data_size=None + ): """Forward a scaled tensor of descriptors through the NN.""" # Ensure the Network is on the correct device. # This line is necessary because GPU acceleration may have been @@ -270,40 +281,50 @@

    Source code for mala.network.predictor

     
             if local_data_size is None:
                 local_data_size = self.data.grid_size
    -        predicted_outputs = \
    -            np.zeros((local_data_size,
    -                      self.data.target_calculator.feature_size))
    +        predicted_outputs = np.zeros(
    +            (local_data_size, self.data.target_calculator.feature_size)
    +        )
     
             # Only predict if there is something to predict.
             # Elsewise, we just wait at the barrier down below.
             if local_data_size > 0:
    -            optimal_batch_size = self.\
    -                _correct_batch_size_for_testing(local_data_size,
    -                                                self.parameters.mini_batch_size)
    +            optimal_batch_size = self._correct_batch_size_for_testing(
    +                local_data_size, self.parameters.mini_batch_size
    +            )
                 if optimal_batch_size != self.parameters.mini_batch_size:
    -                printout("Had to readjust batch size from",
    -                         self.parameters.mini_batch_size, "to",
    -                         optimal_batch_size, min_verbosity=0)
    +                printout(
    +                    "Had to readjust batch size from",
    +                    self.parameters.mini_batch_size,
    +                    "to",
    +                    optimal_batch_size,
    +                    min_verbosity=0,
    +                )
                     self.parameters.mini_batch_size = optimal_batch_size
     
    -            self.number_of_batches_per_snapshot = int(local_data_size /
    -                                                      self.parameters.
    -                                                      mini_batch_size)
    +            self.number_of_batches_per_snapshot = int(
    +                local_data_size / self.parameters.mini_batch_size
    +            )
     
                 for i in range(0, self.number_of_batches_per_snapshot):
    -                inputs = snap_descriptors[i * self.parameters.mini_batch_size:
    -                                          (i+1)*self.parameters.mini_batch_size]
    +                inputs = snap_descriptors[
    +                    i
    +                    * self.parameters.mini_batch_size : (i + 1)
    +                    * self.parameters.mini_batch_size
    +                ]
                     inputs = inputs.to(self.parameters._configuration["device"])
    -                predicted_outputs[i * self.parameters.mini_batch_size:
    -                                          (i+1)*self.parameters.mini_batch_size] \
    -                    = self.data.output_data_scaler.\
    -                    inverse_transform(self.network(inputs).
    -                                      to('cpu'), as_numpy=True)
    +                predicted_outputs[
    +                    i
    +                    * self.parameters.mini_batch_size : (i + 1)
    +                    * self.parameters.mini_batch_size
    +                ] = self.data.output_data_scaler.inverse_transform(
    +                    self.network(inputs).to("cpu"), as_numpy=True
    +                )
     
                 # Restricting the actual quantities to physical meaningful values,
                 # i.e. restricting the (L)DOS to positive values.
    -            predicted_outputs = self.data.target_calculator.\
    -                restrict_data(predicted_outputs)
    +            predicted_outputs = self.data.target_calculator.restrict_data(
    +                predicted_outputs
    +            )
             barrier()
             return predicted_outputs
    diff --git a/_modules/mala/network/runner.html b/_modules/mala/network/runner.html index 8fa99f37e..9cb8f58cc 100644 --- a/_modules/mala/network/runner.html +++ b/_modules/mala/network/runner.html @@ -75,6 +75,7 @@

    Source code for mala.network.runner

     """Runner class for running networks."""
    +
     import os
     from zipfile import ZipFile, ZIP_STORED
     
    @@ -118,8 +119,14 @@ 

    Source code for mala.network.runner

             self.data = data
             self.__prepare_to_run()
     
    -
    [docs] def save_run(self, run_name, save_path="./", zip_run=True, - save_runner=False, additional_calculation_data=None): +
    [docs] def save_run( + self, + run_name, + save_path="./", + zip_run=True, + save_runner=False, + additional_calculation_data=None, + ): """ Save the current run. @@ -154,44 +161,58 @@

    Source code for mala.network.runner

             oscaler_file = run_name + ".oscaler.pkl"
             params_file = run_name + ".params.json"
             if save_runner:
    -            optimizer_file = run_name+".optimizer.pth"
    +            optimizer_file = run_name + ".optimizer.pth"
     
             self.parameters_full.save(os.path.join(save_path, params_file))
             self.network.save_network(os.path.join(save_path, model_file))
             self.data.input_data_scaler.save(os.path.join(save_path, iscaler_file))
    -        self.data.output_data_scaler.save(os.path.join(save_path,
    -                                                       oscaler_file))
    +        self.data.output_data_scaler.save(
    +            os.path.join(save_path, oscaler_file)
    +        )
     
             files = [model_file, iscaler_file, oscaler_file, params_file]
             if save_runner:
                 files += [optimizer_file]
             if zip_run:
                 if additional_calculation_data is not None:
    -                additional_calculation_file = run_name+".info.json"
    +                additional_calculation_file = run_name + ".info.json"
                     if isinstance(additional_calculation_data, str):
    -                    self.data.target_calculator.\
    -                        read_additional_calculation_data(additional_calculation_data)
    -                    self.data.target_calculator.\
    -                        write_additional_calculation_data(os.path.join(save_path,
    -                                                          additional_calculation_file))
    +                    self.data.target_calculator.read_additional_calculation_data(
    +                        additional_calculation_data
    +                    )
    +                    self.data.target_calculator.write_additional_calculation_data(
    +                        os.path.join(save_path, additional_calculation_file)
    +                    )
                     elif isinstance(additional_calculation_data, bool):
                         if additional_calculation_data:
    -                        self.data.target_calculator. \
    -                            write_additional_calculation_data(os.path.join(save_path,
    -                                                              additional_calculation_file))
    +                        self.data.target_calculator.write_additional_calculation_data(
    +                            os.path.join(
    +                                save_path, additional_calculation_file
    +                            )
    +                        )
     
                     files.append(additional_calculation_file)
    -            with ZipFile(os.path.join(save_path, run_name+".zip"), 'w',
    -                         compression=ZIP_STORED) as zip_obj:
    +            with ZipFile(
    +                os.path.join(save_path, run_name + ".zip"),
    +                "w",
    +                compression=ZIP_STORED,
    +            ) as zip_obj:
                     for file in files:
                         zip_obj.write(os.path.join(save_path, file), file)
                         os.remove(os.path.join(save_path, file))
    [docs] @classmethod - def load_run(cls, run_name, path="./", zip_run=True, - params_format="json", load_runner=True, - prepare_data=False, load_with_mpi=None, - load_with_gpu=None): + def load_run( + cls, + run_name, + path="./", + zip_run=True, + params_format="json", + load_runner=True, + prepare_data=False, + load_with_mpi=None, + load_with_gpu=None, + ): """ Load a run. @@ -255,11 +276,11 @@

    Source code for mala.network.runner

                 loaded_network = run_name + ".network.pth"
                 loaded_iscaler = run_name + ".iscaler.pkl"
                 loaded_oscaler = run_name + ".oscaler.pkl"
    -            loaded_params = run_name + ".params."+params_format
    +            loaded_params = run_name + ".params." + params_format
                 loaded_info = run_name + ".info.json"
     
                 zip_path = os.path.join(path, run_name + ".zip")
    -            with ZipFile(zip_path, 'r') as zip_obj:
    +            with ZipFile(zip_path, "r") as zip_obj:
                     loaded_params = zip_obj.open(loaded_params)
                     loaded_network = zip_obj.open(loaded_network)
                     loaded_iscaler = zip_obj.open(loaded_iscaler)
    @@ -273,8 +294,9 @@ 

    Source code for mala.network.runner

                 loaded_network = os.path.join(path, run_name + ".network.pth")
                 loaded_iscaler = os.path.join(path, run_name + ".iscaler.pkl")
                 loaded_oscaler = os.path.join(path, run_name + ".oscaler.pkl")
    -            loaded_params = os.path.join(path, run_name +
    -                                         ".params."+params_format)
    +            loaded_params = os.path.join(
    +                path, run_name + ".params." + params_format
    +            )
     
             loaded_params = Parameters.load_from_json(loaded_params)
     
    @@ -284,36 +306,44 @@ 

    Source code for mala.network.runner

             if load_with_gpu is not None:
                 loaded_params.use_gpu = load_with_gpu
     
    -        loaded_network = Network.load_from_file(loaded_params,
    -                                                loaded_network)
    +        loaded_network = Network.load_from_file(loaded_params, loaded_network)
             loaded_iscaler = DataScaler.load_from_file(loaded_iscaler)
             loaded_oscaler = DataScaler.load_from_file(loaded_oscaler)
    -        new_datahandler = DataHandler(loaded_params,
    -                                      input_data_scaler=loaded_iscaler,
    -                                      output_data_scaler=loaded_oscaler,
    -                                      clear_data=(not prepare_data))
    +        new_datahandler = DataHandler(
    +            loaded_params,
    +            input_data_scaler=loaded_iscaler,
    +            output_data_scaler=loaded_oscaler,
    +            clear_data=(not prepare_data),
    +        )
             if loaded_info is not None:
    -            new_datahandler.target_calculator.\
    -                read_additional_calculation_data(loaded_info,
    -                                                 data_type="json")
    +            new_datahandler.target_calculator.read_additional_calculation_data(
    +                loaded_info, data_type="json"
    +            )
     
             if prepare_data:
                 new_datahandler.prepare_data(reparametrize_scaler=False)
     
             if load_runner:
                 if zip_run is True:
    -                with ZipFile(zip_path, 'r') as zip_obj:
    +                with ZipFile(zip_path, "r") as zip_obj:
                         loaded_runner = run_name + ".optimizer.pth"
                         if loaded_runner in zip_obj.namelist():
                             loaded_runner = zip_obj.open(loaded_runner)
                 else:
                     loaded_runner = os.path.join(run_name + ".optimizer.pth")
     
    -            loaded_runner = cls._load_from_run(loaded_params, loaded_network,
    -                                               new_datahandler,
    -                                               file=loaded_runner)
    -            return loaded_params, loaded_network, new_datahandler, \
    -                   loaded_runner
    +            loaded_runner = cls._load_from_run(
    +                loaded_params,
    +                loaded_network,
    +                new_datahandler,
    +                file=loaded_runner,
    +            )
    +            return (
    +                loaded_params,
    +                loaded_network,
    +                new_datahandler,
    +                loaded_runner,
    +            )
             else:
                 return loaded_params, loaded_network, new_datahandler
    @@ -341,14 +371,18 @@

    Source code for mala.network.runner

                 If True, the model exists.
             """
             if zip_run is True:
    -            return os.path.isfile(run_name+".zip")
    +            return os.path.isfile(run_name + ".zip")
             else:
                 network_name = run_name + ".network.pth"
                 iscaler_name = run_name + ".iscaler.pkl"
                 oscaler_name = run_name + ".oscaler.pkl"
    -            param_name = run_name + ".params."+params_format
    -            return all(map(os.path.isfile, [iscaler_name, oscaler_name, param_name,
    -                                            network_name]))
    + param_name = run_name + ".params." + params_format + return all( + map( + os.path.isfile, + [iscaler_name, oscaler_name, param_name, network_name], + ) + )
    @classmethod def _load_from_run(cls, params, network, data, file=None): @@ -357,10 +391,14 @@

    Source code for mala.network.runner

             loaded_runner = cls(params, network, data)
             return loaded_runner
     
    -    def _forward_entire_snapshot(self, snapshot_number, data_set,
    -                                 data_set_type,
    -                                 number_of_batches_per_snapshot=0,
    -                                 batch_size=0):
    +    def _forward_entire_snapshot(
    +        self,
    +        snapshot_number,
    +        data_set,
    +        data_set_type,
    +        number_of_batches_per_snapshot=0,
    +        batch_size=0,
    +    ):
             """
             Forward a snapshot through the network, get actual/predicted output.
     
    @@ -393,45 +431,45 @@ 

    Source code for mala.network.runner

             from_index = 0
             to_index = None
     
    -        for idx, snapshot in enumerate(self.data.parameters.
    -                                               snapshot_directories_list):
    +        for idx, snapshot in enumerate(
    +            self.data.parameters.snapshot_directories_list
    +        ):
                 if snapshot.snapshot_function == data_set_type:
                     if idx == snapshot_number:
                         to_index = from_index + snapshot.grid_size
                         break
                     else:
                         from_index += snapshot.grid_size
    -        grid_size = to_index-from_index
    +        grid_size = to_index - from_index
     
             if self.data.parameters.use_lazy_loading:
                 data_set.return_outputs_directly = True
    -            actual_outputs = \
    -                (data_set
    -                 [from_index:to_index])[1]
    +            actual_outputs = (data_set[from_index:to_index])[1]
             else:
    -            actual_outputs = \
    -                self.data.output_data_scaler.\
    -                inverse_transform(
    -                    (data_set[from_index:to_index])[1],
    -                    as_numpy=True)
    +            actual_outputs = self.data.output_data_scaler.inverse_transform(
    +                (data_set[from_index:to_index])[1], as_numpy=True
    +            )
     
    -        predicted_outputs = np.zeros((grid_size,
    -                                      self.data.output_dimension))
    +        predicted_outputs = np.zeros((grid_size, self.data.output_dimension))
     
             for i in range(0, number_of_batches_per_snapshot):
    -            inputs, outputs = \
    -                data_set[from_index+(i * batch_size):from_index+((i + 1)
    -                                                                 * batch_size)]
    +            inputs, outputs = data_set[
    +                from_index
    +                + (i * batch_size) : from_index
    +                + ((i + 1) * batch_size)
    +            ]
                 inputs = inputs.to(self.parameters._configuration["device"])
    -            predicted_outputs[i * batch_size:(i + 1) * batch_size, :] = \
    -                self.data.output_data_scaler.\
    -                inverse_transform(self.network(inputs).
    -                                  to('cpu'), as_numpy=True)
    +            predicted_outputs[i * batch_size : (i + 1) * batch_size, :] = (
    +                self.data.output_data_scaler.inverse_transform(
    +                    self.network(inputs).to("cpu"), as_numpy=True
    +                )
    +            )
     
             # Restricting the actual quantities to physical meaningful values,
             # i.e. restricting the (L)DOS to positive values.
    -        predicted_outputs = self.data.target_calculator.\
    -            restrict_data(predicted_outputs)
    +        predicted_outputs = self.data.target_calculator.restrict_data(
    +            predicted_outputs
    +        )
     
             # It could be that other operations will be happening with the data
             # set, so it's best to reset it.
    @@ -467,9 +505,16 @@ 

    Source code for mala.network.runner

                     # We cannot use "printout" here because this is supposed
                     # to happen on every rank.
                     if self.parameters_full.verbosity >= 2:
    -                    print("size=", hvd.size(), "global_rank=", hvd.rank(),
    -                          "local_rank=", hvd.local_rank(), "device=",
    -                          torch.cuda.get_device_name(hvd.local_rank()))
    +                    print(
    +                        "size=",
    +                        hvd.size(),
    +                        "global_rank=",
    +                        hvd.rank(),
    +                        "local_rank=",
    +                        hvd.local_rank(),
    +                        "device=",
    +                        torch.cuda.get_device_name(hvd.local_rank()),
    +                    )
                     # pin GPU to local rank
                     torch.cuda.set_device(hvd.local_rank())
    diff --git a/_modules/mala/network/tester.html b/_modules/mala/network/tester.html index 6417415db..7eea4df4b 100644 --- a/_modules/mala/network/tester.html +++ b/_modules/mala/network/tester.html @@ -75,11 +75,7 @@

    Source code for mala.network.tester

     """Tester class for testing a network."""
    -try:
    -    import horovod.torch as hvd
    -except ModuleNotFoundError:
    -    # Warning is thrown by Parameters class
    -    pass
    +
     import numpy as np
     
     from mala.common.parameters import printout
    @@ -127,8 +123,14 @@ 

    Source code for mala.network.tester

             will be calculated and returned.
         """
     
    -    def __init__(self, params, network, data, observables_to_test=["ldos"],
    -                 output_format="list"):
    +    def __init__(
    +        self,
    +        params,
    +        network,
    +        data,
    +        observables_to_test=["ldos"],
    +        output_format="list",
    +    ):
             # copy the parameters into the class.
             super(Tester, self).__init__(params, network, data)
             self.test_data_loader = None
    @@ -170,7 +172,7 @@ 

    Source code for mala.network.tester

             else:
                 raise Exception("Wrong output format for testing selected.")
    -
    [docs] def test_snapshot(self, snapshot_number, data_type='te'): +
    [docs] def test_snapshot(self, snapshot_number, data_type="te"): """ Test the selected observables for a single snapshot. @@ -187,23 +189,29 @@

    Source code for mala.network.tester

             results : dict
                 A dictionary containing the errors for the selected observables.
             """
    -        actual_outputs, predicted_outputs = \
    -            self.predict_targets(snapshot_number, data_type=data_type)
    +        actual_outputs, predicted_outputs = self.predict_targets(
    +            snapshot_number, data_type=data_type
    +        )
     
             results = {}
             for observable in self.observables_to_test:
                 try:
    -                results[observable] = self.\
    -                    __calculate_observable_error(snapshot_number,
    -                                                observable, predicted_outputs,
    -                                                actual_outputs)
    +                results[observable] = self.__calculate_observable_error(
    +                    snapshot_number,
    +                    observable,
    +                    predicted_outputs,
    +                    actual_outputs,
    +                )
                 except ValueError as e:
    -                printout(f"Error calculating observable: {observable} for snapshot {snapshot_number}",  min_verbosity=0)
    +                printout(
    +                    f"Error calculating observable: {observable} for snapshot {snapshot_number}",
    +                    min_verbosity=0,
    +                )
                     printout(e, min_verbosity=2)
                     results[observable] = np.inf
             return results
    -
    [docs] def predict_targets(self, snapshot_number, data_type='te'): +
    [docs] def predict_targets(self, snapshot_number, data_type="te"): """ Get actual and predicted output for a snapshot. @@ -211,7 +219,7 @@

    Source code for mala.network.tester

             ----------
             snapshot_number : int
                 Snapshot for which the prediction is done.
    -        
    +
             data_type : str
                 'tr', 'va', or 'te' indicating the partition to be tested
     
    @@ -228,40 +236,48 @@ 

    Source code for mala.network.tester

             # Make sure no data lingers in the target calculator.
             self.data.target_calculator.invalidate_target()
             # Select the inputs used for prediction
    -        if data_type == 'tr':
    +        if data_type == "tr":
                 offset_snapshots = 0
                 data_set = self.data.training_data_sets[0]
    -        elif data_type == 'va':
    +        elif data_type == "va":
                 offset_snapshots = self.data.nr_training_snapshots
                 data_set = self.data.validation_data_sets[0]
    -        elif data_type == 'te':
    -            offset_snapshots = self.data.nr_validation_snapshots + \
    -                               self.data.nr_training_snapshots
    +        elif data_type == "te":
    +            offset_snapshots = (
    +                self.data.nr_validation_snapshots
    +                + self.data.nr_training_snapshots
    +            )
                 data_set = self.data.test_data_sets[0]
             else:
    -            raise ValueError(f"Invalid data_type: {data_type} -- Valid options are tr, va, te.")
    +            raise ValueError(
    +                f"Invalid data_type: {data_type} -- Valid options are tr, va, te."
    +            )
             # Forward through network.
    -        return self.\
    -            _forward_entire_snapshot(offset_snapshots+snapshot_number,
    -                                     data_set,
    -                                     data_type,
    -                                     self.number_of_batches_per_snapshot,
    -                                     self.parameters.mini_batch_size)
    - - def __calculate_observable_error(self, snapshot_number, observable, - predicted_target, actual_target): + return self._forward_entire_snapshot( + offset_snapshots + snapshot_number, + data_set, + data_type, + self.number_of_batches_per_snapshot, + self.parameters.mini_batch_size, + )
    + + def __calculate_observable_error( + self, snapshot_number, observable, predicted_target, actual_target + ): if observable == "ldos": - return np.mean((predicted_target - actual_target)**2) + return np.mean((predicted_target - actual_target) ** 2) elif observable == "band_energy": target_calculator = self.data.target_calculator - if not isinstance(target_calculator, LDOS) and not \ - isinstance(target_calculator, DOS): - raise Exception("Cannot calculate the band energy from this " - "observable.") - target_calculator.\ - read_additional_calculation_data( - self.data.get_snapshot_calculation_output(snapshot_number)) + if not isinstance(target_calculator, LDOS) and not isinstance( + target_calculator, DOS + ): + raise Exception( + "Cannot calculate the band energy from this observable." + ) + target_calculator.read_additional_calculation_data( + self.data.get_snapshot_calculation_output(snapshot_number) + ) target_calculator.read_from_array(actual_target) actual = target_calculator.band_energy @@ -272,46 +288,58 @@

    Source code for mala.network.tester

     
             elif observable == "band_energy_full":
                 target_calculator = self.data.target_calculator
    -            if not isinstance(target_calculator, LDOS) and not \
    -                    isinstance(target_calculator, DOS):
    -                raise Exception("Cannot calculate the band energy from this "
    -                                "observable.")
    -            target_calculator.\
    -                read_additional_calculation_data(
    -                self.data.get_snapshot_calculation_output(snapshot_number))
    +            if not isinstance(target_calculator, LDOS) and not isinstance(
    +                target_calculator, DOS
    +            ):
    +                raise Exception(
    +                    "Cannot calculate the band energy from this observable."
    +                )
    +            target_calculator.read_additional_calculation_data(
    +                self.data.get_snapshot_calculation_output(snapshot_number)
    +            )
     
                 target_calculator.read_from_array(actual_target)
                 actual = target_calculator.band_energy
     
                 target_calculator.read_from_array(predicted_target)
                 predicted = target_calculator.band_energy
    -            return [actual, predicted,
    -                    target_calculator.band_energy_dft_calculation]
    +            return [
    +                actual,
    +                predicted,
    +                target_calculator.band_energy_dft_calculation,
    +            ]
     
             elif observable == "number_of_electrons":
                 target_calculator = self.data.target_calculator
    -            if not isinstance(target_calculator, LDOS) and not \
    -                    isinstance(target_calculator, DOS) and not \
    -                    isinstance(target_calculator, Density):
    -                raise Exception("Cannot calculate the band energy from this "
    -                                "observable.")
    -            target_calculator.\
    -                read_additional_calculation_data(
    -                self.data.get_snapshot_calculation_output(snapshot_number))
    +            if (
    +                not isinstance(target_calculator, LDOS)
    +                and not isinstance(target_calculator, DOS)
    +                and not isinstance(target_calculator, Density)
    +            ):
    +                raise Exception(
    +                    "Cannot calculate the band energy from this observable."
    +                )
    +            target_calculator.read_additional_calculation_data(
    +                self.data.get_snapshot_calculation_output(snapshot_number)
    +            )
     
                 actual = target_calculator.get_number_of_electrons(actual_target)
     
    -            predicted = target_calculator.get_number_of_electrons(predicted_target)
    +            predicted = target_calculator.get_number_of_electrons(
    +                predicted_target
    +            )
                 return actual - predicted
     
             elif observable == "total_energy":
                 target_calculator = self.data.target_calculator
                 if not isinstance(target_calculator, LDOS):
    -                raise Exception("Cannot calculate the total energy from this "
    -                                "observable.")
    -            target_calculator.\
    -                read_additional_calculation_data(
    -                self.data.get_snapshot_calculation_output(snapshot_number))
    +                raise Exception(
    +                    "Cannot calculate the total energy from this "
    +                    "observable."
    +                )
    +            target_calculator.read_additional_calculation_data(
    +                self.data.get_snapshot_calculation_output(snapshot_number)
    +            )
     
                 target_calculator.read_from_array(actual_target)
                 actual = target_calculator.total_energy
    @@ -323,29 +351,37 @@ 

    Source code for mala.network.tester

             elif observable == "total_energy_full":
                 target_calculator = self.data.target_calculator
                 if not isinstance(target_calculator, LDOS):
    -                raise Exception("Cannot calculate the total energy from this "
    -                                "observable.")
    -            target_calculator.\
    -                read_additional_calculation_data(
    -                self.data.get_snapshot_calculation_output(snapshot_number))
    +                raise Exception(
    +                    "Cannot calculate the total energy from this "
    +                    "observable."
    +                )
    +            target_calculator.read_additional_calculation_data(
    +                self.data.get_snapshot_calculation_output(snapshot_number)
    +            )
     
                 target_calculator.read_from_array(actual_target)
                 actual = target_calculator.total_energy
     
                 target_calculator.read_from_array(predicted_target)
                 predicted = target_calculator.total_energy
    -            return [actual, predicted,
    -                    target_calculator.total_energy_dft_calculation]
    +            return [
    +                actual,
    +                predicted,
    +                target_calculator.total_energy_dft_calculation,
    +            ]
     
             elif observable == "density":
                 target_calculator = self.data.target_calculator
    -            if not isinstance(target_calculator, LDOS) and \
    -                    not isinstance(target_calculator, Density):
    -                raise Exception("Cannot calculate the total energy from this "
    -                                "observable.")
    -            target_calculator.\
    -                read_additional_calculation_data(
    -                self.data.get_snapshot_calculation_output(snapshot_number))
    +            if not isinstance(target_calculator, LDOS) and not isinstance(
    +                target_calculator, Density
    +            ):
    +                raise Exception(
    +                    "Cannot calculate the total energy from this "
    +                    "observable."
    +                )
    +            target_calculator.read_additional_calculation_data(
    +                self.data.get_snapshot_calculation_output(snapshot_number)
    +            )
     
                 target_calculator.read_from_array(actual_target)
                 actual = target_calculator.density
    @@ -356,13 +392,16 @@ 

    Source code for mala.network.tester

     
             elif observable == "dos":
                 target_calculator = self.data.target_calculator
    -            if not isinstance(target_calculator, LDOS) and \
    -                    not isinstance(target_calculator, DOS):
    -                raise Exception("Cannot calculate the total energy from this "
    -                                "observable.")
    -            target_calculator.\
    -                read_additional_calculation_data(
    -                self.data.get_snapshot_calculation_output(snapshot_number))
    +            if not isinstance(target_calculator, LDOS) and not isinstance(
    +                target_calculator, DOS
    +            ):
    +                raise Exception(
    +                    "Cannot calculate the total energy from this "
    +                    "observable."
    +                )
    +            target_calculator.read_additional_calculation_data(
    +                self.data.get_snapshot_calculation_output(snapshot_number)
    +            )
     
                 # We shift both the actual and predicted DOS by 1.0 to overcome
                 # numerical issues with the DOS having values equal to zero.
    @@ -372,9 +411,15 @@ 

    Source code for mala.network.tester

                 target_calculator.read_from_array(predicted_target)
                 predicted = target_calculator.density_of_states + 1.0
     
    -            return np.ma.masked_invalid(np.abs((actual - predicted) /
    -                                               (np.abs(actual) +
    -                                                np.abs(predicted)))).mean() * 100
    +            return (
    +                np.ma.masked_invalid(
    +                    np.abs(
    +                        (actual - predicted)
    +                        / (np.abs(actual) + np.abs(predicted))
    +                    )
    +                ).mean()
    +                * 100
    +            )
     
         def __prepare_to_test(self, snapshot_number):
             """Prepare the tester class to for test run."""
    @@ -390,17 +435,21 @@ 

    Source code for mala.network.tester

                         break
                     test_snapshot += 1
     
    -        optimal_batch_size = self.\
    -            _correct_batch_size_for_testing(grid_size,
    -                                            self.parameters.mini_batch_size)
    +        optimal_batch_size = self._correct_batch_size_for_testing(
    +            grid_size, self.parameters.mini_batch_size
    +        )
             if optimal_batch_size != self.parameters.mini_batch_size:
    -            printout("Had to readjust batch size from",
    -                     self.parameters.mini_batch_size, "to",
    -                     optimal_batch_size, min_verbosity=0)
    +            printout(
    +                "Had to readjust batch size from",
    +                self.parameters.mini_batch_size,
    +                "to",
    +                optimal_batch_size,
    +                min_verbosity=0,
    +            )
                 self.parameters.mini_batch_size = optimal_batch_size
    -        self.number_of_batches_per_snapshot = int(grid_size /
    -                                                  self.parameters.
    -                                                  mini_batch_size)
    + self.number_of_batches_per_snapshot = int( + grid_size / self.parameters.mini_batch_size + )
    diff --git a/_modules/mala/network/trainer.html b/_modules/mala/network/trainer.html index 5ac4d97b7..e9b942158 100644 --- a/_modules/mala/network/trainer.html +++ b/_modules/mala/network/trainer.html @@ -75,6 +75,7 @@

    Source code for mala.network.trainer

     """Trainer class for training a network."""
    +
     import os
     import time
     from datetime import datetime
    @@ -92,13 +93,12 @@ 

    Source code for mala.network.trainer

     from torch.utils.tensorboard import SummaryWriter
     
     from mala.common.parameters import printout
    -from mala.common.parallelizer import parallel_warn
     from mala.datahandling.fast_tensor_dataset import FastTensorDataset
    -from mala.network.network import Network
     from mala.network.runner import Runner
     from mala.datahandling.lazy_load_dataset_single import LazyLoadDatasetSingle
    -from mala.datahandling.multi_lazy_load_data_loader import \
    -    MultiLazyLoadDataLoader
    +from mala.datahandling.multi_lazy_load_data_loader import (
    +    MultiLazyLoadDataLoader,
    +)
     
     
     
    [docs]class Trainer(Runner): @@ -149,17 +149,22 @@

    Source code for mala.network.trainer

                     os.makedirs(self.parameters.visualisation_dir)
                 if self.parameters.visualisation_dir_append_date:
                     date_time = datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
    -                self.full_visualization_path = \
    -                    os.path.join(self.parameters.visualisation_dir, date_time)
    +                self.full_visualization_path = os.path.join(
    +                    self.parameters.visualisation_dir, date_time
    +                )
                     os.makedirs(self.full_visualization_path)
                 else:
    -                self.full_visualization_path = \
    +                self.full_visualization_path = (
                         self.parameters.visualisation_dir
    +                )
     
                 # Set the path to log files
                 self.tensor_board = SummaryWriter(self.full_visualization_path)
    -            printout("Writing visualization output to",
    -                     self.full_visualization_path, min_verbosity=1)
    +            printout(
    +                "Writing visualization output to",
    +                self.full_visualization_path,
    +                min_verbosity=1,
    +            )
     
             self.gradscaler = None
             if self.parameters.use_mixed_precision:
    @@ -191,21 +196,36 @@ 

    Source code for mala.network.trainer

     
             """
             if zip_run is True:
    -            return os.path.isfile(run_name+".zip")
    +            return os.path.isfile(run_name + ".zip")
             else:
                 network_name = run_name + ".network.pth"
                 iscaler_name = run_name + ".iscaler.pkl"
                 oscaler_name = run_name + ".oscaler.pkl"
    -            param_name = run_name + ".params."+params_format
    +            param_name = run_name + ".params." + params_format
                 optimizer_name = run_name + ".optimizer.pth"
    -            return all(map(os.path.isfile, [iscaler_name, oscaler_name,
    -                                            param_name,
    -                                            network_name, optimizer_name]))
    + return all( + map( + os.path.isfile, + [ + iscaler_name, + oscaler_name, + param_name, + network_name, + optimizer_name, + ], + ) + )
    [docs] @classmethod - def load_run(cls, run_name, path="./", zip_run=True, - params_format="json", load_runner=True, - prepare_data=True): + def load_run( + cls, + run_name, + path="./", + zip_run=True, + params_format="json", + load_runner=True, + prepare_data=True, + ): """ Load a run. @@ -247,11 +267,14 @@

    Source code for mala.network.trainer

                 (Optional) The runner reconstructed from file. For Tester and
                 Predictor class, this is just a newly instantiated object.
             """
    -        return super(Trainer, cls).load_run(run_name, path=path,
    -                                            zip_run=zip_run,
    -                                            params_format=params_format,
    -                                            load_runner=load_runner,
    -                                            prepare_data=prepare_data)
    + return super(Trainer, cls).load_run( + run_name, + path=path, + zip_run=zip_run, + params_format=params_format, + load_runner=load_runner, + prepare_data=prepare_data, + )
    @classmethod def _load_from_run(cls, params, network, data, file=None): @@ -283,8 +306,9 @@

    Source code for mala.network.trainer

             checkpoint = torch.load(file)
     
             # Now, create the Trainer class with it.
    -        loaded_trainer = Trainer(params, network, data,
    -                                 optimizer_dict=checkpoint)
    +        loaded_trainer = Trainer(
    +            params, network, data, optimizer_dict=checkpoint
    +        )
             return loaded_trainer
     
     
    [docs] def train_network(self): @@ -294,30 +318,34 @@

    Source code for mala.network.trainer

             ############################
     
             tloss = float("inf")
    -        vloss = self.__validate_network(self.network,
    -                                        "validation",
    -                                        self.parameters.
    -                                        after_before_training_metric)
    +        vloss = self.__validate_network(
    +            self.network,
    +            "validation",
    +            self.parameters.after_before_training_metric,
    +        )
     
             if self.data.test_data_sets:
    -            tloss = self.__validate_network(self.network,
    -                                            "test",
    -                                            self.parameters.
    -                                            after_before_training_metric)
    +            tloss = self.__validate_network(
    +                self.network,
    +                "test",
    +                self.parameters.after_before_training_metric,
    +            )
     
             # Collect and average all the losses from all the devices
             if self.parameters_full.use_horovod:
    -            vloss = self.__average_validation(vloss, 'average_loss')
    +            vloss = self.__average_validation(vloss, "average_loss")
                 self.initial_validation_loss = vloss
                 if self.data.test_data_set is not None:
    -                tloss = self.__average_validation(tloss, 'average_loss')
    +                tloss = self.__average_validation(tloss, "average_loss")
                     self.initial_test_loss = tloss
     
    -        printout("Initial Guess - validation data loss: ", vloss,
    -                 min_verbosity=1)
    +        printout(
    +            "Initial Guess - validation data loss: ", vloss, min_verbosity=1
    +        )
             if self.data.test_data_sets:
    -            printout("Initial Guess - test data loss: ", tloss,
    -                     min_verbosity=1)
    +            printout(
    +                "Initial Guess - test data loss: ", tloss, min_verbosity=1
    +            )
     
             # Save losses for later use.
             self.initial_validation_loss = vloss
    @@ -344,7 +372,9 @@ 

    Source code for mala.network.trainer

                 self.network.train()
     
                 # Process each mini batch and save the training loss.
    -            training_loss_sum = torch.zeros(1, device=self.parameters._configuration["device"])
    +            training_loss_sum = torch.zeros(
    +                1, device=self.parameters._configuration["device"]
    +            )
     
                 # train sampler
                 if self.parameters_full.use_horovod:
    @@ -355,12 +385,14 @@ 

    Source code for mala.network.trainer

                     self.data.training_data_sets[0].shuffle()
     
                 if self.parameters._configuration["gpu"]:
    -                torch.cuda.synchronize(self.parameters._configuration["device"])
    +                torch.cuda.synchronize(
    +                    self.parameters._configuration["device"]
    +                )
                     tsample = time.time()
                     t0 = time.time()
                     batchid = 0
                     for loader in self.training_data_loaders:
    -                    for (inputs, outputs) in loader:
    +                    for inputs, outputs in loader:
     
                             if self.parameters.profiler_range is not None:
                                 if batchid == self.parameters.profiler_range[0]:
    @@ -371,147 +403,207 @@ 

    Source code for mala.network.trainer

                             torch.cuda.nvtx.range_push(f"step {batchid}")
     
                             torch.cuda.nvtx.range_push("data copy in")
    -                        inputs = inputs.to(self.parameters._configuration["device"],
    -                                           non_blocking=True)
    -                        outputs = outputs.to(self.parameters._configuration["device"],
    -                                             non_blocking=True)
    +                        inputs = inputs.to(
    +                            self.parameters._configuration["device"],
    +                            non_blocking=True,
    +                        )
    +                        outputs = outputs.to(
    +                            self.parameters._configuration["device"],
    +                            non_blocking=True,
    +                        )
                             # data copy in
                             torch.cuda.nvtx.range_pop()
     
    -                        loss = self.__process_mini_batch(self.network,
    -                                                         inputs,
    -                                                         outputs)
    +                        loss = self.__process_mini_batch(
    +                            self.network, inputs, outputs
    +                        )
                             # step
                             torch.cuda.nvtx.range_pop()
                             training_loss_sum += loss
     
    -                        if batchid != 0 and (batchid + 1) % self.parameters.training_report_frequency == 0:
    -                            torch.cuda.synchronize(self.parameters._configuration["device"])
    +                        if (
    +                            batchid != 0
    +                            and (batchid + 1)
    +                            % self.parameters.training_report_frequency
    +                            == 0
    +                        ):
    +                            torch.cuda.synchronize(
    +                                self.parameters._configuration["device"]
    +                            )
                                 sample_time = time.time() - tsample
    -                            avg_sample_time = sample_time / self.parameters.training_report_frequency
    -                            avg_sample_tput = self.parameters.training_report_frequency * inputs.shape[0] / sample_time
    -                            printout(f"batch {batchid + 1}, "#/{total_samples}, "
    -                                     f"train avg time: {avg_sample_time} "
    -                                     f"train avg throughput: {avg_sample_tput}",
    -                                     min_verbosity=2)
    +                            avg_sample_time = (
    +                                sample_time
    +                                / self.parameters.training_report_frequency
    +                            )
    +                            avg_sample_tput = (
    +                                self.parameters.training_report_frequency
    +                                * inputs.shape[0]
    +                                / sample_time
    +                            )
    +                            printout(
    +                                f"batch {batchid + 1}, "  # /{total_samples}, "
    +                                f"train avg time: {avg_sample_time} "
    +                                f"train avg throughput: {avg_sample_tput}",
    +                                min_verbosity=2,
    +                            )
                                 tsample = time.time()
                             batchid += 1
    -                torch.cuda.synchronize(self.parameters._configuration["device"])
    +                torch.cuda.synchronize(
    +                    self.parameters._configuration["device"]
    +                )
                     t1 = time.time()
                     printout(f"training time: {t1 - t0}", min_verbosity=2)
     
                     training_loss = training_loss_sum.item() / batchid
     
                     # Calculate the validation loss. and output it.
    -                torch.cuda.synchronize(self.parameters._configuration["device"])
    +                torch.cuda.synchronize(
    +                    self.parameters._configuration["device"]
    +                )
                 else:
                     batchid = 0
                     for loader in self.training_data_loaders:
    -                    for (inputs, outputs) in loader:
    +                    for inputs, outputs in loader:
                             inputs = inputs.to(
    -                            self.parameters._configuration["device"])
    +                            self.parameters._configuration["device"]
    +                        )
                             outputs = outputs.to(
    -                            self.parameters._configuration["device"])
    -                        training_loss_sum += self.__process_mini_batch(self.network, inputs, outputs)
    +                            self.parameters._configuration["device"]
    +                        )
    +                        training_loss_sum += self.__process_mini_batch(
    +                            self.network, inputs, outputs
    +                        )
                             batchid += 1
                     training_loss = training_loss_sum.item() / batchid
     
    -            vloss = self.__validate_network(self.network,
    -                                            "validation",
    -                                            self.parameters.
    -                                            during_training_metric)
    +            vloss = self.__validate_network(
    +                self.network,
    +                "validation",
    +                self.parameters.during_training_metric,
    +            )
     
                 if self.parameters_full.use_horovod:
    -                vloss = self.__average_validation(vloss, 'average_loss')
    +                vloss = self.__average_validation(vloss, "average_loss")
                 if self.parameters_full.verbosity > 1:
    -                printout("Epoch {0}: validation data loss: {1}, "
    -                         "training data loss: {2}".format(epoch, vloss,
    -                                                          training_loss),
    -                         min_verbosity=2)
    +                printout(
    +                    "Epoch {0}: validation data loss: {1}, "
    +                    "training data loss: {2}".format(
    +                        epoch, vloss, training_loss
    +                    ),
    +                    min_verbosity=2,
    +                )
                 else:
    -                printout("Epoch {0}: validation data loss: {1}".format(epoch,
    -                                                                       vloss),
    -                         min_verbosity=1)
    +                printout(
    +                    "Epoch {0}: validation data loss: {1}".format(
    +                        epoch, vloss
    +                    ),
    +                    min_verbosity=1,
    +                )
     
                 # summary_writer tensor board
                 if self.parameters.visualisation:
    -                self.tensor_board.add_scalars('Loss', {'validation': vloss,
    -                                              'training': training_loss},
    -                                              epoch)
    -                self.tensor_board.add_scalar("Learning rate",
    -                                             self.parameters.learning_rate,
    -                                             epoch)
    +                self.tensor_board.add_scalars(
    +                    "Loss",
    +                    {"validation": vloss, "training": training_loss},
    +                    epoch,
    +                )
    +                self.tensor_board.add_scalar(
    +                    "Learning rate", self.parameters.learning_rate, epoch
    +                )
                     if self.parameters.visualisation == 2:
                         for name, param in self.network.named_parameters():
                             self.tensor_board.add_histogram(name, param, epoch)
    -                        self.tensor_board.add_histogram(f'{name}.grad',
    -                                                        param.grad, epoch)
    +                        self.tensor_board.add_histogram(
    +                            f"{name}.grad", param.grad, epoch
    +                        )
     
                     # method to make sure that all pending events have been written
                     # to disk
                     self.tensor_board.close()
     
                 if self.parameters._configuration["gpu"]:
    -                torch.cuda.synchronize(self.parameters._configuration["device"])
    +                torch.cuda.synchronize(
    +                    self.parameters._configuration["device"]
    +                )
     
                 # Mix the DataSets up (this function only does something
                 # in the lazy loading case).
                 if self.parameters.use_shuffling_for_samplers:
                     self.data.mix_datasets()
                 if self.parameters._configuration["gpu"]:
    -                torch.cuda.synchronize(self.parameters._configuration["device"])
    +                torch.cuda.synchronize(
    +                    self.parameters._configuration["device"]
    +                )
     
                 # If a scheduler is used, update it.
                 if self.scheduler is not None:
    -                if self.parameters.learning_rate_scheduler ==\
    -                        "ReduceLROnPlateau":
    +                if (
    +                    self.parameters.learning_rate_scheduler
    +                    == "ReduceLROnPlateau"
    +                ):
                         self.scheduler.step(vloss)
     
                 # If early stopping is used, check if we need to do something.
                 if self.parameters.early_stopping_epochs > 0:
    -                if vloss < vloss_old * (1.0 - self.parameters.
    -                                        early_stopping_threshold):
    +                if vloss < vloss_old * (
    +                    1.0 - self.parameters.early_stopping_threshold
    +                ):
                         self.patience_counter = 0
                         vloss_old = vloss
                     else:
                         self.patience_counter += 1
    -                    printout("Validation accuracy has not improved "
    -                             "enough.", min_verbosity=1)
    -                    if self.patience_counter >= self.parameters.\
    -                            early_stopping_epochs:
    -                        printout("Stopping the training, validation "
    -                                 "accuracy has not improved for",
    -                                 self.patience_counter,
    -                                 "epochs.", min_verbosity=1)
    +                    printout(
    +                        "Validation accuracy has not improved enough.",
    +                        min_verbosity=1,
    +                    )
    +                    if (
    +                        self.patience_counter
    +                        >= self.parameters.early_stopping_epochs
    +                    ):
    +                        printout(
    +                            "Stopping the training, validation "
    +                            "accuracy has not improved for",
    +                            self.patience_counter,
    +                            "epochs.",
    +                            min_verbosity=1,
    +                        )
                             self.last_epoch = epoch
                             break
     
                 # If checkpointing is enabled, we need to checkpoint.
                 if self.parameters.checkpoints_each_epoch != 0:
                     checkpoint_counter += 1
    -                if checkpoint_counter >= \
    -                        self.parameters.checkpoints_each_epoch:
    +                if (
    +                    checkpoint_counter
    +                    >= self.parameters.checkpoints_each_epoch
    +                ):
                         printout("Checkpointing training.", min_verbosity=0)
                         self.last_epoch = epoch
                         self.last_loss = vloss_old
                         self.__create_training_checkpoint()
                         checkpoint_counter = 0
     
    -            printout("Time for epoch[s]:", time.time() - start_time,
    -                     min_verbosity=2)
    +            printout(
    +                "Time for epoch[s]:",
    +                time.time() - start_time,
    +                min_verbosity=2,
    +            )
     
             ############################
             # CALCULATE FINAL METRICS
             ############################
     
    -        if self.parameters.after_before_training_metric != \
    -                self.parameters.during_training_metric:
    -            vloss = self.__validate_network(self.network,
    -                                            "validation",
    -                                            self.parameters.
    -                                            after_before_training_metric)
    +        if (
    +            self.parameters.after_before_training_metric
    +            != self.parameters.during_training_metric
    +        ):
    +            vloss = self.__validate_network(
    +                self.network,
    +                "validation",
    +                self.parameters.after_before_training_metric,
    +            )
                 if self.parameters_full.use_horovod:
    -                vloss = self.__average_validation(vloss, 'average_loss')
    +                vloss = self.__average_validation(vloss, "average_loss")
     
             # Calculate final loss.
             self.final_validation_loss = vloss
    @@ -519,12 +611,13 @@ 

    Source code for mala.network.trainer

     
             tloss = float("inf")
             if len(self.data.test_data_sets) > 0:
    -            tloss = self.__validate_network(self.network,
    -                                            "test",
    -                                            self.parameters.
    -                                            after_before_training_metric)
    +            tloss = self.__validate_network(
    +                self.network,
    +                "test",
    +                self.parameters.after_before_training_metric,
    +            )
                 if self.parameters_full.use_horovod:
    -                tloss = self.__average_validation(tloss, 'average_loss')
    +                tloss = self.__average_validation(tloss, "average_loss")
                 printout("Final test data loss: ", tloss, min_verbosity=0)
             self.final_test_loss = tloss
     
    @@ -538,59 +631,74 @@ 

    Source code for mala.network.trainer

         def __prepare_to_train(self, optimizer_dict):
             """Prepare everything for training."""
             # Configure keyword arguments for DataSampler.
    -        kwargs = {'num_workers': self.parameters.num_workers,
    -                  'pin_memory': False}
    +        kwargs = {
    +            "num_workers": self.parameters.num_workers,
    +            "pin_memory": False,
    +        }
             if self.parameters_full.use_gpu:
    -            kwargs['pin_memory'] = True
    +            kwargs["pin_memory"] = True
     
             # Read last epoch
    -        if optimizer_dict is not None: 
    -            self.last_epoch = optimizer_dict['epoch']+1
    +        if optimizer_dict is not None:
    +            self.last_epoch = optimizer_dict["epoch"] + 1
     
             # Scale the learning rate according to horovod.
             if self.parameters_full.use_horovod:
                 if hvd.size() > 1 and self.last_epoch == 0:
    -                printout("Rescaling learning rate because multiple workers are"
    -                         " used for training.", min_verbosity=1)
    -                self.parameters.learning_rate = self.parameters.learning_rate \
    -                    * hvd.size()
    +                printout(
    +                    "Rescaling learning rate because multiple workers are"
    +                    " used for training.",
    +                    min_verbosity=1,
    +                )
    +                self.parameters.learning_rate = (
    +                    self.parameters.learning_rate * hvd.size()
    +                )
     
             # Choose an optimizer to use.
             if self.parameters.trainingtype == "SGD":
    -            self.optimizer = optim.SGD(self.network.parameters(),
    -                                      lr=self.parameters.learning_rate,
    -                                      weight_decay=self.parameters.
    -                                      weight_decay)
    +            self.optimizer = optim.SGD(
    +                self.network.parameters(),
    +                lr=self.parameters.learning_rate,
    +                weight_decay=self.parameters.weight_decay,
    +            )
             elif self.parameters.trainingtype == "Adam":
    -            self.optimizer = optim.Adam(self.network.parameters(),
    -                                        lr=self.parameters.learning_rate,
    -                                        weight_decay=self.parameters.
    -                                        weight_decay)
    +            self.optimizer = optim.Adam(
    +                self.network.parameters(),
    +                lr=self.parameters.learning_rate,
    +                weight_decay=self.parameters.weight_decay,
    +            )
             elif self.parameters.trainingtype == "FusedAdam":
                 if version.parse(torch.__version__) >= version.parse("1.13.0"):
    -                self.optimizer = optim.Adam(self.network.parameters(),
    -                                           lr=self.parameters.learning_rate,
    -                                           weight_decay=self.parameters.
    -                                           weight_decay, fused=True)
    +                self.optimizer = optim.Adam(
    +                    self.network.parameters(),
    +                    lr=self.parameters.learning_rate,
    +                    weight_decay=self.parameters.weight_decay,
    +                    fused=True,
    +                )
                 else:
    -                raise Exception("Training method requires "
    -                                "at least torch 1.13.0.")
    +                raise Exception(
    +                    "Training method requires at least torch 1.13.0."
    +                )
             else:
                 raise Exception("Unsupported training method.")
     
             # Load data from pytorch file.
             if optimizer_dict is not None:
    -            self.optimizer.\
    -                load_state_dict(optimizer_dict['optimizer_state_dict'])
    -            self.patience_counter = optimizer_dict['early_stopping_counter']
    -            self.last_loss = optimizer_dict['early_stopping_last_loss']
    +            self.optimizer.load_state_dict(
    +                optimizer_dict["optimizer_state_dict"]
    +            )
    +            self.patience_counter = optimizer_dict["early_stopping_counter"]
    +            self.last_loss = optimizer_dict["early_stopping_last_loss"]
     
             if self.parameters_full.use_horovod:
                 # scaling the batch size for multiGPU per node
                 # self.batch_size= self.batch_size*hvd.local_size()
     
    -            compression = hvd.Compression.fp16 if self.parameters_full.\
    -                running.use_compression else hvd.Compression.none
    +            compression = (
    +                hvd.Compression.fp16
    +                if self.parameters_full.running.use_compression
    +                else hvd.Compression.none
    +            )
     
                 # If lazy loading is used we do not shuffle the data points on
                 # their own, but rather shuffle them
    @@ -601,24 +709,33 @@ 

    Source code for mala.network.trainer

                 if self.data.parameters.use_lazy_loading:
                     do_shuffle = False
     
    -            self.train_sampler = torch.utils.data.\
    -                distributed.DistributedSampler(self.data.training_data_sets[0],
    -                                               num_replicas=hvd.size(),
    -                                               rank=hvd.rank(),
    -                                               shuffle=do_shuffle)
    -
    -            self.validation_sampler = torch.utils.data.\
    -                distributed.DistributedSampler(self.data.validation_data_sets[0],
    -                                               num_replicas=hvd.size(),
    -                                               rank=hvd.rank(),
    -                                               shuffle=False)
    +            self.train_sampler = (
    +                torch.utils.data.distributed.DistributedSampler(
    +                    self.data.training_data_sets[0],
    +                    num_replicas=hvd.size(),
    +                    rank=hvd.rank(),
    +                    shuffle=do_shuffle,
    +                )
    +            )
    +
    +            self.validation_sampler = (
    +                torch.utils.data.distributed.DistributedSampler(
    +                    self.data.validation_data_sets[0],
    +                    num_replicas=hvd.size(),
    +                    rank=hvd.rank(),
    +                    shuffle=False,
    +                )
    +            )
     
                 if self.data.test_data_sets:
    -                self.test_sampler = torch.utils.data.\
    -                    distributed.DistributedSampler(self.data.test_data_sets[0],
    -                                                   num_replicas=hvd.size(),
    -                                                   rank=hvd.rank(),
    -                                                   shuffle=False)
    +                self.test_sampler = (
    +                    torch.utils.data.distributed.DistributedSampler(
    +                        self.data.test_data_sets[0],
    +                        num_replicas=hvd.size(),
    +                        rank=hvd.rank(),
    +                        shuffle=False,
    +                    )
    +                )
     
                 # broadcaste parameters and optimizer state from root device to
                 # other devices
    @@ -626,30 +743,30 @@ 

    Source code for mala.network.trainer

                 hvd.broadcast_optimizer_state(self.optimizer, root_rank=0)
     
                 # Wraps the opimizer for multiGPU operation
    -            self.optimizer = hvd.DistributedOptimizer(self.optimizer,
    -                                                      named_parameters=
    -                                                      self.network.
    -                                                      named_parameters(),
    -                                                      compression=compression,
    -                                                      op=hvd.Average)
    +            self.optimizer = hvd.DistributedOptimizer(
    +                self.optimizer,
    +                named_parameters=self.network.named_parameters(),
    +                compression=compression,
    +                op=hvd.Average,
    +            )
     
             # Instantiate the learning rate scheduler, if necessary.
             if self.parameters.learning_rate_scheduler == "ReduceLROnPlateau":
    -            self.scheduler = optim.\
    -                lr_scheduler.ReduceLROnPlateau(self.optimizer,
    -                                               patience=self.parameters.
    -                                               learning_rate_patience,
    -                                               mode="min",
    -                                               factor=self.parameters.
    -                                               learning_rate_decay,
    -                                               verbose=True)
    +            self.scheduler = optim.lr_scheduler.ReduceLROnPlateau(
    +                self.optimizer,
    +                patience=self.parameters.learning_rate_patience,
    +                mode="min",
    +                factor=self.parameters.learning_rate_decay,
    +                verbose=True,
    +            )
             elif self.parameters.learning_rate_scheduler is None:
                 pass
             else:
                 raise Exception("Unsupported learning rate schedule.")
             if self.scheduler is not None and optimizer_dict is not None:
    -            self.scheduler.\
    -                load_state_dict(optimizer_dict['lr_scheduler_state_dict'])
    +            self.scheduler.load_state_dict(
    +                optimizer_dict["lr_scheduler_state_dict"]
    +            )
     
             # If lazy loading is used we do not shuffle the data points on their
             # own, but rather shuffle them
    @@ -657,56 +774,83 @@ 

    Source code for mala.network.trainer

             # epoch.
             # This shuffling is done in the dataset themselves.
             do_shuffle = self.parameters.use_shuffling_for_samplers
    -        if self.data.parameters.use_lazy_loading or self.parameters_full.\
    -                use_horovod:
    +        if (
    +            self.data.parameters.use_lazy_loading
    +            or self.parameters_full.use_horovod
    +        ):
                 do_shuffle = False
     
             # Prepare data loaders.(look into mini-batch size)
             if isinstance(self.data.training_data_sets[0], FastTensorDataset):
                 # Not shuffling in loader.
                 # I manually shuffle the data set each epoch.
    -            self.training_data_loaders.append(DataLoader(self.data.training_data_sets[0],
    -                                                         batch_size=None,
    -                                                         sampler=self.train_sampler,
    -                                                         **kwargs,
    -                                                         shuffle=False))
    +            self.training_data_loaders.append(
    +                DataLoader(
    +                    self.data.training_data_sets[0],
    +                    batch_size=None,
    +                    sampler=self.train_sampler,
    +                    **kwargs,
    +                    shuffle=False,
    +                )
    +            )
             else:
    -            if isinstance(self.data.training_data_sets[0], LazyLoadDatasetSingle):
    -                self.training_data_loaders = MultiLazyLoadDataLoader(self.data.training_data_sets, **kwargs)
    +            if isinstance(
    +                self.data.training_data_sets[0], LazyLoadDatasetSingle
    +            ):
    +                self.training_data_loaders = MultiLazyLoadDataLoader(
    +                    self.data.training_data_sets, **kwargs
    +                )
                 else:
    -                self.training_data_loaders.append(DataLoader(self.data.training_data_sets[0],
    -                                                             batch_size=self.parameters.
    -                                                             mini_batch_size,
    -                                                             sampler=self.train_sampler,
    -                                                             **kwargs,
    -                                                             shuffle=do_shuffle))
    +                self.training_data_loaders.append(
    +                    DataLoader(
    +                        self.data.training_data_sets[0],
    +                        batch_size=self.parameters.mini_batch_size,
    +                        sampler=self.train_sampler,
    +                        **kwargs,
    +                        shuffle=do_shuffle,
    +                    )
    +                )
     
             if isinstance(self.data.validation_data_sets[0], FastTensorDataset):
    -            self.validation_data_loaders.append(DataLoader(self.data.validation_data_sets[0],
    -                                                           batch_size=None,
    -                                                           sampler=
    -                                                           self.validation_sampler,
    -                                                           **kwargs))
    +            self.validation_data_loaders.append(
    +                DataLoader(
    +                    self.data.validation_data_sets[0],
    +                    batch_size=None,
    +                    sampler=self.validation_sampler,
    +                    **kwargs,
    +                )
    +            )
             else:
    -            if isinstance(self.data.validation_data_sets[0], LazyLoadDatasetSingle):
    -                self.validation_data_loaders = MultiLazyLoadDataLoader(self.data.validation_data_sets, **kwargs)
    +            if isinstance(
    +                self.data.validation_data_sets[0], LazyLoadDatasetSingle
    +            ):
    +                self.validation_data_loaders = MultiLazyLoadDataLoader(
    +                    self.data.validation_data_sets, **kwargs
    +                )
                 else:
    -                self.validation_data_loaders.append(DataLoader(self.data.validation_data_sets[0],
    -                                                               batch_size=self.parameters.
    -                                                               mini_batch_size * 1,
    -                                                               sampler=
    -                                                               self.validation_sampler,
    -                                                               **kwargs))
    +                self.validation_data_loaders.append(
    +                    DataLoader(
    +                        self.data.validation_data_sets[0],
    +                        batch_size=self.parameters.mini_batch_size * 1,
    +                        sampler=self.validation_sampler,
    +                        **kwargs,
    +                    )
    +                )
     
             if self.data.test_data_sets:
                 if isinstance(self.data.test_data_sets[0], LazyLoadDatasetSingle):
    -                self.test_data_loaders = MultiLazyLoadDataLoader(self.data.test_data_sets, **kwargs)
    +                self.test_data_loaders = MultiLazyLoadDataLoader(
    +                    self.data.test_data_sets, **kwargs
    +                )
                 else:
    -                self.test_data_loaders.append(DataLoader(self.data.test_data_sets[0],
    -                                                         batch_size=self.parameters.
    -                                                         mini_batch_size * 1,
    -                                                         sampler=self.test_sampler,
    -                                                         **kwargs))
    +                self.test_data_loaders.append(
    +                    DataLoader(
    +                        self.data.test_data_sets[0],
    +                        batch_size=self.parameters.mini_batch_size * 1,
    +                        sampler=self.test_sampler,
    +                        **kwargs,
    +                    )
    +                )
     
         def __process_mini_batch(self, network, input_data, target_data):
             """Process a mini batch."""
    @@ -714,21 +858,31 @@ 

    Source code for mala.network.trainer

                 if self.parameters.use_graphs and self.train_graph is None:
                     printout("Capturing CUDA graph for training.", min_verbosity=2)
                     s = torch.cuda.Stream(self.parameters._configuration["device"])
    -                s.wait_stream(torch.cuda.current_stream(self.parameters._configuration["device"]))
    +                s.wait_stream(
    +                    torch.cuda.current_stream(
    +                        self.parameters._configuration["device"]
    +                    )
    +                )
                     # Warmup for graphs
                     with torch.cuda.stream(s):
                         for _ in range(20):
                             self.network.zero_grad(set_to_none=True)
     
    -                        with torch.cuda.amp.autocast(enabled=self.parameters.use_mixed_precision):
    +                        with torch.cuda.amp.autocast(
    +                            enabled=self.parameters.use_mixed_precision
    +                        ):
                                 prediction = network(input_data)
    -                            loss = network.calculate_loss(prediction, target_data)
    +                            loss = network.calculate_loss(
    +                                prediction, target_data
    +                            )
     
                             if self.gradscaler:
                                 self.gradscaler.scale(loss).backward()
                             else:
                                 loss.backward()
    -                torch.cuda.current_stream(self.parameters._configuration["device"]).wait_stream(s)
    +                torch.cuda.current_stream(
    +                    self.parameters._configuration["device"]
    +                ).wait_stream(s)
     
                     # Create static entry point tensors to graph
                     self.static_input_data = torch.empty_like(input_data)
    @@ -738,10 +892,16 @@ 

    Source code for mala.network.trainer

                     self.train_graph = torch.cuda.CUDAGraph()
                     self.network.zero_grad(set_to_none=True)
                     with torch.cuda.graph(self.train_graph):
    -                    with torch.cuda.amp.autocast(enabled=self.parameters.use_mixed_precision):
    -                        self.static_prediction = network(self.static_input_data)
    +                    with torch.cuda.amp.autocast(
    +                        enabled=self.parameters.use_mixed_precision
    +                    ):
    +                        self.static_prediction = network(
    +                            self.static_input_data
    +                        )
     
    -                        self.static_loss = network.calculate_loss(self.static_prediction, self.static_target_data)
    +                        self.static_loss = network.calculate_loss(
    +                            self.static_prediction, self.static_target_data
    +                        )
     
                         if self.gradscaler:
                             self.gradscaler.scale(self.static_loss).backward()
    @@ -758,7 +918,9 @@ 

    Source code for mala.network.trainer

                     # zero_grad
                     torch.cuda.nvtx.range_pop()
     
    -                with torch.cuda.amp.autocast(enabled=self.parameters.use_mixed_precision):
    +                with torch.cuda.amp.autocast(
    +                    enabled=self.parameters.use_mixed_precision
    +                ):
                         torch.cuda.nvtx.range_push("forward")
                         prediction = network(input_data)
                         # forward
    @@ -780,7 +942,7 @@ 

    Source code for mala.network.trainer

                     self.gradscaler.update()
                 else:
                     self.optimizer.step()
    -            torch.cuda.nvtx.range_pop() # optimizer
    +            torch.cuda.nvtx.range_pop()  # optimizer
     
                 if self.train_graph:
                     return self.static_loss
    @@ -800,8 +962,10 @@ 

    Source code for mala.network.trainer

                 data_loaders = self.test_data_loaders
                 data_sets = self.data.test_data_sets
                 number_of_snapshots = self.data.nr_test_snapshots
    -            offset_snapshots = self.data.nr_validation_snapshots + \
    -                               self.data.nr_training_snapshots
    +            offset_snapshots = (
    +                self.data.nr_validation_snapshots
    +                + self.data.nr_training_snapshots
    +            )
     
             elif data_set_type == "validation":
                 data_loaders = self.validation_data_loaders
    @@ -810,168 +974,252 @@ 

    Source code for mala.network.trainer

                 offset_snapshots = self.data.nr_training_snapshots
     
             else:
    -            raise Exception("Please select test or validation"
    -                            "when using this function.")
    +            raise Exception(
    +                "Please select test or validation when using this function."
    +            )
             network.eval()
             if validation_type == "ldos":
    -            validation_loss_sum = torch.zeros(1, device=self.parameters.
    -                                              _configuration["device"])
    +            validation_loss_sum = torch.zeros(
    +                1, device=self.parameters._configuration["device"]
    +            )
                 with torch.no_grad():
                     if self.parameters._configuration["gpu"]:
                         report_freq = self.parameters.training_report_frequency
    -                    torch.cuda.synchronize(self.parameters._configuration["device"])
    +                    torch.cuda.synchronize(
    +                        self.parameters._configuration["device"]
    +                    )
                         tsample = time.time()
                         batchid = 0
                         for loader in data_loaders:
    -                        for (x, y) in loader:
    -                            x = x.to(self.parameters._configuration["device"],
    -                                     non_blocking=True)
    -                            y = y.to(self.parameters._configuration["device"],
    -                                     non_blocking=True)
    -
    -                            if self.parameters.use_graphs and self.validation_graph is None:
    -                                printout("Capturing CUDA graph for validation.", min_verbosity=2)
    -                                s = torch.cuda.Stream(self.parameters._configuration["device"])
    -                                s.wait_stream(torch.cuda.current_stream(self.parameters._configuration["device"]))
    +                        for x, y in loader:
    +                            x = x.to(
    +                                self.parameters._configuration["device"],
    +                                non_blocking=True,
    +                            )
    +                            y = y.to(
    +                                self.parameters._configuration["device"],
    +                                non_blocking=True,
    +                            )
    +
    +                            if (
    +                                self.parameters.use_graphs
    +                                and self.validation_graph is None
    +                            ):
    +                                printout(
    +                                    "Capturing CUDA graph for validation.",
    +                                    min_verbosity=2,
    +                                )
    +                                s = torch.cuda.Stream(
    +                                    self.parameters._configuration["device"]
    +                                )
    +                                s.wait_stream(
    +                                    torch.cuda.current_stream(
    +                                        self.parameters._configuration[
    +                                            "device"
    +                                        ]
    +                                    )
    +                                )
                                     # Warmup for graphs
                                     with torch.cuda.stream(s):
                                         for _ in range(20):
    -                                        with torch.cuda.amp.autocast(enabled=self.parameters.use_mixed_precision):
    +                                        with torch.cuda.amp.autocast(
    +                                            enabled=self.parameters.use_mixed_precision
    +                                        ):
                                                 prediction = network(x)
    -                                            loss = network.calculate_loss(prediction, y)
    -                                torch.cuda.current_stream(self.parameters._configuration["device"]).wait_stream(s)
    +                                            loss = network.calculate_loss(
    +                                                prediction, y
    +                                            )
    +                                torch.cuda.current_stream(
    +                                    self.parameters._configuration["device"]
    +                                ).wait_stream(s)
     
                                     # Create static entry point tensors to graph
    -                                self.static_input_validation = torch.empty_like(x)
    -                                self.static_target_validation = torch.empty_like(y)
    +                                self.static_input_validation = (
    +                                    torch.empty_like(x)
    +                                )
    +                                self.static_target_validation = (
    +                                    torch.empty_like(y)
    +                                )
     
                                     # Capture graph
                                     self.validation_graph = torch.cuda.CUDAGraph()
                                     with torch.cuda.graph(self.validation_graph):
    -                                    with torch.cuda.amp.autocast(enabled=self.parameters.use_mixed_precision):
    -                                        self.static_prediction_validation = network(self.static_input_validation)
    -                                        self.static_loss_validation = network.calculate_loss(self.static_prediction_validation, self.static_target_validation)
    +                                    with torch.cuda.amp.autocast(
    +                                        enabled=self.parameters.use_mixed_precision
    +                                    ):
    +                                        self.static_prediction_validation = (
    +                                            network(
    +                                                self.static_input_validation
    +                                            )
    +                                        )
    +                                        self.static_loss_validation = network.calculate_loss(
    +                                            self.static_prediction_validation,
    +                                            self.static_target_validation,
    +                                        )
     
                                 if self.validation_graph:
                                     self.static_input_validation.copy_(x)
                                     self.static_target_validation.copy_(y)
                                     self.validation_graph.replay()
    -                                validation_loss_sum += self.static_loss_validation
    +                                validation_loss_sum += (
    +                                    self.static_loss_validation
    +                                )
                                 else:
    -                                with torch.cuda.amp.autocast(enabled=self.parameters.use_mixed_precision):
    +                                with torch.cuda.amp.autocast(
    +                                    enabled=self.parameters.use_mixed_precision
    +                                ):
                                         prediction = network(x)
    -                                    loss = network.calculate_loss(prediction, y)
    +                                    loss = network.calculate_loss(
    +                                        prediction, y
    +                                    )
                                         validation_loss_sum += loss
    -                            if batchid != 0 and (batchid + 1) % report_freq == 0:
    -                                torch.cuda.synchronize(self.parameters._configuration["device"])
    +                            if (
    +                                batchid != 0
    +                                and (batchid + 1) % report_freq == 0
    +                            ):
    +                                torch.cuda.synchronize(
    +                                    self.parameters._configuration["device"]
    +                                )
                                     sample_time = time.time() - tsample
                                     avg_sample_time = sample_time / report_freq
    -                                avg_sample_tput = report_freq * x.shape[0] / sample_time
    -                                printout(f"batch {batchid + 1}, " #/{total_samples}, "
    -                                         f"validation avg time: {avg_sample_time} "
    -                                         f"validation avg throughput: {avg_sample_tput}",
    -                                         min_verbosity=2)
    +                                avg_sample_tput = (
    +                                    report_freq * x.shape[0] / sample_time
    +                                )
    +                                printout(
    +                                    f"batch {batchid + 1}, "  # /{total_samples}, "
    +                                    f"validation avg time: {avg_sample_time} "
    +                                    f"validation avg throughput: {avg_sample_tput}",
    +                                    min_verbosity=2,
    +                                )
                                     tsample = time.time()
                                 batchid += 1
    -                    torch.cuda.synchronize(self.parameters._configuration["device"])
    +                    torch.cuda.synchronize(
    +                        self.parameters._configuration["device"]
    +                    )
                     else:
                         batchid = 0
                         for loader in data_loaders:
    -                        for (x, y) in loader:
    +                        for x, y in loader:
                                 x = x.to(self.parameters._configuration["device"])
                                 y = y.to(self.parameters._configuration["device"])
                                 prediction = network(x)
    -                            validation_loss_sum += \
    -                                network.calculate_loss(prediction, y).item()
    +                            validation_loss_sum += network.calculate_loss(
    +                                prediction, y
    +                            ).item()
                                 batchid += 1
     
                 validation_loss = validation_loss_sum.item() / batchid
                 return validation_loss
    -        elif validation_type == "band_energy" or \
    -                validation_type == "total_energy":
    +        elif (
    +            validation_type == "band_energy"
    +            or validation_type == "total_energy"
    +        ):
                 errors = []
    -            if isinstance(self.validation_data_loaders,
    -                          MultiLazyLoadDataLoader):
    +            if isinstance(
    +                self.validation_data_loaders, MultiLazyLoadDataLoader
    +            ):
                     loader_id = 0
                     for loader in data_loaders:
    -                    grid_size = self.data.parameters. \
    -                        snapshot_directories_list[loader_id +
    -                                                  offset_snapshots].grid_size
    +                    grid_size = self.data.parameters.snapshot_directories_list[
    +                        loader_id + offset_snapshots
    +                    ].grid_size
     
                         actual_outputs = np.zeros(
    -                        (grid_size, self.data.output_dimension))
    +                        (grid_size, self.data.output_dimension)
    +                    )
                         predicted_outputs = np.zeros(
    -                        (grid_size, self.data.output_dimension))
    +                        (grid_size, self.data.output_dimension)
    +                    )
                         last_start = 0
     
    -                    for (x, y) in loader:
    +                    for x, y in loader:
     
                             x = x.to(self.parameters._configuration["device"])
                             length = int(x.size()[0])
    -                        predicted_outputs[last_start:last_start + length,
    -                        :] = \
    -                            self.data.output_data_scaler. \
    -                                inverse_transform(self.network(x).
    -                                                  to('cpu'), as_numpy=True)
    -                        actual_outputs[last_start:last_start + length, :] = \
    -                            self.data.output_data_scaler. \
    -                                inverse_transform(y, as_numpy=True)
    +                        predicted_outputs[
    +                            last_start : last_start + length, :
    +                        ] = self.data.output_data_scaler.inverse_transform(
    +                            self.network(x).to("cpu"), as_numpy=True
    +                        )
    +                        actual_outputs[last_start : last_start + length, :] = (
    +                            self.data.output_data_scaler.inverse_transform(
    +                                y, as_numpy=True
    +                            )
    +                        )
     
                             last_start += length
    -                    errors.append(self._calculate_energy_errors(actual_outputs,
    -                                                                predicted_outputs,
    -                                                                validation_type,
    -                                                                loader_id+offset_snapshots))
    +                    errors.append(
    +                        self._calculate_energy_errors(
    +                            actual_outputs,
    +                            predicted_outputs,
    +                            validation_type,
    +                            loader_id + offset_snapshots,
    +                        )
    +                    )
                         loader_id += 1
     
                 else:
    -                for snapshot_number in range(offset_snapshots,
    -                                             number_of_snapshots+offset_snapshots):
    +                for snapshot_number in range(
    +                    offset_snapshots, number_of_snapshots + offset_snapshots
    +                ):
                         # Get optimal batch size and number of batches per snapshotss
    -                    grid_size = self.data.parameters.\
    -                        snapshot_directories_list[snapshot_number].grid_size
    -
    -                    optimal_batch_size = self. \
    -                        _correct_batch_size_for_testing(grid_size,
    -                                                        self.parameters.
    -                                                        mini_batch_size)
    -                    number_of_batches_per_snapshot = int(grid_size /
    -                                                         optimal_batch_size)
    -
    -                    actual_outputs, \
    -                    predicted_outputs = self.\
    -                        _forward_entire_snapshot(snapshot_number,
    -                                                 data_sets[0], data_set_type[0:2],
    -                                                 number_of_batches_per_snapshot,
    -                                                 optimal_batch_size)
    -
    -                    errors.append(self._calculate_energy_errors(actual_outputs,
    -                                                                predicted_outputs,
    -                                                                validation_type,
    -                                                                snapshot_number))
    +                    grid_size = self.data.parameters.snapshot_directories_list[
    +                        snapshot_number
    +                    ].grid_size
    +
    +                    optimal_batch_size = self._correct_batch_size_for_testing(
    +                        grid_size, self.parameters.mini_batch_size
    +                    )
    +                    number_of_batches_per_snapshot = int(
    +                        grid_size / optimal_batch_size
    +                    )
    +
    +                    actual_outputs, predicted_outputs = (
    +                        self._forward_entire_snapshot(
    +                            snapshot_number,
    +                            data_sets[0],
    +                            data_set_type[0:2],
    +                            number_of_batches_per_snapshot,
    +                            optimal_batch_size,
    +                        )
    +                    )
    +
    +                    errors.append(
    +                        self._calculate_energy_errors(
    +                            actual_outputs,
    +                            predicted_outputs,
    +                            validation_type,
    +                            snapshot_number,
    +                        )
    +                    )
                 return np.mean(errors)
             else:
                 raise Exception("Selected validation method not supported.")
     
    -    def _calculate_energy_errors(self, actual_outputs, predicted_outputs,
    -                                 energy_type, snapshot_number):
    -        self.data.target_calculator.\
    -            read_additional_calculation_data(self.data.
    -                                             get_snapshot_calculation_output(snapshot_number))
    +    def _calculate_energy_errors(
    +        self, actual_outputs, predicted_outputs, energy_type, snapshot_number
    +    ):
    +        self.data.target_calculator.read_additional_calculation_data(
    +            self.data.get_snapshot_calculation_output(snapshot_number)
    +        )
             if energy_type == "band_energy":
                 try:
    -                fe_actual = self.data.target_calculator. \
    -                    get_self_consistent_fermi_energy(actual_outputs)
    -                be_actual = self.data.target_calculator. \
    -                    get_band_energy(actual_outputs, fermi_energy=fe_actual)
    -
    -                fe_predicted = self.data.target_calculator. \
    -                    get_self_consistent_fermi_energy(predicted_outputs)
    -                be_predicted = self.data.target_calculator. \
    -                    get_band_energy(predicted_outputs,
    -                                    fermi_energy=fe_predicted)
    -                return np.abs(be_predicted - be_actual) * \
    -                       (1000 / len(self.data.target_calculator.atoms))
    +                fe_actual = self.data.target_calculator.get_self_consistent_fermi_energy(
    +                    actual_outputs
    +                )
    +                be_actual = self.data.target_calculator.get_band_energy(
    +                    actual_outputs, fermi_energy=fe_actual
    +                )
    +
    +                fe_predicted = self.data.target_calculator.get_self_consistent_fermi_energy(
    +                    predicted_outputs
    +                )
    +                be_predicted = self.data.target_calculator.get_band_energy(
    +                    predicted_outputs, fermi_energy=fe_predicted
    +                )
    +                return np.abs(be_predicted - be_actual) * (
    +                    1000 / len(self.data.target_calculator.atoms)
    +                )
                 except ValueError:
                     # If the training went badly, it might be that the above
                     # code results in an error, due to the LDOS being so wrong
    @@ -980,19 +1228,22 @@ 

    Source code for mala.network.trainer

                     return float("inf")
             elif energy_type == "total_energy":
                 try:
    -                fe_actual = self.data.target_calculator. \
    -                    get_self_consistent_fermi_energy(actual_outputs)
    -                be_actual = self.data.target_calculator. \
    -                    get_total_energy(ldos_data=actual_outputs,
    -                                     fermi_energy=fe_actual)
    -
    -                fe_predicted = self.data.target_calculator. \
    -                    get_self_consistent_fermi_energy(predicted_outputs)
    -                be_predicted = self.data.target_calculator. \
    -                    get_total_energy(ldos_data=predicted_outputs,
    -                                    fermi_energy=fe_predicted)
    -                return np.abs(be_predicted - be_actual) * \
    -                       (1000 / len(self.data.target_calculator.atoms))
    +                fe_actual = self.data.target_calculator.get_self_consistent_fermi_energy(
    +                    actual_outputs
    +                )
    +                be_actual = self.data.target_calculator.get_total_energy(
    +                    ldos_data=actual_outputs, fermi_energy=fe_actual
    +                )
    +
    +                fe_predicted = self.data.target_calculator.get_self_consistent_fermi_energy(
    +                    predicted_outputs
    +                )
    +                be_predicted = self.data.target_calculator.get_total_energy(
    +                    ldos_data=predicted_outputs, fermi_energy=fe_predicted
    +                )
    +                return np.abs(be_predicted - be_actual) * (
    +                    1000 / len(self.data.target_calculator.atoms)
    +                )
                 except ValueError:
                     # If the training went badly, it might be that the above
                     # code results in an error, due to the LDOS being so wrong
    @@ -1003,7 +1254,6 @@ 

    Source code for mala.network.trainer

             else:
                 raise Exception("Invalid energy type requested.")
     
    -
         def __create_training_checkpoint(self):
             """
             Create a checkpoint during training.
    @@ -1011,8 +1261,7 @@ 

    Source code for mala.network.trainer

             Follows https://pytorch.org/tutorials/recipes/recipes/saving_and_
             loading_a_general_checkpoint.html to some degree.
             """
    -        optimizer_name = self.parameters.checkpoint_name \
    -            + ".optimizer.pth"
    +        optimizer_name = self.parameters.checkpoint_name + ".optimizer.pth"
     
             # Next, we save all the other objects.
     
    @@ -1021,21 +1270,22 @@ 

    Source code for mala.network.trainer

                     return
             if self.scheduler is None:
                 save_dict = {
    -                'epoch': self.last_epoch,
    -                'optimizer_state_dict': self.optimizer.state_dict(),
    -                'early_stopping_counter': self.patience_counter,
    -                'early_stopping_last_loss': self.last_loss
    +                "epoch": self.last_epoch,
    +                "optimizer_state_dict": self.optimizer.state_dict(),
    +                "early_stopping_counter": self.patience_counter,
    +                "early_stopping_last_loss": self.last_loss,
                 }
             else:
                 save_dict = {
    -                'epoch': self.last_epoch,
    -                'optimizer_state_dict': self.optimizer.state_dict(),
    -                'lr_scheduler_state_dict': self.scheduler.state_dict(),
    -                'early_stopping_counter': self.patience_counter,
    -                'early_stopping_last_loss': self.last_loss
    +                "epoch": self.last_epoch,
    +                "optimizer_state_dict": self.optimizer.state_dict(),
    +                "lr_scheduler_state_dict": self.scheduler.state_dict(),
    +                "early_stopping_counter": self.patience_counter,
    +                "early_stopping_last_loss": self.last_loss,
                 }
    -        torch.save(save_dict, optimizer_name,
    -                   _use_new_zipfile_serialization=False)
    +        torch.save(
    +            save_dict, optimizer_name, _use_new_zipfile_serialization=False
    +        )
     
             self.save_run(self.parameters.checkpoint_name, save_runner=True)
     
    diff --git a/_modules/mala/targets/atomic_force.html b/_modules/mala/targets/atomic_force.html
    index 23cfee767..f88a28ff9 100644
    --- a/_modules/mala/targets/atomic_force.html
    +++ b/_modules/mala/targets/atomic_force.html
    @@ -75,6 +75,7 @@
                  
       

    Source code for mala.targets.atomic_force

     """Electronic density calculation class."""
    +
     from ase.units import Rydberg, Bohr
     
     from .target import Target
    @@ -131,7 +132,7 @@ 

    Source code for mala.targets.atomic_force

             if in_units == "eV/Ang":
                 return array
             elif in_units == "Ry/Bohr":
    -            return array * (Rydberg/Bohr)
    +            return array * (Rydberg / Bohr)
             else:
                 raise Exception("Unsupported unit for atomic forces.")
    diff --git a/_modules/mala/targets/calculation_helpers.html b/_modules/mala/targets/calculation_helpers.html index 244aa2d2f..be33861e0 100644 --- a/_modules/mala/targets/calculation_helpers.html +++ b/_modules/mala/targets/calculation_helpers.html @@ -75,11 +75,12 @@

    Source code for mala.targets.calculation_helpers

     """Helper functions for several calculation tasks (such as integration)."""
    +
     from ase.units import kB
     import mpmath as mp
     import numpy as np
     from scipy import integrate
    -import sys
    +
     
     
    [docs]def integrate_values_on_spacing(values, spacing, method, axis=0): """ @@ -114,8 +115,7 @@

    Source code for mala.targets.calculation_helpers

    raise Exception("Unknown integration method.")
    -
    [docs]def fermi_function(energy, fermi_energy, temperature, - suppress_overflow=False): +
    [docs]def fermi_function(energy, fermi_energy, temperature, suppress_overflow=False): r""" Calculate the Fermi function. @@ -198,8 +198,9 @@

    Source code for mala.targets.calculation_helpers

    dim = np.shape(energy)[0] multiplicator = np.zeros(dim, dtype=np.float64) for i in range(0, np.shape(energy)[0]): - fermi_val = fermi_function(energy[i], fermi_energy, temperature, - suppress_overflow=True) + fermi_val = fermi_function( + energy[i], fermi_energy, temperature, suppress_overflow=True + ) if fermi_val == 1.0: secondterm = 0.0 else: @@ -210,8 +211,9 @@

    Source code for mala.targets.calculation_helpers

    firsterm = fermi_val * np.log(fermi_val) multiplicator[i] = firsterm + secondterm else: - fermi_val = fermi_function(energy, fermi_energy, temperature, - suppress_overflow=True) + fermi_val = fermi_function( + energy, fermi_energy, temperature, suppress_overflow=True + ) if fermi_val == 1.0: secondterm = 0.0 else: @@ -259,7 +261,7 @@

    Source code for mala.targets.calculation_helpers

    function_value : float F0 value. """ - results = (x+mp.polylog(1, -1.0*mp.exp(x)))/beta + results = (x + mp.polylog(1, -1.0 * mp.exp(x))) / beta return results
    @@ -280,8 +282,11 @@

    Source code for mala.targets.calculation_helpers

    function_value : float F1 value. """ - results = ((x*x)/2+x*mp.polylog(1, -1.0*mp.exp(x)) - - mp.polylog(2, -1.0*mp.exp(x))) / (beta*beta) + results = ( + (x * x) / 2 + + x * mp.polylog(1, -1.0 * mp.exp(x)) + - mp.polylog(2, -1.0 * mp.exp(x)) + ) / (beta * beta) return results
    @@ -302,9 +307,12 @@

    Source code for mala.targets.calculation_helpers

    function_value : float F2 value. """ - results = ((x*x*x)/3+x*x*mp.polylog(1, -1.0*mp.exp(x)) - - 2*x*mp.polylog(2, -1.0*mp.exp(x)) + - 2*mp.polylog(3, -1.0*mp.exp(x))) / (beta*beta*beta) + results = ( + (x * x * x) / 3 + + x * x * mp.polylog(1, -1.0 * mp.exp(x)) + - 2 * x * mp.polylog(2, -1.0 * mp.exp(x)) + + 2 * mp.polylog(3, -1.0 * mp.exp(x)) + ) / (beta * beta * beta) return results
    @@ -325,8 +333,10 @@

    Source code for mala.targets.calculation_helpers

    function_value : float S0 value. """ - results = (-1.0*x*mp.polylog(1, -1.0*mp.exp(x)) + - 2.0*mp.polylog(2, -1.0*mp.exp(x))) / (beta*beta) + results = ( + -1.0 * x * mp.polylog(1, -1.0 * mp.exp(x)) + + 2.0 * mp.polylog(2, -1.0 * mp.exp(x)) + ) / (beta * beta) return results
    @@ -347,9 +357,11 @@

    Source code for mala.targets.calculation_helpers

    function_value : float S1 value. """ - results = (-1.0*x*x*mp.polylog(1, -1.0*mp.exp(x)) + - 3*x*mp.polylog(2, -1.0*mp.exp(x)) - - 3*mp.polylog(3, -1.0*mp.exp(x))) / (beta*beta*beta) + results = ( + -1.0 * x * x * mp.polylog(1, -1.0 * mp.exp(x)) + + 3 * x * mp.polylog(2, -1.0 * mp.exp(x)) + - 3 * mp.polylog(3, -1.0 * mp.exp(x)) + ) / (beta * beta * beta) return results
    @@ -409,17 +421,20 @@

    Source code for mala.targets.calculation_helpers

    } # Check if everything makes sense. - if I0 not in list(function_mappings.keys()) or I1 not in\ - list(function_mappings.keys()): - raise Exception("Could not calculate analytical intergal, " - "wrong choice of auxiliary functions.") + if I0 not in list(function_mappings.keys()) or I1 not in list( + function_mappings.keys() + ): + raise Exception( + "Could not calculate analytical intergal, " + "wrong choice of auxiliary functions." + ) # Construct the weight vector. weights_vector = np.zeros(energy_grid.shape, dtype=np.float64) gridsize = energy_grid.shape[0] - energy_grid_edges = np.zeros(energy_grid.shape[0]+2, dtype=np.float64) + energy_grid_edges = np.zeros(energy_grid.shape[0] + 2, dtype=np.float64) energy_grid_edges[1:-1] = energy_grid - spacing = (energy_grid[1]-energy_grid[0]) + spacing = energy_grid[1] - energy_grid[0] energy_grid_edges[0] = energy_grid[0] - spacing energy_grid_edges[-1] = energy_grid[-1] + spacing @@ -430,14 +445,14 @@

    Source code for mala.targets.calculation_helpers

    beta = 1 / (kB * temperature) for i in range(0, gridsize): # Some aliases for readibility - ei = energy_grid_edges[i+1] - ei_plus = energy_grid_edges[i+2] + ei = energy_grid_edges[i + 1] + ei_plus = energy_grid_edges[i + 2] ei_minus = energy_grid_edges[i] # Calculate x - x = beta*(ei - fermi_energy) - x_plus = beta*(ei_plus - fermi_energy) - x_minus = beta*(ei_minus - fermi_energy) + x = beta * (ei - fermi_energy) + x_plus = beta * (ei_plus - fermi_energy) + x_minus = beta * (ei_minus - fermi_energy) # Calculate the I0 value i0 = function_mappings[I0](x, beta) @@ -449,11 +464,12 @@

    Source code for mala.targets.calculation_helpers

    i1_plus = function_mappings[I1](x_plus, beta) i1_minus = function_mappings[I1](x_minus, beta) - weights_vector[i] = (i0_plus-i0) * (1 + - ((ei - fermi_energy) / (ei_plus - ei))) \ - + (i0-i0_minus) * (1 - ((ei - fermi_energy) / (ei - ei_minus))) - \ - ((i1_plus-i1) / (ei_plus-ei)) + ((i1 - i1_minus) - / (ei - ei_minus)) + weights_vector[i] = ( + (i0_plus - i0) * (1 + ((ei - fermi_energy) / (ei_plus - ei))) + + (i0 - i0_minus) * (1 - ((ei - fermi_energy) / (ei - ei_minus))) + - ((i1_plus - i1) / (ei_plus - ei)) + + ((i1 - i1_minus) / (ei - ei_minus)) + ) integral_value = np.dot(D, weights_vector) return integral_value
    @@ -486,8 +502,13 @@

    Source code for mala.targets.calculation_helpers

    """ - multiple_gaussians = 1.0/np.sqrt(np.pi*sigma**2) * \ - np.exp(-1.0*((grid[np.newaxis] - centers[..., np.newaxis])/sigma)**2) + multiple_gaussians = ( + 1.0 + / np.sqrt(np.pi * sigma**2) + * np.exp( + -1.0 * ((grid[np.newaxis] - centers[..., np.newaxis]) / sigma) ** 2 + ) + ) return multiple_gaussians
    diff --git a/_modules/mala/targets/cube_parser.html b/_modules/mala/targets/cube_parser.html index a785c6d30..7127ca618 100644 --- a/_modules/mala/targets/cube_parser.html +++ b/_modules/mala/targets/cube_parser.html @@ -132,9 +132,10 @@

    Source code for mala.targets.cube_parser

     
     ------------------------------------------------------------------------------
     """
    +
     import numpy as np
     
    -if __name__ == '__main__':
    +if __name__ == "__main__":
         DEBUGMODE = True
     else:
         DEBUGMODE = False
    @@ -142,6 +143,8 @@ 

    Source code for mala.targets.cube_parser

     
     def _debug(*args):
         global DEBUGMODE
    +
    +
     #    if DEBUGMODE:
     #        print " ".join(map(str, args))
     
    @@ -152,7 +155,7 @@ 

    Source code for mala.targets.cube_parser

     
         Done by returning output in the correct format, matching the
         metadata of the source cube file and replacing volumetric
    -    data with static data provided as arg to the constructor. 
    +    data with static data provided as arg to the constructor.
         Doesn't copy atoms metadata, retains number of atoms, but
         returns dummy atoms
         Mimics file object's readline method.
    @@ -174,20 +177,24 @@ 

    Source code for mala.targets.cube_parser

             src.readline()
             src.readline()
             _debug(srcname)
    -        self.lines = [" Cubefile created by cubetools.py\n", 
    -                      "  source: {0}\n".format(srcname)]
    +        self.lines = [
    +            " Cubefile created by cubetools.py\n",
    +            "  source: {0}\n".format(srcname),
    +        ]
             self.lines.append(src.readline())  # read natm and origin
             self.natm = int(self.lines[-1].strip().split()[0])
             # read cube dim and vectors along 3 axes
             self.lines.extend(src.readline() for i in range(3))
             self.src.close()
    -        self.nx, self.ny, self.nz = [int(line.strip().split()[0])
    -                                     for line in self.lines[3:6]]
    +        self.nx, self.ny, self.nz = [
    +            int(line.strip().split()[0]) for line in self.lines[3:6]
    +        ]
             self.remvals = self.nz
    -        self.remrows = self.nx*self.ny
    +        self.remrows = self.nx * self.ny
             for i in range(self.natm):
    -            self.lines.append("{0:^ 8d}".format(1) + "{0:< 12.6f}".format(0)*4
    -                              + '\n')
    +            self.lines.append(
    +                "{0:^ 8d}".format(1) + "{0:< 12.6f}".format(0) * 4 + "\n"
    +            )
     
         def __del__(self):
             """Close Cube file."""
    @@ -212,11 +219,11 @@ 

    Source code for mala.targets.cube_parser

                 if self.remvals <= 6:
                     nval = min(6, self.remvals)
                     self.remrows -= 1
    -                self.remvals = self.nz 
    +                self.remvals = self.nz
                 else:
                     nval = 6
                     self.remvals -= nval
    -            return " {0: .5E}".format(self.const)*nval + "\n"
    +            return " {0: .5E}".format(self.const) * nval + "\n"
             else:
                 self.cursor += 1
                 return retval
    @@ -227,7 +234,7 @@

    Source code for mala.targets.cube_parser

         Read a line from cube file.
     
         First field is an int and the remaining fields are floats.
    -    
    +
         Parameters
         ----------
         cube : TextIO
    @@ -266,7 +273,7 @@ 

    Source code for mala.targets.cube_parser

     
    [docs]def read_cube(fname): """ Read cube file into numpy array. - + Parameters ---------- fname : string @@ -278,19 +285,19 @@

    Source code for mala.targets.cube_parser

             Data from cube file.
     
         meta : dict
    -        Meta data from cube file.
    +        Metadata from cube file.
         """
         meta = {}
    -    with open(fname, 'r') as cube:
    +    with open(fname, "r") as cube:
             # ignore comments
             cube.readline()
             cube.readline()
    -        natm, meta['org'] = _getline(cube)
    -        nx, meta['xvec'] = _getline(cube)
    -        ny, meta['yvec'] = _getline(cube)
    -        nz, meta['zvec'] = _getline(cube)
    -        meta['atoms'] = [_getline(cube) for i in range(natm)]
    -        data = np.zeros((nx*ny*nz))
    +        natm, meta["org"] = _getline(cube)
    +        nx, meta["xvec"] = _getline(cube)
    +        ny, meta["yvec"] = _getline(cube)
    +        nz, meta["zvec"] = _getline(cube)
    +        meta["atoms"] = [_getline(cube) for i in range(natm)]
    +        data = np.zeros((nx * ny * nz))
             idx = 0
             for line in cube:
                 for val in line.strip().split():
    @@ -306,7 +313,7 @@ 

    Source code for mala.targets.cube_parser

     
         One contains the real part and the other contains the
         imag part. If only one filename given, other filename is inferred.
    -    
    +
         params:
     
         returns: np.array (real part + j*imag part)
    @@ -327,14 +334,14 @@ 

    Source code for mala.targets.cube_parser

         meta : dict
             Meta data from cube file.
         """
    -    ifname = ifname or rfname.replace('real', 'imag')
    +    ifname = ifname or rfname.replace("real", "imag")
         _debug("reading from files", rfname, "and", ifname)
         re, im = read_cube(rfname), read_cube(ifname)
    -    fin = np.zeros(re[0].shape, dtype='complex128')
    +    fin = np.zeros(re[0].shape, dtype="complex128")
         if re[1] != im[1]:
             _debug("warning: meta data mismatch, real part metadata retained")
    -    fin += re[0] 
    -    fin += 1j*im[0]
    +    fin += re[0]
    +    fin += 1j * im[0]
         return fin, re[1]
    @@ -360,14 +367,14 @@

    Source code for mala.targets.cube_parser

         with open(fname, "w") as cube:
             # first two lines are comments
             cube.write(" Cubefile created by cubetools.py\n  source: none\n")
    -        natm = len(meta['atoms'])
    +        natm = len(meta["atoms"])
             nx, ny, nz = data.shape
    -        cube.write(_putline(natm, *meta['org']))  # 3rd line #atoms and origin
    -        cube.write(_putline(nx, *meta['xvec']))
    -        cube.write(_putline(ny, *meta['yvec']))
    -        cube.write(_putline(nz, *meta['zvec']))
    -        for atom_mass, atom_pos in meta['atoms']:
    -            cube.write(_putline(atom_mass, *atom_pos))    # skip the newline
    +        cube.write(_putline(natm, *meta["org"]))  # 3rd line #atoms and origin
    +        cube.write(_putline(nx, *meta["xvec"]))
    +        cube.write(_putline(ny, *meta["yvec"]))
    +        cube.write(_putline(nz, *meta["zvec"]))
    +        for atom_mass, atom_pos in meta["atoms"]:
    +            cube.write(_putline(atom_mass, *atom_pos))  # skip the newline
             for i in range(nx):
                 for j in range(ny):
                     for k in range(nz):
    @@ -402,7 +409,7 @@ 

    Source code for mala.targets.cube_parser

         ifname: string
             optional, filename of cube file containing imag part
         """
    -    ifname = ifname or rfname.replace('real', 'imag')
    +    ifname = ifname or rfname.replace("real", "imag")
         _debug("writing data to files", rfname, "and", ifname)
         write_cube(data.real, meta, rfname)
         write_cube(data.imag, meta, ifname)
    diff --git a/_modules/mala/targets/density.html b/_modules/mala/targets/density.html index 50c72a2fd..e6e725524 100644 --- a/_modules/mala/targets/density.html +++ b/_modules/mala/targets/density.html @@ -75,21 +75,25 @@

    Source code for mala.targets.density

     """Electronic density calculation class."""
    -import os
    +
     import time
     
    -import ase.io
     from ase.units import Rydberg, Bohr, m
     from functools import cached_property
     import numpy as np
    +
     try:
         import total_energy as te
     except ModuleNotFoundError:
         pass
     
    -from mala.common.parallelizer import printout, parallel_warn, barrier, get_size
    +from mala.common.parallelizer import (
    +    printout,
    +    parallel_warn,
    +    barrier,
    +    get_size,
    +)
     from mala.targets.target import Target
    -from mala.targets.calculation_helpers import integrate_values_on_spacing
     from mala.targets.cube_parser import read_cube, write_cube
     from mala.targets.calculation_helpers import integrate_values_on_spacing
     from mala.targets.xsf_parser import read_xsf
    @@ -269,20 +273,25 @@ 

    Source code for mala.targets.density

             return_density_object.fermi_energy_dft = ldos_object.fermi_energy_dft
             return_density_object.temperature = ldos_object.temperature
             return_density_object.voxel = ldos_object.voxel
    -        return_density_object.number_of_electrons_exact = ldos_object.\
    -            number_of_electrons_exact
    -        return_density_object.band_energy_dft_calculation = ldos_object.\
    -            band_energy_dft_calculation
    +        return_density_object.number_of_electrons_exact = (
    +            ldos_object.number_of_electrons_exact
    +        )
    +        return_density_object.band_energy_dft_calculation = (
    +            ldos_object.band_energy_dft_calculation
    +        )
             return_density_object.grid_dimensions = ldos_object.grid_dimensions
             return_density_object.atoms = ldos_object.atoms
             return_density_object.qe_input_data = ldos_object.qe_input_data
    -        return_density_object.qe_pseudopotentials = ldos_object.\
    -            qe_pseudopotentials
    -        return_density_object.total_energy_dft_calculation = \
    +        return_density_object.qe_pseudopotentials = (
    +            ldos_object.qe_pseudopotentials
    +        )
    +        return_density_object.total_energy_dft_calculation = (
                 ldos_object.total_energy_dft_calculation
    +        )
             return_density_object.kpoints = ldos_object.kpoints
    -        return_density_object.number_of_electrons_from_eigenvals = \
    +        return_density_object.number_of_electrons_from_eigenvals = (
                 ldos_object.number_of_electrons_from_eigenvals
    +        )
             return_density_object.local_grid = ldos_object.local_grid
             return_density_object._parameters_full = ldos_object._parameters_full
             return_density_object.y_planes = ldos_object.y_planes
    @@ -365,8 +374,9 @@ 

    Source code for mala.targets.density

             if self.density is not None:
                 return self.get_number_of_electrons()
             else:
    -            raise Exception("No cached density available to "
    -                            "calculate this property.")
    +            raise Exception(
    +                "No cached density available to calculate this property."
    +            )
     
         @cached_property
         def total_energy_contributions(self):
    @@ -378,8 +388,9 @@ 

    Source code for mala.targets.density

             if self.density is not None:
                 return self.get_energy_contributions()
             else:
    -            raise Exception("No cached density available to "
    -                            "calculate this property.")
    +            raise Exception(
    +                "No cached density available to calculate this property."
    +            )
     
     
    [docs] def uncache_properties(self): """Uncache all cached properties of this calculator.""" @@ -422,7 +433,7 @@

    Source code for mala.targets.density

             if in_units == "1/A^3" or in_units is None:
                 return array
             elif in_units == "1/Bohr^3":
    -            return array * (1/Bohr) * (1/Bohr) * (1/Bohr)
    +            return array * (1 / Bohr) * (1 / Bohr) * (1 / Bohr)
             else:
                 raise Exception("Unsupported unit for density.")
    @@ -488,7 +499,7 @@

    Source code for mala.targets.density

                 Units the density is saved in. Usually none.
             """
             printout("Reading density from .cube file ", path, min_verbosity=0)
    -        data, meta = read_xsf(path)*self.convert_units(1, in_units=units)
    +        data, meta = read_xsf(path) * self.convert_units(1, in_units=units)
             self.density = data
             return data
    @@ -508,9 +519,13 @@

    Source code for mala.targets.density

             self.density = array
             return array
    -
    [docs] def write_to_openpmd_file(self, path, array=None, - additional_attributes={}, - internal_iteration_number=0): +
    [docs] def write_to_openpmd_file( + self, + path, + array=None, + additional_attributes={}, + internal_iteration_number=0, + ): """ Write data to a numpy file. @@ -533,25 +548,27 @@

    Source code for mala.targets.density

             """
             if array is None:
                 if len(self.density.shape) == 2:
    -                super(Target, self).\
    -                    write_to_openpmd_file(path, np.reshape(self.density,
    -                                                           self.grid_dimensions
    -                                                           + [1]),
    -                                          internal_iteration_number=
    -                                          internal_iteration_number)
    +                super(Target, self).write_to_openpmd_file(
    +                    path,
    +                    np.reshape(self.density, self.grid_dimensions + [1]),
    +                    internal_iteration_number=internal_iteration_number,
    +                )
                 elif len(self.density.shape) == 4:
    -                super(Target, self).\
    -                    write_to_openpmd_file(path, self.density,
    -                                          internal_iteration_number=
    -                                          internal_iteration_number)
    +                super(Target, self).write_to_openpmd_file(
    +                    path,
    +                    self.density,
    +                    internal_iteration_number=internal_iteration_number,
    +                )
             else:
    -            super(Target, self).\
    -                write_to_openpmd_file(path, array,
    -                                      internal_iteration_number=
    -                                      internal_iteration_number)
    - -
    [docs] def write_to_cube(self, file_name, density_data=None, atoms=None, - grid_dimensions=None): + super(Target, self).write_to_openpmd_file( + path, + array, + internal_iteration_number=internal_iteration_number, + )
    + +
    [docs] def write_to_cube( + self, file_name, density_data=None, atoms=None, grid_dimensions=None + ): """ Write the density data in a cube file. @@ -573,10 +590,12 @@

    Source code for mala.targets.density

             """
             if density_data is not None:
                 if grid_dimensions is None or atoms is None:
    -                raise Exception("No grid or atom data provided. "
    -                                "Please note that these are only optional "
    -                                "if the density saved in the calculator is "
    -                                "used and have to be provided otherwise.")
    +                raise Exception(
    +                    "No grid or atom data provided. "
    +                    "Please note that these are only optional "
    +                    "if the density saved in the calculator is "
    +                    "used and have to be provided otherwise."
    +                )
             else:
                 density_data = self.density
                 grid_dimensions = self.grid_dimensions
    @@ -591,7 +610,14 @@ 

    Source code for mala.targets.density

             atom_list = []
             for i in range(0, len(atoms)):
                 atom_list.append(
    -                (atoms[i].number, [4.0, ] + list(atoms[i].position / Bohr)))
    +                (
    +                    atoms[i].number,
    +                    [
    +                        4.0,
    +                    ]
    +                    + list(atoms[i].position / Bohr),
    +                )
    +            )
     
             meta["atoms"] = atom_list
             meta["org"] = [0.0, 0.0, 0.0]
    @@ -603,8 +629,9 @@ 

    Source code for mala.targets.density

         # Calculations
         ##############
     
    -
    [docs] def get_number_of_electrons(self, density_data=None, voxel=None, - integration_method="summation"): +
    [docs] def get_number_of_electrons( + self, density_data=None, voxel=None, integration_method="summation" + ): """ Calculate the number of electrons from given density data. @@ -631,8 +658,10 @@

    Source code for mala.targets.density

             if density_data is None:
                 density_data = self.density
                 if density_data is None:
    -                raise Exception("No density data provided, cannot calculate"
    -                                " this quantity.")
    +                raise Exception(
    +                    "No density data provided, cannot calculate"
    +                    " this quantity."
    +                )
     
             if voxel is None:
                 voxel = self.voxel
    @@ -641,11 +670,15 @@ 

    Source code for mala.targets.density

             data_shape = np.shape(density_data)
             if len(data_shape) != 4:
                 if len(data_shape) != 2:
    -                raise Exception("Unknown Density shape, cannot calculate "
    -                                "number of electrons.")
    +                raise Exception(
    +                    "Unknown Density shape, cannot calculate "
    +                    "number of electrons."
    +                )
                 elif integration_method != "summation":
    -                raise Exception("If using a 1D density array, you can only"
    -                                " use summation as integration method.")
    +                raise Exception(
    +                    "If using a 1D density array, you can only"
    +                    " use summation as integration method."
    +                )
     
             # We integrate along the three axis in space.
             # If there is only one point in a certain direction we do not
    @@ -662,47 +695,60 @@ 

    Source code for mala.targets.density

     
                 # X
                 if data_shape[0] > 1:
    -                number_of_electrons = \
    -                    integrate_values_on_spacing(number_of_electrons,
    -                                                grid_spacing_bohr_x, axis=0,
    -                                                method=integration_method)
    +                number_of_electrons = integrate_values_on_spacing(
    +                    number_of_electrons,
    +                    grid_spacing_bohr_x,
    +                    axis=0,
    +                    method=integration_method,
    +                )
                 else:
    -                number_of_electrons =\
    -                    np.reshape(number_of_electrons, (data_shape[1],
    -                                                     data_shape[2]))
    +                number_of_electrons = np.reshape(
    +                    number_of_electrons, (data_shape[1], data_shape[2])
    +                )
                     number_of_electrons *= grid_spacing_bohr_x
     
                 # Y
                 if data_shape[1] > 1:
    -                number_of_electrons = \
    -                    integrate_values_on_spacing(number_of_electrons,
    -                                                grid_spacing_bohr_y, axis=0,
    -                                                method=integration_method)
    +                number_of_electrons = integrate_values_on_spacing(
    +                    number_of_electrons,
    +                    grid_spacing_bohr_y,
    +                    axis=0,
    +                    method=integration_method,
    +                )
                 else:
    -                number_of_electrons = \
    -                    np.reshape(number_of_electrons, (data_shape[2]))
    +                number_of_electrons = np.reshape(
    +                    number_of_electrons, (data_shape[2])
    +                )
                     number_of_electrons *= grid_spacing_bohr_y
     
                 # Z
                 if data_shape[2] > 1:
    -                number_of_electrons = \
    -                    integrate_values_on_spacing(number_of_electrons,
    -                                                grid_spacing_bohr_z, axis=0,
    -                                                method=integration_method)
    +                number_of_electrons = integrate_values_on_spacing(
    +                    number_of_electrons,
    +                    grid_spacing_bohr_z,
    +                    axis=0,
    +                    method=integration_method,
    +                )
                 else:
                     number_of_electrons *= grid_spacing_bohr_z
             else:
                 if len(data_shape) == 4:
    -                number_of_electrons = np.sum(density_data, axis=(0, 1, 2)) \
    -                                      * voxel.volume
    +                number_of_electrons = (
    +                    np.sum(density_data, axis=(0, 1, 2)) * voxel.volume
    +                )
                 if len(data_shape) == 2:
    -                number_of_electrons = np.sum(density_data, axis=0) * \
    -                                      voxel.volume
    +                number_of_electrons = (
    +                    np.sum(density_data, axis=0) * voxel.volume
    +                )
     
             return np.squeeze(number_of_electrons)
    -
    [docs] def get_density(self, density_data=None, convert_to_threedimensional=False, - grid_dimensions=None): +
    [docs] def get_density( + self, + density_data=None, + convert_to_threedimensional=False, + grid_dimensions=None, + ): """ Get the electronic density, based on density data. @@ -748,23 +794,33 @@

    Source code for mala.targets.density

                         #                                   last_y-first_y,
                         #                                   last_z-first_z],
                         #                                  dtype=np.float64)
    -                    density_data = \
    -                        np.reshape(density_data,
    -                                   [last_z - first_z, last_y - first_y,
    -                                    last_x - first_x, 1]).transpose([2, 1, 0, 3])
    +                    density_data = np.reshape(
    +                        density_data,
    +                        [
    +                            last_z - first_z,
    +                            last_y - first_y,
    +                            last_x - first_x,
    +                            1,
    +                        ],
    +                    ).transpose([2, 1, 0, 3])
                         return density_data
                     else:
                         if grid_dimensions is None:
                             grid_dimensions = self.grid_dimensions
    -                    return density_data.reshape(grid_dimensions+[1])
    +                    return density_data.reshape(grid_dimensions + [1])
                 else:
                     return density_data
             else:
                 raise Exception("Unknown density data shape.")
    -
    [docs] def get_energy_contributions(self, density_data=None, create_file=True, - atoms_Angstrom=None, qe_input_data=None, - qe_pseudopotentials=None): +
    [docs] def get_energy_contributions( + self, + density_data=None, + create_file=True, + atoms_Angstrom=None, + qe_input_data=None, + qe_pseudopotentials=None, + ): r""" Extract density based energy contributions from Quantum Espresso. @@ -807,27 +863,39 @@

    Source code for mala.targets.density

             if density_data is None:
                 density_data = self.density
                 if density_data is None:
    -                raise Exception("No density data provided, cannot calculate"
    -                                " this quantity.")
    +                raise Exception(
    +                    "No density data provided, cannot calculate"
    +                    " this quantity."
    +                )
     
             if atoms_Angstrom is None:
                 atoms_Angstrom = self.atoms
    -        self.__setup_total_energy_module(density_data, atoms_Angstrom,
    -                                         create_file=create_file,
    -                                         qe_input_data=qe_input_data,
    -                                         qe_pseudopotentials=
    -                                         qe_pseudopotentials)
    +        self.__setup_total_energy_module(
    +            density_data,
    +            atoms_Angstrom,
    +            create_file=create_file,
    +            qe_input_data=qe_input_data,
    +            qe_pseudopotentials=qe_pseudopotentials,
    +        )
     
             # Get and return the energies.
    -        energies = np.array(te.get_energies())*Rydberg
    -        energies_dict = {"e_rho_times_v_hxc": energies[0],
    -                         "e_hartree": energies[1], "e_xc": energies[2],
    -                         "e_ewald": energies[3]}
    +        energies = np.array(te.get_energies()) * Rydberg
    +        energies_dict = {
    +            "e_rho_times_v_hxc": energies[0],
    +            "e_hartree": energies[1],
    +            "e_xc": energies[2],
    +            "e_ewald": energies[3],
    +        }
             return energies_dict
    -
    [docs] def get_atomic_forces(self, density_data=None, create_file=True, - atoms_Angstrom=None, qe_input_data=None, - qe_pseudopotentials=None): +
    [docs] def get_atomic_forces( + self, + density_data=None, + create_file=True, + atoms_Angstrom=None, + qe_input_data=None, + qe_pseudopotentials=None, + ): """ Calculate the atomic forces. @@ -871,24 +939,31 @@

    Source code for mala.targets.density

             if density_data is None:
                 density_data = self.density
                 if density_data is None:
    -                raise Exception("No density data provided, cannot calculate"
    -                                " this quantity.")
    +                raise Exception(
    +                    "No density data provided, cannot calculate"
    +                    " this quantity."
    +                )
     
             # First, set up the total energy module for calculation.
             if atoms_Angstrom is None:
                 atoms_Angstrom = self.atoms
    -        self.__setup_total_energy_module(density_data, atoms_Angstrom,
    -                                         create_file=create_file,
    -                                         qe_input_data=qe_input_data,
    -                                         qe_pseudopotentials=
    -                                         qe_pseudopotentials)
    +        self.__setup_total_energy_module(
    +            density_data,
    +            atoms_Angstrom,
    +            create_file=create_file,
    +            qe_input_data=qe_input_data,
    +            qe_pseudopotentials=qe_pseudopotentials,
    +        )
     
             # Now calculate the forces.
    -        atomic_forces = np.array(te.calc_forces(len(atoms_Angstrom))).transpose()
    +        atomic_forces = np.array(
    +            te.calc_forces(len(atoms_Angstrom))
    +        ).transpose()
     
             # QE returns the forces in Ry/Bohr.
    -        atomic_forces = AtomicForce.convert_units(atomic_forces,
    -                                                  in_units="Ry/Bohr")
    +        atomic_forces = AtomicForce.convert_units(
    +            atomic_forces, in_units="Ry/Bohr"
    +        )
             return atomic_forces
    [docs] @staticmethod @@ -913,7 +988,7 @@

    Source code for mala.targets.density

                 The scaled positions.
             """
             principal_axis = atoms.get_cell()[0][0]
    -        scaled_positions = atoms.get_positions()/principal_axis
    +        scaled_positions = atoms.get_positions() / principal_axis
             return scaled_positions
    # Private methods @@ -928,9 +1003,14 @@

    Source code for mala.targets.density

             # Feature size is always 1 in this case, no need to do anything.
             pass
     
    -    def __setup_total_energy_module(self, density_data, atoms_Angstrom,
    -                                    create_file=True, qe_input_data=None,
    -                                    qe_pseudopotentials=None):
    +    def __setup_total_energy_module(
    +        self,
    +        density_data,
    +        atoms_Angstrom,
    +        create_file=True,
    +        qe_input_data=None,
    +        qe_pseudopotentials=None,
    +    ):
             if create_file:
                 # If not otherwise specified, use values as read in.
                 if qe_input_data is None:
    @@ -938,10 +1018,13 @@ 

    Source code for mala.targets.density

                 if qe_pseudopotentials is None:
                     qe_pseudopotentials = self.qe_pseudopotentials
     
    -            self.write_tem_input_file(atoms_Angstrom, qe_input_data,
    -                                      qe_pseudopotentials,
    -                                      self.grid_dimensions,
    -                                      self.kpoints)
    +            self.write_tem_input_file(
    +                atoms_Angstrom,
    +                qe_input_data,
    +                qe_pseudopotentials,
    +                self.grid_dimensions,
    +                self.kpoints,
    +            )
     
             # initialize the total energy module.
             # FIXME: So far, the total energy module can only be initialized once.
    @@ -952,8 +1035,11 @@ 

    Source code for mala.targets.density

             # for this.
     
             if Density.te_mutex is False:
    -            printout("MALA: Starting QuantumEspresso to get density-based"
    -                     " energy contributions.", min_verbosity=0)
    +            printout(
    +                "MALA: Starting QuantumEspresso to get density-based"
    +                " energy contributions.",
    +                min_verbosity=0,
    +            )
                 barrier()
                 t0 = time.perf_counter()
                 te.initialize(self.y_planes)
    @@ -964,9 +1050,11 @@ 

    Source code for mala.targets.density

                 Density.te_mutex = True
                 printout("MALA: QuantumEspresso setup done.", min_verbosity=0)
             else:
    -            printout("MALA: QuantumEspresso is already running. Except for"
    -                     " the atomic positions, no new parameters will be used.",
    -                     min_verbosity=0)
    +            printout(
    +                "MALA: QuantumEspresso is already running. Except for"
    +                " the atomic positions, no new parameters will be used.",
    +                min_verbosity=0,
    +            )
     
             # Before we proceed, some sanity checks are necessary.
             # Is the calculation spinpolarized?
    @@ -978,67 +1066,83 @@ 

    Source code for mala.targets.density

             number_of_atoms = te.get_nat()
             if create_file is True:
                 if number_of_atoms != atoms_Angstrom.get_global_number_of_atoms():
    -                raise Exception("Number of atoms is inconsistent between MALA "
    -                                "and Quantum Espresso.")
    +                raise Exception(
    +                    "Number of atoms is inconsistent between MALA "
    +                    "and Quantum Espresso."
    +                )
     
             # We need to find out if the grid dimensions are consistent.
             # That depends on the form of the density data we received.
             number_of_gridpoints = te.get_nnr()
             if len(density_data.shape) == 4:
    -            number_of_gridpoints_mala = density_data.shape[0] * \
    -                                        density_data.shape[1] * \
    -                                        density_data.shape[2]
    +            number_of_gridpoints_mala = (
    +                density_data.shape[0]
    +                * density_data.shape[1]
    +                * density_data.shape[2]
    +            )
             elif len(density_data.shape) == 2:
                 number_of_gridpoints_mala = density_data.shape[0]
             else:
                 raise Exception("Density data has wrong dimensions. ")
     
             # If MPI is enabled, we NEED z-splitting for this to work.
    -        if self._parameters_full.use_mpi and \
    -                not self._parameters_full.descriptors.use_z_splitting:
    -            raise Exception("Cannot calculate the total energy if "
    -                            "the real space grid was not split in "
    -                            "z-direction.")
    +        if (
    +            self._parameters_full.use_mpi
    +            and not self._parameters_full.descriptors.use_z_splitting
    +        ):
    +            raise Exception(
    +                "Cannot calculate the total energy if "
    +                "the real space grid was not split in "
    +                "z-direction."
    +            )
     
             # Check if we need to test the grid points.
             # We skip the check only if z-splitting is enabled and unequal
             # z-splits are to be expected, and no
             # y-splitting is enabled (since y-splitting currently works
             # for equal z-splitting anyway).
    -        if self._parameters_full.use_mpi and \
    -           self._parameters_full.descriptors.use_y_splitting == 0 \
    -           and int(self.grid_dimensions[2] / get_size()) != \
    -                  (self.grid_dimensions[2] / get_size()):
    +        if (
    +            self._parameters_full.use_mpi
    +            and self._parameters_full.descriptors.use_y_splitting == 0
    +            and int(self.grid_dimensions[2] / get_size())
    +            != (self.grid_dimensions[2] / get_size())
    +        ):
                 pass
             else:
                 if number_of_gridpoints_mala != number_of_gridpoints:
    -                raise Exception("Grid is inconsistent between MALA and"
    -                                " Quantum Espresso")
    +                raise Exception(
    +                    "Grid is inconsistent between MALA and Quantum Espresso"
    +                )
     
             # Now we need to reshape the density.
             density_for_qe = None
             if len(density_data.shape) == 4:
    -            density_for_qe = np.reshape(density_data, [number_of_gridpoints,
    -                                                       1], order='F')
    +            density_for_qe = np.reshape(
    +                density_data, [number_of_gridpoints, 1], order="F"
    +            )
             elif len(density_data.shape) == 2:
    -            parallel_warn("Using 1D density to calculate the total energy"
    -                          " requires reshaping of this data. "
    -                          "This is unproblematic, as long as you provided t"
    -                          "he correct grid_dimensions.")
    -            density_for_qe = self.get_density(density_data,
    -                                              convert_to_threedimensional=True)
    -
    -            density_for_qe = np.reshape(density_for_qe,
    -                                        [number_of_gridpoints_mala, 1],
    -                                        order='F')
    +            parallel_warn(
    +                "Using 1D density to calculate the total energy"
    +                " requires reshaping of this data. "
    +                "This is unproblematic, as long as you provided t"
    +                "he correct grid_dimensions."
    +            )
    +            density_for_qe = self.get_density(
    +                density_data, convert_to_threedimensional=True
    +            )
    +
    +            density_for_qe = np.reshape(
    +                density_for_qe, [number_of_gridpoints_mala, 1], order="F"
    +            )
     
                 # If there is an inconsistency between MALA and QE (which
                 # can only happen in the uneven z-splitting case at the moment)
                 # we need to pad the density array.
                 if density_for_qe.shape[0] < number_of_gridpoints:
                     grid_diff = number_of_gridpoints - number_of_gridpoints_mala
    -                density_for_qe = np.pad(density_for_qe,
    -                                        pad_width=((0, grid_diff), (0, 0)))
    +                density_for_qe = np.pad(
    +                    density_for_qe, pad_width=((0, grid_diff), (0, 0))
    +                )
     
             # QE has the density in 1/Bohr^3
             density_for_qe *= self.backconvert_units(1, "1/Bohr^3")
    @@ -1048,19 +1152,23 @@ 

    Source code for mala.targets.density

             # instantiate the process with the file.
             positions_for_qe = self.get_scaled_positions_for_qe(atoms_Angstrom)
     
    -        if self._parameters_full.descriptors.\
    -                use_atomic_density_energy_formula:
    +        if self._parameters_full.descriptors.use_atomic_density_energy_formula:
                 # Calculate the Gaussian descriptors for the calculation of the
                 # structure factors.
                 barrier()
                 t0 = time.perf_counter()
    -            gaussian_descriptors = \
    +            gaussian_descriptors = (
                     self._get_gaussian_descriptors_for_structure_factors(
    -                    atoms_Angstrom, self.grid_dimensions)
    +                    atoms_Angstrom, self.grid_dimensions
    +                )
    +            )
                 barrier()
                 t1 = time.perf_counter()
    -            printout("time used by gaussian descriptors: ", t1 - t0,
    -                     min_verbosity=2)
    +            printout(
    +                "time used by gaussian descriptors: ",
    +                t1 - t0,
    +                min_verbosity=2,
    +            )
     
                 #
                 # Check normalization of the Gaussian descriptors
    @@ -1081,13 +1189,18 @@ 

    Source code for mala.targets.density

                 atoms_reference = atoms_Angstrom.copy()
                 del atoms_reference[1:]
                 atoms_reference.set_positions([(0.0, 0.0, 0.0)])
    -            reference_gaussian_descriptors = \
    +            reference_gaussian_descriptors = (
                     self._get_gaussian_descriptors_for_structure_factors(
    -                    atoms_reference, self.grid_dimensions)
    +                    atoms_reference, self.grid_dimensions
    +                )
    +            )
                 barrier()
                 t1 = time.perf_counter()
    -            printout("time used by reference gaussian descriptors: ", t1 - t0,
    -                     min_verbosity=2)
    +            printout(
    +                "time used by reference gaussian descriptors: ",
    +                t1 - t0,
    +                min_verbosity=2,
    +            )
     
                 #
                 # Check normalization of the reference Gaussian descriptors
    @@ -1105,50 +1218,59 @@ 

    Source code for mala.targets.density

     
             # If the Gaussian formula is used, both the calculation of the
             # Ewald energy and the structure factor can be skipped.
    -        te.set_positions(np.transpose(positions_for_qe), number_of_atoms,
    -                         self._parameters_full.descriptors. \
    -                         use_atomic_density_energy_formula,
    -                         self._parameters_full.descriptors. \
    -                         use_atomic_density_energy_formula)
    +        te.set_positions(
    +            np.transpose(positions_for_qe),
    +            number_of_atoms,
    +            self._parameters_full.descriptors.use_atomic_density_energy_formula,
    +            self._parameters_full.descriptors.use_atomic_density_energy_formula,
    +        )
             barrier()
             t1 = time.perf_counter()
    -        printout("time used by set_positions: ", t1 - t0,
    -                 min_verbosity=2)
    +        printout("time used by set_positions: ", t1 - t0, min_verbosity=2)
     
             barrier()
     
    -        if self._parameters_full.descriptors.\
    -                use_atomic_density_energy_formula:
    +        if self._parameters_full.descriptors.use_atomic_density_energy_formula:
                 t0 = time.perf_counter()
    -            gaussian_descriptors = \
    -                np.reshape(gaussian_descriptors,
    -                           [number_of_gridpoints_mala, 1], order='F')
    -            reference_gaussian_descriptors = \
    -                np.reshape(reference_gaussian_descriptors,
    -                           [number_of_gridpoints_mala, 1], order='F')
    +            gaussian_descriptors = np.reshape(
    +                gaussian_descriptors,
    +                [number_of_gridpoints_mala, 1],
    +                order="F",
    +            )
    +            reference_gaussian_descriptors = np.reshape(
    +                reference_gaussian_descriptors,
    +                [number_of_gridpoints_mala, 1],
    +                order="F",
    +            )
     
                 # If there is an inconsistency between MALA and QE (which
                 # can only happen in the uneven z-splitting case at the moment)
                 # we need to pad the gaussian descriptor arrays.
                 if number_of_gridpoints_mala < number_of_gridpoints:
                     grid_diff = number_of_gridpoints - number_of_gridpoints_mala
    -                gaussian_descriptors = np.pad(gaussian_descriptors,
    -                                            pad_width=((0, grid_diff), (0, 0)))
    -                reference_gaussian_descriptors = np.pad(reference_gaussian_descriptors,
    -                                            pad_width=((0, grid_diff), (0, 0)))
    -
    -            sigma = self._parameters_full.descriptors.\
    -                atomic_density_sigma
    +                gaussian_descriptors = np.pad(
    +                    gaussian_descriptors, pad_width=((0, grid_diff), (0, 0))
    +                )
    +                reference_gaussian_descriptors = np.pad(
    +                    reference_gaussian_descriptors,
    +                    pad_width=((0, grid_diff), (0, 0)),
    +                )
    +
    +            sigma = self._parameters_full.descriptors.atomic_density_sigma
                 sigma = sigma / Bohr
    -            te.set_positions_gauss(self._parameters_full.verbosity,
    -                                   gaussian_descriptors,
    -                                   reference_gaussian_descriptors,
    -                                   sigma,
    -                                   number_of_gridpoints, 1)
    +            te.set_positions_gauss(
    +                self._parameters_full.verbosity,
    +                gaussian_descriptors,
    +                reference_gaussian_descriptors,
    +                sigma,
    +                number_of_gridpoints,
    +                1,
    +            )
                 barrier()
                 t1 = time.perf_counter()
    -            printout("time used by set_positions_gauss: ", t1 - t0,
    -                     min_verbosity=2)
    +            printout(
    +                "time used by set_positions_gauss: ", t1 - t0, min_verbosity=2
    +            )
     
             # Now we can set the new density.
             barrier()
    @@ -1156,16 +1278,16 @@ 

    Source code for mala.targets.density

             te.set_rho_of_r(density_for_qe, number_of_gridpoints, nr_spin_channels)
             barrier()
             t1 = time.perf_counter()
    -        printout("time used by set_rho_of_r: ", t1 - t0,
    -                 min_verbosity=2)
    +        printout("time used by set_rho_of_r: ", t1 - t0, min_verbosity=2)
     
             return atoms_Angstrom
     
         def _get_gaussian_descriptors_for_structure_factors(self, atoms, grid):
             descriptor_calculator = AtomicDensity(self._parameters_full)
             kwargs = {"return_directly": True, "use_fp64": True}
    -        return descriptor_calculator.\
    -            calculate_from_atoms(atoms, grid, **kwargs)[:, 6:]
    + return descriptor_calculator.calculate_from_atoms( + atoms, grid, **kwargs + )[:, 6:]
    diff --git a/_modules/mala/targets/dos.html b/_modules/mala/targets/dos.html index 8583fec37..f06a32845 100644 --- a/_modules/mala/targets/dos.html +++ b/_modules/mala/targets/dos.html @@ -75,6 +75,7 @@

    Source code for mala.targets.dos

     """DOS calculation class."""
    +
     from functools import cached_property
     
     import ase.io
    @@ -86,8 +87,13 @@ 

    Source code for mala.targets.dos

     from mala.common.parameters import printout
     from mala.common.parallelizer import get_rank, barrier, get_comm
     from mala.targets.target import Target
    -from mala.targets.calculation_helpers import fermi_function, gaussians, \
    -    analytical_integration, get_beta, entropy_multiplicator
    +from mala.targets.calculation_helpers import (
    +    fermi_function,
    +    gaussians,
    +    analytical_integration,
    +    get_beta,
    +    entropy_multiplicator,
    +)
     
     
     
    [docs]class DOS(Target): @@ -130,18 +136,22 @@

    Source code for mala.targets.dos

             return_dos_object.fermi_energy_dft = ldos_object.fermi_energy_dft
             return_dos_object.temperature = ldos_object.temperature
             return_dos_object.voxel = ldos_object.voxel
    -        return_dos_object.number_of_electrons_exact = \
    +        return_dos_object.number_of_electrons_exact = (
                 ldos_object.number_of_electrons_exact
    -        return_dos_object.band_energy_dft_calculation = \
    +        )
    +        return_dos_object.band_energy_dft_calculation = (
                 ldos_object.band_energy_dft_calculation
    +        )
             return_dos_object.atoms = ldos_object.atoms
             return_dos_object.qe_input_data = ldos_object.qe_input_data
             return_dos_object.qe_pseudopotentials = ldos_object.qe_pseudopotentials
    -        return_dos_object.total_energy_dft_calculation = \
    +        return_dos_object.total_energy_dft_calculation = (
                 ldos_object.total_energy_dft_calculation
    +        )
             return_dos_object.kpoints = ldos_object.kpoints
    -        return_dos_object.number_of_electrons_from_eigenvals = \
    +        return_dos_object.number_of_electrons_from_eigenvals = (
                 ldos_object.number_of_electrons_from_eigenvals
    +        )
             return_dos_object.local_grid = ldos_object.local_grid
             return_dos_object._parameters_full = ldos_object._parameters_full
     
    @@ -290,8 +300,11 @@ 

    Source code for mala.targets.dos

             """Dictionary containing the SI unit dimensions in OpenPMD format."""
             import openpmd_api as io
     
    -        return {io.Unit_Dimension.M: -1, io.Unit_Dimension.L: -2,
    -                io.Unit_Dimension.T: 2}
    +        return {
    +            io.Unit_Dimension.M: -1,
    +            io.Unit_Dimension.L: -2,
    +            io.Unit_Dimension.T: 2,
    +        }
     
         @property
         def density_of_states(self):
    @@ -334,8 +347,9 @@ 

    Source code for mala.targets.dos

             if self.density_of_states is not None:
                 return self.get_band_energy()
             else:
    -            raise Exception("No cached DOS available to calculate this "
    -                            "property.")
    +            raise Exception(
    +                "No cached DOS available to calculate this property."
    +            )
     
         @cached_property
         def number_of_electrons(self):
    @@ -348,8 +362,9 @@ 

    Source code for mala.targets.dos

             if self.density_of_states is not None:
                 return self.get_number_of_electrons()
             else:
    -            raise Exception("No cached DOS available to calculate this "
    -                            "property.")
    +            raise Exception(
    +                "No cached DOS available to calculate this property."
    +            )
     
         @cached_property
         def fermi_energy(self):
    @@ -362,8 +377,7 @@ 

    Source code for mala.targets.dos

             from how this quantity is calculated. Calculated via cached DOS.
             """
             if self.density_of_states is not None:
    -            fermi_energy = self. \
    -                get_self_consistent_fermi_energy()
    +            fermi_energy = self.get_self_consistent_fermi_energy()
     
                 # Now that we have a new Fermi energy, we should uncache the
                 # old number of electrons.
    @@ -384,8 +398,9 @@ 

    Source code for mala.targets.dos

             if self.density_of_states is not None:
                 return self.get_entropy_contribution()
             else:
    -            raise Exception("No cached DOS available to calculate this "
    -                            "property.")
    +            raise Exception(
    +                "No cached DOS available to calculate this property."
    +            )
     
     
    [docs] def uncache_properties(self): """Uncache all cached properties of this calculator.""" @@ -431,7 +446,7 @@

    Source code for mala.targets.dos

             if in_units == "1/eV" or in_units is None:
                 return array
             elif in_units == "1/Ry":
    -            return array * (1/Rydberg)
    +            return array * (1 / Rydberg)
             else:
                 raise Exception("Unsupported unit for LDOS.")
    @@ -486,7 +501,7 @@

    Source code for mala.targets.dos

             return_dos_values = []
     
             # Open the file, then iterate through its contents.
    -        with open(path, 'r') as infile:
    +        with open(path, "r") as infile:
                 lines = infile.readlines()
                 i = 0
     
    @@ -495,8 +510,10 @@ 

    Source code for mala.targets.dos

                     if "#" not in dos_line and i < self.parameters.ldos_gridsize:
                         e_val = float(dos_line.split()[0])
                         dosval = float(dos_line.split()[1])
    -                    if np.abs(e_val-energy_grid[i]) < self.parameters.\
    -                            ldos_gridspacing_ev*0.98:
    +                    if (
    +                        np.abs(e_val - energy_grid[i])
    +                        < self.parameters.ldos_gridspacing_ev * 0.98
    +                    ):
                             return_dos_values.append(dosval)
                             i += 1
     
    @@ -533,17 +550,19 @@ 

    Source code for mala.targets.dos

                 atoms_object = ase.io.read(path, format="espresso-out")
             kweights = atoms_object.get_calculator().get_k_point_weights()
             if kweights is None:
    -            raise Exception("QE output file does not contain band information."
    -                            "Rerun calculation with verbosity set to 'high'.")
    +            raise Exception(
    +                "QE output file does not contain band information."
    +                "Rerun calculation with verbosity set to 'high'."
    +            )
     
             # Get the gaussians for all energy values and calculate the DOS per
             # band.
    -        dos_per_band = gaussians(self.energy_grid,
    -                                 atoms_object.get_calculator().
    -                                 band_structure().energies[0, :, :],
    -                                 smearing_factor*self.parameters.
    -                                 ldos_gridspacing_ev)
    -        dos_per_band = kweights[:, np.newaxis, np.newaxis]*dos_per_band
    +        dos_per_band = gaussians(
    +            self.energy_grid,
    +            atoms_object.get_calculator().band_structure().energies[0, :, :],
    +            smearing_factor * self.parameters.ldos_gridspacing_ev,
    +        )
    +        dos_per_band = kweights[:, np.newaxis, np.newaxis] * dos_per_band
     
             # QE gives the band energies in eV, so no conversion necessary here.
             dos_data = np.sum(dos_per_band, axis=(0, 1))
    @@ -580,16 +599,23 @@ 

    Source code for mala.targets.dos

             """
             emin = self.parameters.ldos_gridoffset_ev
     
    -        emax = self.parameters.ldos_gridoffset_ev + \
    -            self.parameters.ldos_gridsize * \
    -            self.parameters.ldos_gridspacing_ev
    +        emax = (
    +            self.parameters.ldos_gridoffset_ev
    +            + self.parameters.ldos_gridsize
    +            * self.parameters.ldos_gridspacing_ev
    +        )
             grid_size = self.parameters.ldos_gridsize
    -        linspace_array = (np.linspace(emin, emax, grid_size, endpoint=False))
    +        linspace_array = np.linspace(emin, emax, grid_size, endpoint=False)
             return linspace_array
    -
    [docs] def get_band_energy(self, dos_data=None, fermi_energy=None, - temperature=None, integration_method="analytical", - broadcast_band_energy=True): +
    [docs] def get_band_energy( + self, + dos_data=None, + fermi_energy=None, + temperature=None, + integration_method="analytical", + broadcast_band_energy=True, + ): """ Calculate the band energy from given DOS data. @@ -624,17 +650,21 @@

    Source code for mala.targets.dos

             # Parse the parameters.
             # Parse the parameters.
             if dos_data is None and self.density_of_states is None:
    -            raise Exception("No DOS data provided, cannot calculate"
    -                            " this quantity.")
    +            raise Exception(
    +                "No DOS data provided, cannot calculate this quantity."
    +            )
     
             # Here we check whether we will use our internal, cached
             # DOS, or calculate everything from scratch.
             if dos_data is not None:
                 if fermi_energy is None:
    -                printout("Warning: No fermi energy was provided or could be "
    -                         "calculated from electronic structure data. "
    -                         "Using the DFT fermi energy, this may "
    -                         "yield unexpected results", min_verbosity=1)
    +                printout(
    +                    "Warning: No fermi energy was provided or could be "
    +                    "calculated from electronic structure data. "
    +                    "Using the DFT fermi energy, this may "
    +                    "yield unexpected results",
    +                    min_verbosity=1,
    +                )
                     fermi_energy = self.fermi_energy_dft
             else:
                 dos_data = self.density_of_states
    @@ -645,11 +675,13 @@ 

    Source code for mala.targets.dos

             if self.parameters._configuration["mpi"] and broadcast_band_energy:
                 if get_rank() == 0:
                     energy_grid = self.energy_grid
    -                band_energy = self.__band_energy_from_dos(dos_data,
    -                                                          energy_grid,
    -                                                          fermi_energy,
    -                                                          temperature,
    -                                                          integration_method)
    +                band_energy = self.__band_energy_from_dos(
    +                    dos_data,
    +                    energy_grid,
    +                    fermi_energy,
    +                    temperature,
    +                    integration_method,
    +                )
                 else:
                     band_energy = None
     
    @@ -658,17 +690,29 @@ 

    Source code for mala.targets.dos

                 return band_energy
             else:
                 energy_grid = self.energy_grid
    -            return self.__band_energy_from_dos(dos_data, energy_grid,
    -                                               fermi_energy, temperature,
    -                                               integration_method)
    -
    -
    -        return self.__band_energy_from_dos(dos_data, energy_grid, fermi_energy,
    -                                           temperature, integration_method)
    - -
    [docs] def get_number_of_electrons(self, dos_data=None, fermi_energy=None, - temperature=None, - integration_method="analytical"): + return self.__band_energy_from_dos( + dos_data, + energy_grid, + fermi_energy, + temperature, + integration_method, + ) + + return self.__band_energy_from_dos( + dos_data, + energy_grid, + fermi_energy, + temperature, + integration_method, + )
    + +
    [docs] def get_number_of_electrons( + self, + dos_data=None, + fermi_energy=None, + temperature=None, + integration_method="analytical", + ): """ Calculate the number of electrons from given DOS data. @@ -698,17 +742,21 @@

    Source code for mala.targets.dos

             """
             # Parse the parameters.
             if dos_data is None and self.density_of_states is None:
    -            raise Exception("No DOS data provided, cannot calculate"
    -                            " this quantity.")
    +            raise Exception(
    +                "No DOS data provided, cannot calculate this quantity."
    +            )
     
             # Here we check whether we will use our internal, cached
             # DOS, or calculate everything from scratch.
             if dos_data is not None:
                 if fermi_energy is None:
    -                printout("Warning: No fermi energy was provided or could be "
    -                         "calculated from electronic structure data. "
    -                         "Using the DFT fermi energy, this may "
    -                         "yield unexpected results", min_verbosity=1)
    +                printout(
    +                    "Warning: No fermi energy was provided or could be "
    +                    "calculated from electronic structure data. "
    +                    "Using the DFT fermi energy, this may "
    +                    "yield unexpected results",
    +                    min_verbosity=1,
    +                )
                     fermi_energy = self.fermi_energy_dft
             else:
                 dos_data = self.density_of_states
    @@ -717,14 +765,22 @@ 

    Source code for mala.targets.dos

             if temperature is None:
                 temperature = self.temperature
             energy_grid = self.energy_grid
    -        return self.__number_of_electrons_from_dos(dos_data, energy_grid,
    -                                                   fermi_energy, temperature,
    -                                                   integration_method)
    - -
    [docs] def get_entropy_contribution(self, dos_data=None, fermi_energy=None, - temperature=None, - integration_method="analytical", - broadcast_entropy=True): + return self.__number_of_electrons_from_dos( + dos_data, + energy_grid, + fermi_energy, + temperature, + integration_method, + )
    + +
    [docs] def get_entropy_contribution( + self, + dos_data=None, + fermi_energy=None, + temperature=None, + integration_method="analytical", + broadcast_entropy=True, + ): """ Calculate the entropy contribution to the total energy. @@ -758,17 +814,21 @@

    Source code for mala.targets.dos

             """
             # Parse the parameters.
             if dos_data is None and self.density_of_states is None:
    -            raise Exception("No DOS data provided, cannot calculate"
    -                            " this quantity.")
    +            raise Exception(
    +                "No DOS data provided, cannot calculate this quantity."
    +            )
     
             # Here we check whether we will use our internal, cached
             # DOS, or calculate everything from scratch.
             if dos_data is not None:
                 if fermi_energy is None:
    -                printout("Warning: No fermi energy was provided or could be "
    -                         "calculated from electronic structure data. "
    -                         "Using the DFT fermi energy, this may "
    -                         "yield unexpected results", min_verbosity=1)
    +                printout(
    +                    "Warning: No fermi energy was provided or could be "
    +                    "calculated from electronic structure data. "
    +                    "Using the DFT fermi energy, this may "
    +                    "yield unexpected results",
    +                    min_verbosity=1,
    +                )
                     fermi_energy = self.fermi_energy_dft
             else:
                 dos_data = self.density_of_states
    @@ -779,10 +839,13 @@ 

    Source code for mala.targets.dos

             if self.parameters._configuration["mpi"] and broadcast_entropy:
                 if get_rank() == 0:
                     energy_grid = self.energy_grid
    -                entropy = self. \
    -                    __entropy_contribution_from_dos(dos_data, energy_grid,
    -                                                    fermi_energy, temperature,
    -                                                    integration_method)
    +                entropy = self.__entropy_contribution_from_dos(
    +                    dos_data,
    +                    energy_grid,
    +                    fermi_energy,
    +                    temperature,
    +                    integration_method,
    +                )
                 else:
                     entropy = None
     
    @@ -791,14 +854,21 @@ 

    Source code for mala.targets.dos

                 return entropy
             else:
                 energy_grid = self.energy_grid
    -            return self. \
    -                __entropy_contribution_from_dos(dos_data, energy_grid,
    -                                                fermi_energy, temperature,
    -                                                integration_method)
    - -
    [docs] def get_self_consistent_fermi_energy(self, dos_data=None, temperature=None, - integration_method="analytical", - broadcast_fermi_energy=True): + return self.__entropy_contribution_from_dos( + dos_data, + energy_grid, + fermi_energy, + temperature, + integration_method, + )
    + +
    [docs] def get_self_consistent_fermi_energy( + self, + dos_data=None, + temperature=None, + integration_method="analytical", + broadcast_fermi_energy=True, + ): r""" Calculate the self-consistent Fermi energy. @@ -835,8 +905,9 @@

    Source code for mala.targets.dos

             if dos_data is None:
                 dos_data = self.density_of_states
                 if dos_data is None:
    -                raise Exception("No DOS data provided, cannot calculate"
    -                                " this quantity.")
    +                raise Exception(
    +                    "No DOS data provided, cannot calculate this quantity."
    +                )
     
             if temperature is None:
                 temperature = self.temperature
    @@ -844,15 +915,20 @@ 

    Source code for mala.targets.dos

             if self.parameters._configuration["mpi"] and broadcast_fermi_energy:
                 if get_rank() == 0:
                     energy_grid = self.energy_grid
    -                fermi_energy_sc = toms748(lambda fermi_sc:
    -                                          (self.
    -                                           __number_of_electrons_from_dos
    -                                           (dos_data, energy_grid,
    -                                            fermi_sc, temperature,
    -                                            integration_method)
    -                                           - self.number_of_electrons_exact),
    -                                          a=energy_grid[0],
    -                                          b=energy_grid[-1])
    +                fermi_energy_sc = toms748(
    +                    lambda fermi_sc: (
    +                        self.__number_of_electrons_from_dos(
    +                            dos_data,
    +                            energy_grid,
    +                            fermi_sc,
    +                            temperature,
    +                            integration_method,
    +                        )
    +                        - self.number_of_electrons_exact
    +                    ),
    +                    a=energy_grid[0],
    +                    b=energy_grid[-1],
    +                )
                 else:
                     fermi_energy_sc = None
     
    @@ -861,15 +937,20 @@ 

    Source code for mala.targets.dos

                 return fermi_energy_sc
             else:
                 energy_grid = self.energy_grid
    -            fermi_energy_sc = toms748(lambda fermi_sc:
    -                                      (self.
    -                                       __number_of_electrons_from_dos
    -                                       (dos_data, energy_grid,
    -                                        fermi_sc, temperature,
    -                                        integration_method)
    -                                       - self.number_of_electrons_exact),
    -                                      a=energy_grid[0],
    -                                      b=energy_grid[-1])
    +            fermi_energy_sc = toms748(
    +                lambda fermi_sc: (
    +                    self.__number_of_electrons_from_dos(
    +                        dos_data,
    +                        energy_grid,
    +                        fermi_sc,
    +                        temperature,
    +                        integration_method,
    +                    )
    +                    - self.number_of_electrons_exact
    +                ),
    +                a=energy_grid[0],
    +                b=energy_grid[-1],
    +            )
                 return fermi_energy_sc
    [docs] def get_density_of_states(self, dos_data=None): @@ -898,82 +979,96 @@

    Source code for mala.targets.dos

             self.parameters.ldos_gridsize = np.shape(array)[-1]
     
         @staticmethod
    -    def __number_of_electrons_from_dos(dos_data, energy_grid, fermi_energy,
    -                                       temperature, integration_method):
    +    def __number_of_electrons_from_dos(
    +        dos_data, energy_grid, fermi_energy, temperature, integration_method
    +    ):
             """Calculate the number of electrons from DOS data."""
             # Calculate the energy levels and the Fermi function.
     
    -        fermi_vals = fermi_function(energy_grid, fermi_energy, temperature,
    -                                    suppress_overflow=True)
    +        fermi_vals = fermi_function(
    +            energy_grid, fermi_energy, temperature, suppress_overflow=True
    +        )
             # Calculate the number of electrons.
             if integration_method == "trapz":
    -            number_of_electrons = integrate.trapz(dos_data * fermi_vals,
    -                                                  energy_grid, axis=-1)
    +            number_of_electrons = integrate.trapz(
    +                dos_data * fermi_vals, energy_grid, axis=-1
    +            )
             elif integration_method == "simps":
    -            number_of_electrons = integrate.simps(dos_data * fermi_vals,
    -                                                  energy_grid, axis=-1)
    +            number_of_electrons = integrate.simps(
    +                dos_data * fermi_vals, energy_grid, axis=-1
    +            )
             elif integration_method == "quad":
                 dos_pointer = interpolate.interp1d(energy_grid, dos_data)
                 number_of_electrons, abserr = integrate.quad(
    -                lambda e: dos_pointer(e) * fermi_function(e, fermi_energy,
    -                                                          temperature,
    -                                                          suppress_overflow=True),
    -                energy_grid[0], energy_grid[-1], limit=500,
    -                points=fermi_energy)
    +                lambda e: dos_pointer(e)
    +                * fermi_function(
    +                    e, fermi_energy, temperature, suppress_overflow=True
    +                ),
    +                energy_grid[0],
    +                energy_grid[-1],
    +                limit=500,
    +                points=fermi_energy,
    +            )
             elif integration_method == "analytical":
    -            number_of_electrons = analytical_integration(dos_data, "F0", "F1",
    -                                                         fermi_energy,
    -                                                         energy_grid,
    -                                                         temperature)
    +            number_of_electrons = analytical_integration(
    +                dos_data, "F0", "F1", fermi_energy, energy_grid, temperature
    +            )
             else:
                 raise Exception("Unknown integration method.")
     
             return number_of_electrons
     
         @staticmethod
    -    def __band_energy_from_dos(dos_data, energy_grid, fermi_energy,
    -                               temperature, integration_method):
    +    def __band_energy_from_dos(
    +        dos_data, energy_grid, fermi_energy, temperature, integration_method
    +    ):
             """Calculate the band energy from DOS data."""
             # Calculate the energy levels and the Fermi function.
    -        fermi_vals = fermi_function(energy_grid, fermi_energy, temperature,
    -                                    suppress_overflow=True)
    +        fermi_vals = fermi_function(
    +            energy_grid, fermi_energy, temperature, suppress_overflow=True
    +        )
     
             # Calculate the band energy.
             if integration_method == "trapz":
    -            band_energy = integrate.trapz(dos_data * (energy_grid *
    -                                                      fermi_vals),
    -                                          energy_grid, axis=-1)
    +            band_energy = integrate.trapz(
    +                dos_data * (energy_grid * fermi_vals), energy_grid, axis=-1
    +            )
             elif integration_method == "simps":
    -            band_energy = integrate.simps(dos_data * (energy_grid *
    -                                                      fermi_vals),
    -                                          energy_grid, axis=-1)
    +            band_energy = integrate.simps(
    +                dos_data * (energy_grid * fermi_vals), energy_grid, axis=-1
    +            )
             elif integration_method == "quad":
                 dos_pointer = interpolate.interp1d(energy_grid, dos_data)
                 band_energy, abserr = integrate.quad(
    -                lambda e: dos_pointer(e) * e * fermi_function(e, fermi_energy,
    -                                                              temperature,
    -                                                              suppress_overflow=True),
    -                energy_grid[0], energy_grid[-1], limit=500,
    -                points=fermi_energy)
    +                lambda e: dos_pointer(e)
    +                * e
    +                * fermi_function(
    +                    e, fermi_energy, temperature, suppress_overflow=True
    +                ),
    +                energy_grid[0],
    +                energy_grid[-1],
    +                limit=500,
    +                points=fermi_energy,
    +            )
             elif integration_method == "analytical":
    -            number_of_electrons = analytical_integration(dos_data, "F0", "F1",
    -                                                         fermi_energy,
    -                                                         energy_grid,
    -                                                         temperature)
    -            band_energy_minus_uN = analytical_integration(dos_data, "F1", "F2",
    -                                                          fermi_energy,
    -                                                          energy_grid,
    -                                                          temperature)
    -            band_energy = band_energy_minus_uN + fermi_energy * \
    -                          number_of_electrons
    +            number_of_electrons = analytical_integration(
    +                dos_data, "F0", "F1", fermi_energy, energy_grid, temperature
    +            )
    +            band_energy_minus_uN = analytical_integration(
    +                dos_data, "F1", "F2", fermi_energy, energy_grid, temperature
    +            )
    +            band_energy = (
    +                band_energy_minus_uN + fermi_energy * number_of_electrons
    +            )
             else:
                 raise Exception("Unknown integration method.")
     
             return band_energy
     
         @staticmethod
    -    def __entropy_contribution_from_dos(dos_data, energy_grid, fermi_energy,
    -                                        temperature, integration_method):
    +    def __entropy_contribution_from_dos(
    +        dos_data, energy_grid, fermi_energy, temperature, integration_method
    +    ):
             r"""
             Calculate the entropy contribution to the total energy from DOS data.
     
    @@ -981,31 +1076,36 @@ 

    Source code for mala.targets.dos

             """
             # Calculate the entropy contribution to the energy.
             if integration_method == "trapz":
    -            multiplicator = entropy_multiplicator(energy_grid, fermi_energy,
    -                                                  temperature)
    -            entropy_contribution = integrate.trapz(dos_data * multiplicator,
    -                                                   energy_grid, axis=-1)
    +            multiplicator = entropy_multiplicator(
    +                energy_grid, fermi_energy, temperature
    +            )
    +            entropy_contribution = integrate.trapz(
    +                dos_data * multiplicator, energy_grid, axis=-1
    +            )
                 entropy_contribution /= get_beta(temperature)
             elif integration_method == "simps":
    -            multiplicator = entropy_multiplicator(energy_grid, fermi_energy,
    -                                                  temperature)
    -            entropy_contribution = integrate.simps(dos_data * multiplicator,
    -                                                   energy_grid, axis=-1)
    +            multiplicator = entropy_multiplicator(
    +                energy_grid, fermi_energy, temperature
    +            )
    +            entropy_contribution = integrate.simps(
    +                dos_data * multiplicator, energy_grid, axis=-1
    +            )
                 entropy_contribution /= get_beta(temperature)
             elif integration_method == "quad":
                 dos_pointer = interpolate.interp1d(energy_grid, dos_data)
                 entropy_contribution, abserr = integrate.quad(
    -                lambda e: dos_pointer(e) *
    -                          entropy_multiplicator(e, fermi_energy,
    -                                                temperature),
    -                energy_grid[0], energy_grid[-1], limit=500,
    -                points=fermi_energy)
    +                lambda e: dos_pointer(e)
    +                * entropy_multiplicator(e, fermi_energy, temperature),
    +                energy_grid[0],
    +                energy_grid[-1],
    +                limit=500,
    +                points=fermi_energy,
    +            )
                 entropy_contribution /= get_beta(temperature)
             elif integration_method == "analytical":
    -            entropy_contribution = analytical_integration(dos_data, "S0", "S1",
    -                                                          fermi_energy,
    -                                                          energy_grid,
    -                                                          temperature)
    +            entropy_contribution = analytical_integration(
    +                dos_data, "S0", "S1", fermi_energy, energy_grid, temperature
    +            )
             else:
                 raise Exception("Unknown integration method.")
     
    diff --git a/_modules/mala/targets/ldos.html b/_modules/mala/targets/ldos.html
    index a7387f6eb..e7478db61 100644
    --- a/_modules/mala/targets/ldos.html
    +++ b/_modules/mala/targets/ldos.html
    @@ -75,6 +75,7 @@
                  
       

    Source code for mala.targets.ldos

     """LDOS calculation class."""
    +
     from functools import cached_property
     
     from ase.units import Rydberg, Bohr, J, m
    @@ -82,14 +83,22 @@ 

    Source code for mala.targets.ldos

     import numpy as np
     from scipy import integrate
     
    -from mala.common.parallelizer import get_comm, printout, get_rank, get_size, \
    -    barrier
    +from mala.common.parallelizer import (
    +    get_comm,
    +    printout,
    +    get_rank,
    +    get_size,
    +    barrier,
    +)
     from mala.common.parameters import DEFAULT_NP_DATA_DTYPE
     from mala.targets.cube_parser import read_cube
     from mala.targets.xsf_parser import read_xsf
     from mala.targets.target import Target
    -from mala.targets.calculation_helpers import fermi_function, \
    -    analytical_integration, integrate_values_on_spacing
    +from mala.targets.calculation_helpers import (
    +    fermi_function,
    +    analytical_integration,
    +    integrate_values_on_spacing,
    +)
     from mala.targets.dos import DOS
     from mala.targets.density import Density
     
    @@ -165,8 +174,9 @@ 

    Source code for mala.targets.ldos

             return return_ldos_object
    [docs] @classmethod - def from_cube_file(cls, params, path_name_scheme, units="1/(eV*A^3)", - use_memmap=None): + def from_cube_file( + cls, params, path_name_scheme, units="1/(eV*A^3)", use_memmap=None + ): """ Create an LDOS calculator from multiple cube files. @@ -191,13 +201,15 @@

    Source code for mala.targets.ldos

                 If run in MPI parallel mode, such a file MUST be provided.
             """
             return_ldos_object = LDOS(params)
    -        return_ldos_object.read_from_cube(path_name_scheme, units=units,
    -                                          use_memmap=use_memmap)
    +        return_ldos_object.read_from_cube(
    +            path_name_scheme, units=units, use_memmap=use_memmap
    +        )
             return return_ldos_object
    [docs] @classmethod - def from_xsf_file(cls, params, path_name_scheme, units="1/(eV*A^3)", - use_memmap=None): + def from_xsf_file( + cls, params, path_name_scheme, units="1/(eV*A^3)", use_memmap=None + ): """ Create an LDOS calculator from multiple xsf files. @@ -222,8 +234,9 @@

    Source code for mala.targets.ldos

                 If run in MPI parallel mode, such a file MUST be provided.
             """
             return_ldos_object = LDOS(params)
    -        return_ldos_object.read_from_xsf(path_name_scheme, units=units,
    -                                         use_memmap=use_memmap)
    +        return_ldos_object.read_from_xsf(
    +            path_name_scheme, units=units, use_memmap=use_memmap
    +        )
             return return_ldos_object
    [docs] @classmethod @@ -271,15 +284,18 @@

    Source code for mala.targets.ldos

     
             Needed for OpenPMD interface.
             """
    -        return (m**3)*J
    +        return (m**3) * J
     
         @property
         def si_dimension(self):
             """Dictionary containing the SI unit dimensions in OpenPMD format."""
             import openpmd_api as io
     
    -        return {io.Unit_Dimension.M: -1, io.Unit_Dimension.L: -5,
    -                io.Unit_Dimension.T: 2}
    +        return {
    +            io.Unit_Dimension.M: -1,
    +            io.Unit_Dimension.L: -5,
    +            io.Unit_Dimension.T: 2,
    +        }
     
         @property
         def local_density_of_states(self):
    @@ -345,8 +361,9 @@ 

    Source code for mala.targets.ldos

             if self.local_density_of_states is not None:
                 return self.get_total_energy()
             else:
    -            raise Exception("No cached LDOS available to calculate this "
    -                            "property.")
    +            raise Exception(
    +                "No cached LDOS available to calculate this property."
    +            )
     
         @cached_property
         def band_energy(self):
    @@ -354,8 +371,9 @@ 

    Source code for mala.targets.ldos

             if self.local_density_of_states is not None:
                 return self.get_band_energy()
             else:
    -            raise Exception("No cached LDOS available to calculate this "
    -                            "property.")
    +            raise Exception(
    +                "No cached LDOS available to calculate this property."
    +            )
     
         @cached_property
         def entropy_contribution(self):
    @@ -363,8 +381,9 @@ 

    Source code for mala.targets.ldos

             if self.local_density_of_states is not None:
                 return self.get_entropy_contribution()
             else:
    -            raise Exception("No cached LDOS available to calculate this "
    -                            "property.")
    +            raise Exception(
    +                "No cached LDOS available to calculate this property."
    +            )
     
         @cached_property
         def number_of_electrons(self):
    @@ -377,8 +396,9 @@ 

    Source code for mala.targets.ldos

             if self.local_density_of_states is not None:
                 return self.get_number_of_electrons()
             else:
    -            raise Exception("No cached LDOS available to calculate this "
    -                            "property.")
    +            raise Exception(
    +                "No cached LDOS available to calculate this property."
    +            )
     
         @cached_property
         def fermi_energy(self):
    @@ -391,8 +411,7 @@ 

    Source code for mala.targets.ldos

             from how this quantity is calculated. Calculated via cached LDOS
             """
             if self.local_density_of_states is not None:
    -            fermi_energy = self. \
    -                get_self_consistent_fermi_energy()
    +            fermi_energy = self.get_self_consistent_fermi_energy()
     
                 # Now that we have a new Fermi energy, we should uncache the
                 # old number of electrons.
    @@ -412,8 +431,9 @@ 

    Source code for mala.targets.ldos

             if self.local_density_of_states is not None:
                 return self.get_density()
             else:
    -            raise Exception("No cached LDOS available to calculate this "
    -                            "property.")
    +            raise Exception(
    +                "No cached LDOS available to calculate this property."
    +            )
     
         @cached_property
         def density_of_states(self):
    @@ -421,24 +441,27 @@ 

    Source code for mala.targets.ldos

             if self.local_density_of_states is not None:
                 return self.get_density_of_states()
             else:
    -            raise Exception("No cached LDOS available to calculate this "
    -                            "property.")
    +            raise Exception(
    +                "No cached LDOS available to calculate this property."
    +            )
     
         @cached_property
         def _density_calculator(self):
             if self.local_density_of_states is not None:
                 return Density.from_ldos_calculator(self)
             else:
    -            raise Exception("No cached LDOS available to calculate this "
    -                            "property.")
    +            raise Exception(
    +                "No cached LDOS available to calculate this property."
    +            )
     
         @cached_property
         def _density_of_states_calculator(self):
             if self.local_density_of_states is not None:
                 return DOS.from_ldos_calculator(self)
             else:
    -            raise Exception("No cached LDOS available to calculate this "
    -                            "property.")
    +            raise Exception(
    +                "No cached LDOS available to calculate this property."
    +            )
     
         ##############################
         # Methods
    @@ -475,9 +498,9 @@ 

    Source code for mala.targets.ldos

             if in_units == "1/(eV*A^3)" or in_units is None:
                 return array
             elif in_units == "1/(eV*Bohr^3)":
    -            return array * (1/Bohr) * (1/Bohr) * (1/Bohr)
    +            return array * (1 / Bohr) * (1 / Bohr) * (1 / Bohr)
             elif in_units == "1/(Ry*Bohr^3)":
    -            return array * (1/Rydberg) * (1/Bohr) * (1/Bohr) * (1/Bohr)
    +            return array * (1 / Rydberg) * (1 / Bohr) * (1 / Bohr) * (1 / Bohr)
             else:
                 raise Exception("Unsupported unit for LDOS.")
    @@ -515,8 +538,9 @@

    Source code for mala.targets.ldos

             else:
                 raise Exception("Unsupported unit for LDOS.")
    -
    [docs] def read_from_cube(self, path_scheme, units="1/(eV*A^3)", - use_memmap=None, **kwargs): +
    [docs] def read_from_cube( + self, path_scheme, units="1/(eV*A^3)", use_memmap=None, **kwargs + ): """ Read the LDOS data from multiple cube files. @@ -547,11 +571,13 @@

    Source code for mala.targets.ldos

             # tmp.pp003ELEMENT_ldos.cube
             # ...
             # tmp.pp100ELEMENT_ldos.cube
    -        return self._read_from_qe_files(path_scheme, units,
    -                                        use_memmap, ".cube", **kwargs)
    + return self._read_from_qe_files( + path_scheme, units, use_memmap, ".cube", **kwargs + )
    -
    [docs] def read_from_xsf(self, path_scheme, units="1/(eV*A^3)", - use_memmap=None, **kwargs): +
    [docs] def read_from_xsf( + self, path_scheme, units="1/(eV*A^3)", use_memmap=None, **kwargs + ): """ Read the LDOS data from multiple .xsf files. @@ -574,8 +600,9 @@

    Source code for mala.targets.ldos

                 Usage will reduce RAM footprint while SIGNIFICANTLY
                 impacting disk usage and
             """
    -        return self._read_from_qe_files(path_scheme, units,
    -                                        use_memmap, ".xsf", **kwargs)
    + return self._read_from_qe_files( + path_scheme, units, use_memmap, ".xsf", **kwargs + )
    [docs] def read_from_array(self, array, units="1/(eV*A^3)"): """ @@ -607,21 +634,31 @@

    Source code for mala.targets.ldos

             """
             emin = self.parameters.ldos_gridoffset_ev
     
    -        emax = self.parameters.ldos_gridoffset_ev + \
    -            self.parameters.ldos_gridsize * \
    -            self.parameters.ldos_gridspacing_ev
    +        emax = (
    +            self.parameters.ldos_gridoffset_ev
    +            + self.parameters.ldos_gridsize
    +            * self.parameters.ldos_gridspacing_ev
    +        )
             grid_size = self.parameters.ldos_gridsize
    -        linspace_array = (np.linspace(emin, emax, grid_size, endpoint=False))
    +        linspace_array = np.linspace(emin, emax, grid_size, endpoint=False)
             return linspace_array
    -
    [docs] def get_total_energy(self, ldos_data=None, dos_data=None, - density_data=None, fermi_energy=None, - temperature=None, voxel=None, - grid_integration_method="summation", - energy_integration_method="analytical", - atoms_Angstrom=None, qe_input_data=None, - qe_pseudopotentials=None, create_qe_file=True, - return_energy_contributions=False): +
    [docs] def get_total_energy( + self, + ldos_data=None, + dos_data=None, + density_data=None, + fermi_energy=None, + temperature=None, + voxel=None, + grid_integration_method="summation", + energy_integration_method="analytical", + atoms_Angstrom=None, + qe_input_data=None, + qe_pseudopotentials=None, + create_qe_file=True, + return_energy_contributions=False, + ): """ Calculate the total energy from LDOS or given DOS + density data. @@ -703,18 +740,22 @@

    Source code for mala.targets.ldos

                 if ldos_data is None:
                     fermi_energy = self.fermi_energy
                 if fermi_energy is None:
    -                printout("Warning: No fermi energy was provided or could be "
    -                         "calculated from electronic structure data. "
    -                         "Using the DFT fermi energy, this may "
    -                         "yield unexpected results", min_verbosity=1)
    +                printout(
    +                    "Warning: No fermi energy was provided or could be "
    +                    "calculated from electronic structure data. "
    +                    "Using the DFT fermi energy, this may "
    +                    "yield unexpected results",
    +                    min_verbosity=1,
    +                )
                     fermi_energy = self.fermi_energy_dft
             if temperature is None:
                 temperature = self.temperature
     
             # Here we check whether we will use our internal, cached
             # LDOS, or calculate everything from scratch.
    -        if ldos_data is not None or (dos_data is not None
    -                                     and density_data is not None):
    +        if ldos_data is not None or (
    +            dos_data is not None and density_data is not None
    +        ):
     
                 # In this case we calculate everything from scratch,
                 # because the user either provided LDOS data OR density +
    @@ -722,17 +763,19 @@ 

    Source code for mala.targets.ldos

     
                 # Calculate DOS data if need be.
                 if dos_data is None:
    -                dos_data = self.get_density_of_states(ldos_data,
    -                                                      voxel=
    -                                                      voxel,
    -                                                      integration_method=
    -                                                      grid_integration_method)
    +                dos_data = self.get_density_of_states(
    +                    ldos_data,
    +                    voxel=voxel,
    +                    integration_method=grid_integration_method,
    +                )
     
                 # Calculate density data if need be.
                 if density_data is None:
    -                density_data = self.get_density(ldos_data,
    -                                                fermi_energy=fermi_energy,
    -                                                integration_method=energy_integration_method)
    +                density_data = self.get_density(
    +                    ldos_data,
    +                    fermi_energy=fermi_energy,
    +                    integration_method=energy_integration_method,
    +                )
     
                 # Now we can create calculation objects to get the necessary
                 # quantities.
    @@ -743,33 +786,40 @@ 

    Source code for mala.targets.ldos

                 # quantities to construct the total energy.
                 # (According to Eq. 9 in [1])
                 # Band energy (kinetic energy)
    -            e_band = dos_calculator.get_band_energy(dos_data,
    -                                                    fermi_energy=fermi_energy,
    -                                                    temperature=temperature,
    -                                                    integration_method=energy_integration_method)
    +            e_band = dos_calculator.get_band_energy(
    +                dos_data,
    +                fermi_energy=fermi_energy,
    +                temperature=temperature,
    +                integration_method=energy_integration_method,
    +            )
     
                 # Smearing / Entropy contribution
    -            e_entropy_contribution = dos_calculator. \
    -                get_entropy_contribution(dos_data, fermi_energy=fermi_energy,
    -                                         temperature=temperature,
    -                                         integration_method=energy_integration_method)
    +            e_entropy_contribution = dos_calculator.get_entropy_contribution(
    +                dos_data,
    +                fermi_energy=fermi_energy,
    +                temperature=temperature,
    +                integration_method=energy_integration_method,
    +            )
     
                 # Density based energy contributions (via QE)
    -            density_contributions \
    -                = density_calculator. \
    -                get_energy_contributions(density_data,
    -                                         qe_input_data=qe_input_data,
    -                                         atoms_Angstrom=atoms_Angstrom,
    -                                         qe_pseudopotentials=
    -                                         qe_pseudopotentials,
    -                                         create_file=create_qe_file)
    +            density_contributions = (
    +                density_calculator.get_energy_contributions(
    +                    density_data,
    +                    qe_input_data=qe_input_data,
    +                    atoms_Angstrom=atoms_Angstrom,
    +                    qe_pseudopotentials=qe_pseudopotentials,
    +                    create_file=create_qe_file,
    +                )
    +            )
             else:
                 # In this case, we use cached propeties wherever possible.
                 ldos_data = self.local_density_of_states
                 if ldos_data is None:
    -                raise Exception("No input data provided to caculate "
    -                                "total energy. Provide EITHER LDOS"
    -                                " OR DOS and density.")
    +                raise Exception(
    +                    "No input data provided to caculate "
    +                    "total energy. Provide EITHER LDOS"
    +                    " OR DOS and density."
    +                )
     
                 # With these calculator objects we can calculate all the necessary
                 # quantities to construct the total energy.
    @@ -781,33 +831,42 @@ 

    Source code for mala.targets.ldos

                 e_entropy_contribution = self.entropy_contribution
     
                 # Density based energy contributions (via QE)
    -            density_contributions = self._density_calculator.\
    -                total_energy_contributions
    -
    -        e_total = e_band + density_contributions["e_rho_times_v_hxc"] + \
    -            density_contributions["e_hartree"] + \
    -            density_contributions["e_xc"] + \
    -            density_contributions["e_ewald"] +\
    -            e_entropy_contribution
    +            density_contributions = (
    +                self._density_calculator.total_energy_contributions
    +            )
    +
    +        e_total = (
    +            e_band
    +            + density_contributions["e_rho_times_v_hxc"]
    +            + density_contributions["e_hartree"]
    +            + density_contributions["e_xc"]
    +            + density_contributions["e_ewald"]
    +            + e_entropy_contribution
    +        )
             if return_energy_contributions:
    -            energy_contribtuons = {"e_band": e_band,
    -                                   "e_rho_times_v_hxc":
    -                                       density_contributions["e_rho_times_v_hxc"],
    -                                   "e_hartree":
    -                                       density_contributions["e_hartree"],
    -                                   "e_xc":
    -                                       density_contributions["e_xc"],
    -                                   "e_ewald": density_contributions["e_ewald"],
    -                                   "e_entropy_contribution":
    -                                       e_entropy_contribution}
    +            energy_contribtuons = {
    +                "e_band": e_band,
    +                "e_rho_times_v_hxc": density_contributions[
    +                    "e_rho_times_v_hxc"
    +                ],
    +                "e_hartree": density_contributions["e_hartree"],
    +                "e_xc": density_contributions["e_xc"],
    +                "e_ewald": density_contributions["e_ewald"],
    +                "e_entropy_contribution": e_entropy_contribution,
    +            }
                 return e_total, energy_contribtuons
             else:
                 return e_total
    -
    [docs] def get_band_energy(self, ldos_data=None, fermi_energy=None, - temperature=None, voxel=None, - grid_integration_method="summation", - energy_integration_method="analytical"): +
    [docs] def get_band_energy( + self, + ldos_data=None, + fermi_energy=None, + temperature=None, + voxel=None, + grid_integration_method="summation", + energy_integration_method="analytical", + ): """ Calculate the band energy from given LDOS data. @@ -848,8 +907,9 @@

    Source code for mala.targets.ldos

                 Band energy in eV.
             """
             if ldos_data is None and self.local_density_of_states is None:
    -            raise Exception("No LDOS data provided, cannot calculate"
    -                            " this quantity.")
    +            raise Exception(
    +                "No LDOS data provided, cannot calculate this quantity."
    +            )
     
             # Here we check whether we will use our internal, cached
             # LDOS, or calculate everything from scratch.
    @@ -858,24 +918,31 @@ 

    Source code for mala.targets.ldos

                 if voxel is None:
                     voxel = self.voxel
     
    -            dos_data = self.get_density_of_states(ldos_data, voxel,
    -                                                  integration_method=
    -                                                  grid_integration_method)
    +            dos_data = self.get_density_of_states(
    +                ldos_data, voxel, integration_method=grid_integration_method
    +            )
     
                 # Once we have the DOS, we can use a DOS object to calculate
                 # the band energy.
                 dos_calculator = DOS.from_ldos_calculator(self)
    -            return dos_calculator. \
    -                get_band_energy(dos_data, fermi_energy=fermi_energy,
    -                                temperature=temperature,
    -                                integration_method=energy_integration_method)
    +            return dos_calculator.get_band_energy(
    +                dos_data,
    +                fermi_energy=fermi_energy,
    +                temperature=temperature,
    +                integration_method=energy_integration_method,
    +            )
             else:
                 return self._density_of_states_calculator.band_energy
    -
    [docs] def get_entropy_contribution(self, ldos_data=None, fermi_energy=None, - temperature=None, voxel=None, - grid_integration_method="summation", - energy_integration_method="analytical"): +
    [docs] def get_entropy_contribution( + self, + ldos_data=None, + fermi_energy=None, + temperature=None, + voxel=None, + grid_integration_method="summation", + energy_integration_method="analytical", + ): """ Calculate the entropy contribution from given LDOS data. @@ -916,8 +983,9 @@

    Source code for mala.targets.ldos

                 Band energy in eV.
             """
             if ldos_data is None and self.local_density_of_states is None:
    -            raise Exception("No LDOS data provided, cannot calculate"
    -                            " this quantity.")
    +            raise Exception(
    +                "No LDOS data provided, cannot calculate this quantity."
    +            )
     
             # Here we check whether we will use our internal, cached
             # LDOS, or calculate everything from scratch.
    @@ -926,24 +994,31 @@ 

    Source code for mala.targets.ldos

                 if voxel is None:
                     voxel = self.voxel
     
    -            dos_data = self.get_density_of_states(ldos_data, voxel,
    -                                                  integration_method=
    -                                                  grid_integration_method)
    +            dos_data = self.get_density_of_states(
    +                ldos_data, voxel, integration_method=grid_integration_method
    +            )
     
                 # Once we have the DOS, we can use a DOS object to calculate
                 # the band energy.
                 dos_calculator = DOS.from_ldos_calculator(self)
    -            return dos_calculator. \
    -                get_entropy_contribution(dos_data, fermi_energy=fermi_energy,
    -                                         temperature=temperature,
    -                                         integration_method=energy_integration_method)
    +            return dos_calculator.get_entropy_contribution(
    +                dos_data,
    +                fermi_energy=fermi_energy,
    +                temperature=temperature,
    +                integration_method=energy_integration_method,
    +            )
             else:
                 return self._density_of_states_calculator.entropy_contribution
    -
    [docs] def get_number_of_electrons(self, ldos_data=None, voxel=None, - fermi_energy=None, temperature=None, - grid_integration_method="summation", - energy_integration_method="analytical"): +
    [docs] def get_number_of_electrons( + self, + ldos_data=None, + voxel=None, + fermi_energy=None, + temperature=None, + grid_integration_method="summation", + energy_integration_method="analytical", + ): """ Calculate the number of electrons from given LDOS data. @@ -984,8 +1059,9 @@

    Source code for mala.targets.ldos

                 Number of electrons.
             """
             if ldos_data is None and self.local_density_of_states is None:
    -            raise Exception("No LDOS data provided, cannot calculate"
    -                            " this quantity.")
    +            raise Exception(
    +                "No LDOS data provided, cannot calculate this quantity."
    +            )
     
             # Here we check whether we will use our internal, cached
             # LDOS, or calculate everything from scratch.
    @@ -993,24 +1069,30 @@ 

    Source code for mala.targets.ldos

                 # The number of electrons is calculated using the DOS.
                 if voxel is None:
                     voxel = self.voxel
    -            dos_data = self.get_density_of_states(ldos_data, voxel,
    -                                                  integration_method=
    -                                                  grid_integration_method)
    +            dos_data = self.get_density_of_states(
    +                ldos_data, voxel, integration_method=grid_integration_method
    +            )
     
                 # Once we have the DOS, we can use a DOS object to calculate the
                 # number of electrons.
                 dos_calculator = DOS.from_ldos_calculator(self)
    -            return dos_calculator. \
    -                get_number_of_electrons(dos_data, fermi_energy=fermi_energy,
    -                                        temperature=temperature,
    -                                        integration_method=energy_integration_method)
    +            return dos_calculator.get_number_of_electrons(
    +                dos_data,
    +                fermi_energy=fermi_energy,
    +                temperature=temperature,
    +                integration_method=energy_integration_method,
    +            )
             else:
                 return self._density_of_states_calculator.number_of_electrons
    -
    [docs] def get_self_consistent_fermi_energy(self, ldos_data=None, voxel=None, - temperature=None, - grid_integration_method="summation", - energy_integration_method="analytical"): +
    [docs] def get_self_consistent_fermi_energy( + self, + ldos_data=None, + voxel=None, + temperature=None, + grid_integration_method="summation", + energy_integration_method="analytical", + ): r""" Calculate the self-consistent Fermi energy. @@ -1054,30 +1136,38 @@

    Source code for mala.targets.ldos

                 :math:`\epsilon_F` in eV.
             """
             if ldos_data is None and self.local_density_of_states is None:
    -            raise Exception("No LDOS data provided, cannot calculate"
    -                            " this quantity.")
    +            raise Exception(
    +                "No LDOS data provided, cannot calculate this quantity."
    +            )
     
             if ldos_data is not None:
                 # The Fermi energy is calculated using the DOS.
                 if voxel is None:
                     voxel = self.voxel
    -            dos_data = self.get_density_of_states(ldos_data, voxel,
    -                                                  integration_method=
    -                                                  grid_integration_method)
    +            dos_data = self.get_density_of_states(
    +                ldos_data, voxel, integration_method=grid_integration_method
    +            )
     
                 # Once we have the DOS, we can use a DOS object to calculate the
                 # number of electrons.
                 dos_calculator = DOS.from_ldos_calculator(self)
    -            return dos_calculator. \
    -                get_self_consistent_fermi_energy(dos_data,
    -                                                 temperature=temperature,
    -                                                 integration_method=energy_integration_method)
    +            return dos_calculator.get_self_consistent_fermi_energy(
    +                dos_data,
    +                temperature=temperature,
    +                integration_method=energy_integration_method,
    +            )
             else:
                 return self._density_of_states_calculator.fermi_energy
    -
    [docs] def get_density(self, ldos_data=None, fermi_energy=None, temperature=None, - conserve_dimensions=False, integration_method="analytical", - gather_density=False): +
    [docs] def get_density( + self, + ldos_data=None, + fermi_energy=None, + temperature=None, + conserve_dimensions=False, + integration_method="analytical", + gather_density=False, + ): """ Calculate the density from given LDOS data. @@ -1132,10 +1222,13 @@

    Source code for mala.targets.ldos

                 if ldos_data is None:
                     fermi_energy = self.fermi_energy
                 if fermi_energy is None:
    -                printout("Warning: No fermi energy was provided or could be "
    -                         "calculated from electronic structure data. "
    -                         "Using the DFT fermi energy, this may "
    -                         "yield unexpected results", min_verbosity=1)
    +                printout(
    +                    "Warning: No fermi energy was provided or could be "
    +                    "calculated from electronic structure data. "
    +                    "Using the DFT fermi energy, this may "
    +                    "yield unexpected results",
    +                    min_verbosity=1,
    +                )
                     fermi_energy = self.fermi_energy_dft
             if temperature is None:
                 temperature = self.temperature
    @@ -1143,8 +1236,9 @@ 

    Source code for mala.targets.ldos

             if ldos_data is None:
                 ldos_data = self.local_density_of_states
                 if ldos_data is None:
    -                raise Exception("No LDOS data provided, cannot calculate"
    -                                " this quantity.")
    +                raise Exception(
    +                    "No LDOS data provided, cannot calculate this quantity."
    +                )
     
             ldos_data_shape = np.shape(ldos_data)
             if len(ldos_data_shape) == 2:
    @@ -1156,8 +1250,13 @@ 

    Source code for mala.targets.ldos

                 # We have the LDOS as (gridx, gridy, gridz, energygrid),
                 # so some reshaping needs to be done.
                 ldos_data_used = ldos_data.reshape(
    -                [ldos_data_shape[0] * ldos_data_shape[1] * ldos_data_shape[2],
    -                 ldos_data_shape[3]])
    +                [
    +                    ldos_data_shape[0]
    +                    * ldos_data_shape[1]
    +                    * ldos_data_shape[2],
    +                    ldos_data_shape[3],
    +                ]
    +            )
                 # We now have the LDOS as gridpoints x energygrid.
     
             else:
    @@ -1165,36 +1264,47 @@ 

    Source code for mala.targets.ldos

     
             # Build the energy grid and calculate the fermi function.
             energy_grid = self.get_energy_grid()
    -        fermi_values = fermi_function(energy_grid, fermi_energy, temperature,
    -                                      suppress_overflow=True)
    +        fermi_values = fermi_function(
    +            energy_grid, fermi_energy, temperature, suppress_overflow=True
    +        )
     
             # Calculate the number of electrons.
             if integration_method == "trapz":
    -            density_values = integrate.trapz(ldos_data_used * fermi_values,
    -                                             energy_grid, axis=-1)
    +            density_values = integrate.trapz(
    +                ldos_data_used * fermi_values, energy_grid, axis=-1
    +            )
             elif integration_method == "simps":
    -            density_values = integrate.simps(ldos_data_used * fermi_values,
    -                                             energy_grid, axis=-1)
    +            density_values = integrate.simps(
    +                ldos_data_used * fermi_values, energy_grid, axis=-1
    +            )
             elif integration_method == "analytical":
    -            density_values = analytical_integration(ldos_data_used, "F0", "F1",
    -                                                    fermi_energy, energy_grid,
    -                                                    temperature)
    +            density_values = analytical_integration(
    +                ldos_data_used,
    +                "F0",
    +                "F1",
    +                fermi_energy,
    +                energy_grid,
    +                temperature,
    +            )
             else:
                 raise Exception("Unknown integration method.")
     
             # Now we have the full density; We now need to collect it, in the
             # MPI case.
             if self.parameters._configuration["mpi"] and gather_density:
    -            density_values = np.reshape(density_values,
    -                                        [np.shape(density_values)[0], 1])
    -            density_values = np.concatenate((self.local_grid, density_values),
    -                                            axis=1)
    +            density_values = np.reshape(
    +                density_values, [np.shape(density_values)[0], 1]
    +            )
    +            density_values = np.concatenate(
    +                (self.local_grid, density_values), axis=1
    +            )
                 full_density = self._gather_density(density_values)
                 if len(ldos_data_shape) == 2:
                     ldos_shape = np.shape(full_density)
    -                full_density = np.reshape(full_density, [ldos_shape[0] *
    -                                                         ldos_shape[1] *
    -                                                         ldos_shape[2], 1])
    +                full_density = np.reshape(
    +                    full_density,
    +                    [ldos_shape[0] * ldos_shape[1] * ldos_shape[2], 1],
    +                )
                 return full_density
             else:
                 if len(ldos_data_shape) == 4 and conserve_dimensions is True:
    @@ -1207,16 +1317,23 @@ 

    Source code for mala.targets.ldos

                     density_values = density_values.reshape(ldos_data_shape)
                 else:
                     if len(ldos_data_shape) == 4:
    -                    grid_length = ldos_data_shape[0] * ldos_data_shape[1] * \
    -                                  ldos_data_shape[2]
    +                    grid_length = (
    +                        ldos_data_shape[0]
    +                        * ldos_data_shape[1]
    +                        * ldos_data_shape[2]
    +                    )
                     else:
                         grid_length = ldos_data_shape[0]
                     density_values = density_values.reshape([grid_length, 1])
                 return density_values
    -
    [docs] def get_density_of_states(self, ldos_data=None, voxel=None, - integration_method="summation", - gather_dos=True): +
    [docs] def get_density_of_states( + self, + ldos_data=None, + voxel=None, + integration_method="summation", + gather_dos=True, + ): """ Calculate the density of states from given LDOS data. @@ -1254,8 +1371,9 @@

    Source code for mala.targets.ldos

             if ldos_data is None:
                 ldos_data = self.local_density_of_states
                 if ldos_data is None:
    -                raise Exception("No LDOS data provided, cannot calculate"
    -                                " this quantity.")
    +                raise Exception(
    +                    "No LDOS data provided, cannot calculate this quantity."
    +                )
     
             if voxel is None:
                 voxel = self.voxel
    @@ -1265,8 +1383,10 @@ 

    Source code for mala.targets.ldos

                 if len(ldos_data_shape) != 2:
                     raise Exception("Unknown LDOS shape, cannot calculate DOS.")
                 elif integration_method != "summation":
    -                raise Exception("If using a 2D LDOS array, you can only "
    -                                "use summation as integration method.")
    +                raise Exception(
    +                    "If using a 2D LDOS array, you can only "
    +                    "use summation as integration method."
    +                )
     
             # We have the LDOS as (gridx, gridy, gridz, energygrid), no
             # further operation is necessary.
    @@ -1283,48 +1403,58 @@ 

    Source code for mala.targets.ldos

             if integration_method != "summation":
                 # X
                 if ldos_data_shape[0] > 1:
    -                dos_values = integrate_values_on_spacing(dos_values,
    -                                                         grid_spacing_x,
    -                                                         axis=0,
    -                                                         method=
    -                                                         integration_method)
    +                dos_values = integrate_values_on_spacing(
    +                    dos_values,
    +                    grid_spacing_x,
    +                    axis=0,
    +                    method=integration_method,
    +                )
                 else:
    -                dos_values = np.reshape(dos_values, (ldos_data_shape[1],
    -                                                     ldos_data_shape[2],
    -                                                     ldos_data_shape[3]))
    +                dos_values = np.reshape(
    +                    dos_values,
    +                    (
    +                        ldos_data_shape[1],
    +                        ldos_data_shape[2],
    +                        ldos_data_shape[3],
    +                    ),
    +                )
                     dos_values *= grid_spacing_x
     
                 # Y
                 if ldos_data_shape[1] > 1:
    -                dos_values = integrate_values_on_spacing(dos_values,
    -                                                         grid_spacing_y,
    -                                                         axis=0,
    -                                                         method=
    -                                                         integration_method)
    +                dos_values = integrate_values_on_spacing(
    +                    dos_values,
    +                    grid_spacing_y,
    +                    axis=0,
    +                    method=integration_method,
    +                )
                 else:
    -                dos_values = np.reshape(dos_values, (ldos_data_shape[2],
    -                                                     ldos_data_shape[3]))
    +                dos_values = np.reshape(
    +                    dos_values, (ldos_data_shape[2], ldos_data_shape[3])
    +                )
                     dos_values *= grid_spacing_y
     
                 # Z
                 if ldos_data_shape[2] > 1:
    -                dos_values = integrate_values_on_spacing(dos_values,
    -                                                         grid_spacing_z,
    -                                                         axis=0,
    -                                                         method=
    -                                                         integration_method)
    +                dos_values = integrate_values_on_spacing(
    +                    dos_values,
    +                    grid_spacing_z,
    +                    axis=0,
    +                    method=integration_method,
    +                )
                 else:
                     dos_values = np.reshape(dos_values, ldos_data_shape[3])
                     dos_values *= grid_spacing_z
             else:
                 if len(ldos_data_shape) == 4:
    -                dos_values = np.sum(ldos_data, axis=(0, 1, 2),
    -                                    dtype=np.float64) * \
    -                             voxel.volume
    +                dos_values = (
    +                    np.sum(ldos_data, axis=(0, 1, 2), dtype=np.float64)
    +                    * voxel.volume
    +                )
                 if len(ldos_data_shape) == 2:
    -                dos_values = np.sum(ldos_data, axis=0,
    -                                    dtype=np.float64) * \
    -                             voxel.volume
    +                dos_values = (
    +                    np.sum(ldos_data, axis=0, dtype=np.float64) * voxel.volume
    +                )
     
             if self.parameters._configuration["mpi"] and gather_dos:
                 # I think we should refrain from top-level MPI imports; the first
    @@ -1334,15 +1464,19 @@ 

    Source code for mala.targets.ldos

                 comm = get_comm()
                 comm.Barrier()
                 dos_values_full = np.zeros_like(dos_values)
    -            comm.Reduce([dos_values, MPI.DOUBLE],
    -                        [dos_values_full, MPI.DOUBLE],
    -                        op=MPI.SUM, root=0)
    +            comm.Reduce(
    +                [dos_values, MPI.DOUBLE],
    +                [dos_values_full, MPI.DOUBLE],
    +                op=MPI.SUM,
    +                root=0,
    +            )
                 return dos_values_full
             else:
                 return dos_values
    -
    [docs] def get_atomic_forces(self, ldos_data, dE_dd, used_data_handler, - snapshot_number=0): +
    [docs] def get_atomic_forces( + self, ldos_data, dE_dd, used_data_handler, snapshot_number=0 + ): r""" Get the atomic forces, currently work in progress. @@ -1419,8 +1553,9 @@

    Source code for mala.targets.ldos

             if use_pickled_comm:
                 density_list = comm.gather(density_values, root=0)
             else:
    -            sendcounts = np.array(comm.gather(np.shape(density_values)[0],
    -                                              root=0))
    +            sendcounts = np.array(
    +                comm.gather(np.shape(density_values)[0], root=0)
    +            )
                 if get_rank() == 0:
                     # print("sendcounts: {}, total: {}".format(sendcounts,
                     #                                          sum(sendcounts)))
    @@ -1428,19 +1563,19 @@ 

    Source code for mala.targets.ldos

                     # Preparing the list of buffers.
                     density_list = []
                     for i in range(0, get_size()):
    -                    density_list.append(np.empty(sendcounts[i]*4,
    -                                                 dtype=np.float64))
    +                    density_list.append(
    +                        np.empty(sendcounts[i] * 4, dtype=np.float64)
    +                    )
                     # No MPI necessary for first rank. For all the others,
                     # collect the buffers.
                     density_list[0] = density_values
                     for i in range(1, get_size()):
    -                    comm.Recv(density_list[i], source=i,
    -                              tag=100+i)
    -                    density_list[i] = \
    -                        np.reshape(density_list[i],
    -                                   (sendcounts[i], 4))
    +                    comm.Recv(density_list[i], source=i, tag=100 + i)
    +                    density_list[i] = np.reshape(
    +                        density_list[i], (sendcounts[i], 4)
    +                    )
                 else:
    -                comm.Send(density_values, dest=0, tag=get_rank()+100)
    +                comm.Send(density_values, dest=0, tag=get_rank() + 100)
                 barrier()
             # if get_rank() == 0:
             #     printout(np.shape(all_snap_descriptors_list[0]))
    @@ -1458,28 +1593,30 @@ 

    Source code for mala.targets.ldos

                 nx = self.grid_dimensions[0]
                 ny = self.grid_dimensions[1]
                 nz = self.grid_dimensions[2]
    -            full_density = np.zeros(
    -                [nx, ny, nz, 1])
    +            full_density = np.zeros([nx, ny, nz, 1])
                 # Fill the full density array.
                 for idx, local_density in enumerate(density_list):
                     # We glue the individual cells back together, and transpose.
                     first_x = int(local_density[0][0])
                     first_y = int(local_density[0][1])
                     first_z = int(local_density[0][2])
    -                last_x = int(local_density[-1][0])+1
    -                last_y = int(local_density[-1][1])+1
    -                last_z = int(local_density[-1][2])+1
    -                full_density[first_x:last_x,
    -                             first_y:last_y,
    -                             first_z:last_z] = \
    -                    np.reshape(local_density[:, 3],
    -                               [last_z-first_z, last_y-first_y,
    -                                last_x-first_x, 1]).transpose([2, 1, 0, 3])
    +                last_x = int(local_density[-1][0]) + 1
    +                last_y = int(local_density[-1][1]) + 1
    +                last_z = int(local_density[-1][2]) + 1
    +                full_density[
    +                    first_x:last_x, first_y:last_y, first_z:last_z
    +                ] = np.reshape(
    +                    local_density[:, 3],
    +                    [last_z - first_z, last_y - first_y, last_x - first_x, 1],
    +                ).transpose(
    +                    [2, 1, 0, 3]
    +                )
     
             return full_density
     
    -    def _read_from_qe_files(self, path_scheme, units,
    -                            use_memmap, file_type, **kwargs):
    +    def _read_from_qe_files(
    +        self, path_scheme, units, use_memmap, file_type, **kwargs
    +    ):
             """
             Read the LDOS from QE produced files, i.e. one file per energy level.
     
    @@ -1511,17 +1648,23 @@ 

    Source code for mala.targets.ldos

     
             # Iterate over the amount of specified LDOS input files.
             # QE is a Fortran code, so everything is 1 based.
    -        printout("Reading "+str(self.parameters.ldos_gridsize) +
    -                 " LDOS files from"+path_scheme+".", min_verbosity=0)
    +        printout(
    +            "Reading "
    +            + str(self.parameters.ldos_gridsize)
    +            + " LDOS files from"
    +            + path_scheme
    +            + ".",
    +            min_verbosity=0,
    +        )
             ldos_data = None
             if self.parameters._configuration["mpi"]:
    -            local_size = int(np.floor(self.parameters.ldos_gridsize /
    -                                      get_size()))
    -            start_index = get_rank()*local_size + 1
    -            if get_rank()+1 == get_size():
    -                local_size += self.parameters.ldos_gridsize % \
    -                                     get_size()
    -            end_index = start_index+local_size
    +            local_size = int(
    +                np.floor(self.parameters.ldos_gridsize / get_size())
    +            )
    +            start_index = get_rank() * local_size + 1
    +            if get_rank() + 1 == get_size():
    +                local_size += self.parameters.ldos_gridsize % get_size()
    +            end_index = start_index + local_size
             else:
                 start_index = 1
                 end_index = self.parameters.ldos_gridsize + 1
    @@ -1544,13 +1687,14 @@ 

    Source code for mala.targets.ldos

                 # in which we want to store the LDOS.
                 if i == start_index:
                     data_shape = np.shape(data)
    -                ldos_data = np.zeros((data_shape[0], data_shape[1],
    -                                      data_shape[2], local_size),
    -                                     dtype=ldos_dtype)
    +                ldos_data = np.zeros(
    +                    (data_shape[0], data_shape[1], data_shape[2], local_size),
    +                    dtype=ldos_dtype,
    +                )
     
                 # Convert and then append the LDOS data.
    -            data = data*self.convert_units(1, in_units=units)
    -            ldos_data[:, :, :, i-start_index] = data[:, :, :]
    +            data = data * self.convert_units(1, in_units=units)
    +            ldos_data[:, :, :, i - start_index] = data[:, :, :]
                 self.grid_dimensions = list(np.shape(ldos_data)[0:3])
     
             # We have to gather the LDOS either file based or not.
    @@ -1558,30 +1702,37 @@ 

    Source code for mala.targets.ldos

                 barrier()
                 data_shape = np.shape(ldos_data)
                 if return_local:
    -                return ldos_data, start_index-1, end_index-1
    +                return ldos_data, start_index - 1, end_index - 1
                 if use_memmap is not None:
                     if get_rank() == 0:
    -                    ldos_data_full = np.memmap(use_memmap,
    -                                               shape=(data_shape[0],
    -                                                      data_shape[1],
    -                                                      data_shape[2],
    -                                                      self.parameters.
    -                                                      ldos_gridsize),
    -                                               mode="w+",
    -                                               dtype=ldos_dtype)
    +                    ldos_data_full = np.memmap(
    +                        use_memmap,
    +                        shape=(
    +                            data_shape[0],
    +                            data_shape[1],
    +                            data_shape[2],
    +                            self.parameters.ldos_gridsize,
    +                        ),
    +                        mode="w+",
    +                        dtype=ldos_dtype,
    +                    )
                     barrier()
                     if get_rank() != 0:
    -                    ldos_data_full = np.memmap(use_memmap,
    -                                               shape=(data_shape[0],
    -                                                      data_shape[1],
    -                                                      data_shape[2],
    -                                                      self.parameters.
    -                                                      ldos_gridsize),
    -                                               mode="r+",
    -                                               dtype=ldos_dtype)
    +                    ldos_data_full = np.memmap(
    +                        use_memmap,
    +                        shape=(
    +                            data_shape[0],
    +                            data_shape[1],
    +                            data_shape[2],
    +                            self.parameters.ldos_gridsize,
    +                        ),
    +                        mode="r+",
    +                        dtype=ldos_dtype,
    +                    )
                     barrier()
    -                ldos_data_full[:, :, :, start_index-1:end_index-1] = \
    +                ldos_data_full[:, :, :, start_index - 1 : end_index - 1] = (
                         ldos_data[:, :, :, :]
    +                )
                     self.local_density_of_states = ldos_data_full
                     return ldos_data_full
                 else:
    @@ -1589,34 +1740,52 @@ 

    Source code for mala.targets.ldos

     
                     # First get the indices from all the ranks.
                     indices = np.array(
    -                    comm.gather([get_rank(), start_index, end_index],
    -                                root=0))
    +                    comm.gather([get_rank(), start_index, end_index], root=0)
    +                )
                     ldos_data_full = None
                     if get_rank() == 0:
    -                    ldos_data_full = np.empty((data_shape[0], data_shape[1],
    -                                               data_shape[2], self.parameters.
    -                                               ldos_gridsize),dtype=ldos_dtype)
    -                    ldos_data_full[:, :, :, start_index-1:end_index-1] = \
    -                        ldos_data[:, :, :, :]
    +                    ldos_data_full = np.empty(
    +                        (
    +                            data_shape[0],
    +                            data_shape[1],
    +                            data_shape[2],
    +                            self.parameters.ldos_gridsize,
    +                        ),
    +                        dtype=ldos_dtype,
    +                    )
    +                    ldos_data_full[
    +                        :, :, :, start_index - 1 : end_index - 1
    +                    ] = ldos_data[:, :, :, :]
     
                         # No MPI necessary for first rank. For all the others,
                         # collect the buffers.
                         for i in range(1, get_size()):
                             local_start = indices[i][1]
                             local_end = indices[i][2]
    -                        local_size = local_end-local_start
    -                        ldos_local = np.empty(local_size*data_shape[0] *
    -                                              data_shape[1]*data_shape[2],
    -                                              dtype=ldos_dtype)
    +                        local_size = local_end - local_start
    +                        ldos_local = np.empty(
    +                            local_size
    +                            * data_shape[0]
    +                            * data_shape[1]
    +                            * data_shape[2],
    +                            dtype=ldos_dtype,
    +                        )
                             comm.Recv(ldos_local, source=i, tag=100 + i)
    -                        ldos_data_full[:, :, :, local_start-1:local_end-1] = \
    -                            np.reshape(ldos_local, (data_shape[0],
    -                                                    data_shape[1],
    -                                                    data_shape[2],
    -                                                    local_size))[:, :, :, :]
    +                        ldos_data_full[
    +                            :, :, :, local_start - 1 : local_end - 1
    +                        ] = np.reshape(
    +                            ldos_local,
    +                            (
    +                                data_shape[0],
    +                                data_shape[1],
    +                                data_shape[2],
    +                                local_size,
    +                            ),
    +                        )[
    +                            :, :, :, :
    +                        ]
                     else:
    -                    comm.Send(ldos_data, dest=0,
    -                              tag=get_rank() + 100)
    +                    comm.Send(ldos_data, dest=0, tag=get_rank() + 100)
                     barrier()
                     self.local_density_of_states = ldos_data_full
                     return ldos_data_full
    diff --git a/_modules/mala/targets/target.html b/_modules/mala/targets/target.html
    index c647258aa..4bef3fb1d 100644
    --- a/_modules/mala/targets/target.html
    +++ b/_modules/mala/targets/target.html
    @@ -75,7 +75,8 @@
                  
       

    Source code for mala.targets.target

     """Base class for all target calculators."""
    -from abc import ABC, abstractmethod
    +
    +from abc import abstractmethod
     import itertools
     import json
     import os
    @@ -139,14 +140,17 @@ 

    Source code for mala.targets.target

                 else:
                     raise Exception("Wrong type of parameters for Targets class.")
     
    -            if targettype == 'LDOS':
    +            if targettype == "LDOS":
                     from mala.targets.ldos import LDOS
    +
                     target = super(Target, LDOS).__new__(LDOS)
    -            if targettype == 'DOS':
    +            if targettype == "DOS":
                     from mala.targets.dos import DOS
    +
                     target = super(Target, DOS).__new__(DOS)
    -            if targettype == 'Density':
    +            if targettype == "Density":
                     from mala.targets.density import Density
    +
                     target = super(Target, Density).__new__(Density)
     
                 if target is None:
    @@ -171,7 +175,7 @@ 

    Source code for mala.targets.target

             params : mala.Parameters
                 The parameters object with which this object was created.
             """
    -        return self.params_arg,
    +        return (self.params_arg,)
     
         def __init__(self, params):
             super(Target, self).__init__(params)
    @@ -194,19 +198,19 @@ 

    Source code for mala.targets.target

             self.atoms = None
             self.electrons_per_atom = None
             self.qe_input_data = {
    -                "occupations": 'smearing',
    -                "calculation": 'scf',
    -                "restart_mode": 'from_scratch',
    -                "prefix": 'MALA',
    -                "pseudo_dir": self.parameters.pseudopotential_path,
    -                "outdir": './',
    -                "ibrav": None,
    -                "smearing": 'fermi-dirac',
    -                "degauss": None,
    -                "ecutrho": None,
    -                "ecutwfc": None,
    -                "nosym": True,
    -                "noinv": True,
    +            "occupations": "smearing",
    +            "calculation": "scf",
    +            "restart_mode": "from_scratch",
    +            "prefix": "MALA",
    +            "pseudo_dir": self.parameters.pseudopotential_path,
    +            "outdir": "./",
    +            "ibrav": None,
    +            "smearing": "fermi-dirac",
    +            "degauss": None,
    +            "ecutrho": None,
    +            "ecutwfc": None,
    +            "nosym": True,
    +            "noinv": True,
             }
     
             # It has been shown that the number of k-points
    @@ -263,8 +267,9 @@ 

    Source code for mala.targets.target

         def qe_input_data(self):
             """Input data for QE TEM calls."""
             # Update the pseudopotential path from Parameters.
    -        self._qe_input_data["pseudo_dir"] = \
    +        self._qe_input_data["pseudo_dir"] = (
                 self.parameters.pseudopotential_path
    +        )
             return self._qe_input_data
     
         @qe_input_data.setter
    @@ -301,8 +306,9 @@ 

    Source code for mala.targets.target

                 Data in MALA units.
     
             """
    -        raise Exception("No unit conversion method implemented for"
    -                        " this target type.")
    + raise Exception( + "No unit conversion method implemented for this target type." + )
    [docs] @staticmethod @abstractmethod @@ -324,8 +330,10 @@

    Source code for mala.targets.target

                 Data in out_units.
     
             """
    -        raise Exception("No unit back conversion method implemented "
    -                        "for this target type.")
    + raise Exception( + "No unit back conversion method implemented " + "for this target type." + )
    [docs] def read_additional_calculation_data(self, data, data_type=None): """ @@ -368,11 +376,15 @@

    Source code for mala.targets.target

                     elif file_ending == "json":
                         data_type = "json"
                     else:
    -                    raise Exception("Could not guess type of additional "
    -                                    "calculation data provided to MALA.")
    +                    raise Exception(
    +                        "Could not guess type of additional "
    +                        "calculation data provided to MALA."
    +                    )
                 else:
    -                raise Exception("Could not guess type of additional "
    -                                "calculation data provided to MALA.")
    +                raise Exception(
    +                    "Could not guess type of additional "
    +                    "calculation data provided to MALA."
    +                )
     
             if data_type == "espresso-out":
                 # Reset everything.
    @@ -389,8 +401,9 @@ 

    Source code for mala.targets.target

                 # Read the file.
                 self.atoms = ase.io.read(data, format="espresso-out")
                 vol = self.atoms.get_volume()
    -            self.fermi_energy_dft = self.atoms.get_calculator().\
    -                get_fermi_level()
    +            self.fermi_energy_dft = (
    +                self.atoms.get_calculator().get_fermi_level()
    +            )
     
                 # Parse the file for energy values.
                 total_energy = None
    @@ -404,33 +417,40 @@ 

    Source code for mala.targets.target

                         if "End of self-consistent calculation" in line:
                             past_calculation_part = True
                         if "number of electrons       =" in line:
    -                        self.number_of_electrons_exact = \
    -                            np.float64(line.split('=')[1])
    +                        self.number_of_electrons_exact = np.float64(
    +                            line.split("=")[1]
    +                        )
                         if "Fermi-Dirac smearing, width (Ry)=" in line:
    -                        self.temperature = np.float64(line.split('=')[2]) * \
    -                                           Rydberg / kB
    +                        self.temperature = (
    +                            np.float64(line.split("=")[2]) * Rydberg / kB
    +                        )
                         if "convergence has been achieved" in line:
                             break
                         if "FFT dimensions" in line:
                             dims = line.split("(")[1]
                             self.grid_dimensions[0] = int(dims.split(",")[0])
                             self.grid_dimensions[1] = int(dims.split(",")[1])
    -                        self.grid_dimensions[2] = int((dims.split(",")[2]).
    -                                                      split(")")[0])
    +                        self.grid_dimensions[2] = int(
    +                            (dims.split(",")[2]).split(")")[0]
    +                        )
                         if "bravais-lattice index" in line:
                             self.qe_input_data["ibrav"] = int(line.split("=")[1])
                         if "kinetic-energy cutoff" in line:
    -                        self.qe_input_data["ecutwfc"] \
    -                            = float((line.split("=")[1]).split("Ry")[0])
    +                        self.qe_input_data["ecutwfc"] = float(
    +                            (line.split("=")[1]).split("Ry")[0]
    +                        )
                         if "charge density cutoff" in line:
    -                        self.qe_input_data["ecutrho"] \
    -                            = float((line.split("=")[1]).split("Ry")[0])
    +                        self.qe_input_data["ecutrho"] = float(
    +                            (line.split("=")[1]).split("Ry")[0]
    +                        )
                         if "smearing, width" in line:
    -                        self.qe_input_data["degauss"] \
    -                            = float(line.split("=")[-1])
    +                        self.qe_input_data["degauss"] = float(
    +                            line.split("=")[-1]
    +                        )
                         if pseudolinefound:
    -                        self.qe_pseudopotentials[lastpseudo.strip()] \
    -                            = line.split("/")[-1].strip()
    +                        self.qe_pseudopotentials[lastpseudo.strip()] = (
    +                            line.split("/")[-1].strip()
    +                        )
                             pseudolinefound = False
                             lastpseudo = None
                         if "PseudoPot." in line:
    @@ -438,51 +458,61 @@ 

    Source code for mala.targets.target

                             lastpseudo = (line.split("for")[1]).split("read")[0]
                         if "total energy" in line and past_calculation_part:
                             if total_energy is None:
    -                            total_energy \
    -                                = float((line.split('=')[1]).split('Ry')[0])
    +                            total_energy = float(
    +                                (line.split("=")[1]).split("Ry")[0]
    +                            )
                         if "smearing contrib." in line and past_calculation_part:
                             if entropy_contribution is None:
    -                            entropy_contribution \
    -                                = float((line.split('=')[1]).split('Ry')[0])
    +                            entropy_contribution = float(
    +                                (line.split("=")[1]).split("Ry")[0]
    +                            )
                         if "set verbosity='high' to print them." in line:
                             bands_included = False
     
                 # The voxel is needed for e.g. LDOS integration.
                 self.voxel = self.atoms.cell.copy()
    -            self.voxel[0] = self.voxel[0] / (
    -                        self.grid_dimensions[0])
    -            self.voxel[1] = self.voxel[1] / (
    -                        self.grid_dimensions[1])
    -            self.voxel[2] = self.voxel[2] / (
    -                        self.grid_dimensions[2])
    -            self._parameters_full.descriptors.atomic_density_sigma = \
    +            self.voxel[0] = self.voxel[0] / (self.grid_dimensions[0])
    +            self.voxel[1] = self.voxel[1] / (self.grid_dimensions[1])
    +            self.voxel[2] = self.voxel[2] / (self.grid_dimensions[2])
    +            self._parameters_full.descriptors.atomic_density_sigma = (
                     AtomicDensity.get_optimal_sigma(self.voxel)
    +            )
     
                 # This is especially important for size extrapolation.
    -            self.electrons_per_atom = self.number_of_electrons_exact / \
    -                len(self.atoms)
    +            self.electrons_per_atom = self.number_of_electrons_exact / len(
    +                self.atoms
    +            )
     
                 # Unit conversion
    -            self.total_energy_dft_calculation = total_energy*Rydberg
    +            self.total_energy_dft_calculation = total_energy * Rydberg
                 if entropy_contribution is not None:
    -                self.entropy_contribution_dft_calculation = entropy_contribution * Rydberg
    +                self.entropy_contribution_dft_calculation = (
    +                    entropy_contribution * Rydberg
    +                )
     
                 # Calculate band energy, if the necessary data is included in
                 # the output file.
                 if bands_included:
                     eigs = np.transpose(
    -                    self.atoms.get_calculator().band_structure().
    -                    energies[0, :, :])
    +                    self.atoms.get_calculator()
    +                    .band_structure()
    +                    .energies[0, :, :]
    +                )
                     kweights = self.atoms.get_calculator().get_k_point_weights()
    -                eband_per_band = eigs * fermi_function(eigs,
    -                                                       self.fermi_energy_dft,
    -                                                       self.temperature,
    -                                                       suppress_overflow=True)
    +                eband_per_band = eigs * fermi_function(
    +                    eigs,
    +                    self.fermi_energy_dft,
    +                    self.temperature,
    +                    suppress_overflow=True,
    +                )
                     eband_per_band = kweights[np.newaxis, :] * eband_per_band
                     self.band_energy_dft_calculation = np.sum(eband_per_band)
    -                enum_per_band = fermi_function(eigs, self.fermi_energy_dft,
    -                                               self.temperature,
    -                                               suppress_overflow=True)
    +                enum_per_band = fermi_function(
    +                    eigs,
    +                    self.fermi_energy_dft,
    +                    self.temperature,
    +                    suppress_overflow=True,
    +                )
                     enum_per_band = kweights[np.newaxis, :] * enum_per_band
                     self.number_of_electrons_from_eigenvals = np.sum(enum_per_band)
     
    @@ -505,24 +535,25 @@ 

    Source code for mala.targets.target

     
                 # The voxel is needed for e.g. LDOS integration.
                 self.voxel = self.atoms.cell.copy()
    -            self.voxel[0] = self.voxel[0] / (
    -                        self.grid_dimensions[0])
    -            self.voxel[1] = self.voxel[1] / (
    -                        self.grid_dimensions[1])
    -            self.voxel[2] = self.voxel[2] / (
    -                        self.grid_dimensions[2])
    -            self._parameters_full.descriptors.atomic_density_sigma = \
    +            self.voxel[0] = self.voxel[0] / (self.grid_dimensions[0])
    +            self.voxel[1] = self.voxel[1] / (self.grid_dimensions[1])
    +            self.voxel[2] = self.voxel[2] / (self.grid_dimensions[2])
    +            self._parameters_full.descriptors.atomic_density_sigma = (
                     AtomicDensity.get_optimal_sigma(self.voxel)
    +            )
     
                 if self.electrons_per_atom is None:
    -                printout("No number of electrons per atom provided, "
    -                         "MALA cannot guess the number of electrons "
    -                         "in the cell with this. Energy calculations may be"
    -                         "wrong.")
    +                printout(
    +                    "No number of electrons per atom provided, "
    +                    "MALA cannot guess the number of electrons "
    +                    "in the cell with this. Energy calculations may be"
    +                    "wrong."
    +                )
     
                 else:
    -                self.number_of_electrons_exact = self.electrons_per_atom * \
    -                                                 len(self.atoms)
    +                self.number_of_electrons_exact = self.electrons_per_atom * len(
    +                    self.atoms
    +                )
             elif data_type == "json":
                 if isinstance(data, str):
                     json_dict = json.load(open(data, encoding="utf-8"))
    @@ -577,34 +608,42 @@ 

    Source code for mala.targets.target

                 "total_energy_dft_calculation": self.total_energy_dft_calculation,
                 "grid_dimensions": list(self.grid_dimensions),
                 "electrons_per_atom": self.electrons_per_atom,
    -            "number_of_electrons_from_eigenvals":
    -                self.number_of_electrons_from_eigenvals,
    +            "number_of_electrons_from_eigenvals": self.number_of_electrons_from_eigenvals,
                 "ibrav": self.qe_input_data["ibrav"],
                 "ecutwfc": self.qe_input_data["ecutwfc"],
                 "ecutrho": self.qe_input_data["ecutrho"],
                 "degauss": self.qe_input_data["degauss"],
                 "pseudopotentials": self.qe_pseudopotentials,
    -            "entropy_contribution_dft_calculation": self.entropy_contribution_dft_calculation
    +            "entropy_contribution_dft_calculation": self.entropy_contribution_dft_calculation,
             }
             if self.voxel is not None:
                 additional_calculation_data["voxel"] = self.voxel.todict()
    -            additional_calculation_data["voxel"]["array"] = \
    +            additional_calculation_data["voxel"]["array"] = (
                     additional_calculation_data["voxel"]["array"].tolist()
    +            )
                 additional_calculation_data["voxel"].pop("pbc", None)
             if self.atoms is not None:
                 additional_calculation_data["atoms"] = self.atoms.todict()
    -            additional_calculation_data["atoms"]["numbers"] = \
    +            additional_calculation_data["atoms"]["numbers"] = (
                     additional_calculation_data["atoms"]["numbers"].tolist()
    -            additional_calculation_data["atoms"]["positions"] = \
    +            )
    +            additional_calculation_data["atoms"]["positions"] = (
                     additional_calculation_data["atoms"]["positions"].tolist()
    -            additional_calculation_data["atoms"]["cell"] = \
    +            )
    +            additional_calculation_data["atoms"]["cell"] = (
                     additional_calculation_data["atoms"]["cell"].tolist()
    -            additional_calculation_data["atoms"]["pbc"] = \
    +            )
    +            additional_calculation_data["atoms"]["pbc"] = (
                     additional_calculation_data["atoms"]["pbc"].tolist()
    +            )
             if return_string is False:
                 with open(filepath, "w", encoding="utf-8") as f:
    -                json.dump(additional_calculation_data, f,
    -                          ensure_ascii=False, indent=4)
    +                json.dump(
    +                    additional_calculation_data,
    +                    f,
    +                    ensure_ascii=False,
    +                    indent=4,
    +                )
             else:
                 return additional_calculation_data
    @@ -626,8 +665,13 @@

    Source code for mala.targets.target

             else:
                 super(Target, self).write_to_numpy_file(path, target_data)
    -
    [docs] def write_to_openpmd_file(self, path, array=None, additional_attributes={}, - internal_iteration_number=0): +
    [docs] def write_to_openpmd_file( + self, + path, + array=None, + additional_attributes={}, + internal_iteration_number=0, + ): """ Write data to a numpy file. @@ -654,14 +698,16 @@

    Source code for mala.targets.target

                     path,
                     self.get_target(),
                     additional_attributes=additional_attributes,
    -                internal_iteration_number=internal_iteration_number)
    +                internal_iteration_number=internal_iteration_number,
    +            )
             else:
                 # The feature dimension may be undefined.
                 return super(Target, self).write_to_openpmd_file(
                     path,
                     array,
                     additional_attributes=additional_attributes,
    -                internal_iteration_number=internal_iteration_number)
    + internal_iteration_number=internal_iteration_number, + )
    # Accessing target data ######################## @@ -695,8 +741,15 @@

    Source code for mala.targets.target

     
     
    [docs] def get_real_space_grid(self): """Get the real space grid.""" - grid3D = np.zeros((self.grid_dimensions[0], self.grid_dimensions[1], - self.grid_dimensions[2], 3), dtype=np.float64) + grid3D = np.zeros( + ( + self.grid_dimensions[0], + self.grid_dimensions[1], + self.grid_dimensions[2], + 3, + ), + dtype=np.float64, + ) for i in range(0, self.grid_dimensions[0]): for j in range(0, self.grid_dimensions[1]): for k in range(0, self.grid_dimensions[2]): @@ -704,10 +757,9 @@

    Source code for mala.targets.target

             return grid3D
    [docs] @staticmethod - def radial_distribution_function_from_atoms(atoms: ase.Atoms, - number_of_bins, - rMax="mic", - method="mala"): + def radial_distribution_function_from_atoms( + atoms: ase.Atoms, number_of_bins, rMax="mic", method="mala" + ): """ Calculate the radial distribution function (RDF). @@ -765,12 +817,15 @@

    Source code for mala.targets.target

                 _rMax = Target._get_ideal_rmax_for_rdf(atoms, method="2mic")
             else:
                 if method == "asap3":
    -                _rMax_possible = Target._get_ideal_rmax_for_rdf(atoms,
    -                                                                method="2mic")
    +                _rMax_possible = Target._get_ideal_rmax_for_rdf(
    +                    atoms, method="2mic"
    +                )
                     if rMax > _rMax_possible:
    -                    raise Exception("ASAP3 calculation fo RDF cannot work "
    -                                    "with radii that are bigger then the "
    -                                    "cell.")
    +                    raise Exception(
    +                        "ASAP3 calculation fo RDF cannot work "
    +                        "with radii that are bigger then the "
    +                        "cell."
    +                    )
                 _rMax = rMax
     
             atoms = atoms
    @@ -787,21 +842,23 @@ 

    Source code for mala.targets.target

                             parallel_warn(
                                 "Calculating RDF with a radius larger then the "
                                 "unit cell. While this will work numerically, be "
    -                            "cautious about the physicality of its results")
    +                            "cautious about the physicality of its results"
    +                        )
     
                 # Calculate all the distances.
                 # rMax/2 because this is the radius around one atom, so half the
                 # distance to the next one.
                 # Using neighborlists grants us access to the PBC.
    -            neighborlist = ase.neighborlist.NeighborList(np.zeros(len(atoms)) +
    -                                                         [_rMax/2.0],
    -                                                         bothways=True)
    +            neighborlist = NeighborList(
    +                np.zeros(len(atoms)) + [_rMax / 2.0], bothways=True
    +            )
                 neighborlist.update(atoms)
                 for i in range(0, len(atoms)):
                     indices, offsets = neighborlist.get_neighbors(i)
    -                dm = distance.cdist([atoms.get_positions()[i]],
    -                                    atoms.positions[indices] + offsets @
    -                                    atoms.get_cell())
    +                dm = distance.cdist(
    +                    [atoms.get_positions()[i]],
    +                    atoms.positions[indices] + offsets @ atoms.get_cell(),
    +                )
                     index = (np.ceil(dm / dr)).astype(int)
                     index = index.flatten()
                     out_of_scope = index > number_of_bins
    @@ -815,13 +872,15 @@ 

    Source code for mala.targets.target

                 norm = 4.0 * np.pi * dr * phi * len(atoms)
                 for i in range(1, number_of_bins + 1):
                     rr.append((i - 0.5) * dr)
    -                rdf[i] /= (norm * ((rr[-1] ** 2) + (dr ** 2) / 12.))
    +                rdf[i] /= norm * ((rr[-1] ** 2) + (dr**2) / 12.0)
             elif method == "asap3":
                 # ASAP3 loads MPI which takes a long time to import, so
                 # we'll only do that when absolutely needed.
                 from asap3.analysis.rdf import RadialDistributionFunction
    -            rdf = RadialDistributionFunction(atoms, _rMax,
    -                                             number_of_bins).get_rdf()
    +
    +            rdf = RadialDistributionFunction(
    +                atoms, _rMax, number_of_bins
    +            ).get_rdf()
                 rr = []
                 for i in range(1, number_of_bins + 1):
                     rr.append((i - 0.5) * dr)
    @@ -831,9 +890,9 @@ 

    Source code for mala.targets.target

             return rdf[1:], rr
    [docs] @staticmethod - def three_particle_correlation_function_from_atoms(atoms: ase.Atoms, - number_of_bins, - rMax="mic"): + def three_particle_correlation_function_from_atoms( + atoms: ase.Atoms, number_of_bins, rMax="mic" + ): """ Calculate the three particle correlation function (TPCF). @@ -881,22 +940,25 @@

    Source code for mala.targets.target

     
             # TPCF is a function of three radii.
             atoms = atoms
    -        dr = float(_rMax/number_of_bins)
    -        tpcf = np.zeros([number_of_bins + 1, number_of_bins + 1,
    -                        number_of_bins + 1])
    +        dr = float(_rMax / number_of_bins)
    +        tpcf = np.zeros(
    +            [number_of_bins + 1, number_of_bins + 1, number_of_bins + 1]
    +        )
             cell = atoms.get_cell()
             pbc = atoms.get_pbc()
             for i in range(0, 3):
                 if pbc[i]:
                     if _rMax > cell[i, i]:
    -                    raise Exception("Cannot calculate RDF with this radius. "
    -                                    "Please choose a smaller value.")
    +                    raise Exception(
    +                        "Cannot calculate RDF with this radius. "
    +                        "Please choose a smaller value."
    +                    )
     
             # Construct a neighbor list for calculation of distances.
             # With this, the PBC are satisfied.
    -        neighborlist = ase.neighborlist.NeighborList(np.zeros(len(atoms)) +
    -                                                     [_rMax/2.0],
    -                                                     bothways=True)
    +        neighborlist = NeighborList(
    +            np.zeros(len(atoms)) + [_rMax / 2.0], bothways=True
    +        )
             neighborlist.update(atoms)
     
             # To calculate the TPCF we calculate the three distances between
    @@ -911,31 +973,42 @@ 

    Source code for mala.targets.target

                 # Generate all pairs of atoms, and calculate distances of
                 # reference atom to them.
                 indices, offsets = neighborlist.get_neighbors(i)
    -            neighbor_pairs = itertools.\
    -                combinations(list(zip(indices, offsets)), r=2)
    +            neighbor_pairs = itertools.combinations(
    +                list(zip(indices, offsets)), r=2
    +            )
                 neighbor_list = list(neighbor_pairs)
    -            pair_positions = np.array([np.concatenate((atoms.positions[pair1[0]] + \
    -                                                       pair1[1] @ atoms.get_cell(),
    -                                                       atoms.positions[pair2[0]] + \
    -                                                       pair2[1] @ atoms.get_cell()))
    -                                       for pair1, pair2 in neighbor_list])
    +            pair_positions = np.array(
    +                [
    +                    np.concatenate(
    +                        (
    +                            atoms.positions[pair1[0]]
    +                            + pair1[1] @ atoms.get_cell(),
    +                            atoms.positions[pair2[0]]
    +                            + pair2[1] @ atoms.get_cell(),
    +                        )
    +                    )
    +                    for pair1, pair2 in neighbor_list
    +                ]
    +            )
                 dists_between_atoms = np.sqrt(
    -                np.square(pair_positions[:, 0] - pair_positions[:, 3]) +
    -                np.square(pair_positions[:, 1] - pair_positions[:, 4]) +
    -                np.square(pair_positions[:, 2] - pair_positions[:, 5]))
    -            pair_positions = np.reshape(pair_positions, (len(neighbor_list)*2,
    -                                                         3), order="C")
    +                np.square(pair_positions[:, 0] - pair_positions[:, 3])
    +                + np.square(pair_positions[:, 1] - pair_positions[:, 4])
    +                + np.square(pair_positions[:, 2] - pair_positions[:, 5])
    +            )
    +            pair_positions = np.reshape(
    +                pair_positions, (len(neighbor_list) * 2, 3), order="C"
    +            )
                 all_dists = distance.cdist([pos1], pair_positions)[0]
     
                 for idx, neighbor_pair in enumerate(neighbor_list):
    -                r1 = all_dists[2*idx]
    -                r2 = all_dists[2*idx+1]
    +                r1 = all_dists[2 * idx]
    +                r2 = all_dists[2 * idx + 1]
     
                     # We don't need to do any calculation if either of the
                     # atoms are already out of range.
                     if r1 < _rMax and r2 < _rMax:
                         r3 = dists_between_atoms[idx]
    -                    if r3 < _rMax and np.abs(r1-r2) < r3 < (r1+r2):
    +                    if r3 < _rMax and np.abs(r1 - r2) < r3 < (r1 + r2):
                             # print(r1, r2, r3)
                             id1 = (np.ceil(r1 / dr)).astype(int)
                             id2 = (np.ceil(r2 / dr)).astype(int)
    @@ -944,8 +1017,9 @@ 

    Source code for mala.targets.target

     
             # Normalize the TPCF and calculate the distances.
             # This loop takes almost no time compared to the one above.
    -        rr = np.zeros([3, number_of_bins+1, number_of_bins+1,
    -                       number_of_bins+1])
    +        rr = np.zeros(
    +            [3, number_of_bins + 1, number_of_bins + 1, number_of_bins + 1]
    +        )
             phi = len(atoms) / atoms.get_volume()
             norm = 8.0 * np.pi * np.pi * dr * phi * phi * len(atoms)
             for i in range(1, number_of_bins + 1):
    @@ -954,18 +1028,20 @@ 

    Source code for mala.targets.target

                         r1 = (i - 0.5) * dr
                         r2 = (j - 0.5) * dr
                         r3 = (k - 0.5) * dr
    -                    tpcf[i, j, k] /= (norm * r1 * r2 * r3
    -                                      * dr * dr * dr)
    +                    tpcf[i, j, k] /= norm * r1 * r2 * r3 * dr * dr * dr
                         rr[0, i, j, k] = r1
                         rr[1, i, j, k] = r2
                         rr[2, i, j, k] = r3
             return tpcf[1:, 1:, 1:], rr[:, 1:, 1:, 1:]
    [docs] @staticmethod - def static_structure_factor_from_atoms(atoms: ase.Atoms, number_of_bins, - kMax, - radial_distribution_function=None, - calculation_type="direct"): + def static_structure_factor_from_atoms( + atoms: ase.Atoms, + number_of_bins, + kMax, + radial_distribution_function=None, + calculation_type="direct", + ): """ Calculate the static structure factor (SSF). @@ -1010,11 +1086,12 @@

    Source code for mala.targets.target

             """
             if calculation_type == "fourier_transform":
                 if radial_distribution_function is None:
    -                rMax = Target._get_ideal_rmax_for_rdf(atoms)*6
    -                radial_distribution_function = Target.\
    -                    radial_distribution_function_from_atoms(atoms, rMax=rMax,
    -                                                            number_of_bins=
    -                                                            1500)
    +                rMax = Target._get_ideal_rmax_for_rdf(atoms) * 6
    +                radial_distribution_function = (
    +                    Target.radial_distribution_function_from_atoms(
    +                        atoms, rMax=rMax, number_of_bins=1500
    +                    )
    +                )
                 rdf = radial_distribution_function[0]
                 radii = radial_distribution_function[1]
     
    @@ -1024,14 +1101,15 @@ 

    Source code for mala.targets.target

     
                 # Fourier transform the RDF by calculating the integral at each
                 # k-point we investigate.
    -            rho = len(atoms)/atoms.get_volume()
    +            rho = len(atoms) / atoms.get_volume()
                 for i in range(0, number_of_bins + 1):
                     # Construct integrand.
    -                kpoints.append(dk*i)
    -                kr = np.array(radii)*kpoints[-1]
    -                integrand = (rdf-1)*radii*np.sin(kr)/kpoints[-1]
    -                structure_factor[i] = 1 + (4*np.pi*rho * simps(integrand,
    -                                                               radii))
    +                kpoints.append(dk * i)
    +                kr = np.array(radii) * kpoints[-1]
    +                integrand = (rdf - 1) * radii * np.sin(kr) / kpoints[-1]
    +                structure_factor[i] = 1 + (
    +                    4 * np.pi * rho * simps(integrand, radii)
    +                )
     
                 return structure_factor[1:], np.array(kpoints)[1:]
     
    @@ -1044,12 +1122,15 @@ 

    Source code for mala.targets.target

                 # The structure factor is undefined for wave vectors smaller
                 # then this number.
                 dk = float(kMax / number_of_bins)
    -            dk_threedimensional = atoms.get_cell().reciprocal()*2*np.pi
    +            dk_threedimensional = atoms.get_cell().reciprocal() * 2 * np.pi
     
                 # From this, the necessary dimensions of the k-grid for this
                 # particular k-max can be determined as
    -            kgrid_size = np.ceil(np.matmul(np.linalg.inv(dk_threedimensional),
    -                                           [kMax, kMax, kMax])).astype(int)
    +            kgrid_size = np.ceil(
    +                np.matmul(
    +                    np.linalg.inv(dk_threedimensional), [kMax, kMax, kMax]
    +                )
    +            ).astype(int)
                 print("Calculating SSF on k-grid of size", kgrid_size)
     
                 # k-grids:
    @@ -1064,7 +1145,7 @@ 

    Source code for mala.targets.target

                                 kgrid.append(k_point)
                 kpoints = []
                 for i in range(0, number_of_bins + 1):
    -                kpoints.append(dk*i)
    +                kpoints.append(dk * i)
     
                 # The first will hold S(|k|) (i.e., what we are actually interested
                 # in, the second will hold lists of all S(k) corresponding to the
    @@ -1081,7 +1162,9 @@ 

    Source code for mala.targets.target

                 cosine_sum = np.sum(np.cos(dot_product), axis=1)
                 sine_sum = np.sum(np.sin(dot_product), axis=1)
                 del dot_product
    -            s_values = (np.square(cosine_sum)+np.square(sine_sum)) / len(atoms)
    +            s_values = (np.square(cosine_sum) + np.square(sine_sum)) / len(
    +                atoms
    +            )
                 del cosine_sum
                 del sine_sum
     
    @@ -1100,11 +1183,13 @@ 

    Source code for mala.targets.target

                 return structure_factor[1:], np.array(kpoints)[1:]
     
             else:
    -            raise Exception("Static structure factor calculation method "
    -                            "unsupported.")
    + raise Exception( + "Static structure factor calculation method unsupported." + )
    -
    [docs] def get_radial_distribution_function(self, atoms: ase.Atoms, - method="mala"): +
    [docs] def get_radial_distribution_function( + self, atoms: ase.Atoms, method="mala" + ): """ Calculate the radial distribution function (RDF). @@ -1136,15 +1221,12 @@

    Source code for mala.targets.target

                 automatically calculated.
     
             """
    -        return Target.\
    -            radial_distribution_function_from_atoms(atoms,
    -                                                    number_of_bins=self.
    -                                                    parameters.
    -                                                    rdf_parameters
    -                                                    ["number_of_bins"],
    -                                                    rMax=self.parameters.
    -                                                    rdf_parameters["rMax"],
    -                                                    method=method)
    + return Target.radial_distribution_function_from_atoms( + atoms, + number_of_bins=self.parameters.rdf_parameters["number_of_bins"], + rMax=self.parameters.rdf_parameters["rMax"], + method=method, + )
    [docs] def get_three_particle_correlation_function(self, atoms: ase.Atoms): """ @@ -1166,14 +1248,11 @@

    Source code for mala.targets.target

                 The radii at which the TPCF was calculated (for plotting),
                 [rMax, rMax, rMax].
             """
    -        return Target.\
    -            three_particle_correlation_function_from_atoms(atoms,
    -                                                           number_of_bins=self.
    -                                                           parameters.
    -                                                           tpcf_parameters
    -                                                           ["number_of_bins"],
    -                                                           rMax=self.parameters.
    -                                                           tpcf_parameters["rMax"])
    + return Target.three_particle_correlation_function_from_atoms( + atoms, + number_of_bins=self.parameters.tpcf_parameters["number_of_bins"], + rMax=self.parameters.tpcf_parameters["rMax"], + )
    [docs] def get_static_structure_factor(self, atoms: ase.Atoms): """ @@ -1195,16 +1274,20 @@

    Source code for mala.targets.target

                 The k-points  at which the SSF was calculated (for plotting),
                 as [kMax] array.
             """
    -        return Target.static_structure_factor_from_atoms(atoms,
    -                                                         self.parameters.
    -                                                         ssf_parameters["number_of_bins"],
    -                                                         self.parameters.
    -                                                         ssf_parameters["number_of_bins"])
    + return Target.static_structure_factor_from_atoms( + atoms, + self.parameters.ssf_parameters["number_of_bins"], + self.parameters.ssf_parameters["number_of_bins"], + )
    [docs] @staticmethod - def write_tem_input_file(atoms_Angstrom, qe_input_data, - qe_pseudopotentials, - grid_dimensions, kpoints): + def write_tem_input_file( + atoms_Angstrom, + qe_input_data, + qe_pseudopotentials, + grid_dimensions, + kpoints, + ): """ Write a QE-style input file for the total energy module. @@ -1233,9 +1316,11 @@

    Source code for mala.targets.target

                 k-grid used, usually None or (1,1,1) for TEM calculations.
             """
             # Specify grid dimensions, if any are given.
    -        if grid_dimensions[0] != 0 and \
    -                grid_dimensions[1] != 0 and \
    -                grid_dimensions[2] != 0:
    +        if (
    +            grid_dimensions[0] != 0
    +            and grid_dimensions[1] != 0
    +            and grid_dimensions[2] != 0
    +        ):
                 qe_input_data["nr1"] = grid_dimensions[0]
                 qe_input_data["nr2"] = grid_dimensions[1]
                 qe_input_data["nr3"] = grid_dimensions[2]
    @@ -1248,10 +1333,14 @@ 

    Source code for mala.targets.target

             # the DFT calculation. If symmetry is then on in here, that
             # leads to errors.
             # qe_input_data["nosym"] = False
    -        ase.io.write("mala.pw.scf.in", atoms_Angstrom, "espresso-in",
    -                     input_data=qe_input_data,
    -                     pseudopotentials=qe_pseudopotentials,
    -                     kpts=kpoints)
    + ase.io.write( + "mala.pw.scf.in", + atoms_Angstrom, + "espresso-in", + input_data=qe_input_data, + pseudopotentials=qe_pseudopotentials, + kpts=kpoints, + )
    [docs] def restrict_data(self, array): """ @@ -1288,30 +1377,43 @@

    Source code for mala.targets.target

             return array_dimensions
     
         def _process_additional_metadata(self, additional_metadata):
    -        self.read_additional_calculation_data(additional_metadata[0],
    -                                              additional_metadata[1])
    +        self.read_additional_calculation_data(
    +            additional_metadata[0], additional_metadata[1]
    +        )
     
         def _set_openpmd_attribtues(self, iteration, mesh):
             super(Target, self)._set_openpmd_attribtues(iteration, mesh)
     
             # If no atoms have been read, neither have any of the other
             # properties.
    -        additional_calculation_data = \
    -            self.write_additional_calculation_data("", return_string=True)
    +        additional_calculation_data = self.write_additional_calculation_data(
    +            "", return_string=True
    +        )
             for key in additional_calculation_data:
    -            if key != "atoms" and key != "voxel" and key != "grid_dimensions" \
    -                    and key is not None and key != "pseudopotentials" and \
    -                    additional_calculation_data[key] is not None:
    +            if (
    +                key != "atoms"
    +                and key != "voxel"
    +                and key != "grid_dimensions"
    +                and key is not None
    +                and key != "pseudopotentials"
    +                and additional_calculation_data[key] is not None
    +            ):
                     iteration.set_attribute(key, additional_calculation_data[key])
                 if key == "pseudopotentials":
    -                for pseudokey in \
    -                        additional_calculation_data["pseudopotentials"].keys():
    -                    iteration.set_attribute("psp_" + pseudokey,
    -                                            additional_calculation_data[
    -                                                "pseudopotentials"][pseudokey])
    +                for pseudokey in additional_calculation_data[
    +                    "pseudopotentials"
    +                ].keys():
    +                    iteration.set_attribute(
    +                        "psp_" + pseudokey,
    +                        additional_calculation_data["pseudopotentials"][
    +                            pseudokey
    +                        ],
    +                    )
     
         def _process_openpmd_attributes(self, series, iteration, mesh):
    -        super(Target, self)._process_openpmd_attributes(series, iteration, mesh)
    +        super(Target, self)._process_openpmd_attributes(
    +            series, iteration, mesh
    +        )
     
             # Process the atoms, which can only be done if we have voxel info.
             self.grid_dimensions[0] = mesh["0"].shape[0]
    @@ -1335,55 +1437,91 @@ 

    Source code for mala.targets.target

                 cell[0] = self.voxel[0] * self.grid_dimensions[0]
                 cell[1] = self.voxel[1] * self.grid_dimensions[1]
                 cell[2] = self.voxel[2] * self.grid_dimensions[2]
    -            self.atoms = ase.Atoms(positions=positions, cell=cell, numbers=numbers)
    -            self.atoms.pbc[0] = iteration.\
    -                get_attribute("periodic_boundary_conditions_x")
    -            self.atoms.pbc[1] = iteration.\
    -                get_attribute("periodic_boundary_conditions_y")
    -            self.atoms.pbc[2] = iteration.\
    -                get_attribute("periodic_boundary_conditions_z")
    +            self.atoms = ase.Atoms(
    +                positions=positions, cell=cell, numbers=numbers
    +            )
    +            self.atoms.pbc[0] = iteration.get_attribute(
    +                "periodic_boundary_conditions_x"
    +            )
    +            self.atoms.pbc[1] = iteration.get_attribute(
    +                "periodic_boundary_conditions_y"
    +            )
    +            self.atoms.pbc[2] = iteration.get_attribute(
    +                "periodic_boundary_conditions_z"
    +            )
     
             # Process all the regular meta info.
    -        self.fermi_energy_dft = \
    -            self._get_attribute_if_attribute_exists(iteration, "fermi_energy_dft",
    -                                                    default_value=self.fermi_energy_dft)
    -        self.temperature = \
    -            self._get_attribute_if_attribute_exists(iteration, "temperature",
    -                                                    default_value=self.temperature)
    -        self.number_of_electrons_exact = \
    -            self._get_attribute_if_attribute_exists(iteration, "number_of_electrons_exact",
    -                                                    default_value=self.number_of_electrons_exact)
    -        self.band_energy_dft_calculation = \
    -            self._get_attribute_if_attribute_exists(iteration, "band_energy_dft_calculation",
    -                                                    default_value=self.band_energy_dft_calculation)
    -        self.total_energy_dft_calculation = \
    -            self._get_attribute_if_attribute_exists(iteration, "total_energy_dft_calculation",
    -                                                    default_value=self.total_energy_dft_calculation)
    -        self.electrons_per_atom = \
    -            self._get_attribute_if_attribute_exists(iteration, "electrons_per_atom",
    -                                                    default_value=self.electrons_per_atom)
    -        self.number_of_electrons_from_eigenval = \
    -            self._get_attribute_if_attribute_exists(iteration, "number_of_electrons_from_eigenvals",
    -                                                    default_value=self.number_of_electrons_from_eigenvals)
    -        self.qe_input_data["ibrav"] = \
    -            self._get_attribute_if_attribute_exists(iteration, "ibrav",
    -                                                    default_value=self.qe_input_data["ibrav"])
    -        self.qe_input_data["ecutwfc"] = \
    -            self._get_attribute_if_attribute_exists(iteration, "ecutwfc",
    -                                                    default_value=self.qe_input_data["ecutwfc"])
    -        self.qe_input_data["ecutrho"] = \
    -            self._get_attribute_if_attribute_exists(iteration, "ecutrho",
    -                                                    default_value=self.qe_input_data["ecutrho"])
    -        self.qe_input_data["degauss"] = \
    -            self._get_attribute_if_attribute_exists(iteration, "degauss",
    -                                                    default_value=self.qe_input_data["degauss"])
    +        self.fermi_energy_dft = self._get_attribute_if_attribute_exists(
    +            iteration, "fermi_energy_dft", default_value=self.fermi_energy_dft
    +        )
    +        self.temperature = self._get_attribute_if_attribute_exists(
    +            iteration, "temperature", default_value=self.temperature
    +        )
    +        self.number_of_electrons_exact = (
    +            self._get_attribute_if_attribute_exists(
    +                iteration,
    +                "number_of_electrons_exact",
    +                default_value=self.number_of_electrons_exact,
    +            )
    +        )
    +        self.band_energy_dft_calculation = (
    +            self._get_attribute_if_attribute_exists(
    +                iteration,
    +                "band_energy_dft_calculation",
    +                default_value=self.band_energy_dft_calculation,
    +            )
    +        )
    +        self.total_energy_dft_calculation = (
    +            self._get_attribute_if_attribute_exists(
    +                iteration,
    +                "total_energy_dft_calculation",
    +                default_value=self.total_energy_dft_calculation,
    +            )
    +        )
    +        self.electrons_per_atom = self._get_attribute_if_attribute_exists(
    +            iteration,
    +            "electrons_per_atom",
    +            default_value=self.electrons_per_atom,
    +        )
    +        self.number_of_electrons_from_eigenval = (
    +            self._get_attribute_if_attribute_exists(
    +                iteration,
    +                "number_of_electrons_from_eigenvals",
    +                default_value=self.number_of_electrons_from_eigenvals,
    +            )
    +        )
    +        self.qe_input_data["ibrav"] = self._get_attribute_if_attribute_exists(
    +            iteration, "ibrav", default_value=self.qe_input_data["ibrav"]
    +        )
    +        self.qe_input_data["ecutwfc"] = (
    +            self._get_attribute_if_attribute_exists(
    +                iteration,
    +                "ecutwfc",
    +                default_value=self.qe_input_data["ecutwfc"],
    +            )
    +        )
    +        self.qe_input_data["ecutrho"] = (
    +            self._get_attribute_if_attribute_exists(
    +                iteration,
    +                "ecutrho",
    +                default_value=self.qe_input_data["ecutrho"],
    +            )
    +        )
    +        self.qe_input_data["degauss"] = (
    +            self._get_attribute_if_attribute_exists(
    +                iteration,
    +                "degauss",
    +                default_value=self.qe_input_data["degauss"],
    +            )
    +        )
     
             # Take care of the pseudopotentials.
             self.qe_input_data["pseudopotentials"] = {}
             for attribute in iteration.attributes:
                 if "psp" in attribute:
    -                self.qe_pseudopotentials[attribute.split("psp_")[1]] = \
    +                self.qe_pseudopotentials[attribute.split("psp_")[1]] = (
                         iteration.get_attribute(attribute)
    +                )
     
         def _set_geometry_info(self, mesh):
             # Geometry: Save the cell parameters and angles of the grid.
    @@ -1398,7 +1536,7 @@ 

    Source code for mala.targets.target

             spacing = mesh.grid_spacing
             if "angles" in mesh.attributes:
                 angles = mesh.get_attribute("angles")
    -            self.voxel = ase.cell.Cell.new(cell=spacing+angles)
    +            self.voxel = ase.cell.Cell.new(cell=spacing + angles)
     
         def _get_atoms(self):
             return self.atoms
    @@ -1406,7 +1544,7 @@ 

    Source code for mala.targets.target

         @staticmethod
         def _get_ideal_rmax_for_rdf(atoms: ase.Atoms, method="mic"):
             if method == "mic":
    -            return np.min(np.linalg.norm(atoms.get_cell(), axis=0))/2
    +            return np.min(np.linalg.norm(atoms.get_cell(), axis=0)) / 2
             elif method == "2mic":
                 return np.min(np.linalg.norm(atoms.get_cell(), axis=0)) - 0.0001
             else:
    diff --git a/_modules/mala/targets/xsf_parser.html b/_modules/mala/targets/xsf_parser.html
    index 97d9aa802..84f8356f0 100644
    --- a/_modules/mala/targets/xsf_parser.html
    +++ b/_modules/mala/targets/xsf_parser.html
    @@ -114,17 +114,22 @@ 

    Source code for mala.targets.xsf_parser

             if found_datagrid is None:
                 if "BEGIN_BLOCK_DATAGRID_3D" in line:
                     found_datagrid = idx
    -                code = lines[idx+1].strip()
    +                code = lines[idx + 1].strip()
     
                     # The specific formatting may, similar to .cube files.
                     # So better to be specific.
                     if code != "3D_PWSCF":
    -                    raise Exception("This .xsf parser can only read .xsf files"
    -                                    " generated by Quantum ESPRESSO")
    +                    raise Exception(
    +                        "This .xsf parser can only read .xsf files"
    +                        " generated by Quantum ESPRESSO"
    +                    )
             else:
                 if idx == found_datagrid + 3:
    -                grid_dimensions = [int(line.split()[0]), int(line.split()[1]),
    -                                   int(line.split()[2])]
    +                grid_dimensions = [
    +                    int(line.split()[0]),
    +                    int(line.split()[1]),
    +                    int(line.split()[2]),
    +                ]
                     data = np.zeros(grid_dimensions, dtype=np.float64)
     
                     # Quantum ESPRESSO writes with 6 entries per line.
    @@ -133,9 +138,9 @@ 

    Source code for mala.targets.xsf_parser

                     first_data_line = found_datagrid + 8
     
             if first_data_line is not None:
    -            if first_data_line <= idx < number_data_lines+first_data_line:
    +            if first_data_line <= idx < number_data_lines + first_data_line:
                     dataline = line.split()
    -                if idx == number_data_lines+first_data_line-1:
    +                if idx == number_data_lines + first_data_line - 1:
                         number_entries = last_entry
                     else:
                         number_entries = 6
    diff --git a/_sources/CONTRIBUTE.md.txt b/_sources/CONTRIBUTE.md.txt
    index f4b9d5052..7465b8b80 100644
    --- a/_sources/CONTRIBUTE.md.txt
    +++ b/_sources/CONTRIBUTE.md.txt
    @@ -90,6 +90,14 @@ the core development team.
     * If you're adding code that should be tested, add tests
     * If you're adding or modifying examples, make sure to add them to `test_examples.py`
     
    +### Formatting code
    +
    +* MALA uses [`black`](https://github.com/psf/black) for code formatting
    +* The `black` configuration is located in `pyproject.toml`
    +* Currently, no automatic code reformatting will be done in the CI, thus
    +  please ensure that your code is properly formatted before creating a pull 
    +  request
    +
     ### Adding dependencies
     
     If you add additional dependencies, make sure to add them to `requirements.txt`
    @@ -98,7 +106,6 @@ they are not.
     Further, in order for them to be available during the CI tests, make sure to 
     add _required_ dependencies to the appropriate environment files in folder `install/` and _extra_ requirements directly in the `Dockerfile` for the `conda` environment build.
     
    -
     ## Pull Requests
     We actively welcome pull requests.
     1. Fork the repo and create your branch from `develop`
    diff --git a/api/mala.targets.cube_parser.html b/api/mala.targets.cube_parser.html
    index c437f26d5..bc4aa1dfd 100644
    --- a/api/mala.targets.cube_parser.html
    +++ b/api/mala.targets.cube_parser.html
    @@ -190,7 +190,7 @@
     
    Returns

    • data (numpy.array) – Data from cube file.

    • -
    • meta (dict) – Meta data from cube file.

    • +
    • meta (dict) – Metadata from cube file.

    diff --git a/objects.inv b/objects.inv index f7ce56e5c207a5922fb4546623b3c8158e703a1a..c42cde020e4be4c50939fe638140349f119d9588 100644 GIT binary patch delta 1565 zcmV+&2IBebGW#-+Uko@oEoV4kW;11GWizpB7ZZPI`uRFwx7iy&kA>fN&vVczLXA#Y zgvhj&i1^5jR3HOE0VxMfkm)785iuvogoxDq zF@q}fi7;oF1W#C~j%67nuZfx|2xK{qEr-m)&NP8VsUDI)PXRAi#J(wIdaJ^e1qFYs z925-hIu_n$(gg(=ig2`H*b>~KJS8XUKaflUz;fy8B5}$|@FFW|5!BO1Szr5`bqsiC zqH*S#7s2dh(TgnIZPH!gwITCBd>>q_)hSZHAm7vUVJaf_WK1KZB@z*0K*7BNS@HC~ zX2MCZim`@OX~;xHB?kJaLT2AKn3jJQ7naa@fD-@GoK6-DLR{t$K?^J=K<{rLCTCf* z?f^lo=bDMc8E0NB@DA^pH)5Sc;hd9TQ^tsn%o$ukEMhM3i?<8O;NCQck=Q?zN>)S` zL;12mpuW^zPu@y$ruHeAyGd{!Y-~hI0fE8w;9Ag`+r-0RSfIHhT1zpyPC9?=p99Uk zt6J#M6|GX~1loH_wcwLWO+z^(Fun~^OSE`}WH|RGn7L+emSS|RWY|9k`kVT6h%@*4 zg~PC5>>y?qQg(+IiibdbNt+U9dYxN12nv>O8BnKhaBWuDJqFqfl+0jdr)uFiG*Dkq zV#v_?Dh~%if%e)3Q~2I#bU1$w4KyC7^%TR~6h?E~z~tTn3y%JtgK*|WV0N8=4d0~l z$FBkdNAxy?LtPkz2WH;Et=Pt@F@6=8InY*eF1y?gXI}+s&(un;sSoRL5ELxA{ZykG z^@SrBp(?-`hm+wjEYP}nG$fEUcpMrm`!`gg54|9U-D9xes80zd`SO1Y`TtJ>Do&PGw}fy${~S?w;Uz@l6ReO=0%|L zm!f7F`Be#}fMDsXQzhcSBA%GS@)xQ~l(Mzk%bDC|y6D{jtT3Ae5Jxgp5YnEf(3U{4 z@2G?tZBK^%b1>eFoW*~UH!8z!@teL~So)L~I&U97gf%?D8qx(?(svORovh|d!93RQ zkZ(~Tk_QYEzF18cmSqIhin~ILGrXk&%C&YGA}?z=S$>=q;OKW$R9ax9+c?tBfgE#T zt$jgcu+aYT=I;Gd$X3Tuc%lcOdcgt5;)4645a($x&>-m_umyi{ibo57JVfkG^S7+N zNFk&}0)Gs*irP@Is89a}y_kTMB)-BdE^`>-lA-!bDp@5G-z?xlRW zNlJ)r*d}5(&d;IDi2hN&gfxh6c+jAK_RvhMYL3hw;dJj>LY_)8JUOI?ec|PBgUg$4 zpJNVmEVo>KFBgA+Z&IXzlZC#LhcM;I{HF{=+BhX-ZB_v_5c^6WX|mYk0IsBrM|dGY zy3|cXzg|k3L>|5pA`cV0yZrqFNmW25XZ-Naa5ZZw6XOM}H$480 P9Di{e{Qm_3N9LALX3*_F delta 1549 zcmV+o2J-p)GVC&tUko=jEoU||Vq#%sVrH>x7ZZQz6rn~}qeA8b`x(X0(wK}Jnk2PC zANlVHf-3M$SK#zI7A4qJoZV3&hl~iSCd+P^vqk!0oDzH}`aqt-FXCwgDq0+?$s%d% zQUkvf>HoU$kc78dfC7*_Q%9vq*gIz$F|-mBcpuC$w2%(fM!0T zn1g@D^d}o-dj8gnk&?U>VmDBXs5^j;w+j)DH>q4OM3noi;Tzs>-L}c2iKb0+lpy(v zp+%@)#+SDANo0d;Z@mQS!d6hsRf}B>2p}=eDX4@5r+6fpVjVBd$V-YZ;XQf%@ab-h z+k1OaWkZtU_vB00)@upvdCWf1MbayXQF> zL+7OVD;|meA4lUC9z=Y2MJkYipn#NvCdl+A-H43&WY$7z{+K}(`b3yBOoAsYRL8Om zlGjAd6a=yy$Cg88VP~4aqErvbpQnJAD`FphGQCw{%7Ow`4hjYr5(}3w>4E|bML2)j zFl-6#P@a+#b@E3nb+BBzx=5UI61>PtS_E~+QP$V~`Wpk@nP{AO=0z}jqw^w5cja?e zcx}i$5Z|m83u=ngFUa>aeVB@fJsHyoX^BLH7*KH6JytxuLzr+9tYWNTRT?r;QHg;* zs*u?S2&SdQg(Y+zpv1p4r;`PP5SM>BM9>1u3D8Rxh{;*jtUEvu>$zqkamJY!3%tY2 z;Eh-(Q8?!$*pxA%BXb5<5Q~@#{Nn9GGPujjVI=m?q>>ep#ZbO15U6jS*OL$Ks1Mtx zVD7rVd9bk&DFp-ucX(?-XRiDXhhc%{B4;hd=+5V`e-1R4qiUf?_ozyx6KH=g6V-xG zZXONgkihuLMlI3eJ&)nsn_%WHyjhCT-H&1a9O$pp(;?1Wz84O|g0UBuSxDJuT__#` z^-XF@oavow;UFkjz6wB{zQNsAVfPqlZ#go9l|7$@rgx#1O?i=5lrEG z&(7gEG|;$()>90xJQ&Sw1CxKt1uQuF%Lu}m7lE12e;d9@<&R$l2HxUr2#2~b2oKC$ zcw4cJRb%`rF!OS)pW= z?QG{MIp}9-f}_GKVS>u6pt4Ec!=0Q=5JYjkwSk+iv<1{ZWXnmVo{&| z4SF#FDM@^VSzP8Y#3e)h4=&v9;=*FQk=IA<1>T82ecVg=a+8!0-LOr>Zk(S(nGyY? zdfth_rD^$l9y|Y9RKNKGI~d#{pbP8ISNnf^?~yhJT@ODW;V zvR}k6wJ7<*z)&?mTj^NB8LyKdDqB`WD<2*svK1*zWLisIp*}Tf=NG7 zU2obKJQ<((Sr^`8wA-Iu$Go%^E$@Q95f3*k*7BBUzkR8M9{0^8bBo)cQf@Tae7NEZ zAs*xwK~Tq+VMHD#c6a&v2a>9QOwRZTo8fBKQYOX=SZ{dz8#(^sHu(Pog+O-Us6Otj diff --git a/searchindex.js b/searchindex.js index d7f2513ab..828677f54 100644 --- a/searchindex.js +++ b/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["CONTRIBUTE","advanced_usage","advanced_usage/descriptors","advanced_usage/hyperparameters","advanced_usage/openpmd","advanced_usage/predictions","advanced_usage/trainingmodel","api/mala","api/mala.common","api/mala.common.check_modules","api/mala.common.json_serializable","api/mala.common.parallelizer","api/mala.common.parameters","api/mala.common.physical_data","api/mala.datageneration","api/mala.datageneration.ofdft_initializer","api/mala.datageneration.trajectory_analyzer","api/mala.datahandling","api/mala.datahandling.data_converter","api/mala.datahandling.data_handler","api/mala.datahandling.data_handler_base","api/mala.datahandling.data_repo","api/mala.datahandling.data_scaler","api/mala.datahandling.data_shuffler","api/mala.datahandling.fast_tensor_dataset","api/mala.datahandling.lazy_load_dataset","api/mala.datahandling.lazy_load_dataset_single","api/mala.datahandling.multi_lazy_load_data_loader","api/mala.datahandling.snapshot","api/mala.descriptors","api/mala.descriptors.atomic_density","api/mala.descriptors.bispectrum","api/mala.descriptors.descriptor","api/mala.descriptors.lammps_utils","api/mala.descriptors.minterpy_descriptors","api/mala.interfaces","api/mala.interfaces.ase_calculator","api/mala.network","api/mala.network.acsd_analyzer","api/mala.network.hyper_opt","api/mala.network.hyper_opt_naswot","api/mala.network.hyper_opt_oat","api/mala.network.hyper_opt_optuna","api/mala.network.hyperparameter","api/mala.network.hyperparameter_acsd","api/mala.network.hyperparameter_naswot","api/mala.network.hyperparameter_oat","api/mala.network.hyperparameter_optuna","api/mala.network.multi_training_pruner","api/mala.network.naswot_pruner","api/mala.network.network","api/mala.network.objective_base","api/mala.network.objective_naswot","api/mala.network.predictor","api/mala.network.runner","api/mala.network.tester","api/mala.network.trainer","api/mala.targets","api/mala.targets.atomic_force","api/mala.targets.calculation_helpers","api/mala.targets.cube_parser","api/mala.targets.density","api/mala.targets.dos","api/mala.targets.ldos","api/mala.targets.target","api/mala.targets.xsf_parser","api/mala.version","api/modules","basic_usage","basic_usage/hyperparameters","basic_usage/more_data","basic_usage/predictions","basic_usage/trainingmodel","citing","index","install/installing_lammps","install/installing_mala","install/installing_qe","installation"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":5,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":3,"sphinx.domains.rst":2,"sphinx.domains.std":2,"sphinx.ext.intersphinx":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["CONTRIBUTE.md","advanced_usage.rst","advanced_usage/descriptors.rst","advanced_usage/hyperparameters.rst","advanced_usage/openpmd.rst","advanced_usage/predictions.rst","advanced_usage/trainingmodel.rst","api/mala.rst","api/mala.common.rst","api/mala.common.check_modules.rst","api/mala.common.json_serializable.rst","api/mala.common.parallelizer.rst","api/mala.common.parameters.rst","api/mala.common.physical_data.rst","api/mala.datageneration.rst","api/mala.datageneration.ofdft_initializer.rst","api/mala.datageneration.trajectory_analyzer.rst","api/mala.datahandling.rst","api/mala.datahandling.data_converter.rst","api/mala.datahandling.data_handler.rst","api/mala.datahandling.data_handler_base.rst","api/mala.datahandling.data_repo.rst","api/mala.datahandling.data_scaler.rst","api/mala.datahandling.data_shuffler.rst","api/mala.datahandling.fast_tensor_dataset.rst","api/mala.datahandling.lazy_load_dataset.rst","api/mala.datahandling.lazy_load_dataset_single.rst","api/mala.datahandling.multi_lazy_load_data_loader.rst","api/mala.datahandling.snapshot.rst","api/mala.descriptors.rst","api/mala.descriptors.atomic_density.rst","api/mala.descriptors.bispectrum.rst","api/mala.descriptors.descriptor.rst","api/mala.descriptors.lammps_utils.rst","api/mala.descriptors.minterpy_descriptors.rst","api/mala.interfaces.rst","api/mala.interfaces.ase_calculator.rst","api/mala.network.rst","api/mala.network.acsd_analyzer.rst","api/mala.network.hyper_opt.rst","api/mala.network.hyper_opt_naswot.rst","api/mala.network.hyper_opt_oat.rst","api/mala.network.hyper_opt_optuna.rst","api/mala.network.hyperparameter.rst","api/mala.network.hyperparameter_acsd.rst","api/mala.network.hyperparameter_naswot.rst","api/mala.network.hyperparameter_oat.rst","api/mala.network.hyperparameter_optuna.rst","api/mala.network.multi_training_pruner.rst","api/mala.network.naswot_pruner.rst","api/mala.network.network.rst","api/mala.network.objective_base.rst","api/mala.network.objective_naswot.rst","api/mala.network.predictor.rst","api/mala.network.runner.rst","api/mala.network.tester.rst","api/mala.network.trainer.rst","api/mala.targets.rst","api/mala.targets.atomic_force.rst","api/mala.targets.calculation_helpers.rst","api/mala.targets.cube_parser.rst","api/mala.targets.density.rst","api/mala.targets.dos.rst","api/mala.targets.ldos.rst","api/mala.targets.target.rst","api/mala.targets.xsf_parser.rst","api/mala.version.rst","api/modules.rst","basic_usage.rst","basic_usage/hyperparameters.rst","basic_usage/more_data.rst","basic_usage/predictions.rst","basic_usage/trainingmodel.rst","citing.rst","index.md","install/installing_lammps.rst","install/installing_mala.rst","install/installing_qe.rst","installation.rst"],objects:{"":[[7,0,0,"-","mala"]],"mala.common":[[9,0,0,"-","check_modules"],[10,0,0,"-","json_serializable"],[11,0,0,"-","parallelizer"],[12,0,0,"-","parameters"],[13,0,0,"-","physical_data"]],"mala.common.check_modules":[[9,1,1,"","check_modules"]],"mala.common.json_serializable":[[10,2,1,"","JSONSerializable"]],"mala.common.json_serializable.JSONSerializable":[[10,3,1,"","from_json"],[10,3,1,"","to_json"]],"mala.common.parallelizer":[[11,1,1,"","barrier"],[11,1,1,"","finalize"],[11,1,1,"","get_comm"],[11,1,1,"","get_local_rank"],[11,1,1,"","get_rank"],[11,1,1,"","get_size"],[11,1,1,"","parallel_warn"],[11,1,1,"","printout"],[11,1,1,"","set_current_verbosity"],[11,1,1,"","set_horovod_status"],[11,1,1,"","set_lammps_instance"],[11,1,1,"","set_mpi_status"]],"mala.common.parameters":[[12,2,1,"","Parameters"],[12,2,1,"","ParametersBase"],[12,2,1,"","ParametersData"],[12,2,1,"","ParametersDataGeneration"],[12,2,1,"","ParametersDescriptors"],[12,2,1,"","ParametersHyperparameterOptimization"],[12,2,1,"","ParametersNetwork"],[12,2,1,"","ParametersRunning"],[12,2,1,"","ParametersTargets"]],"mala.common.parameters.Parameters":[[12,4,1,"","comment"],[12,4,1,"","data"],[12,4,1,"","debug"],[12,4,1,"","descriptors"],[12,5,1,"","device"],[12,4,1,"","hyperparameters"],[12,3,1,"","load_from_file"],[12,3,1,"","load_from_json"],[12,3,1,"","load_from_pickle"],[12,4,1,"","manual_seed"],[12,4,1,"","network"],[12,5,1,"","openpmd_configuration"],[12,5,1,"","openpmd_granularity"],[12,3,1,"","optuna_singlenode_setup"],[12,4,1,"","running"],[12,3,1,"","save"],[12,3,1,"","save_as_json"],[12,3,1,"","save_as_pickle"],[12,3,1,"","show"],[12,4,1,"","targets"],[12,5,1,"","use_gpu"],[12,5,1,"","use_horovod"],[12,5,1,"","use_lammps"],[12,5,1,"","use_mpi"],[12,5,1,"","verbosity"]],"mala.common.parameters.ParametersBase":[[12,3,1,"","from_json"],[12,3,1,"","show"],[12,3,1,"","to_json"]],"mala.common.parameters.ParametersData":[[12,4,1,"","data_splitting_type"],[12,4,1,"","descriptors_contain_xyz"],[12,4,1,"","input_rescaling_type"],[12,4,1,"","output_rescaling_type"],[12,4,1,"","shuffling_seed"],[12,4,1,"","snapshot_directories_list"],[12,4,1,"","use_fast_tensor_data_set"],[12,4,1,"","use_lazy_loading"],[12,4,1,"","use_lazy_loading_prefetch"]],"mala.common.parameters.ParametersDataGeneration":[[12,4,1,"","local_psp_name"],[12,4,1,"","local_psp_path"],[12,4,1,"","ofdft_friction"],[12,4,1,"","ofdft_kedf"],[12,4,1,"","ofdft_number_of_timesteps"],[12,4,1,"","ofdft_temperature"],[12,4,1,"","ofdft_timestep"],[12,4,1,"","trajectory_analysis_below_average_counter"],[12,4,1,"","trajectory_analysis_correlation_metric_cutoff"],[12,4,1,"","trajectory_analysis_denoising_width"],[12,4,1,"","trajectory_analysis_estimated_equilibrium"],[12,4,1,"","trajectory_analysis_temperature_tolerance_percent"]],"mala.common.parameters.ParametersDescriptors":[[12,4,1,"","atomic_density_sigma"],[12,5,1,"","bispectrum_cutoff"],[12,5,1,"","bispectrum_switchflag"],[12,4,1,"","bispectrum_twojmax"],[12,4,1,"","descriptor_type"],[12,4,1,"","descriptors_contain_xyz"],[12,4,1,"","lammps_compute_file"],[12,5,1,"","use_y_splitting"],[12,5,1,"","use_z_splitting"]],"mala.common.parameters.ParametersHyperparameterOptimization":[[12,4,1,"","direction"],[12,4,1,"","hlist"],[12,4,1,"","n_trials"],[12,5,1,"","number_training_per_trial"],[12,5,1,"","rdb_storage_heartbeat"],[12,3,1,"","show"],[12,5,1,"","trial_ensemble_evaluation"]],"mala.common.parameters.ParametersNetwork":[[12,4,1,"","nn_type"]],"mala.common.parameters.ParametersRunning":[[12,5,1,"","after_before_training_metric"],[12,4,1,"","checkpoint_name"],[12,4,1,"","checkpoints_each_epoch"],[12,5,1,"","during_training_metric"],[12,4,1,"","early_stopping_epochs"],[12,4,1,"","early_stopping_threshold"],[12,4,1,"","inference_data_grid"],[12,4,1,"","learning_rate"],[12,4,1,"","learning_rate_decay"],[12,4,1,"","learning_rate_patience"],[12,4,1,"","learning_rate_scheduler"],[12,4,1,"","max_number_epochs"],[12,4,1,"","mini_batch_size"],[12,4,1,"","num_workers"],[12,4,1,"","profiler_range"],[12,4,1,"","training_report_frequency"],[12,4,1,"","trainingtype"],[12,4,1,"","use_compression"],[12,5,1,"","use_graphs"],[12,4,1,"","use_mixed_precision"],[12,4,1,"","use_shuffling_for_samplers"],[12,4,1,"","visualisation"],[12,4,1,"","visualisation_dir"],[12,4,1,"","visualisation_dir_append_date"],[12,4,1,"","weight_decay"]],"mala.common.parameters.ParametersTargets":[[12,4,1,"","ldos_gridoffset_ev"],[12,4,1,"","ldos_gridsize"],[12,4,1,"","ldos_gridspacing_ev"],[12,4,1,"","pseudopotential_path"],[12,4,1,"","rdf_parameters"],[12,5,1,"","restrict_targets"],[12,4,1,"","ssf_parameters"],[12,4,1,"","target_type"],[12,4,1,"","tpcf_parameters"]],"mala.common.physical_data":[[13,2,1,"","PhysicalData"]],"mala.common.physical_data.PhysicalData":[[13,2,1,"","SkipArrayWriting"],[13,5,1,"","data_name"],[13,5,1,"","feature_size"],[13,3,1,"","read_dimensions_from_numpy_file"],[13,3,1,"","read_dimensions_from_openpmd_file"],[13,3,1,"","read_from_numpy_file"],[13,3,1,"","read_from_openpmd_file"],[13,5,1,"","si_dimension"],[13,5,1,"","si_unit_conversion"],[13,3,1,"","write_to_numpy_file"],[13,3,1,"","write_to_openpmd_file"],[13,3,1,"","write_to_openpmd_iteration"]],"mala.datageneration":[[15,0,0,"-","ofdft_initializer"],[16,0,0,"-","trajectory_analyzer"]],"mala.datageneration.ofdft_initializer":[[15,2,1,"","OFDFTInitializer"]],"mala.datageneration.ofdft_initializer.OFDFTInitializer":[[15,3,1,"","get_equilibrated_configuration"]],"mala.datageneration.trajectory_analyzer":[[16,2,1,"","TrajectoryAnalyzer"]],"mala.datageneration.trajectory_analyzer.TrajectoryAnalyzer":[[16,5,1,"","first_snapshot"],[16,3,1,"","get_first_snapshot"],[16,3,1,"","get_snapshot_correlation_cutoff"],[16,3,1,"","get_uncorrelated_snapshots"],[16,5,1,"","snapshot_correlation_cutoff"],[16,5,1,"","trajectory"],[16,3,1,"","uncache_properties"]],"mala.datahandling":[[18,0,0,"-","data_converter"],[19,0,0,"-","data_handler"],[20,0,0,"-","data_handler_base"],[21,0,0,"-","data_repo"],[22,0,0,"-","data_scaler"],[23,0,0,"-","data_shuffler"],[24,0,0,"-","fast_tensor_dataset"],[25,0,0,"-","lazy_load_dataset"],[26,0,0,"-","lazy_load_dataset_single"],[27,0,0,"-","multi_lazy_load_data_loader"],[28,0,0,"-","snapshot"]],"mala.datahandling.data_converter":[[18,2,1,"","DataConverter"]],"mala.datahandling.data_converter.DataConverter":[[18,3,1,"","add_snapshot"],[18,3,1,"","convert_snapshots"],[18,4,1,"","descriptor_calculator"],[18,4,1,"","target_calculator"]],"mala.datahandling.data_handler":[[19,2,1,"","DataHandler"]],"mala.datahandling.data_handler.DataHandler":[[19,3,1,"","clear_data"],[19,3,1,"","get_snapshot_calculation_output"],[19,3,1,"","get_test_input_gradient"],[19,3,1,"","mix_datasets"],[19,3,1,"","prepare_data"],[19,3,1,"","prepare_for_testing"],[19,3,1,"","raw_numpy_to_converted_scaled_tensor"],[19,3,1,"","resize_snapshots_for_debugging"]],"mala.datahandling.data_handler_base":[[20,2,1,"","DataHandlerBase"]],"mala.datahandling.data_handler_base.DataHandlerBase":[[20,3,1,"","add_snapshot"],[20,3,1,"","clear_data"],[20,5,1,"","input_dimension"],[20,5,1,"","output_dimension"]],"mala.datahandling.data_scaler":[[22,2,1,"","DataScaler"]],"mala.datahandling.data_scaler.DataScaler":[[22,3,1,"","finish_incremental_fitting"],[22,3,1,"","fit"],[22,3,1,"","incremental_fit"],[22,3,1,"","inverse_transform"],[22,3,1,"","load_from_file"],[22,3,1,"","save"],[22,3,1,"","start_incremental_fitting"],[22,3,1,"","transform"]],"mala.datahandling.data_shuffler":[[23,2,1,"","DataShuffler"]],"mala.datahandling.data_shuffler.DataShuffler":[[23,3,1,"","add_snapshot"],[23,3,1,"","shuffle_snapshots"]],"mala.datahandling.fast_tensor_dataset":[[24,2,1,"","FastTensorDataset"]],"mala.datahandling.fast_tensor_dataset.FastTensorDataset":[[24,3,1,"","shuffle"]],"mala.datahandling.lazy_load_dataset":[[25,2,1,"","LazyLoadDataset"]],"mala.datahandling.lazy_load_dataset.LazyLoadDataset":[[25,3,1,"","add_snapshot_to_dataset"],[25,3,1,"","get_new_data"],[25,3,1,"","mix_datasets"],[25,5,1,"","return_outputs_directly"]],"mala.datahandling.lazy_load_dataset_single":[[26,2,1,"","LazyLoadDatasetSingle"]],"mala.datahandling.lazy_load_dataset_single.LazyLoadDatasetSingle":[[26,3,1,"","allocate_shared_mem"],[26,3,1,"","deallocate_shared_mem"],[26,3,1,"","delete_data"],[26,3,1,"","mix_datasets"]],"mala.datahandling.multi_lazy_load_data_loader":[[27,2,1,"","MultiLazyLoadDataLoader"]],"mala.datahandling.multi_lazy_load_data_loader.MultiLazyLoadDataLoader":[[27,3,1,"","cleanup"],[27,3,1,"","load_snapshot_to_shm"]],"mala.datahandling.snapshot":[[28,2,1,"","Snapshot"]],"mala.datahandling.snapshot.Snapshot":[[28,3,1,"","from_json"]],"mala.descriptors":[[30,0,0,"-","atomic_density"],[31,0,0,"-","bispectrum"],[32,0,0,"-","descriptor"],[33,0,0,"-","lammps_utils"],[34,0,0,"-","minterpy_descriptors"]],"mala.descriptors.atomic_density":[[30,2,1,"","AtomicDensity"]],"mala.descriptors.atomic_density.AtomicDensity":[[30,3,1,"","backconvert_units"],[30,3,1,"","convert_units"],[30,5,1,"","data_name"],[30,5,1,"","feature_size"],[30,3,1,"","get_optimal_sigma"]],"mala.descriptors.bispectrum":[[31,2,1,"","Bispectrum"]],"mala.descriptors.bispectrum.Bispectrum":[[31,3,1,"","backconvert_units"],[31,3,1,"","convert_units"],[31,5,1,"","data_name"],[31,5,1,"","feature_size"]],"mala.descriptors.descriptor":[[32,2,1,"","Descriptor"]],"mala.descriptors.descriptor.Descriptor":[[32,3,1,"","backconvert_units"],[32,3,1,"","calculate_from_atoms"],[32,3,1,"","calculate_from_qe_out"],[32,3,1,"","convert_local_to_3d"],[32,3,1,"","convert_units"],[32,5,1,"","descriptors_contain_xyz"],[32,3,1,"","enforce_pbc"],[32,3,1,"","gather_descriptors"],[32,5,1,"","si_dimension"],[32,5,1,"","si_unit_conversion"]],"mala.descriptors.lammps_utils":[[33,1,1,"","extract_compute_np"],[33,1,1,"","set_cmdlinevars"]],"mala.descriptors.minterpy_descriptors":[[34,2,1,"","MinterpyDescriptors"]],"mala.descriptors.minterpy_descriptors.MinterpyDescriptors":[[34,3,1,"","backconvert_units"],[34,3,1,"","convert_units"],[34,5,1,"","data_name"],[34,5,1,"","feature_size"]],"mala.interfaces":[[36,0,0,"-","ase_calculator"]],"mala.interfaces.ase_calculator":[[36,2,1,"","MALA"]],"mala.interfaces.ase_calculator.MALA":[[36,3,1,"","calculate"],[36,3,1,"","calculate_properties"],[36,4,1,"","implemented_properties"],[36,3,1,"","load_model"],[36,3,1,"","save_calculator"]],"mala.network":[[38,0,0,"-","acsd_analyzer"],[39,0,0,"-","hyper_opt"],[40,0,0,"-","hyper_opt_naswot"],[41,0,0,"-","hyper_opt_oat"],[42,0,0,"-","hyper_opt_optuna"],[43,0,0,"-","hyperparameter"],[44,0,0,"-","hyperparameter_acsd"],[45,0,0,"-","hyperparameter_naswot"],[46,0,0,"-","hyperparameter_oat"],[47,0,0,"-","hyperparameter_optuna"],[48,0,0,"-","multi_training_pruner"],[49,0,0,"-","naswot_pruner"],[50,0,0,"-","network"],[51,0,0,"-","objective_base"],[52,0,0,"-","objective_naswot"],[53,0,0,"-","predictor"],[54,0,0,"-","runner"],[55,0,0,"-","tester"],[56,0,0,"-","trainer"]],"mala.network.acsd_analyzer":[[38,2,1,"","ACSDAnalyzer"]],"mala.network.acsd_analyzer.ACSDAnalyzer":[[38,3,1,"","add_hyperparameter"],[38,3,1,"","add_snapshot"],[38,3,1,"","perform_study"],[38,3,1,"","set_optimal_parameters"]],"mala.network.hyper_opt":[[39,2,1,"","HyperOpt"]],"mala.network.hyper_opt.HyperOpt":[[39,3,1,"","add_hyperparameter"],[39,3,1,"","checkpoint_exists"],[39,3,1,"","clear_hyperparameters"],[39,3,1,"","perform_study"],[39,3,1,"","set_optimal_parameters"],[39,3,1,"","set_parameters"]],"mala.network.hyper_opt_naswot":[[40,2,1,"","HyperOptNASWOT"]],"mala.network.hyper_opt_naswot.HyperOptNASWOT":[[40,3,1,"","get_best_trial_results"],[40,3,1,"","perform_study"],[40,3,1,"","set_optimal_parameters"]],"mala.network.hyper_opt_oat":[[41,2,1,"","HyperOptOAT"]],"mala.network.hyper_opt_oat.HyperOptOAT":[[41,3,1,"","add_hyperparameter"],[41,3,1,"","get_best_trial_results"],[41,3,1,"","get_optimal_parameters"],[41,3,1,"","get_orthogonal_array"],[41,3,1,"","load_from_file"],[41,3,1,"","number_of_runs"],[41,3,1,"","perform_study"],[41,3,1,"","resume_checkpoint"],[41,3,1,"","set_optimal_parameters"],[41,3,1,"","show_order_of_importance"]],"mala.network.hyper_opt_optuna":[[42,2,1,"","HyperOptOptuna"]],"mala.network.hyper_opt_optuna.HyperOptOptuna":[[42,3,1,"","get_trials_from_study"],[42,3,1,"","load_from_file"],[42,3,1,"","perform_study"],[42,3,1,"","requeue_zombie_trials"],[42,3,1,"","resume_checkpoint"],[42,3,1,"","set_optimal_parameters"]],"mala.network.hyperparameter":[[43,2,1,"","Hyperparameter"]],"mala.network.hyperparameter_acsd":[[44,2,1,"","HyperparameterACSD"]],"mala.network.hyperparameter_naswot":[[45,2,1,"","HyperparameterNASWOT"]],"mala.network.hyperparameter_oat":[[46,2,1,"","HyperparameterOAT"]],"mala.network.hyperparameter_oat.HyperparameterOAT":[[46,3,1,"","get_categorical"],[46,3,1,"","get_parameter"],[46,5,1,"","num_choices"]],"mala.network.hyperparameter_optuna":[[47,2,1,"","HyperparameterOptuna"]],"mala.network.hyperparameter_optuna.HyperparameterOptuna":[[47,3,1,"","get_categorical"],[47,3,1,"","get_float"],[47,3,1,"","get_int"],[47,3,1,"","get_parameter"]],"mala.network.multi_training_pruner":[[48,2,1,"","MultiTrainingPruner"]],"mala.network.multi_training_pruner.MultiTrainingPruner":[[48,3,1,"","prune"]],"mala.network.naswot_pruner":[[49,2,1,"","NASWOTPruner"]],"mala.network.naswot_pruner.NASWOTPruner":[[49,3,1,"","prune"]],"mala.network.network":[[50,2,1,"","FeedForwardNet"],[50,2,1,"","GRU"],[50,2,1,"","LSTM"],[50,2,1,"","Network"],[50,2,1,"","PositionalEncoding"],[50,2,1,"","TransformerNet"]],"mala.network.network.FeedForwardNet":[[50,3,1,"","forward"]],"mala.network.network.GRU":[[50,3,1,"","forward"],[50,3,1,"","init_hidden"]],"mala.network.network.LSTM":[[50,3,1,"","forward"],[50,3,1,"","init_hidden"]],"mala.network.network.Network":[[50,3,1,"","calculate_loss"],[50,3,1,"","do_prediction"],[50,3,1,"","forward"],[50,3,1,"","load_from_file"],[50,3,1,"","save_network"]],"mala.network.network.PositionalEncoding":[[50,3,1,"","forward"]],"mala.network.network.TransformerNet":[[50,3,1,"","forward"],[50,3,1,"","generate_square_subsequent_mask"],[50,3,1,"","init_weights"]],"mala.network.objective_base":[[51,2,1,"","ObjectiveBase"]],"mala.network.objective_base.ObjectiveBase":[[51,3,1,"","parse_trial"],[51,3,1,"","parse_trial_oat"],[51,3,1,"","parse_trial_optuna"]],"mala.network.objective_naswot":[[52,2,1,"","ObjectiveNASWOT"]],"mala.network.predictor":[[53,2,1,"","Predictor"]],"mala.network.predictor.Predictor":[[53,3,1,"","predict_for_atoms"],[53,3,1,"","predict_from_qeout"]],"mala.network.runner":[[54,2,1,"","Runner"]],"mala.network.runner.Runner":[[54,3,1,"","load_run"],[54,3,1,"","run_exists"],[54,3,1,"","save_run"]],"mala.network.tester":[[55,2,1,"","Tester"]],"mala.network.tester.Tester":[[55,3,1,"","predict_targets"],[55,3,1,"","test_all_snapshots"],[55,3,1,"","test_snapshot"]],"mala.network.trainer":[[56,2,1,"","Trainer"]],"mala.network.trainer.Trainer":[[56,3,1,"","load_run"],[56,3,1,"","run_exists"],[56,3,1,"","train_network"]],"mala.targets":[[58,0,0,"-","atomic_force"],[59,0,0,"-","calculation_helpers"],[60,0,0,"-","cube_parser"],[61,0,0,"-","density"],[62,0,0,"-","dos"],[63,0,0,"-","ldos"],[64,0,0,"-","target"],[65,0,0,"-","xsf_parser"]],"mala.targets.atomic_force":[[58,2,1,"","AtomicForce"]],"mala.targets.atomic_force.AtomicForce":[[58,3,1,"","convert_units"],[58,3,1,"","get_feature_size"]],"mala.targets.calculation_helpers":[[59,1,1,"","analytical_integration"],[59,1,1,"","entropy_multiplicator"],[59,1,1,"","fermi_function"],[59,1,1,"","gaussians"],[59,1,1,"","get_beta"],[59,1,1,"","get_f0_value"],[59,1,1,"","get_f1_value"],[59,1,1,"","get_f2_value"],[59,1,1,"","get_s0_value"],[59,1,1,"","get_s1_value"],[59,1,1,"","integrate_values_on_spacing"]],"mala.targets.cube_parser":[[60,2,1,"","CubeFile"],[60,1,1,"","read_cube"],[60,1,1,"","read_imcube"],[60,1,1,"","write_cube"],[60,1,1,"","write_imcube"]],"mala.targets.cube_parser.CubeFile":[[60,3,1,"","readline"]],"mala.targets.density":[[61,2,1,"","Density"]],"mala.targets.density.Density":[[61,3,1,"","backconvert_units"],[61,3,1,"","convert_units"],[61,5,1,"","data_name"],[61,5,1,"","density"],[61,5,1,"","feature_size"],[61,3,1,"","from_cube_file"],[61,3,1,"","from_ldos_calculator"],[61,3,1,"","from_numpy_array"],[61,3,1,"","from_numpy_file"],[61,3,1,"","from_openpmd_file"],[61,3,1,"","from_xsf_file"],[61,3,1,"","get_atomic_forces"],[61,3,1,"","get_density"],[61,3,1,"","get_energy_contributions"],[61,3,1,"","get_number_of_electrons"],[61,3,1,"","get_scaled_positions_for_qe"],[61,3,1,"","get_target"],[61,3,1,"","invalidate_target"],[61,5,1,"","number_of_electrons"],[61,3,1,"","read_from_array"],[61,3,1,"","read_from_cube"],[61,3,1,"","read_from_xsf"],[61,5,1,"","si_dimension"],[61,5,1,"","si_unit_conversion"],[61,4,1,"","te_mutex"],[61,5,1,"","total_energy_contributions"],[61,3,1,"","uncache_properties"],[61,3,1,"","write_to_cube"],[61,3,1,"","write_to_openpmd_file"]],"mala.targets.dos":[[62,2,1,"","DOS"]],"mala.targets.dos.DOS":[[62,3,1,"","backconvert_units"],[62,5,1,"","band_energy"],[62,3,1,"","convert_units"],[62,5,1,"","data_name"],[62,5,1,"","density_of_states"],[62,5,1,"","energy_grid"],[62,5,1,"","entropy_contribution"],[62,5,1,"","feature_size"],[62,5,1,"","fermi_energy"],[62,3,1,"","from_ldos_calculator"],[62,3,1,"","from_numpy_array"],[62,3,1,"","from_numpy_file"],[62,3,1,"","from_qe_dos_txt"],[62,3,1,"","from_qe_out"],[62,3,1,"","get_band_energy"],[62,3,1,"","get_density_of_states"],[62,3,1,"","get_energy_grid"],[62,3,1,"","get_entropy_contribution"],[62,3,1,"","get_number_of_electrons"],[62,3,1,"","get_self_consistent_fermi_energy"],[62,3,1,"","get_target"],[62,3,1,"","invalidate_target"],[62,5,1,"","number_of_electrons"],[62,3,1,"","read_from_array"],[62,3,1,"","read_from_qe_dos_txt"],[62,3,1,"","read_from_qe_out"],[62,5,1,"","si_dimension"],[62,5,1,"","si_unit_conversion"],[62,3,1,"","uncache_properties"]],"mala.targets.ldos":[[63,2,1,"","LDOS"]],"mala.targets.ldos.LDOS":[[63,3,1,"","backconvert_units"],[63,5,1,"","band_energy"],[63,3,1,"","convert_units"],[63,5,1,"","data_name"],[63,5,1,"","density"],[63,5,1,"","density_of_states"],[63,5,1,"","energy_grid"],[63,5,1,"","entropy_contribution"],[63,5,1,"","feature_size"],[63,5,1,"","fermi_energy"],[63,3,1,"","from_cube_file"],[63,3,1,"","from_numpy_array"],[63,3,1,"","from_numpy_file"],[63,3,1,"","from_openpmd_file"],[63,3,1,"","from_xsf_file"],[63,3,1,"","get_atomic_forces"],[63,3,1,"","get_band_energy"],[63,3,1,"","get_density"],[63,3,1,"","get_density_of_states"],[63,3,1,"","get_energy_grid"],[63,3,1,"","get_entropy_contribution"],[63,3,1,"","get_number_of_electrons"],[63,3,1,"","get_self_consistent_fermi_energy"],[63,3,1,"","get_target"],[63,3,1,"","get_total_energy"],[63,3,1,"","invalidate_target"],[63,5,1,"","local_density_of_states"],[63,5,1,"","number_of_electrons"],[63,3,1,"","read_from_array"],[63,3,1,"","read_from_cube"],[63,3,1,"","read_from_xsf"],[63,5,1,"","si_dimension"],[63,5,1,"","si_unit_conversion"],[63,5,1,"","total_energy"],[63,3,1,"","uncache_properties"]],"mala.targets.target":[[64,2,1,"","Target"]],"mala.targets.target.Target":[[64,3,1,"","backconvert_units"],[64,3,1,"","convert_units"],[64,5,1,"","feature_size"],[64,3,1,"","get_energy_grid"],[64,3,1,"","get_radial_distribution_function"],[64,3,1,"","get_real_space_grid"],[64,3,1,"","get_static_structure_factor"],[64,3,1,"","get_target"],[64,3,1,"","get_three_particle_correlation_function"],[64,3,1,"","invalidate_target"],[64,5,1,"","qe_input_data"],[64,3,1,"","radial_distribution_function_from_atoms"],[64,3,1,"","read_additional_calculation_data"],[64,3,1,"","restrict_data"],[64,5,1,"","si_dimension"],[64,5,1,"","si_unit_conversion"],[64,3,1,"","static_structure_factor_from_atoms"],[64,3,1,"","three_particle_correlation_function_from_atoms"],[64,3,1,"","write_additional_calculation_data"],[64,3,1,"","write_tem_input_file"],[64,3,1,"","write_to_numpy_file"],[64,3,1,"","write_to_openpmd_file"]],"mala.targets.xsf_parser":[[65,1,1,"","read_xsf"]],mala:[[8,0,0,"-","common"],[14,0,0,"-","datageneration"],[17,0,0,"-","datahandling"],[29,0,0,"-","descriptors"],[35,0,0,"-","interfaces"],[37,0,0,"-","network"],[57,0,0,"-","targets"],[66,0,0,"-","version"]]},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","class","Python class"],"3":["py","method","Python method"],"4":["py","attribute","Python attribute"],"5":["py","property","Python property"]},objtypes:{"0":"py:module","1":"py:function","2":"py:class","3":"py:method","4":"py:attribute","5":"py:property"},terms:{"0":[2,5,6,11,12,13,18,22,32,33,36,39,43,44,45,46,47,53,59,61,63,64,69,72,76],"000":[2,74],"00001":72,"0048450":64,"005":69,"01":69,"01070":73,"015":69,"023":73,"030":41,"035120":73,"03610":64,"045008":73,"05":12,"1":[2,5,6,12,20,22,32,36,58,59,60,61,62,63,64,70,72,73],"10":[2,3,12,38,41,64,70,72,73,76],"100":[2,6,12,72,74],"1007":41,"1038":73,"104":73,"1063":64,"108":73,"1088":[38,73],"11":[6,12,70,72],"1103":73,"115":73,"12":[3,5,73],"1234":6,"125146":73,"16":73,"1606":64,"1696":64,"17":[64,73],"1883":12,"1_31":41,"1d":[61,63],"1s":12,"2":[2,5,6,12,33,59,62,64,70,72,77],"20":69,"200":5,"2017":60,"2019":[11,60],"2021":73,"2022":73,"2023":73,"2153":[38,73],"224":5,"25th":60,"2632":[38,73],"2685":12,"27":73,"2mic":64,"3":[2,3,12,20,32,41,61,63,70,73,76],"32":[59,69],"33":59,"36808":41,"39m":77,"3d":[61,63],"4":[2,6,12,13,18,70,72,73,76],"40":72,"400":5,"5":[3,6,12,64,70,72],"500":5,"57":64,"6":64,"64":69,"67637":[70,72],"7":[70,76,77],"8":[12,75],"9":73,"91":[32,70],"94":32,"96":69,"97":32,"978":41,"abstract":[13,39,50,64,73],"boolean":[48,49],"break":32,"case":[6,11,12,13,25,26,41,42,48,53,54,63,64,69,75,77],"class":[0,2,4,5,6,10,11,12,13,15,16,18,19,20,22,23,24,25,26,27,28,29,30,31,32,34,36,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,58,60,61,62,63,64,69,70,71,72],"const":60,"default":[4,5,6,11,12,18,19,28,32,33,38,52,53,54,56,62,63,69,70,77],"do":[0,2,3,4,5,7,11,12,19,20,23,25,26,27,30,31,32,34,41,42,50,55,57,59,60,61,63,67,69,70,71,72,75,78],"export":[10,12,76,77],"final":[6,11,72],"float":[12,16,30,33,39,43,44,45,46,47,50,53,59,60,62,63,64,69],"function":[0,1,2,3,5,6,8,9,11,12,13,16,17,22,28,30,31,32,33,34,36,41,42,43,49,50,51,52,58,59,61,62,63,64,69,70,71,72,73,74,76,78],"import":[1,2,3,36,41,53,63,64,71,77,78],"int":[11,12,13,15,16,18,19,23,25,26,39,43,44,45,46,47,50,52,55,59,60,61,62,64,69],"long":[6,12],"new":[0,3,6,11,12,23,25,26,33,69,72],"p\u00f6schel":0,"public":[2,3,6,69,70,73],"return":[2,10,11,12,13,16,19,22,28,30,31,32,33,34,39,41,42,43,46,47,48,49,50,53,54,55,56,58,59,60,61,62,63,64,65],"static":[5,12,27,30,31,32,34,42,50,58,60,61,62,63,64],"switch":[2,5,12],"true":[2,3,5,6,12,13,18,19,22,25,26,32,33,39,41,42,53,54,56,59,61,62,63,64,70,72],"try":26,"var":21,"while":[2,6,12,61,63,64,73],A:[0,3,5,6,10,11,12,13,16,20,24,27,28,32,36,40,42,48,49,51,53,55,56,60,61,63,64,69,73,74],AND:[11,42,50,60],AS:[11,60],ASE:[5,13,30,32,36,53,61,62,63,64],As:[2,3,4,5,62,72,76,78],BE:[11,42,60],BUT:[11,60],Be:[6,12,50],By:[0,5,6,11,12,61,62,63,69,70,72],FOR:[11,60],For:[2,3,4,5,12,16,19,26,32,36,42,54,56,63,64,69,70,71,72,74,75,78],IN:[11,60],IS:[11,60],IT:42,If:[0,2,3,4,5,6,12,13,15,16,18,19,20,22,23,25,26,32,33,38,39,41,42,48,49,53,54,55,56,59,60,61,62,63,64,69,70,73,74,75,77],In:[0,2,6,12,13,25,39,42,43,44,45,46,47,48,61,62,63,64,69,70,71,72,75,77],It:[3,6,12,26,53,55,60,61,62,63,64,68,71,72,74],NO:[11,60],NOT:[11,12,42,60],No:[2,6,12,22,36,72],OF:[11,12,15,60,74],OR:[11,60],Of:[6,12,72],On:3,One:[3,5,6,60,69,72],THE:[11,42,60],THEN:42,TO:[4,11,42,60],That:[54,69],The:[0,1,2,3,4,5,6,10,11,12,13,16,18,19,28,30,32,33,38,39,40,41,42,50,52,54,56,59,60,61,62,63,64,65,68,69,70,71,72,73,74,75,76,77,78],Their:70,Then:[2,5],There:[2,62,69,72],These:[2,3,6,18,42,62,69,70,74],To:[2,4,5,6,12,26,50,72,73,74,75,77],WILL:42,WITH:[11,60],Will:[16,33,43,63],With:[5,12,25,36,69],__getitem__:24,_build:76,_xxx:12,ab:64,abc:[13,20,39],abil:6,abl:0,about:[5,60,64],abov:[2,11,12,16,49,60,72],absolut:[50,55],absolute_valu:12,ac9956:[38,73],acceler:[1,3,5,6,68,73,74],acces:61,access:[3,5,6,9,16,21,22,26,36,64,69,70,71,72,74,77,78],accompani:[0,72,78],accord:[2,61,64,69],accordingli:[70,74],account:[64,74],accur:[2,3,6,64,70],accuraci:[3,6,12,41,72],achiev:12,acitv:12,acquaint:74,acquir:71,across:[1,12,55,72,73,74],acsd:[2,38,70],acsd_analyz:[7,37,67],acsd_point:2,acsdanalyz:[2,38],action:[11,12,60],activ:[0,3,4,5,6,12,54,69,72,74],actual:[0,6,13,16,25,41,42,50,55,69,72,78],actual_output:55,ad:[6,12,16,20,22,25,33,69,70],adam:[0,12,72],add:[0,2,12,18,20,22,23,25,33,38,39,41,69,70,72,73,75,77],add_hyperparamet:[2,38,39,41,69],add_snapshot:[2,4,6,18,20,23,38,69,70,72],add_snapshot_a:20,add_snapshot_to_dataset:25,addit:[0,5,6,12,13,18,36,54,61,64,73,76],addition:[6,72,74],additional_attribut:[13,61,64],additional_calculation_data:[54,72],additional_info_input_:70,additional_info_input_path:[18,70],additional_info_input_typ:[18,70],additional_info_save_path:[18,23,70],additional_metadata:13,additon:[12,36],aditya95sriram:60,adjust:[5,12,64,69,71],adress:[12,42],advanc:[2,5,68,69,70,71,72,73,74,76],advantag:18,advers:6,advis:[2,5,12,54],affect:[6,18],aforement:3,after:[0,3,6,12,36,70,72,75,76],after_before_training_metr:[3,6,12],afterward:[2,6,25,62,71,72],again:[22,76],against:[48,49],aggres:12,agre:[0,72],aidan:[0,73],aim:[5,6],akin:6,al:42,algorihm:12,algorithm:[6,12,69,74],all:[0,1,2,3,4,5,6,10,11,12,13,16,17,18,19,20,22,23,25,26,28,32,36,39,42,43,51,53,54,55,59,60,61,62,63,64,68,69,70,71,72,76,77,78],all_chang:36,alloc:[2,12,26],allocate_shared_mem:26,allow:[0,4,5,6,12,72,74,76],allreduc:12,along:[5,59,73,74],alongsid:[4,13,61,63,76],alphabet:0,alreadi:[6,13,54,71,72,76],also:[1,2,4,5,6,10,12,19,41,50,54,68,70,71,72,73,76,78],alter:[3,71],altern:[12,13,42],alternative_storage_path:42,although:[40,61,74],aluminium:74,alwai:[6,11,12,38,39,43,44,45,46,47,63,68,69,70,75],am:32,american:73,among:69,amount:[2,6,23,72],amp:12,an:[0,1,2,3,4,5,6,11,12,13,15,16,19,25,26,28,30,32,33,36,41,42,44,46,47,48,49,50,51,53,54,58,60,61,62,63,64,68,69,70,71,74,75,76,77],analys:40,analysi:[2,4,5,12,16,38,41,42],analyt:[59,62,63],analytical_integr:59,analyz:[16,38],ang:[58,61],angstrom:32,ani:[6,11,12,13,16,18,24,25,26,36,48,49,50,60,61,64,69,70,72,73,74],anoth:[3,6,26],anyth:[12,61],anywai:18,ap:73,apart:[6,70],api:[4,71,72,74],apidoc:76,appli:[12,19,22,42,64,72,73],applic:[42,52],approach:[18,25,26,28,39,43,44,45,46,47,73],appropri:[0,6,63,70],approxim:59,apt:77,ar:[0,1,2,3,4,5,6,11,12,13,16,18,19,20,25,26,28,32,39,40,42,43,44,45,46,47,50,52,53,54,55,58,59,60,61,62,63,64,65,68,69,70,71,72,73,74,76,78],arbitrari:64,architectur:[3,37,39,40,42,50,51,69,75,76],archiv:[16,72],arg:[24,25,26,36,48,49,50,60],argdict:33,argument:[12,18,33,59,70],aris:[11,60,77],around:2,arrai:[3,12,13,18,19,20,22,23,27,28,30,31,32,33,34,41,46,50,51,53,58,59,60,61,62,63,64,65,76],array_shap:33,articl:[73,74],arxiv:64,as_numpi:22,asap3:64,asap:64,ase:[15,16,30,32,36,53,61,63,64,71],ase_calcul:[7,35,67],aspect:72,assert:74,assign:[6,12,50],associ:[11,60,61,62],assum:[12,13,16,25,26,33,50,59,61,64,68,69,72,77],assumpt:12,asterisk:63,atom:[2,5,6,12,15,16,28,32,36,53,58,60,61,63,64,70,71,72,74,78],atomic_dens:[7,29,67],atomic_density_sigma:12,atomic_forc:[7,57,61,67],atomicdens:30,atomicforc:58,atomist:71,atoms_angstrom:[61,63,64],attach:6,attempt:[4,23,54,56,61,63,64],attent:[12,73],attila:[0,73,74],attribut:[10,12,13,16,21,28,51,61,64],austin:[0,73],author:[11,60,73],automat:[3,5,6,12,16,41,50,64,76],avail:[0,2,6,9,12,18,32,39,43,44,45,46,47,59,69,70,72,75,76],availab:6,averag:[2,3,12,64,72],avoid:[3,12,26],awar:[5,50,64,75,77],axi:[12,59],b:[59,73,74],back:[12,26,42],backbon:72,backconvert_unit:[30,31,32,34,61,62,63,64],backend:[5,12],background:3,bad:6,band:[6,12,48,55,62,63,72],band_energi:[3,6,12,48,55,62,63,72],band_energy_ful:55,barrier:11,bartosz:0,base:[0,2,3,4,5,10,12,13,15,16,18,19,20,22,23,24,25,26,27,28,30,31,32,34,36,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,58,60,61,62,63,64,69,72,74],baselin:11,baseprun:[48,49],basi:[12,60],basic:[2,5,6,68,70,72,74],bat:76,batch:[12,52,69],batch_siz:52,be_dens:5,be_ldo:70,be_model:[71,72],be_shuffl:[4,6],be_snapshot0:[4,6,70,72],be_snapshot1:[2,6,71,72],be_snapshot2:2,be_snapshot:[4,70],becaus:[3,12,36,72],been:[0,2,3,6,22,32,62,70,72,73,74,76,77,78],befor:[0,6,12,48,49,63,64,72,76],behavior:12,being:[5,6,11,25,26,36,54,55,56,61,62,63,72],believ:12,below:[0,12,16,60],benchmark:54,best:[12,40,41,61,69],beta:[59,62],better:6,between:[2,3,6,11,12,16,23,25,42,69],bias:[6,12],bidirect:12,big:[0,64],bigger:12,bin:[12,64,75,77],binari:[70,76],bind:77,bispectrum:[2,7,12,29,32,67,70,71,72,75],bispectrum_cutoff:[2,12,70,72],bispectrum_switchflag:12,bispectrum_twojmax:[2,12,70,72],bit:[12,24,61],blob:[11,64],bohr:[2,61,63,70],boldsymbol:63,bool:[11,12,13,18,19,22,25,26,32,33,39,41,42,48,49,53,54,56,59,61,62,63,64],both:[2,3,55,60,74],bottleneck:6,bound:[39,43,44,45,47,69],boundari:12,bp:4,branch:75,briefli:6,brillouin:59,broadcast_band_energi:62,broadcast_entropi:62,broadcast_fermi_energi:62,brown:11,brzoza:0,buffer:[26,27],bug:0,bugfix:0,build:[0,4,12,19,68,74],build_fold:75,build_mpi:75,build_shared_lib:75,build_total_energy_energy_modul:77,built:[0,11,75],bump2vers:76,bumpvers:0,busi:6,by_snapshot:12,c:[11,60,64],cach:[16,25,26,61,62,63,64],calcul:[0,2,5,6,11,12,13,15,16,18,19,20,22,28,29,30,31,32,33,34,36,38,41,50,52,53,54,55,57,58,59,61,62,63,64,69,70,72,73,74,75,78],calculate_from_atom:32,calculate_from_qe_out:32,calculate_loss:50,calculate_properti:36,calculation_help:[7,57,67],calculation_output:[19,28],calculation_output_fil:20,calculation_typ:64,calibr:[48,49],call:[2,3,6,11,12,13,16,18,24,41,42,49,50,62,64,70,71,72,73,74,78],callow:0,can:[2,3,4,5,6,7,9,10,11,12,13,16,18,19,22,25,26,32,36,41,42,50,51,53,54,55,56,64,69,70,71,72,74,75,77,78],candid:[48,49,69],cangi:[0,73,74],cannot:[6,32,61,63],capabilit:2,capabl:[1,3,4,74],care:[6,26,42],categor:[3,12,39,41,43,44,45,46,47,69],categori:11,caus:73,cd:76,cell:[5,12,30,32,36,50,61,63,64],center:[59,74],cento:78,central:[3,50,72],certain:[12,18,39,40,42,62],cff:0,cflag:77,challeng:[73,74],chanc:[3,12],chang:[0,3,4,5,12,36,62,64,75,76,77],changelog:0,chapter:41,character:[12,30],charg:[11,36,60],check:[0,4,6,9,19,22,36,39,48,54,56,75,76],check_modul:[7,8,67],checkout:[21,75,76],checkpoint:[12,36,39,41,42,54,56],checkpoint_exist:[39,56],checkpoint_nam:[3,6,12,39,41,42],checkpoints_each_epoch:[6,12],checkpoints_each_tri:[3,12],chemistri:73,choic:[38,39,41,43,44,45,46,47,52,69,72],choos:[0,2,12],chosen:[2,12,70],ci:0,circumv:[6,73],citat:[0,73],cite:74,citeseerx:64,cl:54,claim:[11,60],classic:36,classmethod:[10,12,22,28,36,39,41,42,50,54,56,61,62,63],clean:[42,76],cleanup:27,clear:[0,19,39],clear_data:[19,20],clear_hyperparamet:39,clone:76,cloud:2,cluster:[3,42,77],cmake:75,cmake_cxx_compil:75,cmdarg:33,coars:[2,72],code:[3,32,35,64,68,71,73,74,75,76,78],coeffici:72,collabor:0,collect:[3,12,33],collector:36,com:[0,11,12,21,41,60,64,75,76,77],combin:[2,32,36,69],come:[12,32],comm:[11,13],comm_world:11,command:[3,12,33,69],comment:12,commit:0,common:[7,11,12,15,16,18,19,20,23,28,30,31,32,34,36,38,39,40,41,42,43,48,49,50,52,53,54,55,56,58,61,62,63,64,67],commun:[3,11,12,32],compar:[2,12,16,72,74],comparison:64,compat:[3,4,12,21,41,42,50,51,65,71,75],compil:[75,77],complei:60,complet:[6,70],complete_save_path:[6,18,23,70],complex:60,complianc:0,compliant:4,complic:[2,6],compon:[32,70],comprehens:74,compress:[4,12],compuat:64,comput:[1,2,12,22,33,68,73,74],computation:[3,5],compute_typ:33,concept:[3,74],concern:37,concert:54,conda:0,condens:70,condit:[3,11,60],conduct:74,configur:[4,12,15,16,32,53,71,72,75,77],conjunct:[3,12],connect:[11,60],consecut:12,conserve_dimens:63,consid:[0,12,19],consist:[18,19,28,60,62,63,69,72,78],consquenc:16,constant:60,constitut:0,construct:[3,12,18,59,64,72,73,74],constructor:60,consult:[0,4],contain:[2,4,10,12,13,20,23,28,29,32,36,40,55,60,61,62,63,64,72],continu:[54,56,76],contract:[11,60],contribut:[12,61,62,63,74],control:[12,25,32,64,72],convent:[39,41,64],convers:[1,13,19,20,23,25,26,27,32,33,58,61,62,63,64,68],convert3dto1d:19,convert:[4,10,12,18,19,30,31,32,33,34,38,58,61,62,63,64,70],convert_local_to_3d:32,convert_snapshot:[4,18,70],convert_to_threedimension:61,convert_unit:[30,31,32,34,58,61,62,63,64],converted_arrai:[30,31,32,34,58,61,62,63,64],converted_tensor:19,convet:[43,44,45,46,47],cooper:6,coordin:[12,32],copi:[11,48,49,54,60,61,62],copyright:[11,60],core:[0,77],correct:[2,5,6,36,43,50,60,61,69,72,76],correctli:[0,61,76],correl:[3,12,16,64],correspond:[6,12,64,69,70],cosin:[2,16],cost:12,costli:74,could:[5,12],count:12,counter:12,cours:[6,12,72],cover:[68,71],covers:[61,63],cpp:64,cppflag:77,cpu:[1,2,3,6,53,54,63,68,75],cpython:77,creat:[5,6,12,13,15,16,18,19,20,23,30,31,32,34,36,38,39,40,41,42,48,49,50,52,53,54,55,56,58,60,61,62,63,64,69,70,71,72,75,76],create_fil:61,create_qe_fil:63,creation:[19,70],critic:72,crucial:4,csv:72,cube:[5,60,61,63,70],cube_pars:[7,57,67],cubefil:60,cubetool:60,cubic:[61,63,64,74],cuda:[6,12,75],current:[3,4,5,6,11,12,14,25,26,38,39,40,41,43,46,47,50,51,54,58,59,60,61,62,63,64,70],curv:12,custom:[63,69],cut:12,cutoff:[2,12,16,70],d:[59,62,63,73,74,75],d_model:50,dai:73,damag:[11,60],daniel:[0,11],data:[0,1,3,5,6,7,12,13,14,17,18,19,20,21,22,23,24,25,26,27,28,30,31,32,33,34,36,38,39,40,41,42,50,53,54,55,56,58,59,60,61,62,63,64,65,68,69,71,73,74,78],data_:4,data_convert:[4,7,17,38,67,70],data_handl:[4,5,7,17,36,39,40,41,42,49,51,52,53,54,55,56,63,67,69,71,72],data_handler_bas:[7,17,19,23,67],data_nam:[13,30,31,34,61,62,63],data_path:[2,4,6,70,71,72],data_repo:[7,17,67],data_repo_path:21,data_scal:[7,17,19,25,26,67],data_shuffl:[4,6,7,17,67],data_splitting_typ:12,data_typ:[19,55,64],databas:3,databasenam:3,dataconvert:[2,4,6,18,19,70],dataformat:60,datagener:[7,67],datahandl:[2,3,4,6,7,18,19,23,25,26,27,36,38,39,40,41,42,49,52,53,54,55,56,63,67,69,72],datahandlerbas:[19,20,23],dataload:[25,26],datasampl:[25,26],datascal:[19,22,25,26],dataset:[13,19,24,25,26,27],datashuffl:[4,6,12,23],datashufl:6,datatyp:[39,41,43,44,45,46,47],date:[0,12,60],dayton:73,db:63,dd:63,dd_db:63,de:63,de_dd:63,deactivt:69,dead:42,deadlin:0,deal:[11,13,60,72],dealloc:[26,27],deallocate_shared_mem:26,debian:77,debug:[3,12,72,76],decad:73,decai:12,decid:[0,12,69,72],declar:4,decreas:[12,69],deep:[73,74],defin:[12,48,49,59,62,63,71],degre:16,delete_data:26,delta:[59,62],demand:[2,3,12,50],demonstr:[73,74],denois:12,dens_object:61,denser:70,densiti:[2,5,7,12,55,57,58,62,63,67,71,73,74],density_calcul:[5,61],density_data:[61,63],density_of_st:[5,62,63,71],depend:[5,12,13,19,54,56,60,61,63,70,76],depth:[1,69],deriv:[25,26,27,50,63],descent:12,desciptor:32,describ:[13,30,31,34,61,62,63,69],descript:[0,60,69],descriptor:[0,5,7,11,12,18,19,20,23,25,26,27,28,30,31,34,38,53,63,67,70,71,72,74,75],descriptor_calcul:[18,19,20,23,25,26,27,38],descriptor_calculation_kwarg:[18,70],descriptor_dimens:32,descriptor_input_path:[18,38,70],descriptor_input_typ:[18,38,70],descriptor_save_path:[18,23,70],descriptor_typ:[12,70,72],descriptor_unit:[18,38],descriptors_contain_xyz:[12,32],descriptors_np:32,deseri:10,deserialized_object:[10,12,28],design:3,desir:[12,16,19,30,31,32,34,43,50,61,62,63,64,74],despit:73,detail:[2,3,12,18,38,74],determin:[2,3,5,12,16,55,69,70,72],determinist:12,detriment:12,dev:76,develop:[6,70,74,76,78],deviat:[3,12,22,72],devic:12,devis:2,dft:[3,5,6,7,12,15,18,22,28,32,61,62,63,68,70,74],diagnost:12,dicitionari:33,dict:[10,12,13,18,28,33,55,60,61,63,64,65],dictionari:[10,12,13,18,28,32,33,55,61,62,63,64,72],dictionati:[61,63,64],diff:0,differ:[2,5,6,38,42,52,59,61,69],differenti:12,dim:19,dimens:[5,12,13,20,25,26,30,31,32,34,50,58,61,62,63,64,72],dimension:[2,13,62,70],dipol:36,direct:[0,5,12,18,64,71],directli:[0,2,6,11,12,32,50,53,54,61,62,63,64,72],directori:[0,6,12,18,19,20,23,28,32,63,76,77],dirti:0,disabl:[6,12,25,26,54],discontinu:12,discourag:[25,26],discret:[5,61,62,63,70],discuss:[1,2,3,6,70,72,74],disentangl:3,disk:[6,23,63,72],displac:16,distanc:[2,12,16],distance_threshold:16,distinct:[2,39,43,44,45,46,47],distinguish:3,distribut:[3,5,11,12,50,60,62,64],divid:[5,61],divisor:[12,59],do_predict:50,doc:76,dockerfil:0,docstr:0,document:[0,4,11,12,60,71,78],documentari:76,doe:[6,11,12,19,30,31,34,39,40,56,60,61,62,63,69,76],doesn:[60,62],doi:[38,64,73],don:[12,64],done:[0,2,3,5,11,12,32,38,39,40,41,42,53,55,60,61,64,69,70,72],dornheim:74,dos_calcul:62,dos_data:[62,63],dos_object:62,dos_valu:63,dot:60,doubl:[18,33],doubt:32,down:11,download:77,drastic:[6,18],drawback:6,dresden:74,drive:28,driven:[4,72],dropout:[12,50],dtype:[13,60],due:[61,62,63],dummi:60,dure:[0,2,6,11,12,49,52,54,63,64,69,71,72,73,76],during_training_metr:12,dx:73,dynam:[12,55,71,74],e:[1,3,4,5,6,12,13,16,18,19,30,31,32,34,35,36,38,39,40,41,42,43,44,45,46,47,59,61,62,63,64,69,70,71,72,75,76,77,78],e_:61,e_ewald:61,e_grid:[62,63],e_hartre:61,e_rho_times_v_hxc:61,e_xc:61,eac:12,each:[2,3,5,12,16,42,48,49,69,70,72,74],earli:12,earlier:64,early_stopping_epoch:[12,69],early_stopping_threshold:12,easi:[3,6,55],easier:[19,71,72],easili:[0,2,3,6,69,72],edu:64,effect:[3,6,12,33,54,63,74],effici:[4,5,64,74,78],effort:[0,74],effortlessli:74,eigenvalu:62,either:[0,5,12,13,19,20,23,40,55,59,61,63,64,69,70,72],electron:[5,7,36,55,58,61,62,63,64,70,71,72,73,74],elem_snapshot:18,elimin:3,elli:[0,73,74],els:[3,6],elsewis:[13,16],emploi:[1,6,72,74],empti:[12,65],emul:22,en:41,enabl:[2,3,5,6,53,54,55,70,72,75],encapsul:6,encod:[2,32,51,70,72,78],encourag:4,end:[3,4,11,12,13,16,42,61,62,63,64,69,72],energi:[0,5,6,7,12,36,48,55,59,61,62,63,64,70,71,72,74,78],energy_grid:[5,59,62,63],energy_integration_method:63,energy_unit:59,energygrid:[62,63],enforc:[32,50,64],enforce_pbc:32,enhanc:[0,74],enough:[2,6,12,48,49,70,78],ensur:[0,6,11,12,18,19,61,63,74],enter:63,entir:[5,6,13,19,20,28,32,50,54,70,72],entri:[0,5,12,61,72],entropi:[59,62,63],entropy_contribut:[62,63],entropy_multipl:59,enviro:70,environ:[0,2],epoch:[6,12,69],epsilon:[59,62],epsilon_:62,epsilon_f:[59,62,63],eq:[59,64],equal:33,equat:[62,64],equilibr:[12,15,16,74],equilibrated_snapshot:16,equival:62,erro:76,erron:26,error:[5,6,11,12,25,55,61,62,63,76],especi:[3,12,48,78],espresso:[2,5,18,32,61,62,63,64,70,71,78],essenti:[12,18,69],establish:6,estim:[12,16],etc:[0,3,10,12,20,28,36,39,43,44,45,46,47,54,69,71,72],euclidean:12,ev:[12,20,32,58,59,61,62,63,64],evalu:[3,5,12,19,63],even:[1,5,64,71],evenli:5,event:[11,60],eventu:[36,63],everi:[0,15,63],everyth:[12,37],evid:12,ewald:61,ex01_checkpoint:6,ex01_checkpoint_train:6,ex01_train_network:72,ex02_shuffle_data:6,ex02_test_network:72,ex03_preprocess_data:70,ex03_tensor_board:6,ex04_acsd:2,ex04_hyperparameter_optim:69,ex05_checkpoint:3,ex05_checkpoint_hyperparameter_optim:3,ex05_run_predict:71,ex06_ase_calcul:71,ex06_distributed_hyperparameter_optim:3,ex07_advanced_hyperparameter_optim:3,ex08_visualize_observ:5,exact:[62,63],exactli:[61,62,63],exampl:[0,2,3,4,5,6,21,41,68,69,70,71,72,74,75],example_minimal_number_of_runs_oa:41,except:[3,5,61,64],excess:73,exclud:12,exclus:[5,69],execut:[3,22,42,68,75],exhibit:74,exist:[3,6,26,39,54,56,60,62,71],expans:2,expect:[6,12],experi:12,experiment:[12,14,69],experiment_ddmmyi:12,explain:69,explan:69,explicitli:[12,32],explictli:32,explor:74,exploratori:[2,4],expon:59,express:[11,60,62,63],extend:[5,18,69,71,74],extens:[4,6],extent:13,external_modul:77,extra:[0,32],extract:[3,13,33,46,47,61,65],extract_compute_np:33,f0:59,f1:59,f2:59,f2py:61,f90:77,f90exec:77,f:59,facilit:74,factor:[2,5,6,12,41,59,62,64,69],fail:12,fairli:[32,71],falkner18a:12,fals:[2,6,12,13,16,18,19,22,25,32,33,38,39,40,41,42,53,54,56,59,61,63,64],familiar:[3,68,72],far:[12,70],faruk:0,fashion:69,fast:12,fast_tensor_dataset:[7,17,67],faster:[5,6,18,24,32,71,75,77],fasttensordataset:[24,26],featur:[0,3,6,12,13,20,22,30,31,34,58,61,62,63,64,68,69,72,74,78],feature_from:13,feature_s:[13,30,31,34,61,62,63,64],feature_to:13,fed:74,feed:[12,50],feed_forward:12,feedforwardnet:50,fermi:[55,59,62,63,64],fermi_energi:[59,62,63],fermi_energy_self_consist:[62,63],fermi_funct:59,fermi_v:59,fetch:27,few:[3,5,72],feynman:61,ff:0,ff_multiple_layers_count:69,ff_multiple_layers_neuron:69,ff_neurons_lay:69,ff_neurons_layer_001:[39,43,44,45,46,47],ff_neurons_layer_002:[39,43,44,45,46,47],ff_neurons_layer_00:69,ff_neurons_layer_01:69,ff_neurons_layer_xx:69,ff_neurons_layer_xxx:12,fflag:77,fiedler:[0,73,74],field:70,file:[0,3,4,5,6,10,11,12,13,15,16,18,19,20,22,23,25,26,27,28,32,36,41,42,50,53,54,56,60,61,62,63,64,65,69,70,72,74,76,77],file_based_commun:[18,38],file_index:25,file_nam:61,file_path:[41,42],filenam:[4,12,22,36,60,65],filename_uncorrelated_snapshot:16,filepath:64,fill:[12,15,69,70],find:[41,73,77],fine:[6,12,70],fingerprint:[12,18,32,38],finish:[6,42],finish_incremental_fit:22,finit:[73,74],first:[2,5,12,16,18,48,49,61,69,70,71,72,74,76,78],first_snapshot:16,firstli:[2,69,72],fit:[11,22,60],fix:[0,76],flag:72,flexibl:64,fname:60,focu:74,folder:[0,12,75,76],follow:[0,1,6,11,12,39,41,43,44,45,46,47,59,60,61,68,69,71,72,74,76],footprint:[12,63],forc:[7,36,58,61,63],forgiv:12,fork:0,form:[0,12,60,61,71],formal:4,format:[5,12,13,22,32,43,52,56,60,61,62,63,64,65,70,71,72],former:1,formerli:12,formula:59,fortran:61,forward:[12,50,52],found:[3,12,38,39,40,41,42],fourier:[12,64],fourier_transform:64,fox:0,fp32:18,fpic:77,frac:[59,63],fraction:12,framework:[3,7,13,50,72],franz:0,free:[3,11,26,60,73,74,78],freedom:22,friction:12,from:[0,2,3,4,5,6,10,11,12,13,16,22,25,26,28,32,33,36,40,41,42,46,47,50,52,53,54,56,59,60,61,62,63,64,65,70,71,72,76],from_cube_fil:[61,63],from_json:[10,12,28],from_ldos_calcul:[5,61,62],from_numpy_arrai:[61,62,63],from_numpy_fil:[61,62,63],from_openpmd_fil:[61,63],from_qe_dos_txt:62,from_qe_out:62,from_xsf_fil:[61,63],front:12,frozentri:[42,48,49],full:[4,6,38,72,75,77],full_visualization_path:6,fulli:[3,4,19],function_valu:59,fundament:0,furnish:[11,60],further:[0,3,4,5,6,12,54,56,69,70,71,72,73,74,75],furthermor:[4,78],futur:[62,72],g:[3,4,5,6,12,13,16,18,30,31,32,34,35,36,39,43,44,45,46,47,61,62,63,64,69,70,71,72,73,74,75,76,77,78],gabriel:[0,73],gain:73,gather:[18,24,32,53,63,72],gather_dens:63,gather_descriptor:32,gather_do:63,gather_ldo:53,gaussian:[12,30,34,59,60],gcc:[75,77],gener:[0,2,5,6,8,11,12,13,14,16,18,41,50,61,62,63,64,68,71,72,73,77],generate_square_subsequent_mask:50,get:[5,11,12,13,19,30,31,32,34,40,41,43,46,53,55,58,59,61,62,63,64,71,72,74],get_atomic_forc:[61,63],get_band_energi:[62,63],get_best_trial_result:[40,41],get_beta:59,get_categor:[46,47],get_comm:11,get_dens:[61,63],get_density_of_st:[62,63],get_energy_contribut:61,get_energy_grid:[62,63,64],get_entropy_contribut:[62,63],get_equilibrated_configur:15,get_f0_valu:59,get_f1_valu:59,get_f2_valu:59,get_feature_s:58,get_first_snapshot:16,get_float:47,get_int:47,get_local_rank:11,get_new_data:25,get_number_of_electron:[61,62,63],get_optimal_paramet:41,get_optimal_sigma:30,get_orthogonal_arrai:41,get_paramet:[46,47],get_potential_energi:71,get_radial_distribution_funct:64,get_rank:11,get_real_space_grid:64,get_s0_valu:59,get_s1_valu:59,get_scaled_positions_for_q:61,get_self_consistent_fermi_energi:[62,63],get_siz:11,get_snapshot_calculation_output:19,get_snapshot_correlation_cutoff:16,get_static_structure_factor:64,get_target:[61,62,63,64],get_test_input_gradi:19,get_three_particle_correlation_funct:64,get_total_energi:63,get_trials_from_studi:42,get_uncorrelated_snapshot:16,git:[0,75,76],github:[0,11,12,21,73,75,76],gitlab:[64,77],give:[1,3,6,12,16,63,68,69,70,72,75],given:[6,13,18,32,53,56,59,60,61,62,63,64,69,70,74,78],glimps:72,gmail:60,gnn:0,gnu:77,go:12,goal:65,goe:12,goo:11,good:[2,3,6,12,48,49],got:0,govern:[69,70],gpaw:71,gpu:[0,3,11,12,54,68,75],gradient:[12,19,25,26,69],grand:73,grant:[11,60],granular:70,graph:[6,12],grate:0,greater:12,greatli:[12,72],grid:[0,5,12,30,32,59,61,62,63,64,70,72,74,78],grid_dimens:[32,61,64],grid_integration_method:63,gridi:[61,63],gridpoint:61,gridsiz:[12,61,63],gridspac:12,gridx:[61,63],gridz:[61,63],ground:72,grow:73,gru:[12,50],guarante:6,guess:64,gui:4,guid:[1,2,5,68,69,70,71,72,74],guidelin:0,h5:[4,13,61,64],h:[61,75],ha:[0,2,4,5,6,11,12,13,22,25,33,36,41,42,48,49,50,53,54,61,62,63,69,70,72,73,74,76,77,78],hacki:12,had:[6,70],hand:[5,12,13],handl:[3,4,6,17,19,20,23,64,76],handler:[41,42,54,56,63],happen:62,har:74,hard:28,hardwar:[1,5,68],haswel:75,have:[0,2,3,5,6,10,12,13,22,25,26,28,30,31,32,34,38,39,42,43,44,45,46,47,59,62,63,64,69,70,71,72,73,75,76,77,78],haven:76,head:[0,12],heartbeat:12,heavi:[5,64],hellman:61,helmholtz:74,help:[3,12,53,63,68,72],helper:[4,59],here:[3,12,16,18,25,26,38,41,50,54,62,69,70,71,72,75],herebi:[11,60],hidden:[12,50,69],hierarchi:13,high:[11,12,39,43,44,45,46,47,73],higher:[12,39,43,44,45,47],highli:[2,4,5,6,14,76,78],hint:6,histogram:[12,64],hiwonjoon:11,hlist:12,hoc:16,hoffmann:[0,73,74],hold:[6,12,19,32,39,40,41,42,53,54,55,56,63],holder:[11,60],horovod:[0,11,12,22,25,26],hossein:0,hotyp:[43,44,45,46,47],how:[2,3,12,22,62,63,64,68,69,70,72,75],howev:[2,4,6,12,26,32,52,63,72,73],hpc:[3,6,12,42,77],html:[12,41,76],http:[0,11,12,21,41,60,64,73,75,76,77],huge:6,hundr:[5,74],hyper_opt:[7,37,38,40,41,42,67],hyper_opt_method:[3,12],hyper_opt_naswot:[7,37,67],hyper_opt_oat:[7,37,67],hyper_opt_optuna:[7,37,67],hyperopt:[3,38,39,40,41,42,69],hyperoptim:[2,69],hyperoptnaswot:[40,43],hyperoptoat:[40,41,43],hyperoptoptuna:[40,42,43],hyperparam:12,hyperparamet:[0,1,2,7,12,37,38,39,40,41,42,44,45,46,47,49,51,52,56,67,68,72,73,74,76],hyperparameter_acsd:[7,37,67],hyperparameter_naswot:[7,37,67],hyperparameter_oat:[7,37,67],hyperparameter_optuna:[7,37,45,67],hyperparameteracsd:[43,44],hyperparameternaswot:[43,45],hyperparameteroat:[43,46],hyperparameteroptuna:[43,45,47],hyperparemet:12,i0:59,i1:59,i:[1,3,5,6,12,16,18,19,25,32,38,39,40,41,42,62,64,69,72,78],i_0:59,i_1:59,ibrav:61,icml2019:11,idea:6,ideal:[2,13,61,64],identif:74,identifi:69,idx:46,ifnam:60,ignor:[3,12,18,61,64,68,75],ik:62,imag:[60,64],imaginari:60,immens:0,impact:[6,63],imped:12,implement:[0,3,5,6,10,12,13,22,32,36,48,49,50,61,62,63,64,74,78],implemented_properti:36,impli:[11,13,60,64],improv:[0,1,12,23,24,72],in_unit:[30,31,32,34,58,61,62,63,64],includ:[0,4,11,12,19,28,32,40,41,54,60,63,69,70,74],incopor:70,incorpor:64,increas:[3,12],increment:[6,22,72,76],incremental_fit:22,indent:12,index:[46,76],indic:[22,26,48,49,55],indisput:12,individu:[3,6,70,72,74,78],industri:6,inf:12,infer:[0,5,12,53,54,55,60,63,71,72,74],inference_data_grid:[5,12],infinit:48,infint:48,info:[12,18,72],inform:[2,3,4,12,13,15,50,62,64,65,70,71,72],infrastructur:[0,42],inher:4,inherit:10,init_hidden:50,init_weight:50,initi:[3,13,15,50,70,74],initial_charg:36,initial_magmom:36,initial_setup:[3,6],initialis:50,initil:12,initrang:50,inject:50,input:[12,19,20,22,23,25,26,27,28,50,61,62,63,64,70,72,78],input_data_scal:[19,25,26],input_dimens:[20,25,26,72],input_directori:[20,23],input_fil:[20,23],input_npy_directori:[20,23,28],input_npy_fil:28,input_requires_grad:[25,26],input_rescaling_typ:[12,69,72],input_shm_nam:27,input_unit:[20,28],inputpp:70,insid:[75,76],instal:[0,2,5,74],instanc:[2,3,4,11,12,13,15,16,18,32],instanti:[12,50,54,56,72],instead:[2,3,5,25,26,41,49,60,64,68,70],institut:74,instruct:[0,2,5,74,75,77],integ:[5,12,18,47,69],integr:[53,59,61,62,63,71],integral_valu:59,integrate_values_on_spac:59,integration_method:[61,62,63],integration_valu:59,intel:75,intend:4,interact:4,interest:[4,5,65,69,71,72],interfac:[0,2,3,7,11,12,13,32,36,43,49,50,53,61,62,63,64,67,69,70,71],interg:[61,63],intern:[13,18,32,53,54,61,64],internal_iteration_numb:[13,61,64],interpret:6,interv:[3,6,12],introduc:[12,74],introduct:68,introductori:70,intuit:[2,6],invalid:[61,62,63,64],invalidate_target:[61,62,63,64],inverse_transform:22,investig:[5,19,20,38,39,42,43,44,45,46,47,69],involv:[2,5,6,72],io:[16,41,71],ion:12,ionic:[12,74],iop:73,ish:77,issu:[12,73],ist:64,iter:[12,13,61,64],its:[4,12,19,69,72,74],itself:[3,5,6,12,16,59,64,70,71,72,73,76],j:[60,73,74,77],jacobian:[12,40,52],jame:0,jiang:74,jmax:12,job:[3,12,42],join:[2,70,71,72],jointli:74,jon:[0,74],josh:[0,12],journal:73,json:[10,12,28,36,54,56,64,69,70],json_dict:[10,12,28],json_serializ:[7,8,12,28,43,67],jsonserializ:[10,12,28,43],judg:[6,48,49],jul:73,jun:73,june:60,jupyt:4,just:[2,3,4,5,12,26,54,56,71,72,78],justifi:59,k:[5,53,59,62,63,64,70,74],k_:59,keep:[0,12,25,26],kei:60,kept:[12,60],keyword:[6,12,18,71],kind:[11,13,20,23,60],kindli:[0,73],kinet:12,kmax:[5,12,64],known:[6,36],kohn:[73,74],kokko:[5,11,75],kokkos_arch_gpuarch:75,kokkos_arch_hostarch:75,kokkos_arch_hsw:75,kokkos_arch_volta70:75,kokkos_enable_cuda:75,kotik:0,kpoint:[5,64],ks:[61,62,63],kulkarni:0,kwarg:[24,25,26,27,32,36,41,48,49,50,61,63],kyle:[0,73],l2:12,l:[12,73,74,75],label:12,laboratori:74,lammp:[2,5,11,12,32,33,78],lammps_compute_fil:12,lammps_util:[7,29,67],langevin:12,larg:[2,4,5,6,32,64,72,73,74,76],larger:[5,12,13,61,64,73],last:[12,25,26,36,42,61,69,72],last_trial:42,lastli:70,latenc:6,later:[3,6,22,40,63,69],latest:41,latter:[3,13,64,70],lattic:60,launch:[3,6,12],layer:[3,12,21,39,43,44,45,46,47,69,72],layer_activ:[12,69,72],layer_activation_00:69,layer_activation_xxx:12,layer_s:[12,69,72],lazi:[12,22,23,25,26,72],lazili:[12,19],lazy_load_dataset:[7,17,67],lazy_load_dataset_singl:[7,17,67],lazyloaddataset:[25,26],lazyloaddatasetsingl:26,lbla:77,ldo:[2,5,6,7,12,18,53,55,57,58,59,61,62,64,67,70,71,72,74,78],ldos_calcul:[5,63,71],ldos_data:63,ldos_gridoffset_ev:[6,12,70,72],ldos_grids:[6,12,70,72],ldos_gridspacing_ev:[6,12,70,72],ldos_object:[61,62],ldosfil:70,lead:[2,5,12,64,74],leaf:19,leakyrelu:[12,69],learn:[6,7,12,22,64,69,72,73,74],learner:11,learning_r:[12,69,72],learning_rate_decai:[12,69],learning_rate_pati:[12,69],learning_rate_schedul:12,least:64,leastearly_stopping_threshold:12,leav:26,left:[4,27],legaci:[12,36,64],length:[5,50,73,74],lenz:[0,73,74],less:[12,18,64],let:[12,70,72],level:[11,12,21,25,26,41,53,59,62,63,72,73,74],lf:76,lfftw3:77,liabil:[11,60],liabl:[11,60],lib:[75,77],liblammp:75,librari:[3,4,5,6,22,49,69,71,72,75,77,78],licens:[11,60],lie:32,like:[3,5,6,11,26,72,77],likewis:[2,5,6],limit:[3,5,6,11,12,27,49,60,74],line:[4,33,60,72,73],linger:11,link:[11,41,69,73,75],linux:[76,77,78],list:[0,2,4,5,12,13,18,19,20,27,28,32,33,36,38,39,40,41,42,43,44,45,46,47,51,55,60,61,64,72],littl:61,llapack:77,lmkl_core:77,lmkl_intel_lp64:77,lmkl_sequenti:77,lmp:33,load:[12,19,20,22,23,25,26,27,36,39,41,42,50,53,54,56,62,69,71,72,75,77],load_from_fil:[12,22,41,42,50,69],load_from_json:12,load_from_pickl:12,load_model:[36,71],load_run:[3,6,54,56,71,72],load_runn:[54,56],load_snapshot_to_shm:27,load_with_gpu:54,load_with_mpi:54,loaded_hyperopt:41,loaded_network:[50,54,56],loaded_param:[41,42,54,56],loaded_paramet:12,loaded_train:42,local:[3,11,12,32,61,63,74,75],local_density_of_st:[62,63],local_offset:13,local_psp_nam:12,local_psp_path:12,local_reach:13,locat:[12,63],log:[0,15,59],logdir:6,logging_period:15,longer:[0,2,12,19],look:54,loos:64,loss:[6,12,41,48,50,55,69],loss_function_typ:12,loss_val:50,lot:[65,72,78],low:[12,39,43,44,45,46,47,72],lower:[16,39,43,44,45,47,69],lowest:[12,70],lstm:[12,50],m:74,mach:74,machin:[72,73,74,75,76,77],maco:[76,78],made:[0,5,71],mae:[55,72],magmom:36,magnitud:73,mai:[2,3,12,16,18,59,62,63,69,72,75,76,77],main:77,mainli:4,maintain:[0,6],mainten:[0,74],major:0,make:[0,3,4,5,6,12,52,63,70,72,74,75,76,77],mala:[1,2,3,4,6,8,9,11,12,13,15,16,18,19,20,21,23,25,26,27,28,30,31,32,34,36,38,39,40,41,42,43,44,45,46,47,48,49,50,52,53,54,55,56,58,61,62,63,64,66,67,69,70,72,75,77,78],mala_data_repo:[21,76],mala_foundational_pap:73,mala_hyperparamet:73,mala_paramet:[5,71],mala_shuffled_snapshot:23,mala_sizetransf:73,mala_temperaturetransf:73,mala_vi:6,malada_compat:16,manag:[12,24,72],mandatori:40,mani:[0,2,3,12,70,71],manual:[5,12,69,77],manual_se:12,map:63,mape:55,mark:42,mask:50,mass:60,massiv:[3,73],master:[0,11,64],match:[2,13,60,61,62,63,64],mater:74,materi:[5,71,73,74],mathemat:[3,38,59],mathrm:[59,61],matplotlib:5,matrix:61,matter:[5,19,73,74],max:[12,22,72],max_len:50,max_number_epoch:[12,72],maxim:12,maximum:[2,3,5,12,50,64],mc:[12,35,36],md:[12,15,16,35,36,64,74],mean:[6,12,13,22,32,48,49,52,58,61,62,63,69,70,72],mean_std:12,meaning:[12,64],measur:72,mechan:[18,49,74],medium:12,melt:74,member:[16,64],memori:[6,11,12,18,25,26,27,33,54,56,61,62,63,72],mention:[2,5,6],merchant:[11,60],merg:[0,11,60],merit:71,mess:42,messag:[1,11],meta:[13,60,65],metadata:[4,13,18,26,30,31,34,60,61,62,63,65],metadata_input_path:18,metadata_input_typ:18,method:[0,2,3,5,6,10,12,48,49,50,59,60,61,62,63,64,70,73,74,76],metric:[3,12,16,48,74],mev:6,mic:64,might:[12,26,36,42,50,52],miller:[0,73,74],mimic:60,min:[12,22,72],min_verbos:11,mini:[12,52,69],mini_batch_s:[12,69,72],minim:12,minimum:[11,12,41,64],minor:0,minterpi:0,minterpy_descriptor:[7,29,67],minterpydescriptor:34,minut:5,mit:[11,60],mitig:6,mix:[6,12,19,23,25,26],mix_dataset:[19,25,26],mkl:77,ml:[2,3,5,6,15,58,61,62,63,64,68,70,74],mlr:12,mode:[11,32,54,63,64],model:[0,2,3,5,6,18,36,50,53,54,56,68,69,70,73,74,78],modern:73,modif:[6,64],modifi:[0,11,42,48,49,60,70,77],modin:[0,73,74],modul:[0,9,21,50,60,61,64,78],modular:0,moham:[0,73,74],moldabekov:74,molecular:[71,74],moment:[5,12,19,39,43,44,45,46,47],monitor:6,month:73,more:[1,2,3,5,6,12,22,24,36,59,64,70,71,74],moreov:74,most:[2,6,12,54,73,74,75,76,77,78],move:[12,73],mpi4pi:32,mpi:[2,3,5,11,12,18,53,54,63,75,77],mpi_util:11,mpif90:77,mpirun:3,mse:[12,55],much:[6,26,62],mujoco:11,multi:[5,12],multi_lazy_load_data_load:[7,17,67],multi_train:12,multi_training_prun:[7,37,67],multilazyloaddataload:27,multipl:[1,2,3,6,11,12,16,19,20,27,28,32,39,43,44,45,46,47,48,53,59,63,69,70,72],multiple_gaussian:59,multipli:12,multiplicator_v:59,multitrainingprun:48,multivari:12,must:[12,20,63],mutat:33,mutual:[5,69],my:32,my_studi:3,myriad:73,mysql:3,n:[3,61,73,74],n_trial:[12,69],na:12,naiv:6,name:[0,3,6,12,13,16,18,19,23,27,32,33,36,38,39,41,42,43,44,45,46,47,54,56,61,63,64,69,70,72,75,77],naming_schem:[4,18,70],naming_scheme_input:19,naming_scheme_output:19,naswot:[0,3,12,43,45,48,49],naswot_prun:[7,37,67],naswot_pruner_batch_s:12,naswot_pruner_cutoff:12,naswotprun:49,nation:74,natom:61,natur:[0,12],ndarrai:[13,55,61,62,63,64],ndarri:13,necessari:[3,4,6,10,12,18,22,42,64,68,69,70,71,72,75],necessarili:[61,62,63,64],need:[2,5,10,12,13,19,20,25,28,32,36,50,54,56,59,61,62,63,64,70,72,75,76,77,78],neg:[6,12,64],neglect:12,neighbor:64,neighborhood:16,neither:63,net:[12,50,60],netwok:12,network:[3,6,7,12,19,22,36,38,39,40,41,42,44,45,46,47,48,49,51,52,53,54,55,56,63,67,69,71,72,73,74],neural:[3,12,36,50,53,55,56,72,73,74],neuron:[12,69,72],new_atom:32,new_datahandl:[41,42,54,56],new_hyperopt:[41,42],new_inst:11,new_runn:54,new_train:56,new_valu:11,newer:77,newli:[54,56,70],next:[6,42,60],nil:[0,73],nn:[3,5,6,50,52,64,69,72],nn_type:12,no_data:[41,42],no_hidden_st:12,no_snapshot:12,node:[11,12,42],nois:12,nomenclatur:69,non:[2,4,61,64],none:[12,13,15,16,18,19,20,22,23,28,30,31,32,33,34,36,38,39,40,41,42,43,44,45,46,47,52,53,54,56,61,62,63,64,72],noninfring:[11,60],nor:63,normal:[12,13,22,72],normand:[0,73],note:[0,5,6,12,26,33,38,39,41,42,43,44,45,46,47,49,59,71,75],notebook:[4,41],noteworthi:69,noth:[5,30,31,34],notic:[11,60],now:[4,27,63,65,69,70,71,72,77],np:[3,13,19,59,60,63],npj:[73,74],npy:[2,4,6,18,70,72],nsy:12,num_choic:46,num_head:12,num_hidden_lay:12,num_work:[6,12],number:[0,3,5,6,11,12,13,16,18,19,23,33,36,41,46,55,60,61,62,63,64,66,69,70,72,73,74,77],number_bad_trials_befor:12,number_bad_trials_before_stop:12,number_of_bin:[5,12,64],number_of_electron:[55,61,62,63,72],number_of_run:41,number_of_shuffled_snapshot:[6,23],number_training_per_tri:[3,12],numer:[12,13,16,25,32,39,43,44,45,47,60,61,62,63,64],numpag:73,numpi:[0,2,4,13,18,19,20,22,23,26,27,28,30,31,32,33,34,46,51,53,55,58,59,60,61,62,63,64,65,70],numpy_arrai:19,nvcc_wrapper:75,nvidia:[6,75],o:[12,19],oa:[39,41,43,44,45,46,47,51],oapackag:[41,76],oat:[0,3,12,43,46,51,52],object:[0,3,4,5,6,10,12,13,15,16,18,19,20,22,23,26,27,28,30,31,32,33,34,36,38,39,40,41,42,48,49,50,51,52,53,54,55,56,58,60,61,62,63,64,69,70,71,72],objective_bas:[7,37,52,67],objective_naswot:[7,37,67],objectivebas:[51,52],objectivenaswot:52,observ:[55,71,72,74],observables_to_test:[55,72],obtain:[5,11,19,60,76],occur:[42,59,72,76],oct:73,ofdft_frict:12,ofdft_initi:[7,14,67],ofdft_kedf:12,ofdft_number_of_timestep:12,ofdft_temperatur:12,ofdft_timestep:12,ofdftiniti:15,off:[0,12],offer:[4,6,12,65,74],offici:[4,12,68,71,75,76],offload:[5,6],often:[6,12],ol:[0,73,74],old:[12,28],omar:0,onc:[1,2,3,5,6,42,60,69,70,72],one:[2,3,4,5,6,11,12,16,19,20,23,32,48,53,60,61,62,63,64,69,70,72,74,78],ones:[5,25,26,32,69],ongo:76,onli:[0,1,2,3,5,6,11,12,13,16,18,19,20,22,25,26,28,33,36,41,42,50,53,54,55,59,60,61,62,63,64,65,69,70],onto:0,onward:6,open:[0,4,13,60,76],openmpi:77,openpmd:[0,1,12,13,18,20,23,28,32,61,62,63,64],openpmd_configur:12,openpmd_granular:12,oper:[5,6,11,12,19,20,23,64,70,72,74,76],opt:76,optim:[0,1,2,5,6,12,30,32,38,39,40,41,42,49,51,52,56,64,68,72,73,74,76],optimal_sigma:30,optimizer_dict:56,option1:75,option2:75,option:[3,4,6,9,11,12,13,18,22,26,28,30,31,32,34,38,40,54,56,60,64,69,70,72,73,74,75,78],opttyp:[39,41,43,44,45,46,47],optuna:[3,12,39,41,42,43,44,45,46,47,48,49,51,52,69],optuna_singlenode_setup:[3,12],orbit:74,order:[0,3,6,11,12,13,19,25,26,41,69,70,71,73,76],org:[38,60,64,73],orient:0,origin:[3,11,20,28,33,60,73],orthogon:[3,12,41,46,51,76],os:[2,70,71,72],oscil:16,ot:[25,26],other:[3,6,10,11,16,32,35,60,61,62,64,69,71,74],otherwis:[11,39,56,60],otherwsi:22,our:[4,73],ourselv:22,out:[0,2,4,6,11,19,40,41,53,60,62,64,70,71,72,75,76],out_unit:[30,31,32,34,61,62,63,64],outfil:[32,70],outlin:[6,59],output:[1,2,6,11,12,18,19,20,22,23,25,26,27,28,30,31,32,34,50,55,57,60,61,62,63,64,70,72,76,78],output_data_scal:[19,25,26],output_dimens:[20,25,26,72],output_directori:[20,23],output_fil:[20,23],output_format:[55,72],output_npy_directori:28,output_npy_fil:[20,23,28],output_rescaling_typ:[12,72],output_shm_nam:27,output_unit:[20,28],outsid:[32,63],over:[1,2,64],overal:0,overfit:72,overflow:59,overhead:[3,12,73],overview:[1,75],overwrit:[18,23,26],overwritten:[54,60],own:[4,12,50,72],p:[60,73,74,75],packag:[74,75,78],page:73,pairs:60,paper:[41,48,49,73],parallel:[0,1,4,7,8,12,22,32,63,67,68,74,75],parallel_warn:11,param:[30,31,32,34,36,38,39,40,41,42,50,51,53,54,55,56,58,60,61,62,63,64,69],paramet:[2,3,4,5,6,7,8,10,11,13,15,16,18,19,20,22,23,25,26,27,28,30,31,32,33,34,36,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,58,59,60,61,62,63,64,65,67,69,70,71,74],parametersbas:12,parametersdata:12,parametersdatagener:12,parametersdebug:12,parametersdescriptor:[12,38],parametershyperparameteroptim:12,parametersnetwork:12,parametersrun:[12,52],parameterstarget:[12,64],parametr:19,params_format:[54,56],paraview:4,parent:54,pars:[2,12,18,29,30,31,34,38,51,58,61,62,63,65],parse_tri:51,parse_trial_oat:51,parse_trial_optuna:51,parser:[60,64],part:[5,13,60,61,64,72,78],particl:[12,64],particular:[11,48,49,60],partit:55,parvez:[0,73],pass:[0,12,50,53,63],path:[2,6,12,13,16,18,19,21,36,38,41,42,50,53,54,56,61,62,63,64,70,71,72,75,76,77],path_name_schem:63,path_schem:63,path_to_fil:[50,53],path_to_visu:6,patienc:12,paulbourk:60,pavanello:74,pbc:[32,36],peform:12,penalti:12,peopl:0,pep8:0,per:[12,32,36,69,72],percent:12,perform:[1,3,5,12,18,19,22,24,26,36,38,39,40,41,42,50,53,59,62,63,64,68,70,71,72,73,74,75,78],perform_studi:[2,38,39,40,41,42,69],permiss:[11,60],permit:[11,60],permut:26,person:[11,60,70],phase:73,phenomena:73,phy:[73,74],phyiscal:6,physic:[2,3,6,12,13,57,64,73],physical_data:[7,8,32,64,67],physicaldata:[13,32,64],physrevb:73,pickl:[12,22,32],pip:76,pipelin:[19,20,23],pkg_kokko:75,pkg_ml:75,pkl:[39,41,42,54,56],place:[22,72],plan:75,plane:5,plateau:[12,69],plea:64,pleas:[0,2,3,4,5,6,12,38,39,41,42,43,44,45,46,47,63,69,71,72,73,74,75,76],plot:[2,5,64],plu:[3,12],plugin:4,pmd:4,point:[2,3,5,6,12,21,25,26,33,54,62,64,70,72,74],popoola:[0,73,74],popular:73,portion:[11,18,60],pose:74,posit:[7,32,36,50,53,60,61,70,71],positionalencod:50,possibl:[6,12,38,39,43,44,45,46,47,50,62,69],post:[4,28,64,74,78],postgresql:3,postprocess:[7,58,61,62,63,64],potenti:[0,32,69,74],power:[4,6,71],pp:70,pr:0,practic:6,pre:27,precalcul:78,preced:70,precict:[53,55],precis:[6,12,18,33],predict:[6,7,36,50,53,55,63,64,68,72,73,74],predict_for_atom:[5,53,71],predict_from_qeout:53,predict_target:55,predicted_arrai:50,predicted_ldo:53,predicted_output:55,predictor:[5,7,37,54,56,67,71],prefer:[36,70],prefetch:[6,12,26],prepar:[6,13,19,41,42],prepare_data:[19,54,56,69,72],prepare_for_test:19,preprocess:[2,7,12,32,64,70],present:[13,38,39,40,41,42,54,61,64],press:[12,73],previou:[50,71],primari:69,principl:[2,5,39,43,44,45,46,47,72,74],print:[1,3,6,11,12,41],printout:[1,3,11],prior:[0,2,5,6,12],priorli:16,problem:[6,77],problemat:12,proceed:12,process:[0,2,3,4,6,11,12,18,19,22,25,26,28,32,33,38,51,64,70,71,72,73,74,75,77,78],product:[1,4,6,53,72,75],profil:12,profiler_rang:12,progress:[6,63],project:[0,4,21,75,76],proof:74,proper:[61,62,63,73],properli:[0,11,12],properti:[6,10,12,13,16,20,25,28,30,31,32,34,36,46,61,62,63,64,69,71,74],provid:[2,3,5,6,11,12,13,16,18,21,23,38,40,49,59,60,61,62,63,64,65,70,71,72,75,76],prudent:[3,72],prune:[48,49],pruner:[12,48,49],pseudopotenti:[12,61,63,64,71],pseudopotential_path:[12,71],psu:64,publish:[0,11,60,73],pure:[6,45,62],purpos:[2,11,41,42,60],push:0,put:[5,12,19,42,50],pw:[61,70],py:[0,2,3,6,11,71,72,75],pypi:0,pytest:76,python3:[3,75],python:[2,3,4,5,19,20,32,33,61,64,71,78],pythonpath:77,pytorch:[12,19,50],q:77,qe:[12,32,53,61,62,63,64,77,78],qe_input_data:[61,63,64],qe_out_fil:32,qe_pseudopotenti:[61,63,64],qef:77,qualiti:0,quantif:0,quantit:12,quantiti:[12,16,18,22,55,57,61,62,63,64],quantum:[5,18,32,61,62,63,64,70,71,73,74,78],quantumespresso:64,question:6,queue:42,quick:32,r:[41,60,63,76],race:3,radial:[5,12,64],radial_distribution_funct:64,radial_distribution_function_from_atom:[5,64],radii:[2,5,12,64],radiu:[2,12,64,70],rais:61,rajamanickam:[0,73,74],ram:[6,25,41,42,50,63],random:[6,50],randomli:3,rang:[2,12,22,41,50,72,73,74],rank:[3,11,12,32,53,62,63],rapid:74,rate:[6,12,50,69],rather:[3,19,61,62,63],raw:[2,18,19,32,70],raw_numpy_to_converted_scaled_tensor:19,rawradialdistribut:64,rdb:[12,42],rdb_storag:[3,12,42],rdb_storage_heartbeat:12,rdf:[5,12,16,36,64],rdf_paramet:12,re:[0,2,19],read:[4,10,12,13,16,22,25,26,28,53,59,60,61,62,63,64,65,71],read_additional_calculation_data:[62,64],read_additional_read_additional_calculation_data:61,read_cub:60,read_dimensions_from_numpy_fil:13,read_dimensions_from_openpmd_fil:13,read_dtyp:13,read_from_arrai:[61,62,63,71],read_from_cub:[61,63],read_from_numpy_fil:13,read_from_openpmd_fil:13,read_from_qe_dos_txt:62,read_from_qe_out:62,read_from_xsf:[61,63],read_imcub:60,read_xsf:65,readi:[70,72],readlin:60,readthedoc:41,real:[22,60,64,69,72,74,78],realist:78,realli:[30,31,34,36],realspac:[5,16],reason:[6,12,19,62,65,72],rebas:0,recap:6,recent:[73,74,75,76,77],recogn:12,recommend:[6,12,16,61,62,63,64,75,78],reconstruct:[41,42,54,56],record:12,recv:32,redistribut:23,reduc:[12,26,63,70],reducelronplateau:12,reduct:12,refer:[2,3,12,61,68,69,70,72,74,75],reference_data:36,reflect:[5,61,63],regain:26,regard:73,regular:[2,3,5,12,52,70],regularli:0,reimplement:10,rel:[26,50,62],relat:[3,12,75],releas:77,relev:[2,4,6,12],reli:[5,73],relu:[12,69,72],remark:[2,5],remind:[2,5],remov:32,renam:77,reorder:[12,62],reparametrize_scal:19,replac:[4,13,18,28,60,63,74],repo:[0,76],report:[3,12,48,49],repositori:[0,12,68,72,73,74,76,77],repres:[2,12,28,44,45,46,47,51,52,70,72],represent:[45,70,74],reproduc:[0,6,62,63,64],request:[12,41,73],requeue_zombie_tri:42,requir:[0,3,5,6,12,13,26,40,41,60,70,72,75,76,78],research:[73,74],reset:[19,20],reshap:[13,61],resiz:19,resize_snapshots_for_debug:19,resp:[5,12],respect:[3,10,12,20,70,72,73],respres:[46,51],restart:3,restrict:[11,12,60,64],restrict_data:64,restrict_target:12,resubmit:42,result:[3,6,12,18,19,33,51,55,64,70,71,72,74],result_typ:33,resultsfor:74,resum:[3,6,41,42],resume_checkpoint:[41,42],resumpt:[6,41,42],retain:[32,60],return_energy_contribut:63,return_outputs_directli:25,return_plot:[2,38],return_str:64,return_valu:[46,47],retval:60,reusabl:0,rev:[73,74],rewrit:26,rfname:60,right:[11,19,50,60],rmax:[12,64],robust:3,romero:[0,12],room:74,root:[0,22],rossendorf:74,roughli:73,rout:32,routin:[2,4,6,12,72],row:[12,22,46,51,72],rst:76,run:[3,5,11,12,25,32,36,41,42,53,54,56,63,69,72,76,77],run_exist:[3,6,54,56],run_nam:[36,54,56],runner:[7,37,53,55,56,67],runner_dict:54,runtim:4,ry:[2,58,62,63,70],s0:59,s1:59,s41524:73,s:[0,12,39,41,60,62,64,72,73,74,77],safe:1,sai:77,same:[3,6,12,18,19,20,23,32,38,42,50,59,60,63,64,69,77],samefileerror:75,sampl:[12,16,38,39,40,41,42,70,72],sampler:[12,41],sandia:74,save:[3,4,5,6,10,12,13,16,18,19,20,22,23,28,36,41,42,50,54,56,61,62,63,64,69,70,71,72],save_as_json:12,save_as_pickl:12,save_calcul:36,save_format:[12,22],save_nam:[4,6,23],save_network:50,save_path:[36,54],save_run:[54,72],save_runn:54,scalabl:74,scalar:33,scale:[3,4,5,6,12,19,22,25,26,41,42,50,61,63,69,72,73,74,76],scaled_posit:61,scaler:22,scarc:18,scf:61,schedul:[12,42],scheme:[18,19,63],schmerler:[0,73,74],sci:74,scienc:73,scientif:[0,4,74],scikit:22,score:[48,49],script:[3,5,11,12,69,77],se:36,search:[1,2,69],search_paramet:[48,49,52],second:12,secondli:[2,72],section:[6,68,69,70,71,72],see:[0,2,5,12,18,20,28,38,41,60,64,70,71,72,75,77],seed:[6,12],seem:[5,26],select:[2,6,12,13,55,70,72,77],self:[62,63],sell:[11,60],sendv:32,sens:[12,36,52,54,62,63,72],sep:[11,73],separ:[11,18,28,36,54,56,70,72,78],sequenc:50,seri:[4,13],serial:[10,11],serializ:10,serv:[50,53,74],server:42,servernam:3,set:[0,2,3,4,5,6,11,12,13,16,18,19,23,24,25,26,27,32,38,39,40,41,42,51,53,54,55,61,62,63,64,69,70,71,74,75],set_calcul:71,set_cmdlinevar:33,set_current_verbos:11,set_horovod_statu:11,set_lammps_inst:11,set_mpi_statu:11,set_optimal_paramet:[2,38,39,40,41,42,69],set_paramet:39,setup:[0,3,6,35,76],sever:[3,5,59,69,72],sgd:12,sh:77,shall:[11,60],sham:[73,74],shao:74,shape:[33,61,64],share:[26,27],shift:32,ship:75,shorter:6,should:[0,2,3,5,6,11,12,13,19,21,22,30,31,32,34,36,41,42,47,48,49,50,53,54,58,59,61,62,63,64,69,70,72,75,77],should_prun:[48,49],show:[0,12,74],show_order_of_import:41,showcas:[2,74],shown:[2,3,5,6,70,72],shuffl:[0,4,6,12,20,23,24,25,26],shuffle_snapshot:[4,6,23],shuffling_se:[6,12],shut:11,shutil:75,si:[13,32,61,62,63,64],si_dimens:[13,32,61,62,63,64],si_unit_convers:[13,32,61,62,63,64],sigma:[12,30,59],sigmoid:[12,69],sign:0,signal:72,signific:[12,74],significantli:[63,64],silver:73,similar:[2,3,16,74],simp:[59,61,62,63],simpl:[70,71,72],simplest:6,simpli:[5,6,12,16,19,36,51,61],simpson:[59,61,62,63],simul:[5,12,36,60,61,63,70,71,72,73,74,78],sinc:[2,3,5,6,12,18,30,31,32,34,36,42,71,72,76],singl:[3,5,18,24,26,33,55,68],site:13,siva:0,sivasankaran:[73,74],six:36,size:[0,3,5,11,12,13,26,39,43,44,45,46,47,50,52,69,72,74],skip:33,skiparraywrit:13,slice:[5,19],slightli:42,slowest:12,small:[2,6,64,78],smaller:[12,25,69],smallest:[12,16],smear:62,smearing_factor:62,smith:64,smoothli:12,snap:[12,75],snapshot4:18,snapshot:[6,7,12,15,16,17,18,19,20,23,25,26,27,32,38,55,63,67,70,72],snapshot_correlation_cutoff:16,snapshot_directories_list:12,snapshot_funct:28,snapshot_numb:[19,55,63],snapshot_typ:[4,20,23,28],sneha:0,so:[2,3,4,6,11,12,22,50,54,60,61,62,70,72,74,75,76,77,78],societi:73,softwar:[0,5,11,60,70,71,73,74,78],sole:75,solv:59,somashekhar:0,some:[2,6,12,25,26,50,52,54,64,72],someth:[52,77],sometim:76,somewhat:12,soon:7,sort:[22,25,26,32,41],sourc:[0,9,10,11,12,13,15,16,18,19,20,22,23,24,25,26,27,28,30,31,32,33,34,36,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,58,59,60,61,62,63,64,65,71],space:[2,6,59,62,64,69,70,72,74,78],special:[2,24],specif:[3,4,6,12,19,39,50,59,64,71,76],specifi:[2,3,4,5,6,12,13,22,32,52,62,64,69,70,71,72],speed:[6,12,74],speedup:6,sphere:70,sphinxopt:76,split:[5,12],springer:41,sql:[3,42],sqlite:[3,12],sqlite_timeout:12,sqrt:59,squar:[6,12],src:75,srcname:60,ssf:[12,64],ssf_paramet:12,stabl:12,standard:[3,4,5,12,22,69,72],start:[2,3,5,12,22,70],start_incremental_fit:22,starts_at:18,state:[12,50,62,63,71,74],statement:[5,11],static_structur:5,static_structure_factor_from_atom:[5,64],statu:11,stem:[62,63],step:[2,5,12,15,16,68,69,78],stephen:[0,73,74],steve:[0,73],still:[6,11,13,24,27,41,42,73,74],stochast:12,stop:[12,19,69,76],storag:[4,12,42],store:[1,3,12,25,26,36,61,64,70,72],str:[27,36,54,55,56,61,63],straightforward:[0,2,74],strategi:[3,69],strength:41,stress:36,stretch:5,string:[11,12,13,16,18,19,20,22,23,28,30,31,32,33,34,36,38,39,41,42,43,44,45,46,47,50,52,53,54,55,56,58,59,60,61,62,63,64,65],structur:[5,7,12,13,64,70,71,72,73,74,78],studi:[3,12,38,39,40,41,42,48,49,69,73],study_nam:[3,12,42],style:[0,51,64],sub:72,subclass:[43,50],subfold:12,subject:[11,60,76],sublicens:[11,60],submit:0,subobject:72,subroutin:63,subsequ:[12,53,74],subset:[39,40,42],substanti:[11,60],success:[75,77],successfulli:[75,76],suffic:32,suffici:0,suggest:[0,12,16,64],suit:[0,77],suitabl:[5,12,73,74,75,76],sum_i:62,sum_k:62,summari:64,summat:[61,63,64],supervis:0,supervisor:74,support:[0,3,4,5,6,12,20,28,36,39,41,43,44,45,46,47,52,55,58,59,61,62,63,64,75],suppos:[0,33,49,59,63],suppress:59,suppress_overflow:59,sure:[0,3,4,6,32,63,70,72,74,75,76,77],surrog:[12,48,49,74],switchflag:12,symbol:18,symmetri:[61,63],syntax:[2,3,6,72,76],system:[0,2,3,5,6,12,42,61,62,63,64,71,72,74,77],system_chang:36,t:[4,12,41,42,59,60,62,63,64,74,76],tag:[0,76],tahmasbi:0,take:[2,6,12,42,48,49,64],taken:[41,60],tamar:73,target:[2,6,7,11,12,16,18,19,20,23,25,26,27,28,30,31,34,36,38,48,49,50,53,58,61,62,63,67,70,71,72],target_calcul:[5,16,18,19,20,23,25,26,27,38,71],target_calculation_kwarg:70,target_calculator_kwarg:18,target_data:64,target_input_path:[18,38,70],target_input_typ:[18,38,70],target_save_path:[18,23,70],target_temperatur:16,target_typ:[12,70,72],target_unit:[2,18,38,70],targetbas:[58,62],task:[12,59,72,78],te:[20,28,55,72],te_mutex:61,team:[0,4,5,6,75,76],technic:[32,64],techniqu:[3,70,74],technol:74,technolog:73,tell:[3,72,75],tem:[12,64],temperatur:[5,6,12,16,36,53,59,62,63,64,72,73,74],tempor:16,ten:5,tend:64,tensor:[19,22,24,50,63],tensorboard:[0,12],tensordataset:[6,12,24],term:[50,62,63],termin:12,test:[0,4,6,12,19,20,21,25,28,48,49,53,55,69,70,76,77,78],test_al_debug_2k_nr:19,test_all_snapshot:[55,72],test_exampl:0,test_snapshot:55,tester:[6,7,19,37,53,54,56,67,72],text:4,than:[12,69],thei:[0,3,4,5,6,12,42,64,71],them:[0,6,23,32,62,70],themselv:[4,16,19],theorem:61,theori:[3,73,74],thereaft:[62,64],therefor:[4,25,26,32,61,78],therein:[12,73],thermodynam:59,thi:[0,1,2,3,4,5,6,10,11,12,13,15,16,18,19,20,22,23,24,25,26,27,28,30,31,32,33,34,36,38,39,40,41,42,46,48,49,50,51,52,53,54,55,56,58,59,60,61,62,63,64,68,69,70,71,72,73,74,75,76,77,78],thing:[69,70],third:72,thompson:[0,73,74],those:[12,72,77],though:[12,64],thousand:5,thread:11,three:[5,12,64,72,78],three_particle_correlation_function_from_atom:64,threshold:16,through:[3,11,50,61,72],throughout:55,thrown:11,thu:[6,12,19,76],time:[3,5,6,12,42,70,72,73,77],timeout:12,timestep:[12,16],timothi:0,titl:73,tmp:70,to_json:[10,12],togeth:[6,69],token:50,toml:12,too:[2,32],tool:[4,14,15,16,64],topic:[70,71],torch:[6,18,19,22,24,25,26,50,63,76],tort:[11,60],total:[0,5,12,55,61,62,63,64,71,72,74,78],total_energi:[12,55,63,71,77],total_energy_contribut:61,total_energy_ful:55,total_energy_modul:77,tpcf:[12,64],tpcf_paramet:12,tpe:41,tr:[4,20,28,55,72],track:19,train:[0,1,2,3,5,7,12,19,20,23,25,28,36,40,41,42,48,49,51,52,54,56,64,68,69,71,73,74,76,78],train_network:[56,72],trainer:[3,6,7,12,37,67,72],training_report_frequ:12,trainingtyp:[12,69,72],traj:15,trajectori:[12,15,16,64],trajectory_analysis_below_average_count:12,trajectory_analysis_correlation_metric_cutoff:12,trajectory_analysis_denoising_width:12,trajectory_analysis_estimated_equilibrium:12,trajectory_analysis_temperature_tolerance_perc:12,trajectory_analyz:[7,14,67],trajectoryanalyz:16,transfer:[0,6,73,74],transform:[12,19,22,25,50,61,64,70],transformernet:50,trapezoid:[59,61,62,63],trapz:[59,61,62,63],treat:[11,76],tree:[0,75],trex:11,trial:[3,12,39,40,41,42,46,47,48,49,51,69],trial_ensemble_evalu:12,trial_list:40,trial_typ:52,tricki:24,trivial:[2,5,6],truth:72,tune:[0,3,6,12,41,69,72],turn:6,tutori:[4,72],tweak:[68,71],twice:[5,64],two:[2,12,13,16,60,69,72,73],twojmax:12,txt:[0,62,76],type:[10,11,12,13,16,18,19,22,24,28,30,31,32,33,34,36,38,39,41,42,43,46,47,48,49,50,53,54,55,56,58,59,60,61,62,63,64,70],typestr:22,typic:75,u:3,ubuntu:78,uncach:[16,61,62,63],uncache_properti:[16,61,62,63],uncertainti:0,unchang:[26,61],uncorrel:[12,16],under:[0,36,54,56],underlin:63,understand:74,uniform:[50,59],unit:[13,18,19,20,23,25,26,27,28,30,31,32,34,38,50,58,61,62,63,64],unless:61,unload:6,unnecessari:[19,54],unscal:22,unseen:72,untest:77,until:[12,25,26,69,70],untouch:4,up:[0,2,6,12,32,42,61,62,63,64,69,70,74],updat:0,upon:[0,3,12,19,42,45,50,70],upper:[5,69],upward:12,url:73,us:[0,1,2,3,4,7,11,12,13,15,16,18,19,20,22,23,24,25,26,27,30,31,32,33,34,36,38,39,40,41,42,43,44,45,46,47,48,49,50,52,53,54,55,56,58,59,60,61,62,63,64,68,69,70,72,73,74,75,76,77,78],usag:[0,5,6,19,54,63,68,71,72,74,75],use_compress:12,use_fast_tensor_data_set:[6,12],use_fp64:[18,33],use_gauss_ldo:70,use_gpu:[5,6,12],use_graph:[6,12],use_horovod:[12,22,25,26],use_lammp:12,use_lazy_load:[6,12,72],use_lazy_loading_prefetch:[6,12],use_memmap:63,use_mixed_precis:[6,12],use_mpi:[2,3,5,12],use_multivari:12,use_pickled_comm:32,use_pkl_checkpoint:[38,39,40,41,42,56],use_shuffling_for_sampl:12,use_y_split:[5,12],use_z_split:12,useabl:70,used_data_handl:63,user:[4,11,12,16,48,49,59,63,72,76],userwarn:11,usual:[5,6,12,16,32,50,51,61,62,64,70],util:[6,24,25,26],v1:76,v2:12,v80:12,v:[74,75],v_:61,va:[20,28,55,72],vaidyanathan:60,valid:[3,6,12,19,20,28,69,72],validation_loss:12,validation_loss_old:12,valu:[2,5,6,11,12,13,16,25,26,30,32,40,41,46,47,48,49,50,52,53,55,59,60,61,62,63,64,69,70,72],valuabl:0,vari:77,variabl:[12,16,19,54,64],varianc:25,varieti:74,variou:[12,71,72,74],vector:[2,12,25,26,32,60,64,70,72],verbos:[11,12,62,70,72],veri:[0,3,6,12,50,62],verif:72,verifi:72,verma:0,versatil:74,version:[7,12,18,24,48,49,67,70,75,76,77],via:[0,2,3,5,6,11,12,16,21,26,61,62,63,64,69,70,71,72,75,76,77,78],viabl:48,view:[2,6,33],viewdoc:64,viewer:4,virtu:6,visibl:50,visit:[3,4],visual:[4,6,12,74],visualis:[6,12],visualisation_dir:[6,12],visualisation_dir_append_d:12,visualizatuon:6,vladyslav:[0,73],vogel:[0,73,74],volta:75,volum:73,volumetr:[4,60,65,70,72],voxel:[30,61,63],w:[41,63,76],w_k:62,wa:[5,6,22,25,26,38,39,40,41,42,50,54,56,61,62,63,64,71],wai:[0,3,6,12,64],wait:[12,42],wait_tim:[3,12],want:[2,5,6,20,23,39,43,44,45,46,47,64,69,72,75,76],warmli:0,warn:[3,11,76],warranti:[11,60],wave:[12,64],wavefunct:61,we:[0,2,3,5,12,22,25,26,32,36,64,65,69,70,72,73,75,77],websit:[3,76],weight:[6,12,50,59,72],weight_decai:12,welcom:0,well:[2,3,6,12,61,68,69,76],were:[5,72],what:[0,20,23,32,36,54,56,60,72],whatev:75,when:[0,1,3,4,6,11,12,18,19,20,28,32,42,48,49,50,54,56,60,63,64,69,70,72,77,78],whenev:72,where:[4,5,6,12,26,36,41,42,54,56,72,75],wherea:70,whether:[9,11,12,25,32,48,49,60],which:[0,2,3,4,5,6,9,12,13,15,16,18,19,20,21,22,23,28,30,31,32,33,34,36,38,39,40,41,42,46,47,48,49,50,51,53,54,55,56,58,59,60,61,62,63,64,69,70,71,72,75,76,77,78],whom:[11,60],wide:74,width:[12,30],window:[76,78],wip:63,wise:[6,12,22,69,72],wish:[5,77],within:[2,11,12,13,19,24,63,72],without:[3,6,11,12,13,40,52,59,60,64,75],won:[41,42],wonjoon:11,work:[0,3,5,11,12,33,40,55,60,61,62,63,64,69,77,78],worker:[6,12],workflow:[2,3,4,5,6,28,35,71,72,73,74],working_directori:[32,70],world:22,worldwid:74,would:[2,13,61],wrap:0,write:[4,13,32,60,61,64],write_additional_calculation_data:64,write_cub:60,write_imcub:60,write_tem_input_fil:64,write_to_cub:[5,61],write_to_numpy_fil:[13,64],write_to_openpmd_fil:[13,61,64],write_to_openpmd_iter:13,written:[38,39,40,41,42,61,64],wuantiti:[61,62,63,64],x86_64:77,x:[5,12,19,32,50,59,64,70,74],xc:61,xcrysden:63,xsf:[61,63,65],xsf_parser:[7,57,67],xvec:60,xyz:[12,32],y:[5,12,19,32,64],ye:75,year:73,yet:[4,6,13,30,31,34,64],yield:[2,6],you:[0,2,3,4,5,6,12,20,23,39,43,44,45,46,47,50,68,70,71,72,73,74,75,76,77,78],your:[0,2,4,5,6,12,70,72,73,74,75,76,77],yourself:68,yovel:[73,74],ysplit:5,yt:4,yvec:60,z:[5,12,19,32,64,73,74],zentrum:74,zero:[5,12,50,69],zero_out_neg:12,zip:[36,54,56,72],zip_run:[54,56],zipextfil:[12,22,50],zombi:42,zone:59,zvec:60},titles:["Contributions","Advanced options","Improved data conversion","Improved hyperparameter optimization","Storing data with OpenPMD","Using MALA in production","Improved training performance","mala","common","check_modules","json_serializable","parallelizer","parameters","physical_data","datageneration","ofdft_initializer","trajectory_analyzer","datahandling","data_converter","data_handler","data_handler_base","data_repo","data_scaler","data_shuffler","fast_tensor_dataset","lazy_load_dataset","lazy_load_dataset_single","multi_lazy_load_data_loader","snapshot","descriptors","atomic_density","bispectrum","descriptor","lammps_utils","minterpy_descriptors","interfaces","ase_calculator","network","acsd_analyzer","hyper_opt","hyper_opt_naswot","hyper_opt_oat","hyper_opt_optuna","hyperparameter","hyperparameter_acsd","hyperparameter_naswot","hyperparameter_oat","hyperparameter_optuna","multi_training_pruner","naswot_pruner","network","objective_base","objective_naswot","predictor","runner","tester","trainer","targets","atomic_force","calculation_helpers","cube_parser","density","dos","ldos","target","xsf_parser","version","API reference","Getting started with MALA","Basic hyperparameter optimization","Data generation and conversion","Using ML-DFT models for predictions","Training an ML-DFT model","Citing MALA","Welcome to MALA!","Installing LAMMPS","Installing MALA","Installing Quantum ESPRESSO (total energy module)","Installation"],titleterms:{"do":62,"public":74,ASE:71,acsd_analyz:38,ad:[0,72,76],advanc:[1,3,6],algorithm:3,an:72,api:67,ase_calcul:36,atomic_dens:30,atomic_forc:58,basic:69,behind:74,bispectrum:31,branch:0,build:[72,75,76,77],calcul:71,calculation_help:59,check_modul:9,checkpoint:[3,6],cite:73,code:0,common:8,content:74,contribut:0,contributor:0,convers:[2,70],cpu:5,creat:0,cube_pars:60,data:[2,4,70,72,76],data_convert:18,data_handl:19,data_handler_bas:20,data_repo:21,data_scal:22,data_shuffl:23,datagener:14,datahandl:17,densiti:61,depend:0,descriptor:[2,29,32],develop:0,dft:[71,72],document:76,doe:74,download:76,energi:77,espresso:77,exampl:76,extens:[75,77],fast_tensor_dataset:24,gener:70,get:68,gpu:[5,6],how:74,hyper_opt:39,hyper_opt_naswot:40,hyper_opt_oat:41,hyper_opt_optuna:42,hyperparamet:[3,43,69],hyperparameter_acsd:44,hyperparameter_naswot:45,hyperparameter_oat:46,hyperparameter_optuna:47,improv:[2,3,6],instal:[75,76,77,78],interfac:35,issu:0,json_serializ:10,lammp:75,lammps_util:33,lazi:6,lazy_load_dataset:25,lazy_load_dataset_singl:26,ldo:63,librari:76,licens:0,list:69,load:6,local:76,mala:[0,5,7,68,71,73,74,76],metric:6,minterpy_descriptor:34,ml:[71,72],model:[71,72],modul:77,multi_lazy_load_data_load:27,multi_training_prun:48,naswot_prun:49,network:[37,50],objective_bas:51,objective_naswot:52,observ:5,ofdft_initi:15,openpmd:4,optim:[3,69],option:[1,76],parallel:[2,3,5,11],paramet:[12,72],perform:6,physical_data:13,predict:[5,71],predictor:53,prerequisit:[75,76,77],product:5,pull:0,python:[75,76,77],quantum:77,recommend:76,refer:67,releas:0,request:0,run:6,runner:54,search:3,set:72,snapshot:28,start:[68,74],store:4,strategi:0,target:[57,64],tensorboard:6,test:72,tester:55,total:77,train:[6,72],trainer:56,trajectory_analyz:16,tune:2,us:[5,6,71],version:[0,66],visual:5,welcom:74,what:74,where:74,who:74,work:74,xsf_parser:65}}) \ No newline at end of file +Search.setIndex({docnames:["CONTRIBUTE","advanced_usage","advanced_usage/descriptors","advanced_usage/hyperparameters","advanced_usage/openpmd","advanced_usage/predictions","advanced_usage/trainingmodel","api/mala","api/mala.common","api/mala.common.check_modules","api/mala.common.json_serializable","api/mala.common.parallelizer","api/mala.common.parameters","api/mala.common.physical_data","api/mala.datageneration","api/mala.datageneration.ofdft_initializer","api/mala.datageneration.trajectory_analyzer","api/mala.datahandling","api/mala.datahandling.data_converter","api/mala.datahandling.data_handler","api/mala.datahandling.data_handler_base","api/mala.datahandling.data_repo","api/mala.datahandling.data_scaler","api/mala.datahandling.data_shuffler","api/mala.datahandling.fast_tensor_dataset","api/mala.datahandling.lazy_load_dataset","api/mala.datahandling.lazy_load_dataset_single","api/mala.datahandling.multi_lazy_load_data_loader","api/mala.datahandling.snapshot","api/mala.descriptors","api/mala.descriptors.atomic_density","api/mala.descriptors.bispectrum","api/mala.descriptors.descriptor","api/mala.descriptors.lammps_utils","api/mala.descriptors.minterpy_descriptors","api/mala.interfaces","api/mala.interfaces.ase_calculator","api/mala.network","api/mala.network.acsd_analyzer","api/mala.network.hyper_opt","api/mala.network.hyper_opt_naswot","api/mala.network.hyper_opt_oat","api/mala.network.hyper_opt_optuna","api/mala.network.hyperparameter","api/mala.network.hyperparameter_acsd","api/mala.network.hyperparameter_naswot","api/mala.network.hyperparameter_oat","api/mala.network.hyperparameter_optuna","api/mala.network.multi_training_pruner","api/mala.network.naswot_pruner","api/mala.network.network","api/mala.network.objective_base","api/mala.network.objective_naswot","api/mala.network.predictor","api/mala.network.runner","api/mala.network.tester","api/mala.network.trainer","api/mala.targets","api/mala.targets.atomic_force","api/mala.targets.calculation_helpers","api/mala.targets.cube_parser","api/mala.targets.density","api/mala.targets.dos","api/mala.targets.ldos","api/mala.targets.target","api/mala.targets.xsf_parser","api/mala.version","api/modules","basic_usage","basic_usage/hyperparameters","basic_usage/more_data","basic_usage/predictions","basic_usage/trainingmodel","citing","index","install/installing_lammps","install/installing_mala","install/installing_qe","installation"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":5,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":3,"sphinx.domains.rst":2,"sphinx.domains.std":2,"sphinx.ext.intersphinx":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["CONTRIBUTE.md","advanced_usage.rst","advanced_usage/descriptors.rst","advanced_usage/hyperparameters.rst","advanced_usage/openpmd.rst","advanced_usage/predictions.rst","advanced_usage/trainingmodel.rst","api/mala.rst","api/mala.common.rst","api/mala.common.check_modules.rst","api/mala.common.json_serializable.rst","api/mala.common.parallelizer.rst","api/mala.common.parameters.rst","api/mala.common.physical_data.rst","api/mala.datageneration.rst","api/mala.datageneration.ofdft_initializer.rst","api/mala.datageneration.trajectory_analyzer.rst","api/mala.datahandling.rst","api/mala.datahandling.data_converter.rst","api/mala.datahandling.data_handler.rst","api/mala.datahandling.data_handler_base.rst","api/mala.datahandling.data_repo.rst","api/mala.datahandling.data_scaler.rst","api/mala.datahandling.data_shuffler.rst","api/mala.datahandling.fast_tensor_dataset.rst","api/mala.datahandling.lazy_load_dataset.rst","api/mala.datahandling.lazy_load_dataset_single.rst","api/mala.datahandling.multi_lazy_load_data_loader.rst","api/mala.datahandling.snapshot.rst","api/mala.descriptors.rst","api/mala.descriptors.atomic_density.rst","api/mala.descriptors.bispectrum.rst","api/mala.descriptors.descriptor.rst","api/mala.descriptors.lammps_utils.rst","api/mala.descriptors.minterpy_descriptors.rst","api/mala.interfaces.rst","api/mala.interfaces.ase_calculator.rst","api/mala.network.rst","api/mala.network.acsd_analyzer.rst","api/mala.network.hyper_opt.rst","api/mala.network.hyper_opt_naswot.rst","api/mala.network.hyper_opt_oat.rst","api/mala.network.hyper_opt_optuna.rst","api/mala.network.hyperparameter.rst","api/mala.network.hyperparameter_acsd.rst","api/mala.network.hyperparameter_naswot.rst","api/mala.network.hyperparameter_oat.rst","api/mala.network.hyperparameter_optuna.rst","api/mala.network.multi_training_pruner.rst","api/mala.network.naswot_pruner.rst","api/mala.network.network.rst","api/mala.network.objective_base.rst","api/mala.network.objective_naswot.rst","api/mala.network.predictor.rst","api/mala.network.runner.rst","api/mala.network.tester.rst","api/mala.network.trainer.rst","api/mala.targets.rst","api/mala.targets.atomic_force.rst","api/mala.targets.calculation_helpers.rst","api/mala.targets.cube_parser.rst","api/mala.targets.density.rst","api/mala.targets.dos.rst","api/mala.targets.ldos.rst","api/mala.targets.target.rst","api/mala.targets.xsf_parser.rst","api/mala.version.rst","api/modules.rst","basic_usage.rst","basic_usage/hyperparameters.rst","basic_usage/more_data.rst","basic_usage/predictions.rst","basic_usage/trainingmodel.rst","citing.rst","index.md","install/installing_lammps.rst","install/installing_mala.rst","install/installing_qe.rst","installation.rst"],objects:{"":[[7,0,0,"-","mala"]],"mala.common":[[9,0,0,"-","check_modules"],[10,0,0,"-","json_serializable"],[11,0,0,"-","parallelizer"],[12,0,0,"-","parameters"],[13,0,0,"-","physical_data"]],"mala.common.check_modules":[[9,1,1,"","check_modules"]],"mala.common.json_serializable":[[10,2,1,"","JSONSerializable"]],"mala.common.json_serializable.JSONSerializable":[[10,3,1,"","from_json"],[10,3,1,"","to_json"]],"mala.common.parallelizer":[[11,1,1,"","barrier"],[11,1,1,"","finalize"],[11,1,1,"","get_comm"],[11,1,1,"","get_local_rank"],[11,1,1,"","get_rank"],[11,1,1,"","get_size"],[11,1,1,"","parallel_warn"],[11,1,1,"","printout"],[11,1,1,"","set_current_verbosity"],[11,1,1,"","set_horovod_status"],[11,1,1,"","set_lammps_instance"],[11,1,1,"","set_mpi_status"]],"mala.common.parameters":[[12,2,1,"","Parameters"],[12,2,1,"","ParametersBase"],[12,2,1,"","ParametersData"],[12,2,1,"","ParametersDataGeneration"],[12,2,1,"","ParametersDescriptors"],[12,2,1,"","ParametersHyperparameterOptimization"],[12,2,1,"","ParametersNetwork"],[12,2,1,"","ParametersRunning"],[12,2,1,"","ParametersTargets"]],"mala.common.parameters.Parameters":[[12,4,1,"","comment"],[12,4,1,"","data"],[12,4,1,"","debug"],[12,4,1,"","descriptors"],[12,5,1,"","device"],[12,4,1,"","hyperparameters"],[12,3,1,"","load_from_file"],[12,3,1,"","load_from_json"],[12,3,1,"","load_from_pickle"],[12,4,1,"","manual_seed"],[12,4,1,"","network"],[12,5,1,"","openpmd_configuration"],[12,5,1,"","openpmd_granularity"],[12,3,1,"","optuna_singlenode_setup"],[12,4,1,"","running"],[12,3,1,"","save"],[12,3,1,"","save_as_json"],[12,3,1,"","save_as_pickle"],[12,3,1,"","show"],[12,4,1,"","targets"],[12,5,1,"","use_gpu"],[12,5,1,"","use_horovod"],[12,5,1,"","use_lammps"],[12,5,1,"","use_mpi"],[12,5,1,"","verbosity"]],"mala.common.parameters.ParametersBase":[[12,3,1,"","from_json"],[12,3,1,"","show"],[12,3,1,"","to_json"]],"mala.common.parameters.ParametersData":[[12,4,1,"","data_splitting_type"],[12,4,1,"","descriptors_contain_xyz"],[12,4,1,"","input_rescaling_type"],[12,4,1,"","output_rescaling_type"],[12,4,1,"","shuffling_seed"],[12,4,1,"","snapshot_directories_list"],[12,4,1,"","use_fast_tensor_data_set"],[12,4,1,"","use_lazy_loading"],[12,4,1,"","use_lazy_loading_prefetch"]],"mala.common.parameters.ParametersDataGeneration":[[12,4,1,"","local_psp_name"],[12,4,1,"","local_psp_path"],[12,4,1,"","ofdft_friction"],[12,4,1,"","ofdft_kedf"],[12,4,1,"","ofdft_number_of_timesteps"],[12,4,1,"","ofdft_temperature"],[12,4,1,"","ofdft_timestep"],[12,4,1,"","trajectory_analysis_below_average_counter"],[12,4,1,"","trajectory_analysis_correlation_metric_cutoff"],[12,4,1,"","trajectory_analysis_denoising_width"],[12,4,1,"","trajectory_analysis_estimated_equilibrium"],[12,4,1,"","trajectory_analysis_temperature_tolerance_percent"]],"mala.common.parameters.ParametersDescriptors":[[12,4,1,"","atomic_density_sigma"],[12,5,1,"","bispectrum_cutoff"],[12,5,1,"","bispectrum_switchflag"],[12,4,1,"","bispectrum_twojmax"],[12,4,1,"","descriptor_type"],[12,4,1,"","descriptors_contain_xyz"],[12,4,1,"","lammps_compute_file"],[12,5,1,"","use_y_splitting"],[12,5,1,"","use_z_splitting"]],"mala.common.parameters.ParametersHyperparameterOptimization":[[12,4,1,"","direction"],[12,4,1,"","hlist"],[12,4,1,"","n_trials"],[12,5,1,"","number_training_per_trial"],[12,5,1,"","rdb_storage_heartbeat"],[12,3,1,"","show"],[12,5,1,"","trial_ensemble_evaluation"]],"mala.common.parameters.ParametersNetwork":[[12,4,1,"","nn_type"]],"mala.common.parameters.ParametersRunning":[[12,5,1,"","after_before_training_metric"],[12,4,1,"","checkpoint_name"],[12,4,1,"","checkpoints_each_epoch"],[12,5,1,"","during_training_metric"],[12,4,1,"","early_stopping_epochs"],[12,4,1,"","early_stopping_threshold"],[12,4,1,"","inference_data_grid"],[12,4,1,"","learning_rate"],[12,4,1,"","learning_rate_decay"],[12,4,1,"","learning_rate_patience"],[12,4,1,"","learning_rate_scheduler"],[12,4,1,"","max_number_epochs"],[12,4,1,"","mini_batch_size"],[12,4,1,"","num_workers"],[12,4,1,"","profiler_range"],[12,4,1,"","training_report_frequency"],[12,4,1,"","trainingtype"],[12,4,1,"","use_compression"],[12,5,1,"","use_graphs"],[12,4,1,"","use_mixed_precision"],[12,4,1,"","use_shuffling_for_samplers"],[12,4,1,"","visualisation"],[12,4,1,"","visualisation_dir"],[12,4,1,"","visualisation_dir_append_date"],[12,4,1,"","weight_decay"]],"mala.common.parameters.ParametersTargets":[[12,4,1,"","ldos_gridoffset_ev"],[12,4,1,"","ldos_gridsize"],[12,4,1,"","ldos_gridspacing_ev"],[12,4,1,"","pseudopotential_path"],[12,4,1,"","rdf_parameters"],[12,5,1,"","restrict_targets"],[12,4,1,"","ssf_parameters"],[12,4,1,"","target_type"],[12,4,1,"","tpcf_parameters"]],"mala.common.physical_data":[[13,2,1,"","PhysicalData"]],"mala.common.physical_data.PhysicalData":[[13,2,1,"","SkipArrayWriting"],[13,5,1,"","data_name"],[13,5,1,"","feature_size"],[13,3,1,"","read_dimensions_from_numpy_file"],[13,3,1,"","read_dimensions_from_openpmd_file"],[13,3,1,"","read_from_numpy_file"],[13,3,1,"","read_from_openpmd_file"],[13,5,1,"","si_dimension"],[13,5,1,"","si_unit_conversion"],[13,3,1,"","write_to_numpy_file"],[13,3,1,"","write_to_openpmd_file"],[13,3,1,"","write_to_openpmd_iteration"]],"mala.datageneration":[[15,0,0,"-","ofdft_initializer"],[16,0,0,"-","trajectory_analyzer"]],"mala.datageneration.ofdft_initializer":[[15,2,1,"","OFDFTInitializer"]],"mala.datageneration.ofdft_initializer.OFDFTInitializer":[[15,3,1,"","get_equilibrated_configuration"]],"mala.datageneration.trajectory_analyzer":[[16,2,1,"","TrajectoryAnalyzer"]],"mala.datageneration.trajectory_analyzer.TrajectoryAnalyzer":[[16,5,1,"","first_snapshot"],[16,3,1,"","get_first_snapshot"],[16,3,1,"","get_snapshot_correlation_cutoff"],[16,3,1,"","get_uncorrelated_snapshots"],[16,5,1,"","snapshot_correlation_cutoff"],[16,5,1,"","trajectory"],[16,3,1,"","uncache_properties"]],"mala.datahandling":[[18,0,0,"-","data_converter"],[19,0,0,"-","data_handler"],[20,0,0,"-","data_handler_base"],[21,0,0,"-","data_repo"],[22,0,0,"-","data_scaler"],[23,0,0,"-","data_shuffler"],[24,0,0,"-","fast_tensor_dataset"],[25,0,0,"-","lazy_load_dataset"],[26,0,0,"-","lazy_load_dataset_single"],[27,0,0,"-","multi_lazy_load_data_loader"],[28,0,0,"-","snapshot"]],"mala.datahandling.data_converter":[[18,2,1,"","DataConverter"]],"mala.datahandling.data_converter.DataConverter":[[18,3,1,"","add_snapshot"],[18,3,1,"","convert_snapshots"],[18,4,1,"","descriptor_calculator"],[18,4,1,"","target_calculator"]],"mala.datahandling.data_handler":[[19,2,1,"","DataHandler"]],"mala.datahandling.data_handler.DataHandler":[[19,3,1,"","clear_data"],[19,3,1,"","get_snapshot_calculation_output"],[19,3,1,"","get_test_input_gradient"],[19,3,1,"","mix_datasets"],[19,3,1,"","prepare_data"],[19,3,1,"","prepare_for_testing"],[19,3,1,"","raw_numpy_to_converted_scaled_tensor"],[19,3,1,"","resize_snapshots_for_debugging"]],"mala.datahandling.data_handler_base":[[20,2,1,"","DataHandlerBase"]],"mala.datahandling.data_handler_base.DataHandlerBase":[[20,3,1,"","add_snapshot"],[20,3,1,"","clear_data"],[20,5,1,"","input_dimension"],[20,5,1,"","output_dimension"]],"mala.datahandling.data_scaler":[[22,2,1,"","DataScaler"]],"mala.datahandling.data_scaler.DataScaler":[[22,3,1,"","finish_incremental_fitting"],[22,3,1,"","fit"],[22,3,1,"","incremental_fit"],[22,3,1,"","inverse_transform"],[22,3,1,"","load_from_file"],[22,3,1,"","save"],[22,3,1,"","start_incremental_fitting"],[22,3,1,"","transform"]],"mala.datahandling.data_shuffler":[[23,2,1,"","DataShuffler"]],"mala.datahandling.data_shuffler.DataShuffler":[[23,3,1,"","add_snapshot"],[23,3,1,"","shuffle_snapshots"]],"mala.datahandling.fast_tensor_dataset":[[24,2,1,"","FastTensorDataset"]],"mala.datahandling.fast_tensor_dataset.FastTensorDataset":[[24,3,1,"","shuffle"]],"mala.datahandling.lazy_load_dataset":[[25,2,1,"","LazyLoadDataset"]],"mala.datahandling.lazy_load_dataset.LazyLoadDataset":[[25,3,1,"","add_snapshot_to_dataset"],[25,3,1,"","get_new_data"],[25,3,1,"","mix_datasets"],[25,5,1,"","return_outputs_directly"]],"mala.datahandling.lazy_load_dataset_single":[[26,2,1,"","LazyLoadDatasetSingle"]],"mala.datahandling.lazy_load_dataset_single.LazyLoadDatasetSingle":[[26,3,1,"","allocate_shared_mem"],[26,3,1,"","deallocate_shared_mem"],[26,3,1,"","delete_data"],[26,3,1,"","mix_datasets"]],"mala.datahandling.multi_lazy_load_data_loader":[[27,2,1,"","MultiLazyLoadDataLoader"]],"mala.datahandling.multi_lazy_load_data_loader.MultiLazyLoadDataLoader":[[27,3,1,"","cleanup"],[27,3,1,"","load_snapshot_to_shm"]],"mala.datahandling.snapshot":[[28,2,1,"","Snapshot"]],"mala.datahandling.snapshot.Snapshot":[[28,3,1,"","from_json"]],"mala.descriptors":[[30,0,0,"-","atomic_density"],[31,0,0,"-","bispectrum"],[32,0,0,"-","descriptor"],[33,0,0,"-","lammps_utils"],[34,0,0,"-","minterpy_descriptors"]],"mala.descriptors.atomic_density":[[30,2,1,"","AtomicDensity"]],"mala.descriptors.atomic_density.AtomicDensity":[[30,3,1,"","backconvert_units"],[30,3,1,"","convert_units"],[30,5,1,"","data_name"],[30,5,1,"","feature_size"],[30,3,1,"","get_optimal_sigma"]],"mala.descriptors.bispectrum":[[31,2,1,"","Bispectrum"]],"mala.descriptors.bispectrum.Bispectrum":[[31,3,1,"","backconvert_units"],[31,3,1,"","convert_units"],[31,5,1,"","data_name"],[31,5,1,"","feature_size"]],"mala.descriptors.descriptor":[[32,2,1,"","Descriptor"]],"mala.descriptors.descriptor.Descriptor":[[32,3,1,"","backconvert_units"],[32,3,1,"","calculate_from_atoms"],[32,3,1,"","calculate_from_qe_out"],[32,3,1,"","convert_local_to_3d"],[32,3,1,"","convert_units"],[32,5,1,"","descriptors_contain_xyz"],[32,3,1,"","enforce_pbc"],[32,3,1,"","gather_descriptors"],[32,5,1,"","si_dimension"],[32,5,1,"","si_unit_conversion"]],"mala.descriptors.lammps_utils":[[33,1,1,"","extract_compute_np"],[33,1,1,"","set_cmdlinevars"]],"mala.descriptors.minterpy_descriptors":[[34,2,1,"","MinterpyDescriptors"]],"mala.descriptors.minterpy_descriptors.MinterpyDescriptors":[[34,3,1,"","backconvert_units"],[34,3,1,"","convert_units"],[34,5,1,"","data_name"],[34,5,1,"","feature_size"]],"mala.interfaces":[[36,0,0,"-","ase_calculator"]],"mala.interfaces.ase_calculator":[[36,2,1,"","MALA"]],"mala.interfaces.ase_calculator.MALA":[[36,3,1,"","calculate"],[36,3,1,"","calculate_properties"],[36,4,1,"","implemented_properties"],[36,3,1,"","load_model"],[36,3,1,"","save_calculator"]],"mala.network":[[38,0,0,"-","acsd_analyzer"],[39,0,0,"-","hyper_opt"],[40,0,0,"-","hyper_opt_naswot"],[41,0,0,"-","hyper_opt_oat"],[42,0,0,"-","hyper_opt_optuna"],[43,0,0,"-","hyperparameter"],[44,0,0,"-","hyperparameter_acsd"],[45,0,0,"-","hyperparameter_naswot"],[46,0,0,"-","hyperparameter_oat"],[47,0,0,"-","hyperparameter_optuna"],[48,0,0,"-","multi_training_pruner"],[49,0,0,"-","naswot_pruner"],[50,0,0,"-","network"],[51,0,0,"-","objective_base"],[52,0,0,"-","objective_naswot"],[53,0,0,"-","predictor"],[54,0,0,"-","runner"],[55,0,0,"-","tester"],[56,0,0,"-","trainer"]],"mala.network.acsd_analyzer":[[38,2,1,"","ACSDAnalyzer"]],"mala.network.acsd_analyzer.ACSDAnalyzer":[[38,3,1,"","add_hyperparameter"],[38,3,1,"","add_snapshot"],[38,3,1,"","perform_study"],[38,3,1,"","set_optimal_parameters"]],"mala.network.hyper_opt":[[39,2,1,"","HyperOpt"]],"mala.network.hyper_opt.HyperOpt":[[39,3,1,"","add_hyperparameter"],[39,3,1,"","checkpoint_exists"],[39,3,1,"","clear_hyperparameters"],[39,3,1,"","perform_study"],[39,3,1,"","set_optimal_parameters"],[39,3,1,"","set_parameters"]],"mala.network.hyper_opt_naswot":[[40,2,1,"","HyperOptNASWOT"]],"mala.network.hyper_opt_naswot.HyperOptNASWOT":[[40,3,1,"","get_best_trial_results"],[40,3,1,"","perform_study"],[40,3,1,"","set_optimal_parameters"]],"mala.network.hyper_opt_oat":[[41,2,1,"","HyperOptOAT"]],"mala.network.hyper_opt_oat.HyperOptOAT":[[41,3,1,"","add_hyperparameter"],[41,3,1,"","get_best_trial_results"],[41,3,1,"","get_optimal_parameters"],[41,3,1,"","get_orthogonal_array"],[41,3,1,"","load_from_file"],[41,3,1,"","number_of_runs"],[41,3,1,"","perform_study"],[41,3,1,"","resume_checkpoint"],[41,3,1,"","set_optimal_parameters"],[41,3,1,"","show_order_of_importance"]],"mala.network.hyper_opt_optuna":[[42,2,1,"","HyperOptOptuna"]],"mala.network.hyper_opt_optuna.HyperOptOptuna":[[42,3,1,"","get_trials_from_study"],[42,3,1,"","load_from_file"],[42,3,1,"","perform_study"],[42,3,1,"","requeue_zombie_trials"],[42,3,1,"","resume_checkpoint"],[42,3,1,"","set_optimal_parameters"]],"mala.network.hyperparameter":[[43,2,1,"","Hyperparameter"]],"mala.network.hyperparameter_acsd":[[44,2,1,"","HyperparameterACSD"]],"mala.network.hyperparameter_naswot":[[45,2,1,"","HyperparameterNASWOT"]],"mala.network.hyperparameter_oat":[[46,2,1,"","HyperparameterOAT"]],"mala.network.hyperparameter_oat.HyperparameterOAT":[[46,3,1,"","get_categorical"],[46,3,1,"","get_parameter"],[46,5,1,"","num_choices"]],"mala.network.hyperparameter_optuna":[[47,2,1,"","HyperparameterOptuna"]],"mala.network.hyperparameter_optuna.HyperparameterOptuna":[[47,3,1,"","get_categorical"],[47,3,1,"","get_float"],[47,3,1,"","get_int"],[47,3,1,"","get_parameter"]],"mala.network.multi_training_pruner":[[48,2,1,"","MultiTrainingPruner"]],"mala.network.multi_training_pruner.MultiTrainingPruner":[[48,3,1,"","prune"]],"mala.network.naswot_pruner":[[49,2,1,"","NASWOTPruner"]],"mala.network.naswot_pruner.NASWOTPruner":[[49,3,1,"","prune"]],"mala.network.network":[[50,2,1,"","FeedForwardNet"],[50,2,1,"","GRU"],[50,2,1,"","LSTM"],[50,2,1,"","Network"],[50,2,1,"","PositionalEncoding"],[50,2,1,"","TransformerNet"]],"mala.network.network.FeedForwardNet":[[50,3,1,"","forward"]],"mala.network.network.GRU":[[50,3,1,"","forward"],[50,3,1,"","init_hidden"]],"mala.network.network.LSTM":[[50,3,1,"","forward"],[50,3,1,"","init_hidden"]],"mala.network.network.Network":[[50,3,1,"","calculate_loss"],[50,3,1,"","do_prediction"],[50,3,1,"","forward"],[50,3,1,"","load_from_file"],[50,3,1,"","save_network"]],"mala.network.network.PositionalEncoding":[[50,3,1,"","forward"]],"mala.network.network.TransformerNet":[[50,3,1,"","forward"],[50,3,1,"","generate_square_subsequent_mask"],[50,3,1,"","init_weights"]],"mala.network.objective_base":[[51,2,1,"","ObjectiveBase"]],"mala.network.objective_base.ObjectiveBase":[[51,3,1,"","parse_trial"],[51,3,1,"","parse_trial_oat"],[51,3,1,"","parse_trial_optuna"]],"mala.network.objective_naswot":[[52,2,1,"","ObjectiveNASWOT"]],"mala.network.predictor":[[53,2,1,"","Predictor"]],"mala.network.predictor.Predictor":[[53,3,1,"","predict_for_atoms"],[53,3,1,"","predict_from_qeout"]],"mala.network.runner":[[54,2,1,"","Runner"]],"mala.network.runner.Runner":[[54,3,1,"","load_run"],[54,3,1,"","run_exists"],[54,3,1,"","save_run"]],"mala.network.tester":[[55,2,1,"","Tester"]],"mala.network.tester.Tester":[[55,3,1,"","predict_targets"],[55,3,1,"","test_all_snapshots"],[55,3,1,"","test_snapshot"]],"mala.network.trainer":[[56,2,1,"","Trainer"]],"mala.network.trainer.Trainer":[[56,3,1,"","load_run"],[56,3,1,"","run_exists"],[56,3,1,"","train_network"]],"mala.targets":[[58,0,0,"-","atomic_force"],[59,0,0,"-","calculation_helpers"],[60,0,0,"-","cube_parser"],[61,0,0,"-","density"],[62,0,0,"-","dos"],[63,0,0,"-","ldos"],[64,0,0,"-","target"],[65,0,0,"-","xsf_parser"]],"mala.targets.atomic_force":[[58,2,1,"","AtomicForce"]],"mala.targets.atomic_force.AtomicForce":[[58,3,1,"","convert_units"],[58,3,1,"","get_feature_size"]],"mala.targets.calculation_helpers":[[59,1,1,"","analytical_integration"],[59,1,1,"","entropy_multiplicator"],[59,1,1,"","fermi_function"],[59,1,1,"","gaussians"],[59,1,1,"","get_beta"],[59,1,1,"","get_f0_value"],[59,1,1,"","get_f1_value"],[59,1,1,"","get_f2_value"],[59,1,1,"","get_s0_value"],[59,1,1,"","get_s1_value"],[59,1,1,"","integrate_values_on_spacing"]],"mala.targets.cube_parser":[[60,2,1,"","CubeFile"],[60,1,1,"","read_cube"],[60,1,1,"","read_imcube"],[60,1,1,"","write_cube"],[60,1,1,"","write_imcube"]],"mala.targets.cube_parser.CubeFile":[[60,3,1,"","readline"]],"mala.targets.density":[[61,2,1,"","Density"]],"mala.targets.density.Density":[[61,3,1,"","backconvert_units"],[61,3,1,"","convert_units"],[61,5,1,"","data_name"],[61,5,1,"","density"],[61,5,1,"","feature_size"],[61,3,1,"","from_cube_file"],[61,3,1,"","from_ldos_calculator"],[61,3,1,"","from_numpy_array"],[61,3,1,"","from_numpy_file"],[61,3,1,"","from_openpmd_file"],[61,3,1,"","from_xsf_file"],[61,3,1,"","get_atomic_forces"],[61,3,1,"","get_density"],[61,3,1,"","get_energy_contributions"],[61,3,1,"","get_number_of_electrons"],[61,3,1,"","get_scaled_positions_for_qe"],[61,3,1,"","get_target"],[61,3,1,"","invalidate_target"],[61,5,1,"","number_of_electrons"],[61,3,1,"","read_from_array"],[61,3,1,"","read_from_cube"],[61,3,1,"","read_from_xsf"],[61,5,1,"","si_dimension"],[61,5,1,"","si_unit_conversion"],[61,4,1,"","te_mutex"],[61,5,1,"","total_energy_contributions"],[61,3,1,"","uncache_properties"],[61,3,1,"","write_to_cube"],[61,3,1,"","write_to_openpmd_file"]],"mala.targets.dos":[[62,2,1,"","DOS"]],"mala.targets.dos.DOS":[[62,3,1,"","backconvert_units"],[62,5,1,"","band_energy"],[62,3,1,"","convert_units"],[62,5,1,"","data_name"],[62,5,1,"","density_of_states"],[62,5,1,"","energy_grid"],[62,5,1,"","entropy_contribution"],[62,5,1,"","feature_size"],[62,5,1,"","fermi_energy"],[62,3,1,"","from_ldos_calculator"],[62,3,1,"","from_numpy_array"],[62,3,1,"","from_numpy_file"],[62,3,1,"","from_qe_dos_txt"],[62,3,1,"","from_qe_out"],[62,3,1,"","get_band_energy"],[62,3,1,"","get_density_of_states"],[62,3,1,"","get_energy_grid"],[62,3,1,"","get_entropy_contribution"],[62,3,1,"","get_number_of_electrons"],[62,3,1,"","get_self_consistent_fermi_energy"],[62,3,1,"","get_target"],[62,3,1,"","invalidate_target"],[62,5,1,"","number_of_electrons"],[62,3,1,"","read_from_array"],[62,3,1,"","read_from_qe_dos_txt"],[62,3,1,"","read_from_qe_out"],[62,5,1,"","si_dimension"],[62,5,1,"","si_unit_conversion"],[62,3,1,"","uncache_properties"]],"mala.targets.ldos":[[63,2,1,"","LDOS"]],"mala.targets.ldos.LDOS":[[63,3,1,"","backconvert_units"],[63,5,1,"","band_energy"],[63,3,1,"","convert_units"],[63,5,1,"","data_name"],[63,5,1,"","density"],[63,5,1,"","density_of_states"],[63,5,1,"","energy_grid"],[63,5,1,"","entropy_contribution"],[63,5,1,"","feature_size"],[63,5,1,"","fermi_energy"],[63,3,1,"","from_cube_file"],[63,3,1,"","from_numpy_array"],[63,3,1,"","from_numpy_file"],[63,3,1,"","from_openpmd_file"],[63,3,1,"","from_xsf_file"],[63,3,1,"","get_atomic_forces"],[63,3,1,"","get_band_energy"],[63,3,1,"","get_density"],[63,3,1,"","get_density_of_states"],[63,3,1,"","get_energy_grid"],[63,3,1,"","get_entropy_contribution"],[63,3,1,"","get_number_of_electrons"],[63,3,1,"","get_self_consistent_fermi_energy"],[63,3,1,"","get_target"],[63,3,1,"","get_total_energy"],[63,3,1,"","invalidate_target"],[63,5,1,"","local_density_of_states"],[63,5,1,"","number_of_electrons"],[63,3,1,"","read_from_array"],[63,3,1,"","read_from_cube"],[63,3,1,"","read_from_xsf"],[63,5,1,"","si_dimension"],[63,5,1,"","si_unit_conversion"],[63,5,1,"","total_energy"],[63,3,1,"","uncache_properties"]],"mala.targets.target":[[64,2,1,"","Target"]],"mala.targets.target.Target":[[64,3,1,"","backconvert_units"],[64,3,1,"","convert_units"],[64,5,1,"","feature_size"],[64,3,1,"","get_energy_grid"],[64,3,1,"","get_radial_distribution_function"],[64,3,1,"","get_real_space_grid"],[64,3,1,"","get_static_structure_factor"],[64,3,1,"","get_target"],[64,3,1,"","get_three_particle_correlation_function"],[64,3,1,"","invalidate_target"],[64,5,1,"","qe_input_data"],[64,3,1,"","radial_distribution_function_from_atoms"],[64,3,1,"","read_additional_calculation_data"],[64,3,1,"","restrict_data"],[64,5,1,"","si_dimension"],[64,5,1,"","si_unit_conversion"],[64,3,1,"","static_structure_factor_from_atoms"],[64,3,1,"","three_particle_correlation_function_from_atoms"],[64,3,1,"","write_additional_calculation_data"],[64,3,1,"","write_tem_input_file"],[64,3,1,"","write_to_numpy_file"],[64,3,1,"","write_to_openpmd_file"]],"mala.targets.xsf_parser":[[65,1,1,"","read_xsf"]],mala:[[8,0,0,"-","common"],[14,0,0,"-","datageneration"],[17,0,0,"-","datahandling"],[29,0,0,"-","descriptors"],[35,0,0,"-","interfaces"],[37,0,0,"-","network"],[57,0,0,"-","targets"],[66,0,0,"-","version"]]},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","class","Python class"],"3":["py","method","Python method"],"4":["py","attribute","Python attribute"],"5":["py","property","Python property"]},objtypes:{"0":"py:module","1":"py:function","2":"py:class","3":"py:method","4":"py:attribute","5":"py:property"},terms:{"0":[2,5,6,11,12,13,18,22,32,33,36,39,43,44,45,46,47,53,59,61,63,64,69,72,76],"000":[2,74],"00001":72,"0048450":64,"005":69,"01":69,"01070":73,"015":69,"023":73,"030":41,"035120":73,"03610":64,"045008":73,"05":12,"1":[2,5,6,12,20,22,32,36,58,59,60,61,62,63,64,70,72,73],"10":[2,3,12,38,41,64,70,72,73,76],"100":[2,6,12,72,74],"1007":41,"1038":73,"104":73,"1063":64,"108":73,"1088":[38,73],"11":[6,12,70,72],"1103":73,"115":73,"12":[3,5,73],"1234":6,"125146":73,"16":73,"1606":64,"1696":64,"17":[64,73],"1883":12,"1_31":41,"1d":[61,63],"1s":12,"2":[2,5,6,12,33,59,62,64,70,72,77],"20":69,"200":5,"2017":60,"2019":[11,60],"2021":73,"2022":73,"2023":73,"2153":[38,73],"224":5,"25th":60,"2632":[38,73],"2685":12,"27":73,"2mic":64,"3":[2,3,12,20,32,41,61,63,70,73,76],"32":[59,69],"33":59,"36808":41,"39m":77,"3d":[61,63],"4":[2,6,12,13,18,70,72,73,76],"40":72,"400":5,"5":[3,6,12,64,70,72],"500":5,"57":64,"6":64,"64":69,"67637":[70,72],"7":[70,76,77],"8":[12,75],"9":73,"91":[32,70],"94":32,"96":69,"97":32,"978":41,"abstract":[13,39,50,64,73],"boolean":[48,49],"break":32,"case":[6,11,12,13,25,26,41,42,48,53,54,63,64,69,75,77],"class":[0,2,4,5,6,10,11,12,13,15,16,18,19,20,22,23,24,25,26,27,28,29,30,31,32,34,36,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,58,60,61,62,63,64,69,70,71,72],"const":60,"default":[4,5,6,11,12,18,19,28,32,33,38,52,53,54,56,62,63,69,70,77],"do":[0,2,3,4,5,7,11,12,19,20,23,25,26,27,30,31,32,34,41,42,50,55,57,59,60,61,63,67,69,70,71,72,75,78],"export":[10,12,76,77],"final":[6,11,72],"float":[12,16,30,33,39,43,44,45,46,47,50,53,59,60,62,63,64,69],"function":[0,1,2,3,5,6,8,9,11,12,13,16,17,22,28,30,31,32,33,34,36,41,42,43,49,50,51,52,58,59,61,62,63,64,69,70,71,72,73,74,76,78],"import":[1,2,3,36,41,53,63,64,71,77,78],"int":[11,12,13,15,16,18,19,23,25,26,39,43,44,45,46,47,50,52,55,59,60,61,62,64,69],"long":[6,12],"new":[0,3,6,11,12,23,25,26,33,69,72],"p\u00f6schel":0,"public":[2,3,6,69,70,73],"return":[2,10,11,12,13,16,19,22,28,30,31,32,33,34,39,41,42,43,46,47,48,49,50,53,54,55,56,58,59,60,61,62,63,64,65],"static":[5,12,27,30,31,32,34,42,50,58,60,61,62,63,64],"switch":[2,5,12],"true":[2,3,5,6,12,13,18,19,22,25,26,32,33,39,41,42,53,54,56,59,61,62,63,64,70,72],"try":26,"var":21,"while":[2,6,12,61,63,64,73],A:[0,3,5,6,10,11,12,13,16,20,24,27,28,32,36,40,42,48,49,51,53,55,56,60,61,63,64,69,73,74],AND:[11,42,50,60],AS:[11,60],ASE:[5,13,30,32,36,53,61,62,63,64],As:[2,3,4,5,62,72,76,78],BE:[11,42,60],BUT:[11,60],Be:[6,12,50],By:[0,5,6,11,12,61,62,63,69,70,72],FOR:[11,60],For:[2,3,4,5,12,16,19,26,32,36,42,54,56,63,64,69,70,71,72,74,75,78],IN:[11,60],IS:[11,60],IT:42,If:[0,2,3,4,5,6,12,13,15,16,18,19,20,22,23,25,26,32,33,38,39,41,42,48,49,53,54,55,56,59,60,61,62,63,64,69,70,73,74,75,77],In:[0,2,6,12,13,25,39,42,43,44,45,46,47,48,61,62,63,64,69,70,71,72,75,77],It:[3,6,12,26,53,55,60,61,62,63,64,68,71,72,74],NO:[11,60],NOT:[11,12,42,60],No:[2,6,12,22,36,72],OF:[11,12,15,60,74],OR:[11,60],Of:[6,12,72],On:3,One:[3,5,6,60,69,72],THE:[11,42,60],THEN:42,TO:[4,11,42,60],That:[54,69],The:[0,1,2,3,4,5,6,10,11,12,13,16,18,19,28,30,32,33,38,39,40,41,42,50,52,54,56,59,60,61,62,63,64,65,68,69,70,71,72,73,74,75,76,77,78],Their:70,Then:[2,5],There:[2,62,69,72],These:[2,3,6,18,42,62,69,70,74],To:[2,4,5,6,12,26,50,72,73,74,75,77],WILL:42,WITH:[11,60],Will:[16,33,43,63],With:[5,12,25,36,69],__getitem__:24,_build:76,_xxx:12,ab:64,abc:[13,20,39],abil:6,abl:0,about:[5,60,64],abov:[2,11,12,16,49,60,72],absolut:[50,55],absolute_valu:12,ac9956:[38,73],acceler:[1,3,5,6,68,73,74],acces:61,access:[3,5,6,9,16,21,22,26,36,64,69,70,71,72,74,77,78],accompani:[0,72,78],accord:[2,61,64,69],accordingli:[70,74],account:[64,74],accur:[2,3,6,64,70],accuraci:[3,6,12,41,72],achiev:12,acitv:12,acquaint:74,acquir:71,across:[1,12,55,72,73,74],acsd:[2,38,70],acsd_analyz:[7,37,67],acsd_point:2,acsdanalyz:[2,38],action:[11,12,60],activ:[0,3,4,5,6,12,54,69,72,74],actual:[0,6,13,16,25,41,42,50,55,69,72,78],actual_output:55,ad:[6,12,16,20,22,25,33,69,70],adam:[0,12,72],add:[0,2,12,18,20,22,23,25,33,38,39,41,69,70,72,73,75,77],add_hyperparamet:[2,38,39,41,69],add_snapshot:[2,4,6,18,20,23,38,69,70,72],add_snapshot_a:20,add_snapshot_to_dataset:25,addit:[0,5,6,12,13,18,36,54,61,64,73,76],addition:[6,72,74],additional_attribut:[13,61,64],additional_calculation_data:[54,72],additional_info_input_:70,additional_info_input_path:[18,70],additional_info_input_typ:[18,70],additional_info_save_path:[18,23,70],additional_metadata:13,additon:[12,36],aditya95sriram:60,adjust:[5,12,64,69,71],adress:[12,42],advanc:[2,5,68,69,70,71,72,73,74,76],advantag:18,advers:6,advis:[2,5,12,54],affect:[6,18],aforement:3,after:[0,3,6,12,36,70,72,75,76],after_before_training_metr:[3,6,12],afterward:[2,6,25,62,71,72],again:[22,76],against:[48,49],aggres:12,agre:[0,72],aidan:[0,73],aim:[5,6],akin:6,al:42,algorihm:12,algorithm:[6,12,69,74],all:[0,1,2,3,4,5,6,10,11,12,13,16,17,18,19,20,22,23,25,26,28,32,36,39,42,43,51,53,54,55,59,60,61,62,63,64,68,69,70,71,72,76,77,78],all_chang:36,alloc:[2,12,26],allocate_shared_mem:26,allow:[0,4,5,6,12,72,74,76],allreduc:12,along:[5,59,73,74],alongsid:[4,13,61,63,76],alphabet:0,alreadi:[6,13,54,71,72,76],also:[1,2,4,5,6,10,12,19,41,50,54,68,70,71,72,73,76,78],alter:[3,71],altern:[12,13,42],alternative_storage_path:42,although:[40,61,74],aluminium:74,alwai:[6,11,12,38,39,43,44,45,46,47,63,68,69,70,75],am:32,american:73,among:69,amount:[2,6,23,72],amp:12,an:[0,1,2,3,4,5,6,11,12,13,15,16,19,25,26,28,30,32,33,36,41,42,44,46,47,48,49,50,51,53,54,58,60,61,62,63,64,68,69,70,71,74,75,76,77],analys:40,analysi:[2,4,5,12,16,38,41,42],analyt:[59,62,63],analytical_integr:59,analyz:[16,38],ang:[58,61],angstrom:32,ani:[6,11,12,13,16,18,24,25,26,36,48,49,50,60,61,64,69,70,72,73,74],anoth:[3,6,26],anyth:[12,61],anywai:18,ap:73,apart:[6,70],api:[4,71,72,74],apidoc:76,appli:[12,19,22,42,64,72,73],applic:[42,52],approach:[18,25,26,28,39,43,44,45,46,47,73],appropri:[0,6,63,70],approxim:59,apt:77,ar:[0,1,2,3,4,5,6,11,12,13,16,18,19,20,25,26,28,32,39,40,42,43,44,45,46,47,50,52,53,54,55,58,59,60,61,62,63,64,65,68,69,70,71,72,73,74,76,78],arbitrari:64,architectur:[3,37,39,40,42,50,51,69,75,76],archiv:[16,72],arg:[24,25,26,36,48,49,50,60],argdict:33,argument:[12,18,33,59,70],aris:[11,60,77],around:2,arrai:[3,12,13,18,19,20,22,23,27,28,30,31,32,33,34,41,46,50,51,53,58,59,60,61,62,63,64,65,76],array_shap:33,articl:[73,74],arxiv:64,as_numpi:22,asap3:64,asap:64,ase:[15,16,30,32,36,53,61,63,64,71],ase_calcul:[7,35,67],aspect:72,assert:74,assign:[6,12,50],associ:[11,60,61,62],assum:[12,13,16,25,26,33,50,59,61,64,68,69,72,77],assumpt:12,asterisk:63,atom:[2,5,6,12,15,16,28,32,36,53,58,60,61,63,64,70,71,72,74,78],atomic_dens:[7,29,67],atomic_density_sigma:12,atomic_forc:[7,57,61,67],atomicdens:30,atomicforc:58,atomist:71,atoms_angstrom:[61,63,64],attach:6,attempt:[4,23,54,56,61,63,64],attent:[12,73],attila:[0,73,74],attribut:[10,12,13,16,21,28,51,61,64],austin:[0,73],author:[11,60,73],automat:[0,3,5,6,12,16,41,50,64,76],avail:[0,2,6,9,12,18,32,39,43,44,45,46,47,59,69,70,72,75,76],availab:6,averag:[2,3,12,64,72],avoid:[3,12,26],awar:[5,50,64,75,77],axi:[12,59],b:[59,73,74],back:[12,26,42],backbon:72,backconvert_unit:[30,31,32,34,61,62,63,64],backend:[5,12],background:3,bad:6,band:[6,12,48,55,62,63,72],band_energi:[3,6,12,48,55,62,63,72],band_energy_ful:55,barrier:11,bartosz:0,base:[0,2,3,4,5,10,12,13,15,16,18,19,20,22,23,24,25,26,27,28,30,31,32,34,36,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,58,60,61,62,63,64,69,72,74],baselin:11,baseprun:[48,49],basi:[12,60],basic:[2,5,6,68,70,72,74],bat:76,batch:[12,52,69],batch_siz:52,be_dens:5,be_ldo:70,be_model:[71,72],be_shuffl:[4,6],be_snapshot0:[4,6,70,72],be_snapshot1:[2,6,71,72],be_snapshot2:2,be_snapshot:[4,70],becaus:[3,12,36,72],been:[0,2,3,6,22,32,62,70,72,73,74,76,77,78],befor:[0,6,12,48,49,63,64,72,76],behavior:12,being:[5,6,11,25,26,36,54,55,56,61,62,63,72],believ:12,below:[0,12,16,60],benchmark:54,best:[12,40,41,61,69],beta:[59,62],better:6,between:[2,3,6,11,12,16,23,25,42,69],bias:[6,12],bidirect:12,big:[0,64],bigger:12,bin:[12,64,75,77],binari:[70,76],bind:77,bispectrum:[2,7,12,29,32,67,70,71,72,75],bispectrum_cutoff:[2,12,70,72],bispectrum_switchflag:12,bispectrum_twojmax:[2,12,70,72],bit:[12,24,61],black:0,blob:[11,64],bohr:[2,61,63,70],boldsymbol:63,bool:[11,12,13,18,19,22,25,26,32,33,39,41,42,48,49,53,54,56,59,61,62,63,64],both:[2,3,55,60,74],bottleneck:6,bound:[39,43,44,45,47,69],boundari:12,bp:4,branch:75,briefli:6,brillouin:59,broadcast_band_energi:62,broadcast_entropi:62,broadcast_fermi_energi:62,brown:11,brzoza:0,buffer:[26,27],bug:0,bugfix:0,build:[0,4,12,19,68,74],build_fold:75,build_mpi:75,build_shared_lib:75,build_total_energy_energy_modul:77,built:[0,11,75],bump2vers:76,bumpvers:0,busi:6,by_snapshot:12,c:[11,60,64],cach:[16,25,26,61,62,63,64],calcul:[0,2,5,6,11,12,13,15,16,18,19,20,22,28,29,30,31,32,33,34,36,38,41,50,52,53,54,55,57,58,59,61,62,63,64,69,70,72,73,74,75,78],calculate_from_atom:32,calculate_from_qe_out:32,calculate_loss:50,calculate_properti:36,calculation_help:[7,57,67],calculation_output:[19,28],calculation_output_fil:20,calculation_typ:64,calibr:[48,49],call:[2,3,6,11,12,13,16,18,24,41,42,49,50,62,64,70,71,72,73,74,78],callow:0,can:[2,3,4,5,6,7,9,10,11,12,13,16,18,19,22,25,26,32,36,41,42,50,51,53,54,55,56,64,69,70,71,72,74,75,77,78],candid:[48,49,69],cangi:[0,73,74],cannot:[6,32,61,63],capabilit:2,capabl:[1,3,4,74],care:[6,26,42],categor:[3,12,39,41,43,44,45,46,47,69],categori:11,caus:73,cd:76,cell:[5,12,30,32,36,50,61,63,64],center:[59,74],cento:78,central:[3,50,72],certain:[12,18,39,40,42,62],cff:0,cflag:77,challeng:[73,74],chanc:[3,12],chang:[0,3,4,5,12,36,62,64,75,76,77],changelog:0,chapter:41,character:[12,30],charg:[11,36,60],check:[0,4,6,9,19,22,36,39,48,54,56,75,76],check_modul:[7,8,67],checkout:[21,75,76],checkpoint:[12,36,39,41,42,54,56],checkpoint_exist:[39,56],checkpoint_nam:[3,6,12,39,41,42],checkpoints_each_epoch:[6,12],checkpoints_each_tri:[3,12],chemistri:73,choic:[38,39,41,43,44,45,46,47,52,69,72],choos:[0,2,12],chosen:[2,12,70],ci:0,circumv:[6,73],citat:[0,73],cite:74,citeseerx:64,cl:54,claim:[11,60],classic:36,classmethod:[10,12,22,28,36,39,41,42,50,54,56,61,62,63],clean:[42,76],cleanup:27,clear:[0,19,39],clear_data:[19,20],clear_hyperparamet:39,clone:76,cloud:2,cluster:[3,42,77],cmake:75,cmake_cxx_compil:75,cmdarg:33,coars:[2,72],code:[3,32,35,64,68,71,73,74,75,76,78],coeffici:72,collabor:0,collect:[3,12,33],collector:36,com:[0,11,12,21,41,60,64,75,76,77],combin:[2,32,36,69],come:[12,32],comm:[11,13],comm_world:11,command:[3,12,33,69],comment:12,commit:0,common:[7,11,12,15,16,18,19,20,23,28,30,31,32,34,36,38,39,40,41,42,43,48,49,50,52,53,54,55,56,58,61,62,63,64,67],commun:[3,11,12,32],compar:[2,12,16,72,74],comparison:64,compat:[3,4,12,21,41,42,50,51,65,71,75],compil:[75,77],complei:60,complet:[6,70],complete_save_path:[6,18,23,70],complex:60,complianc:0,compliant:4,complic:[2,6],compon:[32,70],comprehens:74,compress:[4,12],compuat:64,comput:[1,2,12,22,33,68,73,74],computation:[3,5],compute_typ:33,concept:[3,74],concern:37,concert:54,conda:0,condens:70,condit:[3,11,60],conduct:74,configur:[0,4,12,15,16,32,53,71,72,75,77],conjunct:[3,12],connect:[11,60],consecut:12,conserve_dimens:63,consid:[0,12,19],consist:[18,19,28,60,62,63,69,72,78],consquenc:16,constant:60,constitut:0,construct:[3,12,18,59,64,72,73,74],constructor:60,consult:[0,4],contain:[2,4,10,12,13,20,23,28,29,32,36,40,55,60,61,62,63,64,72],continu:[54,56,76],contract:[11,60],contribut:[12,61,62,63,74],control:[12,25,32,64,72],convent:[39,41,64],convers:[1,13,19,20,23,25,26,27,32,33,58,61,62,63,64,68],convert3dto1d:19,convert:[4,10,12,18,19,30,31,32,33,34,38,58,61,62,63,64,70],convert_local_to_3d:32,convert_snapshot:[4,18,70],convert_to_threedimension:61,convert_unit:[30,31,32,34,58,61,62,63,64],converted_arrai:[30,31,32,34,58,61,62,63,64],converted_tensor:19,convet:[43,44,45,46,47],cooper:6,coordin:[12,32],copi:[11,48,49,54,60,61,62],copyright:[11,60],core:[0,77],correct:[2,5,6,36,43,50,60,61,69,72,76],correctli:[0,61,76],correl:[3,12,16,64],correspond:[6,12,64,69,70],cosin:[2,16],cost:12,costli:74,could:[5,12],count:12,counter:12,cours:[6,12,72],cover:[68,71],covers:[61,63],cpp:64,cppflag:77,cpu:[1,2,3,6,53,54,63,68,75],cpython:77,creat:[5,6,12,13,15,16,18,19,20,23,30,31,32,34,36,38,39,40,41,42,48,49,50,52,53,54,55,56,58,60,61,62,63,64,69,70,71,72,75,76],create_fil:61,create_qe_fil:63,creation:[19,70],critic:72,crucial:4,csv:72,cube:[5,60,61,63,70],cube_pars:[7,57,67],cubefil:60,cubetool:60,cubic:[61,63,64,74],cuda:[6,12,75],current:[0,3,4,5,6,11,12,14,25,26,38,39,40,41,43,46,47,50,51,54,58,59,60,61,62,63,64,70],curv:12,custom:[63,69],cut:12,cutoff:[2,12,16,70],d:[59,62,63,73,74,75],d_model:50,dai:73,damag:[11,60],daniel:[0,11],data:[0,1,3,5,6,7,12,13,14,17,18,19,20,21,22,23,24,25,26,27,28,30,31,32,33,34,36,38,39,40,41,42,50,53,54,55,56,58,59,60,61,62,63,64,65,68,69,71,73,74,78],data_:4,data_convert:[4,7,17,38,67,70],data_handl:[4,5,7,17,36,39,40,41,42,49,51,52,53,54,55,56,63,67,69,71,72],data_handler_bas:[7,17,19,23,67],data_nam:[13,30,31,34,61,62,63],data_path:[2,4,6,70,71,72],data_repo:[7,17,67],data_repo_path:21,data_scal:[7,17,19,25,26,67],data_shuffl:[4,6,7,17,67],data_splitting_typ:12,data_typ:[19,55,64],databas:3,databasenam:3,dataconvert:[2,4,6,18,19,70],dataformat:60,datagener:[7,67],datahandl:[2,3,4,6,7,18,19,23,25,26,27,36,38,39,40,41,42,49,52,53,54,55,56,63,67,69,72],datahandlerbas:[19,20,23],dataload:[25,26],datasampl:[25,26],datascal:[19,22,25,26],dataset:[13,19,24,25,26,27],datashuffl:[4,6,12,23],datashufl:6,datatyp:[39,41,43,44,45,46,47],date:[0,12,60],dayton:73,db:63,dd:63,dd_db:63,de:63,de_dd:63,deactivt:69,dead:42,deadlin:0,deal:[11,13,60,72],dealloc:[26,27],deallocate_shared_mem:26,debian:77,debug:[3,12,72,76],decad:73,decai:12,decid:[0,12,69,72],declar:4,decreas:[12,69],deep:[73,74],defin:[12,48,49,59,62,63,71],degre:16,delete_data:26,delta:[59,62],demand:[2,3,12,50],demonstr:[73,74],denois:12,dens_object:61,denser:70,densiti:[2,5,7,12,55,57,58,62,63,67,71,73,74],density_calcul:[5,61],density_data:[61,63],density_of_st:[5,62,63,71],depend:[5,12,13,19,54,56,60,61,63,70,76],depth:[1,69],deriv:[25,26,27,50,63],descent:12,desciptor:32,describ:[13,30,31,34,61,62,63,69],descript:[0,60,69],descriptor:[0,5,7,11,12,18,19,20,23,25,26,27,28,30,31,34,38,53,63,67,70,71,72,74,75],descriptor_calcul:[18,19,20,23,25,26,27,38],descriptor_calculation_kwarg:[18,70],descriptor_dimens:32,descriptor_input_path:[18,38,70],descriptor_input_typ:[18,38,70],descriptor_save_path:[18,23,70],descriptor_typ:[12,70,72],descriptor_unit:[18,38],descriptors_contain_xyz:[12,32],descriptors_np:32,deseri:10,deserialized_object:[10,12,28],design:3,desir:[12,16,19,30,31,32,34,43,50,61,62,63,64,74],despit:73,detail:[2,3,12,18,38,74],determin:[2,3,5,12,16,55,69,70,72],determinist:12,detriment:12,dev:76,develop:[6,70,74,76,78],deviat:[3,12,22,72],devic:12,devis:2,dft:[3,5,6,7,12,15,18,22,28,32,61,62,63,68,70,74],diagnost:12,dicitionari:33,dict:[10,12,13,18,28,33,55,60,61,63,64,65],dictionari:[10,12,13,18,28,32,33,55,61,62,63,64,72],dictionati:[61,63,64],diff:0,differ:[2,5,6,38,42,52,59,61,69],differenti:12,dim:19,dimens:[5,12,13,20,25,26,30,31,32,34,50,58,61,62,63,64,72],dimension:[2,13,62,70],dipol:36,direct:[0,5,12,18,64,71],directli:[0,2,6,11,12,32,50,53,54,61,62,63,64,72],directori:[0,6,12,18,19,20,23,28,32,63,76,77],dirti:0,disabl:[6,12,25,26,54],discontinu:12,discourag:[25,26],discret:[5,61,62,63,70],discuss:[1,2,3,6,70,72,74],disentangl:3,disk:[6,23,63,72],displac:16,distanc:[2,12,16],distance_threshold:16,distinct:[2,39,43,44,45,46,47],distinguish:3,distribut:[3,5,11,12,50,60,62,64],divid:[5,61],divisor:[12,59],do_predict:50,doc:76,dockerfil:0,docstr:0,document:[0,4,11,12,60,71,78],documentari:76,doe:[6,11,12,19,30,31,34,39,40,56,60,61,62,63,69,76],doesn:[60,62],doi:[38,64,73],don:[12,64],done:[0,2,3,5,11,12,32,38,39,40,41,42,53,55,60,61,64,69,70,72],dornheim:74,dos_calcul:62,dos_data:[62,63],dos_object:62,dos_valu:63,dot:60,doubl:[18,33],doubt:32,down:11,download:77,drastic:[6,18],drawback:6,dresden:74,drive:28,driven:[4,72],dropout:[12,50],dtype:[13,60],due:[61,62,63],dummi:60,dure:[0,2,6,11,12,49,52,54,63,64,69,71,72,73,76],during_training_metr:12,dx:73,dynam:[12,55,71,74],e:[1,3,4,5,6,12,13,16,18,19,30,31,32,34,35,36,38,39,40,41,42,43,44,45,46,47,59,61,62,63,64,69,70,71,72,75,76,77,78],e_:61,e_ewald:61,e_grid:[62,63],e_hartre:61,e_rho_times_v_hxc:61,e_xc:61,eac:12,each:[2,3,5,12,16,42,48,49,69,70,72,74],earli:12,earlier:64,early_stopping_epoch:[12,69],early_stopping_threshold:12,easi:[3,6,55],easier:[19,71,72],easili:[0,2,3,6,69,72],edu:64,effect:[3,6,12,33,54,63,74],effici:[4,5,64,74,78],effort:[0,74],effortlessli:74,eigenvalu:62,either:[0,5,12,13,19,20,23,40,55,59,61,63,64,69,70,72],electron:[5,7,36,55,58,61,62,63,64,70,71,72,73,74],elem_snapshot:18,elimin:3,elli:[0,73,74],els:[3,6],elsewis:[13,16],emploi:[1,6,72,74],empti:[12,65],emul:22,en:41,enabl:[2,3,5,6,53,54,55,70,72,75],encapsul:6,encod:[2,32,51,70,72,78],encourag:4,end:[3,4,11,12,13,16,42,61,62,63,64,69,72],energi:[0,5,6,7,12,36,48,55,59,61,62,63,64,70,71,72,74,78],energy_grid:[5,59,62,63],energy_integration_method:63,energy_unit:59,energygrid:[62,63],enforc:[32,50,64],enforce_pbc:32,enhanc:[0,74],enough:[2,6,12,48,49,70,78],ensur:[0,6,11,12,18,19,61,63,74],enter:63,entir:[5,6,13,19,20,28,32,50,54,70,72],entri:[0,5,12,61,72],entropi:[59,62,63],entropy_contribut:[62,63],entropy_multipl:59,enviro:70,environ:[0,2],epoch:[6,12,69],epsilon:[59,62],epsilon_:62,epsilon_f:[59,62,63],eq:[59,64],equal:33,equat:[62,64],equilibr:[12,15,16,74],equilibrated_snapshot:16,equival:62,erro:76,erron:26,error:[5,6,11,12,25,55,61,62,63,76],especi:[3,12,48,78],espresso:[2,5,18,32,61,62,63,64,70,71,78],essenti:[12,18,69],establish:6,estim:[12,16],etc:[0,3,10,12,20,28,36,39,43,44,45,46,47,54,69,71,72],euclidean:12,ev:[12,20,32,58,59,61,62,63,64],evalu:[3,5,12,19,63],even:[1,5,64,71],evenli:5,event:[11,60],eventu:[36,63],everi:[0,15,63],everyth:[12,37],evid:12,ewald:61,ex01_checkpoint:6,ex01_checkpoint_train:6,ex01_train_network:72,ex02_shuffle_data:6,ex02_test_network:72,ex03_preprocess_data:70,ex03_tensor_board:6,ex04_acsd:2,ex04_hyperparameter_optim:69,ex05_checkpoint:3,ex05_checkpoint_hyperparameter_optim:3,ex05_run_predict:71,ex06_ase_calcul:71,ex06_distributed_hyperparameter_optim:3,ex07_advanced_hyperparameter_optim:3,ex08_visualize_observ:5,exact:[62,63],exactli:[61,62,63],exampl:[0,2,3,4,5,6,21,41,68,69,70,71,72,74,75],example_minimal_number_of_runs_oa:41,except:[3,5,61,64],excess:73,exclud:12,exclus:[5,69],execut:[3,22,42,68,75],exhibit:74,exist:[3,6,26,39,54,56,60,62,71],expans:2,expect:[6,12],experi:12,experiment:[12,14,69],experiment_ddmmyi:12,explain:69,explan:69,explicitli:[12,32],explictli:32,explor:74,exploratori:[2,4],expon:59,express:[11,60,62,63],extend:[5,18,69,71,74],extens:[4,6],extent:13,external_modul:77,extra:[0,32],extract:[3,13,33,46,47,61,65],extract_compute_np:33,f0:59,f1:59,f2:59,f2py:61,f90:77,f90exec:77,f:59,facilit:74,factor:[2,5,6,12,41,59,62,64,69],fail:12,fairli:[32,71],falkner18a:12,fals:[2,6,12,13,16,18,19,22,25,32,33,38,39,40,41,42,53,54,56,59,61,63,64],familiar:[3,68,72],far:[12,70],faruk:0,fashion:69,fast:12,fast_tensor_dataset:[7,17,67],faster:[5,6,18,24,32,71,75,77],fasttensordataset:[24,26],featur:[0,3,6,12,13,20,22,30,31,34,58,61,62,63,64,68,69,72,74,78],feature_from:13,feature_s:[13,30,31,34,61,62,63,64],feature_to:13,fed:74,feed:[12,50],feed_forward:12,feedforwardnet:50,fermi:[55,59,62,63,64],fermi_energi:[59,62,63],fermi_energy_self_consist:[62,63],fermi_funct:59,fermi_v:59,fetch:27,few:[3,5,72],feynman:61,ff:0,ff_multiple_layers_count:69,ff_multiple_layers_neuron:69,ff_neurons_lay:69,ff_neurons_layer_001:[39,43,44,45,46,47],ff_neurons_layer_002:[39,43,44,45,46,47],ff_neurons_layer_00:69,ff_neurons_layer_01:69,ff_neurons_layer_xx:69,ff_neurons_layer_xxx:12,fflag:77,fiedler:[0,73,74],field:70,file:[0,3,4,5,6,10,11,12,13,15,16,18,19,20,22,23,25,26,27,28,32,36,41,42,50,53,54,56,60,61,62,63,64,65,69,70,72,74,76,77],file_based_commun:[18,38],file_index:25,file_nam:61,file_path:[41,42],filenam:[4,12,22,36,60,65],filename_uncorrelated_snapshot:16,filepath:64,fill:[12,15,69,70],find:[41,73,77],fine:[6,12,70],fingerprint:[12,18,32,38],finish:[6,42],finish_incremental_fit:22,finit:[73,74],first:[2,5,12,16,18,48,49,61,69,70,71,72,74,76,78],first_snapshot:16,firstli:[2,69,72],fit:[11,22,60],fix:[0,76],flag:72,flexibl:64,fname:60,focu:74,folder:[0,12,75,76],follow:[0,1,6,11,12,39,41,43,44,45,46,47,59,60,61,68,69,71,72,74,76],footprint:[12,63],forc:[7,36,58,61,63],forgiv:12,fork:0,form:[0,12,60,61,71],formal:4,format:[5,12,13,22,32,43,52,56,60,61,62,63,64,65,70,71,72],former:1,formerli:12,formula:59,fortran:61,forward:[12,50,52],found:[3,12,38,39,40,41,42],fourier:[12,64],fourier_transform:64,fox:0,fp32:18,fpic:77,frac:[59,63],fraction:12,framework:[3,7,13,50,72],franz:0,free:[3,11,26,60,73,74,78],freedom:22,friction:12,from:[0,2,3,4,5,6,10,11,12,13,16,22,25,26,28,32,33,36,40,41,42,46,47,50,52,53,54,56,59,60,61,62,63,64,65,70,71,72,76],from_cube_fil:[61,63],from_json:[10,12,28],from_ldos_calcul:[5,61,62],from_numpy_arrai:[61,62,63],from_numpy_fil:[61,62,63],from_openpmd_fil:[61,63],from_qe_dos_txt:62,from_qe_out:62,from_xsf_fil:[61,63],front:12,frozentri:[42,48,49],full:[4,6,38,72,75,77],full_visualization_path:6,fulli:[3,4,19],function_valu:59,fundament:0,furnish:[11,60],further:[0,3,4,5,6,12,54,56,69,70,71,72,73,74,75],furthermor:[4,78],futur:[62,72],g:[3,4,5,6,12,13,16,18,30,31,32,34,35,36,39,43,44,45,46,47,61,62,63,64,69,70,71,72,73,74,75,76,77,78],gabriel:[0,73],gain:73,gather:[18,24,32,53,63,72],gather_dens:63,gather_descriptor:32,gather_do:63,gather_ldo:53,gaussian:[12,30,34,59,60],gcc:[75,77],gener:[0,2,5,6,8,11,12,13,14,16,18,41,50,61,62,63,64,68,71,72,73,77],generate_square_subsequent_mask:50,get:[5,11,12,13,19,30,31,32,34,40,41,43,46,53,55,58,59,61,62,63,64,71,72,74],get_atomic_forc:[61,63],get_band_energi:[62,63],get_best_trial_result:[40,41],get_beta:59,get_categor:[46,47],get_comm:11,get_dens:[61,63],get_density_of_st:[62,63],get_energy_contribut:61,get_energy_grid:[62,63,64],get_entropy_contribut:[62,63],get_equilibrated_configur:15,get_f0_valu:59,get_f1_valu:59,get_f2_valu:59,get_feature_s:58,get_first_snapshot:16,get_float:47,get_int:47,get_local_rank:11,get_new_data:25,get_number_of_electron:[61,62,63],get_optimal_paramet:41,get_optimal_sigma:30,get_orthogonal_arrai:41,get_paramet:[46,47],get_potential_energi:71,get_radial_distribution_funct:64,get_rank:11,get_real_space_grid:64,get_s0_valu:59,get_s1_valu:59,get_scaled_positions_for_q:61,get_self_consistent_fermi_energi:[62,63],get_siz:11,get_snapshot_calculation_output:19,get_snapshot_correlation_cutoff:16,get_static_structure_factor:64,get_target:[61,62,63,64],get_test_input_gradi:19,get_three_particle_correlation_funct:64,get_total_energi:63,get_trials_from_studi:42,get_uncorrelated_snapshot:16,git:[0,75,76],github:[0,11,12,21,73,75,76],gitlab:[64,77],give:[1,3,6,12,16,63,68,69,70,72,75],given:[6,13,18,32,53,56,59,60,61,62,63,64,69,70,74,78],glimps:72,gmail:60,gnn:0,gnu:77,go:12,goal:65,goe:12,goo:11,good:[2,3,6,12,48,49],got:0,govern:[69,70],gpaw:71,gpu:[0,3,11,12,54,68,75],gradient:[12,19,25,26,69],grand:73,grant:[11,60],granular:70,graph:[6,12],grate:0,greater:12,greatli:[12,72],grid:[0,5,12,30,32,59,61,62,63,64,70,72,74,78],grid_dimens:[32,61,64],grid_integration_method:63,gridi:[61,63],gridpoint:61,gridsiz:[12,61,63],gridspac:12,gridx:[61,63],gridz:[61,63],ground:72,grow:73,gru:[12,50],guarante:6,guess:64,gui:4,guid:[1,2,5,68,69,70,71,72,74],guidelin:0,h5:[4,13,61,64],h:[61,75],ha:[0,2,4,5,6,11,12,13,22,25,33,36,41,42,48,49,50,53,54,61,62,63,69,70,72,73,74,76,77,78],hacki:12,had:[6,70],hand:[5,12,13],handl:[3,4,6,17,19,20,23,64,76],handler:[41,42,54,56,63],happen:62,har:74,hard:28,hardwar:[1,5,68],haswel:75,have:[0,2,3,5,6,10,12,13,22,25,26,28,30,31,32,34,38,39,42,43,44,45,46,47,59,62,63,64,69,70,71,72,73,75,76,77,78],haven:76,head:[0,12],heartbeat:12,heavi:[5,64],hellman:61,helmholtz:74,help:[3,12,53,63,68,72],helper:[4,59],here:[3,12,16,18,25,26,38,41,50,54,62,69,70,71,72,75],herebi:[11,60],hidden:[12,50,69],hierarchi:13,high:[11,12,39,43,44,45,46,47,73],higher:[12,39,43,44,45,47],highli:[2,4,5,6,14,76,78],hint:6,histogram:[12,64],hiwonjoon:11,hlist:12,hoc:16,hoffmann:[0,73,74],hold:[6,12,19,32,39,40,41,42,53,54,55,56,63],holder:[11,60],horovod:[0,11,12,22,25,26],hossein:0,hotyp:[43,44,45,46,47],how:[2,3,12,22,62,63,64,68,69,70,72,75],howev:[2,4,6,12,26,32,52,63,72,73],hpc:[3,6,12,42,77],html:[12,41,76],http:[0,11,12,21,41,60,64,73,75,76,77],huge:6,hundr:[5,74],hyper_opt:[7,37,38,40,41,42,67],hyper_opt_method:[3,12],hyper_opt_naswot:[7,37,67],hyper_opt_oat:[7,37,67],hyper_opt_optuna:[7,37,67],hyperopt:[3,38,39,40,41,42,69],hyperoptim:[2,69],hyperoptnaswot:[40,43],hyperoptoat:[40,41,43],hyperoptoptuna:[40,42,43],hyperparam:12,hyperparamet:[0,1,2,7,12,37,38,39,40,41,42,44,45,46,47,49,51,52,56,67,68,72,73,74,76],hyperparameter_acsd:[7,37,67],hyperparameter_naswot:[7,37,67],hyperparameter_oat:[7,37,67],hyperparameter_optuna:[7,37,45,67],hyperparameteracsd:[43,44],hyperparameternaswot:[43,45],hyperparameteroat:[43,46],hyperparameteroptuna:[43,45,47],hyperparemet:12,i0:59,i1:59,i:[1,3,5,6,12,16,18,19,25,32,38,39,40,41,42,62,64,69,72,78],i_0:59,i_1:59,ibrav:61,icml2019:11,idea:6,ideal:[2,13,61,64],identif:74,identifi:69,idx:46,ifnam:60,ignor:[3,12,18,61,64,68,75],ik:62,imag:[60,64],imaginari:60,immens:0,impact:[6,63],imped:12,implement:[0,3,5,6,10,12,13,22,32,36,48,49,50,61,62,63,64,74,78],implemented_properti:36,impli:[11,13,60,64],improv:[0,1,12,23,24,72],in_unit:[30,31,32,34,58,61,62,63,64],includ:[0,4,11,12,19,28,32,40,41,54,60,63,69,70,74],incopor:70,incorpor:64,increas:[3,12],increment:[6,22,72,76],incremental_fit:22,indent:12,index:[46,76],indic:[22,26,48,49,55],indisput:12,individu:[3,6,70,72,74,78],industri:6,inf:12,infer:[0,5,12,53,54,55,60,63,71,72,74],inference_data_grid:[5,12],infinit:48,infint:48,info:[12,18,72],inform:[2,3,4,12,13,15,50,62,64,65,70,71,72],infrastructur:[0,42],inher:4,inherit:10,init_hidden:50,init_weight:50,initi:[3,13,15,50,70,74],initial_charg:36,initial_magmom:36,initial_setup:[3,6],initialis:50,initil:12,initrang:50,inject:50,input:[12,19,20,22,23,25,26,27,28,50,61,62,63,64,70,72,78],input_data_scal:[19,25,26],input_dimens:[20,25,26,72],input_directori:[20,23],input_fil:[20,23],input_npy_directori:[20,23,28],input_npy_fil:28,input_requires_grad:[25,26],input_rescaling_typ:[12,69,72],input_shm_nam:27,input_unit:[20,28],inputpp:70,insid:[75,76],instal:[0,2,5,74],instanc:[2,3,4,11,12,13,15,16,18,32],instanti:[12,50,54,56,72],instead:[2,3,5,25,26,41,49,60,64,68,70],institut:74,instruct:[0,2,5,74,75,77],integ:[5,12,18,47,69],integr:[53,59,61,62,63,71],integral_valu:59,integrate_values_on_spac:59,integration_method:[61,62,63],integration_valu:59,intel:75,intend:4,interact:4,interest:[4,5,65,69,71,72],interfac:[0,2,3,7,11,12,13,32,36,43,49,50,53,61,62,63,64,67,69,70,71],interg:[61,63],intern:[13,18,32,53,54,61,64],internal_iteration_numb:[13,61,64],interpret:6,interv:[3,6,12],introduc:[12,74],introduct:68,introductori:70,intuit:[2,6],invalid:[61,62,63,64],invalidate_target:[61,62,63,64],inverse_transform:22,investig:[5,19,20,38,39,42,43,44,45,46,47,69],involv:[2,5,6,72],io:[16,41,71],ion:12,ionic:[12,74],iop:73,ish:77,issu:[12,73],ist:64,iter:[12,13,61,64],its:[4,12,19,69,72,74],itself:[3,5,6,12,16,59,64,70,71,72,73,76],j:[60,73,74,77],jacobian:[12,40,52],jame:0,jiang:74,jmax:12,job:[3,12,42],join:[2,70,71,72],jointli:74,jon:[0,74],josh:[0,12],journal:73,json:[10,12,28,36,54,56,64,69,70],json_dict:[10,12,28],json_serializ:[7,8,12,28,43,67],jsonserializ:[10,12,28,43],judg:[6,48,49],jul:73,jun:73,june:60,jupyt:4,just:[2,3,4,5,12,26,54,56,71,72,78],justifi:59,k:[5,53,59,62,63,64,70,74],k_:59,keep:[0,12,25,26],kei:60,kept:[12,60],keyword:[6,12,18,71],kind:[11,13,20,23,60],kindli:[0,73],kinet:12,kmax:[5,12,64],known:[6,36],kohn:[73,74],kokko:[5,11,75],kokkos_arch_gpuarch:75,kokkos_arch_hostarch:75,kokkos_arch_hsw:75,kokkos_arch_volta70:75,kokkos_enable_cuda:75,kotik:0,kpoint:[5,64],ks:[61,62,63],kulkarni:0,kwarg:[24,25,26,27,32,36,41,48,49,50,61,63],kyle:[0,73],l2:12,l:[12,73,74,75],label:12,laboratori:74,lammp:[2,5,11,12,32,33,78],lammps_compute_fil:12,lammps_util:[7,29,67],langevin:12,larg:[2,4,5,6,32,64,72,73,74,76],larger:[5,12,13,61,64,73],last:[12,25,26,36,42,61,69,72],last_trial:42,lastli:70,latenc:6,later:[3,6,22,40,63,69],latest:41,latter:[3,13,64,70],lattic:60,launch:[3,6,12],layer:[3,12,21,39,43,44,45,46,47,69,72],layer_activ:[12,69,72],layer_activation_00:69,layer_activation_xxx:12,layer_s:[12,69,72],lazi:[12,22,23,25,26,72],lazili:[12,19],lazy_load_dataset:[7,17,67],lazy_load_dataset_singl:[7,17,67],lazyloaddataset:[25,26],lazyloaddatasetsingl:26,lbla:77,ldo:[2,5,6,7,12,18,53,55,57,58,59,61,62,64,67,70,71,72,74,78],ldos_calcul:[5,63,71],ldos_data:63,ldos_gridoffset_ev:[6,12,70,72],ldos_grids:[6,12,70,72],ldos_gridspacing_ev:[6,12,70,72],ldos_object:[61,62],ldosfil:70,lead:[2,5,12,64,74],leaf:19,leakyrelu:[12,69],learn:[6,7,12,22,64,69,72,73,74],learner:11,learning_r:[12,69,72],learning_rate_decai:[12,69],learning_rate_pati:[12,69],learning_rate_schedul:12,least:64,leastearly_stopping_threshold:12,leav:26,left:[4,27],legaci:[12,36,64],length:[5,50,73,74],lenz:[0,73,74],less:[12,18,64],let:[12,70,72],level:[11,12,21,25,26,41,53,59,62,63,72,73,74],lf:76,lfftw3:77,liabil:[11,60],liabl:[11,60],lib:[75,77],liblammp:75,librari:[3,4,5,6,22,49,69,71,72,75,77,78],licens:[11,60],lie:32,like:[3,5,6,11,26,72,77],likewis:[2,5,6],limit:[3,5,6,11,12,27,49,60,74],line:[4,33,60,72,73],linger:11,link:[11,41,69,73,75],linux:[76,77,78],list:[0,2,4,5,12,13,18,19,20,27,28,32,33,36,38,39,40,41,42,43,44,45,46,47,51,55,60,61,64,72],littl:61,llapack:77,lmkl_core:77,lmkl_intel_lp64:77,lmkl_sequenti:77,lmp:33,load:[12,19,20,22,23,25,26,27,36,39,41,42,50,53,54,56,62,69,71,72,75,77],load_from_fil:[12,22,41,42,50,69],load_from_json:12,load_from_pickl:12,load_model:[36,71],load_run:[3,6,54,56,71,72],load_runn:[54,56],load_snapshot_to_shm:27,load_with_gpu:54,load_with_mpi:54,loaded_hyperopt:41,loaded_network:[50,54,56],loaded_param:[41,42,54,56],loaded_paramet:12,loaded_train:42,local:[3,11,12,32,61,63,74,75],local_density_of_st:[62,63],local_offset:13,local_psp_nam:12,local_psp_path:12,local_reach:13,locat:[0,12,63],log:[0,15,59],logdir:6,logging_period:15,longer:[0,2,12,19],look:54,loos:64,loss:[6,12,41,48,50,55,69],loss_function_typ:12,loss_val:50,lot:[65,72,78],low:[12,39,43,44,45,46,47,72],lower:[16,39,43,44,45,47,69],lowest:[12,70],lstm:[12,50],m:74,mach:74,machin:[72,73,74,75,76,77],maco:[76,78],made:[0,5,71],mae:[55,72],magmom:36,magnitud:73,mai:[2,3,12,16,18,59,62,63,69,72,75,76,77],main:77,mainli:4,maintain:[0,6],mainten:[0,74],major:0,make:[0,3,4,5,6,12,52,63,70,72,74,75,76,77],mala:[1,2,3,4,6,8,9,11,12,13,15,16,18,19,20,21,23,25,26,27,28,30,31,32,34,36,38,39,40,41,42,43,44,45,46,47,48,49,50,52,53,54,55,56,58,61,62,63,64,66,67,69,70,72,75,77,78],mala_data_repo:[21,76],mala_foundational_pap:73,mala_hyperparamet:73,mala_paramet:[5,71],mala_shuffled_snapshot:23,mala_sizetransf:73,mala_temperaturetransf:73,mala_vi:6,malada_compat:16,manag:[12,24,72],mandatori:40,mani:[0,2,3,12,70,71],manual:[5,12,69,77],manual_se:12,map:63,mape:55,mark:42,mask:50,mass:60,massiv:[3,73],master:[0,11,64],match:[2,13,60,61,62,63,64],mater:74,materi:[5,71,73,74],mathemat:[3,38,59],mathrm:[59,61],matplotlib:5,matrix:61,matter:[5,19,73,74],max:[12,22,72],max_len:50,max_number_epoch:[12,72],maxim:12,maximum:[2,3,5,12,50,64],mc:[12,35,36],md:[12,15,16,35,36,64,74],mean:[6,12,13,22,32,48,49,52,58,61,62,63,69,70,72],mean_std:12,meaning:[12,64],measur:72,mechan:[18,49,74],medium:12,melt:74,member:[16,64],memori:[6,11,12,18,25,26,27,33,54,56,61,62,63,72],mention:[2,5,6],merchant:[11,60],merg:[0,11,60],merit:71,mess:42,messag:[1,11],meta:[13,60,65],metadata:[4,13,18,26,30,31,34,60,61,62,63,65],metadata_input_path:18,metadata_input_typ:18,method:[0,2,3,5,6,10,12,48,49,50,59,60,61,62,63,64,70,73,74,76],metric:[3,12,16,48,74],mev:6,mic:64,might:[12,26,36,42,50,52],miller:[0,73,74],mimic:60,min:[12,22,72],min_verbos:11,mini:[12,52,69],mini_batch_s:[12,69,72],minim:12,minimum:[11,12,41,64],minor:0,minterpi:0,minterpy_descriptor:[7,29,67],minterpydescriptor:34,minut:5,mit:[11,60],mitig:6,mix:[6,12,19,23,25,26],mix_dataset:[19,25,26],mkl:77,ml:[2,3,5,6,15,58,61,62,63,64,68,70,74],mlr:12,mode:[11,32,54,63,64],model:[0,2,3,5,6,18,36,50,53,54,56,68,69,70,73,74,78],modern:73,modif:[6,64],modifi:[0,11,42,48,49,60,70,77],modin:[0,73,74],modul:[0,9,21,50,60,61,64,78],modular:0,moham:[0,73,74],moldabekov:74,molecular:[71,74],moment:[5,12,19,39,43,44,45,46,47],monitor:6,month:73,more:[1,2,3,5,6,12,22,24,36,59,64,70,71,74],moreov:74,most:[2,6,12,54,73,74,75,76,77,78],move:[12,73],mpi4pi:32,mpi:[2,3,5,11,12,18,53,54,63,75,77],mpi_util:11,mpif90:77,mpirun:3,mse:[12,55],much:[6,26,62],mujoco:11,multi:[5,12],multi_lazy_load_data_load:[7,17,67],multi_train:12,multi_training_prun:[7,37,67],multilazyloaddataload:27,multipl:[1,2,3,6,11,12,16,19,20,27,28,32,39,43,44,45,46,47,48,53,59,63,69,70,72],multiple_gaussian:59,multipli:12,multiplicator_v:59,multitrainingprun:48,multivari:12,must:[12,20,63],mutat:33,mutual:[5,69],my:32,my_studi:3,myriad:73,mysql:3,n:[3,61,73,74],n_trial:[12,69],na:12,naiv:6,name:[0,3,6,12,13,16,18,19,23,27,32,33,36,38,39,41,42,43,44,45,46,47,54,56,61,63,64,69,70,72,75,77],naming_schem:[4,18,70],naming_scheme_input:19,naming_scheme_output:19,naswot:[0,3,12,43,45,48,49],naswot_prun:[7,37,67],naswot_pruner_batch_s:12,naswot_pruner_cutoff:12,naswotprun:49,nation:74,natom:61,natur:[0,12],ndarrai:[13,55,61,62,63,64],ndarri:13,necessari:[3,4,6,10,12,18,22,42,64,68,69,70,71,72,75],necessarili:[61,62,63,64],need:[2,5,10,12,13,19,20,25,28,32,36,50,54,56,59,61,62,63,64,70,72,75,76,77,78],neg:[6,12,64],neglect:12,neighbor:64,neighborhood:16,neither:63,net:[12,50,60],netwok:12,network:[3,6,7,12,19,22,36,38,39,40,41,42,44,45,46,47,48,49,51,52,53,54,55,56,63,67,69,71,72,73,74],neural:[3,12,36,50,53,55,56,72,73,74],neuron:[12,69,72],new_atom:32,new_datahandl:[41,42,54,56],new_hyperopt:[41,42],new_inst:11,new_runn:54,new_train:56,new_valu:11,newer:77,newli:[54,56,70],next:[6,42,60],nil:[0,73],nn:[3,5,6,50,52,64,69,72],nn_type:12,no_data:[41,42],no_hidden_st:12,no_snapshot:12,node:[11,12,42],nois:12,nomenclatur:69,non:[2,4,61,64],none:[12,13,15,16,18,19,20,22,23,28,30,31,32,33,34,36,38,39,40,41,42,43,44,45,46,47,52,53,54,56,61,62,63,64,72],noninfring:[11,60],nor:63,normal:[12,13,22,72],normand:[0,73],note:[0,5,6,12,26,33,38,39,41,42,43,44,45,46,47,49,59,71,75],notebook:[4,41],noteworthi:69,noth:[5,30,31,34],notic:[11,60],now:[4,27,63,65,69,70,71,72,77],np:[3,13,19,59,60,63],npj:[73,74],npy:[2,4,6,18,70,72],nsy:12,num_choic:46,num_head:12,num_hidden_lay:12,num_work:[6,12],number:[0,3,5,6,11,12,13,16,18,19,23,33,36,41,46,55,60,61,62,63,64,66,69,70,72,73,74,77],number_bad_trials_befor:12,number_bad_trials_before_stop:12,number_of_bin:[5,12,64],number_of_electron:[55,61,62,63,72],number_of_run:41,number_of_shuffled_snapshot:[6,23],number_training_per_tri:[3,12],numer:[12,13,16,25,32,39,43,44,45,47,60,61,62,63,64],numpag:73,numpi:[0,2,4,13,18,19,20,22,23,26,27,28,30,31,32,33,34,46,51,53,55,58,59,60,61,62,63,64,65,70],numpy_arrai:19,nvcc_wrapper:75,nvidia:[6,75],o:[12,19],oa:[39,41,43,44,45,46,47,51],oapackag:[41,76],oat:[0,3,12,43,46,51,52],object:[0,3,4,5,6,10,12,13,15,16,18,19,20,22,23,26,27,28,30,31,32,33,34,36,38,39,40,41,42,48,49,50,51,52,53,54,55,56,58,60,61,62,63,64,69,70,71,72],objective_bas:[7,37,52,67],objective_naswot:[7,37,67],objectivebas:[51,52],objectivenaswot:52,observ:[55,71,72,74],observables_to_test:[55,72],obtain:[5,11,19,60,76],occur:[42,59,72,76],oct:73,ofdft_frict:12,ofdft_initi:[7,14,67],ofdft_kedf:12,ofdft_number_of_timestep:12,ofdft_temperatur:12,ofdft_timestep:12,ofdftiniti:15,off:[0,12],offer:[4,6,12,65,74],offici:[4,12,68,71,75,76],offload:[5,6],often:[6,12],ol:[0,73,74],old:[12,28],omar:0,onc:[1,2,3,5,6,42,60,69,70,72],one:[2,3,4,5,6,11,12,16,19,20,23,32,48,53,60,61,62,63,64,69,70,72,74,78],ones:[5,25,26,32,69],ongo:76,onli:[0,1,2,3,5,6,11,12,13,16,18,19,20,22,25,26,28,33,36,41,42,50,53,54,55,59,60,61,62,63,64,65,69,70],onto:0,onward:6,open:[0,4,13,60,76],openmpi:77,openpmd:[0,1,12,13,18,20,23,28,32,61,62,63,64],openpmd_configur:12,openpmd_granular:12,oper:[5,6,11,12,19,20,23,64,70,72,74,76],opt:76,optim:[0,1,2,5,6,12,30,32,38,39,40,41,42,49,51,52,56,64,68,72,73,74,76],optimal_sigma:30,optimizer_dict:56,option1:75,option2:75,option:[3,4,6,9,11,12,13,18,22,26,28,30,31,32,34,38,40,54,56,60,64,69,70,72,73,74,75,78],opttyp:[39,41,43,44,45,46,47],optuna:[3,12,39,41,42,43,44,45,46,47,48,49,51,52,69],optuna_singlenode_setup:[3,12],orbit:74,order:[0,3,6,11,12,13,19,25,26,41,69,70,71,73,76],org:[38,60,64,73],orient:0,origin:[3,11,20,28,33,60,73],orthogon:[3,12,41,46,51,76],os:[2,70,71,72],oscil:16,ot:[25,26],other:[3,6,10,11,16,32,35,60,61,62,64,69,71,74],otherwis:[11,39,56,60],otherwsi:22,our:[4,73],ourselv:22,out:[0,2,4,6,11,19,40,41,53,60,62,64,70,71,72,75,76],out_unit:[30,31,32,34,61,62,63,64],outfil:[32,70],outlin:[6,59],output:[1,2,6,11,12,18,19,20,22,23,25,26,27,28,30,31,32,34,50,55,57,60,61,62,63,64,70,72,76,78],output_data_scal:[19,25,26],output_dimens:[20,25,26,72],output_directori:[20,23],output_fil:[20,23],output_format:[55,72],output_npy_directori:28,output_npy_fil:[20,23,28],output_rescaling_typ:[12,72],output_shm_nam:27,output_unit:[20,28],outsid:[32,63],over:[1,2,64],overal:0,overfit:72,overflow:59,overhead:[3,12,73],overview:[1,75],overwrit:[18,23,26],overwritten:[54,60],own:[4,12,50,72],p:[60,73,74,75],packag:[74,75,78],page:73,pairs:60,paper:[41,48,49,73],parallel:[0,1,4,7,8,12,22,32,63,67,68,74,75],parallel_warn:11,param:[30,31,32,34,36,38,39,40,41,42,50,51,53,54,55,56,58,60,61,62,63,64,69],paramet:[2,3,4,5,6,7,8,10,11,13,15,16,18,19,20,22,23,25,26,27,28,30,31,32,33,34,36,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,58,59,60,61,62,63,64,65,67,69,70,71,74],parametersbas:12,parametersdata:12,parametersdatagener:12,parametersdebug:12,parametersdescriptor:[12,38],parametershyperparameteroptim:12,parametersnetwork:12,parametersrun:[12,52],parameterstarget:[12,64],parametr:19,params_format:[54,56],paraview:4,parent:54,pars:[2,12,18,29,30,31,34,38,51,58,61,62,63,65],parse_tri:51,parse_trial_oat:51,parse_trial_optuna:51,parser:[60,64],part:[5,13,60,61,64,72,78],particl:[12,64],particular:[11,48,49,60],partit:55,parvez:[0,73],pass:[0,12,50,53,63],path:[2,6,12,13,16,18,19,21,36,38,41,42,50,53,54,56,61,62,63,64,70,71,72,75,76,77],path_name_schem:63,path_schem:63,path_to_fil:[50,53],path_to_visu:6,patienc:12,paulbourk:60,pavanello:74,pbc:[32,36],peform:12,penalti:12,peopl:0,pep8:0,per:[12,32,36,69,72],percent:12,perform:[1,3,5,12,18,19,22,24,26,36,38,39,40,41,42,50,53,59,62,63,64,68,70,71,72,73,74,75,78],perform_studi:[2,38,39,40,41,42,69],permiss:[11,60],permit:[11,60],permut:26,person:[11,60,70],phase:73,phenomena:73,phy:[73,74],phyiscal:6,physic:[2,3,6,12,13,57,64,73],physical_data:[7,8,32,64,67],physicaldata:[13,32,64],physrevb:73,pickl:[12,22,32],pip:76,pipelin:[19,20,23],pkg_kokko:75,pkg_ml:75,pkl:[39,41,42,54,56],place:[22,72],plan:75,plane:5,plateau:[12,69],plea:64,pleas:[0,2,3,4,5,6,12,38,39,41,42,43,44,45,46,47,63,69,71,72,73,74,75,76],plot:[2,5,64],plu:[3,12],plugin:4,pmd:4,point:[2,3,5,6,12,21,25,26,33,54,62,64,70,72,74],popoola:[0,73,74],popular:73,portion:[11,18,60],pose:74,posit:[7,32,36,50,53,60,61,70,71],positionalencod:50,possibl:[6,12,38,39,43,44,45,46,47,50,62,69],post:[4,28,64,74,78],postgresql:3,postprocess:[7,58,61,62,63,64],potenti:[0,32,69,74],power:[4,6,71],pp:70,pr:0,practic:6,pre:27,precalcul:78,preced:70,precict:[53,55],precis:[6,12,18,33],predict:[6,7,36,50,53,55,63,64,68,72,73,74],predict_for_atom:[5,53,71],predict_from_qeout:53,predict_target:55,predicted_arrai:50,predicted_ldo:53,predicted_output:55,predictor:[5,7,37,54,56,67,71],prefer:[36,70],prefetch:[6,12,26],prepar:[6,13,19,41,42],prepare_data:[19,54,56,69,72],prepare_for_test:19,preprocess:[2,7,12,32,64,70],present:[13,38,39,40,41,42,54,61,64],press:[12,73],previou:[50,71],primari:69,principl:[2,5,39,43,44,45,46,47,72,74],print:[1,3,6,11,12,41],printout:[1,3,11],prior:[0,2,5,6,12],priorli:16,problem:[6,77],problemat:12,proceed:12,process:[0,2,3,4,6,11,12,18,19,22,25,26,28,32,33,38,51,64,70,71,72,73,74,75,77,78],product:[1,4,6,53,72,75],profil:12,profiler_rang:12,progress:[6,63],project:[0,4,21,75,76],proof:74,proper:[61,62,63,73],properli:[0,11,12],properti:[6,10,12,13,16,20,25,28,30,31,32,34,36,46,61,62,63,64,69,71,74],provid:[2,3,5,6,11,12,13,16,18,21,23,38,40,49,59,60,61,62,63,64,65,70,71,72,75,76],prudent:[3,72],prune:[48,49],pruner:[12,48,49],pseudopotenti:[12,61,63,64,71],pseudopotential_path:[12,71],psu:64,publish:[0,11,60,73],pure:[6,45,62],purpos:[2,11,41,42,60],push:0,put:[5,12,19,42,50],pw:[61,70],py:[0,2,3,6,11,71,72,75],pypi:0,pyproject:0,pytest:76,python3:[3,75],python:[2,3,4,5,19,20,32,33,61,64,71,78],pythonpath:77,pytorch:[12,19,50],q:77,qe:[12,32,53,61,62,63,64,77,78],qe_input_data:[61,63,64],qe_out_fil:32,qe_pseudopotenti:[61,63,64],qef:77,qualiti:0,quantif:0,quantit:12,quantiti:[12,16,18,22,55,57,61,62,63,64],quantum:[5,18,32,61,62,63,64,70,71,73,74,78],quantumespresso:64,question:6,queue:42,quick:32,r:[41,60,63,76],race:3,radial:[5,12,64],radial_distribution_funct:64,radial_distribution_function_from_atom:[5,64],radii:[2,5,12,64],radiu:[2,12,64,70],rais:61,rajamanickam:[0,73,74],ram:[6,25,41,42,50,63],random:[6,50],randomli:3,rang:[2,12,22,41,50,72,73,74],rank:[3,11,12,32,53,62,63],rapid:74,rate:[6,12,50,69],rather:[3,19,61,62,63],raw:[2,18,19,32,70],raw_numpy_to_converted_scaled_tensor:19,rawradialdistribut:64,rdb:[12,42],rdb_storag:[3,12,42],rdb_storage_heartbeat:12,rdf:[5,12,16,36,64],rdf_paramet:12,re:[0,2,19],read:[4,10,12,13,16,22,25,26,28,53,59,60,61,62,63,64,65,71],read_additional_calculation_data:[62,64],read_additional_read_additional_calculation_data:61,read_cub:60,read_dimensions_from_numpy_fil:13,read_dimensions_from_openpmd_fil:13,read_dtyp:13,read_from_arrai:[61,62,63,71],read_from_cub:[61,63],read_from_numpy_fil:13,read_from_openpmd_fil:13,read_from_qe_dos_txt:62,read_from_qe_out:62,read_from_xsf:[61,63],read_imcub:60,read_xsf:65,readi:[70,72],readlin:60,readthedoc:41,real:[22,60,64,69,72,74,78],realist:78,realli:[30,31,34,36],realspac:[5,16],reason:[6,12,19,62,65,72],rebas:0,recap:6,recent:[73,74,75,76,77],recogn:12,recommend:[6,12,16,61,62,63,64,75,78],reconstruct:[41,42,54,56],record:12,recv:32,redistribut:23,reduc:[12,26,63,70],reducelronplateau:12,reduct:12,refer:[2,3,12,61,68,69,70,72,74,75],reference_data:36,reflect:[5,61,63],reformat:0,regain:26,regard:73,regular:[2,3,5,12,52,70],regularli:0,reimplement:10,rel:[26,50,62],relat:[3,12,75],releas:77,relev:[2,4,6,12],reli:[5,73],relu:[12,69,72],remark:[2,5],remind:[2,5],remov:32,renam:77,reorder:[12,62],reparametrize_scal:19,replac:[4,13,18,28,60,63,74],repo:[0,76],report:[3,12,48,49],repositori:[0,12,68,72,73,74,76,77],repres:[2,12,28,44,45,46,47,51,52,70,72],represent:[45,70,74],reproduc:[0,6,62,63,64],request:[12,41,73],requeue_zombie_tri:42,requir:[0,3,5,6,12,13,26,40,41,60,70,72,75,76,78],research:[73,74],reset:[19,20],reshap:[13,61],resiz:19,resize_snapshots_for_debug:19,resp:[5,12],respect:[3,10,12,20,70,72,73],respres:[46,51],restart:3,restrict:[11,12,60,64],restrict_data:64,restrict_target:12,resubmit:42,result:[3,6,12,18,19,33,51,55,64,70,71,72,74],result_typ:33,resultsfor:74,resum:[3,6,41,42],resume_checkpoint:[41,42],resumpt:[6,41,42],retain:[32,60],return_energy_contribut:63,return_outputs_directli:25,return_plot:[2,38],return_str:64,return_valu:[46,47],retval:60,reusabl:0,rev:[73,74],rewrit:26,rfname:60,right:[11,19,50,60],rmax:[12,64],robust:3,romero:[0,12],room:74,root:[0,22],rossendorf:74,roughli:73,rout:32,routin:[2,4,6,12,72],row:[12,22,46,51,72],rst:76,run:[3,5,11,12,25,32,36,41,42,53,54,56,63,69,72,76,77],run_exist:[3,6,54,56],run_nam:[36,54,56],runner:[7,37,53,55,56,67],runner_dict:54,runtim:4,ry:[2,58,62,63,70],s0:59,s1:59,s41524:73,s:[0,12,39,41,60,62,64,72,73,74,77],safe:1,sai:77,same:[3,6,12,18,19,20,23,32,38,42,50,59,60,63,64,69,77],samefileerror:75,sampl:[12,16,38,39,40,41,42,70,72],sampler:[12,41],sandia:74,save:[3,4,5,6,10,12,13,16,18,19,20,22,23,28,36,41,42,50,54,56,61,62,63,64,69,70,71,72],save_as_json:12,save_as_pickl:12,save_calcul:36,save_format:[12,22],save_nam:[4,6,23],save_network:50,save_path:[36,54],save_run:[54,72],save_runn:54,scalabl:74,scalar:33,scale:[3,4,5,6,12,19,22,25,26,41,42,50,61,63,69,72,73,74,76],scaled_posit:61,scaler:22,scarc:18,scf:61,schedul:[12,42],scheme:[18,19,63],schmerler:[0,73,74],sci:74,scienc:73,scientif:[0,4,74],scikit:22,score:[48,49],script:[3,5,11,12,69,77],se:36,search:[1,2,69],search_paramet:[48,49,52],second:12,secondli:[2,72],section:[6,68,69,70,71,72],see:[0,2,5,12,18,20,28,38,41,60,64,70,71,72,75,77],seed:[6,12],seem:[5,26],select:[2,6,12,13,55,70,72,77],self:[62,63],sell:[11,60],sendv:32,sens:[12,36,52,54,62,63,72],sep:[11,73],separ:[11,18,28,36,54,56,70,72,78],sequenc:50,seri:[4,13],serial:[10,11],serializ:10,serv:[50,53,74],server:42,servernam:3,set:[0,2,3,4,5,6,11,12,13,16,18,19,23,24,25,26,27,32,38,39,40,41,42,51,53,54,55,61,62,63,64,69,70,71,74,75],set_calcul:71,set_cmdlinevar:33,set_current_verbos:11,set_horovod_statu:11,set_lammps_inst:11,set_mpi_statu:11,set_optimal_paramet:[2,38,39,40,41,42,69],set_paramet:39,setup:[0,3,6,35,76],sever:[3,5,59,69,72],sgd:12,sh:77,shall:[11,60],sham:[73,74],shao:74,shape:[33,61,64],share:[26,27],shift:32,ship:75,shorter:6,should:[0,2,3,5,6,11,12,13,19,21,22,30,31,32,34,36,41,42,47,48,49,50,53,54,58,59,61,62,63,64,69,70,72,75,77],should_prun:[48,49],show:[0,12,74],show_order_of_import:41,showcas:[2,74],shown:[2,3,5,6,70,72],shuffl:[0,4,6,12,20,23,24,25,26],shuffle_snapshot:[4,6,23],shuffling_se:[6,12],shut:11,shutil:75,si:[13,32,61,62,63,64],si_dimens:[13,32,61,62,63,64],si_unit_convers:[13,32,61,62,63,64],sigma:[12,30,59],sigmoid:[12,69],sign:0,signal:72,signific:[12,74],significantli:[63,64],silver:73,similar:[2,3,16,74],simp:[59,61,62,63],simpl:[70,71,72],simplest:6,simpli:[5,6,12,16,19,36,51,61],simpson:[59,61,62,63],simul:[5,12,36,60,61,63,70,71,72,73,74,78],sinc:[2,3,5,6,12,18,30,31,32,34,36,42,71,72,76],singl:[3,5,18,24,26,33,55,68],site:13,siva:0,sivasankaran:[73,74],six:36,size:[0,3,5,11,12,13,26,39,43,44,45,46,47,50,52,69,72,74],skip:33,skiparraywrit:13,slice:[5,19],slightli:42,slowest:12,small:[2,6,64,78],smaller:[12,25,69],smallest:[12,16],smear:62,smearing_factor:62,smith:64,smoothli:12,snap:[12,75],snapshot4:18,snapshot:[6,7,12,15,16,17,18,19,20,23,25,26,27,32,38,55,63,67,70,72],snapshot_correlation_cutoff:16,snapshot_directories_list:12,snapshot_funct:28,snapshot_numb:[19,55,63],snapshot_typ:[4,20,23,28],sneha:0,so:[2,3,4,6,11,12,22,50,54,60,61,62,70,72,74,75,76,77,78],societi:73,softwar:[0,5,11,60,70,71,73,74,78],sole:75,solv:59,somashekhar:0,some:[2,6,12,25,26,50,52,54,64,72],someth:[52,77],sometim:76,somewhat:12,soon:7,sort:[22,25,26,32,41],sourc:[0,9,10,11,12,13,15,16,18,19,20,22,23,24,25,26,27,28,30,31,32,33,34,36,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,58,59,60,61,62,63,64,65,71],space:[2,6,59,62,64,69,70,72,74,78],special:[2,24],specif:[3,4,6,12,19,39,50,59,64,71,76],specifi:[2,3,4,5,6,12,13,22,32,52,62,64,69,70,71,72],speed:[6,12,74],speedup:6,sphere:70,sphinxopt:76,split:[5,12],springer:41,sql:[3,42],sqlite:[3,12],sqlite_timeout:12,sqrt:59,squar:[6,12],src:75,srcname:60,ssf:[12,64],ssf_paramet:12,stabl:12,standard:[3,4,5,12,22,69,72],start:[2,3,5,12,22,70],start_incremental_fit:22,starts_at:18,state:[12,50,62,63,71,74],statement:[5,11],static_structur:5,static_structure_factor_from_atom:[5,64],statu:11,stem:[62,63],step:[2,5,12,15,16,68,69,78],stephen:[0,73,74],steve:[0,73],still:[6,11,13,24,27,41,42,73,74],stochast:12,stop:[12,19,69,76],storag:[4,12,42],store:[1,3,12,25,26,36,61,64,70,72],str:[27,36,54,55,56,61,63],straightforward:[0,2,74],strategi:[3,69],strength:41,stress:36,stretch:5,string:[11,12,13,16,18,19,20,22,23,28,30,31,32,33,34,36,38,39,41,42,43,44,45,46,47,50,52,53,54,55,56,58,59,60,61,62,63,64,65],structur:[5,7,12,13,64,70,71,72,73,74,78],studi:[3,12,38,39,40,41,42,48,49,69,73],study_nam:[3,12,42],style:[0,51,64],sub:72,subclass:[43,50],subfold:12,subject:[11,60,76],sublicens:[11,60],submit:0,subobject:72,subroutin:63,subsequ:[12,53,74],subset:[39,40,42],substanti:[11,60],success:[75,77],successfulli:[75,76],suffic:32,suffici:0,suggest:[0,12,16,64],suit:[0,77],suitabl:[5,12,73,74,75,76],sum_i:62,sum_k:62,summari:64,summat:[61,63,64],supervis:0,supervisor:74,support:[0,3,4,5,6,12,20,28,36,39,41,43,44,45,46,47,52,55,58,59,61,62,63,64,75],suppos:[0,33,49,59,63],suppress:59,suppress_overflow:59,sure:[0,3,4,6,32,63,70,72,74,75,76,77],surrog:[12,48,49,74],switchflag:12,symbol:18,symmetri:[61,63],syntax:[2,3,6,72,76],system:[0,2,3,5,6,12,42,61,62,63,64,71,72,74,77],system_chang:36,t:[4,12,41,42,59,60,62,63,64,74,76],tag:[0,76],tahmasbi:0,take:[2,6,12,42,48,49,64],taken:[41,60],tamar:73,target:[2,6,7,11,12,16,18,19,20,23,25,26,27,28,30,31,34,36,38,48,49,50,53,58,61,62,63,67,70,71,72],target_calcul:[5,16,18,19,20,23,25,26,27,38,71],target_calculation_kwarg:70,target_calculator_kwarg:18,target_data:64,target_input_path:[18,38,70],target_input_typ:[18,38,70],target_save_path:[18,23,70],target_temperatur:16,target_typ:[12,70,72],target_unit:[2,18,38,70],targetbas:[58,62],task:[12,59,72,78],te:[20,28,55,72],te_mutex:61,team:[0,4,5,6,75,76],technic:[32,64],techniqu:[3,70,74],technol:74,technolog:73,tell:[3,72,75],tem:[12,64],temperatur:[5,6,12,16,36,53,59,62,63,64,72,73,74],tempor:16,ten:5,tend:64,tensor:[19,22,24,50,63],tensorboard:[0,12],tensordataset:[6,12,24],term:[50,62,63],termin:12,test:[0,4,6,12,19,20,21,25,28,48,49,53,55,69,70,76,77,78],test_al_debug_2k_nr:19,test_all_snapshot:[55,72],test_exampl:0,test_snapshot:55,tester:[6,7,19,37,53,54,56,67,72],text:4,than:[12,69],thei:[0,3,4,5,6,12,42,64,71],them:[0,6,23,32,62,70],themselv:[4,16,19],theorem:61,theori:[3,73,74],thereaft:[62,64],therefor:[4,25,26,32,61,78],therein:[12,73],thermodynam:59,thi:[0,1,2,3,4,5,6,10,11,12,13,15,16,18,19,20,22,23,24,25,26,27,28,30,31,32,33,34,36,38,39,40,41,42,46,48,49,50,51,52,53,54,55,56,58,59,60,61,62,63,64,68,69,70,71,72,73,74,75,76,77,78],thing:[69,70],third:72,thompson:[0,73,74],those:[12,72,77],though:[12,64],thousand:5,thread:11,three:[5,12,64,72,78],three_particle_correlation_function_from_atom:64,threshold:16,through:[3,11,50,61,72],throughout:55,thrown:11,thu:[0,6,12,19,76],time:[3,5,6,12,42,70,72,73,77],timeout:12,timestep:[12,16],timothi:0,titl:73,tmp:70,to_json:[10,12],togeth:[6,69],token:50,toml:[0,12],too:[2,32],tool:[4,14,15,16,64],topic:[70,71],torch:[6,18,19,22,24,25,26,50,63,76],tort:[11,60],total:[0,5,12,55,61,62,63,64,71,72,74,78],total_energi:[12,55,63,71,77],total_energy_contribut:61,total_energy_ful:55,total_energy_modul:77,tpcf:[12,64],tpcf_paramet:12,tpe:41,tr:[4,20,28,55,72],track:19,train:[0,1,2,3,5,7,12,19,20,23,25,28,36,40,41,42,48,49,51,52,54,56,64,68,69,71,73,74,76,78],train_network:[56,72],trainer:[3,6,7,12,37,67,72],training_report_frequ:12,trainingtyp:[12,69,72],traj:15,trajectori:[12,15,16,64],trajectory_analysis_below_average_count:12,trajectory_analysis_correlation_metric_cutoff:12,trajectory_analysis_denoising_width:12,trajectory_analysis_estimated_equilibrium:12,trajectory_analysis_temperature_tolerance_perc:12,trajectory_analyz:[7,14,67],trajectoryanalyz:16,transfer:[0,6,73,74],transform:[12,19,22,25,50,61,64,70],transformernet:50,trapezoid:[59,61,62,63],trapz:[59,61,62,63],treat:[11,76],tree:[0,75],trex:11,trial:[3,12,39,40,41,42,46,47,48,49,51,69],trial_ensemble_evalu:12,trial_list:40,trial_typ:52,tricki:24,trivial:[2,5,6],truth:72,tune:[0,3,6,12,41,69,72],turn:6,tutori:[4,72],tweak:[68,71],twice:[5,64],two:[2,12,13,16,60,69,72,73],twojmax:12,txt:[0,62,76],type:[10,11,12,13,16,18,19,22,24,28,30,31,32,33,34,36,38,39,41,42,43,46,47,48,49,50,53,54,55,56,58,59,60,61,62,63,64,70],typestr:22,typic:75,u:3,ubuntu:78,uncach:[16,61,62,63],uncache_properti:[16,61,62,63],uncertainti:0,unchang:[26,61],uncorrel:[12,16],under:[0,36,54,56],underlin:63,understand:74,uniform:[50,59],unit:[13,18,19,20,23,25,26,27,28,30,31,32,34,38,50,58,61,62,63,64],unless:61,unload:6,unnecessari:[19,54],unscal:22,unseen:72,untest:77,until:[12,25,26,69,70],untouch:4,up:[0,2,6,12,32,42,61,62,63,64,69,70,74],updat:0,upon:[0,3,12,19,42,45,50,70],upper:[5,69],upward:12,url:73,us:[0,1,2,3,4,7,11,12,13,15,16,18,19,20,22,23,24,25,26,27,30,31,32,33,34,36,38,39,40,41,42,43,44,45,46,47,48,49,50,52,53,54,55,56,58,59,60,61,62,63,64,68,69,70,72,73,74,75,76,77,78],usag:[0,5,6,19,54,63,68,71,72,74,75],use_compress:12,use_fast_tensor_data_set:[6,12],use_fp64:[18,33],use_gauss_ldo:70,use_gpu:[5,6,12],use_graph:[6,12],use_horovod:[12,22,25,26],use_lammp:12,use_lazy_load:[6,12,72],use_lazy_loading_prefetch:[6,12],use_memmap:63,use_mixed_precis:[6,12],use_mpi:[2,3,5,12],use_multivari:12,use_pickled_comm:32,use_pkl_checkpoint:[38,39,40,41,42,56],use_shuffling_for_sampl:12,use_y_split:[5,12],use_z_split:12,useabl:70,used_data_handl:63,user:[4,11,12,16,48,49,59,63,72,76],userwarn:11,usual:[5,6,12,16,32,50,51,61,62,64,70],util:[6,24,25,26],v1:76,v2:12,v80:12,v:[74,75],v_:61,va:[20,28,55,72],vaidyanathan:60,valid:[3,6,12,19,20,28,69,72],validation_loss:12,validation_loss_old:12,valu:[2,5,6,11,12,13,16,25,26,30,32,40,41,46,47,48,49,50,52,53,55,59,60,61,62,63,64,69,70,72],valuabl:0,vari:77,variabl:[12,16,19,54,64],varianc:25,varieti:74,variou:[12,71,72,74],vector:[2,12,25,26,32,60,64,70,72],verbos:[11,12,62,70,72],veri:[0,3,6,12,50,62],verif:72,verifi:72,verma:0,versatil:74,version:[7,12,18,24,48,49,67,70,75,76,77],via:[0,2,3,5,6,11,12,16,21,26,61,62,63,64,69,70,71,72,75,76,77,78],viabl:48,view:[2,6,33],viewdoc:64,viewer:4,virtu:6,visibl:50,visit:[3,4],visual:[4,6,12,74],visualis:[6,12],visualisation_dir:[6,12],visualisation_dir_append_d:12,visualizatuon:6,vladyslav:[0,73],vogel:[0,73,74],volta:75,volum:73,volumetr:[4,60,65,70,72],voxel:[30,61,63],w:[41,63,76],w_k:62,wa:[5,6,22,25,26,38,39,40,41,42,50,54,56,61,62,63,64,71],wai:[0,3,6,12,64],wait:[12,42],wait_tim:[3,12],want:[2,5,6,20,23,39,43,44,45,46,47,64,69,72,75,76],warmli:0,warn:[3,11,76],warranti:[11,60],wave:[12,64],wavefunct:61,we:[0,2,3,5,12,22,25,26,32,36,64,65,69,70,72,73,75,77],websit:[3,76],weight:[6,12,50,59,72],weight_decai:12,welcom:0,well:[2,3,6,12,61,68,69,76],were:[5,72],what:[0,20,23,32,36,54,56,60,72],whatev:75,when:[0,1,3,4,6,11,12,18,19,20,28,32,42,48,49,50,54,56,60,63,64,69,70,72,77,78],whenev:72,where:[4,5,6,12,26,36,41,42,54,56,72,75],wherea:70,whether:[9,11,12,25,32,48,49,60],which:[0,2,3,4,5,6,9,12,13,15,16,18,19,20,21,22,23,28,30,31,32,33,34,36,38,39,40,41,42,46,47,48,49,50,51,53,54,55,56,58,59,60,61,62,63,64,69,70,71,72,75,76,77,78],whom:[11,60],wide:74,width:[12,30],window:[76,78],wip:63,wise:[6,12,22,69,72],wish:[5,77],within:[2,11,12,13,19,24,63,72],without:[3,6,11,12,13,40,52,59,60,64,75],won:[41,42],wonjoon:11,work:[0,3,5,11,12,33,40,55,60,61,62,63,64,69,77,78],worker:[6,12],workflow:[2,3,4,5,6,28,35,71,72,73,74],working_directori:[32,70],world:22,worldwid:74,would:[2,13,61],wrap:0,write:[4,13,32,60,61,64],write_additional_calculation_data:64,write_cub:60,write_imcub:60,write_tem_input_fil:64,write_to_cub:[5,61],write_to_numpy_fil:[13,64],write_to_openpmd_fil:[13,61,64],write_to_openpmd_iter:13,written:[38,39,40,41,42,61,64],wuantiti:[61,62,63,64],x86_64:77,x:[5,12,19,32,50,59,64,70,74],xc:61,xcrysden:63,xsf:[61,63,65],xsf_parser:[7,57,67],xvec:60,xyz:[12,32],y:[5,12,19,32,64],ye:75,year:73,yet:[4,6,13,30,31,34,64],yield:[2,6],you:[0,2,3,4,5,6,12,20,23,39,43,44,45,46,47,50,68,70,71,72,73,74,75,76,77,78],your:[0,2,4,5,6,12,70,72,73,74,75,76,77],yourself:68,yovel:[73,74],ysplit:5,yt:4,yvec:60,z:[5,12,19,32,64,73,74],zentrum:74,zero:[5,12,50,69],zero_out_neg:12,zip:[36,54,56,72],zip_run:[54,56],zipextfil:[12,22,50],zombi:42,zone:59,zvec:60},titles:["Contributions","Advanced options","Improved data conversion","Improved hyperparameter optimization","Storing data with OpenPMD","Using MALA in production","Improved training performance","mala","common","check_modules","json_serializable","parallelizer","parameters","physical_data","datageneration","ofdft_initializer","trajectory_analyzer","datahandling","data_converter","data_handler","data_handler_base","data_repo","data_scaler","data_shuffler","fast_tensor_dataset","lazy_load_dataset","lazy_load_dataset_single","multi_lazy_load_data_loader","snapshot","descriptors","atomic_density","bispectrum","descriptor","lammps_utils","minterpy_descriptors","interfaces","ase_calculator","network","acsd_analyzer","hyper_opt","hyper_opt_naswot","hyper_opt_oat","hyper_opt_optuna","hyperparameter","hyperparameter_acsd","hyperparameter_naswot","hyperparameter_oat","hyperparameter_optuna","multi_training_pruner","naswot_pruner","network","objective_base","objective_naswot","predictor","runner","tester","trainer","targets","atomic_force","calculation_helpers","cube_parser","density","dos","ldos","target","xsf_parser","version","API reference","Getting started with MALA","Basic hyperparameter optimization","Data generation and conversion","Using ML-DFT models for predictions","Training an ML-DFT model","Citing MALA","Welcome to MALA!","Installing LAMMPS","Installing MALA","Installing Quantum ESPRESSO (total energy module)","Installation"],titleterms:{"do":62,"public":74,ASE:71,acsd_analyz:38,ad:[0,72,76],advanc:[1,3,6],algorithm:3,an:72,api:67,ase_calcul:36,atomic_dens:30,atomic_forc:58,basic:69,behind:74,bispectrum:31,branch:0,build:[72,75,76,77],calcul:71,calculation_help:59,check_modul:9,checkpoint:[3,6],cite:73,code:0,common:8,content:74,contribut:0,contributor:0,convers:[2,70],cpu:5,creat:0,cube_pars:60,data:[2,4,70,72,76],data_convert:18,data_handl:19,data_handler_bas:20,data_repo:21,data_scal:22,data_shuffl:23,datagener:14,datahandl:17,densiti:61,depend:0,descriptor:[2,29,32],develop:0,dft:[71,72],document:76,doe:74,download:76,energi:77,espresso:77,exampl:76,extens:[75,77],fast_tensor_dataset:24,format:0,gener:70,get:68,gpu:[5,6],how:74,hyper_opt:39,hyper_opt_naswot:40,hyper_opt_oat:41,hyper_opt_optuna:42,hyperparamet:[3,43,69],hyperparameter_acsd:44,hyperparameter_naswot:45,hyperparameter_oat:46,hyperparameter_optuna:47,improv:[2,3,6],instal:[75,76,77,78],interfac:35,issu:0,json_serializ:10,lammp:75,lammps_util:33,lazi:6,lazy_load_dataset:25,lazy_load_dataset_singl:26,ldo:63,librari:76,licens:0,list:69,load:6,local:76,mala:[0,5,7,68,71,73,74,76],metric:6,minterpy_descriptor:34,ml:[71,72],model:[71,72],modul:77,multi_lazy_load_data_load:27,multi_training_prun:48,naswot_prun:49,network:[37,50],objective_bas:51,objective_naswot:52,observ:5,ofdft_initi:15,openpmd:4,optim:[3,69],option:[1,76],parallel:[2,3,5,11],paramet:[12,72],perform:6,physical_data:13,predict:[5,71],predictor:53,prerequisit:[75,76,77],product:5,pull:0,python:[75,76,77],quantum:77,recommend:76,refer:67,releas:0,request:0,run:6,runner:54,search:3,set:72,snapshot:28,start:[68,74],store:4,strategi:0,target:[57,64],tensorboard:6,test:72,tester:55,total:77,train:[6,72],trainer:56,trajectory_analyz:16,tune:2,us:[5,6,71],version:[0,66],visual:5,welcom:74,what:74,where:74,who:74,work:74,xsf_parser:65}}) \ No newline at end of file