Creating the Extension for Connecting to a Third-Party Solver

The file ExtSolver1.xml follows.

 <extension version="1" name="ExtSolver1">

  <script src="[ext.Folder]\main.py" />

  <interface context="Mechanical">
    
    <images>[ext.Folder]\images</images>

    <callbacks>
      <onload>Load</onload>
      <onsave>Save</onsave>
    </callbacks>

    <toolbar name="ExtSolver1" caption="ExtSolver1">
      <entry name="Values Load" icon="tload">
        <callbacks>
          <onclick>CreateValuesLoad</onclick>
        </callbacks>
      </entry>
    </toolbar>

  </interface>

  <simdata context="Project|Mechanical">

    <solver name="Solver1" version="1" caption="Solver1" icon="result" analysis="Static" physics="Structural">

      <callbacks>
        <onsolve>Solve</onsolve>
        <getsteps>GetSteps</getsteps>
        <getreader>GetReader</getreader>
      </callbacks>

      <property name="MaxIter" caption="Max. Iterations" control="integer" default="10" />

    </solver>

  </simdata>

  <simdata context="Mechanical">

    <load name="Values" version="1" caption="Values" icon="tload" issupport="false" isload="true" color="#0000FF">

      <callbacks>
        <getsolvecommands>WriteInitialValues</getsolvecommands>
        <getnodalvaluesfordisplay>NodeValues</getnodalvaluesfordisplay>
      </callbacks>

      <property name="Geometry" control="scoping" />
      <property name="Expression" caption="Expression" control="text" />

    </load>

  </simdata>

</extension>

In this file, the element <simdata> has child elements that define the solver. The attribute context is Project|Mechanical. When Project is specified, the solver appears as a system in the Mechanical Toolbox.

 


Note:  Custom solver-based systems support general data transfer to their Model, Setup, and Solution tasks. For an explanation of general data transfer, see Defining Task-Level Data Transfer in the ACT Customization Guide for Mechanical.


The child element <solver> has some mandatory attributes:

  • name: Internal name of the solver

  • version: Version of the solver

  • caption: Display name of the solver

  • analysis: Analysis type addressed by the solver. For compatibility reasons, this attribute must be set to Static, but this does not prevent you from integrating any type of third-party solver.

  • physics: Physics type addressed by the solver. This attribute must be set to Structural, even though it has no real impact on what the solver computes.

You must define the callback <onsolve>. This callback is invoked when the product starts the solver, thereby taking the object solver as an argument.

You can define a set of properties, which appear in the Details view of the analysis. In this example, the property MaxIter is created. It is an integer value for defining the maximum number of iterations that the solver is to perform. The default value is set to 10.

As shown in the earlier figure, a new system for the third-party solver ExtSolver1 is added to the Toolbox. Each third-party solver is added into a new category, identified by the caption of the extension. The system is named by the caption of the solver.

The system related to the third-party solver is equivalent to one standard system that can be created with the Ansys solver. The components that build this new system remain the same. You can add the new system related to the solver to the Project Schematic just as you do for any other system.