コード例 #1
0
def todict(record, full=True):

    model = DM(record)

    calc = model['calculation-grain-boundary-search']
    params = {}
    params['calc_key'] = calc['key']
    params['calc_script'] = calc['calculation']['script']
    params['potential_key'] = calc['potential']['key']
    params['potential_id'] = calc['potential']['id']
    params['symbols'] = aslist(calc['system-info']['symbols'])
    params['x_axis_1'] = calc['grain-1']['crystallographic-axes']['x-axis']
    params['y_axis_1'] = calc['grain-1']['crystallographic-axes']['y-axis']
    params['z_axis_1'] = calc['grain-1']['crystallographic-axes']['z-axis']
    params['x_axis_2'] = calc['grain-2']['crystallographic-axes']['x-axis']
    params['y_axis_2'] = calc['grain-2']['crystallographic-axes']['y-axis']
    params['z_axis_2'] = calc['grain-2']['crystallographic-axes']['z-axis']

    if full is True:
        if 'error' in calc:
            params['status'] = calc['status']
            params['error'] = calc['error']
            params['E_gb'] = np.nan

        elif 'status' in calc:
            params['status'] = calc['status']
            params['error'] = np.nan
            params['E_gb'] = np.nan

        else:
            params['status'] = np.nan
            params['error'] = np.nan
            params['E_gb'] = uc.value_unit(calc['lowest-energy']['E_gb'])

    return params
コード例 #2
0
ファイル: todict.py プロジェクト: lmhale99/iprPy
def todict(record, full=True, flat=False):

    model = DM(record)

    calc = model['calculation-grain-boundary-search']
    params = {}
    params['calc_key'] = calc['key']
    params['calc_script'] = calc['calculation']['script']
    params['potential_key'] = calc['potential']['key']
    params['potential_id'] = calc['potential']['id']
    params['symbols'] = aslist(calc['system-info']['symbols'])
    params['x_axis_1'] = calc['grain-1']['crystallographic-axes']['x-axis']
    params['y_axis_1'] = calc['grain-1']['crystallographic-axes']['y-axis']
    params['z_axis_1'] = calc['grain-1']['crystallographic-axes']['z-axis']
    params['x_axis_2'] = calc['grain-2']['crystallographic-axes']['x-axis']
    params['y_axis_2'] = calc['grain-2']['crystallographic-axes']['y-axis']
    params['z_axis_2'] = calc['grain-2']['crystallographic-axes']['z-axis']

    params['status'] = calc.get('status', 'finished')

    if full is True:
        if params['status'] == 'error':
            params['error'] = calc['error']

        elif params['status'] == 'not calculated':
            pass

        else:
            params['E_gb'] = uc.value_unit(calc['lowest-energy']['E_gb'])

    return params
コード例 #3
0
ファイル: master_prepare.py プロジェクト: Aditya-912/iprPy
def main(*args):
    
    # Read input file in as dictionary
    with open(args[0]) as f:
        input_dict = iprPy.input.parse(f)

    # Get database_name
    database_name = input_dict.pop('database_name')

    # Get commands
    commands = {}
    commands['mpi_command'] = input_dict.pop('mpi_command')
    allkeys = list(input_dict.keys())
    for key in allkeys:
        if key[:14] == 'lammps_command':
            commands[key] = input_dict.pop(key)

    # Get pools
    all_styles = aslist(input_dict.pop('styles'))
    all_np_per_runner = aslist(input_dict.pop('np_per_runner'))
    all_run_directory_name = aslist(input_dict.pop('run_directory_name'))
    if len(all_styles) != len(all_np_per_runner) or len(all_styles) != len(all_run_directory_name):
        raise ValueError('Equal numbers of styles, np_per_runner and run_directory_name lines required')
    pools = []
    for styles, np_per_runner, run_directory_name in zip(all_styles, all_np_per_runner, all_run_directory_name):
        pool = {}
        pool['styles'] = styles.split()
        pool['np_per_runner'] = int(np_per_runner)
        pool['run_directory_name'] = run_directory_name
        pools.append(pool)

    # Get pot_kwargs:
    pot_kwargs = {}
    allkeys = list(input_dict.keys())
    for key in allkeys:
        if key[:10] == 'potential_':
            pot_kwargs[key[10:]] = input_dict.pop(key)

    # Get test_commands
    test_commands = boolean(input_dict.pop('test_commands', True))

    master_prepare(database_name, commands, pools, pot_kwargs=pot_kwargs,
                   test_commands=test_commands, **input_dict)
