def tests():
    # Currently assume some relative path stuff. This is apt to change once we
    # make this into a module.
    sys.path.insert(0, "..")  # Make this the first thing since we want to override
    from XYZ import XYZ  # XYZ class
    from reax_connection_table import Connection_Table

    # Test files location:
    structure_file = "tests/a10a_ph7.xyz"
    connection_table_file = "tests/a10a_ph7.connect"

    # Read in XYZ file. Store all the coordinates.
    simulation_atoms = XYZ()
    simulation_atoms.load(structure_file)  # simulation_atoms.rows contains the data
    print "Structure file loaded successfully: " + structure_file

    # Read in connection table (ReaxFF fort.7 style, see ReaxFF manual for more info)
    connection_table = Connection_Table()
    connection_table.load(connection_table_file)
    connection_table.next()
    print "Connection table file loaded successfully: " + connection_table_file

    molecule_helper = Molecule_Helper()
    molecule_helper.simulation_atoms_class = simulation_atoms
    molecule_helper.connection_table_class = connection_table
    molecule_helper.bondorder_cutoff = 0.6

    assert molecule_helper.atom_label_list_to_formula(["H", "O", "H"]) == "H2O"
    # print molecule_helper.atom_label_list_to_formula(['H', 'O', 'H'])
    assert molecule_helper.atom_label_list_to_formula(["H"]) == "H"
    assert molecule_helper.atom_label_list_to_formula(["H", "H", "Ti", "O", "Ti", "P"]) == "H2OPTi2"

    all_molecules = molecule_helper.get_all_molecules()
    # We compare this to molfra.out file generated by ReaxFF with bond order
    # cutoff of 0.6
    assert molecule_helper.molecule_list_to_frequency_dict(all_molecules) == {
        "HO20Ti10": 1,
        "H2O81Ti40": 1,
        "H3O41Ti20": 1,
        "H2O": 149,
        "O20Ti10": 6,
        "HO": 1,
        "H2O40Ti20": 1,
        "HO21Ti10": 3,
    }

    print "All tests completed successfully!"
    sys.exit(0)
Beispiel #2
0
def tests():
    #Currently assume some relative path stuff. This is apt to change once we
    #make this into a module.
    sys.path.insert(0, "..") #Make this the first thing since we want to override
    from XYZ import XYZ #XYZ class
    from reax_connection_table import Connection_Table
   
    #Test files location:
    structure_file = 'tests/a10a_ph7.xyz'
    connection_table_file = 'tests/a10a_ph7.connect'

    #Read in XYZ file. Store all the coordinates.
    simulation_atoms = XYZ()
    simulation_atoms.load(structure_file) #simulation_atoms.rows contains the data
    print 'Structure file loaded successfully: '+structure_file
    
    #Read in connection table (ReaxFF fort.7 style, see ReaxFF manual for more info)
    connection_table = Connection_Table()
    connection_table.load(connection_table_file)
    connection_table.next()
    print 'Connection table file loaded successfully: '+connection_table_file

    molecule_helper = Molecule_Helper()
    molecule_helper.simulation_atoms_class = simulation_atoms
    molecule_helper.connection_table_class = connection_table
    molecule_helper.bondorder_cutoff = 0.6

    assert molecule_helper.atom_label_list_to_formula(['H', 'O', 'H']) == 'H2O'
    #print molecule_helper.atom_label_list_to_formula(['H', 'O', 'H'])
    assert molecule_helper.atom_label_list_to_formula(['H']) == 'H'
    assert molecule_helper.atom_label_list_to_formula(['H', 'H', 'Ti', 'O', 'Ti', 'P']) == 'H2OPTi2'

    all_molecules = molecule_helper.get_all_molecules()
    #We compare this to molfra.out file generated by ReaxFF with bond order
    #cutoff of 0.6
    assert molecule_helper.molecule_list_to_frequency_dict(all_molecules) == \
        {'HO20Ti10': 1, 'H2O81Ti40': 1, 'H3O41Ti20': 1, 'H2O': 149, 'O20Ti10': 6, 'HO': 1, 'H2O40Ti20': 1, 'HO21Ti10': 3}
    
    print 'All tests completed successfully!'
    sys.exit(0)