def hcp_edge_dislocation(self): sz = (40, 40, 10) atoms = othoHCP(latticeconstant=(self.pot['ahcp'], self.pot['chcp'], self.pot['ahcp'] * sqrt(3.)), size=sz, symbol=self.pot['element']) # let the axes consistent with the elastic constants axes = np.array([[1, 0, 0], [0, 0, 1], [0, -1, 0]]) burgers = self.pot['lattice'] * np.array([1, 0, 0]) c = am.ElasticConstants() # the lattice constant has conventional direction as # x - [1 -2 1 0] y[1, 0, -1, 0] z [0, 0, 0, 1] c.hexagonal(C11=61.8, C33=67.5, C12=25.9, C13=21.9, C44=18.2) # kim stroh = stroh_solve.Stroh(c, burgers, axes=axes) pos = atoms.get_positions() cx = 20 * self.pot["ahcp"] + 0.01 cy = 20 * self.pot["chcp"] + 0.01 s1 = np.ones(pos.shape) * np.array([cx, cy, 0.0]) d1 = stroh.displacement(pos - s1) # cy = 60 * self.pot["chcp"] - 0.01 # s2 = np.ones(pos.shape) * np.array([cx, cy, 0.0]) # d2 = stroh.displacement(pos - s2) atoms.set_positions(pos + np.real(d1)) # cut a layer normal the burger direction # atoms = self.cut_x_normal_atoms(atoms, lata, 1, sqrt(3) / 4.0) # atoms = self.cut_x_normal_atoms(atoms) atoms = self.cut_y_normal_atoms(atoms) atoms = self.cut_x_normal_atoms(atoms) self.write_lmp_config_data(atoms)
def build_screw_basal_hcp_atoms(self, atoms): axes = np.array([[0, 1, 0], [0, 0, 1], [1, 0, 0]]) burgers = self.pot['lattice'] * np.array([1, 0, 0]) c = am.ElasticConstants() # the lattice constant has conventional direction as # x - [1 -2 1 0] y[1, 0, -1, 0] z [0, 0, 0, 1] # c.hexagonal(C11=61.8, C33=67.5, C12=25.9, C13=21.9, C44=18.2) # kim c.hexagonal(C11=64.3218889159844, C33=70.9452244231304, C12=25.4175328222502, C13=20.306421440903, C44=18.0690056385527) # curtin stroh = stroh_solve.Stroh(c, burgers, axes=axes) cell = atoms.get_cell() cx = 0.25 * cell[0, 0] + 0.01 cy = 0.50 * cell[1, 1] + 0.01 pos = atoms.get_positions() shift = np.ones(pos.shape) * np.array([cx, cy, 0.0]) disp = stroh.displacement(pos - shift) atoms.set_positions(pos + np.real(disp)) # pos = atoms.get_positions() # shiftN = np.ones(pos.shape) * np.array([cx + 0.5 * cell[0, 0], # cy, 0.0]) # dispN = stroh.displacement(pos - shiftN) # atoms.set_positions(pos + np.real(dispN)) return atoms
def build_screw_basal_hcp_atoms_dipole(self, atoms): axes = np.array([[0, 1, 0], [0, 0, 1], [1, 0, 0]]) burgers = self.pot['lattice'] * np.array([1, 0, 0]) c = am.ElasticConstants() c.hexagonal(C11=64.3218889159844, C33=70.9452244231304, C12=25.4175328222502, C13=20.306421440903, C44=18.0690056385527) # curtin stroh1 = stroh_solve.Stroh(c, burgers, axes=axes) # stroh2 = stroh_solve.Stroh(c, -burgers, axes=axes) cell = atoms.get_cell() pos = atoms.get_positions() cx = 0.25 * cell[0, 0] + 0.01 cy1 = 0.25 * cell[1, 1] + 0.01 cy2 = 0.75 * cell[1, 1] + 0.01 pos = atoms.get_positions() print(cy1, cy2) shift1 = np.ones(pos.shape) * np.array([cx, cy1, 0.0]) shift2 = np.ones(pos.shape) * np.array([cx, cy2, 0.0]) disp1 = stroh1.displacement(pos - shift1) disp2 = stroh1.displacement(pos - shift2) # atoms.set_positions(pos + np.real(disp1)) atoms.set_positions(pos + np.real(disp1) - np.real(disp2)) return atoms
def intro_edge(self): self.find_angles_1100(il=[[1], [1]], jl=[1]) # 58.361 ux = self.pot['ahcp'] uy = self.pot['chcp'] uz = self.pot['ahcp'] * sqrt(3.) atoms = ase.io.read("dump/dump.00017", format='lammps-dump') atoms.rotate(self.ag[0][0], 'z') # rotate atoms.translate(np.array([80 * ux, 0.0, 0])) # # introduce dislocation axes = np.array([[1, 0, 0], [0, 0, 1], [0, -1, 0]]) burgers = self.pot['lattice'] * np.array([1, 0, 0]) c = am.ElasticConstants() c.hexagonal(C11=self.pot['C11'], C12=self.pot['C12'], C33=self.pot['C33'], C13=self.pot['C13'], C44=self.pot['C44']) stroh = stroh_solve.Stroh(c, burgers, axes=axes) pos = atoms.get_positions() cx = 60 * ux + 0.01 cy = 60 * uy + 0.01 shift = np.ones(pos.shape) * np.array([cx, cy, 0.0]) disp = stroh.displacement(pos - shift) atoms.set_positions(pos + np.real(disp)) atoms.translate(np.array([-80 * ux, 0.0, 0])) atoms.rotate(-self.ag[0][0], 'z') # rotate back # try with non periodict boundary conditions cell = atoms.get_cell() cell[0, 0] += 30 cell[1, 1] += 30 atoms.translate(np.array([15, 15, 0.0])) atoms.set_cell(cell) # ase.io.write("pos02", images=atoms, format='cfg') self.write_lmp_config_data(atoms, "pos02")
def aniso_211(self): c = tool_elastic_constants.elastic_constants(C11=self.pot['c11'], C12=self.pot['c12'], C44=self.pot['c44']) e1 = [1, 0, 0] e2 = [0, 1, -1] e3 = [0, 1, 1] # axes = np.array([e2, e1, e3]) axes = np.array([e1, e2, e3]) burgers = self.pot["lattice"] / 2. * np.array([1., 1., -1.]) burgers = axes_check.axes_check(axes).dot(burgers) stroh = stroh_solve.Stroh(c, burgers, axes=axes) A = np.mat(np.zeros([3, 3]), dtype='complex') A[:, 0] = np.mat(stroh.A[0]).transpose() A[:, 1] = np.mat(stroh.A[2]).transpose() A[:, 2] = np.mat(stroh.A[4]).transpose() B = np.mat(np.zeros([3, 3]), dtype='complex') B[:, 0] = np.mat(stroh.L[0]).transpose() B[:, 1] = np.mat(stroh.L[2]).transpose() B[:, 2] = np.mat(stroh.L[4]).transpose() Linv = np.real(np.complex(0, 1) * A * np.linalg.inv(B)) Gamma = 0.5 * Linv self.ckcoeff.K1 = sqrt(2 * self.pot["surf110"] / abs(Gamma[1, 1] * 1e3)) # theta = np.deg2rad(54.735610317245346) theta = np.deg2rad(35.2643896828) omega = np.mat([[cos(theta), sin(theta), 0.0], [-sin(theta), cos(theta), 0.0], [0.0, 0.0, 1.0]]) Gamma = omega * Gamma * omega.transpose() # Gamma = np.abs(np.linalg.inv(Gamma)) Gamma = Gamma * 1e9 # Pa print(self.ckcoeff.K1) if axes is not None: burgers = axes_check.axes_check(axes).dot(burgers) c = c.transform(axes) G00 = Gamma[0, 0] usf = 0.57405172613 k1e = np.sqrt(G00 * usf) * 1e-6 print(Gamma) print(self.ckcoeff.K1, k1e) self.set_plane_strain_bij(c.Sij) # self.get_scalarB(self.pot["surf110"]) get the same k1c self.get_coeffs() atoms = self.intro_crack_k1(atoms=self.gn_perf_plate()) self.write_lmp_config_data(atoms, 'crack.txt')
def bcc_screw_dipole_alongz_atoms(self, atoms, c1, c2): c = tool_elastic_constants.elastic_constants(C11=self.pot['c11'], C12=self.pot['c12'], C44=self.pot['c44']) burgers = self.pot['lattice'] / 2 * np.array([1., 1., 1.]) stroh = stroh_solve.Stroh(c, burgers, axes=axes) pos = atoms.get_positions() atoms = self.bcc_screw_dipole_tools(stroh, pos, atoms, c1, 1) atoms = self.bcc_screw_dipole_tools(stroh, pos, atoms, c2, -1) return atoms
def get_bcc_w_result211(self, param): c = tool_elastic_constants.elastic_constants(C11=param['c11'], C12=param['c12'], C44=param['c44']) e1 = [1, 0, 0] e2 = [0, 1, -1] e3 = [0, 1, 1] # glide plane [2, 1, -1] axes = np.array([e1, e2, e3]) # x [1, 0, 0], y[0, 1, -1], z[0, 1, 1] burgers = param['lat'] / 2. * np.array([1., 1., -1.]) stroh = stroh_solve.Stroh(c, burgers, axes=axes) A = np.mat(np.zeros([3, 3]), dtype='complex') A[:, 0] = np.mat(stroh.A[0]).transpose() A[:, 1] = np.mat(stroh.A[2]).transpose() A[:, 2] = np.mat(stroh.A[4]).transpose() B = np.mat(np.zeros([3, 3]), dtype='complex') B[:, 0] = np.mat(stroh.L[0]).transpose() B[:, 1] = np.mat(stroh.L[2]).transpose() B[:, 2] = np.mat(stroh.L[4]).transpose() Linv = np.real(np.complex(0, 1) * A * np.linalg.inv(B)) Gamma = 0.5 * Linv surf = param['surf'] k1c = sqrt(2 * surf / abs(Gamma[1, 1] * 1e3)) theta = np.deg2rad(54.735610317245346) omega = np.mat([[cos(theta), sin(theta), 0.0], [-sin(theta), cos(theta), 0.0], [0.0, 0.0, 1.0]]) Gamma = omega * Gamma * omega.transpose() Gamma = np.abs(np.linalg.inv(Gamma)) Gamma = Gamma * 1e9 # Pa # K1c # G11 = Gamma[1, 1] # k1c = sqrt(2 * surf / G11) * 1e6 # Ke if axes is not None: T = axes_check.axes_check(axes) burgers = T.dot(burgers) c = c.transform(axes) (coeff, Kg) = self.cal_crack(param, c, theta=theta) print(Kg) usf = param['ugsf1'] # J/m^2 G00 = Gamma[0, 0] k1e = np.sqrt(G00 * usf) * 1e-6 k1e = k1e / coeff print(k1e, k1c, Kg, k1e / k1c) return (k1e, k1c, k1e / k1c)
def build_hcp_ase_1100_with_edge(self): self.find_angles_1100(il=[[1], [1]], jl=[1]) # 58.361 ux = self.pot['ahcp'] uy = self.pot['chcp'] uz = self.pot['ahcp'] * sqrt(3.) print(self.ag) atoms = othoHCP(latticeconstant=(ux, uy, uz), size=(80, 80, 2), symbol=self.pot['element']) # introduce dislocation axes = np.array([[1, 0, 0], [0, 0, 1], [0, -1, 0]]) burgers = self.pot['lattice'] * np.array([1, 0, 0]) c = am.ElasticConstants() c.hexagonal(C11=self.pot['C11'], C12=self.pot['C12'], C33=self.pot['C33'], C13=self.pot['C13'], C44=self.pot['C44']) stroh = stroh_solve.Stroh(c, burgers, axes=axes) pos = atoms.get_positions() cell = atoms.get_cell() cell[0, 0], cell[1, 1] = 8 * self.ag[0][1], 300 cx = 30 * ux + 0.01 cy = 30 * uy + 0.01 shift = np.ones(pos.shape) * np.array([cx, cy, 0.0]) disp = stroh.displacement(pos - shift) atoms.set_positions(pos + np.real(disp)) atoms.rotate(self.ag[0][0], 'z') atoms.translate(np.array([cell[0, 0], -100, 0])) lob = np.array([0.0, 10, 0.0]) hib = np.array([cell[0, 0], 0.5 * cell[1, 1] + 0.3, cell[2, 2]]) atoms = self.make_cubic('out', atoms, lob, hib) atoms2 = othoHCP(latticeconstant=(ux, uy, uz), size=(80, 80, 2), symbol=self.pot['element']) lob = np.array([0.0, 0.5 * cell[1, 1], 0.0]) hib = np.array([cell[0, 0], cell[1, 1] - 10, cell[2, 2]]) atoms2.rotate(-self.ag[0][0], 'z') atoms2.translate(np.array([-90, cell[1, 1], 0])) # for 72.877 atoms2 = self.make_cubic('out', atoms2, lob, hib) atoms.extend(atoms2) # try with non periodict boundary conditions atoms.set_cell(cell) self.write_lmp_config_data(atoms, "lmp_init.txt")
def get_cutin_result_mat_k2e(self, param): c = tool_elastic_constants.elastic_constants(C11=param['c11'], C12=param['c12'], C44=param['c44']) # A axes = np.array([[1, 1, 2], [1, 1, -1], [-1, 1, 0]]) burgers = param['lat'] / np.sqrt(6.) * np.array([1., 1., 2.]) stroh = stroh_solve.Stroh(c, burgers, axes=axes) A = np.mat(np.zeros([3, 3]), dtype='complex') A[:, 0] = np.mat(stroh.A[0]).transpose() A[:, 1] = np.mat(stroh.A[2]).transpose() A[:, 2] = np.mat(stroh.A[4]).transpose() B = np.mat(np.zeros([3, 3]), dtype='complex') B[:, 0] = np.mat(stroh.L[0]).transpose() B[:, 1] = np.mat(stroh.L[2]).transpose() B[:, 2] = np.mat(stroh.L[4]).transpose() # print A * B.transpose() + B * A.transpose() Linv = np.real(np.complex(0, 1) * A * np.linalg.inv(B)) Gamma = 0.5 * Linv theta = np.deg2rad(0.0) omega = np.mat([[cos(theta), sin(theta), 0.0], [-sin(theta), cos(theta), 0.0], [0.0, 0.0, 1.0]]) Gamma = np.abs(omega * Gamma * omega) # phi = 0 # svect = np.mat(np.array([cos(phi), 0.0, sin(phi)])) Gamma = np.linalg.inv(Gamma) Gamma00 = Gamma[0, 0] # in GPa Gamma11 = Gamma[1, 1] Gamma00 *= 1e9 Gamma11 *= 1e9 # cal F(theta) soltrace = np.mat([[stroh.p[0], 0.0, 0.0], [0.0, stroh.p[2], 0.0], [0.0, 0.0, stroh.p[4]]], dtype='complex') Fmat1 = soltrace / np.sqrt(np.cos(theta) + soltrace * np.sin(theta)) Fmat1 = np.real(B * Fmat1 * np.linalg.inv(B)) Fmat2 = 1.0 / np.sqrt(np.cos(theta) + soltrace * np.sin(theta)) Fmat2 = np.real(B * Fmat2 * np.linalg.inv(B)) print(Fmat1[0, 1]) # print Gamma k2e = np.sqrt(Gamma00 * param['ugsf']) * 1e-6 # Mpa print('k2e', k2e / abs(Fmat1[0, 1]))
def build_screw_basal_hcp(self): sz = (100, 100, 5) ux = self.pot["ahcp"] * sqrt(3) uy = self.pot["chcp"] uz = self.pot['ahcp'] atoms = othoHCPB(latticeconstant=(ux, uy, uz), size=sz, symbol=self.pot['element']) # let the axes consistent with the elastic constants axes = np.array([[0, 1, 0], [0, 0, 1], [1, 0, 0]]) burgers = self.pot['lattice'] * np.array([1, 0, 0]) c = am.ElasticConstants() # the lattice constant has conventional direction as # x - [1 -2 1 0] y[1, 0, -1, 0] z [0, 0, 0, 1] # c.hexagonal(C11=61.8, C33=67.5, C12=25.9, C13=21.9, C44=18.2) # c.hexagonal(C11=62.807, C33=69.615, C12=25.974, # C13=21.184, C44=17.138) # Kim c.hexagonal(C11=64.3218889159844, C33=70.9452244231304, C12=25.4175328222502, C13=20.306421440903, C44=18.0690056385527) # curtin stroh = stroh_solve.Stroh(c, burgers, axes=axes) pos = atoms.get_positions() cx = 0.5 * sz[0] * ux + 0.01 cy = 0.5 * sz[1] * uy + 0.01 print(cx, cy) self.write_lmp_config_data(atoms, "before.txt") shift = np.ones(pos.shape) * np.array([cx, cy, 0.0]) disp = stroh.displacement(pos - shift) atoms.set_positions(pos + np.real(disp)) self.write_lmp_config_data(atoms) ase.io.write("SCREW.cfg", atoms, format="cfg") return atoms
def bcc_screw_dipole_alongz_with_image(self, atoms, center): # x direction +10.5 unitx, +21 # -10.5 unitx, -21 # y direction +(11 + 1./3.) unity + 22 # -(11 - 1./3.) unity - 22 c = tool_elastic_constants.elastic_constants(C11=self.pot['c11'], C12=self.pot['c12'], C44=self.pot['c44']) burgers = self.pot['lattice'] / 2 * np.array([1., 1., 1.]) stroh = stroh_solve.Stroh(c, burgers, axes=axes) px = 10.5 py = 11 # ydisp = [4 * py, 3 * py + 1. / 3., 2 * py, py + 1. / 3., # 0., -py + 1. / 3., -2 * py, -3 * py + 1. / 3., -4 * py] # xdisp = [-4 * px, -3 * px, -2 * px, -1 * # px, 0.0, px, 2 * px, 3 * px, 4 * px] ydisp = [2 * py, py + 1. / 3., 0., -py + 1. / 3., -2 * py] xdisp = [-2 * px, -1 * px, 0.0, px, 2 * px] pos = atoms.get_positions() ux = np.sqrt(6) / 3. * self.pot['lattice'] uy = np.sqrt(2) / 2. * self.pot['lattice'] sign = 1.0 for dy in ydisp: for dx in xdisp: ctmp = np.array([center[0] + dx * ux, center[1] + dy * uy]) atoms = self.bcc_screw_dipole_tools(stroh, pos, atoms, ctmp, sign) sign *= -1 atoms.wrap(pbc=[1, 1, 1]) return atoms
def build_edge_basal_hcp_atoms(self, atoms, center, sign=1): # let the axes consistent with the elastic constants axes = np.array([[1, 0, 0], [0, 0, 1], [0, -1, 0]]) burgers = self.pot['lattice'] * np.array([1, 0, 0]) * sign c = am.ElasticConstants() print("build edge basial hcp") # x - [1 -2 1 0] y[1, 0, -1, 0] z [0, 0, 0, 1] # c.hexagonal(C11=61.8, C33=67.5, C12=25.9, C13=21.9, C44=18.2) # kim c.hexagonal(C11=64.3218889159844, C33=70.9452244231304, C12=25.4175328222502, C13=20.306421440903, C44=18.0690056385527) # curtin stroh = stroh_solve.Stroh(c, burgers, axes=axes) pos = atoms.get_positions() cx = center[0] + 0.01 cy = center[1] + 0.01 print(cx, cy) shift = np.ones(pos.shape) * np.array([cx, cy, 0.0]) disp = stroh.displacement(pos - shift) atoms.set_positions(pos + np.real(disp)) return atoms
def build_edge_basal_hcp(self): sz = (200, 100, 3) atoms = othoHCP(latticeconstant=(self.pot['ahcp'], self.pot['chcp'], self.pot['ahcp'] * sqrt(3.)), size=sz, symbol=self.pot['element']) # let the axes consistent with the elastic constants axes = np.array([[1, 0, 0], [0, 0, 1], [0, -1, 0]]) burgers = self.pot['lattice'] * np.array([1, 0, 0]) c = am.ElasticConstants() # the lattice constant has conventional direction as # x - [1 -2 1 0] y[1, 0, -1, 0] z [0, 0, 0, 1] # c.hexagonal(C11=61.8, C33=67.5, C12=25.9, C13=21.9, C44=18.2) # kim # c.hexagonal(C11=62.369, C33=67.788, C12=26.252, # C13=22.113, C44=18.274) # Coco # c.hexagonal(C11=62.807, C33=69.615, C12=25.974, # C13=21.184, C44=17.138) # Kim c.hexagonal(C11=64.3556, C33=70.9849, C12=25.460289, C13=20.333408, C44=18.06331) # Curtin stroh = stroh_solve.Stroh(c, burgers, axes=axes) pos = atoms.get_positions() cx = 0.5 * sz[0] * self.pot["ahcp"] + 0.01 cy = 0.5 * sz[1] * self.pot["chcp"] + 0.01 print(cx, cy) shift = np.ones(pos.shape) * np.array([cx, cy, 0.0]) disp = stroh.displacement(pos - shift) atoms.set_positions(pos + np.real(disp)) self.write_lmp_config_data(atoms) return atoms
def formular_make_edge_large(self): self.find_angles_1100(il=[[1], [1]], jl=[1]) # 58.361 ux = self.pot['ahcp'] uy = self.pot['chcp'] uz = self.pot['ahcp'] * np.sqrt(3.) atoms = ase.io.read(glob.glob("dump_init_v2/dump.*")[-1], format='lammps-dump') atoms.rotate(180 - self.ag[0][0], 'z') # rotate atoms.translate(np.array([80 * ux, 0, 0])) axes = np.array([[1, 0, 0], [0, 0, 1], [0, -1, 0]]) burgers = self.pot['lattice'] * np.array([1, 0, 0]) c = am.ElasticConstants() c.hexagonal(C11=self.pot['C11'], C12=self.pot['C12'], C33=self.pot['C33'], C13=self.pot['C13'], C44=self.pot['C44']) stroh = stroh_solve.Stroh(c, burgers, axes=axes) pos = atoms.get_positions() cell = atoms.get_cell() sh1 = np.ones(pos.shape) * \ np.array([-30 * ux + 0.1, 10 * uy, cell[2, 2]]) sh2 = np.ones(pos.shape) * \ np.array([-30 * ux + 0.1, 30 * uy, cell[2, 2]]) d1 = stroh.displacement(pos - sh1) d2 = stroh.displacement(pos - sh2) atoms.set_positions(pos + np.real(d1) - np.real(d2)) atoms.translate(np.array([-80 * ux, 0.0, 0])) atoms.rotate(self.ag[0][0] - 180, 'z') # rotate back self.write_lmp_config_data(atoms, "lmp_init02.txt")
def intro_edge_dipole(self): ux = self.pot['ahcp'] uy = self.pot['chcp'] uz = self.pot['ahcp'] * sqrt(3.) angle = 67.66901744178166 atoms = ase.io.read("dump.save", format='lammps-dump') cell = atoms.get_cell() # before rotate, mark the center upper = cell[1, 1] * 0.5 + 2 lower = cell[1, 1] * 0.5 - 2 left = cell[0, 0] * 0.3 right = cell[0, 0] * 0.3 + 4 for atm in atoms: if (atm.position[1] > lower and atm.position[1] < upper and atm.position[0] >= left and atm.position[0] <= right): print(atm.position) atm.symbol = 'Nb' atoms.rotate(angle, 'z') # rotate shift = cell[1, 1] * np.sin(np.deg2rad(angle)) atoms.translate(np.array([shift, 0.0, 0])) # check line after rotation for atm in atoms: if (atm.symbol == 'Nb'): print(atm.position) dis_core_pos = atm.position axes = np.array([[1, 0, 0], [0, 0, 1], [0, -1, 0]]) burgers = self.pot['lattice'] * np.array([1, 0, 0]) c = am.ElasticConstants() c.hexagonal(C11=self.pot['C11'], C12=self.pot['C12'], C33=self.pot['C33'], C13=self.pot['C13'], C44=self.pot['C44']) stroh = stroh_solve.Stroh(c, burgers, axes=axes) pos = atoms.get_positions() dis_core_pos[2] = 0 sh1 = dis_core_pos sh2 = np.copy(dis_core_pos) sh2[0] = sh2[0] - 80 sh1[1] += 0.01 sh2[1] += 0.01 print(sh1, sh2) sh1 = np.ones(pos.shape) * sh1 sh2 = np.ones(pos.shape) * sh2 org_sh1 = np.ones(pos.shape) * \ np.array([50 * ux + 0.01, 40 * uy + 0.01, 0.0]) org_sh2 = np.ones(pos.shape) * \ np.array([50 * ux + 0.01, 50 * uy + 0.01, 0.0]) # print(sh1, org_sh1) d1 = stroh.displacement(pos - sh1) d2 = stroh.displacement(pos - sh2) atoms.set_positions(pos + np.real(d1) - np.real(d2)) atoms.translate(np.array([-shift, 0.0, 0])) atoms.rotate(-angle, 'z') # rotate back self.write_lmp_config_data(atoms, "lmp_init.txt")
def get_cutin_result_mat_k1e(self, param): c = tool_elastic_constants.elastic_constants(C11=param['c11'], C12=param['c12'], C44=param['c44']) axes = np.array([[-1, -1, 2], [1, 1, 1], [-1, 1, 0]]) burgers = param['lat'] / np.sqrt(6.) * np.array([-1., -1., 2.]) stroh = stroh_solve.Stroh(c, burgers, axes=axes) A = np.mat(np.zeros([3, 3]), dtype='complex') A[:, 0] = np.mat(stroh.A[0]).transpose() A[:, 1] = np.mat(stroh.A[2]).transpose() A[:, 2] = np.mat(stroh.A[4]).transpose() B = np.mat(np.zeros([3, 3]), dtype='complex') B[:, 0] = np.mat(stroh.L[0]).transpose() B[:, 1] = np.mat(stroh.L[2]).transpose() B[:, 2] = np.mat(stroh.L[4]).transpose() Linv = np.real(np.complex(0, 1) * A * np.linalg.inv(B)) Gamma = 0.5 * Linv v1 = np.array([-1, -1, 2]) v2 = np.array([1, 1, 2]) theta = (np.arccos( np.dot(v1, v2) / (np.linalg.norm(v1) * np.linalg.norm(v2)))) omega = np.mat([[cos(theta), sin(theta), 0.0], [-sin(theta), cos(theta), 0.0], [0.0, 0.0, 1.0]]) Gamma = omega * Gamma * omega.transpose() # phi = 0 # svect = np.mat(np.array([cos(phi), 0.0, sin(phi)])) Gamma = np.linalg.inv(Gamma) Gamma = np.abs(Gamma) Gamma00 = Gamma[0, 0] # in GPa Gamma11 = Gamma[1, 1] Gamma00 *= 1e9 Gamma11 *= 1e9 if axes is not None: T = axes_check.axes_check(axes) burgers = T.dot(burgers) c = c.transform(axes) (coeff, Kg) = self.cal_crack(param, c, theta) # print((cos(0.5 * theta))**2 * sin(0.5 * theta)) # cal F(theta) soltrace = np.mat([[stroh.p[0], 0.0, 0.0], [0.0, stroh.p[2], 0.0], [0.0, 0.0, stroh.p[4]]], dtype='complex') Fmat1 = soltrace / np.sqrt(np.cos(theta) + soltrace * np.sin(theta)) Fmat1 = np.real(B * Fmat1 * np.linalg.inv(B)) Fmat2 = 1.0 / np.sqrt(np.cos(theta) + soltrace * np.sin(theta)) Fmat2 = np.real(B * Fmat2 * np.linalg.inv(B)) # print(((Fmat1 + Fmat2) * Gamma) * 1e-3 * param["ugsf"]) k1e = sqrt(Gamma00 * param['ugsf']) * 1e-6 # Mpa print('k1e', k1e) print('k1e / coeff', k1e / coeff)
def formular_make_edge(self): self.find_angles_1100(il=[[1], [1]], jl=[1]) # 58.361 ux = self.pot['ahcp'] uy = self.pot['chcp'] uz = self.pot['ahcp'] * np.sqrt(3.) atoms = ase.io.read(glob.glob("dump_init/dump.*")[-1], format='lammps-dump') print(len(atoms)) cell = atoms.get_cell() atoms.rotate(self.ag[0][0], 'z') # rotate atoms.translate(np.array([83.5 * ux, -80 * uy, 0])) axes = np.array([[1, 0, 0], [0, 0, 1], [0, -1, 0]]) burgers = self.pot['lattice'] * np.array([1, 0, 0]) c = am.ElasticConstants() c.hexagonal(C11=self.pot['C11'], C12=self.pot['C12'], C33=self.pot['C33'], C13=self.pot['C13'], C44=self.pot['C44']) stroh = stroh_solve.Stroh(c, burgers, axes=axes) pos = atoms.get_positions() # sh1 = np.ones(pos.shape) * \ # np.array([30 * ux + 0.1, 0.5 * uy, cell[2, 2]]) sh1 = np.ones(pos.shape) * \ np.array([34.5 * ux + 0.1, 0.5 * uy, cell[2, 2]]) sh2 = np.ones(pos.shape) * \ np.array([-20 * ux + 0.1, 0.5 * uy, cell[2, 2]]) d1 = stroh.displacement(pos - sh1) d2 = stroh.displacement(pos - sh2) atoms.set_positions(pos + np.real(d1) - np.real(d2)) # lob = np.array([0.0, 0.0, 0.0]) # hib = np.array([29.5 * ux, 0.5 * uy, cell[2, 2]]) # for i in range(len(atoms)): # if all(((atoms[i].position - lob) * (atoms[i].position - hib)) <= 0.0): # atoms[i].symbol = 'Mg' # lob2 = np.array([0.0, 0.5 * uy, 0.0]) # hib2 = np.array([30 * ux, 1.0 * uy, cell[2, 2]]) # for i in range(len(atoms)): # if all(((atoms[i].position - lob2) * (atoms[i].position - hib2)) <= 0.0): # atoms[i].symbol = 'Cr' atoms.translate(np.array([-83.5 * ux, 80 * uy, 0])) atoms.rotate(-self.ag[0][0], 'z') # rotate back self.write_lmp_config_data(atoms, "lmp_init01.txt") # add shear strain = np.mat([[1.0, 0.0, 0.0], [-0.015, 1.0, 0.0], [0.0, 0.0, 1.0]]) pos = atoms.get_positions() * strain cell = strain * atoms.get_cell() atoms.set_cell(cell) atoms.set_positions(pos) self.write_lmp_config_data(atoms, "lmp_init02.txt") self.write_lmp_config_data(atoms, "lmp_init.txt")
def bcc_screw_dipole_configs_alongz(self, sizen=1): c = tool_elastic_constants.elastic_constants(C11=self.pot['c11'], C12=self.pot['c12'], C44=self.pot['c44']) burgers = self.pot['lattice'] / 2 * np.array([1., 1., 1.]) stroh = stroh_solve.Stroh(c, burgers, axes=axes) atoms = self.set_dipole_box() atoms_perf = atoms.copy() pos = atoms.get_positions() ux = sqrt(6) / 3. * self.pot['lattice'] uy = sqrt(2) / 2. * self.pot['lattice'] uz = sqrt(3) / 2. * self.pot['lattice'] sx = 10.0 * sizen sy = 5 * sizen ix = 10.5 * sizen # c1 = 1. / 3. * np.sum(self.pot['core1'], axis=0) # c2 = 1. / 3. * np.sum(self.pot['core2'], axis=0) # shiftc1 = \ # np.ones(np.shape(pos)) * np.array([c1[0, 0], c1[0, 1], 0.0]) # shiftc2 = \ # np.ones(np.shape(pos)) * np.array([c2[0, 0], c2[0, 1], 0.0]) opt = 'original' if opt in ['split']: c1 = self.pot['posleft'] + \ np.array([0.0, 0.21 * self.pot['yunit']]) c2 = self.pot['posrigh'] + \ np.array([0.0, -0.21 * self.pot['yunit']]) elif opt in ['move']: c1 = [(sx + 0.5) * ux, (sy + 1. / 3. - 0.95 * 1. / 3.) * uy] c2 = [(sx + ix + 0.5) * ux, (sy + 2. / 3. + 0.95 * 1. / 3.) * uy] else: c1 = [(sx) * ux, (sy + 1. / 3.) * uy] c2 = [(sx + ix) * ux, (sy + 2. / 3.) * uy] shiftc1 = np.ones(np.shape(pos)) * np.array([c1[0], c1[1], 0.0]) shiftc2 = np.ones(np.shape(pos)) * np.array([c2[0], c2[1], 0.0]) disp1 = stroh.displacement(pos - shiftc1) disp2 = stroh.displacement(pos - shiftc2) if opt in ['pull']: radius = 2.0 # find the atoms near the center for ps, dp in zip(pos, disp1): dis = np.linalg.norm(ps[:2] - c1) if (dis < radius): dp[2] += 1. / 6. * uz # add shirt for ps, dp in zip(pos, disp2): dis = np.linalg.norm(ps[:2] - c2) if (dis < radius): dp[2] -= 1. / 6. * uz atoms.set_positions(pos + np.real(disp1) - np.real(disp2)) # periodic boundary conditions ??? # c2l = [(sx - ix + 0.5) * ux, (sy + 2. / 3. + 0.95 * 1. / 3.) * uy] # shft = np.ones(np.shape(pos)) * np.array([c2l[0], c2l[1], 0.0]) # disp3 = stroh.displacement(pos - shft) # atoms.set_positions(atoms.get_positions() - np.real(disp3)) atoms.wrap(pbc=[1, 1, 1]) ase.io.write("perf_poscar", atoms_perf, format='vasp') ase.io.write('POSCAR', atoms, format='vasp') return (atoms, atoms_perf)