Skip to content

Instantly share code, notes, and snippets.

@mlund
mlund / Dockerfile-llvm
Last active January 1, 2023 02:46
How to build rust-mos for aarch64 linux based on Docker files from rust-mos
FROM ubuntu:22.04 as llvm_mos_base
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
git curl ca-certificates ninja-build cmake build-essential \
libstdc++-10-dev libxml2-dev libssl-dev pkg-config python3-pip \
swig python3-dev libedit-dev libncurses5-dev liblzma-dev
FROM llvm_mos_base as build
WORKDIR /tmp
@mlund
mlund / Dockerfile
Created March 21, 2022 15:45
JupyterLab with Faunus master branch installed
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
#
# What is installed?
# - https://jupyter-docker-stacks.readthedocs.io/en/latest/using/selecting.html
# - GCC 11, CMake, OpenMPI, parmed, openmm, nglview, mdtraj
# - Faunus main branch incl. manual and examples
#
ARG OWNER=jupyter
@mlund
mlund / EigenSTLFacade.cpp
Last active February 25, 2018 13:00
Eigen facade or view for structured data in STL vector/array (Eigen3 and C++14 required)
#include <vector>
#include <iostream>
#include <type_traits>
#include <Eigen/Eigen>
/**
* @brief Eigen::Map facade to access data members in STL vectors/arrays
*
* No data is copied and modifications of the Eigen object
* modifies the original container and vice versa.
@mlund
mlund / README.md
Last active April 11, 2018 06:14
Ubuntu terminal setup for MacOS X 10.11+

Ubuntu terminal setup for macOS

This will setup a Ubuntu-like terminal in MacOS X.

Installation

cat bash_profile >> ~/.bash_profile
open Ubuntu.terminal
@mlund
mlund / loadgrace.py
Last active March 8, 2024 19:39
Python module to load xmgrace plots into numpy arrays
#!/usr/bin/env python
# Copyright (c) 2015-2023 Mikael Lund
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
@mlund
mlund / MatrixBaseAddons.h
Last active December 16, 2015 08:19
Calculates the scattering intensity from a molecular structure
private:
enum baseparticle_ : Index {RX=0,RY,RZ,ID,Q,LAST};
enum multipoleparticle_ : Index {MUX=LAST,MUY,MUZ};
public:
// Particle charge
EIGEN_STRONG_INLINE Scalar charge() const { return (*this)[Q]; }
EIGEN_STRONG_INLINE Scalar& charge() { return (*this)[Q]; }
// Particle id
@mlund
mlund / tabulator.cpp
Last active December 14, 2015 22:59
Possible design for tabulated pair potential. Require C++11 flags, for example "g++ -std=c++11"
#include <iostream>
#include <functional>
#include <map>
#include <cmath>
#include <memory>
/* ordered pair */
template<class T>
struct opair : public std::pair<T,T> {
typedef std::pair<T,T> base;
@mlund
mlund / README.md
Last active March 9, 2018 08:52
Cell list for particle simulations, in progress

Cell list with periodic boundaries

This maps a vector of 3d positions and map each index into an evenly spaced lattice of grid points (cells). The neighbors of a given index in the position vector can be used to quickly find all other index in the vicinity.

More inspiration: http://cacs.usc.edu/education/cs596/01-1LinkedListCell.pdf

@mlund
mlund / doi2bib.sh
Last active March 25, 2018 23:31
Convert Digital Object Identifier (DOI) to BibTeX using crosscite.org
#!/bin/bash
curl -LH "Accept: application/x-bibtex;q=1" http://dx.doi.org/$1
echo
@mlund
mlund / randone.cpp
Last active December 11, 2015 01:29
Random float in range [0:1[ using C++11's Mersenne Twister as well as a non-deterministic seed.
#include <random>
#include <iostream>
template<typename T, typename Tengine=std::mt19937>
class RandOne {
std::uniform_real_distribution<T> dist_;
Tengine eng_;
public:
/* constructor w. non-deterministic seed */
RandOne() : dist_(0,1) {
std::random_device rd;