コード例 #4
0
def todict(record, full=True):

    model = DM(record)

    calc = model['calculation-cohesive-energy-relation']
    params = {}
    params['calc_key'] = calc['key']
    params['calc_script'] = calc['calculation']['script']
    params['minimum_r'] = uc.value_unit(
        calc['calculation']['run-parameter']['minimum_r'])
    params['maximum_r'] = uc.value_unit(
        calc['calculation']['run-parameter']['maximum_r'])
    params['number_of_steps_r'] = calc['calculation']['run-parameter'][
        'number_of_steps_r']
    params['sizemults'] = calc['calculation']['run-parameter'][
        'size-multipliers']
    params['sizemults'] = np.array([
        params['sizemults']['a'], params['sizemults']['b'],
        params['sizemults']['c']
    ])
    params['potential_key'] = calc['potential']['key']
    params['potential_id'] = calc['potential']['id']
    params['load'] = '%s %s' % (calc['system-info']['artifact']['format'],
                                calc['system-info']['artifact']['file'])
    params['prototype'] = calc['system-info']['artifact']['family']
    params['symbols'] = aslist(calc['system-info']['symbols'])

    if full is True:
        if 'error' in calc:
            params['status'] = calc['status']
            params['error'] = calc['error']
            params['e_vs_r_plot'] = np.nan
            params['number_min_states'] = 0

        elif 'status' in calc:
            params['status'] = calc['status']
            params['error'] = np.nan
            params['e_vs_r_plot'] = np.nan
            params['number_min_states'] = 1

        else:
            params['status'] = np.nan
            params['error'] = np.nan
            plot = calc['cohesive-energy-relation']
            params['e_vs_r_plot'] = pd.DataFrame({
                'r':
                uc.value_unit(plot['r']),
                'a':
                uc.value_unit(plot['a']),
                'E_coh':
                uc.value_unit(plot['cohesive-energy'])
            })
            params['number_min_states'] = len(
                calc.aslist('minimum-atomic-system'))
    return params
コード例 #5
0
ファイル: master_1_E_vs_r.py プロジェクト: jarinfrench/iprPy
        pool = Pool(num_runners)
    else:
        pool = None

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #

# Prepare E_vs_r_scan
    kwargs = deepcopy(global_kwargs)
    for key in pot_kwargs:
        kwargs[f'prototype_potential_{key}'] = pot_kwargs[key]

    if 'pair_style' not in pot_kwargs:
        #prepare.E_vs_r_scan.bop(database_name, run_directory_name, **kwargs)
        prepare.E_vs_r_scan.main(database_name, run_directory_name, **kwargs)
    else:
        if 'bop' in aslist(pot_kwargs['pair_style']):
            pair_style = kwargs.pop('prototype_potential_pair_style')
            prepare.E_vs_r_scan.bop(database_name, run_directory_name,
                                    **kwargs)
            kwargs['prototype_potential_pair_style'] = pair_style
        prepare.E_vs_r_scan.main(database_name, run_directory_name, **kwargs)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #

# Run E_vs_r_scan
    multi_runners(database_name, run_directory_name, num_runners, pool=pool)

    # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #

    # Close pool
    if pool is not None:
