# ttrr – TrussTopologyRobustRedundant¶

platform: Unix ttrr is a software package to do topology optimization of a truss with respect to robustness and redundancy.

TrussTopologyRobustRedundant

Contents

• ttrr – TrussTopologyRobustRedundant

## description¶

ttrr is a software package to do topology optimization of a truss with respect to robustness and redundancy — see literatur.

There are 2 parts of ttrr:

• library:

You can use ttrr as a library to import to your own python-code. To calculate trusses ttrr needs ttrr_calculate resp. ttrr_calculate.cc

• command line tool:

you can use ttrr_tools.py as a command line tool. for detail:

```ttrr_tools.py -h
```
functions to include from ttrr resp. ttrr.py: (in alphabetical order)

## typical parameters¶

dim : integer
dimension 2 or 3 of the design space
nodes : numpy.array

is a matrix to represent all nodal points with:

• nodes(k,:) are the nodal points.
• nodes(:,1) are the x-coordinates of the nodal points.
• nodes(:,2) are the y-coordinates of the nodal points.
• nodes(:,3) are the z-coordinates of the nodal points. (mostly optional)
bars : numpy.array

is a vector to represent all trusses:

• bars(s,:) are numbers of the trusses.
• bars(:,1) is the number of the first nodal point.
• bars(:,2) is the number of the second nodal point.
mounting : numpy.array
are the numbers of the nodal points as for the coordinate direction which are fixed.

smax : float
is the maximum allowed cross section of a truss
opt : integer

choose the optimization routine: (optional)

• 0 glp_simplex (default, iff redundancy == 0)
• 1 glp_interior (only for redundancy == 0)
• 2-5 glp_mip (for redundancy != 0)
• 2 do not search greedy-solution (default, for redundancy != 0)
• 3 search greedy-solution and go on
• 4 search greedy-solution, write greedy solution and go on
• 5 search greedy-solution and stop

## functions¶

Parameters:
dim : integer
dimension 2 or 3 of the design space
p : float
percentage of magnitude of the unperturbed force is used for the perturbation. p*norm(loads[:,k]) is the magnitude of the perturbation of the load case k.
art : integer

chooses the kind of the perturbation: (optional)

art == 0
generates perturbations in every direction of the original forces and scales them. The maximal magnitude of the forces is the same. (default)
art == 1
generates perturbations in every direction of the original forces. The maximal magnitude of the forces changes.
art : integer

waehlt die Art die gestoerrten Kraefte zu erstellen (optional)

art == 0
erzeuge Stoerrung um p*norm(kraft) in jede Richtung. skaliere die Kraefte so, dass die maximale Kraftgroesse gleich bleibt (default)
art == 1
erzeuge Stoerrung um p*norm(kraft) in jede Richtung. Achtung: maximale Kraftgroesse aendert sich

Author: Daniel Mohr.

Date: 2012-01-23, 2012-01-28, 2012-02-27 (last change)

Copyright (C) 2011, 2012 Daniel Mohr

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/

ttrr.nodenumberfromcoordinates(nodes, x, y, z=0, eps=1.4901161193847656e-08)

kk = nodenumberfromcoordinates(nodes,x,y,z=0,eps=_epsilon) calculates the number of a node from the coordinates.

nodes is a matrix to represent all nodal points with
nodes(k,:) are the nodal points nodes(:,1) are the x-coordinates of the nodal points nodes(:,2) are the y-coordinates of the nodal points nodes(:,3) are the z-coordinates of the nodal points (optional)
x,y,z gives the coordinate of the wanted node.
If the dimension of the design space (it is get from the dimension of nodes) is 2 z is ignored. z is optional.
eps is a bound for the possible difference between the coordinate of
the wanted node and given coordinate.

Author: Daniel Mohr Date: 2012-01-23, 2012-01-28 (last change) License: GNU GENERAL PUBLIC LICENSE, Version 3, 29 June 2007

Copyright (C) 2012 Daniel Mohr This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/

ttrr.barsnodesongrid2d(gx0, gx1, gy0, gy1, nelx, nely, mounting=0)

[nodes,bars]=barsnodesongrid2d(gx0,gx1,gy0,gy1,nelx,nely,mounting=0)

