projects/guix·blob python-team · refs

1661 lines · 74.7 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2017, 2018, 2019, 2020, 2021 Paul Garlick <[email protected]>
3;;; Copyright © 2021, 2022 Maxim Cournoyer <[email protected]>
4;;; Copyright © 2022 Eric Bavier <[email protected]>
5;;; Copyright © 2022 Liliana Marie Prikler <[email protected]>
6;;; Copyright © 2023-2026 Reza Housseini <[email protected]>
7;;; Copyright © 2024 Ricardo Wurmus <[email protected]>
8;;; Copyright © 2024-2025 Sharlatan Hellseher <[email protected]>
9;;; Copyright © 2025 Francisco-Galindo <[email protected]>
10;;;
11;;; This file is part of GNU Guix.
12;;;
13;;; GNU Guix is free software; you can redistribute it and/or modify it
14;;; under the terms of the GNU General Public License as published by
15;;; the Free Software Foundation; either version 3 of the License, or (at
16;;; your option) any later version.
17;;;
18;;; GNU Guix is distributed in the hope that it will be useful, but
19;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21;;; GNU General Public License for more details.
22;;;
23;;; You should have received a copy of the GNU General Public License
24;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25
26(define-module (gnu packages simulation)
27 #:use-module (gnu packages)
28 #:use-module (gnu packages algebra)
29 #:use-module (gnu packages admin)
30 #:use-module (gnu packages base)
31 #:use-module (gnu packages bash)
32 #:use-module (gnu packages bison)
33 #:use-module (gnu packages boost)
34 #:use-module (gnu packages check)
35 #:use-module (gnu packages cmake)
36 #:use-module (gnu packages compression)
37 #:use-module (gnu packages cpp)
38 #:use-module (gnu packages curl)
39 #:use-module (gnu packages engineering)
40 #:use-module (gnu packages compiler-tools)
41 #:use-module (gnu packages fontutils)
42 #:use-module (gnu packages gettext)
43 #:use-module (gnu packages gcc)
44 #:use-module (gnu packages geo)
45 #:use-module (gnu packages gl)
46 #:use-module (gnu packages graphics)
47 #:use-module (gnu packages gtk)
48 #:use-module (gnu packages image)
49 #:use-module (gnu packages iso-codes)
50 #:use-module (gnu packages image-processing)
51 #:use-module (gnu packages linux)
52 #:use-module (gnu packages m4)
53 #:use-module (gnu packages maths)
54 #:use-module (gnu packages mpi)
55 #:use-module (gnu packages multiprecision)
56 #:use-module (gnu packages ncurses)
57 #:use-module (gnu packages pdf)
58 #:use-module (gnu packages pkg-config)
59 #:use-module (gnu packages pretty-print)
60 #:use-module (gnu packages protobuf)
61 #:use-module (gnu packages python)
62 #:use-module (gnu packages python-build)
63 #:use-module (gnu packages python-science)
64 #:use-module (gnu packages python-xyz)
65 #:use-module (gnu packages qt)
66 #:use-module (gnu packages readline)
67 #:use-module (gnu packages serialization)
68 #:use-module (gnu packages sqlite)
69 #:use-module (gnu packages ssh)
70 #:use-module (gnu packages textutils)
71 #:use-module (gnu packages tls)
72 #:use-module (gnu packages version-control)
73 #:use-module (gnu packages video)
74 #:use-module (gnu packages xiph)
75 #:use-module (gnu packages xml)
76 #:use-module (gnu packages xorg)
77 #:use-module (guix download)
78 #:use-module (guix gexp)
79 #:use-module (guix git-download)
80 #:use-module (guix svn-download)
81 #:use-module (guix build-system cmake)
82 #:use-module (guix build-system gnu)
83 #:use-module (guix build-system pyproject)
84 #:use-module ((guix licenses) #:prefix license:)
85 #:use-module (guix packages)
86 #:use-module (guix gexp)
87 #:use-module (guix utils)
88 #:use-module (ice-9 ftw)
89 #:use-module (ice-9 match)
90 #:use-module (ice-9 regex)
91 #:use-module (srfi srfi-1))
92
93(define-public openfoam-org
94 (package
95 (name "openfoam-org")
96 (version "14")
97 (source
98 (origin
99 (method git-fetch)
100 (uri (git-reference
101 (url "https://github.com/OpenFOAM/OpenFOAM-dev")
102 (commit (string-append "version-" version))))
103 (file-name (git-file-name name version))
104 (sha256
105 (base32 "11dbxzhnml51vjdq4v91y4vc67hkm84lpj4px8i9nrh3v756z230"))))
106 (build-system gnu-build-system)
107 (native-inputs (list bison flex git))
108 (inputs (list bash-completion
109 boost
110 cgal
111 cgns
112 cli11
113 cmake-minimal
114 coreutils
115 curl
116 double-conversion
117 eigen
118 expat
119 ffmpeg
120 findutils
121 fmt
122 freetype
123 gdal
124 gl2ps
125 glew
126 gmp
127 gmsh
128 gnuplot
129 hdf5
130 jsoncpp
131 libjpeg-turbo
132 libogg
133 libpng
134 libharu
135 libtheora
136 libtiff
137 libx11
138 libxml2
139 libxslt
140 libxt
141 lz4
142 metis
143 mpfr
144 ncurses
145 netcdf
146 nlohmann-json
147 openmpi
148 paraview
149 proj
150 protobuf
151 pt-scotch32
152 pugixml
153 python
154 python-mpi4py
155 qt5compat
156 qtbase
157 qtsvg
158 qttools
159 qtwebengine
160 readline
161 trilinos-zoltan
162 utfcpp
163 vtk-9.5
164 xz
165 zlib))
166 (propagated-inputs (list python-openpmd-api)) ;needed for paraFoam
167 (outputs '("debug" ;~60MB
168 "out"))
169 (arguments
170 (list
171 ;; Executable files and shared libraries are located in the 'platforms'
172 ;; subdirectory.
173 #:strip-directories
174 #~(list (string-append "OpenFOAM-"
175 #$(package-version this-package)
176 "/platforms/linux64GccDPInt32Opt/bin")
177 (string-append "OpenFOAM-"
178 #$(package-version this-package)
179 "/platforms/linux64GccDPInt32Opt/lib"))
180
181 #:modules '((ice-9 ftw)
182 (ice-9 regex)
183 (ice-9 string-fun)
184 (srfi srfi-1)
185 (guix build gnu-build-system)
186 (guix build utils))
187
188 #:phases
189 #~(modify-phases %standard-phases
190 (add-after 'unpack 'rename-self
191 (lambda _
192 (let* ((old-build-path (getcwd))
193 (root-path (canonicalize-path (string-append
194 old-build-path "/..")))
195 (new-build-path (string-append root-path "/OpenFOAM-"
196 #$(package-version
197 this-package))))
198 (chdir root-path)
199 (rename-file old-build-path new-build-path)
200 (chdir new-build-path))))
201 (add-before 'configure 'patch-version
202 (lambda _
203 (substitute* "etc/bashrc"
204 (("export WM_PROJECT_VERSION=.*$")
205 (string-append "export WM_PROJECT_VERSION="
206 #$(package-version this-package) "\n")))))
207 (add-before 'configure 'patch-foamcleanpath
208 (lambda _
209 (substitute* "bin/foamCleanPath"
210 (("getconf")
211 (which "getconf")))))
212 (add-before 'configure 'patch-shell-path
213 (lambda _
214 (substitute* "wmake/makefiles/general"
215 (("/bin/sh")
216 (which "sh")))))
217 ;; needed for tests
218 (add-before 'configure 'patch-HOME-path
219 (lambda _
220 (setenv "HOME" "/tmp")))
221 (add-before 'configure 'patch-bash-completion
222 (lambda _
223 (substitute* "etc/bashrc"
224 ;; do not source bash_completion (gives error)
225 (("^.*bash_completion.*$" all)
226 (string-append "#" all)))))
227 (add-before 'configure 'patch-rpaths
228 (lambda _
229 (letrec* ((libraries '(#$(this-package-input "boost")
230 #$(this-package-input "cgal")
231 #$(this-package-input "gmp")
232 #$(this-package-input "metis")
233 #$(this-package-input "mpfr")
234 #$(this-package-input "pt-scotch32")
235 #$(this-package-input "openmpi")
236 #$(this-package-input "zlib")
237 #$(this-package-input "paraview")))
238 (rpaths (fold-right (lambda (lib rpaths)
239 (string-append rpaths "-rpath="
240 lib "/lib,")) ""
241 libraries))
242 (openfoam-lib (string-append #$output
243 "/share/OpenFOAM-"
244 #$(package-version this-package)
245 "/platforms/linux64GccDPInt32Opt/lib"))
246 (ldflags (string-append "-Wl,"
247 rpaths
248 "-rpath="
249 openfoam-lib
250 ","
251 "-rpath="
252 openfoam-lib
253 "/dummy,"
254 "-rpath="
255 openfoam-lib
256 "/paraview-"
257 #$(version-major+minor (package-version
258 (this-package-input
259 "paraview"))))))
260 (substitute* "wmake/rules/linux64Gcc/c++"
261 (("-fPIC" all)
262 (string-append all " " ldflags))))))
263 (add-before 'configure 'patch-paraview
264 (lambda _
265 (substitute* "etc/config.sh/paraview"
266 (("ldd")
267 (which "ldd")))
268 (substitute* "bin/paraFoam"
269 (("paraview \"\\$@\"")
270 (string-append #$paraview "/bin/paraview \"$@\"")))))
271 (add-before 'configure 'patch-mpi
272 (lambda _
273 (substitute* "etc/config.sh/mpi"
274 (("mpicc")
275 (string-append #$(this-package-input "openmpi") "/bin/mpicc")))))
276 (add-before 'configure 'patch-paraview
277 (lambda _
278 (substitute* "etc/config.sh/paraview"
279 (("\\$paraviewBinDir/paraview")
280 "$paraviewBinDir/.paraview-real")
281 (("libpqCore-pv")
282 "libpqCore"))))
283 (add-before 'configure 'patch-vtk-include-path
284 (lambda _
285 (let* ((vtk-version #$(version-major+minor (package-version (this-package-input
286 "vtk"))))
287 (vtk-inc (string-append #$(this-package-input "vtk")
288 "/include/vtk-" vtk-version))
289 (vtk-inc-flag (string-append "-I" vtk-inc)))
290 (substitute* "wmake/makefiles/general"
291 (("SYS_INC =" all)
292 (string-append all " " vtk-inc-flag))))))
293 (replace 'configure
294 (lambda _
295 (substitute* "etc/bashrc"
296 (("export ParaView_TYPE=.*$")
297 "export ParaView_TYPE=system\n")
298 (("export SCOTCH_TYPE=.*$")
299 "export SCOTCH_TYPE=system\n")
300 (("export METIS_TYPE=.*$")
301 "export METIS_TYPE=system\n")
302 (("export ZOLTAN_TYPE=.*$")
303 "export ZOLTAN_TYPE=system\n"))
304 (substitute* "etc/config.sh/scotch"
305 (("export SCOTCH_ARCH_PATH=.*$")
306 (string-append "export SCOTCH_ARCH_PATH="
307 #$(this-package-input "pt-scotch32") "\n")))
308 (substitute* "etc/config.sh/metis"
309 (("export METIS_ARCH_PATH=.*$")
310 (string-append "export METIS_ARCH_PATH="
311 #$(this-package-input "metis") "\n")))
312 (substitute* "etc/config.sh/zoltan"
313 (("export ZOLTAN_ARCH_PATH=.*$")
314 (string-append "export ZOLTAN_ARCH_PATH="
315 #$(this-package-input "trilinos-zoltan") "\n")))))
316 (replace 'build
317 (lambda _
318 ;; compile OpenFOAM libraries and applications
319 (invoke "bash" "-c"
320 (format #f "source ./etc/bashrc && ./Allwmake -j~a"
321 (parallel-job-count)))))
322 (add-after 'build 'cleanup
323 ;; Avoid unnecessary, voluminous object and dep files.
324 (lambda _
325 (when (file-exists? "platforms/linux64GccDPInt32Opt/src")
326 (delete-file-recursively "platforms/linux64GccDPInt32Opt/src"))
327 (when (file-exists?
328 "platforms/linux64GccDPInt32OptSYSTEMOPENMPI")
329 (delete-file-recursively
330 "platforms/linux64GccDPInt32OptSYSTEMOPENMPI"))
331 (for-each delete-file
332 (find-files "." "\\.o$"))
333 (for-each delete-file
334 (find-files "." "\\.dep$"))
335 ;; Remove spurious files in src tree
336 ;; (invoke "bash" "-c" "source ./etc/bashrc && wclean all")
337 ))
338 (replace 'check
339 (lambda* (#:key tests? #:allow-other-keys)
340 (when tests?
341 (when (file-exists? "test")
342 (with-directory-excursion "test"
343 (invoke "bash" "-c"
344 (format #f "source ../etc/bashrc && ./Allrun -j~a"
345 (parallel-job-count)))))
346 ;; too many tutorials are failing
347 ;; (with-directory-excursion "tutorials"
348 ;; (invoke "bash" "-c" "source ../etc/bashrc && ./Alltest"))
349 )))
350 (replace 'install
351 (lambda _
352 (let ((install-path (string-append #$output "/share/OpenFOAM-"
353 #$(package-version
354 this-package))))
355 (mkdir-p install-path) ;create install directory
356 ;; move contents of build directory to install directory
357 (copy-recursively "." install-path))))
358 (add-after 'install 'add-symbolic-link
359 (lambda _
360 (let* ((bin (string-append #$output "/bin"))
361 (lib (string-append #$output "/lib"))
362 (etc (string-append #$output "/etc"))
363 (openfoam (string-append #$output "/share/OpenFOAM-"
364 #$(package-version this-package)))
365 (build-bin (string-append openfoam
366 "/platforms/linux64GccDPInt32Opt/bin"))
367 (build-lib (string-append openfoam
368 "/platforms/linux64GccDPInt32Opt/lib"))
369 (foam-bin (string-append openfoam "/bin")))
370 ;; add symbolic links in standard 'bin' directory
371 (mkdir-p bin)
372 (for-each (lambda (file)
373 (symlink file
374 (string-append bin "/"
375 (basename file))))
376 (find-files build-bin))
377 (for-each (lambda (file)
378 (symlink file
379 (string-append bin "/"
380 (basename file))))
381 (find-files foam-bin))
382 ;; add symbolic link for standard 'lib' directory
383 (symlink build-lib lib)
384 ;; add symbolic link for bashrc file
385 (mkdir-p etc)
386 (symlink (string-append openfoam "/etc/bashrc")
387 (string-append etc "/bashrc"))) #t))
388 (add-after 'add-symbolic-link 'wrap
389 (lambda* (#:key python inputs outputs #:allow-other-keys)
390 (let* ((bin (string-append #$output "/bin"))
391 (openfoam-version #$(package-version this-package))
392 (openfoam-root (string-append #$output "/share/OpenFOAM-"
393 openfoam-version))
394 (openmpi-version #$(package-version (this-package-input
395 "openmpi")))
396 (paraview-version #$(package-version (this-package-input
397 "paraview")))
398 (paraview-version-major+minor #$(version-major+minor (package-version
399 (this-package-input
400 "paraview")))))
401 (for-each (lambda (program)
402 ;; wrap the programs with all the variables created by sourcing
403 ;; etc/bashrc
404 (wrap-program program
405 `("WM_PROJECT_INST_DIR" =
406 (,openfoam-root))
407 `("WM_PROJECT_DIR" =
408 (,openfoam-root))
409 '("WM_PROJECT" =
410 ("OpenFOAM"))
411 `("WM_PROJECT_VERSION" =
412 (,openfoam-version))
413 '("WM_COMPILER_TYPE" =
414 ("system"))
415 '("WM_COMPILER" =
416 ("Gcc"))
417 '("WM_ARCH_OPTION" =
418 ("64"))
419 '("WM_PRECISION_OPTION" =
420 ("DP"))
421 '("WM_LABEL_SIZE" =
422 ("32"))
423 '("WM_COMPILE_OPTION" =
424 ("Opt"))
425 '("WM_MPLIB" =
426 ("SYSTEMOPENMPI"))
427 '("WM_OSTYPE" =
428 ("POSIX"))
429 '("WM_OPTIONS" =
430 ("linux64GccDPInt32Opt"))
431 `("WM_PROJECT_USER_DIR" =
432 (,(string-append "$HOME/OpenFOAM/$USER-"
433 openfoam-version)))
434 `("WM_THIRD_PARTY_DIR" =
435 (,(string-append openfoam-root "/ThirdParty-"
436 openfoam-version)))
437 '("WM_LABEL_OPTION" =
438 ("Int32"))
439 '("WM_LINK_LANGUAGE" =
440 ("c++"))
441 '("WM_COMPILER_LIB_ARCH" =
442 ("64"))
443 `("WM_DIR" =
444 (,(string-append openfoam-root "/wmake")))
445 '("WM_LDFLAGS" =
446 ("-m64"))
447 '("WM_CC" =
448 ("gcc"))
449 '("WM_CFLAGS" =
450 ("-m64 -fPIC"))
451 '("WM_CXX" =
452 ("g++"))
453 '("WM_CXXFLAGS" =
454 ("-m64 -fPIC -std=c++0x"))
455
456 `("FOAM_INST_DIR" =
457 (,openfoam-root))
458 `("FOAM_APP" =
459 (,(string-append openfoam-root "/applications")))
460 `("FOAM_SRC" =
461 (,(string-append openfoam-root "/src")))
462 `("FOAM_ETC" =
463 (,(string-append openfoam-root "/etc")))
464 `("FOAM_TUTORIALS" =
465 (,(string-append openfoam-root "/tutorials")))
466 `("FOAM_UTILITIES" =
467 (,(string-append openfoam-root
468 "/applications/utilities")))
469 `("FOAM_SOLVERS" =
470 (,(string-append openfoam-root
471 "/applications/solvers")))
472 `("FOAM_MPI" =
473 (,(string-append "openmpi-" openmpi-version)))
474 `("FOAM_RUN" =
475 (,(string-append "$HOME/OpenFOAM/$USER-"
476 openfoam-version "/run")))
477 `("FOAM_EXT_LIBBIN" =
478 (,(string-append openfoam-root "/ThirdParty-"
479 openfoam-version
480 "/platforms/linux64GccDPInt32/lib")))
481 `("FOAM_APPBIN" =
482 (,(string-append openfoam-root
483 "/platforms/linux64GccDPInt32Opt/bin")))
484 `("FOAM_JOB_DIR" =
485 (,(string-append openfoam-root "/jobControl")))
486 `("FOAM_LIBBIN" =
487 (,(string-append openfoam-root
488 "/platforms/linux64GccDPInt32Opt/lib")))
489 `("FOAM_SITE_LIBBIN" =
490 (,(string-append openfoam-root "/site/"
491 openfoam-version
492 "/platforms/linux64GccDPInt32Opt/lib")))
493 `("FOAM_SITE_APPBIN" =
494 (,(string-append openfoam-root "/site/"
495 openfoam-version
496 "/platforms/linux64GccDPInt32Opt/bin")))
497 `("FOAM_USER_LIBBIN" =
498 (,(string-append "$HOME/OpenFOAM/$USER-"
499 openfoam-version
500 "/platforms/linux64GccDPInt32Opt/lib")))
501 `("FOAM_USER_APPBIN" =
502 (,(string-append "$HOME/OpenFOAM/$USER-"
503 openfoam-version
504 "/platforms/linux64GccDPInt32Opt/bin")))
505 `("FOAM_MODULES" =
506 (,(string-append openfoam-root
507 "/applications/modules")))
508 '("FOAM_SIGFPE" =
509 (""))
510 '("FOAM_SETTINGS" =
511 (""))
512
513 `("ParaView_INCLUDE_DIR" =
514 (,(string-append #$(this-package-input
515 "paraview")
516 "/include/paraview-"
517 paraview-version-major+minor)))
518 '("ParaView_GL" =
519 ("mesa"))
520 `("ParaView_VERSION" =
521 (,paraview-version))
522 `("ParaView_MAJOR" =
523 (,paraview-version-major+minor))
524 `("ParaView_DIR" =
525 (,#$(this-package-input "paraview")))
526 `("PV_PLUGIN_PATH" =
527 (,(string-append openfoam-root
528 "/platforms/linux64GccDPInt32Opt/lib/paraview-"
529 paraview-version-major+minor)))
530
531 `("MPI_ARCH_PATH" =
532 (,#$(this-package-input "openmpi")))
533 `("OPAL_PREFIX" =
534 (,#$(this-package-input "openmpi")))
535 '("MPI_BUFFER_SIZE" =
536 ("20000000"))
537
538 `("LD_LIBRARY_PATH" prefix
539 (,(string-append openfoam-root "/ThirdParty-"
540 openfoam-version
541 "/platforms/linux64Gcc/gperftools-svn/lib") ,
542 (string-append #$(this-package-input
543 "paraview") "/lib")
544 ,(string-append openfoam-root
545 "/platforms/linux64GccDPInt32Opt/lib/openmpi-"
546 openmpi-version)
547 ,(string-append openfoam-root "/ThirdParty-"
548 openfoam-version
549 "/platforms/linux64GccDPInt32/lib/openmpi-"
550 openmpi-version)
551 ,(string-append #$(this-package-input
552 "openmpi") "/lib")
553 ,(string-append #$(this-package-input
554 "openmpi") "/lib64")
555 ,(string-append "$HOME/OpenFOAM/$USER-"
556 openfoam-version
557 "/platforms/linux64GccDPInt32Opt/lib")
558 ,(string-append openfoam-root "/site/"
559 openfoam-version
560 "/platforms/linux64GccDPInt32Opt/lib")
561 ,(string-append openfoam-root
562 "/platforms/linux64GccDPInt32Opt/lib")
563 ,(string-append openfoam-root "/ThirdParty-"
564 openfoam-version
565 "/platforms/linux64GccDPInt32/lib")
566 ,(string-append openfoam-root
567 "/platforms/linux64GccDPInt32Opt/lib/openmpi-system")
568 ,(string-append openfoam-root
569 "/platforms/linux64GccDPInt32Opt/lib/paraview-"
570 paraview-version-major+minor)))
571 `("PATH" prefix
572 (,(string-append openfoam-root "/ThirdParty-"
573 openfoam-version
574 "/platforms/linux64Gcc/gperftools-svn/bin") ,
575 (string-append #$(this-package-input
576 "paraview") "/bin")
577 ,(string-append openfoam-root "/ThirdParty-"
578 openfoam-version
579 "/platforms/linux64Gcc/cmake-*/bin")
580 ,(string-append #$(this-package-input
581 "openmpi") "/bin")
582 ,(string-append openfoam-root "/bin")
583 ,(string-append openfoam-root "/wmake")
584 ,(string-append "$HOME/OpenFOAM/$USER-"
585 openfoam-version
586 "/platforms/linux64GccDPInt32Opt/bin")
587 ,(string-append openfoam-root "/site/"
588 openfoam-version
589 "/platforms/linux64GccDPInt32Opt/bin")
590 ,(string-append openfoam-root
591 "/platforms/linux64GccDPInt32Opt/bin")))))
592 (find-files bin))))))))
593 ;; Note:
594 ;; Tutorial files are installed read-only in /gnu/store.
595 ;; To allow write permissions on files copied from the store a
596 ;; 'chmod' step is needed before running the applications. For
597 ;; example, from a user's login:
598 ;; $ source $(foamEtcFile bashrc)
599 ;; $ mkdir -p $FOAM_RUN
600 ;; $ cd $FOAM_RUN
601 ;; $ cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily .
602 ;; $ cd pitzDaily
603 ;; $ chmod -R u+w .
604 ;; $ blockMesh
605 (home-page "https://openfoam.org")
606 (synopsis "Framework for numerical simulation of fluid flow")
607 (description
608 "OpenFOAM provides a set of solvers and methods for tackling
609problems in the field of Computational Fluid Dynamics (CFD). It is written in
610C++. Governing equations such as the Navier-Stokes equations can be solved in
611integral form. Physical processes such as phase change, droplet transport and
612chemical reaction can be modelled. Numerical methods are included to deal with
613sharp gradients, such as those encountered in flows with shock waves and flows
614with gas/liquid interfaces. Large problems may be split into smaller, connected
615problems for efficient solution on parallel systems.")
616 (license license:gpl3+)))
617
618(define-public openfoam-com
619 ;; This is a fork of 'openfoam-org', maintained separately.
620 (package
621 (inherit openfoam-org)
622 (name "openfoam-com")
623 (version "2512")
624 (source
625 (origin
626 (method git-fetch)
627 (uri (git-reference
628 (url "https://gitlab.com/openfoam/core/openfoam")
629 (commit (string-append "OpenFOAM-v" version))))
630 (file-name (git-file-name name version))
631 (sha256
632 (base32 "0v2dy7zcr1s6jc0z8gx726ljai3jnihzydiisszab8vcq79c19dr"))))
633 (synopsis
634 "Framework for numerical simulation of fluid flow (from openfoam.com)")
635 (home-page "https://www.openfoam.com")))
636
637(define-public open-simulation-interface
638 (package
639 (name "open-simulation-interface")
640 (version "3.5.0")
641 (source (origin
642 (method git-fetch)
643 (uri (git-reference
644 (url (string-append "https://github.com/"
645 "OpenSimulationInterface/"
646 "open-simulation-interface"))
647 (commit (string-append "v" version))))
648 (file-name (git-file-name name version))
649 (sha256
650 (base32
651 "09vclrvsawx608kk0vnzywr71xn11qzwxzh2j508zjfn0kvhyx7q"))))
652 (build-system cmake-build-system)
653 (arguments (list #:tests? #f ; tests are for the python package
654 #:phases
655 #~(modify-phases %standard-phases
656 (add-after 'unpack 'fix-cmake
657 (lambda _
658 (substitute* "CMakeLists.txt"
659 (("-targets\\.cmake") "_targets.cmake")))))))
660 (native-inputs (list protobuf))
661 (home-page
662 "https://github.com/OpenSimulationInterface/open-simulation-interface")
663 (synopsis "Generic interface for environmental perception")
664 (description "The Open Simulation Interface is a generic interface based on
665Google's protocol buffers for the environmental perception of automated driving
666functions in virtual scenarios.")
667 (license license:mpl2.0)))
668
669(define-public python-open-simulation-interface
670 (package/inherit open-simulation-interface
671 (name "python-open-simulation-interface")
672 (build-system pyproject-build-system)
673 (arguments '())
674 (native-inputs
675 (modify-inputs native-inputs
676 (append python-pytest python-setuptools)))
677 (propagated-inputs
678 (list python-pyyaml
679 python-protobuf))))
680
681(define-public esmini
682 (package
683 (name "esmini")
684 (version "3.5.0")
685 (source
686 (origin
687 (method git-fetch)
688 (uri (git-reference
689 (url "https://github.com/esmini/esmini")
690 (commit (string-append "v" version))))
691 (file-name (git-file-name name version))
692 (modules '((guix build utils) (ice-9 ftw)))
693 (snippet
694 #~(begin
695 (with-directory-excursion "externals"
696 (for-each
697 (lambda (dir) (unless (member dir '("." ".." "expr" "yaml"))
698 (delete-file-recursively dir)))
699 (scandir ".")))
700 (substitute* "CMakeLists.txt"
701 (("add_subdirectory\\(externals/fmt\\)") "")
702 (("set_.*_libs\\(\\)") ""))
703 (with-directory-excursion "EnvironmentSimulator"
704 (with-directory-excursion "Applications/esmini-dyn/"
705 (substitute* "CMakeLists.txt"
706 (("\\$ORIGIN") "$ORIGIN/../lib")))
707 (with-directory-excursion "Modules/RoadManager"
708 (substitute* (find-files "." "CMakeLists\\.txt$")
709 (("\\$\\{EXTERNALS_.*\\}/[^ )\n]*") "")
710 (("add_library\\(\n") "add_library("))
711 (substitute* (find-files "." "CMakeLists\\.txt$")
712 (("add_library\\(.*pugixml_lib") "find_package(pugixml")
713 (("pugixml_lib") "pugixml")))
714 (with-directory-excursion "Modules/Controllers"
715 (substitute* "ControllerSumo.cpp"
716 (("#include <utils/geom/PositionVector\\.h>") ""))))
717 (with-directory-excursion "support/cmake/external"
718 (for-each make-file-writable (scandir "."))
719 (call-with-output-file "gtest.cmake"
720 (lambda (out)
721 (display "find_package(GTest REQUIRED)" out)))
722 (call-with-output-file "osg.cmake"
723 (lambda (out)
724 (display "include_guard()\n" out)
725 (display "include(FindPkgConfig)\n" out)
726 (format out "pkg_check_modules(OSG REQUIRED~@{ ~a~})"
727 "openscenegraph"
728 "osgdb_jpeg"
729 "osgdb_png"
730 "osgdb_osg"
731 "osgdb_serializers_osg"
732 "osgdb_serializers_osgsim")))
733 (call-with-output-file "osi.cmake"
734 (lambda (out)
735 (display "\
736find_package(open_simulation_interface REQUIRED)
737set(EXTERNALS_OSI_INCLUDES \"${OPEN_SIMULATION_INTERFACE_INCLUDE_DIRS}\")
738set(OSI_LIBRARIES open_simulation_interface::open_simulation_interface)
739" out)
740 ))
741 (call-with-output-file "sumo.cmake"
742 (lambda (out)
743 (display "set(SUMO_LIBRARIES sumocpp tracicpp)"
744 out))))))
745 (sha256
746 (base32
747 "13xlkhg6z2z1j99l0j5m77lkcvsqkgmy19yjikqy32x1r0hm17df"))))
748 (build-system cmake-build-system)
749 (arguments
750 (list
751 #:configure-flags
752 #~(list "-DDYN_PROTOBUF=TRUE"
753 ;; Missing implot package
754 "-DUSE_IMPLOT=FALSE"
755 "-DDOWNLOAD_EXTERNALS=FALSE")
756 #:phases
757 #~(modify-phases %standard-phases
758 (add-after 'unpack 'fix-cmake
759 (lambda* (#:key inputs outputs #:allow-other-keys)
760 (substitute* "support/cmake/common/locations.cmake"
761 (("\\$\\{CMAKE_SOURCE_DIR\\}/bin")
762 (string-append (assoc-ref outputs "out") "/bin")))))
763 (replace 'check
764 (lambda* (#:key tests? #:allow-other-keys)
765 (with-directory-excursion "EnvironmentSimulator/Unittest/"
766 (for-each invoke (find-files "_test$")))))
767 (add-after 'install 'move-libraries
768 (lambda* (#:key outputs #:allow-other-keys)
769 (let ((out (assoc-ref outputs "out")))
770 (mkdir-p (string-append out "/lib"))
771 (with-directory-excursion (string-append out "/bin")
772 (for-each
773 (lambda (f)
774 (rename-file f (string-append out "/lib/"
775 (basename f))))
776 (find-files "." "\\.(a|so)$")))))))))
777 (inputs (list fmt
778 mesa
779 openscenegraph
780 `(,openscenegraph "pluginlib")
781 open-simulation-interface
782 protobuf
783 pugixml
784 sumo))
785 (native-inputs (list googletest pkg-config))
786 (home-page "https://github.com/esmini/esmini")
787 (synopsis "Basic OpenSCENARIO player")
788 (description "@command{esmini} is a tool to play OpenSCENARIO files.
789It is provided as both a standalone application and a shared library and has
790some support for generating and analysing traffic scenarios..")
791 (license license:mpl2.0)))
792
793(define-public python-fenics-dijitso
794 (package
795 (name "python-fenics-dijitso")
796 (version "2019.1.0")
797 (source
798 (origin
799 (method url-fetch)
800 (uri (pypi-uri "fenics-dijitso" version))
801 (sha256
802 (base32 "0lhqsq8ypdak0ahr2jnyvg07yrqp6wicjxi6k56zx24wp3qg60sc"))))
803 (build-system pyproject-build-system)
804 (arguments
805 (list
806 #:phases
807 #~(modify-phases %standard-phases
808 (add-after 'build 'mpi-setup
809 #$%openmpi-setup)
810 (replace 'check
811 (lambda* (#:key tests? #:allow-other-keys)
812 (when tests?
813 (setenv "HOME" "/tmp")
814 (with-directory-excursion "test"
815 ;; Disable parallel tests to avoid race condition. See
816 ;; https://github.com/pytest-dev/pytest-cov/issues/237.
817 (substitute* "runtests.sh"
818 (("for p in 1 4 8 16; do") "for p in 1; do"))
819 (invoke "./runtests.sh"))))))))
820 (native-inputs
821 (list python-pytest
822 ;; This package has a custom way to run tests.
823 python-pytest-cov
824 python-setuptools))
825 (inputs
826 (list openmpi python-numpy))
827 (propagated-inputs
828 (list python-mpi4py))
829 (home-page "https://bitbucket.org/fenics-project/dijitso/")
830 (synopsis "Distributed just-in-time building of shared libraries")
831 (description
832 "Dijitso provides a core component of the @code{FEniCS} framework,
833namely the just-in-time compilation of C++ code that is generated from
834Python modules. It is called from within a C++ library, using ctypes
835to import the dynamic shared library directly.
836
837As long as the compiled code can provide a simple factory function to
838a class implementing a predefined C++ interface, there is no limit to
839the complexity of that interface. Parallel support depends on the
840@code{mpi4py} interface.")
841 (license license:lgpl3+)))
842
843(define-public python-fenics-ufl
844 (package
845 (name "python-fenics-ufl")
846 (version "2025.2.0")
847 (source
848 (origin
849 (method url-fetch)
850 (uri (pypi-uri "fenics_ufl" version))
851 (sha256
852 (base32 "1k2r7s1c7dqlgkah4jr08lqy4z17h49r94yxjm7ca16vgvqvq1xg"))))
853 (build-system pyproject-build-system)
854 (inputs (list python-numpy))
855 (native-inputs (list python-pytest python-setuptools))
856 (home-page "https://bitbucket.org/fenics-project/ufl/")
857 (synopsis "Unified language for form-compilers")
858 (description
859 "The Unified Form Language (UFL) is a domain specific language for
860declaration of finite element discretizations of variational forms. More
861precisely, it defines a flexible interface for choosing finite element spaces
862and defining expressions for weak forms in a notation close to mathematical
863notation.
864
865UFL is part of the FEniCS Project.")
866 (license license:lgpl3+)))
867
868(define-public python-fenics-ufl-2019
869 (package/inherit python-fenics-ufl
870 (name "python-fenics-ufl")
871 (version "2019.1.0")
872 (source
873 (origin
874 (method url-fetch)
875 (uri (pypi-uri "fenics-ufl" version))
876 (sha256
877 (base32 "10dz8x3lm68x2w3kkqcjask38h0zkhhak26jdbkppr8g9y8wny7p"))))
878 (inputs '())
879 (propagated-inputs (list python-numpy-1))))
880
881;; XXX: This package is quite dated and upstream no longer maintains it: "This
882;; repository was archived by the owner on Feb 21, 2022. It is now read-only."
883;; <https://bitbucket.org/fenics-project/fiat> ->
884;; <https://github.com/FEniCS/fiat> while providing a new refactored fork
885;; <https://github.com/firedrakeproject/fiat>.
886(define-public python-fenics-fiat
887 (package
888 (name "python-fenics-fiat")
889 (version "2019.1.0")
890 (source
891 (origin
892 (method url-fetch)
893 (uri (pypi-uri "fenics-fiat" version))
894 (sha256
895 (base32 "13sc7lma3d2mh43an7i4kkdbbk4cmvxjk45wi43xnjd7qc38zg4b"))))
896 (build-system pyproject-build-system)
897 (arguments
898 (list
899 #:test-flags
900 #~(list
901 ;; FIXME: three FIAT test modules are known to fail with recent
902 ;; versions of pytest (>= 4). These are skipped for FIAT version
903 ;; 2019.1.0 pending an upstream pull request. For details see request
904 ;; #59 at https://bitbucket.org/fenics-project/fiat/.
905 "--ignore=test/regression/"
906 "--ignore=test/unit/test_quadrature.py"
907 "--ignore=test/unit/test_reference_element.py"
908 "-k" (string-join
909 (list "not test_nodality"
910 "test_basis_values")
911 " and not "))))
912 (native-inputs
913 (list python-pytest
914 python-setuptools
915 python-wheel))
916 (propagated-inputs
917 (list python-numpy
918 python-sympy))
919 (home-page "https://bitbucket.org/fenics-project/fiat/")
920 (synopsis "Tabulation of finite element function spaces")
921 (description
922 "The FInite element Automatic Tabulator (FIAT) supports generation of
923arbitrary order instances of the Lagrange elements on lines, triangles, and
924tetrahedra. It is also capable of generating arbitrary order instances of
925Jacobi-type quadrature rules on the same element shapes. Further, H(div) and
926H(curl) conforming finite element spaces such as the families of
927Raviart-Thomas, Brezzi-Douglas-Marini and Nedelec are supported on triangles
928and tetrahedra. Upcoming versions will also support Hermite and nonconforming
929elements.
930
931FIAT is part of the FEniCS Project.")
932 (license license:lgpl3+)))
933
934(define-public python-fenics-ffc
935 (package
936 (name "python-fenics-ffc")
937 (version "2019.1.0.post0")
938 (source
939 (origin
940 (method url-fetch)
941 (uri (pypi-uri "fenics-ffc" version))
942 (sha256
943 (base32 "1f2a44ha65fg3a1prrbrsz4dgvibsv0j5c3pi2m52zi93bhwwgg9"))))
944 (build-system pyproject-build-system)
945 (arguments
946 (list
947 #:phases
948 #~(modify-phases %standard-phases
949 (replace 'check
950 (lambda _
951 (setenv "HOME" (getcwd))
952 (with-directory-excursion "test"
953 ;; FIXME: the tests in subdirectory
954 ;; 'unit/ufc/finite_element' require the ffc_factory
955 ;; extension module. This module, located in the 'libs'
956 ;; subdirectory, needs to be built and made accessible
957 ;; prior to running the tests.
958 (invoke "pytest" "unit/" "--ignore=unit/ufc/")
959 (with-directory-excursion "uflacs"
960 (invoke "pytest" "unit/"))))))))
961 (native-inputs (list python-pytest python-setuptools))
962 (propagated-inputs (list python-fenics-dijitso python-fenics-fiat
963 python-fenics-ufl-2019
964 python-numpy-1))
965 (home-page "https://bitbucket.org/fenics-project/ffc/")
966 (synopsis "Compiler for finite element variational forms")
967 (description
968 "The FEniCS Form Compiler (FFC) is a compiler for finite element
969variational forms. From a high-level description of the form, it generates
970efficient low-level C++ code that can be used to assemble the corresponding
971discrete operator (tensor). In particular, a bilinear form may be assembled
972into a matrix and a linear form may be assembled into a vector. FFC may be
973used either from the command line (by invoking the @code{ffc} command) or as a
974Python module (@code{import ffc}).
975
976FFC is part of the FEniCS Project.")
977 ;; There are two files released with a public domain licence;
978 ;; ufc.h and ufc_geometry.h, in subdirectory 'ffc/backends/ufc'.
979 (license (list license:public-domain license:lgpl3+))))
980
981(define-public fenics-dolfin
982 (package
983 (name "fenics-dolfin")
984 (version "2019.1.0.post0")
985 (source
986 (origin
987 (method url-fetch)
988 (uri (string-append "https://bitbucket.org/fenics-project/dolfin/get/"
989 version ".tar.gz"))
990 (file-name (string-append name "-" version ".tar.gz"))
991 (sha256
992 (base32 "1m91hwcq5gfj4qqswp8l8kj58nia48f0n4kq13w0xqj4biq7rla0"))
993 (patches (search-patches "fenics-dolfin-algorithm.patch"
994 "fenics-dolfin-demo-init.patch"
995 "fenics-dolfin-boost.patch"
996 "fenics-dolfin-config-slepc.patch"
997 "fenics-dolfin-hdf5-version-check.patch"
998 "fenics-dolfin-integer-types.patch"))
999 (modules '((guix build utils)))
1000 (snippet '(begin
1001 ;; Make sure we don't use the bundled test framework.
1002 (delete-file-recursively "test/unit/cpp/catch")
1003 (substitute* "test/unit/cpp/main.cpp"
1004 ;; Use standard search paths for 'catch' header file.
1005 (("#include.*")
1006 "#include <catch.hpp>\n"))
1007 (substitute* "test/unit/cpp/CMakeLists.txt"
1008 ;; Specify directory to find the header file.
1009 (("(^set\\(CATCH_INCLUDE_DIR ).*(/catch\\))" _ front back)
1010 (string-append front "$ENV{CATCH_DIR}/include" back "\n")))))))
1011 (build-system cmake-build-system)
1012 (inputs (list openblas
1013 boost-1.83
1014 eigen
1015 hdf5-parallel-openmpi
1016 libxml2
1017 python-3
1018 pt-scotch32
1019 suitesparse
1020 zlib))
1021 (native-inputs (list catch-framework pkg-config python-setuptools))
1022 (propagated-inputs (list python-fenics-ffc petsc-openmpi slepc-openmpi))
1023 (arguments
1024 (list
1025 #:configure-flags
1026 #~`("-DDOLFIN_ENABLE_DOCS:BOOL=OFF" "-DDOLFIN_ENABLE_HDF5:BOOL=ON"
1027 "-DDOLFIN_ENABLE_MPI:BOOL=ON"
1028 "-DDOLFIN_ENABLE_PARMETIS:BOOL=OFF"
1029 "-DDOLFIN_ENABLE_SCOTCH:BOOL=ON"
1030 "-DDOLFIN_ENABLE_SUNDIALS:BOOL=OFF"
1031 "-DDOLFIN_ENABLE_TRILINOS:BOOL=OFF")
1032 #:phases
1033 #~(modify-phases %standard-phases
1034 (add-after 'patch-usr-bin-file 'mpi-setup
1035 #$%openmpi-setup)
1036 (add-after 'patch-source-shebangs 'set-paths
1037 (lambda _
1038 ;; Define paths to store locations.
1039 (setenv "BLAS_DIR"
1040 #$(this-package-input "openblas"))
1041 (setenv "CATCH_DIR"
1042 #$(this-package-input "catch"))
1043 (setenv "LAPACK_DIR"
1044 #$(this-package-input "openblas"))
1045 (setenv "PETSC_DIR"
1046 #$(this-package-input "petsc"))
1047 (setenv "SLEPC_DIR"
1048 #$(this-package-input "slepc"))
1049 (setenv "SCOTCH_DIR"
1050 #$(this-package-input "scotch"))
1051 (setenv "UMFPACK_DIR"
1052 #$(this-package-input "suitesparse"))))
1053 (add-before 'check 'pre-check
1054 (lambda _
1055 ;; The Dolfin repository uses git-lfs, whereby web links are
1056 ;; substituted for large files. Only the links are downloaded.
1057 ;; The tests that require the absent meshes cannot run and are
1058 ;; skipped.
1059 ;;
1060 ;; One serial test fails and is skipped.
1061 ;; i) demo_multimesh-stokes_serial:
1062 ;; Warning: Found no facets matching domain for boundary
1063 ;; condition.
1064 ;;
1065 ;; One mpi test fails and is skipped.
1066 ;; i) demo_stokes-iterative_mpi:
1067 ;; The MPI_Comm_rank() function was called before MPI_INIT was
1068 ;; invoked.
1069 (call-with-output-file "CTestCustom.cmake"
1070 (lambda (port)
1071 (display (string-append "set(CTEST_CUSTOM_TESTS_IGNORE "
1072 "demo_bcs_serial "
1073 "demo_bcs_mpi "
1074 "demo_eigenvalue_serial "
1075 "demo_eigenvalue_mpi "
1076 "demo_navier-stokes_serial "
1077 "demo_navier-stokes_mpi "
1078 "demo_stokes-taylor-hood_serial "
1079 "demo_stokes-taylor-hood_mpi "
1080 "demo_subdomains_serial "
1081 "demo_advection-diffusion_serial "
1082 "demo_advection-diffusion_mpi "
1083 "demo_auto-adaptive-navier-stokes_serial "
1084 "demo_contact-vi-snes_serial "
1085 "demo_contact-vi-snes_mpi "
1086 "demo_contact-vi-tao_serial "
1087 "demo_contact-vi-tao_mpi "
1088 "demo_curl-curl_serial "
1089 "demo_curl-curl_mpi "
1090 "demo_dg-advection-diffusion_serial "
1091 "demo_dg-advection-diffusion_mpi "
1092 "demo_elasticity_serial "
1093 "demo_elasticity_mpi "
1094 "demo_elastodynamics_serial "
1095 "demo_elastodynamics_mpi "
1096 "demo_lift-drag_serial "
1097 "demo_lift-drag_mpi "
1098 "demo_mesh-quality_serial "
1099 "demo_mesh-quality_mpi "
1100 "demo_multimesh-stokes_serial "
1101 "demo_stokes-iterative_mpi"
1102 ")\n") port)))))
1103 (replace 'check
1104 (lambda* (#:key tests? #:allow-other-keys)
1105 (when tests?
1106 (invoke "make" "unittests")
1107 (invoke "make" "demos")
1108 (invoke "ctest" "-R" "unittests")
1109 (invoke "ctest" "-R" "demo" "-R" "serial")
1110 (invoke "ctest" "-R" "demo" "-R" "mpi")))))))
1111 (home-page "https://bitbucket.org/fenics-project/dolfin/")
1112 (synopsis "Problem solving environment for differential equations")
1113 (description
1114 "DOLFIN is a computational framework for finding numerical
1115solutions to problems described by differential equations. Numerical
1116models in DOLFIN are constructed using general families of finite
1117elements. Data structures are provided for discretizing the governing
1118system on a computational mesh. A compact syntax, similar to
1119mathematical notation, is made available for defining function spaces
1120and expressing variational forms. Interfaces to specialized matrix
1121solvers are provided for solving the resultant linear systems.
1122
1123@code{fenics-dolfin} is part of the FEniCS project. It is the C++
1124user interface to the FEniCS core components and external libraries.")
1125 ;; The source code for the DOLFIN C++ library is licensed under the
1126 ;; GNU Lesser General Public License, version 3 or later, with the
1127 ;; following exceptions:
1128 ;;
1129 ;; public-domain: dolfin/geometry/predicates.cpp
1130 ;; dolfin/geometry/predicates.h
1131 ;;
1132 ;; zlib: dolfin/io/base64.cpp
1133 ;; dolfin/io/base64.h
1134 ;;
1135 ;; expat: dolfin/io/pugiconfig.hpp
1136 ;; dolfin/io/pugixml.cpp
1137 ;; dolfin/io/pugixml.hpp
1138 (license (list license:public-domain license:zlib license:expat
1139 license:lgpl3+))))
1140
1141(define-public fenics
1142 (package/inherit fenics-dolfin
1143 (name "fenics")
1144 (build-system pyproject-build-system)
1145 (arguments
1146 (list
1147 #:test-flags
1148 #~(list
1149 "unit"
1150 ;; This test fails and is ignored.
1151 "--deselect"
1152 "unit/nls/test_PETScSNES_solver.py::test_snes_set_from_options"
1153 ;; These tests are flaky.
1154 "--deselect=unit/common/test_timer.py::test_context_manager_named"
1155 "--deselect=unit/common/test_timer.py::test_context_manager_anonymous"
1156 ;; FIXME: Tests with binary encoded hdf5 files fail with a
1157 ;; segfault. See fenics-project DOLFIN commit 6fbc9fb.
1158 "--ignore=unit/io/test_XDMF.py"
1159 ;; Assertions failed.
1160 "--deselect=unit/common/test_timer.py::test_context_manager_named"
1161 "--deselect=unit/common/test_timer.py::test_context_manager_anonymous"
1162 ;; TypeError: 'float' object cannot be interpreted as an integer.
1163 "--ignore=unit/common/test_timer.py")
1164 #:phases
1165 #~(modify-phases %standard-phases
1166 (add-after 'unpack 'relax-requirements
1167 (lambda _
1168 (substitute* "python/setup.py"
1169 (("pybind11==") "pybind11>="))))
1170 (add-after 'unpack 'set-dolfin-pc-file-name
1171 (lambda* (#:key inputs #:allow-other-keys)
1172 ;; Instead of cluttering the user's PKG_CONFIG_PATH environment
1173 ;; variable, hard-code the 'dolfin.pc' absolute file name.
1174 (let ((pc-file (search-input-file inputs
1175 "/lib/pkgconfig/dolfin.pc")))
1176 (substitute* "python/dolfin/jit/jit.py"
1177 (("pkgconfig\\.parse\\(\"dolfin\"\\)")
1178 (string-append "pkgconfig.parse(\"" pc-file "\")"))))))
1179 (add-after 'patch-source-shebangs 'set-paths
1180 (lambda _
1181 ;; Define paths to store locations.
1182 (setenv "PYBIND11_DIR" #$(this-package-input "pybind11"))
1183 ;; Move to python sub-directory.
1184 (chdir "python")))
1185 (add-after 'build 'mpi-setup #$%openmpi-setup)
1186 (add-before 'check 'pre-check
1187 (lambda _
1188 ;; Exclude three tests that generate 'NotImplementedError' in
1189 ;; matplotlib v3.1.2. See
1190 ;; <https://github.com/matplotlib/matplotlib/issues/15382>.
1191 ;; Also exclude tests that require meshes supplied by git-lfs.
1192 (substitute* "demo/test.py"
1193 (("(.*stem !.*)" line)
1194 (format #f "~a
1195excludeList = [~{ '~a',~% ~}]
1196demos = [d for d in demos if d[0].stem not in excludeList]~%"
1197 line
1198 (list "built-in-meshes"
1199 "hyperelasticity"
1200 "elasticity"
1201 "multimesh-quadrature"
1202 "multimesh-marking"
1203 "mixed-poisson-sphere"
1204 "mesh-quality"
1205 "lift-drag"
1206 "elastodynamics"
1207 "dg-advection-diffusion"
1208 "curl-curl"
1209 "contact-vi-tao"
1210 "contact-vi-snes"
1211 "collision-detection"
1212 "buckling-tao"
1213 "auto-adaptive-navier-stokes"
1214 "advection-diffusion"
1215 "subdomains"
1216 "stokes-taylor-hood"
1217 "stokes-mini"
1218 "navier-stokes"
1219 "eigenvalue"))))
1220 ;; Do not test for expired numpy aliases.
1221 (substitute* "test/unit/la/test_vector.py"
1222 ((" numpy.float\\(42.0\\),") "")
1223 (("^.*numpy.int\\(42.0\\).*$") ""))
1224 (substitute* "test/unit/la/test_la_basic.py"
1225 ((" int,") " ")
1226 (("\\[int,") "["))
1227 (setenv "HOME" (getcwd))
1228 ;; Restrict OpenBLAS to MPI-only in preference to MPI+OpenMP.
1229 (setenv "OPENBLAS_NUM_THREADS" "1")))
1230 (replace 'check
1231 (lambda* (#:key tests? test-flags #:allow-other-keys)
1232 (when tests?
1233 (with-directory-excursion "test"
1234 (apply invoke "pytest" test-flags)))))
1235 (add-after 'install 'install-demo-files
1236 (lambda _
1237 (let* ((demos (string-append #$output
1238 "/share/python-dolfin/demo")))
1239 (mkdir-p demos)
1240 (with-directory-excursion "demo"
1241 (for-each (lambda (file)
1242 (let* ((dir (dirname file))
1243 (tgt-dir (string-append demos "/" dir)))
1244 (unless (equal? "." dir)
1245 (mkdir-p tgt-dir)
1246 (install-file file tgt-dir))))
1247 (find-files "." ".*\\.(py|gz|xdmf)$")))))))))
1248 (inputs
1249 (modify-inputs inputs
1250 (delete "python")
1251 (prepend pybind11-2 python-matplotlib)))
1252 (native-inputs
1253 (modify-inputs native-inputs
1254 (prepend cmake-minimal
1255 python-decorator
1256 python-numpy-1
1257 python-ply
1258 python-pytest
1259 python-setuptools)))
1260 (propagated-inputs
1261 (list fenics-dolfin
1262 python-petsc4py
1263 python-slepc4py
1264 ;; 'dolfin/jit/jit.py' parses 'dolfin.pc' at runtime.
1265 python-pkgconfig))
1266 (home-page "https://fenicsproject.org/")
1267 (synopsis "High-level environment for solving differential equations")
1268 (description
1269 "@code{fenics} is a computing platform for solving general classes of
1270problems that involve differential equations. @code{fenics} facilitates
1271access to efficient methods for dealing with ordinary differential
1272equations (ODEs) and partial differential equations (PDEs). Systems of
1273equations such as these are commonly encountered in areas of engineering,
1274mathematics and the physical sciences. It is particularly well-suited to
1275problems that can be solved using the Finite Element Method (FEM).
1276
1277@code{fenics} is the top level of the set of packages that are developed
1278within the FEniCS project. It provides the python user interface to the
1279FEniCS core components and external libraries.")
1280 (license license:lgpl3+)))
1281
1282(define-public fullswof-2d
1283 (let ((revision 505)
1284 (release "1.09.01"))
1285 (package
1286 (name "fullswof-2d")
1287 (version release)
1288 (source (origin
1289 (method svn-fetch)
1290 (uri (svn-reference
1291 (url (string-append "https://subversion.renater.fr/"
1292 "anonscm/svn/fullswof-2d/tags/"
1293 "release-" version))
1294 (revision revision)))
1295 (file-name (string-append "fullswof-2d-" version "-checkout"))
1296 (sha256
1297 (base32
1298 "16v08dx7h7n4wyddzbwimazwyj74ynis12mpjfkay4243npy44b8"))))
1299 (build-system gnu-build-system)
1300 (native-inputs
1301 (list inetutils)) ; for 'hostname', used in the check phase
1302 (arguments
1303 `(#:phases
1304 (modify-phases %standard-phases
1305 (delete 'configure) ; no configure script
1306 (add-after 'build 'build-tools
1307 (lambda _
1308 (with-directory-excursion "Tools/ConvertFormat"
1309 (invoke "make" "../../bin/asc2xyz")
1310 (invoke "make" "../../bin/xyz2asc"))
1311 (with-directory-excursion "Tools/ExtractWindow"
1312 (invoke "make" "../../bin/cropxyz"))
1313 #t))
1314 (replace 'check ; no check target
1315 (lambda _
1316 (invoke "make" "benchref")))
1317 (replace 'install ; no install target
1318 (lambda* (#:key outputs #:allow-other-keys)
1319 (let* ((out (assoc-ref outputs "out"))
1320 (bin (string-append out "/bin"))
1321 (doc (string-append
1322 out "/share/doc/" ,name "-" ,version))
1323 (examples (string-append doc "/Examples")))
1324 (with-directory-excursion "bin"
1325 (for-each (lambda (binary) (install-file binary bin))
1326 (list "asc2xyz" "xyz2asc" "cropxyz"
1327 "FullSWOF_2D")))
1328 (with-directory-excursion "doc"
1329 (for-each (lambda (pdf) (install-file pdf doc))
1330 (list "Documentation.pdf" "refman.pdf")))
1331 (with-directory-excursion "Tools"
1332 (for-each (lambda (dir)
1333 (copy-file
1334 (string-append dir "/README.txt")
1335 (string-append doc "/README_" dir ".txt")))
1336 (list "ConvertFormat" "ExtractWindow")))
1337 (copy-recursively "Examples" examples)
1338 #t))))))
1339 (home-page "https://www.idpoisson.fr/fullswof/")
1340 (synopsis "Two dimensional flow solver for flood modelling")
1341 (description "@code{FullSWOF_2d} is a numerical tool for solving
1342the shallow water equations on structured grids. The name FullSWOF
1343refers to the Full form of the Shallow Water equations for Overland
1344Flow. The discretized system of equations is solved using the finite
1345volume method. A choice of shock-capturing methods is available to
1346locate the transition boundaries between the wet areas and the dry
1347areas in the model. A semi-implicit method is used to advance the
1348solution in time. The tool is typically applied to the modelling of
1349river flooding.")
1350 (license license:cecill))))
1351
1352(define-public python-meshio
1353 (package
1354 (name "python-meshio")
1355 (version "5.3.5")
1356 (source
1357 (origin
1358 ;; Using PyPI rather than git because some test files must be
1359 ;; downloaded through git-fls.
1360 (method url-fetch)
1361 (uri (pypi-uri "meshio" version))
1362 (sha256
1363 (base32 "0vaqhygr2d186qixvfckzqf4447674ylnc0rl5pa16zjv6mh27zj"))))
1364 (build-system pyproject-build-system)
1365 (arguments
1366 (list
1367 #:test-flags
1368 ;; XXX: See: <https://github.com/nschloe/meshio/issues/1499>.
1369 ;; ValueError: invalid literal for int() with base 10: 'np.int64(4)'
1370 #~(list "--deselect=tests/test_dolfin.py::test_dolfin[mesh3]"
1371 "--deselect=tests/test_gmsh.py::test_gmsh22[False-mesh9]"
1372 "--deselect=tests/test_gmsh.py::test_gmsh22[False-mesh10]"
1373 "--deselect=tests/test_gmsh.py::test_gmsh22[False-mesh11]"
1374 "--deselect=tests/test_gmsh.py::test_gmsh22[False-mesh12]"
1375 "--deselect=tests/test_gmsh.py::test_gmsh22[False-mesh13]"
1376 "--deselect=tests/test_gmsh.py::test_gmsh22[False-mesh14]"
1377 "--deselect=tests/test_gmsh.py::test_gmsh40[False-mesh8]"
1378 "--deselect=tests/test_gmsh.py::test_gmsh40[False-mesh9]"
1379 "--deselect=tests/test_gmsh.py::test_gmsh40[False-mesh10]"
1380 "--deselect=tests/test_gmsh.py::test_gmsh40[False-mesh11]"
1381 "--deselect=tests/test_gmsh.py::test_gmsh40[False-mesh12]"
1382 "--deselect=tests/test_gmsh.py::test_gmsh40[False-mesh13]"
1383 "--deselect=tests/test_gmsh.py::test_gmsh41[False-mesh8]"
1384 "--deselect=tests/test_gmsh.py::test_gmsh41[False-mesh9]"
1385 "--deselect=tests/test_gmsh.py::test_gmsh41[False-mesh10]"
1386 "--deselect=tests/test_gmsh.py::test_gmsh41[False-mesh11]"
1387 "--deselect=tests/test_gmsh.py::test_gmsh41[False-mesh12]"
1388 "--deselect=tests/test_gmsh.py::test_gmsh41[False-mesh13]"
1389 "--deselect=tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh0]"
1390 "--deselect=tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh1]"
1391 "--deselect=tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh2]"
1392 "--deselect=tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh3]"
1393 "--deselect=tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh4]"
1394 "--deselect=tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh5]"
1395 ;; XXX: <...>/h5py/defs.cpython-312-x86_64-linux-gnu.so:
1396 ;; undefined symbol: H5Pset_dxpl_mpio
1397 "--deselect=tests/test_xdmf.py"
1398 "--deselect=tests/test_hmf.py"
1399 "--deselect=tests/test_cgns.py::test[mesh0]")))
1400 (inputs (list python-h5py python-netcdf4))
1401 (native-inputs (list python-pytest python-setuptools))
1402 (propagated-inputs (list python-numpy python-rich))
1403 (home-page "https://github.com/nschloe/meshio")
1404 (synopsis "I/O for mesh files")
1405 (description
1406 "There are various file formats available for representing unstructured
1407meshes and mesh data. The @code{meshio} package is able to read and write
1408mesh files in many formats and to convert files from one format to another.
1409Formats such as cgns, h5m, gmsh, xdmf and vtk are supported. The package
1410provides command-line tools and a collection of Python modules for
1411programmatic use.")
1412 (license license:expat)))
1413
1414(define-public python-pygmsh
1415 (package
1416 (name "python-pygmsh")
1417 (version "7.1.17")
1418 (source
1419 (origin
1420 (method git-fetch)
1421 (uri (git-reference
1422 (url "https://github.com/nschloe/pygmsh")
1423 (commit (string-append "v" version))))
1424 (file-name (git-file-name name version))
1425 (sha256
1426 (base32
1427 "11flp2c4ynk1fhanf4mqyzrpd0gjbnv6afrwwc7xi3mb6ms69lr0"))))
1428 (build-system pyproject-build-system)
1429 (arguments
1430 (list
1431 #:phases
1432 #~(modify-phases %standard-phases
1433 (add-after 'unpack 'workaround-gmsh-detection-failure
1434 (lambda _
1435 ;; Due to lack of metadata, the gmsh Python package is not
1436 ;; detected although importable.
1437 (substitute* "pyproject.toml"
1438 (("\"gmsh\",") "")))))))
1439 (native-inputs (list python-flit-core python-pytest))
1440 (propagated-inputs (list gmsh python-meshio python-numpy))
1441 (home-page "https://github.com/nschloe/pygmsh")
1442 (synopsis "Python frontend for Gmsh")
1443 (description "The goal of @code{pygmsh} is to combine the power of
1444Gmsh with the versatility of Python. The package generalises many of
1445the methods and functions that comprise the Gmsh Python API. In this
1446way the meshing of complex geometries using high-level abstractions is
1447made possible. The package provides a Python library together with a
1448command-line utility for mesh optimisation.")
1449 (license license:gpl3+)))
1450
1451(define-public python-simpy
1452 (package
1453 (name "python-simpy")
1454 (version "4.1.1")
1455 (source
1456 (origin
1457 (method url-fetch)
1458 (uri (pypi-uri "simpy" version))
1459 (sha256
1460 (base32 "19h1a3wxygyi819njmnl8cbmzvflqv3hpki0iq71xcc4g057bl06"))))
1461 (build-system pyproject-build-system)
1462 (arguments
1463 (list
1464 ;; tests: 141 passed, 10 deselected, 10 warnings
1465 #:test-flags
1466 ;; Doctests require deprecated python-py.
1467 #~(list "--ignore=docs/")))
1468 (native-inputs
1469 (list python-pytest
1470 python-setuptools
1471 python-setuptools-scm))
1472 (home-page "https://gitlab.com/team-simpy/simpy")
1473 (synopsis "Process-based discrete-event simulation framework")
1474 (description
1475 "SimPy is a process-based discrete-event simulation framework based
1476on standard Python. Processes in SimPy are defined by Python generator
1477functions and can, for example, be used to model active components like
1478customers, vehicles or agents. SimPy also provides various types of shared
1479resources to model limited capacity congestion points (like servers, checkout
1480counters and tunnels).")
1481 (license license:bsd-2)))
1482
1483(define %commonroad-dont-install-license-at-root
1484 #~(substitute* "setup.py"
1485 (("data_files=\\[\\('.', \\['LICENSE.txt'\\]\\)\\],")
1486 "")))
1487
1488(define-public python-commonroad-vehicle-models
1489 (package
1490 (name "python-commonroad-vehicle-models")
1491 (version "3.0.2")
1492 (source (origin
1493 (method url-fetch)
1494 (uri (pypi-uri "commonroad-vehicle-models" version))
1495 (sha256
1496 (base32
1497 "13jg0cys7y4n7rg548w6mxk9g10gd5qxmj4ynrlriczpffqy6kc7"))))
1498 (build-system pyproject-build-system)
1499 (arguments
1500 (list
1501 #:test-flags
1502 #~(list "--ignore=scripts/test_vehicle.py" ; import error
1503 "-k" "not test_std") ; flaky
1504 #:phases
1505 #~(modify-phases %standard-phases
1506 (add-after 'unpack 'fix-setup.py
1507 (lambda _
1508 #$%commonroad-dont-install-license-at-root)))))
1509 (native-inputs
1510 (list python-matplotlib
1511 python-pytest
1512 python-scipy
1513 python-setuptools))
1514 (propagated-inputs (list python-numpy python-omegaconf))
1515 (home-page "https://commonroad.in.tum.de/")
1516 (synopsis "CommonRoad vehicle models")
1517 (description "This package provides vehicle models used in CommonRoad
1518benchmarks. Varying abstraction levels are used ranging from kinematic single
1519track models to multi-body models.")
1520 (license license:bsd-3)))
1521
1522(define-public python-commonroad-io
1523 (package
1524 (name "python-commonroad-io")
1525 (version "2022.3")
1526 (source (origin
1527 (method url-fetch)
1528 (uri (pypi-uri "commonroad-io" version))
1529 (sha256
1530 (base32
1531 "1cj9zj567mca8xb8sx9h3nnl2cccv6vh8h73imgpq61cimk9mvas"))))
1532 (build-system pyproject-build-system)
1533 (arguments
1534 (list
1535 #:tests? #f ; No tests.
1536 #:phases
1537 #~(modify-phases %standard-phases
1538 (add-after 'unpack 'fix-setup.py
1539 (lambda _
1540 (substitute* "setup.py"
1541 (("protobuf==3.20.1") "protobuf >= 3.20.1"))
1542 #$%commonroad-dont-install-license-at-root)))))
1543 (propagated-inputs (list python-commonroad-vehicle-models
1544 python-iso3166
1545 python-lxml
1546 python-matplotlib
1547 python-networkx
1548 python-numpy
1549 python-omegaconf
1550 python-pillow
1551 python-protobuf
1552 python-rtree
1553 python-scipy
1554 python-shapely
1555 python-tqdm))
1556 (native-inputs (list python-lxml python-setuptools))
1557 (home-page "https://commonroad.in.tum.de/")
1558 (synopsis "Read, write, and visualize CommonRoad scenarios")
1559 (description "This package provides methods to read, write, and visualize
1560CommonRoad scenarios and planning problems. It can be used as a framework for
1561implementing motion planning algorithms to solve CommonRoad Benchmarks
1562and is the basis for other tools of the CommonRoad Framework.")
1563 (license license:bsd-3)))
1564
1565(define-public python-commonroad-route-planner
1566 (package
1567 (name "python-commonroad-route-planner")
1568 (version "2022.3")
1569 (source (origin
1570 (method git-fetch)
1571 (uri (git-reference
1572 (url "https://gitlab.lrz.de/tum-cps/commonroad-route-planner")
1573 (commit version)))
1574 (file-name (git-file-name name version))
1575 (sha256
1576 (base32
1577 "0xn0l7bzmj56d4mlqacvbl8mdvsffkg2fn2lzfmis5jl4vp99ipf"))))
1578 (arguments
1579 (list
1580 #:tests? #f ; No tests.
1581 #:phases
1582 #~(modify-phases %standard-phases
1583 (add-after 'unpack 'fix-setup.py
1584 (lambda _
1585 #$%commonroad-dont-install-license-at-root)))))
1586 (build-system pyproject-build-system)
1587 (native-inputs (list python-setuptools))
1588 (propagated-inputs (list python-commonroad-io
1589 python-matplotlib
1590 python-networkx
1591 python-numpy
1592 python-setuptools
1593 python-shapely))
1594 (home-page "https://gitlab.lrz.de/tum-cps/commonroad-route-planner")
1595 (synopsis "Route planner for CommonRoad scenarios")
1596 (description
1597 "This package provides functions for route planning, that is finding
1598sequences that lead from a given start lanelet to some goal lanelet(s).")
1599 (license license:bsd-3)))
1600
1601(define-public sumo
1602 (package
1603 (name "sumo")
1604 (version "1.27.1")
1605 (source (origin
1606 (method git-fetch)
1607 (uri (git-reference
1608 (url "https://github.com/eclipse/sumo")
1609 (commit (string-append "v"
1610 (string-replace-substring version
1611 "." "_")))))
1612 (file-name (git-file-name name version))
1613 (sha256
1614 (base32
1615 "0l2bqxs5xjxx23aagxw5wvr1sz325ldnyx1l5gvhbvhvpxqg64xh"))))
1616 (build-system cmake-build-system)
1617 (arguments
1618 (list
1619 #:phases
1620 #~(modify-phases %standard-phases
1621 (add-after 'unpack 'disable-problematic-tests
1622 (lambda _
1623 (substitute* "CMakeLists.txt"
1624 ;; docs/example appears to be missing
1625 (("add_test\\(exampletest .*") ""))
1626 (substitute* "src/traci_testclient/CMakeLists.txt"
1627 ;; requires network connection (at least to localhost)
1628 (("add_test\\(NAME libtracitest .*") "")))))))
1629 (inputs (list eigen
1630 freetype
1631 fontconfig
1632 ffmpeg
1633 fox
1634 gdal
1635 glu
1636 gperftools ; tcmalloc
1637 libjpeg-turbo
1638 libtiff
1639 libx11
1640 libxcursor
1641 libxft
1642 libxi
1643 libxrandr
1644 libxrender
1645 openscenegraph
1646 proj
1647 python
1648 xerces-c
1649 zlib))
1650 (native-inputs (list googletest python))
1651 (home-page "https://eclipse.org/sumo")
1652 (synopsis "Traffic simulator")
1653 (description "@acronym{SUMO, Simulation of Urban MObility} is a traffic
1654simulation package designed to handle large road networks and different modes
1655of transportation -- including road vehicles, public transport and pedestrians.
1656Included with SUMO is a wealth of supporting tools which automate core tasks
1657for the creation, the execution and evaluation of traffic simulations,
1658such as network import, route calculations, visualization and emission
1659calculation. SUMO can be enhanced with custom models and provides various
1660APIs to remotely control the simulation.")
1661 (license (list license:epl2.0 license:gpl2+))))