Welcome to the forums. Please post in English or French.

You are not logged in.

#1 2021-12-14 23:19:38

Johannes_ACKVA
Member
From: Ingenieurbüro für Mechanik, DE
Registered: 2009-11-04
Posts: 763
Website

How to use Code-Aster in the "pythonic way"?

hello,

how can Code-Aster be used in the "pythonic way"?

The new pythonic way (since v 15) is shown in this training document:
https: //code-aster.org/UPLOAD/DOC/Formations/20-asterxx-inanutshell.pdf

The problem is when starting from the bash:

singularity run --bind /home:/home /opt/SaloMec2021/salome_meca-lgpl-2021.0.0-1-20210811-scibian-9.sif shell

(details see at  https: //code-aster.org/forum2/viewtopic.php?id=26013)

the salome shell appears. What to do next? I would instead need a python shell in order to do

export PREFIX=/home/myNNI/dev/codeaster/install/
. $PREFIX/share/aster/profile.sh
import code_aster
from code_aster.Commands import *
code_aster.init()
monMaillage = code_aster.Mesh()

and so on and so on . . .

Many thanks and regards

Johannes_ACKVA

*** NEW: all Code-Aster courses now  as Video and Webinar courses  ***


Ingenieurbüro für Mechanik
D 91717 Wassertrüdingen / Germany

www.code-aster.de                                                Training & Support for NASTRAN and CODE-ASTER

Offline

#2 2022-01-21 14:37:58

Celdor
Member
From: Germany
Registered: 2021-12-16
Posts: 3

Re: How to use Code-Aster in the "pythonic way"?

hi,

looks like there is a path missing so python can look it up:
What i tried in python and it seems to work

import sys
sys.path.append('/opt/salome_meca/Salome-V2021-s9/tools/Code_aster_stable-1540/lib/aster/')
import code_aster

else you could add this in bash

export $PYTHONPATH=/opt/salome_meca/Salome-V2021-s9/tools/Code_aster_stable-1540/lib/aster/:$PYTHONPATH

but i have no idea on how to fix this in the container, or if there is another way which would work.

best regards

Offline

#3 2022-01-26 18:29:27

mathieu.courtois
Administrator
From: France
Registered: 2007-11-21
Posts: 1,183

Re: How to use Code-Aster in the "pythonic way"?

Hello,

The container embeds a convenient starter script. See `singularity run-help NAME.sif`
It tells you to run: `singularity run --app install NAME.sif`
Then just use the created script, named as `NAME` (without .sif)
See `./NAME --help` for options.


Next steps:

$ ./NAME shell
Singularity> /opt/salome_meca/Salome-V2021-s9/tools/Code_aster_stable-1540/bin/run_aster FILENAME.export

See `run_aster --help`

Example: for interactive executions (it will stop before executing FIN):

$ ./NAME shell
Singularity> /opt/salome_meca/Salome-V2021-s9/tools/Code_aster_stable-1540/bin/run_aster -i FILENAME.export

The next version (>16.1) will allow to directly use `run_aster FILENAME.py`...

MC


Code_Aster release : last unstable on Ubuntu 16.04 64 bits - GNU Compilers

Please do not forget to tag your first post as *SOLVED* when it is!

Offline

#4 2022-02-04 14:48:25

jlopez
Member
Registered: 2014-04-04
Posts: 15

Re: How to use Code-Aster in the "pythonic way"?

Hello,

I tried to launch code_aster from Python, but without success.
When loading the necessary environment (share/aster/profile.sh) the Python environment seems to be misconfigured (see attachment).

erreur-aster.png

Moreover, using Celdor's method I can execute the

import code_aster

command, but the command below crashes, which is not surprising because the profile.sh contains more path definitions than lib/aster:

from code_aster.Commands import *

Attachments:
erreur_aster.png, Size: 35.53 KiB, Downloads: 191

Offline