Exemplo n.º 1
0
    def setUp(self):

        # set up test computer
        self.zeopp_code = zt.get_code(entry_point='zeopp.network')
        self.pore_surface_code = pt.get_code(entry_point='phtools.surface')
        self.distance_matrix_code = pt.get_code(entry_point='phtools.dmatrix')
        self.rips_code = gt.get_code(entry_point='gudhi.rdm')
Exemplo n.º 2
0
def main(network_code_string):
    """Example usage:
    $ verdi run submit.py network@localhost
    Alternative use (creates network@localhost-test code):
    $ verdi run submit.py createcode
    """
    if network_code_string == 'createcode':
        from aiida_zeopp import tests
        code = tests.get_code(entry_point='zeopp.network')
    else:
        from aiida.orm import Code
        code = Code.get_from_string(network_code_string)

    # Prepare input parameters
    NetworkParameters = DataFactory('zeopp.parameters')
    # For allowed keys, print(NetworkParameters.schema)
    parameters = NetworkParameters(
        dict={
            'ha': 'LOW',  #just for speed; use 'DEF' for prodution!
            'cssr': True,  #converting to cssr
            'sa': [1.86, 1.86, 1000],  #computing surface area
            'vol': [0.0, 0.0, 1000],  #computing gemetric pore volume
        })

    CifData = DataFactory('cif')
    this_dir = os.path.dirname(os.path.realpath(__file__))
    structure = CifData(file=os.path.join(this_dir, 'HKUST-1.cif'))

    # set up calculation
    inputs = {
        'code': code,
        'parameters': parameters,
        'structure': structure,
        'metadata': {
            'options': {
                'max_wallclock_seconds': 1 * 60,
            },
            'label':
            'aiida_zeopp example calculation',
            'description':
            'Converts .cif to .cssr format, computes surface area, and pore volume',
        },
    }

    # or use aiida.engine.submit
    print('Running NetworkCalculation: wait...')
    result, node = run_get_node(NetworkCalculation, **inputs)  # pylint: disable=unused-variable

    print('Nitrogen accessible surface area (m^2/g): {:.3f}'.format(
        node.outputs.output_parameters.get_attribute('ASA_m^2/g')))
    print('Geometric pore volume (cm^3/g): {:.3f}'.format(
        node.outputs.output_parameters.get_attribute('AV_cm^3/g')))
    print('CSSR structure: SinglefileData<{}>'.format(
        node.outputs.structure_cssr.pk))
Exemplo n.º 3
0
def test_submit(network_code):
    """Example of how to submit a zeo++ calculation.

    Simply copy the contents of this function into a script.
    """
    from aiida.plugins import DataFactory, CalculationFactory
    from aiida.engine import run_get_node

    if not network_code:
        from aiida_zeopp import tests
        network_code = tests.get_code(entry_point='zeopp.network')

    # Prepare input parameters
    NetworkParameters = DataFactory('zeopp.parameters')
    # For allowed keys, print(NetworkParameters.schema)
    parameters = NetworkParameters(
        dict={
            'ha': 'LOW',  #just for speed; use 'DEF' for prodution!
            'psd': [1.2, 1.2, 1000],  #compute pore size distribution
        })

    CifData = DataFactory('cif')
    this_dir = os.path.dirname(os.path.realpath(__file__))
    structure = CifData(file=os.path.join(this_dir, 'HKUST-1.cif'))

    # set up calculation
    inputs = {
        'code': network_code,
        'parameters': parameters,
        'structure': structure,
        'metadata': {
            'options': {
                'max_wallclock_seconds': 1 * 60,
            },
            'label': 'aiida_zeopp example calculation',
            'description': 'Compute PSD',
        },
    }

    NetworkCalculation = CalculationFactory('zeopp.network')
    print('Running NetworkCalculation: computing PSD ...')
    result, node = run_get_node(NetworkCalculation,
                                **inputs)  # or use aiida.engine.submit

    print('NetworkCalculation<{}> terminated.'.format(node.pk))

    print('\nComputed output_parameters {}\n'.format(
        str(result['output_parameters'])))
Exemplo n.º 4
0
 def setUp(self):
     self.code = zt.get_code(entry_point='zeopp.network')
Exemplo n.º 5
0
""" Example submission of work chain """
import os
from aiida_phtools.workflows.dmatrix import DistanceMatrixWorkChain
import aiida_phtools.tests as pt
import aiida_zeopp.tests as zt
import aiida_gudhi.tests as gt

from aiida.work.run import submit
from aiida.orm.data.cif import CifData
from aiida_zeopp.tests import TEST_DIR

structure = CifData(file=os.path.join(TEST_DIR, 'HKUST-1.cif'),
                    parse_policy='lazy')

