Esempio n. 1
0
exit()

# print out qoi performance constraints
#print(80*'-')
#print('{:^80}'.format('QOI PERFORMANCE CONSTRAINTS'))
#print(80*'-')
#for qoi_name, value in Si_sw_qoi_constraints.items():
#    print('{:>20} {:>10}'.format(qoi_name,value))

_structure_directory = engine.configuration.structures['structure_directory']
_n_iterations = engine.configuration.sampling_type['n_iterations']
_n_samples = engine.configuration.sampling_type[1]['n_samples']
_rv_generators = OrderedDict()

_filename_in = os.path.join('data', 'pypospack.kde.01.out')
_datafile_in = PyposmatDataFile(filename=_filename_in)
_datafile_in.read()
_rv_generator = scipy.stats.gaussian_kde(
    _datafile_in.df[engine.free_parameter_names].values.T)

engine.pyposmat_datafile_out.write_header_section(
    filename=filename_out,
    parameter_names=engine.parameter_names,
    qoi_names=engine.qoi_names,
    error_names=engine.error_names)

import time
time_start = time.time()
_n_errors = 0
_n_samples = engine.configuration.sampling_type[1]['n_samples']
for i_sample in range(_n_samples):
Esempio n. 2
0
from pypospack.pyposmat import PyposmatDataFile
if __name__ == "__main__":
    import Ni__eam__morse_exp_fs as config

    #------------------------------------------------------------------------------
    # WRITE CONFIGURATION FILE
    #------------------------------------------------------------------------------
    configuration = PyposmatConfigurationFile()
    configuration.qois = config.qoi_db.qois
    configuration.qoi_constraints = config.qoi_constraints
    configuration.structures = config.structure_db
    configuration.potential = config.potential_formalism
    configuration.sampling_type = config.sampling
    configuration.sampling_distribution = config.parameter_distribution
    configuration.sampling_constraints = config.parameter_constraints
    configuration.write(filename='pypospack.config.in')
    configuration.read(filename='pypospack.config.in')

    import argparse
    arg_parser = argparse.ArgumentParser()
    arg_parser.add_argument('-i',
                            '--input',
                            type=str,
                            help="input file to be processed")
    args = vars(arg_parser.parse_args())

    filename = args['input']

    datafile = PyposmatDataFile(filename=filename)
    datafile.read()
Esempio n. 3
0
def dev__read():

    testing_set = get_testing_set()

    o = PyposmatDataFile()
    o.read
Esempio n. 4
0
is_convert = False

if is_convert:
    lines = None
    with open(seaton_data_filename, 'r') as f:
        lines = f.readlines()

    for i, line in enumerate(lines):
        _line = [s.strip() for s in line.strip().split(' ')]
        lines[i] = ",".join(_line)

    with open(pypospack_data_filename, 'w') as f:
        f.write("\n".join(lines))

obj_datafile = PyposmatDataFile(filename=pypospack_data_filename)
obj_datafile.read(filename=pypospack_data_filename)

parameter_dictionaries = obj_datafile.parameter_df.to_dict(into=OrderedDict,
                                                           orient='index')

n_potentials = len(parameter_dictionaries)
print('there are {} potentials to evaluation'.format(n_potentials))
for i, parameters in parameter_dictionaries.items():
    sim_id = int(obj_datafile.df.loc[i, 'sim_id'])
    _workflow_directory = 'param_{}'.format(sim_id)

    if os.path.isdir(_workflow_directory):
        shutil.rmtree(_workflow_directory)
    os.mkdir(_workflow_directory)
    temp_0 = 100
Esempio n. 5
0
        'MgO_NaCl.c11': 277.00031,
        'MgO_NaCl.c12': 91.67016,
        'MgO_NaCl.c44': 144.00722,
        'MgO_NaCl.B': 153.4468767,
        'MgO_NaCl.G': 92.665075,
        'MgO_NaCl.fr_a': 10.9781666,
        'MgO_NaCl.fr_c': 8.98642095,
        'MgO_NaCl.sch':5.067179685,
        'MgO_NaCl.001s': 0.055950069}
