Automation with few parameters

Rosa Esquer Cerezo
Rosa Esquer Cerezo Altair Community Member
edited October 23 in Community Q&A

Hi experts! 

I am trying to automate few simulations with different inputs. I am trying to do with a geometry from de tutorial: "Mixing Elbow". This geometry has two velocity inlets that i want to change in each simulation. My excel table is something like this:

ID VEL_LONG VEL_SMALL
412 0.4 1.2
512 0.5 1.2
612 0.6 1.2
413 0.4 1.3
414 0.4 1.4
415 0.4 1.5
513 0.5 1.3
614 0.6 1.4

I have made a visual basic Script that doesn't give any problem. My problem is with the .bat because i dont know how to link my script.bat with the file mixingElbow.inp in order to get the simulations  with the velocity inlets changed

In the mixingElbow.inp I have this for both, the small and the large one
SIMPLE_BOUNDARY_CONDITION( "Small_Inlet" ) {
    surface_sets                        = { "mixingElbow.SurfaceSet_3.tria3.SolidBody_2_1.tet4" }
    type                                = inflow
    inflow_type                         = average_velocity
    precedence                          = 1
    average_velocity                    = Env( "V_Small")
And for the script.bat i have this:

@echo off

SETLOCAL ENABLEDELAYEDEXPANSION

set input_file="C:\Users\Stress\Desktop\rosa\AUTOMATIZ\MIXING_ELBOW\velocidades.txt"
set base_dir="C:\Users\Stress\Desktop\rosa\AUTOMATIZ\MIXING_ELBOW"

for /F "usebackq tokens=1,2,3 delims=," %%I in (%input_file%) do (
    set "ID=%%I"
    set "V_Large= %%J"
    set "V_Small=%%K"

    echo Leyendo ID: %%I - Velocidad Grande: %%J - Velocidad Pequeña: %%K

    REM Crea la carpeta para el identificador si no existe
    echo Creando carpeta: ID_%%I
    if not exist "ID_%%I" (
        mkdir "ID_%%I"
        echo Carpeta ID_%%I creada.
    ) else (
        echo La carpeta ID_%%I ya existe. Saltando creación.
    )
   
    REM Cambia al directorio de la carpeta creada
    pushd "ID_%%I"
   
    REM Copia el archivo ACU-T1000_Manifold a la carpeta que se acaba de crear
    copy %base_dir%\mixingElbow.inp .  > nul
    if errorlevel 1 (
        echo Error al copiar mixingElbow.inp
    ) else (
        echo Archivo mixingElbow.inp copiado correctamente.
    )
   
    REM Copia la carpeta MESH.DIR a la carpeta que se acaba de crear
    xcopy %base_dir%\MESH.DIR .\MESH.DIR /E /I /Y  > nul
    if errorlevel 1 (
        echo Error al copiar la carpeta MESH.DIR
    ) else (
        echo Carpeta MESH.DIR copiada correctamente.
    )
 
  
    REM Vuelve al directorio anterior
    popd
)

ENDLOCAL


Answers

  • acupro
    acupro
    Altair Employee
    edited October 22

    I would probably use environment variables as in the previous question, rather than trying to edit/modify the input file itself.  It looks like you want:

    Vel_Long = 0.4
    Vel_Small = 1.2, 1.3, 1.4

    Vel_Long = 0.5
    Vel_Small = 1.2, 1.3

    Vel_Long = 0.6
    Vel_Small = 1.2, 1.4

    SIMPLE_BOUNDARY_CONDITION( "Small_Inlet" ) {
        surface_sets                        = { "mixingElbow.SurfaceSet_3.tria3.SolidBody_2_1.tet4" }
        type                                = inflow
        inflow_type                         = average_velocity
        precedence                          = 1
        average_velocity                    = Env( "V_Small")
    }

    SIMPLE_BOUNDARY_CONDITION( "Large_Inlet" ) {
        surface_sets                        = ...
        type                                = inflow
        inflow_type                         = average_velocity
        precedence                          = 1
        average_velocity                    = Env( "V_Large")
    }

    Then your .bat file executed from the AcuSolve Command Prompt would be something like:

    foreach vel ( 1.2 1.3 1.4 )
        setenv V_Long 0.4
        setenv V_Small $vel
        acuRun      (plus other necessary options to the acuRun command)
    end

    foreach vel (1.2 1.3 )
        setenv V_Long 0.5
        setenv V_Small $vel
        acuRun      (plus other necessary options to the acuRun command)
    end

    foreach vel (1.2 1.4 )
        setenv V_Long 0.6
        setenv V_Small $vel
        acuRun      (plus other necessary options to the acuRun command)
    end

    Then you'll end up with seven runs of the model - each with a different combination of V_Long and V_Small

    You may be able to set up these table-type runs in SimLab directly.

  • Rosa Esquer Cerezo
    Rosa Esquer Cerezo Altair Community Member
    edited October 23

    Thank you for the reply. I've tried to  put the 'setenv' command but it gives me an error:

    "setenv is not recognized as an internal or external command"

    I will think about install SimLab, but  i want it in this way  because we want to set the boundary conditions in an excel and the same document have a button that by clicking on in it, the simulations occur.

  • acupro
    acupro
    Altair Employee
    edited October 23

    Thank you for the reply. I've tried to  put the 'setenv' command but it gives me an error:

    "setenv is not recognized as an internal or external command"

    I will think about install SimLab, but  i want it in this way  because we want to set the boundary conditions in an excel and the same document have a button that by clicking on in it, the simulations occur.

    Right - setenv is probably Linux.  You need the equivalent for Windows.  Maybe

    set V_LONG=0.6
    set V_Small=$vel

    You'll need to discover the exact syntax for these things - how to grab a value from the 'foreach' line, set environment variables, etc.  That is not specific to the software - but rather Linux/Windows scripting.

    The questions about how to use Excel, create buttons, etc is also outside the software scope - but maybe others on Community can direct, or search other places.