예제 #1
0
def run(pluginManager):
    """
    This is the entry point for the plugin manager.
    The plugin manager will pass a reference to itself
    to the function.
    Use the APD_Printer instance returned by
    pluginManager.setup() instead of the 'print'
    statement to generate autoformated cmd line output.
    :param pluginManager: Reference to the plugin manager
    instance.
    """
    printer = pluginManager.setup()
    data = pluginManager.get_variable()
    if not data:
        loader = Loader(printer)
        loader.create(pluginManager.arg('load'))
        data = DATA()
        data['exp'] = loader.load('exp')
    #     T = loader.get_temperature()
    # else:
    #     T = pluginManager.get_variable('T')
    # obj = ObjectiveObject(data)
    # printer('Searching for optimal rigid bond description...')
    # f, best_solution = harmonize([(0, 10)], obj, 1000, startValues=[5, 0], pitchRange=0.01, dynamicPitch=200)
    # hresult, esd = obj(None, f[0], 'report')
    # printer('U_int/U_all * m ratio of f={:4.2f} yields best hirshfeld solution of {:5.3f} +- {:5.3f}.\n'.
    #         format(f[0], hresult, esd))
    # f = float('{:4.2f}'.format(f[0]))
    a, b = build_ls_matrix(data)
    solution = nnls(a, b)
    f = solution[0][0]
    if f > 1:
        printer('f out of bounds ({:4.2f}).'.format(f))
        printer('Starting linear search for reasonable solution:')
        f = find_f(data)[1]
        printer('U_int/U_all * m ratio of f={:4.2f} yields best hirshfeld solution.\n'.format(f))
    else:
        printer('U_int/U_all * m ratio of f={:4.2f} yields best hirshfeld solution.\n'.format(f))
    pluginManager.register_variable(f, 'f')
    analyser = Analyser(printer, pluginManager.get_variable('f'))
    for atom1, atom2 in data.iter_atom_pairs():
        if not any([atom.adp['flag'] == 'riding' for atom in (atom1, atom2)]) or pluginManager.arg('f'):
            # if atom1.element == 'H' or atom2.element == 'H':
            #     continue
            analyser(atom1, atom2)
    printer()
    printer('Average:             {:6.4f}\n                  +- {:6.4f}'.format(*analyser.harvest()))
    if pluginManager.arg('+'):
        printer('\n\nReporting element specific mean square displacements in bond direction.\n')
        for element, values in details(data).items():
            printer('{:>3}: {:5.3f}'.format(element, mean(values)))
    if pluginManager.arg('write'):
        options = {'full': True, 'use': 'beef'}
        pluginManager.call('W', options)
예제 #2
0
def run(pluginManager):
    """
    Called by the plugin manager.
    Asks the plugin manager for user input and
    configures the database generator to generate
    the desired database file.
    """
    import lauescript.database as db
    from lauescript.types.data import GENERATOR
    from lauescript.laueio.inout import FlexLoad
    from lauescript.laueio.loader import Loader
    from lauescript.core.core import apd_exit

    printer = pluginManager.setup()
    data = DATA()
    loader = Loader(printer)
    pluginManager.register_variable(loader, 'loader')
    pluginManager.register_variable(data, 'data')
    dabapath = '.'
    match = pluginManager.arg('match')
    if pluginManager.arg('generate'):
        printer('Generating new micro database.')
        data = GENERATOR([], True)
        path = pluginManager.arg('load')
        db.generate_micro_database(data, pluginManager.get_frequency_cutoff(), path=path,
                                   printer=printer, clustersize=int(pluginManager.arg('cluster')),
                                   frequency_scale=pluginManager.get_config_valueFloat('Database', 'frequency_scale'))
        apd_exit(0)
    data = pluginManager.get_variable()
    printer('Loading data.')
    filename = pluginManager.arg('load')
    printer('Setting ADP transfer mode to pattern matching.\n')
    loader = Loader(printer)
    pluginManager.register_variable(loader, 'loader')
    if filename:
        if '.apd' in filename:
            printer('APD-Script file found. Executing script.')
            from lauescript.scripting import Parser

            parser = Parser(filename, indent=5)
            printer.enter()
            parser()
            printer.exit()
            apd_exit()
        FlexLoad(data, loader, dabapath, pluginManager, filename, noTransfer=True)
        # data['exp'] = quickLoad(pluginManager, filename)
    else:
        FlexLoad(data, loader, dabapath, pluginManager, noTransfer=True)
        # data['exp'] = quickLoad(pluginManager, filename)
    printer('Loading successful.')
    printer.spacer()
    printer('\nUsing option {} to transfer ADPs.'.format(match))
    data.update(match=match)
예제 #3
0
def run(pluginManager):
    """
    Asks the plugin manager for user input and executes
    the APD-Toolkit's main functions.
    """
    from lauescript.laueio.inout import FlexLoad
    from lauescript.laueio.loader import Loader
    from lauescript.types.data import DATA
    from os.path import isfile

    printer = pluginManager.setup()
    data = DATA()
    loader = Loader(printer)
    pluginManager.register_variable(loader, 'loader')
    pluginManager.register_variable(data, 'data')
    planarityThreshold = float(pluginManager.arg('planarity'))
    # data.register_pluginManager(pluginManager)
    dabapath = pluginManager.get_databasepath()
    # print(pluginManager.arg('temp'))
    # print(pluginManager.arg('load'))

    filename = pluginManager.arg('load')
    if not isfile(filename):
        filename = None
        printer('No file specified. Searching for files in working directory.'
                '\nTo specify a file use \'load <filename>\'.\n')
    if filename:
        # if filename.endswith('.apd'):
        #     printer('APD-Script file found. Executing script.')
        #     from lauescript.core.scripting import Parser
        #
        #     parser = Parser(filename, indent=5, config=pluginManager)
        #     printer.enter()
        #     parser()
        #     printer.exit()
        #     exit()
        FlexLoad(data, loader, dabapath, pluginManager, filename, planarityThreshold=planarityThreshold)
    else:
        FlexLoad(data, loader, dabapath, pluginManager, planarityThreshold=planarityThreshold)
    printer('Loading successful.')
    data.update()