Skip to content

siconos/guix-siconos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 

Repository files navigation

Guix Siconos

Introduction

These are some cut and paste examples for the usage of Siconos with Guix through the Guix HPC channel.

Examples

A c++ bouncing ball with reference check

addr=https://raw.githubusercontent.com/siconos/guix-siconos &&
wget -q -N $addr/channels/siconos-2023-03-06.scm && \
  guix time-machine -C siconos-2023-03-06.scm -- \
       shell --pure \
       gcc-toolchain cmake make \
       coreutils grep dash \
       siconos@4.4 siconos-tutorials@4.4 -- \
       dash -c '
tutorials=${GUIX_ENVIRONMENT}/share/siconos/siconos-tutorials
bdir=$tutorials/examples/mechanics/BouncingBall
cp $bdir/BouncingBallTS.ref .
siconos $bdir/BouncingBallTS.cpp'

A python bouncing ball

addr=https://raw.githubusercontent.com/siconos/guix-siconos
wget -N $addr/channels/siconos-2023-03-06.scm && \
guix time-machine -C siconos-2023-03-06.scm -- \
     shell --pure \
     python python-numpy python-matplotlib python-packaging \
     siconos@4.4.0.rc3 siconos-tutorials@4.4 dash coreutils sed -- \
     dash -c '
      tutorials=${GUIX_ENVIRONMENT}/share/siconos/siconos-tutorials
      bdir=$tutorials/examples/mechanics/BouncingBall
      sed "/matplotlib.use.*/a else:\n    matplotlib.use(\"TkAgg\")" \
      $bdir/BouncingBallTS.py | python3'

A reproducible experiment of a cube falling on the ground

computation

addr=https://raw.githubusercontent.com/siconos/guix-siconos
wget -N $addr/channels/siconos-2023-03-06.scm && \
  guix time-machine -C siconos-2023-03-06.scm -- \
       shell --pure  \
       siconos@4.5.x siconos-tutorials dash -- \
       dash -c '
tutorials=${GUIX_ENVIRONMENT}/share/siconos/siconos-tutorials
siconos $tutorials/examples/mechanics/GeometricPrimitives/cube.py'

visualization

addr=https://raw.githubusercontent.com/siconos/guix-siconos
wget -N $addr/channels/siconos-2023-03-06.scm && \
guix time-machine -C siconos-2023-03-06.scm -- \
     environment --pure --ad-hoc \
     vtk siconos -- \
     siconos_vview cube.hdf5

Open Cascade contactors

computation

An example of a slider crank with Open Cascade contactors. The computation is done with a previous version of Siconos (siconos@4.2) and a specific commit on siconos-tutorials:

addr=https://raw.githubusercontent.com/siconos/guix-siconos &&
wget -N $addr/channels/siconos-2023-03-06.scm && \
  guix time-machine -C siconos-2023-03-06.scm -- \
       environment \
       --with-git-url=siconos-tutorials=https://github.com/siconos/siconos-tutorials \
       --with-commit=siconos-tutorials=7e1322d1c51224970967e46408b81a84e81b18a8 \
       --pure --ad-hoc \
       siconos@4.2  siconos-tutorials python pythonocc dash coreutils cmake make gcc-toolchain@7 sed -- \
       dash -c '
tutorials=${GUIX_ENVIRONMENT}/share/siconos/siconos-tutorials
cp -r $tutorials/examples/mechanics/OCC_Examples .
cp -r $tutorials/examples/mechanics/Mechanisms .
cd OCC_Examples
sed -i "s/with_timer=True/with_timer=False/" occ_slider_crank.py
siconos occ_slider_crank.py'

visualization

addr=https://raw.githubusercontent.com/siconos/guix-siconos &&
wget -N $addr/channels/siconos-2023-03-06.scm && \
  guix time-machine -C siconos-2023-03-06.scm -- \
       environment --pure --ad-hoc \
       pythonocc vtk siconos@4.2 dash -- dash -c '\
       cd OCC_Examples && \
       siconos_vview --cf-scale=0.05 occ_slider_crank.hdf5'

Package build and compilation with a guix environment

Package build with different sources

with transformation on repositories

An example with transformations on siconos-tutorials and siconos

addr=https://raw.githubusercontent.com/siconos/guix-siconos &&
wget -q -N $addr/channels/siconos-2021-06-08.scm && \
  guix time-machine -C siconos-2021-06-08.scm -- \
       environment \
       --with-git-url=siconos-tutorials=git@github.com:vacary/siconos-tutorials \
       --with-branch=siconos-tutorials=stress_tests \
       --with-git-url=siconos=git@github.com:vacary/siconos \
       --with-branch=siconos=optimize_2d_granular \
       --pure --ad-hoc gcc-toolchain cmake make grep coreutils dash \
       siconos siconos-tutorials -- \
       dash -c '
tutorials=${GUIX_ENVIRONMENT}/share/siconos/siconos-tutorials
siconos $tutorials/examples/mechanics/2DRigidBodies/Disks_stress_test.cpp'

with local sources

To check code before commit, there is the --with-source option:

git clone --depth 1 git@github.com:siconos/siconos &&
addr=https://raw.githubusercontent.com/siconos/guix-siconos &&
wget -N $addr/channels/siconos-2021-05-05.scm && \
    guix time-machine -C siconos-2021-05-05.scm -- \
         environment --pure --ad-hoc siconos \
         --with-source=siconos=/tmp/siconos -- siconos --help

Direct compilation with guix environment

This may be needed for debug through gdb and when modifying by hand the installation is convenient. Otherwise, it is preferable to use the transformations on repositories described above as they can be included in scripts.

usage of inputs of siconos package

The siconos package is placed before --ad-hoc option in order to provide the necessary inputs packages:

