Skip to content

Solver for the plane linear elasticity problem using the finite element method in python

License

Notifications You must be signed in to change notification settings

nasseralkmim/elastopy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

https://cloud.githubusercontent.com/assets/9167399/25065900/38b750a8-21ee-11e7-9a38-a4b1139e97a7.png

This package solves the linear elasticity assuming the plane stress constitutive model. The solution is obtained via the finite element method.

The program input is a mesh (.geo and .msh files), material properties and boundary conditions. The boundary conditions are create using python functions. The results obtained from the function statics.solver() are the nodal displacements and nodal stresses.

How to download

pip install elastopy

How to use it

In order to use you need the .geo and .msh from gmsh. See the test folder for an example.

Example of usage

First we import the necessary classes and functions

import numpy as np
from elastopy import gmsh, Build, Material, statics, plotter

Then we create the model by parsing the mesh file and instanciante the Build class.

mesh_file = 'test/patch'
mesh = gmsh.Parse(mesh_file)
model = Build(mesh)

plotter.model(model, ele=True, nodes_label=True, ele_label=True, edges_label=True)
plotter.show()

https://cloud.githubusercontent.com/assets/9167399/25065913/6cbdd7be-21ee-11e7-97fc-aa3f41cc3871.png

Next we define material parameters using the Material class which takes as argument keyword dictionaries where the key is the surface label,

surf = list(model.surf.keys())
material = Material(E={surf[0]: 1000}, nu={surf[0]: 0.3})

Then we define body forces and boundary conditions as functions,

def b_force(x1, x2, t=1):
    return np.array([0.0,
                     0.0])


def trac_bc(x1, x2, t=1):
    return {
        ('line', 3): [-1, 0],
        ('line', 1): [1, 0]}


def displ_bc(x1, x2):
    return {('node', 0): [0, 0],
            ('node', 1): ['free', 0]}

finally we call the statics solver

U, SIG = statics.solver(model, material, b_force,
                        trac_bc, displ_bc)
Starting statics solver at 0.000h Solution completed!

We then proceed to process the results

plotter.model_deformed(model, U, magf=100, ele=True)
print(np.round(SIG[:, 0], 2))   # s11 on all nodes
plotter.show()

https://cloud.githubusercontent.com/assets/9167399/25065912/6cbd66a8-21ee-11e7-895c-4e302a9315e6.png

About

Solver for the plane linear elasticity problem using the finite element method in python

Resources

License

Stars

Watchers

Forks

Packages