creates all bars and nodes which make sense. gx0, gx1, gy0 and gy1 describes the edges (gx0,gy0), (gx0,gy1), (gx1,gy0) and (gx1,gy1) of the rectangular design space. In this rectangle it will be nelx*nely nodes calculated. With the assumption of an equidistant grid all meaningful bars are calculated. Bars which can be represent of others are ignored. For example a bar from (0,0) to (0,1) is ignored, if bars from (0,0) to (0,0.5) and from (0,0.5) to (0,1) exist.

Parameters:
gx0 : float
lower bound of the x-cooredinates to describe the rectangle
gx1 : float
upper bound of the x-cooredinates to describe the rectangle
gy0 : float
lower bound of the y-cooredinates to describe the rectangle
gy0 : float
upper bound of the y-cooredinates to describe the rectangle
nelx : integer
is the number of nodes in x-direction
nely : integer
is the number of nodes in y-direction
mounting : numpy.array
are the numbers of the nodal points as for the coordinate direction which are fixed. (optional) If denoted bars fixed on both ends will be ignored.
Returns:
nodes : numpy.array

is a matrix to represent all nodal points with:

• nodes(k,:) are the nodal points.
• nodes(:,1) are the x-coordinates of the nodal points.
• nodes(:,2) are the y-coordinates of the nodal points.
• nodes(:,3) are the z-coordinates of the nodal points. (mostly optional)
bars : numpy.array

is a vector to represent all trusses:

• bars(s,:) are numbers of the trusses.
• bars(:,1) is the number of the first nodal point.
• bars(:,2) is the number of the second nodal point.

Author: Daniel Mohr.

Date: 2010-09-09, 2011-06-24, 2012-01-24 (last change)

Copyright (C) 2009, 2010, 2011, 2012 Daniel Mohr

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/

ttrr.barsnodesongrid3d(gx0, gx1, gy0, gy1, gz0, gz1, nelx, nely, nelz, mounting=0, areawithoutnode=0, mountingarea=0, maxstablaenge=-1)

[nodes,bars]=barsnodesongrid3d(gx0,gx1,gy0,gy1,gz0,gz1,nelx, nely,nelz,mounting=0,areawithoutnode=0,maxstablaenge=-1) [nodes,bars,mounting]=barsnodesongrid3d(gx0,gx1,gy0,gy1,gz0,gz1,nelx,

nely,nelz,areawithoutnode=0,mountingarea=0, maxstablaenge=-1)

creates all bars and nodes which make sense. If mountingarea is denoted the fixed nodes are also calculated and returned. gx0, gx1, gy0, gy1, gz0 and gz1 describes the edges (gx0,gy0,gz0), (gx0,gy0,gz1), (gx0,gy1,gz0), (gx0,gy1,gz1) (gx1,gy0,gz0), (gx1,gy0,gz1), (gx1,gy1,gz0) and (gx1,gy1,gz1) of the cuboid-shaped design space. In this cuboid it will be nelx*nely*nelz nodes calculated. With the assumption of an equidistant grid all meaningful bars are calculated. Bars which can be represent of others are ignored. For example a bar from (0,0,0) to (0,0,2) is ignored, if bars from (0,0,0) to (0,0,1) and from (0,0,1) to (0,0,2) exist.

Parameters:
gx0 : float
lower bound of the x-cooredinates to describe the rectangle
gx1 : float
upper bound of the x-cooredinates to describe the rectangle
gy0 : float
lower bound of the y-cooredinates to describe the rectangle
gy0 : float
upper bound of the y-cooredinates to describe the rectangle
gz0 : float
lower bound of the z-cooredinates to describe the rectangle
gz0 : float
upper bound of the z-cooredinates to describe the rectangle
nelx : integer
is the number of nodes in x-direction
nely : integer
is the number of nodes in y-direction
nelz : integer
is the number of nodes in z-direction
mounting : numpy.array
are the numbers of the nodal points as for the coordinate direction which are fixed. (optional) If denoted bars fixed on both ends will be ignored.
areawithoutnode : numpy.array
is a matrix describing areas without nodes (optional) In every row are 6 values ax, bx, ay, by, az, bz. Nodes with coordinate (kx,ky,kz) and (ax<=kx<=bx and ay<=ky<=by and az<=kz<=bz) will be ignored for the bars. Theses nodes are in nodes. But no bar will be connect to these nodes.
mountingarea : numpy.array
is a matrix describing areas where the nodes are fixed. (optional) In every row are 6 values ax, bx, ay, by, az, bz. Nodes with coordinate (kx,ky,kz) and (ax<=kx<=bx and ay<=ky<=by and az<=kz<=bz) are considered as fixed nodes. If mountingarea is denoted also mounting will be returned. The paarameter mounting will be ignored. But the affected bars will be ignored.
maxstablaenge : float
Bars which are longer than maxstablaenge will be ignored.
Returns:
nodes : numpy.array