コード例 #6
0
def todict(record, full=True, flat=False):
    """
    Converts the XML content of a record to a dictionary.
    
    Parameters
    ----------
    record : iprPy.Record
        A record of the record style associated with this function.
    full : bool, optional
        Flag used by the calculation records.  A True value will include
        terms for both the calculation's input and results, while a value
        of False will only include input terms (Default is True).
    flat : bool, optional
        Flag affecting the format of the dictionary terms.  If True, the
        dictionary terms are limited to having only str, int, and float
        values, which is useful for comparisons.  If False, the term
        values can be of any data type, which is convenient for analysis.
        (Default is False).
    
    Returns
    -------
    dict
        A dictionary representation of the record's content.
    """
    model = DM(record)
    
    calc = model['calculation-dislocation-Peierls-Nabarro']
    params = {}
    params['calc_key'] = calc['key']
    params['calc_script'] = calc['calculation']['script']
    params['iprPy_version'] = calc['calculation']['iprPy-version']
    params['atomman_version'] = calc['calculation']['atomman-version']
    
    rp = calc['calculation']['run-parameter']
    params['delta_tau_xy'] = uc.value_unit(rp['delta_tau_xy'])
    params['delta_tau_yy'] = uc.value_unit(rp['delta_tau_yy'])
    params['delta_tau_yz'] = uc.value_unit(rp['delta_tau_yz'])
    params['tausteps'] = rp['tausteps']
    params['cdiffstress'] = rp['cdiffstress']
    params['fullstress'] = rp['fullstress']
    params['min_method'] = rp['minimize_style']
    params['min_options'] = rp['minimize_options']
    
    params['load_file'] = calc['system-info']['artifact']['file']
    params['load_style'] = calc['system-info']['artifact']['format']
    params['load_options'] = calc['system-info']['artifact']['load_options']
    params['family'] = calc['system-info']['family']
    symbols = aslist(calc['system-info']['symbol'])
    
    params['dislocation_key'] = calc['dislocation-monopole']['key']
    params['dislocation_id'] = calc['dislocation-monopole']['id']
    
    params['gammasurface_calc_key'] = calc['gamma-surface']['calc_key']
    params['peierlsnabarro_calc_key'] = calc['Peierls-Nabarro']['calc_key']
    
    if flat is True:
        params['symbols'] = ' '.join(symbols)
    else:
        params['symbols'] = symbols
    
    params['status'] = calc.get('status', 'finished')
    
    if full is True:
        if params['status'] == 'error':
            params['error'] = calc['error']
        
        elif params['status'] == 'not calculated':
            pass
        else:
            if flat is True:
                pass
            else:
                params['tau_xy'] = uc.value_unit(calc['tau-xy'])
                params['tau_yy'] = uc.value_unit(calc['tau-yy'])
                params['tau_yz'] = uc.value_unit(calc['tau-yz'])
                params['total_energy'] = uc.value_unit(calc['total-energy'])
    
    return params
