Comment utiliser l'image Apptainer d'AMITEX_FFTP ?
Prérequis
- Avoir installé Apptainer (guide d’installation) ou Docker
- Avoir téléchargé l’image amitex_fftp disponible ici
- Avoir téléchargé les fichiers d’entrées disponibles ici
Pour plus d’informations sur les conteneurs Apptainer, veuillez consulter la page dédiée ou suivre ce tutoriel pour s’approprier les principales commandes d’Apptainer.
Créez un dossier contenant l’image amitex_fftp.sif et l’archive des fichiers d’entrées. Placez-vous dans ce dossier et décompressez l’archive comme ceci:
tar -xzf amitex-tutorial-inputs.tar.gz # Extrait le contenu de l'archive.Commande en une ligne
Pour les personnes pressées, voici comment lancer un calcul Amitex_FFTP :
apptainer exec amitex_fftp.sif mpirun -np <N> amitex_fftp <args>Introduction
Amitex_FFTP est un code de calcul massivement parallèle, construit autour du standard MPI permettant de distribuer la charge de calcul sur différents processus. Il existe deux façons de lancer le code conteneurisé en parallèle:
- MPI embarqué dans le conteneur => fonctionnement garanti, mais limité à une seule machine (un seul noeud)
- MPI hybride avec celui de la machine hôte => fonctionne sur plusieurs noeuds mais il peut exister des incompatibilités.
Simulation en local (MPI embarqué)
apptainer exec amitex_fftp.sif mpirun amitex_fftp -nm concrete.vtk -m material.xml -c loading.xml -a algorithm.xml -s outOn remarque que la commande commence par lancer apptainer, qui exécute ensuite mpirun amitex_fftp <args> dans le conteneur.
Simulation sur cluster (MPI hybride)
Lancement avec le scheduler SLURM (recommandé)
Exemple de script minimal de lancement job.sh :
#!/bin/bash
#SBATCH --job-name=test_amitex
#SBATCH --output=slurm-%j.out
#SBATCH --error=slurm-%j.err
#SBATCH --ntasks=12
#SBATCH --time=00:05:00
srun apptainer exec amitex_fftp.sif amitex_fftp -nm concrete.vtk -m material.xml -c loading.xml -a algorithm.xml -s outIl est ensuite possible de lancer le calcul avec la commande :
sbatch job.shLancement sans scheduler
mpirun -np <N> apptainer exec amitex_fftp.sif amitex_fftp -nm concrete.vtk -m material.xml -c loading.xml -a algorithm.xml -s out*La commande mpirun doit provenir d’OpenMPI 4 pour que cela fonctionne.
Visualiser les résultats:
Générer les courbes de déformation avec Gnuplot :
apptainer exec amitex_fftp.sif gnuplot < plot.gpCela crée concrete_stress_strain.svg qui peut ensuite être affichée avec une visionneuse d’images classique.
Pour visualiser les fichiers .vtk, il faut utiliser Paraview. Nous mettons un conteneur Paraview à disposition
ici. Une fois le conteneur Paraview téléchargé, il est possible de visualiser la microstructure concrete.vtk comme ceci :
apptainer run paraview.sif concrete.vtk
# Puis dans l'interface graphique cliquez sur apply, dans le panneau de gauche Properties
# Puis dans la barre menu du haut, sélectionner MaterialId dans le menu déroulant à la place de Solid Color.
# Puis dans la barre menu du haut, sélectionner Surface dans le menu déroulant à la place de Outline.(Avancé) Loi de comportement définie par l’utilisateur
Comportements UMAT
Il est possible de définir ses propres lois de comportement matériau via une procédure compatible UMAT. Nous allons voir un exemple d’un comportement matériau défini par l’utilisateur, puis utilisé avec AMITEX_FFTP. On peut récupérer l’exemple fourni dans le conteneur grâce à :
cp -r /gnu/store/$(ls /gnu/store | grep amitex_fftp)/cas_tests/comportements/polyxCC/comportement_umat .
chmod -R u+w comportement_umatL’exemple fourni est déjà compilé, on peut donc commencer par nettoyer le répertoire comportement_umat:
cd comportement_umat
apptainer exec ../amitex_fftp.sif make cleanIl est maintenant possible d’implémenter le comportement voulu en modifiant les fichiers avec votre éditeur de texte préféré. Puis on peut recompiler la loi de comportement avec :
apptainer exec ../amitex_fftp.sif make
cd ..Ce qui crée comportement_umat/libUmatAmitex.so. Il faut ensuite modifier material.xml, pour appeler cette nouvelle loi de comportement en remplaçant par exemple <Material numM="2" Lib="" Law="elasiso"> [...] </Material> par :
<Material numM="2" Lib="comportement_umat/libUmatAmitex.so" Law="umatBCCHPP" >
<Coeff Index="1" Type="Constant" Value="236.412E3"/>
<Coeff Index="2" Type="Constant" Value="0.35"/>
<Coeff Index="3" Type="Constant" Value="275.2E3"/>
<Coeff Index="4" Type="Constant" Value="112.4E3"/>
<Coeff Index="5" Type="Constant" Value="87.56E3"/>
<Coeff Index="6" Type="Constant" Value="363."/>
<Coeff Index="7" Type="Constant" Value="0."/>
<Coeff Index="8" Type="Constant" Value="1000."/>
<Coeff Index="9" Type="Constant" Value="10e-6"/>
<Coeff Index="10" Type="Constant" Value="1e11"/>
<Coeff Index="11" Type="Constant" Value="2.481e-7"/>
<Coeff Index="12" Type="Constant" Value="100"/>
<Coeff Index="13" Type="Constant" Value="3."/>
<Coeff Index="14" Type="Constant" Value="2.e-6"/>
<Coeff Index="15" Type="Constant" Value="0.84"/>
<Coeff Index="16" Type="Constant" Value="1e5"/>
<Coeff Index="17" Type="Constant" Value="1e5"/>
<Coeff Index="18" Type="Constant" Value="1e-6"/>
<Coeff Index="19" Type="Constant" Value="50"/>
<Coeff Index="20" Type="Constant" Value="0"/>
<Coeff Index="21" Type="Constant" Value="0.3"/>
<Coeff Index="22" Type="Constant" Value="1."/>
<Coeff Index="23" Type="Constant" Value="5.e-4"/>
<Coeff Index="24" Type="Constant" Value="50"/>
<Coeff Index="25" Type="Constant" Value="0."/>
<Coeff Index="26" Type="Constant" Value="0."/>
<Coeff Index="27" Type="Constant" Value="0."/>
<IntVar Index="1" Type="Constant" Value="0."/>
<IntVar Index="2" Type="Constant" Value="0."/>
<IntVar Index="3" Type="Constant" Value="0."/>
<IntVar Index="4" Type="Constant" Value="0."/>
<IntVar Index="5" Type="Constant" Value="0."/>
<IntVar Index="6" Type="Constant" Value="0."/>
<IntVar Index="7" Type="Constant" Value="0."/>
<IntVar Index="8" Type="Constant" Value="0."/>
<IntVar Index="9" Type="Constant" Value="0."/>
<IntVar Index="10" Type="Constant" Value="0."/>
<IntVar Index="11" Type="Constant" Value="0."/>
<IntVar Index="12" Type="Constant" Value="0."/>
<IntVar Index="13" Type="Constant" Value="0."/>
<IntVar Index="14" Type="Constant" Value="0."/>
<IntVar Index="15" Type="Constant" Value="0."/>
<IntVar Index="16" Type="Constant" Value="0."/>
<IntVar Index="17" Type="Constant" Value="0."/>
<IntVar Index="18" Type="Constant" Value="0."/>
<IntVar Index="19" Type="Constant" Value="0."/>
<IntVar Index="20" Type="Constant" Value="0."/>
<IntVar Index="21" Type="Constant" Value="0."/>
<IntVar Index="22" Type="Constant" Value="0."/>
<IntVar Index="23" Type="Constant" Value="0."/>
<IntVar Index="24" Type="Constant" Value="0."/>
<IntVar Index="25" Type="Constant" Value="0."/>
<IntVar Index="26" Type="Constant" Value="0."/>
<IntVar Index="27" Type="Constant" Value="0."/>
<IntVar Index="28" Type="Constant" Value="0."/>
<IntVar Index="29" Type="Constant" Value="0."/>
<IntVar Index="30" Type="Constant" Value="0."/>
<IntVar Index="31" Type="Constant" Value="0."/>
<IntVar Index="32" Type="Constant" Value="0."/>
<IntVar Index="33" Type="Constant" Value="0."/>
<IntVar Index="34" Type="Constant" Value="0."/>
<IntVar Index="35" Type="Constant" Value="0."/>
<IntVar Index="36" Type="Constant" Value="0."/>
<IntVar Index="37" Type="Constant" Value="0."/>
<IntVar Index="38" Type="Constant" Value="0."/>
<IntVar Index="39" Type="Constant" Value="0."/>
<IntVar Index="40" Type="Constant" Value="0."/>
<IntVar Index="41" Type="Constant" Value="0."/>
<IntVar Index="42" Type="Constant" Value="0."/>
<IntVar Index="43" Type="Constant" Value="0."/>
<IntVar Index="44" Type="Constant" Value="0."/>
<IntVar Index="45" Type="Constant" Value="0."/>
<IntVar Index="46" Type="Constant" Value="0."/>
<IntVar Index="47" Type="Constant" Value="0."/>
<IntVar Index="48" Type="Constant" Value="0."/>
<IntVar Index="49" Type="Constant" Value="0."/>
</Material>On peut maintenant relancer le calcul avec la nouvelle loi de comportement, après avoir supprimé <Loading Tag="2"> [...] </Loading> de loading.xml qui ne fonctionne pas dans cet exemple :
apptainer exec amitex_fftp.sif mpirun amitex_fftp -nm concrete.vtk -m material.xml -c loading.xml -a algorithm.xml -s outComportements MFRONT
Il est possible de définir ses propres lois de comportement matériau également grace à mfront. Nous allons voir un exemple d’un comportement matériau défini avec mfront, puis utilisé avec AMITEX_FFTP. La première étape consiste à générer la bibliothèque dynamique contenant la fonction umat :
apptainer exec amitex_fftp.sif mfront --obuild --interface=umat Mazars.mfrontCe qui crée src/libUmatBehaviour.so. Il faut ensuite modifier material.xml, pour appeler cette nouvelle loi de comportement en remplaçant par exemple <Material numM="2" Lib="" Law="elasiso"> [...] </Material> par :
<Material numM="2" Lib="src/libUmatBehaviour.so" Law="umatmazars" >
<Coeff Index="1" Type="Constant" Value="1.e+10"/>
<Coeff Index="2" Type="Constant" Value="0.2"/>
<Coeff Index="3" Type="Constant" Value="0."/>
<Coeff Index="4" Type="Constant" Value="0."/>
<Coeff Index="5" Type="Constant" Value="1.15"/>
<Coeff Index="6" Type="Constant" Value="0.8"/>
<Coeff Index="7" Type="Constant" Value="1391.3"/>
<Coeff Index="8" Type="Constant" Value="10000"/>
<Coeff Index="9" Type="Constant" Value="0.7"/>
<Coeff Index="10" Type="Constant" Value="9.375e-5"/>
<IntVar Index = "1" Type = "Constant" Value = "0." />
<IntVar Index = "2" Type = "Constant" Value = "0." />
<IntVar Index = "3" Type = "Constant" Value = "0." />
</Material>On peut maintenant relancer le calcul avec la nouvelle loi de comportement :
apptainer exec amitex_fftp.sif mpirun amitex_fftp -nm concrete.vtk -m material.xml -c loading.xml -a algorithm.xml -s outPuis visualiser les résultats :
apptainer exec amitex_fftp.sif gnuplot < plot.gpCréez un dossier contenant l’archive des fichiers d’entrées. Placez-vous dans ce dossier, décompressez l’archive et modifiez les droits sur les fichiers comme ceci :
tar -xzf amitex-tutorial-inputs.tar.gz # Extrait le contenu de l'archive.
chmod -R a+rwx $(pwd) # Donne les droits aux autres utilisateurs sur les fichiers.Il est nécessaire de donner les droits d’accès aux autres utilisateurs sur les fichiers, car nous allons exécuter Docker en spécifiant un utilisateur différent.
On entre ensuite dans le conteneur avec la commande suivante :
docker run -v=$(pwd):/workdir -w=/workdir --user=1000:1000 --entrypoint=bash -it --rm gricad-registry.univ-grenoble-alpes.fr/diamond/apptainer/apptainer-singularity-projects/amitex_fftp-v=$(pwd):/workdirpermet de monter le répertoire courant dans/workdirdu conteneur.-w=/workdirpermet de se placer dans le répertoire de travail/workdir.--user=1000:1000spécifie l’utilisateur avec l’UID1000et le GID1000dans le conteneur. Cela permet d’éviter d’exécuter les commandes en tant queroot, ce qui est plus sûr et nécessaire pour utilisermpirun.--entrypoint=bashet-itpermettent de lancer un shell Bash interactif.--rmsupprime automatiquement le conteneur lorsqu’on quitte le shell
Commande en une ligne
Pour les personnes pressées, voici comment lancer un calcul Amitex_FFTP une fois dans le conteneur:
mpirun -np <N> amitex_fftp <args>mpirun refuse d’être lancé par un utilisateur root, veillez donc à bien présiser --user=1000:1000 lors du lancement du docker, ou bien mettez --allow-run-as-root après chaque commande mpirun
Introduction
Amitex_FFTP est un code de calcul massivement parallèle, construit autour du standard MPI permettant de distribuer la charge de calcul sur différents processus. Avec Docker, il est uniquement possible d’utiliser le MPI embarqué dans le conteneur. De cette façon, le fonctionnement est garanti mais limité à une seule machine (un seul noeud).
Lancer l’exemple
mpirun amitex_fftp -nm concrete.vtk -m material.xml -c loading.xml -a algorithm.xml -s outAucun paramètre n’est passé à mpirun, tous les coeurs disponibles vont donc être utilisés pour le calcul.
Visualiser les résultats
Générer les courbes de déformation avec Gnuplot :
gnuplot < plot.gpCela crée concrete_stress_strain.svg qui peut ensuite être affichée avec une visionneuse d’images classique.
Pour visualiser les fichiers .vtk, il faut sortir du conteneur et utiliser Paraview. Nous mettons un conteneur Paraview à disposition
ici. Une fois le conteneur Paraview téléchargé, il est possible de visualiser la microstructure concrete.vtk comme ceci :
apptainer run paraview.sif concrete.vtk
# Puis dans l'interface graphique cliquez sur apply, dans le panneau de gauche Properties
# Puis dans la barre menu du haut, sélectionner MaterialId dans le menu déroulant à la place de Solid Color.
# Puis dans la barre menu du haut, sélectionner Surface dans le menu déroulant à la place de Outline.(Avancé) Loi de comportement définie par l’utilisateur
Comportements UMAT
Il est possible de définir ses propres lois de comportement matériau via une procédure compatible UMAT. Nous allons voir un exemple d’un comportement matériau défini par l’utilisateur, puis utilisé avec AMITEX_FFTP. On peut récupérer l’exemple fourni dans le conteneur grâce à :
cp -r /gnu/store/$(ls /gnu/store | grep amitex_fftp)/cas_tests/comportements/polyxCC/comportement_umat .
chmod -R a+rw comportement_umatL’exemple fourni est déjà compilé, on peut donc commencer par nettoyer le répertoire comportement_umat:
cd comportement_umat
make cleanIl est maintenant possible d’implémenter le comportement voulu en modifiant les fichiers avec votre éditeur de texte préféré. Puis on peut recompiler la loi de comportement avec :
make
cd ..Ce qui crée comportement_umat/libUmatAmitex.so. Il faut ensuite modifier material.xml, pour appeler cette nouvelle loi de comportement en remplaçant par exemple <Material numM="2" Lib="" Law="elasiso"> [...] </Material> par :
<Material numM="2" Lib="comportement_umat/libUmatAmitex.so" Law="umatBCCHPP" >
<Coeff Index="1" Type="Constant" Value="236.412E3"/>
<Coeff Index="2" Type="Constant" Value="0.35"/>
<Coeff Index="3" Type="Constant" Value="275.2E3"/>
<Coeff Index="4" Type="Constant" Value="112.4E3"/>
<Coeff Index="5" Type="Constant" Value="87.56E3"/>
<Coeff Index="6" Type="Constant" Value="363."/>
<Coeff Index="7" Type="Constant" Value="0."/>
<Coeff Index="8" Type="Constant" Value="1000."/>
<Coeff Index="9" Type="Constant" Value="10e-6"/>
<Coeff Index="10" Type="Constant" Value="1e11"/>
<Coeff Index="11" Type="Constant" Value="2.481e-7"/>
<Coeff Index="12" Type="Constant" Value="100"/>
<Coeff Index="13" Type="Constant" Value="3."/>
<Coeff Index="14" Type="Constant" Value="2.e-6"/>
<Coeff Index="15" Type="Constant" Value="0.84"/>
<Coeff Index="16" Type="Constant" Value="1e5"/>
<Coeff Index="17" Type="Constant" Value="1e5"/>
<Coeff Index="18" Type="Constant" Value="1e-6"/>
<Coeff Index="19" Type="Constant" Value="50"/>
<Coeff Index="20" Type="Constant" Value="0"/>
<Coeff Index="21" Type="Constant" Value="0.3"/>
<Coeff Index="22" Type="Constant" Value="1."/>
<Coeff Index="23" Type="Constant" Value="5.e-4"/>
<Coeff Index="24" Type="Constant" Value="50"/>
<Coeff Index="25" Type="Constant" Value="0."/>
<Coeff Index="26" Type="Constant" Value="0."/>
<Coeff Index="27" Type="Constant" Value="0."/>
<IntVar Index="1" Type="Constant" Value="0."/>
<IntVar Index="2" Type="Constant" Value="0."/>
<IntVar Index="3" Type="Constant" Value="0."/>
<IntVar Index="4" Type="Constant" Value="0."/>
<IntVar Index="5" Type="Constant" Value="0."/>
<IntVar Index="6" Type="Constant" Value="0."/>
<IntVar Index="7" Type="Constant" Value="0."/>
<IntVar Index="8" Type="Constant" Value="0."/>
<IntVar Index="9" Type="Constant" Value="0."/>
<IntVar Index="10" Type="Constant" Value="0."/>
<IntVar Index="11" Type="Constant" Value="0."/>
<IntVar Index="12" Type="Constant" Value="0."/>
<IntVar Index="13" Type="Constant" Value="0."/>
<IntVar Index="14" Type="Constant" Value="0."/>
<IntVar Index="15" Type="Constant" Value="0."/>
<IntVar Index="16" Type="Constant" Value="0."/>
<IntVar Index="17" Type="Constant" Value="0."/>
<IntVar Index="18" Type="Constant" Value="0."/>
<IntVar Index="19" Type="Constant" Value="0."/>
<IntVar Index="20" Type="Constant" Value="0."/>
<IntVar Index="21" Type="Constant" Value="0."/>
<IntVar Index="22" Type="Constant" Value="0."/>
<IntVar Index="23" Type="Constant" Value="0."/>
<IntVar Index="24" Type="Constant" Value="0."/>
<IntVar Index="25" Type="Constant" Value="0."/>
<IntVar Index="26" Type="Constant" Value="0."/>
<IntVar Index="27" Type="Constant" Value="0."/>
<IntVar Index="28" Type="Constant" Value="0."/>
<IntVar Index="29" Type="Constant" Value="0."/>
<IntVar Index="30" Type="Constant" Value="0."/>
<IntVar Index="31" Type="Constant" Value="0."/>
<IntVar Index="32" Type="Constant" Value="0."/>
<IntVar Index="33" Type="Constant" Value="0."/>
<IntVar Index="34" Type="Constant" Value="0."/>
<IntVar Index="35" Type="Constant" Value="0."/>
<IntVar Index="36" Type="Constant" Value="0."/>
<IntVar Index="37" Type="Constant" Value="0."/>
<IntVar Index="38" Type="Constant" Value="0."/>
<IntVar Index="39" Type="Constant" Value="0."/>
<IntVar Index="40" Type="Constant" Value="0."/>
<IntVar Index="41" Type="Constant" Value="0."/>
<IntVar Index="42" Type="Constant" Value="0."/>
<IntVar Index="43" Type="Constant" Value="0."/>
<IntVar Index="44" Type="Constant" Value="0."/>
<IntVar Index="45" Type="Constant" Value="0."/>
<IntVar Index="46" Type="Constant" Value="0."/>
<IntVar Index="47" Type="Constant" Value="0."/>
<IntVar Index="48" Type="Constant" Value="0."/>
<IntVar Index="49" Type="Constant" Value="0."/>
</Material>On peut maintenant relancer le calcul avec la nouvelle loi de comportement, après avoir supprimé <Loading Tag="2"> [...] </Loading> de loading.xml qui ne fonctionne pas dans cet exemple :
mpirun amitex_fftp -nm concrete.vtk -m material.xml -c loading.xml -a algorithm.xml -s outComportements MFRONT
Il est possible de définir ses propres lois de comportement matériau également grace à mfront. Nous allons voir un exemple d’un comportement matériau défini avec mfront, puis utilisé avec AMITEX_FFTP. La première étape consiste à générer la bibliothèque dynamique contenant la fonction umat :
mfront --obuild --interface=umat Mazars.mfrontCe qui crée src/libUmatBehaviour.so. Il faut ensuite modifier material.xml, pour appeler cette nouvelle loi de comportement en remplaçant par exemple <Material numM="2" Lib="" Law="elasiso"> [...] </Material> par :
<Material numM="2" Lib="src/libUmatBehaviour.so" Law="umatmazars" >
<Coeff Index="1" Type="Constant" Value="1.e+10"/>
<Coeff Index="2" Type="Constant" Value="0.2"/>
<Coeff Index="3" Type="Constant" Value="0."/>
<Coeff Index="4" Type="Constant" Value="0."/>
<Coeff Index="5" Type="Constant" Value="1.15"/>
<Coeff Index="6" Type="Constant" Value="0.8"/>
<Coeff Index="7" Type="Constant" Value="1391.3"/>
<Coeff Index="8" Type="Constant" Value="10000"/>
<Coeff Index="9" Type="Constant" Value="0.7"/>
<Coeff Index="10" Type="Constant" Value="9.375e-5"/>
<IntVar Index = "1" Type = "Constant" Value = "0." />
<IntVar Index = "2" Type = "Constant" Value = "0." />
<IntVar Index = "3" Type = "Constant" Value = "0." />
</Material>On peut maintenant relancer le calcul avec la nouvelle loi de comportement :
mpirun amitex_fftp -nm concrete.vtk -m material.xml -c loading.xml -a algorithm.xml -s outPuis visualiser les résultats :
gnuplot < plot.gpCertains fichiers peuvent être crées avec des droits ne permettant pas de les modifier/supprimer depuis l’extérieur du conteneur. Il est possible de changer les droits en exécutant par exemple : chmod -R a+rwx $(pwd) à l’intérieur du conteneur.