{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Create LAMMPS Dump File\n", "1. `l_Cbpb_Cp`: Basis of the 2D lattice in the CSLp reference frame for the given (hkl) plane.\n", "2. `l_CRbpb_Cp`: Basis of the 2D lattice such that the basis vectors have length that is greater than rCut and the basis vectors are similar in lengths and the angle between them is close to 90. Defined in the CSLp reference frame" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import byxtal.tools as gbt\n", "import byxtal.lattice as gbl\n", "import pickle as pkl\n", "import numpy as np\n", "import numpy.linalg as nla\n", "import byxtal.misorient_fz as mfz\n", "import gbpy.generate_hkl_indices as ghi\n", "import gbpy.util_funcs_create_byxtal as uf\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "########################################################################\n", "l1=gbl.Lattice('Al')\n", "pkl_name = l1.elem_type+'_byxtal_props.pkl'\n", "jar = open(pkl_name, 'rb');\n", "\n", "csl_props = pkl.load(jar)\n", "sig_mats = csl_props['sig_mats']\n", "csl_mats = csl_props['csl_mats']\n", "dsc_mats = csl_props['dsc_mats']\n", "bxt_symm_props = csl_props['csl_symm_props']\n", "jar.close()\n", "########################################################################\n", "\n", "########################################################################\n", "pkl_name = 'bp_list_' + l1.elem_type + '.pkl'\n", "jar = open(pkl_name, 'rb');\n", "\n", "bp_list = pkl.load(jar)\n", "l_p_po = bp_list['l_p_po']\n", "hkl_sig_inds = bp_list['miller_inds']\n", "\n", "jar.close()\n", "########################################################################\n" ] }, { "cell_type": "code", "execution_count": 59, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[0. , 2.025, 2.025],\n", " [2.025, 0. , 2.025],\n", " [2.025, 2.025, 0. ]])" ] }, "execution_count": 59, "metadata": {}, "output_type": "execute_result" } ], "source": [ "l_p_po" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "l1 = gbl.Lattice('Al')\n", "lat_par = l1.lat_params['a']\n", "rCut = lat_par*3\n", "A_cut = (rCut+lat_par)**2\n", "\n", "l_p_po = l1.l_p_po\n", "l_po_p = nla.inv(l_p_po)\n" ] }, { "cell_type": "code", "execution_count": 76, "metadata": {}, "outputs": [], "source": [ "s1_keys = list(hkl_sig_inds.keys())\n", "ind1 = 0\n", "sig_id = s1_keys[ind1]\n", "hkl_inds = hkl_sig_inds[sig_id]\n", "l_csl_p1 = csl_mats[sig_id]\n", "l_csl_po1 = l_p_po.dot(l_csl_p1)\n", "\n", "tct1 = 0\n", "hkl1 = np.zeros((1,3), dtype='int64')\n", "hkl1[0,:] = hkl_inds[tct1,:]\n" ] }, { "cell_type": "code", "execution_count": 77, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[ 0. , -2.025, 4.05 ],\n", " [ 2.025, 2.025, 4.05 ],\n", " [-2.025, 0. , 4.05 ]])" ] }, "execution_count": 77, "metadata": {}, "output_type": "execute_result" } ], "source": [ "l_csl_po1" ] }, { "cell_type": "code", "execution_count": 78, "metadata": {}, "outputs": [], "source": [ "# for i in range(len(hkl_inds)):\n", "# print(i)\n", "# hkl1[0,:] = hkl_inds[i,:]\n", "# l_CSLbpb_CSLp = {}\n", "# l_CSLbpbSig_CSLp = {}\n", "\n", "# l_CSLbpb_CSLp_mat = ghi.compute_hkl_bpb(hkl1)\n", "# l_CSLbpbSig_CSLp_mat = ghi.gen_Acut_bpb(l_CSLbpb_CSLp_mat, l_csl_po1, rCut, A_cut)\n", "\n", "# l_Cbpb_Cp = l_CSLbpb_CSLp_mat[0]\n", "# l_CRbpb_Cp = l_CSLbpbSig_CSLp_mat[0]\n", "\n", "# l_bp_po1 = l_csl_po1.dot(l_CRbpb_Cp)\n", "\n", "# symm_grp_ax = bxt_symm_props[sig_id]['symm_grp_ax'];\n", "# bp_symm_grp = bxt_symm_props[sig_id]['bxt_symm_grp'];\n", "\n", "# l_p2_p1 = sig_mats[sig_id]\n", "# gb_ID = uf.get_gb_uID(l1, l_bp_po1, l_p2_p1, l_p_po, bp_symm_grp, symm_grp_ax, sig_id)\n", "# print(gb_ID)" ] }, { "cell_type": "code", "execution_count": 79, "metadata": {}, "outputs": [], "source": [ "l_CSLbpb_CSLp = {}\n", "l_CSLbpbSig_CSLp = {}\n", "\n", "l_CSLbpb_CSLp_mat = ghi.compute_hkl_bpb(hkl1)\n", "l_CSLbpbSig_CSLp_mat = ghi.gen_Acut_bpb(l_CSLbpb_CSLp_mat, l_csl_po1, rCut, A_cut)\n", "\n", "l_Cbpb_Cp = l_CSLbpb_CSLp_mat[0]\n", "l_CRbpb_Cp = l_CSLbpbSig_CSLp_mat[0]\n", "\n", "l_bp_po1 = l_csl_po1.dot(l_CRbpb_Cp)\n", "\n", "symm_grp_ax = bxt_symm_props[sig_id]['symm_grp_ax'];\n", "bp_symm_grp = bxt_symm_props[sig_id]['bxt_symm_grp'];\n", "\n", "l_p2_p1 = sig_mats[sig_id] \n", "gb_ID = uf.get_gb_uID(l1, l_bp_po1, l_p2_p1, l_p_po, bp_symm_grp, symm_grp_ax, sig_id)" ] }, { "cell_type": "code", "execution_count": 81, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Al_S3_1_N1_1_0_0_N2_-2_1_-2'" ] }, "execution_count": 81, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gb_ID" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "zCut = 25*l1.lat_params['a']\n", "\n", "threeD_upts, sim_cell2 = uf.create_half_cryst(l1, l_csl_p1, l_CRbpb_Cp, l_p_po, 'upper', zCut)\n", "\n", "l_p1_p2 = nla.inv(l_p2_p1)\n", "l_csl_p2 = l_p1_p2.dot(l_csl_p1)\n", "threeD_lpts, sim_cell1 = uf.create_half_cryst(l1, l_csl_p2, l_CRbpb_Cp, l_p_po, 'lower', zCut)\n" ] }, { "cell_type": "code", "execution_count": 61, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[ 1.43189123e+01, -3.43653896e+00, 0.00000000e+00,\n", " 0.00000000e+00],\n", " [ 4.44089210e-16, 1.89009643e+01, 0.00000000e+00,\n", " 0.00000000e+00],\n", " [ 0.00000000e+00, 0.00000000e+00, 2.02500000e+02,\n", " -1.01250000e+02]])" ] }, "execution_count": 61, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sim_cell2" ] }, { "cell_type": "code", "execution_count": 48, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([-7., 2., 5.])" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.matmul(np.array([-5,7,-2]), np.linalg.inv(l_p2_p1))" ] }, { "cell_type": "code", "execution_count": 54, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[ 0.66666667, -0.33333333, 0.66666667],\n", " [ 0.66666667, 0.66666667, -0.33333333],\n", " [-0.33333333, 0.66666667, 0.66666667]])" ] }, "execution_count": 54, "metadata": {}, "output_type": "execute_result" } ], "source": [ "l_p2_p1" ] }, { "cell_type": "code", "execution_count": 52, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[-1.00000000e+00, 1.11022302e-16, 1.00000000e+00],\n", " [-1.11022302e-16, -1.00000000e+00, 1.00000000e+00],\n", " [ 1.00000000e+00, 1.00000000e+00, 1.00000000e+00]])" ] }, "execution_count": 52, "metadata": {}, "output_type": "execute_result" } ], "source": [ "l_csl_p2" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [], "source": [ "#test:leila\n", "l_csl_po1 = l_p_po.dot(l_csl_p1)\n", "l_bp_po1 = l_csl_po1.dot(l_CRbpb_Cp)\n", "l_po1_go = uf.compute_orientation(l_bp_po1)" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[ 1.43189123e+01, -3.43653896e+00, 0.00000000e+00],\n", " [ 0.00000000e+00, 1.89009643e+01, 0.00000000e+00],\n", " [ 8.88178420e-16, 8.88178420e-16, 2.02500000e+02]])" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sim_cell1[0:3,0:3]" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "gb_attr = {}\n", "gb_attr['cell'] = sim_cell1\n", "gb_attr['upts'] = threeD_upts\n", "gb_attr['lpts'] = threeD_lpts\n", "gb_attr['lattice'] = l1.elem_type\n", "\n", "pkl_name = 'gb_attr_'+gb_ID+'.pkl'\n", "jar = open(pkl_name,'wb')\n", "pkl.dump(gb_attr, jar)\n", "jar.close()" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "import gbpy.lammps_dump_writer as ldw\n", "initial_dump = 'gb_attr_' + gb_ID + '.out'\n", "box_bound, dump_lamp, box_type = ldw.lammps_box(pkl_name) # lammps creates from the pkl file\n", "ldw.write_lammps_dump(initial_dump, box_bound, dump_lamp, box_type)" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[ 0., 1., 1.],\n", " [-1., -1., 1.],\n", " [ 1., 0., 1.]])" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "l_csl_p1" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[-1.00000000e+00, 1.11022302e-16, 1.00000000e+00],\n", " [-1.11022302e-16, -1.00000000e+00, 1.00000000e+00],\n", " [ 1.00000000e+00, 1.00000000e+00, 1.00000000e+00]])" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "l_csl_p2" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.9" } }, "nbformat": 4, "nbformat_minor": 4 }