Example #1
0
def load_data(u_conf: dict, stepsize=0) ->  (int, int, np.array, list):
    '''
    Loads the data from the file specified in u_conf and returns the parameters of the
    simulation as (N_conf, N_ion, lattice vectors, list of configurations)
    '''
    if stepsize == 0:
        stepsize = int(input("Stepsize for prediction? (integer): -> "))

    # load parser and save nr of ions and lattice vectors
    parser = Parser(u_conf['file_in'])
    lattice_vectors = parser.find_lattice_vectors()
    lat_consts = np.diag(lattice_vectors.dot(lattice_vectors.T))

    # check if lattice constant is bigger than 2 rcut
    if any(np.greater(2 * u_conf["cutoff"], lat_consts)):
        raise ValueError('Cutoff cannot be bigger than half the lattice constants')

    # build the configurations from the parser
    configurations = [
        Configuration(position, energy, forces) for (energy, position, forces) in parser
        .build_configurations(stepsize)
    ]

    return (len(configurations), parser.find_ion_nr(), lattice_vectors, configurations)
Example #2
0
 def test_ion_nrs(self):
     test_in = 'OUTCAR.21'
     parser = Parser(test_in)
     nr_ions = parser.find_ion_nr()
     self.assertIsInstance(nr_ions, int, 'ions should have type int')
     self.assertEqual(nr_ions, 64, f'nr of ions should be 64, is {nr_ions}')