Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working MEEP in pythonPackages #1

Merged
merged 3 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ let

mctdh = callPackage ./pkgs/apps/mctdh { };

meep = callPackage ./pkgs/apps/meep { };

mesa-qc = callPackage ./pkgs/apps/mesa {
gfortran = final.gfortran6;
};
Expand Down
55 changes: 51 additions & 4 deletions pkgs/apps/meep/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{ stdenv, lib, fetchFromGitHub, autoreconfHook, gfortran, blas, lapack, fftw, hdf5-full
, pkg-config, mpi, python3, harminv, libctl, libGDSII
{ stdenv, lib, buildPythonPackage, fetchFromGitHub, autoreconfHook, pkg-config
, gfortran, mpi, blas, lapack, fftw, hdf5-full, swig, gsl, harminv, libctl
, libGDSII
# Python
, python, numpy, scipy, matplotlib, h5py, cython, autograd, mpi4py
} :

stdenv.mkDerivation rec {
buildPythonPackage rec {
pname = "meep";
version = "1.18.0";

Expand All @@ -17,9 +20,12 @@ stdenv.mkDerivation rec {
autoreconfHook
gfortran
pkg-config
swig
mpi
];

buildInputs = [
gsl
blas
lapack
fftw
Expand All @@ -31,18 +37,59 @@ stdenv.mkDerivation rec {

propagatedBuildInputs = [
mpi
python3
numpy
scipy
matplotlib
h5py
cython
autograd
mpi4py
];

propagatedUserEnvPkgs = [ mpi ];

dontUseSetuptoolsBuild = true;
dontUsePipInstall = true;
dontUseSetuptoolsCheck = true;

HDF5_MPI = "ON";
PYTHON = "${python}/bin/${python.executable}";

enableParallelBuilding = true;

configureFlags = [
"--without-libctl"
"--enable-shared"
"--with-mpi"
"--with-openmp"
"--enable-maintainer-mode"
];

passthru = { inherit mpi; };

doCheck = true;
checkPhase = ''
export PYTHONPATH="$out/lib/${python.libPrefix}/site-packages:$PYTHONPATH"
python3 << EOF
import meep as mp
cell = mp.Vector3(16,8,0)
geometry = [mp.Block(mp.Vector3(mp.inf,1,mp.inf),
center=mp.Vector3(),
material=mp.Medium(epsilon=12))]
sources = [mp.Source(mp.ContinuousSource(frequency=0.15),
component=mp.Ez,
center=mp.Vector3(-7,0))]
pml_layers = [mp.PML(1.0)]
resolution = 10
sim = mp.Simulation(cell_size=cell,
boundary_layers=pml_layers,
geometry=geometry,
sources=sources,
resolution=resolution)
sim.run(until=200)
EOF
'';

meta = with lib; {
description = "Free finite-difference time-domain (FDTD) software for electromagnetic simulations";
homepage = "https://meep.readthedocs.io/en/latest/";
Expand Down
3 changes: 3 additions & 0 deletions pythonPackages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let
lib = selfPkgs.pkgs.lib;

overlay = {

pychemps2 = callPackage ./pkgs/apps/chemps2/PyChemMPS2.nix { };

} // lib.optionalAttrs super.isPy3k {
Expand All @@ -23,6 +24,8 @@ let
gau2grid-1_3_1 = callPackage ./pkgs/apps/gau2grid { version = "1.3.1"; sha256 = "0zkfil7cxjip79wqvhljk1ifjq0cwxzx6wlxgp63b6wbagma0i12"; };
gau2grid-2_0_4 = callPackage ./pkgs/apps/gau2grid { version = "2.0.4"; sha256 = "0qypq8iax0n6yfi4223zya468v24b60nr0x43ypmsafj0104zqa6"; };

meep = callPackage ./pkgs/apps/meep { };

pylibefp = callPackage ./pkgs/lib/pylibefp { };

psi4 = callPackage ./pkgs/apps/psi4 {
Expand Down