Skip to content

Instantly share code, notes, and snippets.

View Ionizing's full-sized avatar
😵
Being defeated by DALAOs

Ionizing Ionizing

😵
Being defeated by DALAOs
  • Mars
View GitHub Profile
@Ionizing
Ionizing / band_unfold.py
Created June 30, 2024 10:09
Band unfold script using vaspwfc.
#!/usr/bin/env python3
from functools import lru_cache
import numpy as np
from numpy.typing import NDArray
from vaspwfc import vaspwfc
class UnfoldSystem:
def __init__(self, wavecar: str, M, *,
@Ionizing
Ionizing / MoS2-schematic-band.py
Created June 22, 2024 15:28
MoS2 monolayer schematic view of valleys band structure.
#!/usr/bin/env python3
from enum import Enum, unique
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse
mpl.rcParams["font.sans-serif"] = "monospace"
mpl.rcParams["text.usetex"] = True
@Ionizing
Ionizing / supbz.py
Created June 19, 2024 14:30
Plot real cell and Brillouin zone.
#!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
from scipy.spatial import Voronoi
def get_reduced_voronoi(cell):
assert cell.shape == (2,2)
@Ionizing
Ionizing / INCAR.SOC_U
Created January 20, 2024 03:50
INCAR for spin orbit coupling calculation with hubbard U correction.
SYSTEM = xxxxx
Startparameter for this Run:
NWRITE = 2 default is 2
ISTART = 0 0-new 1-cont 2-same basic set
ICHARG = 1 charge: 1-file 2-atom 10-const
LCHARG = .TRUE. Write down charge densities or not
LWAVE = .TRUE. Write down wavefunctions or not
# LVTOT = .TRUE. Write LOCPOT, total local potential
# LVHAR = .TRUE. Write LOCPOT, Hartree potential only
# LELF = .TRUE. Write electronic localiz. function (ELF)
@Ionizing
Ionizing / Dockerfile
Last active January 9, 2024 12:43
Dockerfile for cross-rs to build glibc 2.17 compatible rust binaries. MKL supported.
FROM centos:centos7.9.2009
RUN yum update -y && yum group install -y 'Development Tools'
# install rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y --target x86_64-unknown-linux-gnu
ENV PATH="${HOME}/.cargo/bin:${PATH}"
# install blas
RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
@Ionizing
Ionizing / dm.jl
Created January 4, 2024 04:20
DensityMatrix method
#!/usr/bin/env julia
using LinearAlgebra;
using Printf;
import Random;
Random.seed!(1234);
N = 1_000_000;
δt = 0.1;
@Ionizing
Ionizing / nebmake.py
Created November 26, 2023 09:18
make NEB initial POSCAR with specified atom not affected by PBC.
#!/usr/bin/env python3
import copy
from pathlib import Path
import shutil
from sys import argv
import numpy as np
from ase.io import read as poscar_reader
from ase import Atoms
@Ionizing
Ionizing / gpaw_coulomb_correction.py
Created October 15, 2023 13:50
First order and second order coulomb correction for PAW method, extracted from GPAW.
#!/usr/bin/env python3
import gzip
from xml.etree import ElementTree as ET
from glob import glob
import numpy as np
import numpy.typing as npt
@Ionizing
Ionizing / overloading.rs
Created July 26, 2023 15:48
Function overloading in Rust
// Credits to (Telegram):
// - @QC_Grove (zh) | blog.quarticcat.com (en/zh)
// - @bdbai_chat
trait Foo<T, U> {
type Output;
fn foo(a: T, b: U) -> Self::Output;
}
impl Foo<i32, f64> for () {
@Ionizing
Ionizing / str2fn_nom.rs
Last active May 26, 2023 09:08
Parse string and return an Fn object
use std::fmt;
use std::fmt::{Debug, Display, Formatter};
use nom::{
branch::alt,
bytes::complete::tag,
character::complete::multispace0 as multispace,
number::complete::double,
combinator::map,
multi::many0,