outputs = submit(
    DistanceMatrixWorkChain,
    structure=structure,
    zeopp_code=zt.get_code(entry_point='zeopp.network'),
    pore_surface_code=pt.get_code(entry_point='phtools.surface'),
    distance_matrix_code=pt.get_code(entry_point='phtools.dmatrix'),
    rips_code=gt.get_code(entry_point='gudhi.rdm'),
)
Exemplo n.º 6
0
# -*- coding: utf-8 -*-
"""Submit a test calculation on localhost.

Usage: verdi run submit.py
"""
from __future__ import absolute_import
from __future__ import print_function

import os
from aiida_zeopp import tests
from aiida.plugins import DataFactory, CalculationFactory
from aiida.engine import run_get_node

NetworkCalculation = CalculationFactory('zeopp.network')
code = tests.get_code(entry_point='zeopp.network')
# To load a pre-configured code, use:
# from aiida.orm import Code
# code = Code.objects.get(label='network@computer')

# Prepare input parameters
NetworkParameters = DataFactory('zeopp.parameters')
# For allowed keys, print(NetworkParameters.schema)
d = {
    'cssr': True,
    'sa': [1.82, 1.82, 1000],
    'volpo': [1.82, 1.82, 1000],
    'chan': 1.2,
    #'ha': 'LOW',
}
parameters = NetworkParameters(dict=d)
Exemplo n.º 7
0
def network_code(aiida_profile):  # pylint: disable=redefined-outer-name,unused-argument
    return zt.get_code(entry_point='zeopp.network')
Exemplo n.º 8
0
def test_get_code():
    """Test helper for setting up a code."""
    from aiida_zeopp import tests
    code = tests.get_code(entry_point='zeopp.network')
    assert 'network' in code.get_execname()
Exemplo n.º 9
0
    def setUp(self):

        # set up test computer
        self.code = zt.get_code(entry_point='zeopp.network')
Exemplo n.º 10
0
def test_submit(network_code, submit=True):
    """Example of how to submit a zeo++ calculation.

    Simply copy the contents of this function into a script.
    """

    if not network_code:
        network_code = tests.get_code(entry_point='zeopp.network')

    # For allowed keys, print(NetworkParameters.schema)
    parameters = DataFactory('zeopp.parameters')(
        dict={
            'ha': 'LOW',  #just for speed; use 'DEF' for prodution!
            'cssr': True,  #converting to cssr
            'res': True,
            'sa': [1.86, 1.86, 1000],  #compute surface area
            'vol': [0.0, 0.0, 1000],  #compute gemetric pore volume
            #'block': [2.0, 100]  #compute blocking spheres for a big molecule
        })

    this_dir = os.path.dirname(os.path.realpath(__file__))
    structure = DataFactory('cif')(file=os.path.join(this_dir, 'HKUST-1.cif'))

    # set up calculation
    inputs = {
        'code': network_code,
        'parameters': parameters,
        'structure': structure,
        'metadata': {
            'options': {
                'max_wallclock_seconds': 1 * 60,
            },
            'label':
            'aiida_zeopp example calculation',
            'description':
            'Converts .cif to .cssr format, computes surface area, and pore volume',
        },
    }

    NetworkCalculation = CalculationFactory('zeopp.network')  # pylint: disable=invalid-name
    print('Running NetworkCalculation: please wait...')
    if submit:
        engine.submit(NetworkCalculation, **inputs)
    else:
        result, node = engine.run_get_node(
            NetworkCalculation, **inputs)  # or use aiida.engine.submit

        print('NetworkCalculation<{}> terminated.'.format(node.pk))

        print('\nComputed output_parameters {}\n'.format(
            str(result['output_parameters'])))
        outputs = result['output_parameters'].get_dict()

        print('Density ({}): {:.3f}'.format(outputs['Density_unit'],
                                            outputs['Density']))

        print('Largest free sphere ({}): {:.3f}'.format(
            outputs['Largest_free_sphere_unit'],
            outputs['Largest_free_sphere']))

        print('Largest included sphere ({}): {:.3f}'.format(
            outputs['Largest_included_sphere_unit'],
            outputs['Largest_included_sphere']))

        print('Nitrogen accessible surface area ({}): {:.3f}'.format(
            outputs['ASA_m^2/g_unit'], outputs['ASA_m^2/g']))

        print('Geometric pore volume ({}): {:.3f}'.format(
            outputs['AV_cm^3/g_unit'], outputs['AV_cm^3/g']))

        # print('Number of blocking spheres needed for probe radius of {:.2f}A: {}'.
        #       format(
        #           outputs['Input_block'][0],
        #           outputs['Number_of_blocking_spheres']))
        # print('Blocking spheres file: SinglefileData<{}>'.format(
        #     node.outputs.block.pk))

        print('CSSR structure: SinglefileData<{}>'.format(
            node.outputs.structure_cssr.pk))