def test_score_uio(): harmonic, equivalencies = get_harmonic('uio66_ff') mapping = Mapping(harmonic.atoms.get_masses(), equivalencies) # contains reference values on the number of reductions as a function of # the maximum number of equivalent clusters to be considered cutoff = 4 tol = 1e-1 reductions = generate_reductions( mapping, harmonic, cutoff=cutoff, tol=tol, max_num_equiv_clusters=6, ) reduction = reductions[0] reduction.apply(mapping) masses = np.repeat(harmonic.atoms.get_masses(), 3) mass_matrix = 1 / np.sqrt(np.outer(masses, masses)) hessian_mw = mass_matrix * harmonic.hessian smap = score(mapping, hessian_mw=hessian_mw, temperature=300) smap_ = score(mapping, harmonic=harmonic, temperature=300) assert smap == smap_ assert smap > 0 # construct mapping that groups all atoms into same bead clusters = np.zeros((mapping.natoms, mapping.natoms), dtype=np.int32) clusters[0, :] = 1 mapping.update_clusters(clusters) mapping.update_identities() entropy = score(mapping, harmonic=harmonic, temperature=300) print(entropy)
def test_generate_uio(): harmonic, equivalencies = get_harmonic('uio66_ff') mapping = Mapping(harmonic.atoms.get_masses(), equivalencies) cutoff = 3.0 tol = 1e-1 environments, radii = generate_environments(mapping, harmonic, cutoff, tol) # check whether each cluster receives precisely one environment _all = [] for _, envs in environments.items(): for env in envs: _all.append(env.indices[0]) # get index of central atom assert np.allclose(np.sort(np.array(_all)), np.arange(mapping.nclusters)) # verify that envs of the same cluster_type are 'equal' # verify that each env generates the same number of templates for cluster_type, envs in environments.items(): reference = envs[0] templates = reference.generate_templates() n = len(templates) for env in envs: assert reference.equals(env, tol) assert len(env.generate_templates()) == n # discard those which cannot be matched uniquely i = 0 while i < len(templates): if len(reference.match_template(templates[i], tol)) > 1: templates.pop(i) else: i += 1 for env in envs: for template in templates: assert len(env.match_template(template, tol)) == 1
def test_uio(): harmonic, equivalencies = get_harmonic('uio66_ff') mapping = Mapping(harmonic.atoms.get_masses(), equivalencies) #write('test.xyz', harmonic.atoms) # contains reference values on the number of reductions as a function of # the maximum number of equivalent clusters to be considered cutoff = 4 tol = 1e-1 reductions = generate_reductions( mapping, harmonic, cutoff=cutoff, tol=tol, max_num_equiv_clusters=1, ) assert len(reductions) == 10 reductions = generate_reductions( mapping, harmonic, cutoff=cutoff, tol=tol, max_num_equiv_clusters=2, ) assert len(reductions) == 18 reductions = generate_reductions( mapping, harmonic, cutoff=cutoff, tol=tol, max_num_equiv_clusters=3, ) assert len(reductions) == 21 reductions = generate_reductions( mapping, harmonic, cutoff=cutoff, tol=tol, max_num_equiv_clusters=4, ) assert len(reductions) == 24 reductions = generate_reductions( mapping, harmonic, cutoff=cutoff, tol=tol, max_num_equiv_clusters=5, ) assert len(reductions) == 24 reductions = generate_reductions( mapping, harmonic, cutoff=cutoff, tol=tol, max_num_equiv_clusters=6, ) assert len(reductions) == 27
def test_frequencies(): name = 'uio66_ff' harmonic, _ = get_harmonic(name) frequencies, _ = harmonic.compute_eigenmodes() entropy, _ = get_entropy(frequencies, 300) assert np.isclose(np.sum(entropy), 5.328, atol=1e-3) # reference value # check whether largest frequencies are below 4000 and above 3800 cm^-1 frequencies_invcm = frequencies * ase.units.s / (ase.units._c * 100) assert np.all(frequencies_invcm[3:] < 4e3) assert np.any(frequencies_invcm[3:] > 3.8e3)
def test_write_load(tmp_path): harmonic, equivalencies = get_harmonic('uio66_ff') mapping = Mapping(harmonic.atoms.get_masses(), equivalencies) clusters = Mapping.merge( mapping.clusters, [(0, 1, 2, 5), (4, 8, 33, 6, 100)], ) mapping.update_clusters(clusters) mapping.update_identities(validate=True) path_npz = tmp_path / 'mapping.npz' mapping.write(path_npz) loaded = Mapping.load(path_npz) assert np.allclose(loaded.masses, mapping.masses) for i in range(mapping.natoms): assert loaded.atom_types[i] == mapping.atom_types[i] assert np.allclose(loaded.clusters, mapping.clusters)
def test_algorithm_uio(): harmonic, equivalencies = get_harmonic('uio66_ff') mapping = Mapping(harmonic.atoms.get_masses(), equivalencies) min_neighbors = 3 max_num_equiv_clusters = 6 temperature = 300 algorithm = Algorithm( harmonic, mapping, temperature, min_neighbors, max_num_equiv_clusters, ) cutoff = 4 tol = 1e-1 threshold = 450 # performs only one reduction step algorithm.run(threshold, cutoff, tol)
def test_init(): name = 'uio66_ff' harmonic, _ = get_harmonic(name) assert harmonic.periodic