# Communication between OptiStruct and AcuSolve

OptiStruct and AcuSolve can be run on heterogeneous and remote platforms which are located on the same network domain. The communication between OptiStruct and AcuSolve is via sockets.

To start a coupled simulation between OptiStruct and AcuSolve, one of them should be run first to initiate the communication process, while the other will subsequently connect to the initiated communication process.

## Communication Initiation

In OptiStruct the socket port number is specified by the PORT field of the FSI Bulk Data Entry. The default port number is 10000. This same port number must be specified in the socket_port entry of the EXTERNAL_CODE block in the AcuSolve input file (filename.inp). If the machine that OptiStruct is running on is named machine1, then the EXTERNAL_CODE will look like:
EXTERNAL_CODE {
communication= socket
socket_initiate= no
socket_host= "machine1"
socket_port= 10000
}

OptiStruct and AcuSolve should be started independently. OptiStruct will wait for AcuSolve to initiate the socket connection (or vice-versa). The time that OptiStruct will wait (in seconds, after pre-processing is complete) is determined by the WAITTIME field on the FSI Bulk Data Entry (the default value is 3600 seconds). Similarly, the time (in seconds, after pre-processing is complete) that AcuSolve will wait until OptiStruct initiates communication at the socket is determined by the external_code_wait_time field in the Acusim.cnf file (or the -ecwait run option).

The wait time counting is initiated after pre-processing of the input file in both OptiStruct and AcuSolve. The following example schematic illustrates one scenario wherein OptiStruct is initiated first and waits for AcuSolve.
The wait time input by you determines the time the solver will wait until the initial handshake. After this initial handshake, the wait time no longer applies. When the wait time specified expires, and the second solver has still not begun communication with the first, then the solver that was started first will error out (Figure 2).
Note: AcuSolve is not started, so OptiStruct exits the solution after the wait time expires.

Before the start of the time step loops, basic information about the interface must be exchanged between the two software. First, a number of parameters controlling the interface strategy must be set for both. Second, the physical parameters of the interface must be defined.

## Time Steps and Data Exchanges

For AcuSolve, in conjunction to the EQUATION command, which specifies the existence of solution fields in the problem, you must use TIME_SEQUENCE and STAGGER commands to define time stepping and staggering strategy. The preferred method is to use the AUTO_SOLUTION_STRATEGY command to have AcuSolve generate the solution strategy commands. For OptiStruct, the data exchange parameters are available on the FSI Bulk Data Entry and time stepping data is specified on the NLPARM, TSTEP, or TSTEPNL entries (depending upon the type of solution or data). See the corresponding SFSI or TFSI User Guide pages for more information.

Both OptiStruct and AcuSolve need to use the same time step size and the total number of time steps should be the same. Also, the size of the time step needs to remain constant in both OptiStruct and AcuSolve. For example, for 100 time steps of 0.001 seconds each the OptiStruct and AcuSolve data are:
AUTO_SOLUTION_STRATEGY {
initial_time_increment = 0.001
max_time_steps = 101
min_stagger_iterations= 1
max_stagger_iterations= 20
}

and

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10)
NLPARM 5 40 1.0e-3     80 UP
1.0e-2 1.0e-5
1.0e-1
Note: For AcuSolve the maximum number of time steps set should be one greater than the maximum number of times steps set for the corresponding OptiStruct model.

At each time step, solution variables (displacement/pressures for SFSI, temperature/flux for TFSI) are exchanged between OptiStruct and AcuSolve until they converge to a certain tolerance. Once convergence is achieved, the analysis continues on to the next time step. These exchanges are called staggers in AcuSolve. The minimum number of staggers (called exchanges in OptiStruct) can be specified by the min_stagger_iterations parameter in the AcuSolve AUTO_SOLUTION_STRATEGY block, this is also influenced by other AcuSolve run parameters. The minimum number of exchanges in OptiStruct can be specified by the MINEX field in the OptiStruct FSI Bulk Data Entry.

The maximum number of staggers is set by the max_stagger_iterations parameter in the AcuSolve AUTO_SOLUTION_STRATEGY block, this is also influenced by other AcuSolve run parameters. The maximum number of exchanges in OptiStruct can be specified by the MAXEX field in the FSI Bulk Data Entry.

The maximum or minimum number of exchanges (MAXEX/MINEX) is set in the OptiStruct model. There may be multiple locations within the AcuSolve model, where the maximum/minimum number of staggers are defined. The FSI run will use the lowest maximum number of exchanges/staggers and the highest minimum number of exchanges/staggers out of all available such specified data. Therefore, depending on AcuSolve, each time increment may end within a subset space lesser than or equal to [MINEX,MAXEX].

The solution variable convergence tolerances are used to reduce the number of exchanges/staggers to that required receive stable and accurate results. This may significantly reduce run times while generating results. The solution variable tolerances are specified by the FCNVTOL, DCNVTOL, TCNVTOL, and FXCNVTOL fields on the FSI Bulk Data Entry. If these tolerances are set high, the solution time will be reduced, but solution accuracy may also be affected. The convergence_tolerance parameter can also be used to define convergence tolerances in the AcuSolve input data.