Esempio n. 1
0
def get_box_from_system(item, structure_indices='all', check=True):

    if check:

        _digest_item(item, _form)
        structure_indices = _digest_structure_indices(structure_indices)

    from molsysmt._private.math import serie_to_chunks

    if structure_indices is 'all':

        n_structures = get_n_structures_from_system(item)
        structure_indices = np.arange(n_structures)

    starts_serie_frames, size_serie_frames = serie_to_chunks(structure_indices)

    box_list = []

    for start, size in zip(starts_serie_frames, size_serie_frames):
        item.seek(start)
        _, _, _, box = item.read(n_frames=size)
        box_list.append(box)

    box = np.concatenate(box_list)
    del (box_list)

    box = box.astype('float64')

    box = box * _puw.unit(item.distance_unit)
    box = _puw.standardize(box)

    return box
Esempio n. 2
0
def get_step_from_system(item, structure_indices='all', check=True):

    if check:

        _digest_item(item, _form)
        structure_indices = _digest_structure_indices(structure_indices)

    from molsysmt._private.math import serie_to_chunks

    if structure_indices is 'all':

        n_structures = get_n_structures_from_system(item)
        structure_indices = _np.arange(n_structures)

    starts_serie_frames, size_serie_frames = serie_to_chunks(structure_indices)

    step_list = []

    for start, size in zip(starts_serie_frames, size_serie_frames):
        item.seek(start)
        _, _, step, _ = item.read(n_frames=size)
        step_list.append(step)

    step = _np.concatenate(step_list)
    del (step_list)

    step = step.astype('int64')

    return step
Esempio n. 3
0
def get_time_from_system(item, structure_indices='all', check=True):

    if check:

        _digest_item(item, _form)
        structure_indices = _digest_structure_indices(structure_indices)

    from molsysmt._private.math import serie_to_chunks

    if structure_indices is 'all':

        n_structures = get_n_structures_from_system(item)
        structure_indices = np.arange(n_structures)

    starts_serie_frames, size_serie_frames = serie_to_chunks(structure_indices)

    time_list = []

    for start, size in zip(starts_serie_frames, size_serie_frames):
        item.seek(start)
        _, time, _, _ = item.read(n_frames=size)
        time_list.append(time)

    time = _np.concatenate(time_list)
    del (time_list)

    time = time.astype('float64')

    time = time * _puw.unit('ps')
    time = _puw.standardize(time)

    return time
Esempio n. 4
0
def get_box_from_system(item, structure_indices='all', check=True):

    if check:

        _digest_item(item, _form)
        structure_indices = _digest_structure_indices(structure_indices)

    from molsysmt._private.math import serie_to_chunks
    from molsysmt.pbc import box_vectors_from_box_lengths_and_angles

    if structure_indices is 'all':
        structure_indices = _np.arange(get_n_structures_from_system(item))

    starts_serie_frames, size_serie_frames = serie_to_chunks(structure_indices)

    box_list = []

    for start, size in zip(starts_serie_frames, size_serie_frames):
        item.seek(start)
        frame_hdf5 = item.read(n_frames=size)
        cell_lengths = frame_hdf5.cell_lengths
        cell_angles = frame_hdf5.cell_angles
        box = box_vectors_from_box_lengths_and_angles(
            cell_lengths * _puw.unit('nm'), cell_angles * _puw.unit('degrees'))
        box_list.append(_puw.get_value(box))

    box = _np.concatenate(box_list)
    del (box_list)

    box = box.astype('float64')

    box = box * _puw.unit('nm')
    box = _puw.standardize(box)

    return box
def load_frame(item, atom_indices='all', structure_indices='all'):

    # It doesn't really work. seek doesn't work. Once the file is read can not be rewinded.

    step = None

    if structure_indices is 'all':

        coordinates, time, box = item.read()

        if atom_indices is not 'all':

            coordinates = coordinates[:, atom_indices, :]

    else:

        from molsysmt._private.math import serie_to_chunks

        starts_serie_frames, size_serie_frames = serie_to_chunks(
            structure_indices)

        coordinates_list = []
        time_list = []
        step_list = []
        box_list = []

        for start, size in zip(starts_serie_frames, size_serie_frames):
            item.seek(start)
            coordinates, time, box = item.read(n_structures=size,
                                               atom_indices=atom_indices)
            coordinates_list.append(coordinates)
            time_list.append(time)
            step_list.append(step)
            box_list.append(box)

        coordinates = np.concatenate(coordinates_list)
        time = np.concatenate(time_list)
        box = np.concatenate(box_list)
        del (coordinates_list, time_list, box_list)

    if len(box) == 0:
        box = None
    else:
        box = box * unit.nanometer
    if len(time) == 0:
        time = None
    else:
        time = time * unit.picoseconds
    coordinates = coordinates * unit.nanometer

    return step, time, coordinates, box
Esempio n. 6
0
def get_coordinates_from_atom(item,
                              indices='all',
                              structure_indices='all',
                              check=True):

    if check:

        _digest_item(item, _form)
        indices = _digest_indices(indices)
        structure_indices = _digest_structure_indices(structure_indices)

    from molsysmt._private.math import serie_to_chunks

    if structure_indices is 'all':

        n_structures = get_n_structures_from_system(item)
        structure_indices = _np.arange(n_structures)

    starts_serie_frames, size_serie_frames = serie_to_chunks(structure_indices)

    xyz_list = []

    for start, size in zip(starts_serie_frames, size_serie_frames):
        item.seek(start)
        if indices is 'all':
            xyz, _, _, _ = item.read(n_structures=size)
        else:
            xyz, _, _, _ = item.read(n_structures=size, atom_indices=indices)
        xyz_list.append(xyz)

    xyz = _np.concatenate(xyz_list)
    del (xyz_list)

    xyz = xyz.astype('float64')

    xyz = xyz * _puw.unit(item.distance_unit)
    xyz = _puw.standardize(xyz)

    return xyz