powershellcmdcommand-lineansys

Run Ansys using powershell


I am trying to run Ansys using powershell. I am completely new in powershell environment. The only help I have got from Ansys website and different online forum is running ansys using the following command line prompt (cmd)

%ans_path% -b -np %num_proc% -j %job% -run %run% -i therm.inp -o trun.out

where %ans_path% , %num_proc% etc. are variables defined early.

Reference: https://deepthoughtdocs.flinders.edu.au/en/latest/software/ansys.html

How do I run this same code in Powershell? or Do I have to invoke CMD from powershell to run this code?

Would appreciate help any direction!


Solution

  • It is unlikely that cmd.exe would need to be invoked. A PowerShell command might be:

    & "C:\Program Files\ans\ansys212.exe" -b -np 4 -j 'the_job' -run 'the_run' -i therm.inp -o trun.out
    

    This assumes the the -np parameter is numeric and that -j and -run are strings that name the job and run respectively.

    If you wanted to do it "just like cmd," then you might:

    $AnsPath = 'C:\Program Files\ans\ansys212.exe'
    $NumProcessors = 4
    $JobName = 'the_job'
    $RunName = 'the_run'
    & $AnsPath -b -np $NumProcessors -j $JobName -run $RunName -i therm.inp -o trun.out