AdjacencyConstraint

The main purpose of this class is to constrain design variables step sizes across adjacent components. The formulation is a linear constraint that takes the following form:

c = dv_i - dv_j

Where dv_i and dv_j are two design variables in adjacent components.

A common example of this is ensuring that thicknesses vary to abruptly across panel boundaries:

-delta_t < t_i - t_j < delta_t

Note

This class should be created using the pyTACS.createAdjacencyConstraint method.

Options

Options can be set for AdjacencyConstraint at time of creation for the class in the pyTACS.createAdjacencyConstraint method or using the AdjacencyConstraint.setOption method. Current option values for a class instance can be printed out using the AdjacencyConstraint.printOption method. The following options, their default values and descriptions are listed below:

+----------------------------------------+
|  AdjacencyConstraint default options:  |
+----------------------------------------+
'outputDir': './'
	 Output directory for F5 file writer.
'numberSolutions': True
	 Flag for attaching solution counter index to f5 files.

API Reference

class tacs.constraints.AdjacencyConstraint(name, assembler, comm, outputViewer=None, meshLoader=None, options=None)[source]

NOTE: This class should not be initialized directly by the user. Use pyTACS.createAdjacencyConstraint instead.

Parameters:
  • name (str) -- Name of this tacs problem

  • assembler (TACS.Assembler) -- Cython object responsible for creating and setting tacs objects used to solve problem

  • comm (mpi4py.MPI.Intracomm) -- The comm object on which to create the pyTACS object.

  • outputViewer (TACS.TACSToFH5) -- Cython object used to write out f5 files that can be converted and used for postprocessing.

  • meshLoader (pymeshloader.pyMeshLoader) -- pyMeshLoader object used to create the assembler.

  • options (dict) -- Dictionary holding problem-specific option parameters (case-insensitive).

addConstraint(conName, compIDs=None, lower=-1e+20, upper=1e+20, dvIndex=0)[source]

Generic method to adding a new constraint set for TACS.

Parameters:
  • conName (str) -- The user-supplied name for the constraint set. This will typically be a string that is meaningful to the user

  • compIDs (list[int] or None) -- List of compIDs to select. If None, all compIDs will be selected. Defaults to None.

  • lower (float or complex) -- lower bound for constraint. Defaults to -1e20.

  • upper (float or complex) -- upper bound for constraint. Defaults to 1e20.

  • dvIndex (int) -- Index number of element DV to be used in constraint. Defaults to 0.

evalConstraints(funcs, evalCons=None, ignoreMissing=False)[source]

Evaluate values for constraints. The constraints corresponding to the strings in evalCons are evaluated and updated into the provided dictionary.

Parameters:
  • funcs (dict) -- Dictionary into which the constraints are saved.

  • evalCons (iterable object containing strings.) -- If not none, use these constraints to evaluate.

  • ignoreMissing (bool) -- Flag to supress checking for a valid constraint. Please use this option with caution.

Examples

>>> funcs = {}
>>> adjConstraint.evalConstraints(funcs, 'LE_SPAR')
>>> funcs
>>> # Result will look like (if AdjacencyConstraint has name of 'c1'):
>>> # {'c1_LE_SPAR': array([12354.10])}
evalConstraintsSens(funcsSens, evalCons=None)[source]

This is the main routine for returning useful (sensitivity) information from constraint. The derivatives of the constraints corresponding to the strings in evalCons are evaluated and updated into the provided dictionary. The derivitives with respect to all design variables and node locations are computed.

Parameters:
  • funcsSens (dict) -- Dictionary into which the derivatives are saved.

  • evalCons (iterable object containing strings) -- The constraints the user wants returned

Examples

>>> funcsSens = {}
>>> adjConstraint.evalConstraintsSens(funcsSens, 'LE_SPAR')
>>> funcsSens
>>> # Result will look like (if AdjacencyConstraint has name of 'c1'):
>>> # {'c1_LE_SPAR':{'struct':<50x242 sparse matrix of type '<class 'numpy.float64'>' with 100 stored elements in Compressed Sparse Row format>}}
writeVisualization(outputDir=None, baseName=None, number=None)[source]

This function can be used to write a tecplot file for the purposes of visualization.

