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 / 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,
@Ionizing
Ionizing / incbin.c
Last active April 3, 2023 15:25 — forked from mmozeiko/incbin.c
Include binary file with gcc/clang
#define STR2(x) #x
#define STR(x) STR2(x)
#ifdef __APPLE__
#define USTR(x) "_" STR(x)
#else
#define USTR(x) STR(x)
#endif
#ifdef _WIN32
@Ionizing
Ionizing / semver_parse.sh
Last active December 5, 2022 13:33
Parse the sematic version string with bash
# Let VER_STR be the version string
VER_STR="v1.14.514-rc-v1.919.810-tnok.."
# Use `sed` to extract the MAJOR, MINOR, PATCH number
echo $VER_STR | sed -nE 's/^v([0-9]+).([0-9]+).([0-9]+)(.*)$/\1 \2 \3/p'
# prints "1 14 514"
# Convert "1 14 514" to an array of ["1", "14", "514"]
VER=($(echo $VER_STR | sed -nE 's/^v([0-9]+).([0-9]+).([0-9]+)(.*)$/\1 \2 \3/p'))
echo ${VER[0]} # prints 1
@Ionizing
Ionizing / ising2d.jl
Created November 23, 2022 09:20
Simulating 2D Ising model.
#!/usr/bin/env julia
using Printf: @printf;
function bc(x, L)
mod(x-1, L) + 1;
end
function totalEnergy(grid ::Matrix{Int64}) ::Float64
(x, y) = size(grid);