git clone --depth 1 git@github.com:siconos/siconos &&
 addr=https://raw.githubusercontent.com/siconos/guix-siconos &&
wget -N $addr/channels/siconos-2021-05-05.scm && \
  guix time-machine -C siconos-2021-05-05.scm -- \
     environment siconos --pure --ad-hoc dash -- \
     dash -c 'mkdir -p siconos-build &&
     cd siconos-build &&
     cmake ../siconos -DWITH_BULLET=1 \
     -DCMAKE_INSTALL_PREFIX=/tmp/install-siconos &&
     make -j8 &&
     make install'

the c++ bouncing ball

With an installation from a direct compilation, the shebang part of siconos script has not been replaced. It points to local system and not into the /gnu/store. To avoid the usage of the wrong python interpreter, it is necessary to call the siconos script with the python3 executable of the python package:

addr=https://raw.githubusercontent.com/siconos/guix-siconos &&
wget -N $addr/channels/siconos-2021-06-08.scm && \
  guix time-machine -C siconos-2021-06-08.scm -- \
     environment --pure --ad-hoc \
     siconos-tutorials@4.4 \
     cmake make gcc-toolchain \
     python python-packaging \
     dash coreutils -- \
     dash -c '
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp/install-siconos/lib &&
export PYTHONPATH=$PYTHONPATH:/tmp/install-siconos/lib/python3.8/site-packages
tutorials=${GUIX_ENVIRONMENT}/share/siconos/siconos-tutorials
cp $tutorials/examples/mechanics/BouncingBall/BouncingBallTS.ref .
python3 /tmp/install-siconos/bin/siconos \
  $tutorials/examples/mechanics/BouncingBall/BouncingBallTS.cpp'

the python bouncing ball

addr=https://raw.githubusercontent.com/siconos/guix-siconos &&
wget -N $addr/channels/siconos-2021-06-08.scm && \
  guix time-machine -C siconos-2021-06-08.scm -- \
     environment --pure --ad-hoc siconos-tutorials@4.4 \
     dash python python-numpy python-matplotlib python-packaging -- \
     dash -c '
      export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp/install-siconos/lib &&
      export PYTHONPATH=$PYTHONPATH:/tmp/install-siconos/lib/python3.8/site-packages
      tutorials=${GUIX_ENVIRONMENT}/share/siconos/siconos-tutorials
      python3 /tmp/install-siconos/bin/siconos \
      $tutorials/examples/mechanics/BouncingBall/BouncingBallTS.py'

the cube example

addr=https://raw.githubusercontent.com/siconos/guix-siconos &&
wget -N $addr/channels/siconos-2021-06-08.scm && \
  guix time-machine -C siconos-2021-06-08.scm -- \
     environment --pure --ad-hoc siconos-tutorials@4.4 \
     dash python python-numpy python-scipy python-h5py python-packaging -- \
     dash -c '
      export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp/install-siconos/lib &&
      export PYTHONPATH=$PYTHONPATH:/tmp/install-siconos/lib/python3.8/site-packages
      tutorials=${GUIX_ENVIRONMENT}/share/siconos/siconos-tutorials
      python3 /tmp/install-siconos/bin/siconos \
      $tutorials/examples/mechanics/GeometricPrimitives/cube.py'

Configuration of the Guix channel for Siconos

See Guix channels for more information about how to configure guix channels.

The channel file

  • it must include the repository url:
(cons
 (channel
  (name 'guix-hpc)
  (url "https://gitlab.inria.fr/bremond/guix-hpc.git")
  (branch "add-siconos"))
 %default-channels)
  • some branch specification may be added:
(list
 (channel
  (name 'guix-hpc)
  (url "https://gitlab.inria.fr/bremond/guix-hpc.git")
  (branch "add-siconos"))
 (name 'guix)
 (url "https://git.savannah.gnu.org/git/guix.git")
 (branch "version-1.4.0")))
  • for reproducibility commits are necessary:
(list (channel
        (name 'guix-hpc)
        (url "https://gitlab.inria.fr/bremond/guix-hpc.git")
        (branch "add-siconos")
        (commit
          "e51151ff99fa8f97ffb9133f31745933dbb46ec8"))
      (channel
        (name 'guix)
        (url "https://git.savannah.gnu.org/git/guix.git")
        (branch "master")
        (commit
          "461577f0fce1b69a88a752857eeee2e9e1116d6c")
        (introduction
          (make-channel-introduction
            "9edb3f66fd807b096b48283debdcddccfea34bad"
            (openpgp-fingerprint
              "BBB0 2DDF 2CEA F6A8 0D1D  E643 A2A0 6DF2 A33A 54FA")))))

Download of channel files

Some specifications are available in the channel branch of this repository. They are named with this convention:

  • without constraints, the channels file is named siconos-now.scm
  • with constraints on commits with the same date for Siconos channel and Guix channel: siconos-<iso 8601 date of commits>.scm
  • with different dates for Siconos channel and Guix channel: siconos-<iso 8601 date of siconos commits>-<iso 8601 date of Guix commits>.scm
addr=https://raw.githubusercontent.com/siconos/guix-siconos
wget -q -N $addr/channels/siconos-now.scm
addr=https://raw.githubusercontent.com/siconos/guix-siconos
wget -q -N $addr/channels/siconos-2021-05-05.scm

How to form a reproducible specification:

addr=https://raw.githubusercontent.com/siconos/guix-siconos
wget -q -N $addr/channels/siconos-now.scm && \
  guix time-machine  -C siconos-now.scm -- \
       describe -f channels 2>/dev/null > \
       siconos-$(date --iso-8601).scm

Releases

No releases published

Packages

No packages published

Languages