Imported from https://github.com/materialsvirtuallab/megnet