is a matrix to represent all nodal points with:

• nodes(k,:) are the nodal points.
• nodes(:,1) are the x-coordinates of the nodal points.
• nodes(:,2) are the y-coordinates of the nodal points.
• nodes(:,3) are the z-coordinates of the nodal points.
bars : numpy.array

is a vector to represent all trusses:

• bars(s,:) are numbers of the trusses.
• bars(:,1) is the number of the first nodal point.
• bars(:,2) is the number of the second nodal point.
mounting : numpy.array
are the numbers of the nodal points as for the coordinate direction which are fixed. (optional) It will will be returned only if mountingarea is denoted.

Author: Daniel Mohr.

Date: 2011-06-24, 2012-01-24, 2012-01-25 (last change)

Copyright (C) 2011, 2012 Daniel Mohr

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/

ttrr.ttrr(dim, nodes, bars, mounting, loads, smax, name='test', sigmamin=-100000000.0, sigmamax=100000000.0, density=2700.0, redundancy=0, opt=0, undisturbed_forces=0, sort=0, zlb=0, zub=0, scale_sigma=-1.0, scale_forces=-1.0)

opt=0,undisturbed_forces=0,sort=0,zlb=0,zub=0, scale_sigma=-1,scale_forces=-1)

Parameters:

dim : integer
dimension 2 or 3 of the design space
nodes : numpy.array

is a matrix to represent all nodal points with:

• nodes(k,:) are the nodal points.

• nodes(:,1) are the x-coordinates of the nodal points.

• nodes(:,2) are the y-coordinates of the nodal points.

• nodes(:,3) are the z-coordinates of the nodal points.

(optional for dim = 2)

bars : numpy.array

is a vector to represent all trusses:

• bars(s,:) are numbers of the trusses.
• bars(:,1) is the number of the first nodal point.
• bars(:,2) is the number of the second nodal point.
mounting : numpy.array
are the numbers of the nodal points as for the coordinate direction which are fixed.

smax : float
is the maximal allowed cross section of a bar. If you do not need it, set it to a huge value — e. g. 1.
name : string
is a name for the problem. The result is saved in name.tar.bz2 in the current working directory.
sigmamin : float
lower limit for the allowed stress, e.g. compressive strength (e.g. -1e8 Pa for aluminium or -4e8 Pa for some steel)
sigmamax : float
upper limit for the allowed stress, e.g. tensile strength (e.g. 1e8 Pa for aluminium or 4e8 Pa for some steel)
density : float
density (e.g. 2.7e3 kg/m^3 for aluminium or 7e3 kg/m^3 for some steel)
redundancy : integer
describes the redundancy. If redundancy != 0 this function is not the right one. ttrr_redundant() will be called.
opt : integer

choose the optimization routine: (optional)

• 0 glp_simplex (default, iff redundancy == 0)

• 1 glp_interior (only for redundancy == 0)

• 2-6 glp_mip (only for redundancy != 0, therefore not in this

function) see ttrr_redundant()

undisturbed_forces : numpy.array
is not used. It will be saved to the problem data.
sort : integer

describes a feature: (optional)

• 0 not used (default)

problem. This is only useful for redundancy != 0. see ttrr_redundant()

zlb : float
is a lower bound for the objective function. As we are minimizing the result must not the best solution. Only values greater zero are considered. (optional)
zub : float
is a upper bound for the objective function. As we are minimizing the optimization problem may be not solvable. Only values greater zero are considered. (optional)
scale_sigma : float
scales sigmamin and sigmamax for the calculation. (optional)
• < 0.0 no scaling will be done (default)
• = 0.0 autoscaling will be done
• > 0.0 scaling will be done with this value
scale_forces : float
scales loads for the calculation. (optional)
• < 0.0 no scaling will be done (default)
• = 0.0 autoscaling will be done
• > 0.0 scaling will be done with this value

