gnu: emacs-helm: Update to 3.8.7.
[jackhill/guix/guix.git] / gnu / packages / simulation.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017, 2018, 2019, 2020, 2021 Paul Garlick <pgarlick@tourbillion-technology.com>
3 ;;; Copyright © 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
4 ;;; Copyright © 2022 Eric Bavier <bavier@posteo.net>
5 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
12 ;;;
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
17 ;;;
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21 (define-module (gnu packages simulation)
22 #:use-module (gnu packages)
23 #:use-module (gnu packages algebra)
24 #:use-module (gnu packages admin)
25 #:use-module (gnu packages base)
26 #:use-module (gnu packages bash)
27 #:use-module (gnu packages bison)
28 #:use-module (gnu packages boost)
29 #:use-module (gnu packages check)
30 #:use-module (gnu packages cmake)
31 #:use-module (gnu packages compression)
32 #:use-module (gnu packages flex)
33 #:use-module (gnu packages gettext)
34 #:use-module (gnu packages gcc)
35 #:use-module (gnu packages gl)
36 #:use-module (gnu packages graphics)
37 #:use-module (gnu packages gtk)
38 #:use-module (gnu packages linux)
39 #:use-module (gnu packages m4)
40 #:use-module (gnu packages maths)
41 #:use-module (gnu packages mpi)
42 #:use-module (gnu packages multiprecision)
43 #:use-module (gnu packages ncurses)
44 #:use-module (gnu packages pkg-config)
45 #:use-module (gnu packages python)
46 #:use-module (gnu packages python-build)
47 #:use-module (gnu packages python-science)
48 #:use-module (gnu packages python-xyz)
49 #:use-module (gnu packages readline)
50 #:use-module (gnu packages tls)
51 #:use-module (gnu packages version-control)
52 #:use-module (gnu packages xml)
53 #:use-module (gnu packages xorg)
54 #:use-module (guix download)
55 #:use-module (guix gexp)
56 #:use-module (guix git-download)
57 #:use-module (guix svn-download)
58 #:use-module (guix build-system cmake)
59 #:use-module (guix build-system gnu)
60 #:use-module (guix build-system python)
61 #:use-module ((guix licenses) #:prefix license:)
62 #:use-module (guix packages)
63 #:use-module (guix utils)
64 #:use-module (ice-9 ftw)
65 #:use-module (ice-9 regex)
66 #:use-module (srfi srfi-1))
67
68 (define-public openfoam
69 (package
70 (name "openfoam")
71 (version "4.1")
72 (source
73 (origin
74 (method url-fetch)
75 (uri (string-append
76 "http://dl.openfoam.org/source/"
77 (string-map (lambda (x) (if (eq? x #\.) #\- x)) version)))
78 (file-name (string-append name "-" version ".tar.gz"))
79 (sha256
80 (base32 "0cgxh4h2hf50qbvvdg5miwc2nympb0nrv3md96vb3gbs9vk8vq9d"))
81 (patches (search-patches "openfoam-4.1-cleanup.patch"))
82 (modules '((guix build utils)))
83 (snippet
84 '(begin
85 ;; Include <sys/sysmacros.h>, which is where glibc >= 2.28 provides
86 ;; 'major' and 'minor'.
87 (substitute* "src/OSspecific/POSIX/fileStat.C"
88 (("#include <unistd\\.h>")
89 "#include <unistd.h>\n#include <sys/sysmacros.h>\n"))
90 #t))))
91 (build-system gnu-build-system)
92 (inputs
93 `(("boost" ,boost)
94 ("cgal" ,cgal)
95 ("flex" ,flex)
96 ("git" ,git)
97 ("gmp" ,gmp)
98 ("libxt" ,libxt)
99 ("metis" ,metis)
100 ("mpfr" ,mpfr)
101 ("ncurses" ,ncurses)
102 ("readline" ,readline)
103 ("scotch" ,pt-scotch32)
104 ("zlib" ,zlib)))
105 (native-inputs
106 (list bison))
107 (propagated-inputs
108 (list gzip gnuplot openmpi))
109 (outputs '("debug" ;~60MB
110 "out"))
111 (arguments
112 `( ;; Executable files and shared libraries are located in the 'platforms'
113 ;; subdirectory.
114 #:strip-directories (list (string-append
115 "lib/OpenFOAM-" ,version
116 "/platforms/linux64GccDPInt32Opt/bin")
117 (string-append
118 "lib/OpenFOAM-" ,version
119 "/platforms/linux64GccDPInt32Opt/lib"))
120 #:tests? #f ; no tests to run
121
122 #:modules ((ice-9 ftw)
123 (ice-9 regex)
124 (guix build gnu-build-system)
125 (guix build utils))
126
127 #:phases (modify-phases %standard-phases
128 (add-after 'unpack 'rename-build-directory
129 (lambda _
130 (chdir "..")
131 ;; Use 'OpenFOAM-version' convention to match the file
132 ;; name expectations in the build phase.
133 (let ((unpack-dir (string-append
134 (getcwd) "/"
135 (list-ref (scandir (getcwd) (lambda (name)
136 (string-match "^OpenFOAM" name))) 0)))
137 (build-dir (string-append
138 (getcwd) "/OpenFOAM-" ,version)))
139 (rename-file unpack-dir build-dir) ; rename build directory
140 (chdir (basename build-dir))) ; move to build directory
141 #t))
142 (delete 'configure) ; no configure phase
143 (replace 'build
144 (lambda _
145 (let ((libraries '("boost" "cgal" "gmp" "metis" "mpfr" "scotch")))
146 ;; set variables to define store paths
147 (for-each (lambda (library)
148 (setenv (string-append
149 (string-upcase library) "_ROOT")
150 (assoc-ref %build-inputs library))) libraries))
151 ;; set variables to define package versions
152 (setenv "SCOTCHVERSION" ,(package-version scotch))
153 (setenv "METISVERSION" ,(package-version metis))
154 ;; set variable to pass extra 'rpath' arguments to linker
155 (setenv "LDFLAGS"
156 (string-append
157 "-Wl,"
158 "-rpath=" %output "/lib/OpenFOAM-" ,version
159 "/platforms/linux64GccDPInt32Opt/lib,"
160 "-rpath=" %output "/lib/OpenFOAM-" ,version
161 "/platforms/linux64GccDPInt32Opt/lib/dummy"))
162 ;; compile OpenFOAM libraries and applications
163 (zero? (system (format #f
164 "source ./etc/bashrc && ./Allwmake -j~a"
165 (parallel-job-count))))))
166 (add-after 'build 'update-configuration-files
167 (lambda _
168 ;; record store paths and package versions in
169 ;; configuration files
170 (substitute* "etc/config.sh/CGAL"
171 (("$BOOST_ROOT") (getenv "BOOST_ROOT")))
172 (substitute* "etc/config.sh/CGAL"
173 (("$CGAL_ROOT") (getenv "CGAL_ROOT")))
174 (substitute* "etc/config.sh/metis"
175 (("$METIS_ROOT") (getenv "METIS_ROOT")))
176 (substitute* "etc/config.sh/metis"
177 (("$METISVERSION") (getenv "METISVERSION")))
178 (substitute* "etc/config.sh/scotch"
179 (("$SCOTCH_ROOT") (getenv "SCOTCH_ROOT")))
180 (substitute* "etc/config.sh/scotch"
181 (("$SCOTCHVERSION") (getenv "SCOTCHVERSION")))
182 (substitute* "etc/config.sh/settings"
183 (("$GMP_ROOT") (getenv "GMP_ROOT")))
184 (substitute* "etc/config.sh/settings"
185 (("$MPFR_ROOT") (getenv "MPFR_ROOT")))
186 ;; reset lockDir variable to refer to write-enabled
187 ;; directory
188 (substitute* "wmake/wmake"
189 ((" lockDir=.*$")
190 " lockDir=$HOME/.$WM_PROJECT/.wmake\n"))
191 (substitute* "wmake/wmakeScheduler"
192 (("lockDir=.*$")
193 "lockDir=$HOME/.$WM_PROJECT/.wmake\n"))
194 (substitute* "wmake/wmakeSchedulerUptime"
195 (("lockDir=.*$")
196 "lockDir=$HOME/.$WM_PROJECT/.wmake\n"))
197 #t))
198 (add-after 'build 'cleanup
199 ;; Avoid unncessary, voluminous object and dep files.
200 (lambda _
201 (delete-file-recursively
202 "platforms/linux64GccDPInt32Opt/src")
203 (delete-file-recursively
204 "platforms/linux64GccDPInt32OptSYSTEMOPENMPI")
205 (for-each delete-file (find-files "." "\\.o$"))
206 #t))
207 (replace 'install
208 (lambda _
209 ;; use 'OpenFOAM-version' convention
210 (let ((install-dir (string-append
211 %output "/lib/OpenFOAM-" ,version)))
212 (mkdir-p install-dir) ; create install directory
213 ;; move contents of build directory to install directory
214 (copy-recursively "." install-dir))))
215 (add-after 'install 'add-symbolic-link
216 (lambda _
217 ;; add symbolic link for standard 'bin' directory
218 (symlink
219 (string-append "./lib/OpenFOAM-" ,version
220 "/platforms/linux64GccDPInt32Opt/bin")
221 (string-append %output "/bin"))
222 #t)))))
223 ;; Note:
224 ;; Tutorial files are installed read-only in /gnu/store.
225 ;; To allow write permissions on files copied from the store a
226 ;; 'chmod' step is needed before running the applications. For
227 ;; example, from a user's login:
228 ;; $ source $GUIX_PROFILE/lib/OpenFOAM-4.1/etc/bashrc
229 ;; $ mkdir -p $FOAM_RUN
230 ;; $ cd $FOAM_RUN
231 ;; $ cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily .
232 ;; $ cd pitzDaily
233 ;; $ chmod -R u+w .
234 ;; $ blockMesh
235 (synopsis "Framework for numerical simulation of fluid flow")
236 (description "OpenFOAM provides a set of solvers and methods for tackling
237 problems in the field of Computational Fluid Dynamics (CFD). It is written in
238 C++. Governing equations such as the Navier-Stokes equations can be solved in
239 integral form. Physical processes such as phase change, droplet transport and
240 chemical reaction can be modelled. Numerical methods are included to deal with
241 sharp gradients, such as those encountered in flows with shock waves and flows
242 with gas/liquid interfaces. Large problems may be split into smaller, connected
243 problems for efficient solution on parallel systems.")
244 (license license:gpl3+)
245 (home-page "https://openfoam.org")))
246
247 (define-public python-fenics-dijitso
248 (package
249 (name "python-fenics-dijitso")
250 (version "2019.1.0")
251 (source
252 (origin
253 (method url-fetch)
254 (uri (pypi-uri "fenics-dijitso" version))
255 (sha256
256 (base32
257 "0lhqsq8ypdak0ahr2jnyvg07yrqp6wicjxi6k56zx24wp3qg60sc"))))
258 (build-system python-build-system)
259 (inputs
260 (list openmpi python-numpy))
261 (native-inputs
262 (list python-pytest-cov))
263 (propagated-inputs
264 (list python-mpi4py))
265 (arguments
266 `(#:phases
267 (modify-phases %standard-phases
268 (add-after 'build 'mpi-setup
269 ,%openmpi-setup)
270 (replace 'check
271 (lambda _
272 (setenv "HOME" "/tmp")
273 (with-directory-excursion "test"
274 ;; Disable parallel tests to avoid race condition. See
275 ;; https://github.com/pytest-dev/pytest-cov/issues/237.
276 (substitute* "runtests.sh"
277 (("for p in 1 4 8 16; do")
278 "for p in 1; do"))
279 (invoke "./runtests.sh")))))))
280 (home-page "https://bitbucket.org/fenics-project/dijitso/")
281 (synopsis "Distributed just-in-time building of shared libraries")
282 (description
283 "Dijitso provides a core component of the @code{FEniCS} framework,
284 namely the just-in-time compilation of C++ code that is generated from
285 Python modules. It is called from within a C++ library, using ctypes
286 to import the dynamic shared library directly.
287
288 As long as the compiled code can provide a simple factory function to
289 a class implementing a predefined C++ interface, there is no limit to
290 the complexity of that interface. Parallel support depends on the
291 @code{mpi4py} interface.")
292 (license license:lgpl3+)))
293
294 (define-public python-fenics-ufl
295 (package
296 (name "python-fenics-ufl")
297 (version "2019.1.0")
298 (source
299 (origin
300 (method url-fetch)
301 (uri (pypi-uri "fenics-ufl" version))
302 (sha256
303 (base32
304 "10dz8x3lm68x2w3kkqcjask38h0zkhhak26jdbkppr8g9y8wny7p"))))
305 (build-system python-build-system)
306 (inputs
307 (list python-numpy))
308 (native-inputs
309 (list python-pytest))
310 (arguments
311 '(#:phases
312 (modify-phases %standard-phases
313 (replace 'check
314 (lambda _
315 (invoke "py.test" "test"))))))
316 (home-page "https://bitbucket.org/fenics-project/ufl/")
317 (synopsis "Unified language for form-compilers")
318 (description "The Unified Form Language (UFL) is a domain specific
319 language for declaration of finite element discretizations of
320 variational forms. More precisely, it defines a flexible interface
321 for choosing finite element spaces and defining expressions for weak
322 forms in a notation close to mathematical notation.
323
324 UFL is part of the FEniCS Project.")
325 (license license:lgpl3+)))
326
327 (define-public python-fenics-fiat
328 (package
329 (name "python-fenics-fiat")
330 (version "2019.1.0")
331 (source
332 (origin
333 (method url-fetch)
334 (uri (pypi-uri "fenics-fiat" version))
335 (sha256
336 (base32
337 "13sc7lma3d2mh43an7i4kkdbbk4cmvxjk45wi43xnjd7qc38zg4b"))))
338 (build-system python-build-system)
339 (native-inputs
340 (list python-pytest))
341 (propagated-inputs
342 (list python-numpy python-sympy))
343 (arguments
344 '(#:phases
345 (modify-phases %standard-phases
346 (replace 'check
347 (lambda _
348 (with-directory-excursion "test"
349 ;; FIXME: three FIAT test modules are known to fail
350 ;; with recent versions of pytest (>= 4). These are
351 ;; skipped for FIAT version 2019.1.0 pending an
352 ;; upstream pull request. For details see request #59
353 ;; at https://bitbucket.org/fenics-project/fiat/.
354 (invoke "py.test" "unit/"
355 "--ignore=unit/test_fiat.py"
356 "--ignore=unit/test_quadrature.py"
357 "--ignore=unit/test_reference_element.py")))))))
358 (home-page "https://bitbucket.org/fenics-project/fiat/")
359 (synopsis "Tabulation of finite element function spaces")
360 (description
361 "The FInite element Automatic Tabulator (FIAT) supports
362 generation of arbitrary order instances of the Lagrange elements on
363 lines, triangles, and tetrahedra. It is also capable of generating
364 arbitrary order instances of Jacobi-type quadrature rules on the same
365 element shapes. Further, H(div) and H(curl) conforming finite element
366 spaces such as the families of Raviart-Thomas, Brezzi-Douglas-Marini
367 and Nedelec are supported on triangles and tetrahedra. Upcoming
368 versions will also support Hermite and nonconforming elements.
369
370 FIAT is part of the FEniCS Project.")
371 (license license:lgpl3+)))
372
373 (define-public python-fenics-ffc
374 (package
375 (name "python-fenics-ffc")
376 (version "2019.1.0.post0")
377 (source
378 (origin
379 (method url-fetch)
380 (uri (pypi-uri "fenics-ffc" version))
381 (sha256
382 (base32
383 "1f2a44ha65fg3a1prrbrsz4dgvibsv0j5c3pi2m52zi93bhwwgg9"))))
384 (build-system python-build-system)
385 (native-inputs
386 (list python-pytest))
387 (propagated-inputs
388 (list python-fenics-dijitso python-fenics-fiat python-fenics-ufl))
389 (arguments
390 '(#:phases
391 (modify-phases %standard-phases
392 (replace 'check
393 (lambda _
394 (setenv "HOME" (getcwd))
395 (with-directory-excursion "test"
396 ;; FIXME: the tests in subdirectory
397 ;; 'unit/ufc/finite_element' require the ffc_factory
398 ;; extension module. This module, located in the 'libs'
399 ;; subdirectory, needs to be built and made accessible
400 ;; prior to running the tests.
401 (invoke "py.test" "unit/" "--ignore=unit/ufc/")
402 (with-directory-excursion "uflacs"
403 (invoke "py.test" "unit/")))
404 #t)))))
405 (home-page "https://bitbucket.org/fenics-project/ffc/")
406 (synopsis "Compiler for finite element variational forms")
407 (description "The FEniCS Form Compiler (FFC) is a compiler for
408 finite element variational forms. From a high-level description of
409 the form, it generates efficient low-level C++ code that can be used
410 to assemble the corresponding discrete operator (tensor). In
411 particular, a bilinear form may be assembled into a matrix and a
412 linear form may be assembled into a vector. FFC may be used either
413 from the command line (by invoking the @code{ffc} command) or as a
414 Python module (@code{import ffc}).
415
416 FFC is part of the FEniCS Project.")
417 ;; There are two files released with a public domain licence;
418 ;; ufc.h and ufc_geometry.h, in subdirectory 'ffc/backends/ufc'.
419 (license (list license:public-domain license:lgpl3+))))
420
421 (define-public fenics-dolfin
422 (package
423 (name "fenics-dolfin")
424 (version "2019.1.0.post0")
425 (source
426 (origin
427 (method url-fetch)
428 (uri (string-append
429 "https://bitbucket.org/fenics-project/dolfin/get/"
430 version ".tar.gz"))
431 (file-name (string-append name "-" version ".tar.gz"))
432 (sha256
433 (base32
434 "1m91hwcq5gfj4qqswp8l8kj58nia48f0n4kq13w0xqj4biq7rla0"))
435 (patches (search-patches "fenics-dolfin-algorithm.patch"
436 "fenics-dolfin-demo-init.patch"
437 "fenics-dolfin-boost.patch"
438 "fenics-dolfin-config-slepc.patch"))
439 (modules '((guix build utils)))
440 (snippet
441 '(begin
442 ;; Make sure we don't use the bundled test framework.
443 (delete-file-recursively "test/unit/cpp/catch")
444 (substitute* "test/unit/cpp/main.cpp"
445 ;; Use standard search paths for 'catch' header file.
446 (("#include.*")
447 "#include <catch.hpp>\n"))
448 (substitute* "test/unit/cpp/CMakeLists.txt"
449 ;; Specify directory to find the header file.
450 (("(^set\\(CATCH_INCLUDE_DIR ).*(/catch\\))" _ front back)
451 (string-append front
452 "$ENV{CATCH_DIR}/include" back "\n")))))))
453 (build-system cmake-build-system)
454 (inputs
455 `(("blas" ,openblas)
456 ("boost" ,boost)
457 ("eigen" ,eigen)
458 ("hdf5" ,hdf5-parallel-openmpi)
459 ("lapack" ,lapack)
460 ("libxml2" ,libxml2)
461 ("openmpi" ,openmpi)
462 ("python" ,python-3)
463 ("scotch" ,pt-scotch32)
464 ("suitesparse" ,suitesparse)
465 ("sundials" ,sundials-openmpi)
466 ("zlib" ,zlib)))
467 (native-inputs
468 `(("catch" ,catch-framework2-1)
469 ("pkg-config" ,pkg-config)))
470 (propagated-inputs
471 `(("ffc" ,python-fenics-ffc)
472 ("petsc" ,petsc-openmpi)
473 ("slepc" ,slepc-openmpi)))
474 (arguments
475 `(#:configure-flags
476 `("-DDOLFIN_ENABLE_DOCS:BOOL=OFF"
477 "-DDOLFIN_ENABLE_HDF5:BOOL=ON"
478 "-DDOLFIN_ENABLE_MPI:BOOL=ON"
479 "-DDOLFIN_ENABLE_PARMETIS:BOOL=OFF"
480 "-DDOLFIN_ENABLE_SCOTCH:BOOL=ON"
481 "-DDOLFIN_ENABLE_SUNDIALS:BOOL=ON"
482 "-DDOLFIN_ENABLE_TRILINOS:BOOL=OFF")
483 #:phases
484 (modify-phases %standard-phases
485 (add-after 'patch-usr-bin-file 'mpi-setup
486 ,%openmpi-setup)
487 (add-after 'patch-source-shebangs 'set-paths
488 (lambda _
489 ;; Define paths to store locations.
490 (setenv "BLAS_DIR" (assoc-ref %build-inputs "blas"))
491 (setenv "CATCH_DIR" (assoc-ref %build-inputs "catch"))
492 (setenv "LAPACK_DIR" (assoc-ref %build-inputs "lapack"))
493 (setenv "PETSC_DIR" (assoc-ref %build-inputs "petsc"))
494 (setenv "SLEPC_DIR" (assoc-ref %build-inputs "slepc"))
495 (setenv "SCOTCH_DIR" (assoc-ref %build-inputs "scotch"))
496 (setenv "SUNDIALS_DIR" (assoc-ref %build-inputs "sundials"))
497 (setenv "UMFPACK_DIR" (assoc-ref %build-inputs "suitesparse"))))
498 (add-before 'check 'pre-check
499 (lambda _
500 ;; The Dolfin repository uses git-lfs, whereby web links are
501 ;; substituted for large files. Guix does not currently support
502 ;; git-lfs, so only the links are downloaded. The tests that
503 ;; require the absent meshes cannot run and are skipped.
504 ;;
505 ;; One serial test fails and is skipped.
506 ;; i) demo_multimesh-stokes_serial:
507 ;; Warning: Found no facets matching domain for boundary
508 ;; condition.
509 ;;
510 ;; One mpi test fails and is skipped.
511 ;; i) demo_stokes-iterative_mpi:
512 ;; The MPI_Comm_rank() function was called before MPI_INIT was
513 ;; invoked
514 (call-with-output-file "CTestCustom.cmake"
515 (lambda (port)
516 (display
517 (string-append
518 "set(CTEST_CUSTOM_TESTS_IGNORE "
519 "demo_bcs_serial "
520 "demo_bcs_mpi "
521 "demo_eigenvalue_serial "
522 "demo_eigenvalue_mpi "
523 "demo_navier-stokes_serial "
524 "demo_navier-stokes_mpi "
525 "demo_stokes-taylor-hood_serial "
526 "demo_stokes-taylor-hood_mpi "
527 "demo_subdomains_serial "
528 "demo_advection-diffusion_serial "
529 "demo_advection-diffusion_mpi "
530 "demo_auto-adaptive-navier-stokes_serial "
531 "demo_contact-vi-snes_serial "
532 "demo_contact-vi-snes_mpi "
533 "demo_contact-vi-tao_serial "
534 "demo_contact-vi-tao_mpi "
535 "demo_curl-curl_serial "
536 "demo_curl-curl_mpi "
537 "demo_dg-advection-diffusion_serial "
538 "demo_dg-advection-diffusion_mpi "
539 "demo_elasticity_serial "
540 "demo_elasticity_mpi "
541 "demo_elastodynamics_serial "
542 "demo_elastodynamics_mpi "
543 "demo_lift-drag_serial "
544 "demo_lift-drag_mpi "
545 "demo_mesh-quality_serial "
546 "demo_mesh-quality_mpi "
547 "demo_multimesh-stokes_serial "
548 ")\n") port)))))
549 (replace 'check
550 (lambda* (#:key tests? #:allow-other-keys)
551 (when tests?
552 (invoke "make" "unittests")
553 (invoke "make" "demos")
554 (invoke "ctest" "-R" "unittests")
555 (invoke "ctest" "-R" "demo" "-R" "serial")
556 (invoke "ctest" "-R" "demo" "-R" "mpi")))))))
557 (home-page "https://bitbucket.org/fenics-project/dolfin/")
558 (synopsis "Problem solving environment for differential equations")
559 (description
560 "DOLFIN is a computational framework for finding numerical
561 solutions to problems described by differential equations. Numerical
562 models in DOLFIN are constructed using general families of finite
563 elements. Data structures are provided for discretizing the governing
564 system on a computational mesh. A compact syntax, similar to
565 mathematical notation, is made available for defining function spaces
566 and expressing variational forms. Interfaces to specialized matrix
567 solvers are provided for solving the resultant linear systems.
568
569 @code{fenics-dolfin} is part of the FEniCS project. It is the C++
570 user interface to the FEniCS core components and external libraries.")
571 ;; The source code for the DOLFIN C++ library is licensed under the
572 ;; GNU Lesser General Public License, version 3 or later, with the
573 ;; following exceptions:
574 ;;
575 ;; public-domain: dolfin/geometry/predicates.cpp
576 ;; dolfin/geometry/predicates.h
577 ;;
578 ;; zlib: dolfin/io/base64.cpp
579 ;; dolfin/io/base64.h
580 ;;
581 ;; expat: dolfin/io/pugiconfig.hpp
582 ;; dolfin/io/pugixml.cpp
583 ;; dolfin/io/pugixml.hpp
584 (license (list license:public-domain
585 license:zlib
586 license:expat
587 license:lgpl3+))))
588
589 (define-public fenics
590 (package/inherit fenics-dolfin
591 (name "fenics")
592 (build-system python-build-system)
593 (inputs
594 `(("pybind11" ,pybind11)
595 ("python-matplotlib" ,python-matplotlib)
596 ,@(alist-delete "python" (package-inputs fenics-dolfin))))
597 (native-inputs
598 `(("cmake" ,cmake-minimal)
599 ("ply" ,python-ply)
600 ("pytest" ,python-pytest)
601 ("python-decorator" ,python-decorator)
602 ("python-pkgconfig" ,python-pkgconfig)
603 ,@(package-native-inputs fenics-dolfin)))
604 (propagated-inputs
605 `(("dolfin" ,fenics-dolfin)
606 ("petsc4py" ,python-petsc4py)
607 ("slepc4py" ,python-slepc4py)))
608 (arguments
609 `(#:phases
610 (modify-phases %standard-phases
611 (add-after 'unpack 'relax-requirements
612 (lambda _
613 (substitute* "python/setup.py"
614 (("pybind11==") "pybind11>="))))
615 (add-after 'patch-source-shebangs 'set-paths
616 (lambda _
617 ;; Define paths to store locations.
618 (setenv "PYBIND11_DIR" (assoc-ref %build-inputs "pybind11"))
619 ;; Move to python sub-directory.
620 (chdir "python")))
621 (add-after 'build 'mpi-setup
622 ,%openmpi-setup)
623 (add-before 'check 'pre-check
624 (lambda _
625 ;; Exclude three tests that generate
626 ;; 'NotImplementedError' in matplotlib version 3.1.2.
627 ;; See
628 ;; <https://github.com/matplotlib/matplotlib/issues/15382>.
629 ;; Also exclude tests that require meshes supplied by
630 ;; git-lfs.
631 (substitute* "demo/test.py"
632 (("(.*stem !.*)" line)
633 (string-append
634 line "\n"
635 "excludeList = [\n"
636 "'built-in-meshes', \n"
637 "'hyperelasticity', \n"
638 "'elasticity', \n"
639 "'multimesh-quadrature', \n"
640 "'multimesh-marking', \n"
641 "'mixed-poisson-sphere', \n"
642 "'mesh-quality', \n"
643 "'lift-drag', \n"
644 "'elastodynamics', \n"
645 "'dg-advection-diffusion', \n"
646 "'curl-curl', \n"
647 "'contact-vi-tao', \n"
648 "'contact-vi-snes', \n"
649 "'collision-detection', \n"
650 "'buckling-tao', \n"
651 "'auto-adaptive-navier-stokes', \n"
652 "'advection-diffusion', \n"
653 "'subdomains', \n"
654 "'stokes-taylor-hood', \n"
655 "'stokes-mini', \n"
656 "'navier-stokes', \n"
657 "'eigenvalue']\n"
658 "demos = ["
659 "d for d in demos if d[0].stem not in "
660 "excludeList]\n")))
661 (setenv "HOME" (getcwd))
662 ;; Restrict OpenBLAS to MPI-only in preference to MPI+OpenMP.
663 (setenv "OPENBLAS_NUM_THREADS" "1")))
664 (replace 'check
665 (lambda* (#:key tests? #:allow-other-keys)
666 (when tests?
667 (with-directory-excursion "test"
668 (invoke
669 "pytest" "unit"
670 ;; The test test_snes_set_from_options() in the file
671 ;; unit/nls/test_PETScSNES_solver.py fails and is ignored.
672 "--ignore" "unit/nls/test_PETScSNES_solver.py"
673 ;; Fails with a segfault.
674 "--ignore" "unit/io/test_XDMF.py")))))
675 (add-after 'install 'install-demo-files
676 (lambda* (#:key outputs #:allow-other-keys)
677 (let* ((demos (string-append
678 (assoc-ref outputs "out")
679 "/share/python-dolfin/demo")))
680 (mkdir-p demos)
681 (with-directory-excursion "demo"
682 (for-each (lambda (file)
683 (let* ((dir (dirname file))
684 (tgt-dir (string-append demos "/" dir)))
685 (unless (equal? "." dir)
686 (mkdir-p tgt-dir)
687 (install-file file tgt-dir))))
688 (find-files "." ".*\\.(py|gz|xdmf)$")))))))))
689 (home-page "https://fenicsproject.org/")
690 (synopsis "High-level environment for solving differential equations")
691 (description
692 "@code{fenics} is a computing platform for solving general classes of
693 problems that involve differential equations. @code{fenics} facilitates
694 access to efficient methods for dealing with ordinary differential
695 equations (ODEs) and partial differential equations (PDEs). Systems of
696 equations such as these are commonly encountered in areas of engineering,
697 mathematics and the physical sciences. It is particularly well-suited to
698 problems that can be solved using the Finite Element Method (FEM).
699
700 @code{fenics} is the top level of the set of packages that are developed
701 within the FEniCS project. It provides the python user interface to the
702 FEniCS core components and external libraries.")
703 (license license:lgpl3+)))
704
705 (define-public fullswof-2d
706 (let ((revision 505)
707 (release "1.09.01"))
708 (package
709 (name "fullswof-2d")
710 (version release)
711 (source (origin
712 (method svn-fetch)
713 (uri (svn-reference
714 (url (string-append "https://subversion.renater.fr/"
715 "anonscm/svn/fullswof-2d/tags/"
716 "release-" version))
717 (revision revision)))
718 (file-name (string-append "fullswof-2d-" version "-checkout"))
719 (sha256
720 (base32
721 "16v08dx7h7n4wyddzbwimazwyj74ynis12mpjfkay4243npy44b8"))))
722 (build-system gnu-build-system)
723 (native-inputs
724 (list inetutils)) ; for 'hostname', used in the check phase
725 (arguments
726 `(#:phases
727 (modify-phases %standard-phases
728 (delete 'configure) ; no configure script
729 (add-after 'build 'build-tools
730 (lambda _
731 (with-directory-excursion "Tools/ConvertFormat"
732 (invoke "make" "../../bin/asc2xyz")
733 (invoke "make" "../../bin/xyz2asc"))
734 (with-directory-excursion "Tools/ExtractWindow"
735 (invoke "make" "../../bin/cropxyz"))
736 #t))
737 (replace 'check ; no check target
738 (lambda _
739 (invoke "make" "benchref")))
740 (replace 'install ; no install target
741 (lambda* (#:key outputs #:allow-other-keys)
742 (let* ((out (assoc-ref outputs "out"))
743 (bin (string-append out "/bin"))
744 (doc (string-append
745 out "/share/doc/" ,name "-" ,version))
746 (examples (string-append doc "/Examples")))
747 (with-directory-excursion "bin"
748 (for-each (lambda (binary) (install-file binary bin))
749 (list "asc2xyz" "xyz2asc" "cropxyz"
750 "FullSWOF_2D")))
751 (with-directory-excursion "doc"
752 (for-each (lambda (pdf) (install-file pdf doc))
753 (list "Documentation.pdf" "refman.pdf")))
754 (with-directory-excursion "Tools"
755 (for-each (lambda (dir)
756 (copy-file
757 (string-append dir "/README.txt")
758 (string-append doc "/README_" dir ".txt")))
759 (list "ConvertFormat" "ExtractWindow")))
760 (copy-recursively "Examples" examples)
761 #t))))))
762 (home-page "https://www.idpoisson.fr/fullswof/")
763 (synopsis "Two dimensional flow solver for flood modelling")
764 (description "@code{FullSWOF_2d} is a numerical tool for solving
765 the shallow water equations on structured grids. The name FullSWOF
766 refers to the Full form of the Shallow Water equations for Overland
767 Flow. The discretized system of equations is solved using the finite
768 volume method. A choice of shock-capturing methods is available to
769 locate the transition boundaries between the wet areas and the dry
770 areas in the model. A semi-implicit method is used to advance the
771 solution in time. The tool is typically applied to the modelling of
772 river flooding.")
773 (license license:cecill))))
774
775 (define-public python-meshio
776 (package
777 (name "python-meshio")
778 (version "5.3.4")
779 (source
780 (origin
781 (method url-fetch)
782 (uri (pypi-uri "meshio" version))
783 (sha256
784 (base32
785 "1w39qcg0rw5kb04j7sa45fnqd6k20fsdgrf62cmw2ygjgwnnjh72"))
786 (snippet
787 '(let ((file (open-file "setup.py" "a")))
788 (display "from setuptools import setup\nsetup()" file)
789 (close-port file)))))
790 (build-system python-build-system)
791 (inputs
792 (list python-h5py
793 python-netcdf4))
794 (native-inputs
795 (list python-pytest))
796 (propagated-inputs
797 (list python-importlib-metadata
798 python-numpy
799 python-rich))
800 (arguments
801 '(#:phases
802 (modify-phases %standard-phases
803 (replace 'check
804 (lambda* (#:key tests? #:allow-other-keys)
805 (when tests?
806 (invoke "python" "-m" "pytest" "-v" "tests")))))))
807 (home-page "https://github.com/nschloe/meshio")
808 (synopsis "I/O for mesh files")
809 (description "There are various file formats available for
810 representing unstructured meshes and mesh data. The @code{meshio}
811 package is able to read and write mesh files in many formats and to
812 convert files from one format to another. Formats such as cgns, h5m,
813 gmsh, xdmf and vtk are supported. The package provides command-line
814 tools and a collection of Python modules for programmatic use.")
815 (license license:expat)))
816
817 (define-public python-pygmsh
818 (package
819 (name "python-pygmsh")
820 (version "7.1.17")
821 (source
822 (origin
823 (method git-fetch)
824 (uri (git-reference
825 (url "https://github.com/nschloe/pygmsh")
826 (commit (string-append "v" version))))
827 (file-name (git-file-name name version))
828 (sha256
829 (base32
830 "11flp2c4ynk1fhanf4mqyzrpd0gjbnv6afrwwc7xi3mb6ms69lr0"))))
831 (build-system python-build-system)
832 (arguments
833 (list
834 #:phases
835 #~(modify-phases %standard-phases
836 (add-after 'unpack 'workaround-gmsh-detection-failure
837 (lambda _
838 ;; Due to lack of metadata, the gmsh Python package is not
839 ;; detected although importable.
840 (substitute* "pyproject.toml"
841 (("\"gmsh\",") ""))))
842 ;; XXX: PEP 517 manual build copied from python-isort.
843 (replace 'build
844 (lambda _
845 (invoke "python" "-m" "build" "--wheel" "--no-isolation" ".")))
846 (replace 'check
847 (lambda* (#:key tests? #:allow-other-keys)
848 (when tests?
849 (invoke "pytest" "-v" "tests"))))
850 (replace 'install
851 (lambda _
852 (let ((whl (car (find-files "dist" "\\.whl$"))))
853 (invoke "pip" "--no-cache-dir" "--no-input"
854 "install" "--no-deps" "--prefix" #$output whl)))))))
855 (native-inputs (list python-pypa-build python-flit-core python-pytest))
856 (propagated-inputs (list gmsh python-meshio python-numpy))
857 (home-page "https://github.com/nschloe/pygmsh")
858 (synopsis "Python frontend for Gmsh")
859 (description "The goal of @code{pygmsh} is to combine the power of
860 Gmsh with the versatility of Python. The package generalises many of
861 the methods and functions that comprise the Gmsh Python API. In this
862 way the meshing of complex geometries using high-level abstractions is
863 made possible. The package provides a Python library together with a
864 command-line utility for mesh optimisation.")
865 (license license:gpl3+)))
866
867 (define-public python-dolfin-adjoint
868 (package
869 (name "python-dolfin-adjoint")
870 (version "2019.1.0")
871 (source
872 (origin
873 (method git-fetch)
874 (uri (git-reference
875 (url "https://github.com/dolfin-adjoint/pyadjoint")
876 (commit version)))
877 (file-name (git-file-name name version))
878 (sha256
879 (base32
880 "0xhy76a5f33hz94wc9g2mc5qmwkxfccbbc6yxl7psm130afp8lhn"))
881 (modules '((guix build utils)))
882 (snippet
883 '(begin
884 ;; One of the migration tests attempts to call openmpi
885 ;; recursively and fails. See
886 ;; https://bitbucket.org/mpi4py/mpi4py/issues/95. Run the
887 ;; test sequentially instead.
888 (with-directory-excursion "tests/migration/optimal_control_mms"
889 (substitute* "test_optimal_control_mms.py"
890 (("\\\"mpirun\\\", \\\"-n\\\", \\\"2\\\", ") "")))
891 ;; Result files are regenerated in the check phase.
892 (delete-file-recursively
893 "tests/migration/viscoelasticity/test-results")
894 #t))))
895 (build-system python-build-system)
896 (inputs
897 (list fenics openmpi pybind11))
898 (native-inputs
899 (list pkg-config
900 python-coverage
901 python-decorator
902 python-flake8
903 python-pkgconfig
904 python-pytest))
905 (propagated-inputs
906 `(("scipy" ,python-scipy)))
907 (arguments
908 `(#:phases
909 (modify-phases %standard-phases
910 (add-after 'build 'mpi-setup
911 ,%openmpi-setup)
912 (add-after 'install 'install-doc
913 (lambda* (#:key outputs #:allow-other-keys)
914 (let* ((doc (string-append (assoc-ref outputs "out")
915 "/share/doc/" ,name "-"
916 ,version))
917 (examples (string-append doc "/examples")))
918 (mkdir-p examples)
919 (copy-recursively "examples" examples))
920 #t))
921 (replace 'check
922 (lambda* (#:key inputs outputs tests? #:allow-other-keys)
923 (when tests?
924 (add-installed-pythonpath inputs outputs)
925 (setenv "HOME" (getcwd))
926 (and (invoke "py.test" "-v" "tests/fenics_adjoint")
927 (invoke "py.test" "-v" "tests/migration")
928 (invoke "py.test" "-v" "tests/pyadjoint")))
929 #t)))))
930 (home-page "http://www.dolfin-adjoint.org")
931 (synopsis "Automatic differentiation library")
932 (description "@code{python-dolfin-adjoint} is a solver of
933 differential equations associated with a governing system and a
934 functional of interest. Working from the forward model the solver
935 automatically derives the discrete adjoint and tangent linear models.
936 These additional models are key ingredients in many algorithms such as
937 data assimilation, optimal control, sensitivity analysis, design
938 optimisation and error estimation. The dolfin-adjoint project
939 provides the necessary tools and data structures for cases where the
940 forward model is implemented in @code{fenics} or
941 @url{https://firedrakeproject.org,firedrake}.")
942 (license license:lgpl3)))