コード例 #7
0
def todict(record, full=True):

    model = DM(record)

    calc = model['calculation-system-relax']
    params = {}
    params['calc_key'] = calc['key']
    params['calc_script'] = calc['calculation']['script']
    params['strainrange'] = calc['calculation']['run-parameter'][
        'strain-range']
    params['load_options'] = calc['calculation']['run-parameter'][
        'load_options']
    params['sizemults'] = calc['calculation']['run-parameter'][
        'size-multipliers']
    params['sizemults'] = np.array([
        params['sizemults']['a'], params['sizemults']['b'],
        params['sizemults']['c']
    ])
    params['potential_key'] = calc['potential']['key']
    params['potential_id'] = calc['potential']['id']
    params['load'] = '%s %s' % (calc['system-info']['artifact']['format'],
                                calc['system-info']['artifact']['file'])
    params['prototype'] = calc['system-info']['artifact']['family']
    params['symbols'] = aslist(calc['system-info']['symbols'])
    params['temperature'] = calc['phase-state']['temperature']['value']
    params['pressure_xx'] = uc.value_unit(calc['phase-state']['pressure-xx'])
    params['pressure_yy'] = uc.value_unit(calc['phase-state']['pressure-yy'])
    params['pressure_zz'] = uc.value_unit(calc['phase-state']['pressure-zz'])

    if full is True:
        if 'error' in calc:
            params['status'] = calc['status']
            params['error'] = calc['error']
            params['initial_a'] = np.nan
            params['initial_b'] = np.nan
            params['initial_c'] = np.nan
            params['final_a'] = np.nan
            params['final_b'] = np.nan
            params['final_c'] = np.nan
            params['E_cohesive'] = np.nan
            params['C'] = np.nan

        elif 'status' in calc:
            params['status'] = calc['status']
            params['error'] = np.nan
            params['initial_a'] = np.nan
            params['initial_b'] = np.nan
            params['initial_c'] = np.nan
            params['final_a'] = np.nan
            params['final_b'] = np.nan
            params['final_c'] = np.nan
            params['E_cohesive'] = np.nan
            params['C'] = np.nan

        else:
            params['status'] = np.nan
            params['error'] = np.nan
            init = calc['as-constructed-atomic-system']
            params['initial_a'] = uc.value_unit(init.find('a'))
            try:
                params['initial_b'] = uc.value_unit(init.find('b'))
            except:
                params['initial_b'] = params['initial_a']
            try:
                params['initial_c'] = uc.value_unit(init.find('c'))
            except:
                params['initial_c'] = params['initial_a']

            final = calc['relaxed-atomic-system']
            params['final_a'] = uc.value_unit(final.find('a'))
            try:
                params['final_b'] = uc.value_unit(final.find('b'))
            except:
                params['final_b'] = params['final_a']
            try:
                params['final_c'] = uc.value_unit(final.find('c'))
            except:
                params['final_c'] = params['final_a']
            params['E_cohesive'] = uc.value_unit(calc['cohesive-energy'])
            params['C'] = am.ElasticConstants(model=calc)

    return params
