# TA7: Structural Analysis with Advanced Contact Options

## 1.PROBLEM DESCRIPTION

- In this tutorial there is a frictionless contact defined between the two parts. The ends of both parts are fixed and given displacement is applied on the contact surface of Part1. Aim of the tutorial is finding directional deformation in the z direction for each part. We have four Scenarios:
1)Scenario 1: Parts are adjusted to touch.

2)Scenario 2: There is a Gap = 0.0005m and Offset is 0.

3)Scenario 3: There is a Gap = 0.0005m and Offset = 0.001m

4)Scenario 4: There is a Gap = 0.0005m and Offset = -0.001m

Material Properties |
Geometric Properties |
Loading |
---|---|---|

E = 2e11 Pa Poisson’s Ratio = 0 |
Gap=0.0005m Dimesions for each part 0.1m x 0.1m x 0.5m |
Given Displacement=(0, 0,0.0006m) |

## 2.MODEL SETUP AND SOLUTION

The following sections describe the setup and solution steps for this tutorial:

### 2.1. Preparation

To run this tutorial;

1.You must sign up and log in. —->>>>> TwinAPI

2.After login, Click **Personel Projects>>New Project** button on the screen and then we will create a project page by giving the project name.

(Let’s name of Analysis “ContactExample”)

3.You can see the project page on your Personel Project Part.

4.Our Screen is a blank python page without any script. We will be doing a tutorial by using Simularge’s Library.

5.We import our libraries from the Simularge Libraries to our empty Python page that we almost will use in each tutorial.

```
1from TwinAPI.SimulationTools import Solver
2from TwinAPI.SimulationTools import Mesher
```

Material Properties is one of the most significant factor that affect to result. Therefore,we should define it easily to the problem. I will explain below how to use and write Material Library elaborately. Furtherless, The Libraries that has to imported to problem is given below.

```
1from TwinAPI.MaterialLibrary import MaterialManager
2from TwinAPI.MaterialLibrary.Units import units
```

### 2.2. General Settings

After the necessary libraries are imported into the analysis, analysis are defined.

1.Defined name of Analysis as “ContactExample”

```
1ContactExample= Solver.Analysis(Verbose=True)
```

2.Calculix is used on solid mechanics problems in TwinAPI. Hence, we are defining Calculix to run this analysis.

```
1ContactExample.SetSolver("Calculix")
```

Analysis is defined successfully into TwinAPI System.

### 2.3. Geometry/Mesh

There is two different options to define geometry on TwinAPI System. Create own geometry on TwinAPI by using Mesher Library that belong to Simularge’s libraries or You can import own CAD Geometry.

```
1LengthX=0.1 #m
2LengthY=0.1 #m
3LengthZ=0.5 #m
4Gap=0.0005 #m
5Offset=0.001 #m
6NodeX=3
7NodeY=3
8NodeZ=10
9Trans_X=0
10Trans_Y=0
11Trans_Z_1=Offset
12Trans_Z_2=LengthZ+Gap
13directionX=''
14directionY=''
15directionZ=''
16typeX='uniform'
17typeY='uniform'
18typeZ='uniform'
```

box1=Mesher.box(LengthX,NodeX,typeX,directionX,LengthY,NodeY,typeY,directionY,LengthZ,NodeZ,typeZ,directionZ,Trans_X,Trans_Y,Trans_Z_1) box2=Mesher.box(LengthX,NodeX,typeX,directionX,LengthY,NodeY,typeY,directionY,LengthZ,NodeZ,typeZ,directionZ,Trans_X,Trans_Y,Trans_Z_2)

With the script given above, you can create your box geometry and mesh.

LengthX= Length of X Direction

NodeX= Node Number of X Direction

Trans_X= Translation of X Direction

directionX= Aspect

typeX= Mesh type of X direction.

All of given above is valid for Y and Z Direction.

We create a box geometry that name is “box1” from given inputs.

Note

We told you that you can also create this geometry import 3D CAD file apart from using MESHER. Code should be written like this;

```
1 Box1=Mesher.MeshFromCad('Box.step',20000,1,1e4,SurfaceExtract=True)
```

If we are not sure how created geometry and want to see geometry before starting analysis;

Click **Preview** Button

### 2.4. Material

Before we started,There are lots of parameters to impact to result of problem. We are going to explain which parameters are requirement for problem first. Later, We would give an parameters instances which can be used.

If your material is isotropic thats means all properties is equal with different direction. However Anisotropic Material Properties is not the same value with different direction. Modulus of Elasticity and density of material will impact amount of deflection in this problem.

We call the Material class in the Material Manager library and name the material “Material_name”. At the same time, We give the information that the material behaves as a steel by typing “steel”.

```
1 material = MaterialManager.Material("Material_name","steel")
2
3 material.SetMechanicType("Elastic")
4 material.SetMechanicData("youngsModulus",2e11,units["pa"])
5 material.SetMechanicData("poissonsRatio",0)
```

We will make an example to understand better what can be used parameters in Material Library.

```
1 material.SetThermalData("specificHeat",7,units["j/kgk"])
2
3 material.SetThermalData("expansionCoefficient",10,units["1/k"])
4
5 material.SetThermalData("conductivity",25,units["btu/hr*ft*F"])
```

After defining the material into our system, we should combine geometry define above and material using Addpart method. And we should also define contact relationship.

```
1ContactExample.AddPart(box1, material)
2ContactExample.AddPart(box2, material)
3ContactExample.Assemble()
4
5MyContact=Solver.Interaction.Contact()
6MyContact.AddMaster(box1.front)
7MyContact.AddSlave(box2.back)
8ContactExample.AddContact(MyContact)
```

### 2.5. Boundary Conditions

After adding material and geometry to the analysis, we are ready to set the boundary conditions.