Author: Daniel Mohr.

Date: 2012-02-19 (last change)

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/

ttrr.ttrr_redundant(dim, nodes, bars, mounting, loads, smax, name='test', sigmamin=-100000000.0, sigmamax=100000000.0, density=2700.0, redundancy=0, opt=2, undisturbed_forces=0, sort=0, zlb=0, zub=0, scale_sigma=-1.0, scale_forces=-1.0)

sigmamax=1e8,density=2.7e3,redundancy=0, opt=2,undisturbed_forces=0,sort=0, zlb=0,zub=0, scale_sigma=-1,scale_forces=-1)

Parameters:

dim : integer
dimension 2 or 3 of the design space
nodes : numpy.array

is a matrix to represent all nodal points with:

• nodes(k,:) are the nodal points.

• nodes(:,1) are the x-coordinates of the nodal points.

• nodes(:,2) are the y-coordinates of the nodal points.

• nodes(:,3) are the z-coordinates of the nodal points.

(optional for dim = 2)

bars : numpy.array

is a vector to represent all trusses:

• bars(s,:) are numbers of the trusses.
• bars(:,1) is the number of the first nodal point.
• bars(:,2) is the number of the second nodal point.
mounting : numpy.array
are the numbers of the nodal points as for the coordinate direction which are fixed.

smax : float
is the maximal allowed cross section of a bar. If you do not need it, set it to a huge value — e. g. 1. It is nessecary for the interaction of the integer values and the cross section values (for redundancy != 0).
name : string
is a name for the problem. The result is saved in name.tar.bz2 in the current working directory.
sigmamin : float
lower limit for the allowed stress, e.g. compressive strength (e.g. -1e8 Pa for aluminium or -4e8 Pa for some steel)
sigmamax : float
upper limit for the allowed stress, e.g. tensile strength (e.g. 1e8 Pa for aluminium or 4e8 Pa for some steel)
density : float
density (e.g. 2.7e3 kg/m^3 for aluminium or 7e3 kg/m^3 for some steel)
redundancy : integer
describes the redundancy. If redundancy == 0 this function is not the right one. ttrr() will be called. A value greater 0 describes a 1/redundancy redundancy — therefore redundancy >= 2 makes sense. A value lower 0 descirbes a 1-1/redundancy redundancy — therefore redundancy <= 2 makes sense. Obviosly 1/2 = 1-1/2 are the same redundancy. But the problem and the calculation are different. If there is no error the results are equal.
opt : integer

choose the optimization routine: (optional)

• 0 glp_simplex (only for redundancy == 0)

• 1 glp_interior (only for redundancy == 0)

• 2-6 glp_mip (for redundancy != 0)

• 2 do not search greedy-solution (default)

• 3 search greedy-solution and go on

• 4 search greedy-solution, write greedy solution and go on

• 5 search greedy-solution and stop

• 6 search in parallel with 2 and 3 and stop

after solution is found with one method

undisturbed_forces : numpy.array
is not used. It will be saved to the problem data.
sort : integer

describes a feature: (optional)

• 0 not used (default)

problem. This is only useful for redundancy != 0. If s_i describes a vector of the cross section of the i-th part structure the constraints are l^T s_i <= l^T s_{i+1} for adequate i with l the vector of the lengths of all bars.

zlb : float
is a lower bound for the objective function. As we are minimizing the result must not the best solution. Only values greater zero are considered.
zub : float
is a upper bound for the objective function. As we are minimizing the optimization problem may be not solvable. Only values greater zero are considered.
scale_sigma : float
scales sigmamin and sigmamax for the calculation. (optional)
• < 0.0 no scaling will be done (default)
• = 0.0 autoscaling will be done
• > 0.0 scaling will be done with this value
scale_forces : float
scales loads for the calculation. (optional)
• < 0.0 no scaling will be done (default)
• = 0.0 autoscaling will be done
• > 0.0 scaling will be done with this value

Author: Daniel Mohr.

Date: 2013-08-30 (last change)

Copyright (C) 2012, 2013 Daniel Mohr

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/