コード例 #8
0
    def modeltodict(self, model):
        """
        Transforms a tiered data model into a flat dictionary.
        """
        calc = model[self.contentroot]
        params = {}
        params['key'] = calc['key']
        params['script'] = calc['calculation']['script']
        params['atomman_version'] = calc['calculation']['atomman-version']
        params['iprPy_version'] = calc['calculation']['iprPy-version']
        params['LAMMPS_version'] = calc['calculation']['LAMMPS-version']

        params['a_mult1'] = calc['calculation']['run-parameter'][
            'size-multipliers']['a'][0]
        params['a_mult2'] = calc['calculation']['run-parameter'][
            'size-multipliers']['a'][1]
        params['b_mult1'] = calc['calculation']['run-parameter'][
            'size-multipliers']['b'][0]
        params['b_mult2'] = calc['calculation']['run-parameter'][
            'size-multipliers']['b'][1]
        params['c_mult1'] = calc['calculation']['run-parameter'][
            'size-multipliers']['c'][0]
        params['c_mult2'] = calc['calculation']['run-parameter'][
            'size-multipliers']['c'][1]
        params['min_etol'] = calc['calculation']['run-parameter'][
            'energytolerance']
        params['min_ftol'] = uc.value_unit(
            calc['calculation']['run-parameter']['forcetolerance'])
        params['min_maxiter'] = calc['calculation']['run-parameter'][
            'maxiterations']
        params['min_maxeval'] = calc['calculation']['run-parameter'][
            'maxevaluations']
        params['min_dmax'] = uc.value_unit(
            calc['calculation']['run-parameter']['maxatommotion'])

        params['potential_LAMMPS_key'] = calc['potential-LAMMPS']['key']
        params['potential_LAMMPS_id'] = calc['potential-LAMMPS']['id']
        params['potential_key'] = calc['potential-LAMMPS']['potential']['key']
        params['potential_id'] = calc['potential-LAMMPS']['potential']['id']

        params['load_file'] = calc['system-info']['artifact']['file']
        params['load_style'] = calc['system-info']['artifact']['format']
        params['load_options'] = calc['system-info']['artifact'][
            'load_options']
        params['family'] = calc['system-info']['family']
        params['symbols'] = ' '.join(aslist(calc['system-info']['symbol']))

        params['temperature'] = uc.value_unit(
            calc['phase-state']['temperature'])
        params['pressure_xx'] = uc.value_unit(
            calc['phase-state']['pressure-xx'])
        params['pressure_yy'] = uc.value_unit(
            calc['phase-state']['pressure-yy'])
        params['pressure_zz'] = uc.value_unit(
            calc['phase-state']['pressure-zz'])
        params['pressure_xy'] = uc.value_unit(
            calc['phase-state']['pressure-xy'])
        params['pressure_xz'] = uc.value_unit(
            calc['phase-state']['pressure-xz'])
        params['pressure_yz'] = uc.value_unit(
            calc['phase-state']['pressure-yz'])

        params['status'] = calc.get('status', 'finished')
        params['error'] = calc.get('error', np.nan)

        if params['status'] == 'finished':

            params['initial_load_file'] = calc['initial-system']['artifact'][
                'file']
            params['initial_load_style'] = calc['initial-system']['artifact'][
                'format']
            params['initial_load_options'] = calc['initial-system'][
                'artifact'].get('load_options', None)
            params['initial_symbols'] = ' '.join(
                aslist(calc['initial-system']['symbols']))

            params['final_load_file'] = calc['final-system']['artifact'][
                'file']
            params['final_load_style'] = calc['final-system']['artifact'][
                'format']
            params['final_load_options'] = calc['final-system'][
                'artifact'].get('load_options', None)
            params['final_symbols'] = ' '.join(
                aslist(calc['final-system']['symbols']))

            params['lx'] = uc.value_unit(calc['measured-box-parameter']['lx'])
            params['ly'] = uc.value_unit(calc['measured-box-parameter']['ly'])
            params['lz'] = uc.value_unit(calc['measured-box-parameter']['lz'])
            params['xy'] = uc.value_unit(calc['measured-box-parameter']['xy'])
            params['xz'] = uc.value_unit(calc['measured-box-parameter']['xz'])
            params['yz'] = uc.value_unit(calc['measured-box-parameter']['yz'])

            params['E_cohesive'] = uc.value_unit(calc['cohesive-energy'])
            params['measured_temperature'] = uc.value_unit(
                calc['measured-phase-state']['temperature'])
            params['measured_pressure_xx'] = uc.value_unit(
                calc['measured-phase-state']['pressure-xx'])
            params['measured_pressure_yy'] = uc.value_unit(
                calc['measured-phase-state']['pressure-yy'])
            params['measured_pressure_zz'] = uc.value_unit(
                calc['measured-phase-state']['pressure-zz'])
            params['measured_pressure_xy'] = uc.value_unit(
                calc['measured-phase-state']['pressure-xy'])
            params['measured_pressure_xz'] = uc.value_unit(
                calc['measured-phase-state']['pressure-xz'])
            params['measured_pressure_yz'] = uc.value_unit(
                calc['measured-phase-state']['pressure-yz'])

        else:
            params['initial_load_file'] = np.nan
            params['initial_load_style'] = np.nan
            params['initial_load_options'] = np.nan
            params['initial_symbols'] = np.nan

            params['final_load_file'] = np.nan
            params['final_load_style'] = np.nan
            params['final_load_options'] = np.nan
            params['initial_symbols'] = np.nan

            params['lx'] = np.nan
            params['ly'] = np.nan
            params['lz'] = np.nan
            params['xy'] = np.nan
            params['xz'] = np.nan
            params['yz'] = np.nan

            params['E_cohesive'] = np.nan
            params['measured_temperature'] = np.nan
            params['measured_pressure_xx'] = np.nan
            params['measured_pressure_yy'] = np.nan
            params['measured_pressure_zz'] = np.nan
            params['measured_pressure_xy'] = np.nan
            params['measured_pressure_xz'] = np.nan
            params['measured_pressure_yz'] = np.nan

        return params