Skip to content

Instantly share code, notes, and snippets.

@terencezl
terencezl / convert_pdf.py
Created April 20, 2017 04:39
use pdfminer to extract pdf
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import TextConverter, XMLConverter, HTMLConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
from io import BytesIO
def convert_pdf(path, format='text', codec='utf-8', password=''):
rsrcmgr = PDFResourceManager()
retstr = BytesIO()
laparams = LAParams()
@terencezl
terencezl / symmetrizing-the-elastic-tensor-with-crystal-symmetry-operations.md
Created April 12, 2016 22:44
symmetrizing-the-elastic-tensor-with-crystal-symmetry-operations.md

Introduction

Density functional theory (DFT) has proven to be an effective way to obtain the physical properties of material systems. Using the linear stress-strain relationship, one is able to obtain the elastic constants from a set of DFT calculations. One particular challenge is that the elastic tensor thus obtained is usually not numerically symmetric with respect to the crystal symmetry. Neumann's principle, or principle of symmetry, states that [^1]:

If a crystal is invariant with respect to certain symmetry operations, any of its physical properties must also be invariant with respect to the same symmetry operations, or otherwise stated, the symmetry operations of any physical property of a crystal must include the symmetry operations of the point group of the crystal.

Therefore, it is worthwhile working out a routine to symmetrize the elastic tensor using the symmetry operations of the crystal.

Theoretical formulation

A $3\times 3 \times 3\times 3$ elastic tensor ${c_{ijkl}}$ has the in

@terencezl
terencezl / homework-semiconductors-II.md
Created April 3, 2016 04:59
homework-semiconductors-II.md

Problem 8

The ${200}$ set of wavefunctions are $\phi = \exp(i 2\pi/a (\pm 2x))$, $\exp(i 2\pi/a (\pm 2y))$, and $\exp(i 2\pi/a (\pm 2z))$. They can be represented as

$$ \begin{pmatrix} 1 \ 0 \ 0 \end{pmatrix} \begin{pmatrix} -1 \ 0 \ 0 \end{pmatrix} \begin{pmatrix} 0 \ 1 \ 0 \end{pmatrix} \begin{pmatrix} 0 \ -1 \ 0 \end{pmatrix} \begin{pmatrix} 0 \ 0 \ 1 \end{pmatrix} \begin{pmatrix} 0 \ 0 \ -1 \end{pmatrix}, $$ treating the magnitude of each as 1.

The classes are ${E}, {3C_2}, {6S_4}, {6\sigma}, {8C_3}$.

@terencezl
terencezl / questions-of-semiconductors-II.md
Last active April 1, 2016 19:29
questions-of-semiconductors-II.md

Questions

The definition of complex $R$ and point group $\mathrm{\textbf{R}}$

In the first half of Lecture II, the complex $R$, not necessarily a group $\mathrm{\textbf{R}}$, is introduced as such.

Consider only the purely translational symmetry operations of an infinite crystal. These operations form a group denoted $\mathrm{\textbf{T}}$, where $\mathrm{\textbf{T}}$ is a subgroup of the full space group $\mathrm{\textbf{G}}$ of the crystal. Denote by $R$, the set of all symmetry operations of $\mathrm{\textbf{G}}$ that involve pure rotations only (proper or improper) as well as rotations accompanied by a translation not in $\mathrm{\textbf{T}}$. $R$ is a subset of $\mathrm{\textbf{G}}$ called a "complex" whose elements are denoted by $\alpha$, $\beta$, $\gamma$, ... since in general $R$ is not a group.

@terencezl
terencezl / get_symmetrized_elastic_tensor.py
Last active December 9, 2018 02:44
get_symmetrized_elastic_tensor
import warnings
import numpy as np
import pandas as pd
from pymatgen.analysis.elasticity.elastic import ElasticTensor
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
def get_symmetrized_elastic_tensor(C, structure, align=False, tol=1e-4):
"""
Parameters:
@terencezl
terencezl / jekyll.py
Last active August 29, 2015 14:08 — forked from cscorley/jekyll.py
A few key strokes to convert IPython notebooks to markdown and serve in Jekyll, per http://cscorley.github.io/2014/02/21/blogging-with-ipython-and-jekyll/. Pics and GitHub markdown style triple backtick code blocks with line numbers are supported.
try:
from urllib.parse import quote # Py 3
except ImportError:
from urllib2 import quote # Py 2
import os
import sys
try:
BLOG_DIR = os.environ['BLOG_DIR']
except KeyError: