Server#

Run PyDYNA server locally#

Launching the servers directly on local machines.

1. Start PyDYNA preprocessing server locally#

Run an example on the client side#

hostname = "localhost"
if len(sys.argv) > 1:
    hostname = sys.argv[1]
    solution = launch_dynapre(ip = hostname)
    ......
  1. The function of launch_dynapre() can download and start the preprocessing server automatically.

2. Start PyDYNA solver server locally#

Prerequisites#

Start server on Windows#
  1. If you want to start the server on Windows,please ensure that you have installed the ANSYS locally.

Start server on Linux(Centos7)#
  1. If you want to start the server on Linux,please ensure that you have installed the Open MPI package.

    yum install openmpi3 openmpi3-dev
    
  2. set environment variable for Open MPI

    export LD_LIBRARY_PATH=/usr/lib64/openmpi3/lib:$LD_LIBRARY_PATH
    export PATH=/usr/lib64/openmpi3/bin:$PATH
    

Run an example on the client side#

import ansys.dyna.core.solver as solver

hostname = "localhost"
port = "5000"
dyna=launch_dyna(ip = hostname,port = port)     # connect to the server
dyna.push("./output/ball_plate.k")        # push an input file
dyna.start_locally(input = "ball_plate.k",nproc=1)
  1. The function of DynaSolver() can download and start the solver server automatically.

Run PyDYNA Server in a Docker container#

PyDYNA server can be run in a Docker container.

Build the Docker image for the pre service#

You must build the Docker image for the PyDYNA pre service and then run the image as a container.

Prerequisites#

  • Ensure that you have cloned the PyDYNA repository locally with these commands:

    git clone https://github.com/ansys/pydyna.git
    cd pydyna
    

    The docker file in the docker/pre directory is used to build the Linux-based Docker image.

  • If you are building the image on Windows, ensure that the Windows Subsystem for Linux (WSL) is installed. For installation information, see Microsoft’s Install Linux on Windows with WSL.

  • Install docker engine. Based on the Linux distro you can use the corresponding installation instructions from this page.

  • Download the latest Linux release artifacts for the pre Docker container: linux-binaries.zip.

  • Move this ZIP file to the docker/pre directory.

Once all prerequisites are met, you can build the Docker container for the pre service.

Build the Docker container for the pre service#

To build the Docker image, perform these steps:

  1. In your terminal, go to the docker directory.

  2. Run the following Docker command, replacing <DOCKERFILE_NAME> with Dockerfile and <DOCKER_IMAGE_TAG> with latest.

    docker build -t ghcr.io/ansys/ls-pre:<DOCKER_IMAGE_TAG> -f <DOCKERFILE_NAME> .
    
  3. Check that the image has been built successfully by running this command:

    docker images
    

    Your output should look similar to this:

    >>> REPOSITORY                                               TAG                                IMAGE ID       CREATED          SIZE
    >>> ghcr.io/ansys/ls-pre                                     *******-latest                     ............   X seconds ago    188MB
    >>> ......                                                   ......                             ............   ..............   ......
    

Run the image as a container#

Once the Docker image of the pre service is built successfully, perform these steps to run this image as a container:

  1. Run this Docker command:

    docker run -d -p 50051:50051 ghcr.io/ansys/ls-pre
    
  2. Check that the image is running successfully by running this command.

    docker ps
    

    Your output should look similar to this:

    >>> CONTAINER ID   IMAGE                  COMMAND                  CREATED         STATUS         PORTS                                           NAMES
    >>> c77ffd67f9fa   ghcr.io/ansys/ls-pre   "python3 ./linux-bin…"   7 seconds ago   Up 7 seconds   0.0.0.0:50051->50051/tcp, :::50051->50051/tcp   hardcore_margulis
    

Alternatively, you can start the container for the pre service from a docker-compose.yml file.

  1. Ensure that Docker Compose has been installed on your computer. If Docker Compose is not installed, see Overview of installing Docker Compose in the Docker documentation.

  2. In your terminal, go to the docker/pre directory and run this Docker command:

    docker compose up -d
    

Copy files from Docker#

To copy files back from the pre docker container to your host machine use the command below:

docker cp <containerId>:/file/path/within/container /host/target/path

The path within the container is /server/output.

Build the Docker image for the solver service#

You must build the Docker image for the PyDYNA solver service and then run the image as a container.

Prerequisites#

  • Ensure that you have cloned the PyDYNA repository locally with these commands:

 git clone https://github.com/ansys/pydyna.git
 cd pydyna

The ``docker`` file in the  ``docker/solver`` directory is used to build the
Linux-based Docker image.
  • If you are building the image on Windows, ensure that the Windows Subsystem for Linux (WSL) is installed. For installation information, see Microsoft’s Install Linux on Windows with WSL.

  • Install docker engine. Based on the Linux distro you can use the corresponding installation instructions from this page.

  • Download the latest Linux release artifacts for the solver Docker container: mppdyna_docker_centos7.zip.

  • Move this ZIP file to the docker/solver directory.

    The files in this folder should look similar to this:

>>> Dockerfile README.rst docker-compose.yml  mppdyna_docker_centos7.zip

Once all prerequisites are met, you can build the Docker image for the solver service.

Build the Docker image#

To build the Docker image for the solver service, perform these steps:

  1. In your terminal, go to the pydyna/docker/solver directory.

  2. Run this Docker command:

    docker build -t dyna_solver_v04 .
    
  3. Check that the image has been built successfully by running this command:

    docker images
    

    Your output should look similar to this:

    >>> REPOSITORY                        TAG                                        IMAGE ID       CREATED          SIZE
    >>> dyna_solver_v04                   latest                                     defbadbeee8e   16 minutes ago   730MB
    >>> ......                                                   ......                             ............   ..............   ......
    

Start the container from a docker-compose.yml file#

Alternatively, you can start the container for the pre service from a docker-compose.yml file.

  1. Ensure that Docker Compose has been installed on your computer. If Docker Compose is not installed, see Overview of installing Docker Compose in the Docker documentation.

  2. In the docker-compose.yml file, replace <license_server_name> with the correct license server hosting the LS-DYNA license.

  3. In your terminal, go to the docker/solver directory and run this Docker command:

    docker compose up -d
    
  4. Check that the image is running successfully by running this command.

    docker ps
    

    Your output should look similar to this:

    >>> CONTAINER ID   IMAGE             COMMAND                  CREATED          STATUS         PORTS                            NAMES
    >>> be84c95db31d   dyna_solver_v04   "/ansys_inc/server.p…"   18 minutes ago   Up 8 seconds   22/tcp, 0.0.0.0:5000->5000/tcp   mppdyna_docker_centos7_dyna_1
    

Copy files from Docker#

To copy files back from the solver container to your host machine use the command below:

docker cp <containerId>:/file/path/within/container /host/target/path

The path within the container is /rundir.