ModalProblem

The main purpose of this class is to represent all relevant information for a modal analysis.

Note

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

Options

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

+----------------------------------------+
|     ModalProblem default options:      |
+----------------------------------------+
'outputDir': './'
	 Output directory for F5 file writer.
'L2Convergence': 1e-12
	 Absolute convergence tolerance for Eigenvalue solver based on l2 norm of residual.
'L2ConvergenceRel': 1e-12
	 Relative convergence tolerance for Eigenvalue solver based on l2 norm of residual.
'RBEStiffnessScaleFactor': 1000.0
	 Constraint matrix scaling factor used in RBE Lagrange multiplier stiffness matrix.
'RBEArtificialStiffness': 0.001
	 Artificial constant added to diagonals of RBE Lagrange multiplier stiffness matrix 
	 to stabilize preconditioner.
'subSpaceSize': 10
	 Subspace size for Krylov solver used by Eigenvalue solver.
'nRestarts': 15
	 Max number of resets for Krylov solver used by Eigenvalue solver.
'writeSolution': True
	 Flag for suppressing all f5 file writing.
'numberSolutions': True
	 Flag for attaching solution counter index to f5 files.
'printTiming': False
	 Flag for printing out timing information for class procedures.
'printLevel': 0
	 Print level for Eigenvalue solver.
	 Accepts:
		   0 : No printing.
		   1 : Print major iterations.
		 > 1 : Print major + minor iterations.

API Reference

class tacs.problems.ModalProblem(name, sigma, numEigs, assembler, comm, outputViewer=None, meshLoader=None, isNonlinear=False, options=None)[source]

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

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

  • sigma (float) -- Guess for the lowest eigenvalue. This corresponds to the lowest frequency squared. (rad^2/s^2)

  • numEigs (int) -- Number of eigenvalues to solve for

  • 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).

setOption(name, value)[source]

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

setValName(valName)[source]

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

Parameters:

valName (str) -- Name of the eigenvalue output used in evalFunctions().

getNumEigs()[source]

Get the number of eigenvalues requested from solver for this problem.

Returns:

numEigs -- Number of eigenvalues.

Return type:

int

addFunction(funcName, funcHandle, compIDs=None, **kwargs)[source]

NOT SUPPORTED FOR THIS PROBLEM

evalFunctions(funcs, evalFuncs=None, ignoreMissing=False)[source]

Evaluate eigenvalues for problem. The functions corresponding to the integers in evalFuncs are evaluated and updated into the provided dictionary.

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

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

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

Examples

>>> funcs = {}
>>> modalProblem.solve()
>>> modalProblem.evalFunctions(funcs, 'eigsm.0')
>>> funcs
>>> # Result will look like (if ModalProblem has name of 'c1'):
>>> # {'c1_eigsm.0':12354.10}
evalFunctionsSens(funcsSens, evalFuncs=None)[source]

This is the main routine for returning useful (sensitivity) information from problem. The derivatives of the functions corresponding to the strings in evalFuncs 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.

  • evalFuncs (iterable object containing strings) -- The functions the user wants returned

Examples

>>> funcsSens = {}
>>> modalProblem.evalFunctionsSens(funcsSens, 'eigsm.0')
>>> funcsSens
>>> # Result will look like (if ModalProblem has name of 'c1'):
>>> # {'c1_eigsm.0':{'struct':[1.234, ..., 7.89], 'Xpts':[3.14, ..., 1.59]}}
solve()[source]

Solve the eigenvalue problem.

getVariables(index, states=None)[source]

Return the current state values for one mode of the current problem

Parameters:
  • index (int) -- Mode index to return solution for.

  • states (tacs.TACS.Vec or numpy.ndarray or None) -- Place eigenvector for mode into this array (optional).

Returns:

  • eigVal (float) -- Eigenvalue for mode corresponds to square of eigenfrequency (rad^2/s^2)

  • states (numpy.ndarray) -- Eigenvector for mode

writeSolution(outputDir=None, baseName=None, number=None, indices=None)[source]

This is a generic shell function that writes the output file(s). The intent is that the user or calling program can call this function and pyTACS writes all the files that the user has defined. It is recommended that this function is used along with the associated logical flags in the options to determine the desired writing procedure

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 solution. Again, only typically used from an external solver

  • indices (int or list[int] or None) -- Mode index or indices to get state variables for. If None, returns a solution for all modes. Defaults to None.

dtype

alias of float64

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

getFunctionKeys()

Return a list of the current function key names

Returns:

funcNames -- List containing user-defined names for functions added so far.

Return type:

list[str]

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

property isNonlinear

The public interface for the isNonlinear attribute. Implemented as a property so that it is read-only.

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.

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().

writeSensFile(evalFuncs, tacsAim, proc: int = 0, root=0)

write an ESP/CAPS .sens file from the tacs aim Optional tacs_aim arg for TacsAim wrapper class object in root/tacs/caps2tacs/

Parameters:
  • evalFuncs (list[str]) -- names of TACS functions to be evaluated

  • tacsAim (tacs.caps2tacs.TacsAIM) -- class which handles the sensitivity file writing for ESP/CAPS shape derivatives

  • proc (int) -- which processor (in case of parallel tacsAIM instances) to write the sens file to

  • root (int) -- which processor we get the data from (usually proc 0)