about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKim Lindberger <kim.lindberger@gmail.com>2022-02-12 11:34:10 +0100
committerGitHub <noreply@github.com>2022-02-12 11:34:10 +0100
commitc7df3bf58cc735f9dff85f2c1c2f62323171a886 (patch)
tree2b04eaff8796b2e461ad6a8f288db812a463276b
parentfe5b7d6e3dfad11007dbc1b15532d07b065bf021 (diff)
parent10b7f30936e56cc17d1378c93b878b357f19e528 (diff)
Merge pull request #155108 from fedeinthemix/add-xyce-2
Add Xyce 7.4 (second attempt)
-rw-r--r--maintainers/maintainer-list.nix6
-rw-r--r--pkgs/applications/science/electronics/xyce/default.nix182
-rw-r--r--pkgs/development/libraries/science/math/trilinos/default.nix100
-rw-r--r--pkgs/top-level/all-packages.nix10
4 files changed, 298 insertions, 0 deletions
diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix
index 39e3599f8ef6c..61d1275442ff2 100644
--- a/maintainers/maintainer-list.nix
+++ b/maintainers/maintainer-list.nix
@@ -3930,6 +3930,12 @@
     githubId = 1276854;
     name = "Florian Peter";
   };
+  fbeffa = {
+    email = "beffa@fbengineering.ch";
+    github = "fedeinthemix";
+    githubId = 7670450;
+    name = "Federico Beffa";
+  };
   fbrs = {
     email = "yuuki@protonmail.com";
     github = "cideM";
diff --git a/pkgs/applications/science/electronics/xyce/default.nix b/pkgs/applications/science/electronics/xyce/default.nix
new file mode 100644
index 0000000000000..8d9b02d909e95
--- /dev/null
+++ b/pkgs/applications/science/electronics/xyce/default.nix
@@ -0,0 +1,182 @@
+{ stdenv
+, fetchFromGitHub
+, fetchgit
+, lib
+, autoconf
+, automake
+, bison
+, blas
+, flex
+, fftw
+, gfortran
+, lapack
+, libtool_2
+, mpi
+, suitesparse
+, trilinos
+, withMPI ? false
+  # for doc
+, texlive
+, pandoc
+, enableDocs ? true
+  # for tests
+, bash
+, bc
+, openssh # required by MPI
+, perl
+, perlPackages
+, python3
+, enableTests ? true
+}:
+
+assert withMPI -> trilinos.withMPI;
+
+stdenv.mkDerivation rec {
+  pname = "xyce";
+  version = "7.4.0";
+
+  srcs = [
+    # useing fetchurl or fetchFromGitHub doesn't include the manuals
+    # due to .gitattributes files
+    (fetchgit {
+      url = "https://github.com/Xyce/Xyce.git";
+      rev = "Release-${version}";
+      sha256 = "sha256-sOHjQEo4FqlDseTtxFVdLa0SI/VAf2OkwQV7QSL7SNM=";
+    })
+    (fetchFromGitHub {
+      owner = "Xyce";
+      repo = "Xyce_Regression";
+      rev = "Release-${version}";
+      sha256 = "sha256-kSGUaFarOHDNJ8kA/TAGkmzicm9O7cfJ7mGFZcbqCZM=";
+    })
+  ];
+
+  sourceRoot = "./Xyce";
+
+  preConfigure = "./bootstrap";
+
+  configureFlags = [
+    "CXXFLAGS=-O3"
+    "--enable-xyce-shareable"
+    "--enable-shared"
+    "--enable-stokhos"
+    "--enable-amesos2"
+  ] ++ lib.optionals withMPI [
+    "--enable-mpi"
+    "CXX=mpicxx"
+    "CC=mpicc"
+    "F77=mpif77"
+  ];
+
+  enableParallelBuilding = true;
+
+  nativeBuildInputs = [
+    autoconf
+    automake
+    gfortran
+    libtool_2
+  ] ++ lib.optionals enableDocs [
+    (texlive.combine {
+      inherit (texlive)
+        scheme-medium
+        koma-script
+        optional
+        framed
+        enumitem
+        multirow
+        preprint;
+    })
+  ];
+
+  buildInputs = [
+    bison
+    blas
+    flex
+    fftw
+    lapack
+    suitesparse
+    trilinos
+  ] ++ lib.optionals withMPI [ mpi ];
+
+  doCheck = enableTests;
+
+  postPatch = ''
+    pushd ../source
+    find Netlists -type f -regex ".*\.sh\|.*\.pl" -exec chmod ugo+x {} \;
+    # some tests generate new files, some overwrite netlists
+    find . -type d -exec chmod u+w {} \;
+    find . -type f -name "*.cir" -exec chmod u+w {} \;
+    patchShebangs Netlists/ TestScripts/
+    # patch script generating functions
+    sed -i -E 's|/usr/bin/env perl|${lib.escapeRegex perl.outPath}/bin/perl|'  \
+      TestScripts/XyceRegression/Testing/Netlists/RunOptions/runOptions.cir.sh
+    sed -i -E 's|/bin/sh|${lib.escapeRegex bash.outPath}/bin/sh|' \
+      TestScripts/XyceRegression/Testing/Netlists/RunOptions/runOptions.cir.sh
+    popd
+  '';
+
+  checkInputs = [
+    bc
+    perl
+    perlPackages.DigestMD5
+    (python3.withPackages (ps: with ps; [ numpy scipy ]))
+  ] ++ lib.optionals withMPI [ mpi openssh ];
+
+  checkPhase = ''
+    XYCE_BINARY="$(pwd)/src/Xyce"
+    EXECSTRING="${lib.optionalString withMPI "mpirun -np 2 "}$XYCE_BINARY"
+    TEST_ROOT="$(pwd)/../source"
+
+    # Honor the TMP variable
+    sed -i -E 's|/tmp|\$TMP|' $TEST_ROOT/TestScripts/suggestXyceTagList.sh
+
+    EXLUDE_TESTS_FILE=$TMP/exclude_tests.$$
+    # Gold standard has additional ":R" suffix in result column label
+    echo "Output/HB/hb-step-tecplot.cir" >> $EXLUDE_TESTS_FILE
+    # This test makes Xyce access /sys/class/net when run with MPI
+    ${lib.optionalString withMPI "echo \"CommandLine/command_line.cir\" >> $EXLUDE_TESTS_FILE"}
+
+    $TEST_ROOT/TestScripts/run_xyce_regression \
+      --output="$(pwd)/Xyce_Test" \
+      --xyce_test="''${TEST_ROOT}" \
+      --taglist="$($TEST_ROOT/TestScripts/suggestXyceTagList.sh "$XYCE_BINARY" | sed -E -e 's/TAGLIST=([^ ]+).*/\1/' -e '2,$d')" \
+      --resultfile="$(pwd)/test_results" \
+      --excludelist="$EXLUDE_TESTS_FILE" \
+      "''${EXECSTRING}"
+  '';
+
+  outputs = [ "out" "doc" ];
+
+  postInstall = lib.optionalString enableDocs ''
+    local docFiles=("doc/Users_Guide/Xyce_UG"
+      "doc/Reference_Guide/Xyce_RG"
+      "doc/Release_Notes/Release_Notes_${lib.versions.majorMinor version}/Release_Notes_${lib.versions.majorMinor version}")
+
+    # Release notes refer to an image not in the repo.
+    sed -i -E 's/\\includegraphics\[height=(0.5in)\]\{snllineblubrd\}/\\mbox\{\\rule\{0mm\}\{\1\}\}/' ''${docFiles[2]}.tex
+
+    install -d $doc/share/doc/${pname}-${version}/
+    for d in ''${docFiles[@]}; do
+      # Use a public document class
+      sed -i -E 's/\\documentclass\[11pt,report\]\{SANDreport\}/\\documentclass\[11pt,letterpaper\]\{scrreprt\}/' $d.tex
+      sed -i -E 's/\\usepackage\[sand\]\{optional\}/\\usepackage\[report\]\{optional\}/' $d.tex
+      pushd $(dirname $d)
+      make
+      install -t $doc/share/doc/${pname}-${version}/ $(basename $d.pdf)
+      popd
+    done
+  '';
+
+  meta = with lib; {
+    description = "High-performance analog circuit simulator";
+    longDescription = ''
+      Xyce is a SPICE-compatible, high-performance analog circuit simulator,
+      capable of solving extremely large circuit problems by supporting
+      large-scale parallel computing platforms.
+    '';
+    homepage = "https://xyce.sandia.gov";
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ fbeffa ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/development/libraries/science/math/trilinos/default.nix b/pkgs/development/libraries/science/math/trilinos/default.nix
new file mode 100644
index 0000000000000..19d2119622e9d
--- /dev/null
+++ b/pkgs/development/libraries/science/math/trilinos/default.nix
@@ -0,0 +1,100 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, blas
+, boost
+, cmake
+, gfortran
+, lapack
+, mpi
+, suitesparse
+, swig
+, withMPI ? false
+}:
+
+# NOTE: Not all packages are enabled.  We specifically enable the ones
+# required to build Xyce. If the need comes, we can enable more of them.
+
+let
+  flagsBase = ''
+    -G "Unix Makefiles"
+    -DBUILD_SHARED_LIBS=ON
+    -DCMAKE_CXX_FLAGS="-O3 -fPIC"
+    -DCMAKE_C_FLAGS="-O3 -fPIC"
+    -DCMAKE_Fortran_FLAGS="-O3 -fPIC"
+    -DTrilinos_ENABLE_NOX=ON
+    -DNOX_ENABLE_LOCA=ON
+    -DTrilinos_ENABLE_EpetraExt=ON
+    -DEpetraExt_BUILD_BTF=ON
+    -DEpetraExt_BUILD_EXPERIMENTAL=ON
+    -DEpetraExt_BUILD_GRAPH_REORDERINGS=ON
+    -DTrilinos_ENABLE_TrilinosCouplings=ON
+    -DTrilinos_ENABLE_Ifpack=ON
+    -DTrilinos_ENABLE_AztecOO=ON
+    -DTrilinos_ENABLE_Belos=ON
+    -DTrilinos_ENABLE_Teuchos=ON
+    -DTeuchos_ENABLE_COMPLEX=ON
+    -DTrilinos_ENABLE_Amesos=ON
+    -DAmesos_ENABLE_KLU=ON
+    -DTrilinos_ENABLE_Amesos2=ON
+    -DAmesos2_ENABLE_KLU2=ON
+    -DAmesos2_ENABLE_Basker=ON
+    -DTrilinos_ENABLE_Sacado=ON
+    -DTrilinos_ENABLE_Stokhos=ON
+    -DTrilinos_ENABLE_Kokkos=ON
+    -DTrilinos_ENABLE_ALL_OPTIONAL_PACKAGES=OFF
+    -DTrilinos_ENABLE_CXX11=ON
+    -DTPL_ENABLE_AMD=ON
+    -DTPL_ENABLE_BLAS=ON
+    -DTPL_ENABLE_LAPACK=ON
+  '';
+  flagsParallel = ''
+    -DCMAKE_C_COMPILER=mpicc
+    -DCMAKE_CXX_COMPILER=mpic++
+    -DCMAKE_Fortran_COMPILER=mpif77
+    -DTrilinos_ENABLE_Isorropia=ON
+    -DTrilinos_ENABLE_Zoltan=ON
+    -DTPL_ENABLE_MPI=ON
+  '';
+in
+stdenv.mkDerivation rec {
+  pname = "trilinos";
+  version = "12.12.1"; # Xyce 7.4 requires version 12.12.1
+
+  src = fetchFromGitHub {
+    owner = "trilinos";
+    repo = "Trilinos";
+    rev = "${pname}-release-${lib.replaceStrings [ "." ] [ "-" ] version}";
+    sha256 = "sha256-Nqjr7RAlUHm6vs87a1P84Y7BIZEL0Vs/A1Z6dykfv+o=";
+  };
+
+  nativeBuildInputs = [ cmake gfortran swig ];
+
+  buildInputs = [ blas boost lapack suitesparse ] ++ lib.optionals withMPI [ mpi ];
+
+  preConfigure =
+    if withMPI then ''
+      cmakeFlagsArray+=(${flagsBase} ${flagsParallel})
+    ''
+    else ''
+      cmakeFlagsArray+=(${flagsBase})
+    '';
+
+  passthru = {
+    inherit withMPI;
+  };
+
+  meta = with lib; {
+    description = "Engineering and scientific problems algorithms";
+    longDescription = ''
+      The Trilinos Project is an effort to develop algorithms and enabling
+      technologies within an object-oriented software framework for the
+      solution of large-scale, complex multi-physics engineering and scientific
+      problems.
+    '';
+    homepage = "https://trilinos.org";
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ fbeffa ];
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index ffc349f26efda..21b9facce2f91 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -32103,6 +32103,10 @@ with pkgs;
 
   sympow = callPackage ../development/libraries/science/math/sympow { };
 
+  trilinos = callPackage ../development/libraries/science/math/trilinos {};
+
+  trilinos-mpi = callPackage ../development/libraries/science/math/trilinos { withMPI = true; };
+
   ipopt = callPackage ../development/libraries/science/math/ipopt { };
 
   gmsh = callPackage ../applications/science/math/gmsh { };
@@ -32473,6 +32477,12 @@ with pkgs;
 
   xoscope = callPackage ../applications/science/electronics/xoscope { };
 
+  xyce = callPackage ../applications/science/electronics/xyce { };
+
+  xyce-parallel = callPackage ../applications/science/electronics/xyce {
+    withMPI = true;
+    trilinos = trilinos-mpi;
+  };
 
   ### SCIENCE / MATH