예제 #1
0
    def __init__(self, file_name, file_type='xyz'):
        self.struc = struc_linalg.structure(name=file_name[:4])
        self.struc.read_file(file_path=file_name, file_type=file_type)
        self.num_at = self.struc.ret_num_at()

        print
        print "%s read in" % file_name
        print "Number of atoms: %i" % self.num_at
예제 #2
0
    def __init__(self, file_name, file_type='xyz', vib=False):
        self.struc = struc_linalg.structure(name=file_name[:4])
        self.struc.read_file(file_path=file_name, file_type=file_type)
        self.num_at = self.struc.ret_num_at()
        self.file_name = file_name
        self.file_type = file_type

        self.vib = vib
        if self.vib:
            self.freqs = numpy.zeros([3 * self.num_at])
            self.vib_mat = numpy.zeros([3 * self.num_at, 3 * self.num_at])
            self.curr_vib = 0

        print
        print "Template %s read in" % file_name
        print "Number of atoms: %i" % self.num_at
예제 #3
0
    raise

try:
    from matilda import file_handler, struc_linalg, superposition
except:
    print "Error in importing module of this distribution"
    print "check the PYTHONPATH environment variable"
    raise

if __name__ == '__main__':

    ref_file = file_handler.def_input("Template structure file")
    ins_file = file_handler.def_input("File name of the molecule to insert")
    file_type = file_handler.def_input("File type", "xyz")

    ins = struc_linalg.structure(name=ins_file[:4])
    ins.read_file(file_path=ins_file, file_type=file_type)
    num_at = ins.ret_num_at()

    ref = struc_linalg.structure(name=ref_file[:4])
    ref.read_file(file_path=ref_file, file_type=file_type)

    print
    print "Number of atoms to insert: %i" % num_at
    print """
    Enter indices of the atoms in the template structure corresponding to the
    indices of the molecule inserted
    """

    at_list_ref = []
    for iat in xrange(1, num_at + 1):
예제 #4
0
start_file = sys.argv[1]
end_file = sys.argv[2]
out_dir = sys.argv[3]
steps_nr = eval(sys.argv[4])
file_type = sys.argv[5]

try:
    os.makedirs(out_dir)
except OSError:
    print 'Output directory could not be created. It either already exists or you have no writing access.'

# for calculations an instance of this class with a default molecule has to be defined
mc = struc_linalg.mol_calc(def_file_path=start_file, file_type=file_type)

# load the structures
st = struc_linalg.structure(name='st')  # optional name for output
st.read_file(file_path=start_file, file_type=file_type)

en_temp = struc_linalg.structure(name='en_t')
en_temp.read_file(file_path=end_file, file_type=file_type)

# superimpose the structures
en = en_temp.ret_superimposed_structure(struc=st, mass_wt_pw=1, name='en')

# define the vector for the linear interpolation
diff_vect = mc.subtract(en, st)

# create <steps_nr> structures and put them into separate folders
for i in xrange(1, steps_nr + 1):
    x = i * 1. / (steps_nr + 1)
    plus_struc = mc.scalar_mult(x, diff_vect)
예제 #5
0
    elif arg == '-h':
        print 'Usage example: int_coor.py dist 4 5 struc.xyz'
        print 'Supported internal coordinates: dist, bend, tors'
        print 'Arguments: -type (xyz, tmol, mol ...)'
        print '   -dig (number of digits in print out)'
        sys.exit()
    elif arg[0] == '-':
        print 'Unsupported option: ' + arg
        print 'int_coor.py -h for more information'
        sys.exit()
    else:
        files += [arg]

#print coors, files