reference_LC = [2.0,-2.0,0.0,0.5,0.0,821.6,0.3242,0.0,22764.0,0.149,27.88,4.21078276561128,307.5718095128,171.135602331774,168.168424521017,216.61433805878266,68.21810359051298,9.68024989411606,9.810715180656189,5.797051474639375,0.06783817649966246,-0.035217234388720264,30.571809512799973,79.46560233177401,24.158424521016997,63.164338058782675,-24.441896409487015,-1.2977501058839405,0.8247151806561881,0.7300514746393745,0.011888176499662464]
reference_BG1 = [2.0,-2.0,0.0,0.5,0.0,1279.69,0.29969,0.0,9547.96,0.21916,32.0,4.20923604431415,383.274119165401,169.434215310753,179.601185701851,240.71418326230233,106.91995192732399,12.419259511088967,11.869114175328832,7.198887069605007,0.08070791160146304,-0.036763955685850114,106.27411916540098,77.76421531075299,35.591185701851,87.26418326230234,14.259951927323996,1.4412595110889672,2.8831141753288314,2.131887069605007,0.02475791160146304]
reference_BG2 = [1.7,-1.7,0.0,0.5,0.0,929.69,0.29909,0.0,4870,0.2679,77.0,4.222448,301.315822490901,150.827961179874,142.471471673523,200.990581616883,75.2439306555135,10.434727086962994,8.526633932683126,5.509135247188169,0.0692527749868838,-0.02355200000000046,24.315822490900985,59.15796117987399,-1.5385283264769782,47.540581616883,-17.416069344486502,-0.543272913037006,-0.4593660673168749,0.442135247188169,0.0133027749868838]

if __name__ == "__main__":
    from pypospack.pyposmat import PyposmatDataFile
    obj_datafile = PyposmatDataFile(filename=pypospack_data_filename)
    obj_datafile.read()
    obj_datafile.qoi_references = OrderedDict()
    obj_datafile.qoi_references['DFT'] = copy.deepcopy(qoi_reference_dft)
    obj_datafile.score_by_d_metric()
    obj_datafile.subselect_by_score(score_name='d_metric')
    sub_filename = obj_datafile.write_subselect()

    obj_datafile = PyposmatDataFile(filename=sub_filename)
    obj_datafile.read()
    obj_datafile.score_by_sum_if_less_than_median()
    score_best = np.max(obj_datafile.df['sum_b_lt_median'])
    idx_best = np.where(obj_datafile.df['sum_b_lt_median'] >= score_best-1)[0]
    idx_best = idx_best.tolist()
    obj_datafile.sub_df = obj_datafile.df.loc[idx_best,:]
    sub_filename = obj_datafile.write_subselect()
Esempio n. 6
0
        with open(_fname_out, 'w') as f:
            f.write(" ".join(_labels) + "\n")
            for T in _temperatures:
                _line = ' '.join([str(row) for row in _th_exp_curve])
                f.write(_line + "\n")

        self.thermal_expansion_curve = np.array(_th_exp_curve)
        return _th_exp_curve


from pypospack.pyposmat import PyposmatDataFile

pyposmat_data_filename = os.path.join(
    'test_WorkflowLammpsThermalExpansion',
    'subselect.d_metric.sum_b_lt_median.out')
datafile = PyposmatDataFile(filename=pyposmat_data_filename)
datafile.read()
best_median_id = int(
    datafile.df.loc[datafile.df['sum_b_lt_median'].idxmax(axis=1), 'sim_id'])
best_median_name = 'param_{}'.format(best_median_id)
best_dmetric_id = int(datafile.df.loc[datafile.df['d_metric'].idxmin(axis=1),
                                      'sim_id'])
best_dmetric_name = 'param_{}'.format(best_dmetric_id)
workflow_directories = ['MgO_LC', 'MgO_BG1', 'MgO_BG2']
workflow_directories += [v for v in os.listdir() if v.startswith('param_')]
workflow_data = OrderedDict()
for wfd in workflow_directories:
    workflow_data[wfd] = WorkflowLammpsThermalExpansionData(
        workflow_directory=wfd)
    workflow_data[wfd].read_data()
    workflow_data[wfd].calculate_thermal_expansion_curve(N=200)