def test__evaluate_parameter_set(): engine = PyposmatEngine(filename_in=config_fn, filename_out='pyposmat.config.out') engine.configure() results = engine.evaluate_parameter_set(parameters=parameters) assert 'parameters' in results assert 'qois' in results assert type(results['parameters']) is OrderedDict assert type(results['qois']) is OrderedDict assert all([v is not None for k, v in results['parameters'].items()]) assert all([v is not None for k, v in results['qois'].items()])
from pypospack.pyposmat.engines import PyposmatEngine from pypospack.pyposmat.data import PyposmatDataFile from pypospack.pyposmat.data import PyposmatConfigurationFile # from pypospack.qoi import QoiManager # from pypospack.task import TaskManager filename_config = 'pypospack.config.in' write_configuration_file( filename=filename_config, qois=qoi_db.qois, potential_definition=potential_definition, structures=structures) #Ni_configuration = PyposmatConfigurationFile() #Ni_configuration.qois = Ni_qoi_db.qois #Ni_configuration.potential = potential_definition #Ni_configuration.structures = Ni_structures #Ni_configuration.write(filename='pypospack.config.in') #Ni_configuration.read(filename='pypospack.config.in') engine = PyposmatEngine( filename_in = 'pypospack.config.in', filename_out = 'pypospack.config.out') engine.configure() _parameters = potential_parameters results = engine.evaluate_parameter_set(parameters=_parameters) print(results)
from pypospack.exceptions import LammpsSimulationError filename_in = "pypospack.config.in" filename_out = "pypospack.results.out" a0 = 3.52 r0 = 1 / (2**0.5) * a0 parameters = OrderedDict() parameters['p_NiNi_phi0'] = 1.0 parameters['p_NiNi_gamma'] = 2.0 parameters['p_NiNi_r0'] = r0 parameters['d_Ni_rho0'] = 1.0 parameters['d_Ni_beta'] = 4.0 parameters['d_Ni_r0'] = r0 parameters['e_Ni_latticetype'] = 'fcc' parameters['e_Ni_ecoh'] = -4.45 parameters['e_Ni_B'] = 188. parameters['e_Ni_a0'] = a0 if __name__ == "__main__": engine = PyposmatEngine(filename_in=filename_in, filename_out=filename_out) engine.read_configuration_file( filename=os.path.join('data', 'pyposmat.config.in')) engine.configure_qoi_manager() engine.configure_task_manager() try: engine.evaluate_parameter_set(parameters=parameters) except LammpsSimulationError as e: print('lammps_simulation_error')
('SiSiSi_a', 1.927303534824485), ('SiSiSi_lambda', 12.109230909182934), ('SiSiSi_gamma', 2.242334213331301), ('SiSiSi_costheta0', -0.3333333333333333), ('SiSiSi_A', 19.19755654803364), ('SiSiSi_B', 0.16452955359488666), ('SiSiSi_p', 4.313046208558489), ('SiSiSi_q', 0.7433313641477534), ('SiSiSi_tol', 0.0)]) def cleanup(testing_set): import shutil if os.path.exists(testing_set['base_directory']): if os.path.isdir(testing_set['base_directory']): shutil.rmtree(testing_set['base_directory']) elif os.path.isfile(testing_set['base_directory']): os.remove(testing_set['base_directory']) else: raise ValueError('path:{}'.format(testing_set['base_directory'])) if __name__ == "__main__": cleanup(testing_set) o = PyposmatEngine(filename_in=testing_set['config_fn'], base_directory=testing_set['base_directory']) o.configure() o.evaluate_parameter_set(parameters=testing_set['parameters'])
def test__evaluate_parameter_set(): engine = PyposmatEngine(filename_in=config_fn, filename_out='pyposmat.config.out') engine.configure() results = engine.evaluate_parameter_set(parameters=parameters) cleanup_simulation_directories()