struc = struc_linalg.structure()
tm = file_handler.table_maker(col_widths=[20] + len(coors) * [5 + digits])
tm.write_line(['File'] + [coor[0] for coor in coors])
for file in files:
    struc.read_file(file_path=file, file_type=file_type)
    out_line = [file]
    for coor in coors:
        if coor[0] == 'dist':
            dist = struc.ret_bond_length(*coor[1:])
            out_line += [locale.format("%.*f", (digits, dist))]
        elif coor[0] == 'bend':
            bend = struc.ret_bend(*coor[1:])
            out_line += [locale.format("%.*f", (digits, bend))]
        elif coor[0] == 'tors':
            tors = struc.ret_tors(*coor[1:])
            out_line += [locale.format("%.*f", (digits, tors))]
예제 #6
0
ref_file = sys.argv[1]
super_files = []  # list with filenames to be superimposed onto ref_struc
for arg in sys.argv[2:]:
    if arg[:4] == '-mwp':
        mass_wt_pw = eval(arg[4:])
    elif arg[:2] == '-t':
        file_type = arg[2:]
    else:
        super_files += [arg]

# for calculations an instance of this class with a default molecule has to be defined
# from it the numbering of the atoms and their masses are taken
mc = struc_linalg.mol_calc(def_file_path=ref_file, file_type=file_type)

# load the structures (DK and MK are random names used for identification)
ref = struc_linalg.structure(name=ref_file[:9])
ref.read_file(file_path=ref_file, file_type=file_type)

strucs = []  #initial structures and superimposed structures
for i, super_file in enumerate(super_files):
    strucs += [struc_linalg.structure(name=super_file[:9])]
    strucs[-1].read_file(file_path=super_file, file_type=file_type)
    # superimpose the structures
    strucs += [
        strucs[-1].ret_superimposed_structure(struc=ref,
                                              mass_wt_pw=mass_wt_pw,
                                              name=super_file[:2] + '_X')
    ]
    strucs[-1].make_coord_file('SI_' + super_file, file_type=file_type)

# to follow the effect of the superposition, a matrix with the distances can be printed out
예제 #7
0
digits = 4

files = []
for arg in sys.argv[1:]:
    if arg[:4] == '-mwp':
        mass_wt_pw = eval(arg[4:])
    elif arg[:2] == '-t':
        file_type = arg[2:]
    elif arg[:4] == '-fit':
        fitting = arg[4:]
    elif arg[:4] == '-dig':
        digits = int(arg[4:])
    else:
        files += [arg]

struc0 = struc_linalg.structure(name=files[0][:4])
struc0.read_file(file_path=files[0], file_type=file_type)
out_strucs = [struc0]

for i, file in enumerate(files[1:]):
    struc = struc_linalg.structure(name=file[:digits + 3])
    struc.read_file(file_path=file, file_type=file_type)
    # superimpose the structures
    if fitting == 1:
        print '- Superimposing the structures'
        out_strucs += [
            struc.ret_superimposed_structure(struc0, mass_wt_pw=mass_wt_pw)
        ]
    else:
        out_strucs += [struc]
예제 #8
0
    print 'At least 5 arguments required.'
    print 'Syntax: python add_normal_mode.py <in_struc> <out_struc> <vib_file> <nm_ind> <disp> [<type>]'
    sys.exit()

# read in data
in_file = sys.argv[1]
out_file = sys.argv[2]
vib_file = sys.argv[3]
nm_ind = eval(sys.argv[4])
disp = eval(sys.argv[5])  # displacement
try:
    file_type = sys.argv[6]
except IndexError:
    file_type = 'xyz'

in_struc = struc_linalg.structure()
in_struc.read_file(file_path=in_file, file_type=file_type)

vmol = vib_molden.vib_molden()
vmol.read_molden_file(vib_file)

#print  in_struc.ret_vector()
#print  disp
#print  vmol.vibs[nm_ind - 1].ret_joined_vector()
# it is not -ttmol !
new_vec = in_struc.ret_vector() + disp * vmol.vibs[nm_ind -
                                                   1].ret_joined_vector()

out_struc = struc_linalg.structure()
out_struc.read_file_vector(def_file_path=in_file,
                           file_type=file_type,