Parameters:
  • outputDir (str or None) -- Use the supplied output directory

  • baseName (str or None) -- Use this supplied string for the base filename. Typically only used from an external solver.

  • number (int or None) -- Use the user supplied number to index output. Again, only typically used from an external solver

dtype

alias of float64

getConstraintBounds(bounds, evalCons=None)

Get bounds for constraints. The constraints corresponding to the strings in evalCons are evaluated and updated into the provided dictionary.

Parameters:
  • bounds (dict) -- Dictionary into which the constraint bounds are saved. Bounds will be saved as a tuple: (lower, upper)

  • evalCons (iterable object containing strings.) -- If not none, use these constraints to evaluate.

Examples

>>> conBounds = {}
>>> tacsConstraint.getConstraintBounds(conBounds, 'LE_SPAR')
>>> conBounds
>>> # Result will look like (if TACSConstraint has name of 'c1'):
>>> # {'c1_LE_SPAR': (array([-1e20]), array([1e20]))}
getConstraintKeys()

Return a list of the current constraint key names

Returns:

conNames -- List containing user-defined names for constraint groups added so far.

Return type:

list[str]

getConstraintSizes(sizes, evalCons=None)

Get number for constraint equations in each set. The constraints corresponding to the strings in evalCons are evaluated and updated into the provided dictionary.

Parameters:
  • sizes (dict) -- Dictionary into which the constraint sizes are saved.

  • evalCons (iterable object containing strings.) -- If not none, use these constraints to evaluate.

Examples

>>> conSizes = {}
>>> tacsConstraint.getConstraintSizes(conSizes, 'LE_SPAR')
>>> funconSizescs
>>> # Result will look like (if TACSConstraint has name of 'c1'):
>>> # {'c1_LE_SPAR': 10}
getDesignVarRange()

get the lower/upper bounds for the design variables.

Returns:

  • xlb (numpy.ndarray) -- The design variable lower bound.

  • xub (numpy.ndarray) -- The design variable upper bound.

getDesignVars()

Get the current set of design variables for this problem.

Returns:

x -- The current design variable vector set in tacs.

Return type:

numpy.ndarray

getNodes()

Return the mesh coordinates of this problem.

Returns:

coords -- Structural coordinate in array of size (N * 3) where N is the number of structural nodes on this processor.

Return type:

numpy.ndarray

getNumCoordinates()

Return the number of mesh coordinates on this processor.

Returns:

ncoords -- Number of mesh coordinates on this processor.

Return type:

int

getNumDesignVars()

Return the number of design variables on this processor.

Returns:

ndvs -- Number of design variables on this processor.

Return type:

int

getNumOwnedNodes()

Get the number of nodes owned by this processor.

Returns:

nnodes -- Number of nodes on this processor.

Return type:

int

getNumVariables()

Return the number of degrees of freedom (states) that are on this processor

Returns:

nstate -- number of states.

Return type:

int

getOption(name)

Get a solver option value. The name is not case sensitive.

Parameters:

name (str) -- Name of option to get

getVarsPerNode()

Get the number of variables per node for the model.

Returns:

vpn -- Number of variables per node.

Return type:

int

classmethod printDefaultOptions()

Prints a nicely formatted dictionary of all the default solver options to the stdout

printModifiedOptions()

Prints a nicely formatted table of all the options that have been modified from their defaults

printOptions()

Prints a nicely formatted dictionary of all the current solver options to the stdout on the root processor

setDesignVars(x)

Update the design variables used by tacs.

Parameters:

x (numpy.ndarray or dict or tacs.TACS.Vec) -- The variables (typically from the optimizer) to set. It looks for variable in the self.varName attribute if in dict.

setNodes(Xpts)

Set the mesh coordinates of the structure.

Parameters:

Xpts (numpy.ndarray) -- Structural coordinate in array of size (N * 3) where N is the number of structural nodes on this processor.

setOption(name, value)

Set a solver option value. The name is not case sensitive.

Parameters:
  • name (str) -- Name of option to modify

  • value (depends on option) -- New option value to set

setOptions(options)

Set multiple solver options at once. The names are not case sensitive.

Parameters:

options (dict) -- Dictionary of option names and values to set

setVarName(varName)

Set a name for the structural variables in pyOpt. Only needs to be changed if more than 1 pytacs object is used in an optimization

Parameters:

varName (str) -- Name of the structural variable used in addVarGroup().