Skip to content

Commit

Permalink
1. adding the module solver containing the MPM solution to the motion…
Browse files Browse the repository at this point in the history
…s equation. 2. Improvements in documentation.
  • Loading branch information
fabricix committed Jul 15, 2021
1 parent c5f76ed commit 89d8642
Show file tree
Hide file tree
Showing 18 changed files with 635 additions and 555 deletions.
33 changes: 24 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MPM-Py

A Material Point Method implementation using Python: MPM-Py.
A Material Point Method implementation using Python: MPM-Py. This program uses objected-oriented programming paradigm to represent and modeling the elements and its interaction in the material point method context.

## Installation

Expand All @@ -10,47 +10,62 @@ git clone https://github.com/fabricix/MPM-Py.git

## Documentation

To create the documentation, run:
To create the documentation, install pdoc:

```bash
pdoc --html modules
pip3 install pdoc3
```

To read the documentation, open
And then run

```bash
/html/modules/index.html
pdoc --html -c latex_math=True modules/
```

To read the documentation, open the file `/html/modules/index.html` using a web browser.

## Requirements

* Python 3.7.4 or superior

* Matplotlib 3.3.4 or superior


## Running tests and examples

In the folders `verification_problems` and `tests` there are examples showing and testing the functionalities of the program.

### Mesh test

The file `tests/mesh-test.py` tests the mesh generations module by plotting the mesh and showing the number of elements, nodes and material points.

Run this example as:

```bash
python mesh-test.py
```

### Interpolation function test

The file `tests/interpolation_functions_test.py` shows the interpolation functions and its derivates over an one 1D element.

Run this example as:
```bash
python interpolation-functions-test.py
```

### Single mass bar vibration problem
### Single mass vibration problem

In this verification problem a single mass vibration is analyzed numerically and then the numerical solution is compared with the analytical one.

Run this example as:
```bash
python mpm-single-mass-bar-vibration.py
```

### Continuum bar vibration problem

In this verification problem a continuum bar vibration is analyzed numerically and then the numerical solution is compared with the analytical one.

Run this example as:
```bash
python mpm-continuum-bar-vibration.py
```
```
File renamed without changes.
File renamed without changes.
63 changes: 31 additions & 32 deletions modules/element.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Purpose
-------
Defines classes for finite elements representation

Data
----
Created on Tue Mar 16 08:29:59 2021
"""
Author
------
Fabricio Fernandez, <[email protected]>
Represent a finite element
"""
class bar_1D:
"""
Class to create 1D bar element with 2 nodes
Attributes
----------
eid : int
Element identification
n1 : node type
Node 1 (left)
n2 : node type
Node 2 (right)
L : float
Element length
particles : list
List of particles in element
"""
def __init__(self):
self.eid = 0 # element id
self.n1 = 0 # node 1
self.n2 = 0 # node 2
self.L = 0 # element length
self.particles = [] # particles in element

"""
Represent an 1D finite element with 2 nodes
Attributes
----------
eid : int
Element identification
n1 : node
Node 1 (left)
n2 : node
Node 2 (right)
L : float
Element length
particles : list
List of particles in the element
"""

def __init__(self):
self.eid = 0 # element id
self.n1 = 0 # node 1 (left)
self.n2 = 0 # node 2 (right)
self.L = 0 # element length
self.particles = [] # list of particles in element
25 changes: 16 additions & 9 deletions modules/integration.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
Purpose
-------
Defines nodal integration functions
Data
----
Created on Tue Mar 16 16:17:03 2021
Defines nodal integration functions.
This functions in general have the objective to advance in time, or adding quantities at the nodes.
Author
------
Fabricio Fernandez, <[email protected]>
"""

def total_force_in_nodes(msh):
"""
Calculate total forces in nodes
Arguments
---------
msh: mesh
a mesh object
"""
for node in msh.nodes:
node.f_tot = node.f_int + node.f_ext

def momentum_in_nodes(msh,dt):
"""
Calculate momentum in nodes
Arguments
---------
msh: mesh
a mesh object
dt: float
time step
"""
for inode in msh.nodes:
inode.momentum += inode.f_tot*dt
Loading

0 comments on commit 89d8642

Please sign in to comment.