Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

AQWA user force

    • Lijie Yuan
      Subscriber

      Hi!

      I'm currently having problems implementing user Force using python. I first implemented the modeling, meshing, and computational parameter settings through workbench, and finally got two dat files in the dp0 folder for AQW and AQW-1 respectively.I did the user force calculation with reference to Aqwa_Reference_Manual after adding the SUFC option to the Timeresponse.dat file. It shows user force error number 1.
      What is the problem please?

      from AqwaServerMgr import *
      def UF1(Analysis,Mode,Stage,Time,TimeStep,Pos,Vel):
          # Check that input file is the one expected without .DAT extension
      
          Error   = 0
      
          ExpectedFileName = "TimeResponse"
          ActualFileName = Analysis.InputFileName.split("\\")[-1] # We strip the path part of the filename for easy comparison
          if (ActualFileName!=ExpectedFileName):
              print("Error. Incorrect input file !")
              print("Expected : "+ ExpectedFileName)
              print("Actual : "+ActualFileName)
              Error = 1    # Will cause Aqwa to stop
      
          # If this passed, we create an empty container for AddMass and Force
          AddMass = BlankAddedMass(Analysis.NOfStruct)
          Force   = BlankForce(Analysis.NOfStruct)
      
          # User defined code here
          # Here additional inertial force for structure s : F[s][dof] = AddMass[s][dof2][dof] * Acc[s][dof2]
          # (Einstein notation, and Python Row-Major order of array indices)
          for s in range(Analysis.NOfStruct):
              for dof in range(6):
                  Force[s][dof] = -10000.0*Pos[s][dof] # Elastic Force
                  for dof2 in range(6):
                      AddMass[s][dof2][dof]=1e-3*(dof2*6+dof) # AddMass goes [0.000, 0.001, 0.002, ..., 0.036]
      
          # Now return the results
      
          return Force,AddMass,Error
      
      Server = AqwaUserForceServer()
      
      print('-----------------')
      print('Running user force function UF1')
      print('Simulating...')
      print('-----------------')
      Server.Run(UF1)
    • Mike Pettit
      Ansys Employee

      Hello,

      You should not need to add the SUFC option manually - you can set this in Workbench from the time domain Analysis Settings, under Common Analysis Options:

      You also need to start the Python server before the time domain analysis is launched. You can do this using a pre-solve Python script, or you can do it manually from the Windows command line. You can find an example of the Python server code in the Ansys installation, at C:\Program Files\ANSYS Inc\v232\aqwa\utils\ExternalForceCalculation\AqwaServerMgr.py (change the 'v232' as necessary for your installed version). You should not need to modify the code in AqwaServerMgr.py.

      I hope this helps!

      Mike

    • Ingrid M
      Ansys Employee

      Hello, 

      in addition to Mike's reply, in your installation, in your Ansys installation folder (under v\aqwa\utils\ExternalForceCalculation) , you have the complete example of the script you are sharing. There is also a readme.txt and the bat file to start the server gracefully based on the python version installed in the application.

      I hope this helps,

      Ingrid

    • Ingrid M
      Ansys Employee

      Hello again, 

      To be more specific, you don't run the AqwaServerMgr.py but the AqwaSocketUserForceExample.py file from the installation. The latter file calls the AqwaServerMgr when the server.run() command is fired.

      If you run the whole simulation as command (like the readme in the installation folder), you just need to run:

      on one side: \your path to python\python.exe AqwaSocketUserForceExample.py

      on the other side: \you path to aqwa\aqwa.exe timeresponse.dat

      I hope this helps.

Viewing 3 reply threads
  • The topic ‘AQWA user force’ is closed to new replies.