Skip to content

Tutorials

William Hunter edited this page Jun 14, 2016 · 36 revisions

Before you do anything else, please just read through the list of ToPy Keywords on the Help page, or else the below is going to make very little sense.

2D problems

Tutorial 1

NOTE:- This is a work in progress, check back again soon, I should have it finished in the next two weeks or so.

Problem

Two loads acting on a 30x30 square area, supported at two locations at the bottom. What is the stiffest structure I can place inside the area to resist the two loads?

2d problem def

Note that the bottom left constraint can 'slide' in the horizontal direction (along the X-axis).

Trivial solution

The stiffest possible structure we can place in our 30x30 domain (region/area) is simply to put material everywhere in the domain, but that's exactly what we don't want to do.

ToPy solution (non-trivial)

Solution for limited material usage

Assume we don't have material to fill the 30x30 area, let's say we only have 20x20 (400) elements that we need to place in the 900 possible locations in our grid, but where to place them to obtain an optimally stiff structure? A brute force approach is to check each possible valid (forming realistic load paths) layout for the domain until the stiffest structure is found, which works out to roughly 0.5(900!/(900-400)!) permutations (I think, but you can probably see that it's going to be a big number). The alternative is to make use of topology optimisation.

Approach

We start with a 30x30 grid, with loading (forces at nodes) and constraints (fixtures at nodes) as shown in the figure above (the red arrows are the loads) applied at the relevant node numbers. Note that the node numbering is from top left corner downwards -- all 2d ToPy problems must follow this numbering scheme. The mesh was created using ToPy's create_2d_msh function, the mesh is viewed in Gmsh.

2d Gmsh msh

Create the `msh' file by entering the following in a Python or IPython console:

>> create_2d_msh(30, 30, 'tut1')

This will create a file named 'tut1.msh' that can be opened and viewed with Gmsh. Looking at the mesh, we can see that the loads are applied at node numbers 1 and 951.

Define the TPD file

Open a text editor, for example Notepad on Windows, and enter the following lines of text (shown in blocks below).

The first line of a TPD file must be

[ToPy Problem Definition File v2007]

or else ToPy will complain and not run. Save the file as tut1_2d.tpd (it can be any name, but you don't use spaces in the name). The rest of the keywords can have any order, whitespace has no effect. Next, we give the problem a name, it doesn't have to be the same as the file name (but again, no spaces, use an underscore instead):

PROB_NAME: tut1_2d

and we say what type of problem it is. In this case, it is a minimum compliance problem:

PROB_TYPE: comp # you can add comments after a hash

You need to say how many elements you have in the X and Y direction:

NUM_ELEM_X: 30
NUM_ELEM_Y: 30
NUM_ELEM_Z: 0 # set to zero for 2d problems

Set the fraction of the area you want to use:

VOL_FRAC: 0.444 # 20*20/30*30

Specify which nodes are loaded, and their magnitudes and directions. Normally you'd normalise the loads.

LOAD_NODE_X: 1 # load node number 1 in the positive x-direction
LOAD_NODE_Y: 951 # load node number 951 in the negative y-direction

Specify which nodes are fixed, and the translation direction(s) in which they're constrained.

FXTR_NODE_X: 651 # this is the only node that is fixed in the X-direction
FXTR_NODE_Y: 31; 651 # these nodes are fixed in the Y-direction

Specify the finite element type to be used, as well as the number of degrees of freedom per node:

ELEM_K: Q4 # element type (stiffness matrix) for 2d compliance problems
DOF_PN: 2 # degrees of freedom per node, 2 for 2d compliance problems
Clone this wiki locally