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

meep: init at 1.25.0 #214924

Merged
merged 3 commits into from
Feb 8, 2023
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
42 changes: 42 additions & 0 deletions pkgs/development/libraries/science/chemistry/harminv/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{ lib
, stdenv
, fetchFromGitHub
, autoreconfHook
, gfortran
, blas
, lapack
sheepforce marked this conversation as resolved.
Show resolved Hide resolved
}:

assert !blas.isILP64;
assert !lapack.isILP64;

stdenv.mkDerivation rec {
pname = "harminv";
version = "1.4.2";

src = fetchFromGitHub {
owner = "NanoComp";
repo = pname;
rev = "v${version}";
hash = "sha256-EXEt7l69etcBdDdEDlD1ODOdhTBZCVjgY1jhRUDd/W0=";
};

# File is missing in the git checkout but required by autotools
postPatch = ''
touch ChangeLog
'';

nativeBuildInputs = [ autoreconfHook gfortran ];

buildInputs = [ blas lapack ];

configureFlags = [ "--enable-shared" ];

meta = with lib; {
description = "Harmonic inversion algorithm of Mandelshtam: decompose signal into sum of decaying sinusoids";
homepage = "https://github.com/NanoComp/harminv";
license = with licenses; [ gpl2Only ];
maintainers = with maintainers; [ sheepforce markuskowa ];
platforms = platforms.linux;
};
}
32 changes: 32 additions & 0 deletions pkgs/development/libraries/science/chemistry/libGDSII/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{ lib
, stdenv
, fetchFromGitHub
, autoreconfHook
}:

stdenv.mkDerivation rec {
pname = "libGDSII";
version = "0.21";

src = fetchFromGitHub {
owner = "HomerReid";
repo = pname;
rev = "v${version}";
hash = "sha256-EXEt7l69etcBdDdEDlD1ODOdhTBZCVjgY1jhRUDd/W0=";
};

# File is missing in the repo but automake requires it
postPatch = ''
touch ChangeLog
'';

nativeBuildInputs = [ autoreconfHook ];

meta = with lib; {
description = "Library and command-line utility for reading GDSII geometry files";
homepage = "https://github.com/HomerReid/libGDSII";
license = [ licenses.gpl2Only ];
maintainers = with maintainers; [ sheepforce markuskowa ];
platforms = platforms.linux;
};
}
151 changes: 151 additions & 0 deletions pkgs/development/python-modules/meep/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
{ stdenv
, lib
, buildPythonPackage
, fetchFromGitHub
, autoreconfHook
, pkg-config
, gfortran
, mpi
, blas
, lapack
, fftw
, hdf5-mpi
, swig
, gsl
, harminv
, libctl
, libGDSII
, openssh
, guile
, python
, numpy
, scipy
, matplotlib
, h5py-mpi
, cython
, autograd
, mpi4py
}:

assert !blas.isILP64;
assert !lapack.isILP64;

buildPythonPackage rec {
pname = "meep";
version = "1.25.0";

src = fetchFromGitHub {
owner = "NanoComp";
repo = pname;
rev = "v${version}";
hash = "sha256-4rIz2RXLSWzZbRuv8d4nidOa0ULYc4QHIdaYrGu1WkI=";
};

format = "other";

# MPI is needed in nativeBuildInputs too, otherwise MPI libs will be missing
# at runtime
nativeBuildInputs = [
autoreconfHook
gfortran
pkg-config
swig
mpi
markuskowa marked this conversation as resolved.
Show resolved Hide resolved
];

buildInputs = [
gsl
blas
lapack
fftw
hdf5-mpi
harminv
libctl
libGDSII
guile
gsl
];

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

propagatedUserEnvPkgs = [ mpi ];

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

enableParallelBuilding = true;

preConfigure = ''
export HDF5_MPI=ON
export PYTHON=${python}/bin/${python.executable};
'';

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

passthru = { inherit mpi; };

/*
This test is taken from the MEEP tutorial "Fields in a Waveguide" at
<https://meep.readthedocs.io/en/latest/Python_Tutorials/Basics/>.
It is important, that the test actually performs a calculation
(calls `sim.run()`), as only then MPI will be initialised and MPI linking
errors can be caught.
*/
doCheck = true;
checkPhase = ''
sheepforce marked this conversation as resolved.
Show resolved Hide resolved
export PATH=$PATH:${openssh}/bin
export PYTHONPATH="$out/lib/${python.libPrefix}/site-packages:$PYTHONPATH"

export OMP_NUM_THREADS=1

# Fix to make mpich run in a sandbox
export HYDRA_IFACE=lo
export OMPI_MCA_rmaps_base_oversubscribe=1

# Generate a python test script
cat > test.py << 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

${mpi}/bin/mpiexec -np 2 python3 test.py
'';

meta = with lib; {
description = "Free finite-difference time-domain (FDTD) software for electromagnetic simulations";
homepage = "https://meep.readthedocs.io/en/latest/";
license = licenses.gpl2Only;
platforms = platforms.linux;
maintainers = with maintainers; [ sheepforce markuskowa ];
};
}
4 changes: 4 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7899,6 +7899,8 @@ with pkgs;

gyb = callPackage ../tools/backup/gyb { };

harminv = callPackage ../development/libraries/science/chemistry/harminv { };

igrep = callPackage ../tools/text/igrep {
inherit (darwin.apple_sdk.frameworks) Security;
};
Expand Down Expand Up @@ -27320,6 +27322,8 @@ with pkgs;

ledger-udev-rules = callPackage ../os-specific/linux/ledger-udev-rules {};

libGDSII = callPackage ../development/libraries/science/chemistry/libGDSII { };

inherit (callPackages ../data/fonts/liberation-fonts { })
liberation_ttf_v1
liberation_ttf_v2
Expand Down
2 changes: 2 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5804,6 +5804,8 @@ self: super: with self; {

mediapy = callPackage ../development/python-modules/mediapy { };

meep = callPackage ../development/python-modules/meep { };

meilisearch = callPackage ../development/python-modules/meilisearch { };

meinheld = callPackage ../development/python-modules/meinheld { };
Expand Down