ttrr.ttrr_robust(dim, nodes, bars, mounting, loads, smax, name='test', sigmamin=-100000000.0, sigmamax=100000000.0, density=2700.0, redundancy=0, opt=0, undisturbed_forces=0, p=0.1, art=0, sort=0, zlb=0, zub=0, scale_sigma=-1.0, scale_forces=-1.0)

sigmamax=1e8,density=2.7e3,redundancy=0, opt=0,undisturbed_forces=0,p=0.1,art=0, sort=0,zlb=0,zub=0, scale_sigma=-1,scale_forces=-1)

Parameters:

dim : integer
dimension 2 or 3 of the design space
nodes : numpy.array

is a matrix to represent all nodal points with:

• nodes(k,:) are the nodal points.

• nodes(:,1) are the x-coordinates of the nodal points.

• nodes(:,2) are the y-coordinates of the nodal points.

• nodes(:,3) are the z-coordinates of the nodal points.

(optional for dim = 2)

bars : numpy.array

is a vector to represent all trusses:

• bars(s,:) are numbers of the trusses.
• bars(:,1) is the number of the first nodal point.
• bars(:,2) is the number of the second nodal point.
mounting : numpy.array
are the numbers of the nodal points as for the coordinate direction which are fixed.

smax : float
is the maximal allowed cross section of a bar. If you do not need it, set it to a huge value — e. g. 1. It is nessecary for the interaction of the integer values and the cross section values (for redundancy != 0).
name : string
is a name for the problem. The result is saved in name.tar.bz2 in the current working directory.
sigmamin : float
lower limit for the allowed stress, e.g. compressive strength (e.g. -1e8 Pa for aluminium or -4e8 Pa for some steel)
sigmamax : float
upper limit for the allowed stress, e.g. tensile strength (e.g. 1e8 Pa for aluminium or 4e8 Pa for some steel)
density : float
density (e.g. 2.7e3 kg/m^3 for aluminium or 7e3 kg/m^3 for some steel)
redundancy : integer
describes the redundancy. After evaluating the special parameter the other functions are called. If redundancy == 0 the function ttrr() will be called and if redundancy != 0 the function ttrr_redundant() will be called.
opt : integer

choose the optimization routine: (optional)

• 0 glp_simplex (for redundancy == 0) (default)

• 1 glp_interior (for redundancy == 0)

• 2-6 glp_mip (for redundancy != 0)

• 2 do not search greedy-solution

• 3 search greedy-solution and go on

• 4 search greedy-solution, write greedy solution and go on

• 5 search greedy-solution and stop

• 6 search in parallel with 2 and 3 and stop

after solution is found with one method

undisturbed_forces : numpy.array
If it is a scalar the perturbed forces are calculated with compute_disturbed_forces(). Otherwise loads are assumed to be the perturbed forces. The content of undisturbed_forces is not used. It will be saved to the problem data.
p : float
is a parameter for the calculation of perturbed forces. (optional) see compute_disturbed_forces()
art : integer
chooses the kind of the perturbation: (optional) see compute_disturbed_forces()
sort : integer

describes a feature: (optional)

• 0 not used (default)

problem. see ttrr_redundant()

zlb : float
is a lower bound for the objective function. As we are minimizing the result must not the best solution. Only values greater zero are considered.
zub : float
is a upper bound for the objective function. As we are minimizing the optimization problem may be not solvable. Only values greater zero are considered.
scale_sigma : float
scales sigmamin and sigmamax for the calculation. (optional)
• < 0.0 no scaling will be done (default)
• = 0.0 autoscaling will be done
• > 0.0 scaling will be done with this value
scale_forces : float
scales loads for the calculation. (optional)
• < 0.0 no scaling will be done (default)
• = 0.0 autoscaling will be done
• > 0.0 scaling will be done with this value

Author: Daniel Mohr.

Date: 2012-02-19 (last change)

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/

## dependencies¶

Dependencies for ttrr.py and ttrr_tools.py:

Dependencies for ttrr and ttrr.cc, respectively:

Runtime dependencies for ttrr_tools.py to get graphical output (picture, movie, animation) you need some of the following programs:

At least for pictures you need gnuplot and/or POV-Ray. The frames for all movie and animation output are rendered with POV-Ray.