Ejemplo n.º 1
0
    def test_calculation_factory(self):
        """Test the `CalculationFactory`."""
        plugin = factories.CalculationFactory('calc_function')
        self.assertEqual(plugin.is_process_function, True)
        self.assertEqual(plugin.node_class, CalcFunctionNode)

        plugin = factories.CalculationFactory('calc_job')
        self.assertEqual(plugin, CalcJob)

        with self.assertRaises(InvalidEntryPointTypeError):
            factories.CalculationFactory('work_function')

        with self.assertRaises(InvalidEntryPointTypeError):
            factories.CalculationFactory('work_chain')
Ejemplo n.º 2
0
def launch_calculation(code, cif, parameters, daemon, dry_run):
    """Run any cod-tools calculation for the given ``CifData`` node.

    The ``-p/--parameters`` option takes a single string with any command line parameters that you want to be passed
    to the calculation, and by extension the cod-tools script. Example::

        aiida-codtools calculation launch cod-tools -X cif-filter -N 95 -p '--use-c-parser --authors "Jane Doe"'

    The parameters will be parsed into a dictionary and passed as the ``parameters`` input node to the calculation.
    """
    from aiida import orm
    from aiida.plugins import factories
    from aiida_codtools.cli.utils.parameters import CliParameters
    from aiida_codtools.common.resources import get_default_options

    parameters = CliParameters.from_string(parameters).get_dictionary()

    inputs = {
        'cif': cif,
        'code': code,
        'metadata': {
            'options': get_default_options(),
            'dry_run': dry_run,
            'store_provenance': not dry_run
        }
    }

    if parameters:
        inputs['parameters'] = orm.Dict(dict=parameters)

    launch.launch_process(factories.CalculationFactory(code.get_attribute('input_plugin')), daemon, **inputs)
Ejemplo n.º 3
0
    def input_file_name_hubbard_file(cls):
        """
        The relative file name of the file containing the Hubbard parameters if they should
        be read from file instead of specified in the input file cards. Requires the
        aiida-quantumespresso-hp plugin to be installed
        """
        try:
            HpCalculation = factories.CalculationFactory('quantumespresso.hp')
        except Exception:
            raise RuntimeError('this is determined by the aiida-quantumespresso-hp plugin but it is not installed')

        return HpCalculation.input_file_name_hubbard_file
Ejemplo n.º 4
0
    def input_file_name_hubbard_file(cls):
        """Return the relative file name of the file containing the Hubbard parameters.

        .. note:: This only applies if they should be read from file instead of specified in the input file cards.
        .. warning:: Requires the aiida-quantumespresso-hp plugin to be installed
        """
        # pylint: disable=no-self-argument,no-self-use
        try:
            HpCalculation = factories.CalculationFactory('quantumespresso.hp')
        except Exception:
            raise RuntimeError('this is determined by the aiida-quantumespresso-hp plugin but it is not installed')

        return HpCalculation.input_file_name_hubbard_file