Skip to content

Instantly share code, notes, and snippets.

View henriasv's full-sized avatar

Henrik Andersen Sveinsson henriasv

View GitHub Profile
@henriasv
henriasv / language_processing.ipynb
Created January 22, 2020 10:46
language_processing.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
pip3 install numpy matplotlib python-Levenshtein lxml future scipy
wget https://bitbucket.org/logg/publish/get/ce47f50420a6.zip && unzip ce47f50420a6.zip && cd logg-publish-ce47f50420a6 && pip3 install . && cd ..
pip3 install git+https://github.com/doconce/preprocess
pip3 install git+https://github.com/hplgit/doconce
from ase import Atoms
import ase
d = 1.1
co = Atoms('CO', positions=[(0, 0, 0), (0, 0, d)])
# http://rruff.geo.arizona.edu/AMS/minerals/Methane-hydrate
from ase.spacegroup import crystal
# Create ice lh
# Pm3n
a = 11.877
@henriasv
henriasv / water.mol
Created October 23, 2019 11:22
Lammps water molecule file
Water molecule LAMMPS molecule file
3 atoms
Coords
1 0.0000000 0.000000 0.00000
2 0.8164904 0.5773590 0.00000
3 -0.8164904 0.5773590 0.00000
Types
@henriasv
henriasv / convert_svg_to_pdf_folder.py
Created August 21, 2019 11:35
Convert all svg files in a folder to pdf
import subprocess
import os
for file in os.listdir(os.getcwd()):
if file.endswith(".pdf"):
subprocess.call(["pdf2svg", file, file.strip(".pdf") + ".svg"])
# pdf2svg can be installed with homebrew on mac
# brew install pdf2svg

Man kan lage en haug med simuleringer ved å:

Lage en fil med én kommando per linje. La oss si at vi kaller den for tmp_commands.

Da kan vi bruke dette scriptet til å fyre av en haug med simuleringer

#!/bin/bash
#SBATCH --account=<account>
#SBATCH --mem-per-cpu=1G
#SBATCH --tasks=1
@henriasv
henriasv / rotation_matrix.py
Created October 7, 2018 10:08
Rotation matrix 3D
def rotation_matrix(axis, theta):
"""
Return the rotation matrix associated with counterclockwise rotation about
the given axis by theta radians.
"""
axis = np.asarray(axis)
axis = axis / np.sqrt(np.dot(axis, axis))
a = np.cos(theta / 2.0)
b, c, d = -axis * np.sin(theta / 2.0)
aa, bb, cc, dd = a * a, b * b, c * c, d * d
@henriasv
henriasv / von_mises_ovito.txt
Last active March 31, 2025 17:54
ovito von mises stress computation
sqrt(((StressTensor.XX - StressTensor.YY)*(StressTensor.XX - StressTensor.YY) + (StressTensor.YY - StressTensor.ZZ)*(StressTensor.YY - StressTensor.ZZ) + (StressTensor.ZZ - StressTensor.XX)*(StressTensor.ZZ - StressTensor.XX) +
6*(StressTensor.XY*StressTensor.XY + StressTensor.XZ *StressTensor.XZ + StressTensor.YZ*StressTensor.YZ))/2 )

Keybase proof

I hereby claim:

  • I am henriasv on github.
  • I am henriasv (https://keybase.io/henriasv) on keybase.
  • I have a public key ASAEUpSYlYP-i3VKEK8s11_5hRUMJTdCzCP_F866qCP6Swo

To claim this, I am signing this object: