{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Compute Bicrystallographic properties\n", "\n", "In this code, we compute and save the bicrystallography properties for each $\\Sigma$-miorientation. These properties include:\n", "1. `sig_mats`: The $\\Sigma$-miorientation in the primitive $p$ reference frame. For example, we use the variable `T_p1top2_p1`\n", "2. `csl_mats`: The CSL lattice basis vectors in the primitive $p$ reference frame. For example, we use the variable `l_csl_p` denoting $\\Lambda_{csl}^p$\n", "3. `dsc_mats`: The DSC lattice basis vectors in the primitive $p$ reference frame. For example, we use the variable `l_dsc_p` denoting $\\Lambda_{dsc}^p$\n", "4. `bxt_symm_props`: The symmetry aspects of the $\\Sigma$-miorientation\n", " + `bxt_symm_grp`: The point-group symmetry of the bicrystal. This is the symmetry for the Boundary-plane orientations.\n", " + `symm_grp_ax`: The axes of the symmetry point-group." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import byxtal.lattice as gbl\n", "import byxtal.csl_utility_functions as cuf\n", "import byxtal.find_csl_dsc as fcd\n", "import numpy as np\n", "import byxtal.tools as gbt\n", "import byxtal.misorient_fz as mfz\n", "import byxtal.disorient_symm_props as dsp" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "1. `l1`: The lattice object.\n", "2. `l_p_po`: $\\Lambda_p^{po}$" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3_1\n" ] }, { "ename": "IndexError", "evalue": "list index out of range", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 26\u001b[0m \u001b[0;31m# l_csl_p, l_dsc_p = fcd.find_csl_dsc(l_p_po, T_p1top2_p1, 1e-6, False)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 27\u001b[0;31m \u001b[0ml_csl_p\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfcd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfind_csl_dsc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ml_p_po\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mT_p1top2_p1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m1e-6\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mFalse\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 28\u001b[0m \u001b[0mcsl_mats\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0msig_id\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0ml_csl_p\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 29\u001b[0m \u001b[0;31m# dsc_mats[sig_id] = l_dsc_p;\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/Leila_sndhard/codes/byxtal/byxtal/byxtal/find_csl_dsc.py\u001b[0m in \u001b[0;36mfind_csl_dsc\u001b[0;34m(l_p_po, T_p1top2_p1, tol1, print_check)\u001b[0m\n\u001b[1;32m 102\u001b[0m \u001b[0;31m########################################################################\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 103\u001b[0m \u001b[0;31m# l_csl_p = csl_finder(T_p1top2_p1, Sigma, l_p_po, tol1)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 104\u001b[0;31m \u001b[0ml_csl_p\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcsl_finder\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mT_p1top2_p1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0ml_p_po\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtol1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 105\u001b[0m \u001b[0mcheck_val1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcheck_csl\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ml_csl_p\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0ml_p_po\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mT_p1top2_p1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mSigma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mprint_check\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 106\u001b[0m \u001b[0;31m########################################################################\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/Leila_sndhard/codes/byxtal/byxtal/byxtal/find_csl_dsc.py\u001b[0m in \u001b[0;36mcsl_finder\u001b[0;34m(T_p1top2_p1, l_p_po, tol1)\u001b[0m\n\u001b[1;32m 165\u001b[0m \u001b[0minp_args\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'mat'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mTI_p1top2_p1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 166\u001b[0m \u001b[0minp_args\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'sig_num'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mSigma\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 167\u001b[0;31m \u001b[0ml_csl1_p\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mrpl\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcall_sage_math\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexec_str\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0minp_args\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 168\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 169\u001b[0m \u001b[0ml_csl_csl1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mrpl\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreduce_po_lat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ml_csl1_p\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0ml_p_po\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtol1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/Leila_sndhard/codes/byxtal/byxtal/byxtal/reduce_po_lat.py\u001b[0m in \u001b[0;36mcall_sage_math\u001b[0;34m(exec_str, inp_args)\u001b[0m\n\u001b[1;32m 36\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi1\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mSz\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 37\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mj1\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mSz\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 38\u001b[0;31m \u001b[0mM_out\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mj1\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstr_out\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mct1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 39\u001b[0m \u001b[0mct1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mct1\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 40\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mIndexError\u001b[0m: list index out of range" ] } ], "source": [ "l1 = gbl.Lattice('Al')\n", "sig_type = 'common'\n", "l_p_po = l1.l_p_po\n", "\n", "### For cubic only odd Sigma numbers exist!\n", "n1 = 1\n", "n2 = 10\n", "sig_nums = 2*np.arange(n1,n2)+1\n", "\n", "num_sigs = 0\n", "sig_mats = {}\n", "csl_mats = {}\n", "dsc_mats = {}\n", "bxt_symm_props = {}\n", "\n", "for sig_num in sig_nums:\n", " s1 = cuf.csl_rotations(sig_num, sig_type, l1)\n", " for ct1 in range(np.shape(s1['N'])[0]):\n", " symm_grp_props = {}\n", " sig_id = str(sig_num)+'_'+str(ct1+1)\n", " print(sig_id)\n", " #### Store the sigma-misorientation (in 'p' reference frame)\n", " T_p1top2_p1 = s1['N'][ct1]/s1['D'][ct1]\n", " sig_mats[sig_id] = T_p1top2_p1\n", "\n", "# l_csl_p, l_dsc_p = fcd.find_csl_dsc(l_p_po, T_p1top2_p1, 1e-6, False)\n", " l_csl_p = fcd.find_csl_dsc(l_p_po, T_p1top2_p1, 1e-6, False)\n", " csl_mats[sig_id] = l_csl_p\n", "# dsc_mats[sig_id] = l_dsc_p;\n", "\n", " #### Generate boundary-planpe orientations\n", " l_p_po = l1.l_p_po\n", " l_po_p = np.linalg.inv(l_p_po)\n", " T_p1top2_po1 = np.dot(l_p_po, np.dot(T_p1top2_p1, l_po_p))\n", "\n", " ## Find the corresponding disorientation\n", " quat1 = gbt.mat2quat(T_p1top2_po1)\n", " # print(quat1)\n", " dis_quat1 = mfz.misorient_fz(quat1, l1.cryst_ptgrp)\n", " # print(dis_quat1)\n", " x_g, y_g, z_g, bxt_symm_grp = dsp.disorient_symm_props(dis_quat1, l1.cryst_ptgrp)\n", " symm_grp_ax = (np.vstack((x_g, y_g, z_g))).transpose()\n", " symm_grp_props['symm_grp_ax'] = symm_grp_ax\n", " symm_grp_props['bxt_symm_grp'] = bxt_symm_grp\n", " bxt_symm_props[sig_id] = symm_grp_props\n", " num_sigs = num_sigs + 1\n", " print(num_sigs)\n", "\n", "import pickle as pkl;\n", "pkl_name = l1.elem_type+'_byxtal_props.pkl'\n", "csl_props = {}\n", "csl_props['sig_mats'] = sig_mats\n", "csl_props['csl_mats'] = csl_mats\n", "csl_props['dsc_mats'] = dsc_mats\n", "csl_props['csl_symm_props'] = bxt_symm_props\n", "\n", "jar = open(pkl_name, 'wb')\n", "pkl.dump(csl_props, jar)\n", "jar.close()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "csl_props" ] }, { "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 }