1.First of all, we need to call a method to create a step. Step1’s name can be change.

```
1Step1=Solver.CreateStep("new")
```

2.We need to choose whether this step is computed depending on time or not.Explained problem is Steady-State. Therefore,below code should be written.

```
1Step1.Time("SteadyState")
```

If the Problem was Transient,type of problem and time of analysis should be written in a similar manner with below code.

```
1Step1.Time("Transient",[0,10,0.1])
```

3.The type of boundary condition is fixed for this problem. Also we should define displacement in order to observe its effect.

```
1Step1.AddBC("Fix",[box1.back],[("X",0)],"m")
2Step1.AddBC("Fix",[box1.back],[("Y",0)],"m")
3Step1.AddBC("Fix",[box1.back],[("Z",0)],"m")
4Step1.AddBC("Fix",[box2.front],[("X",0)],"m")
5Step1.AddBC("Fix",[box2.front],[("Y",0)],"m")
6Step1.AddBC("Fix",[box2.front],[("Z",0)],"m")
7Step1.AddBC("Fix",[box1.front],[("X",0)],"m")
8Step1.AddBC("Fix",[box1.front],[("Y",0)],"m")
9Step1.AddBC("Fix",[box1.front],[("Z",0.0006)],"m")
```

### 2.6. Solution

After defining our boundary conditions, we need to combine our defined domain and the steps containing boundary conditions.To complete this task;

```
1ContactExample.Build([Step1])
```

Now,Problem is ready to be solved.

```
1ContactExample.Solve()
```

Before going to be PostProcess Stage, we can review what we have done.

### 2.7. Processing

Click

**Run**Button and gears rotate on right side while problem is being solved.

### 2.8. Post-Processing

2.After Problem solved;

We can see result;

Click **Result** Button

3.If we want to see detailed result about problem;

Output Tab shows us the results that we desire to see. By using print line we could see the result in the Output section.

```
1print(ContactExample.Result(Variable="Displacement", Loc=[LengthX,LengthY,LengthZ+0.01]))
2ContactExample.Result(Print=True)
```

Log tab tells us respectively what happened in analysis.

Error tab shows us if there is an error in script, It tells us what the error is and where it is.

Files tab can upload the files to be imported from the Upload command and check them from Files.

Graph tab shows us analysis result can be viewed graphically. (It will be shown in other examples.)

## 3.SUMMARY

In this tutorial, we learned how to observe the displacement of two beams which contact each other on TwinAPI. We also learned how to perform postprocessing in an engineering manner.

With table given below shows that comparasion of Ansys Mechanical Result and TwinAPI result.

## 4. SOURCE CODE

```
1from TwinAPI.SimulationTools import Solver
2from TwinAPI.SimulationTools import Mesher
3
4from TwinAPI.MaterialLibrary import MaterialManager
5from TwinAPI.MaterialLibrary.Units import units
6
7ContactExample= Solver.Analysis(Verbose=True)
8ContactExample.SetSolver('Calculix')
9
10LengthX=0.1 # m
11LengthY=0.1 # m
12LengthZ=0.5 # m
13Gap=0.0005 # m
14Offset=0.001 # m
15NodeX=3
16NodeY=3
17NodeZ=10
18Trans_X=0
19Trans_Y=0
20Trans_Z_1=Offset
21Trans_Z_2=LengthZ+Gap
22directionX=''
23directionY=''
24directionZ=''
25typeX='uniform'
26typeY='uniform'
27typeZ='uniform'
28
29
30box1=Mesher.box(LengthX,NodeX,typeX,directionX,LengthY,NodeY,typeY,directionY,LengthZ,NodeZ,typeZ,directionZ,Trans_X,Trans_Y,Trans_Z_1)
31box2=Mesher.box(LengthX,NodeX,typeX,directionX,LengthY,NodeY,typeY,directionY,LengthZ,NodeZ,typeZ,directionZ,Trans_X,Trans_Y,Trans_Z_2)
32
33material = MaterialManager.Material("Material_name","steel")
34
35material.SetMechanicType("Elastic")
36material.SetMechanicData("youngsModulus",2e11,units["pa"])
37material.SetMechanicData("poissonsRatio",0)
38
39ContactExample.AddPart(box1, material)
40
41ContactExample.AddPart(box2, material)
42
43ContactExample.Assemble()
44
45MyContact=Solver.Interaction.Contact()
46MyContact.AddMaster(box1.front)
47MyContact.AddSlave(box2.back)
48ContactExample.AddContact(MyContact)
49
50Step1=Solver.CreateStep("new")
51Step1.Time("SteadyState")
52
53Step1.AddBC("Fix",[box1.back],[("X",0)],"m")
54Step1.AddBC("Fix",[box1.back],[("Y",0)],"m")
55Step1.AddBC("Fix",[box1.back],[("Z",0)],"m")
56Step1.AddBC("Fix",[box2.front],[("X",0)],"m")
57Step1.AddBC("Fix",[box2.front],[("Y",0)],"m")
58Step1.AddBC("Fix",[box2.front],[("Z",0)],"m")
59Step1.AddBC("Fix",[box1.front],[("X",0)],"m")
60Step1.AddBC("Fix",[box1.front],[("Y",0)],"m")
61Step1.AddBC("Fix",[box1.front],[("Z",0.0006)],"m")
62
63ContactExample.Build([Step1])
64ContactExample.Solve()
65
66print(ContactExample.Result(Variable="Displacement", Loc=[LengthX,LengthY,LengthZ+0.01]))
67ContactExample.Result(Print=True)
```

Keywords: Nonlinear Static Structural Analysis, Contact Problem, Gap, Offset, Displacement

Problem Reference: Any basic Strength of Material book

Author: Berke Kadioglu