def print_boundary_type(axis, plane, theta): if (plane == axis * sum(plane) / sum(axis)).all(): bt = "twist" elif inner(plane, axis) == 0: R = rodrigues(axis, theta, verbose=False) p2 = dot(linalg.inv(R), plane) plane2 = csl.scale_to_integers(p2) bt = "tilt (%i %i %i) (%i %i %i)" % (tuple(plane) + tuple(plane2)) else: bt = "mixed" return bt
def parse_args(): if len(sys.argv) < 7: print usage sys.exit() opts = BicrystalOptions() opts.axis = csl.parse_miller(sys.argv[1]) print "-------> rotation axis: [%i %i %i]" % tuple(opts.axis) opts.parse_sigma_and_find_theta(sys.argv[3]) plane = sys.argv[2] if plane == "twist": opts.plane = opts.axis.copy() elif plane.startswith("m"): m_plane = csl.parse_miller(plane[1:]) if inner(m_plane, opts.axis) != 0: raise ValueError("Axis must be contained in median plane.") R = rodrigues(opts.axis, opts.theta / 2., verbose=False) plane_ = dot(R, m_plane) opts.plane = csl.scale_to_integers(plane_) else: opts.plane = csl.parse_miller(plane) print "-------> boundary plane: (%i %i %i)" % tuple(opts.plane) bt = print_boundary_type(opts.axis, opts.plane, opts.theta) print " boundary type:", bt opts.req_dim = [float(eval(i, math.__dict__)) for i in sys.argv[4:7]] options = sys.argv[7:-1] for i in options: if i == "nofit": assert opts.fit is None opts.fit = False if i == "nozfit": assert opts.zfit is None opts.zfit = False elif i == "mono1": assert opts.mono1 is None opts.mono1 = True elif i == "mono2": assert opts.mono2 is None opts.mono2 = True elif i == "all": assert opts.all is None and opts.allall is None opts.all = True elif i == "allall": assert opts.allall is None and opts.all is None opts.allall = True elif i.startswith("remove:"): assert opts.remove_dist is None opts.remove_dist = float(i[7:]) elif i.startswith("remove2:"): assert opts.remove_dist2 is None opts.remove_dist2 = float(i[8:]) elif i.startswith("vacuum:"): assert opts.vacuum is None opts.vacuum = float(i[7:]) * 10. #nm -> A elif i.startswith("lattice:"): opts.lattice_name = i[8:] elif i.startswith("shift:"): s = i[6:].split(",") if len(s) != 3: raise ValueError("Wrong format of shift parameter") opts.lattice_shift = [float(i) for i in s] elif i.startswith("edge:"): try: z1, z2 = i[5:].split(",") opts.edge = (float(z1), float(z2)) except (TypeError, ValueError): raise ValueError("Wrong format of edge parameter") else: raise ValueError("Unknown option: %s" % i) # default values if opts.fit is None: opts.fit = True if opts.zfit is None: opts.zfit = True if opts.mono1 is None: opts.mono1 = False if opts.mono2 is None: opts.mono2 = False #if opts.remove_dist is None: # opts.remove_dist = 0.8 * opts.atom_min_dist opts.output_filename = sys.argv[-1] return opts