Skip to content

Examples and Benchmarks

Many examples are provided for various types of problems that the project currently addresses. More examples exploring new functionalities will be added in the future. To verify the accuracy of myfempy, several Benchmarks Reports (e.g. analytics, ansys, etc.) are available below.

But first, follow these steps:

Install myfempy

  1. Clone/ Download the main code [latest version] from github/myfempy/main

  2. Unzip the pack in your preferred location

  3. Install the myfempy in a isolated Python environments (with virtualenv or conda)

  4. Change to myfempy/docs/gallery folder

  5. Run any file example

Run this Commands on Terminal (win, linux, ...)

>> git clone https://github.com/avgcampos/myfempy   # install git is needed before this command

>> python -m pip install --upgrade pip               # update pip

>> pip install .                                     # install myfempy-main

>> cd myfempy/examples/gallery                       # change to the examples gallery directory

>> python run_first_test.py                           # run any file to check installation

Example List

Many Examples are available to download here.

Static Linear Analysis

run_first_test.py

You can use this code to first test required to check myfempy install Relatório de Benchmark (PT-BR PDF)

Relatório de Benchmark (PT-BR PDF)

"""
==============================================================================
MYFEMPY example runscript
==============================================================================
@File    :   run_fist_test.py
@Date    :   2026/02/03
@Author  :   Antonio V. G. Campos
@Description : This example can be used as an initial analysis to test the complete
installation of the myfempy code. A report (PT-BR) is available to verify the program's
compatibility. See the user guide or _help_ for more information about commands.

Usage: >>> python run_fist_test.py
"""

# environ['OMP_NUM_THREADS'] = '1'        #win

# ===============================================================================
# imports, set SteadyStateLinear as a Solver or SteadyStateLinearIterative, see help
# ===============================================================================
from myfempy import newAnalysis
from myfempy import SteadyStateLinear, SteadyStateLinearIterative
import numpy as np

# ===============================================================================
# FEA API
# ===============================================================================
fea = newAnalysis(SteadyStateLinear)

# ===============================================================================
# set material prop.
# ===============================================================================
mat = {
    "NAME": "aco",
    "VXY": 0.30,
    "EXX": 200E3,       # N/mm^2 --> MPa
    "GXY": 0.5*200E3,
    "RHO": 7.85E-06,    # kg/mm^2
    }

# ===============================================================================
# set geometry prop.
# ===============================================================================
geo = {
    "NAME": "sec",
    "THICKN": 40,
    }

# ===============================================================================
# set gmsh config.
# ===============================================================================
# MODEL SET
LX = 1200
LY = 80
esize = 10
points = [
    [0, 0, 0],
    [LX, 0, 0],
    [LX, LY, 0],
    [0, LY, 0]
]

lines = [[1, 2],
         [2, 3],
         [3, 4],
         [4, 1],
         ]

plane = [[1, 2, 3, 4]]


# ===============================================================================
# set modeldata
# ===============================================================================
modeldata = {
   "MESH": {
        'TYPE': 'gmsh',
        'filename': 'mesh_gmsh',
        # "meshimport": 'object_dir',
        'pointlist': points,
        'linelist': lines,
        'planelist': plane,
        # 'arc': arcs,
        'meshconfig': {
            'mesh': 'hexa8',   #quad4 tria3
            'sizeelement': 2*esize,
            'extrude': 40,
            'meshmap': {'on': True,
                        'edge': 'all', #[[1,3], [2,4]], #'all'
                        # "numbernodes": [20, 10],
            }
            }
    },

    "ELEMENT": {
        'TYPE': 'structsolid',
        'SHAPE': 'hexa8',
        # 'INTGAUSS': 8,
    },

    "MATERIAL": {
        "MAT": 'solidelastic',
        "TYPE": 'isotropic',
        "PROPMAT": [mat],
    },

    "GEOMETRY": {
        "GEO": 'solid',
        # "SECTION": 'rectangle',
        "PROPGEO": [geo],
    },
}

# ===============================================================================
# pass modeldata to Model API
# ===============================================================================
fea.Model(modeldata)

# ===============================================================================
# set bound. cond.
# ===============================================================================
bc = {
    'TYPE': 'fixed',  
    'DOF': 'full',
    'DIR': 'plane',
    'TAG': 5,
    }

# ===============================================================================
# set load
# ===============================================================================
fr = {
    'TYPE': 'forcesurf',
    'DOF': 'fy',
    'DIR': 'plane',
    'TAG': 3,
    'VAL': [-1.5625],
    }

physicdata = {
    "PHYSIC": {"DOMAIN": "structural", # 'fluid' 'thermal'; "COUPLING": 'fsi'
               "LOAD": [fr],
               "BOUNDCOND": [bc],
    },
}

# ===============================================================================
# pass physicdata to Physic API
# ===============================================================================
fea.Physic(physicdata)

# ===============================================================================
# preview config.
# ===============================================================================
previewset = {'RENDER': {'filename': 'preview', 'show': True, 'scale': 5, 'savepng': True, 'lines': False,
                        #  'plottags': {'plane': True},
                        #  'cs': True,
                         },
              }
fea.PreviewAnalysis(previewset)

# ===============================================================================
# SOLVER
# ===============================================================================
solverset = {"STEPSET": {'type': 'table',  # mode, freq, time ...
                        'start': 0,
                        'end': 1,
                        'step': 1},
             'SYMM':False,
             'MP':False,
            }
solverdata = fea.Solve(solverset)

# ===============================================================================
# post process
# ===============================================================================
postprocset = {"SOLVERDATA": solverdata,
                "COMPUTER": {'structural': {'displ': True, 'stress': True}},
                "PLOTSET": {'show': True, 'filename': 'output', 'savepng': True},
                # "TRACKER": {'point': {'x': 0, 'y': 0, 'z': 0, 'dof':1}},
                "REPORT": {'log': True, 'get': {'nelem': True, 'nnode': True}}, #'coord': True
            }
postprocdata = fea.PostProcess(postprocset)

print(np.max(np.abs(solverdata['solution']['U'])))

static_linear_beam3d_LoganBook.py

Relatório de Benchmark (PT-BR PDF)

Relatório de Benchmark (PT-BR PDF)

from myfempy import newAnalysis
from myfempy import SteadyStateLinearIterative

from time import time

fea = newAnalysis(SteadyStateLinearIterative)
# MODEL SET
mat = {
    "NAME": "mat",
    "EXX": 30000,       # N/mm^2 --> MPa
    "GXY": 10000,
    }

geo = {
    "NAME": "secao1",
    "AREACS": 10,
    "INERYY": 100,
    "INERZZ": 100,
    "INERXX": 50,
    # "CG":{
    #     "y_max":1,
    #     "y_min":-1,
    #     "z_max":1,
    #     "z_min":-1,
    #     "r_max":1
    # },
    }

# gmsh config
points = [
    [100, 0, 100],
    [100, 100, 100],
    [0, 100, 100],
    [100, 100, 0],
]

lines = [[2, 1],
         [3, 2],
         [2, 4],
         ]

modeldata = {
   "MESH": {
        'TYPE': 'gmsh',
        'filename': 'mesh_gmsh',
        'pointlist': points,
        'linelist': lines,
        'meshconfig': {
            'mesh': 'line2',
            "numbernodes": 2,
            }
    },

    "ELEMENT": {
        'TYPE': 'structbeam',
        'SHAPE': 'line2',
        # 'INTGAUSS': 2,
    },

    "MATERIAL": {
        "MAT": 'uniaxialstress',
        "TYPE": 'isotropic',
        "PROPMAT": [mat, mat, mat],
    },

    "GEOMETRY": {
        "GEO": 'frame',
        "SECTION": 'userdefined',
        "PROPGEO": [geo, geo, geo],
    },
}
fea.Model(modeldata)

bc1 = {
    'TYPE': 'fixed',  
    'DOF': 'full',
    'DIR': 'point',
    'TAG': 1,
    }

bc2 = {
    'TYPE': 'fixed',  
    'DOF': 'full',
    'DIR': 'point',
    'TAG': 3,
    }

bc3 = {
    'TYPE': 'fixed',  
    'DOF': 'full',
    'DIR': 'point',
    'TAG': 4,
    }

fy = {
    'TYPE': 'forcenode',
    'DOF': 'fy',
    'DIR': 'point',
    'TAG': 2,
    'VAL': [-50],
    }

tx = {
    'TYPE': 'forcenode',
    'DOF': 'tx',
    'DIR': 'point',
    'TAG': 2,
    'VAL': [-1000],
    }

physicdata = {
    "PHYSIC": {"DOMAIN": "structural",
               "LOAD": [fy, tx],
               "BOUNDCOND": [bc1, bc2, bc3],
    },
}
fea.Physic(physicdata)

previewset = {'RENDER': {'filename': 'preview', 'show': True, 'scale': 15, 'savepng': True, 'lines': True,
                         'plottags': {'point': True},
                        # 'cs': True,
                         },
            #   'LABELS': {'show': True, 'lines': True, 'scale': 1},
              }
fea.PreviewAnalysis(previewset)

# #-------------------------------- SOLVER -------------------------------------#
solverset = {"STEPSET": {'type': 'table',  # mode, freq, time ...
                        'start': 0,
                        'end': 1,
                        'step': 1},
             'SYMM':True,
            #  'MP':True,
            }
solverdata = fea.Solve(solverset)
print(solverdata['solution']['U'])

postprocset = {"SOLVERDATA": solverdata,
                "COMPUTER": {'structural': {'displ': True, 'stress': True}},
                "PLOTSET": {'show': True, 'filename': 'output', 'savepng': True},
                # "TRACKER": {'point': {'x': 0, 'y': 0, 'z': 0, 'dof':1}},
                "REPORT": {'log': True, 'get':{
                        'nelem': True,
                        'nnode': True,
                        'inci': True,
                        'coord':True,
                        'tabmat':True,
                        'tabgeo':True,
                        'boundcond_list':True,
                        'forces_list':True,
                    },
            }}
postprocdata = fea.PostProcess(postprocset)

myfempy_nafems_le1.py

Relatório de Benchmark (PT-BR PDF) Extra files download

Relatório de Benchmark (PT-BR PDF)

import sys
# setting path
sys.path.append('../myfempy')

from myfempy import newAnalysis
from myfempy import SteadyStateLinear
import numpy as np

# ===============================================================================
#                                   FEA
# ===============================================================================
fea = newAnalysis(SteadyStateLinear, 'sim')

mat = {
    "NAME": "aco",
    "VXY": 0.3,
    "EXX": 210E3,       # N/mm^2 --> MPa
    }

geo = {
    "NAME": "espessura",
    "THICKN": 100,
    }

modeldata = {
   "MESH": {
        'TYPE': 'gmsh',
        'filename': 'mesh_gmsh',
        "meshimport": {'object': 'nafems_le1_mesh_quad4_fine'}, 
        'meshconfig': {
            'mesh': 'quad4',
            }
    },

    "ELEMENT": {
        'TYPE': 'structplane',
        'SHAPE': 'quad4',
        'INTGAUSS': 2,
    },

    "MATERIAL": {
        "MAT": 'planestress',
        "TYPE": 'isotropic',
        "PROPMAT": [mat],
    },

    "GEOMETRY": {
        "GEO": 'thickness',
        "PROPGEO": [geo],
    },
}
fea.Model(modeldata)

press = {
    'TYPE': 'forceedge',
    'DOF': 'pressure',
    'DIR': 'line',
    'TAG': 2,
    'VAL': [10],
    }

bc1 = {
    'TYPE': 'fixed',  
    'DOF': 'ux',
    'DIR': 'line',
    'TAG': 1,
    }


bc2 = {
    'TYPE': 'fixed',
    'DOF': 'uy',
    'DIR': 'line',
    'TAG': 3,
    }


physicdata = {
    "PHYSIC": {"DOMAIN": "structural", # 'fluid' 'thermal'; "COUPLING": 'fsi'
               "LOAD": [press],
               "BOUNDCOND": [bc1, bc2],
    },
}
fea.Physic(physicdata)

previewset = {'RENDER': {'filename': 'preview', 'show': True, 'scale': 4, 'savepng': True, 'lines': False,
                         'plottags': {'line': True}
                         },
              }
fea.PreviewAnalysis(previewset)

# #-------------------------------- SOLVER -------------------------------------#
solverset = {"STEPSET": {'type': 'table',  # mode, freq, time ...
                        'start': 0,
                        'end': 1,
                        'step': 1},
             'SYMM':True,
            #  'MP':True,
            }
solverdata = fea.Solve(solverset)

postprocset = {"SOLVERDATA": solverdata,
                "COMPUTER": {'structural': {'displ': True, 'stress': True}},
                "PLOTSET": {'show': True, 'filename': 'output', 'savepng': True},
                "REPORT": {'log': True, 'get': {'nelem': True, 'nnode': True}},
            }
postprocdata = fea.PostProcess(postprocset)

STR_YY_D = max(postprocdata['STRESS_YY'])
print('STRESS_YY_D ',STR_YY_D)

STR_YY_D_REF = 92.7
erro = (abs(STR_YY_D_REF - STR_YY_D)/abs(STR_YY_D_REF))*100
print('ERRO [%] ',erro)

tapered_bar.py

Relatório de Benchmark (PT-BR PDF)

Relatório de Benchmark (PT-BR PDF)

from myfempy import newAnalysis
from myfempy import SteadyStateLinearIterative, SteadyStateLinear
from myfempy.io.iocsv import writer2csv

import numpy as np
# ===============================================================================
#                                   FEA
# ===============================================================================
fea = newAnalysis(SteadyStateLinearIterative)
mat = {
    "NAME": "mat",
    "VXY": 0.3,
    "EXX": 1000,       # N/mm^2 --> MPa
    }

geo = {
    "NAME": "geo",
    "THICKN": 10.0,
    # "DIM": [b, h, t, d],
    }

# gmsh config
points = [
    [0, 0, 0],    # ponto A
    [64, 0, 0],   # ponto B
    [64, 8, 0],   # ponto C   
    [0, 24, 0],   # ponto D
]


lines = [[1, 2],  # linha 1
         [2, 3],  # linha 2
         [3, 4], # linha 3
         [4, 1], # linha 4
         ]

plane = [[1, 2, 3, 4],
         ]

NFINE = 2

modeldata = {

   "MESH": {
        'TYPE': 'gmsh',
        'filename': 'fem_tbar',
        'pointlist': points,
        'linelist': lines,
        'planelist': plane,
        'meshconfig': {
            'mesh': 'quad4',   #quad4
            'sizeelement': 1,
            'meshmap': {'on': True,
                        'edge': [[2, 4], [1, 3]], #'all'
                        "numbernodes": [NFINE*2, NFINE*4],
            }
            }
    },

    "ELEMENT": {
        'TYPE': 'structplane',
        'SHAPE': 'quad4',
        'INTGAUSS': 1,
    },

    "MATERIAL": {
        "MAT": 'planestress',
        "TYPE": 'isotropic',
        "PROPMAT": [mat],
    },

    "GEOMETRY": {
        "GEO": 'thickness',
        "PROPGEO": [geo],
    },
}
fea.Model(modeldata)

force = {
    'TYPE': 'forceedge',
    'DOF': 'fx',
    'DIR': 'line',
    'TAG': 2,
    'VAL': [0.625],
    }

bc_symm_x = {
    'TYPE': 'fixed',
    'DOF': 'uy',
    'DIR': 'line',
    'TAG': 1,
    }

bc_fixed_wall = {
    'TYPE': 'fixed',
    'DOF': 'full',
    'DIR': 'line',
    'TAG': 4,
    }

physicdata = {
    "PHYSIC": {"DOMAIN": "structural",
               "LOAD": [force],
               "BOUNDCOND": [bc_symm_x, bc_fixed_wall],
    },
    }
fea.Physic(physicdata)

loadaply = fea.getLoadApply()
# print(loadaply)
# print(fea.getLoadArray(loadaply))
print('forca total [N]', np.sum(loadaply[:,2]))

previewset = {'RENDER': {'filename': 'fem_tbar', 'show': True, 'scale': 3, 'savepng': True, 'lines': False,
                         'plottags': {
                             'line': True
                            # 'point': True
                             }
                         },
            #   'LABELS': {'show': True, 'lines': True, 'scale': 1},
              }
fea.PreviewAnalysis(previewset)

# #-------------------------------- SOLVER -------------------------------------#
solverset = {"STEPSET": {'type': 'table',  # mode, freq, time ...
                        'start': 0,
                        'end': 1,
                        'step': 1},
             'SYMM':True,
            #  'MP':True,
            }
solverdata = fea.Solve(solverset)

print(np.max(np.abs(solverdata['solution']['U'])))

postprocset = {"SOLVERDATA": solverdata,
                "COMPUTER": {'structural': {'displ': True, 'stress': True}},
                "PLOTSET": {'show': True, 'filename': 'fem_tbar', 'savepng': True},
                # "PLOT": {'data': {'x': 0, 'y': 0, 'z': 0, 'dof':1}},
                "REPORT": {'log': True, 'get': {'nelem': True, 'nnode': True}},
            }
postprocdata = fea.PostProcess(postprocset)

# ===============================================================================
#                              RESULTADO ANALITICO
# ===============================================================================
# Parâmetros (substitua pelos valores reais)
F = 100.0    # força
l = 64.0     # comprimento
A0 = 16*10   # área inicial
E = 1000     # módulo de elasticidade

# Definição da função ux(x)
def ux(xn):
    return -((F * l) / (2 * A0 * E)) * np.log(1 - ((2 * xn) / (3 * l)))

# Intervalo de valores de x
x_vals = np.linspace(0, l, 200)
ux_vals = ux(x_vals)
print(np.max(np.abs(ux_vals)))

data = [x_vals, ux_vals]
label = ['x', 'u_x(x)']

# comando interno de io do myfempy para salvar arquivos CSV .txt para visualizar no ParaView
writer2csv('out/resultado_analitico.txt', data, label)  

stress_concentration.py

Relatório de Benchmark (PT-BR PDF)

Relatório de Benchmark (PT-BR PDF)

from myfempy import newAnalysis
from myfempy import SteadyStateLinearIterative
from myfempy.io.iocsv import writer2csv

import numpy as np
# ===============================================================================
#                                   FEA
# ===============================================================================
fea = newAnalysis(SteadyStateLinearIterative) 

mat = {
    "NAME": "mat",
    "VXY": 0.3,
    "EXX": 1000,
    }

geo = {
    "NAME": "geo",
    "THICKN": 10.0,
    }


# gmsh config
points = [
    [0, 0, 0],      # ponto 0
    [8, 0, 0],      # ponto A
    [128, 0, 0],    # ponto B
    [128, 32, 0],   # ponto C
    [0, 32, 0],     # ponto D
    [0, 8, 0],      # ponto E
]


lines = [[2, 3],        # line 1
         [3, 4],        # line 2
         [4, 5],        # line 3
         [5, 6],        # line 4
         ]

arcs = [
    [2, 1, 6],          # arco line 5
    ]  

plane = [
    [1, 2, 3, 4, 5],    # plano 1
        ]

NFINE = np.arange(20, 0, -1)
STR_XX_E = np.ones_like(NFINE)
NNODES = np.ones_like(NFINE)

for delem in range(len(NFINE)):

    modeldata = {

    "MESH": {
            'TYPE': 'gmsh',
            'filename': 'stress_conc',
            'pointlist': points,
            'linelist': lines,
            'planelist': plane,
            'arc': arcs,  
            'meshconfig': {
                'mesh': 'tria3', 
                'sizeelement': NFINE[delem],
                'meshmap': {'on': True,
                            'edge': 'all', #[[5]], #'all'
                            # "numbernodes": [50],
                }
                }
        },

        "ELEMENT": {
            'TYPE': 'structplane',
            'SHAPE': 'tria3',
            # 'INTGAUSS': 4,
        },

        "MATERIAL": {
            "MAT": 'planestress',
            "TYPE": 'isotropic',
            "PROPMAT": [mat],
        },

        "GEOMETRY": {
            "GEO": 'thickness',
            "PROPGEO": [geo],
        },
    }
    fea.Model(modeldata)

    coord = fea.getCoord()

    force = {
        'TYPE': 'forceedge',
        'DOF': 'fx',
        'DIR': 'line',
        'TAG': 2,
        'VAL': [75]
    }

    bc_left = {
        'TYPE': 'fixed',
        'DOF': 'ux',
        'DIR': 'line',
        'TAG': 4,
    }

    bc_bottom = {
        'TYPE': 'fixed',
        'DOF': 'uy',
        'DIR': 'line',
        'TAG': 1
    }

    physicdata = {
        "PHYSIC": {"DOMAIN": "structural",
                "LOAD": [force],
                "BOUNDCOND": [bc_left, bc_bottom],
        },
        }
    fea.Physic(physicdata)

    # loadaply = fea.getLoadApply()
    # # print(loadaply)
    # # # print(fea.getLoadArray(loadaply))
    # print('forca total [N]', np.sum(loadaply[:,2]))

    # previewset = {'RENDER': {'filename': 'stress_conc', 'show': True, 'scale': 4, 'savepng': True, 'lines': False,
    #                          'plottags': {'line': True}
    #                          },
    #             #   'LABELS': {'show': True, 'lines': True, 'scale': 1},
    #               }
    # fea.PreviewAnalysis(previewset)

    # #-------------------------------- SOLVER -------------------------------------#
    solverset = {"STEPSET": {'type': 'table',  # mode, freq, time ...
                            'start': 0,
                            'end': 1,
                            'step': 1},
                'SYMM':True,
                #  'MP':True,
                }
    solverdata = fea.Solve(solverset)

    postprocset = {"SOLVERDATA": solverdata,
                    "COMPUTER": {'structural': {'displ': True, 'stress': True}},
                    "PLOTSET": {'show': True, 'filename': 'stress_conc', 'savepng': True},
                    # "TRACKER": {'point': {'x': 0, 'y': 0, 'z': 0, 'dof':1}},
                    "REPORT": {'log': True, 'get': {'nelem': True, 'nnode': True}},
                }
    postprocdata = fea.PostProcess(postprocset)

    STR_XX_E[delem] = max(postprocdata['STRESS_XX'])
    NNODES[delem] = len(coord)

STR_XX_E_TEORICA = 242*np.ones_like(STR_XX_E)

data = [NNODES, STR_XX_E_TEORICA]
label = ['MESH', 'STR_XX_E_TEORICA']

# comando interno de io do myfempy para salvar arquivos CSV .txt para visualizar no ParaView
writer2csv('out/resultado_analitico.txt', data, label)  

data = [NNODES, STR_XX_E]
label = ['MESH', 'STR_XX_E']

# comando interno de io do myfempy para salvar arquivos CSV .txt para visualizar no ParaView
writer2csv('out/resultado_fem.txt', data, label)  

patchtest_quad4.py

Relatório de Benchmark (PT-BR PDF)

from myfempy import newAnalysis
from myfempy import SteadyStateLinear

fea = newAnalysis(SteadyStateLinear)

mat = {
    'NAME': 'material',
    'EXX': 1000,
    'VXX': 0.3
}

geo = {
    'NAME':'geo',
    'THICKN': 0.1,
}

nodes = [
    [1,     0.00,   0.00,   0.00],
    [2,     2.00,   0.00,   0.00],
    [3,     2.00,   3.00,   0.00],
    [4,     0.00,   2.00,   0.00],
    [5,     0.40,   0.40,   0.00],
    [6,     1.40,   0.60,   0.00],
    [7,     1.50,   2.00,   0.00],
    [8,     0.30,   1.60,   0.00],    
        ]

conec = [
    [1, 1, 1, 1, 2, 6, 5],
    [2, 1, 1, 2, 3, 7, 6],
    [3, 1, 1, 3, 4, 8, 7],
    [4, 1, 1, 1, 5, 8, 4],
    [5, 1, 1, 5, 6, 7, 8],
        ]

modeldata = {
    'MESH':{
        'TYPE':'manual',
        'COORD':nodes,
        'INCI':conec
    },

    'ELEMENT':{
        'TYPE':'structplane',
        'SHAPE':'quad4',
        'INTGAUSS':2,
    },

    'MATERIAL':{
        'MAT':'planestress',
        'TYPE':'isotropic',
        'PROPMAT':[mat]
    },

    'GEOMETRY':{
        'GEO':'thickness',
        'PROPGEO':[geo]
    }
}

fea.Model(modeldata)


previewset = {
    'RENDER':{
        'filename':'patchtest',
        'show':True,
        'scale':5,
        'savepng':True,
        'lines':True
    }
}

bcfix = {
    'TYPE':'fixed',
    'DOF':'full',
    'DIR':'node',
    'LOC':{'x':0, 'y':0, 'z':0},
}

def displ_patch_test(x,y):
    ux = 0.002*x
    uy = -0.0006*y
    return ux, uy

bcnh_node1_ux = {
    'TYPE':'displ',
    'DOF':'ux',
    'DIR':'node',
    'LOC':{'x':0.0, 'y':0, 'z':0},
    'VAL':[displ_patch_test(0.0,0.00)[0]]
} 

bcnh_node1_uy = {
    'TYPE':'displ',
    'DOF':'uy',
    'DIR':'node',
    'LOC':{'x':0.0, 'y':0, 'z':0},
    'VAL':[displ_patch_test(0.0,0.00)[1]]
} 

bcnh_node2_ux = {
    'TYPE':'displ',
    'DOF':'ux',
    'DIR':'node',
    'LOC':{'x':2.0, 'y':0, 'z':0},
    'VAL':[displ_patch_test(2.0,0.00)[0]]
} 

bcnh_node2_uy = {
    'TYPE':'displ',
    'DOF':'uy',
    'DIR':'node',
    'LOC':{'x':2.0, 'y':0, 'z':0},
    'VAL':[displ_patch_test(2.0,0.00)[1]]
} 

bcnh_node3_ux = {
    'TYPE':'displ',
    'DOF':'ux',
    'DIR':'node',
    'LOC':{'x':2.0, 'y':3.0,'z':0},
    'VAL':[displ_patch_test(2.0,3.0)[0]]
} 

bcnh_node3_uy = {
    'TYPE':'displ',
    'DOF':'uy',
    'DIR':'node',
    'LOC':{'x':2.0, 'y':3.0, 'z':0},
    'VAL':[displ_patch_test(2.0,3.0)[1]]
} 


bcnh_node4_ux = {
    'TYPE':'displ',
    'DOF':'ux',
    'DIR':'node',
    'LOC':{'x':0, 'y':2.0,'z':0},
    'VAL':[displ_patch_test(0,2.0)[0]]
} 

bcnh_node4_uy = {
    'TYPE':'displ',
    'DOF':'uy',
    'DIR':'node',
    'LOC':{'x':0, 'y':2.0, 'z':0},
    'VAL':[displ_patch_test(0,2.0)[1]]
} 

physicdata = {
    'PHYSIC':{
        'DOMAIN':'structural',
        'LOAD':[],
        'BOUNDCOND':[
                    # bcfix,
                    bcnh_node1_ux, bcnh_node1_uy,
                    bcnh_node2_ux, bcnh_node2_uy,
                    bcnh_node3_ux, bcnh_node3_uy,
                    bcnh_node4_ux, bcnh_node4_uy,]
    }
}

fea.Physic(physicdata)


fea.PreviewAnalysis(previewset)

solverset = {
    'STEPSET':{
        'type':'table',
        'start':0,
        'end':1,
        'step':1
    },
    'SYMM':False,
    'MP':False
}

solverdata = fea.Solve(solverset)

print(solverdata['solution']['U'])

postprocset = {"SOLVERDATA": solverdata,
                "COMPUTER": {'structural': {'displ': True, 'stress': True}},
                "PLOTSET": {'show': True, 'filename': 'PatchTest', 'savepng': True},
                "REPORT": {'log': True, 'get':{
                        'nelem': True,
                        'nnode': True,
                        'inci': True,
                        'coord':True,
                        'tabmat':True,
                        'tabgeo':True,
                        'boundcond_list':True,
                        'forces_list':True,
                    }
            }}
postprocdata = fea.PostProcess(postprocset)

print('STRESS_XX: ',postprocdata['STRESS_XX'])

myfempyVSsu2_StaticLinear.py

Analysis to convergence of myfempy solver with su2

Resposta do MYFEMPY Relatório de Benchmark (PT-BR PDF)

import sys
# setting path
sys.path.append('../myfempy')

from myfempy import newAnalysis
from myfempy import SteadyStateLinear

import numpy as np

# ===============================================================================
#                                   FEA
# ===============================================================================

fea = newAnalysis(SteadyStateLinear, 'su2_test')

mat = {
    "NAME": "material",
    "VXX": 0.35,
    "EXX": 5.0E9,
    }

geo = {"NAME": "geo1",
       "THICKN": 1.0}

# MODEL SET
LX = 0.5
LY = 10 

# gmsh config
points = [
        [0, 0, 0],
        [LX, 0, 0],
        [LX, LY, 0],
        [0, LY, 0]
        ]

lines = [
        [1, 2],
        [2, 3],
        [3, 4],
        [4, 1],
        ]

plane = [
        [1, 2, 3, 4]
        ]

modeldata = {

   "MESH": {
        'TYPE': 'gmsh',
        'filename': 'mesh_gmsh',
        'pointlist': points,
        'linelist': lines,
        'planelist': plane,
        'meshconfig': {
            'mesh': 'quad4',
            'sizeelement': 0.2,
            'meshmap': {'on': True,
                        'edge': 'all',
                    #  "numbernodes": 10,
            }
            }
    },

    "ELEMENT": {
        'TYPE': 'structplane',
        'SHAPE': 'quad4',
        'INTGAUSS': 4,
    },

    "MATERIAL": {
        "MAT": 'planestress',
        "TYPE": 'isotropic',
        "PROPMAT": [mat],
    },

    "GEOMETRY": {
        "GEO": 'thickness',
        "PROPGEO": [geo],
    },
}
fea.Model(modeldata)

f1 = {
    'TYPE': 'forceedge',
    'DOF': 'fx',
    'DIR': 'edgex',
    'LOC': {'x': 0, 'y': 999, 'z': 0},
    'VAL': [1.0],
    }

bc1 = {
    'TYPE': 'fixed',
    'DOF': 'full',
    'DIR': 'edgey',
    'LOC': {'x': 999, 'y': 0, 'z': 0},
    }

physicdata = {
    "PHYSIC": {"DOMAIN": "structural",
               "LOAD": [f1],
               "BOUNDCOND": [bc1],
    },
    }

fea.Physic(physicdata)


previewset = {'RENDER': {'filename': 'model_preview', 'show': True, 'scale': 2, 'savepng': True, 'lines': False,
                         'plottags': {'line': True}
                         },
              }
fea.PreviewAnalysis(previewset)

# #-------------------------------- SOLVER -------------------------------------#
solverset = {"STEPSET": {'type': 'table',
                        'start': 0,
                        'end': 1,
                        'step': 1},
             'SYMM':True,
             }
solverdata = fea.Solve(solverset)

print(np.max(np.abs(solverdata['solution']['U'])))

postprocset = {"SOLVERDATA": solverdata,
                "COMPUTER": {'structural': {'displ': True, 'stress': True}},
                "PLOTSET": {'show': True, 'filename': 'solution', 'savepng': True},
                "REPORT": {'log': True,
                           'get': {
                                'nelem': True,
                                'nnode': True
                                }
                                },
            }
postprocdata = fea.PostProcess(postprocset)

Vibration Modal Linear Analysis

vibration_plane.py

Relatório de Benchmark (PT-BR PDF)

Relatório de Benchmark (PT-BR PDF)

from myfempy import newAnalysis
from myfempy import DynamicEigenLinear

#===============================================================================
#                                   FEA
#===============================================================================
fea = newAnalysis(DynamicEigenLinear)

mat = {
    "NAME": "mat1",
    "VXY": 0.25,
    "EXX": 10000,
    "RHO": 10,
    }

geo = {
    "NAME": "espessura",
    "THICKN": 2,
    }

# MODEL SET
LX = 10
LY = 5

# nelx = 40
# nely = 30

esize = 0.25

# gmsh config
points = [
    [0, 0, 0],
    [LX, 0, 0],
    [LX, LY, 0],
    [0, LY, 0]
]

lines = [[1, 2],
         [2, 3],
         [3, 4],
         [4, 1],
         ]

plane = [[1, 2, 3, 4]]

modeldata = {        
    # "MESH": {
    #     'TYPE': 'legacy',
    #     'LX': LX,
    #     'LY': LY,
    #     'NX': nelx,
    #     'NY': nely,
    #     },

    "MESH": {
            'TYPE': 'gmsh',
            'filename': 'mesh_gmsh',
            'pointlist': points,
            'linelist': lines,
            'planelist': plane,
            'meshconfig': {
                'mesh': 'quad4',   #quad4
                'sizeelement': 2 * esize,
                'meshmap': {'on': True,
                            'edge': 'all', #'all'
                        #  "numbernodes": 10,
                }}
        },

    "ELEMENT": {
        'TYPE': 'structplane',
        'SHAPE': 'quad4',
        # 'INTGAUSS': 4,
    },

    "MATERIAL": {
        "MAT": 'planestress',
        "TYPE": 'isotropic',
        "PROPMAT": [mat],
    },

    "GEOMETRY": {
        "GEO": 'thickness',
        "PROPGEO": [geo],
    },
}
fea.Model(modeldata)

forcespring_left = {
    'TYPE': 'forcenode',
    'DOF': 'spring2ground',
    'DIR': 'point',
    'TAG': 1,
    'VAL': [1000.0],
    }

forcespring_right = {
    'TYPE': 'forcenode',
    'DOF': 'spring2ground',
    'DIR': 'point',
    'TAG': 2,
    'VAL': [1000.0],
    }

massadd = {
    'TYPE': 'forcenode',
    'DOF': 'masspoint',
    'DIR': 'node', #'point', #'node',
    'LOC': {'x': LX/2, 'y': LY/2, 'z': 0},
    'VAL': [1.4],
    }

bc_nodes_left = {
    'TYPE': 'fixed',
    'DOF': 'full',
    'DIR': 'edgex',
    'LOC': {'x': 0, 'y': 999, 'z': 0},
    }

physicdata = {
    "PHYSIC": {"DOMAIN": "structural",
                "LOAD": [],
                "BOUNDCOND": [bc_nodes_left],
    },
    }
fea.Physic(physicdata)

previewset = {'RENDER': {'filename': 'preview', 'show': True, 'scale': 10, 'savepng': True, 'lines': False,
                        'plottags': {
                        # 'line': True
                        'point': True
                              }
                         },
            #   'LABELS': {'show': True, 'lines': True, 'scale': 1},
              }
fea.PreviewAnalysis(previewset)

# #-------------------------------- SOLVER -------------------------------------#
solverset = {"STEPSET": {'type': 'mode',  # mode, freq, time ...
                        'start': 0,
                        'end': 3,
                        'step': 1},
             'SYMM':True,
            #  'MP':True,
            }
solverdata = fea.Solve(solverset)

print(solverdata['solution']['FREQ'])

postprocdata = {"SOLVERDATA": solverdata,
                "COMPUTER": {
                    'structural': {'modes': True},
                    },
                "PLOTSET": {'filename': 'output', 'savepng': True},
                "REPORT": {'log': True, 'get': {'nelem': True, 'nnode': True}},           
                }

postporc_result = fea.PostProcess(postprocdata)

vibration_beam.py

import sys
# setting path
sys.path.append('../myfempy')

from myfempy import newAnalysis
from myfempy import DynamicEigenLinear

# ===============================================================================
#                                   FEA
# ===============================================================================
fea = newAnalysis(DynamicEigenLinear)
LX = 10 
nelx = 10
# MODEL SET
mat = {
    "NAME": "aco",
    "EXX": 10000,       # N/mm^2 --> MPa
    "GXY": 4000,
    "RHO": 10,    # kg/mm^2
    }

geo = {
    "NAME": "secao",
    "AREACS": 10,
    "INERYY": 100,
    "INERZZ": 100,
    "INERXX": 100,
    }


# MODEL SET
# gmsh config
points = [
    [0, 0, 0],
    [LX, 0, 0],
]

lines = [
    [1, 2],
         ]

modeldata = {
   "MESH": {
        'TYPE': 'gmsh',
        'filename': 'mesh_gmsh',
        'pointlist': points,
        'linelist': lines,
        'meshconfig': {
            'mesh': 'line2',
            "numbernodes": nelx + 1,
            }
    },

    "ELEMENT": {
        'TYPE': 'structbeam',
        'SHAPE': 'line2',
        # 'INTGAUSS': 4,
    },

    "MATERIAL": {
        "MAT": 'uniaxialstress',
        "TYPE": 'isotropic',
        "PROPMAT": [mat],
    },

    "GEOMETRY": {
        "GEO": 'frame',
        "SECTION": 'userdefined',
        "PROPGEO": [geo],
    },
}
fea.Model(modeldata)

bc = {
    'TYPE': 'fixed',
    'DOF': 'full',
    'DIR': 'node',
    'LOC': {'x': 0, 'y': 0, 'z': 0},
    }

physicdata = {
    "PHYSIC": {"DOMAIN": "structural",
               "LOAD": [],
               "BOUNDCOND": [bc],
    },
}
fea.Physic(physicdata)

previewset = {'RENDER': {'filename': 'preview', 'show': True, 'scale': 20, 'savepng': True, 'lines': False,
                         },
              }
fea.PreviewAnalysis(previewset)

# #-------------------------------- SOLVER -------------------------------------#
solverset = {"STEPSET": {'type': 'mode',  # mode, freq, time ...
                        'start': 0,
                        'end': 30,
                        'step': 1},
             'SYMM':True,
            #  'MP':True,
            }
solverdata = fea.Solve(solverset)

print(solverdata['solution']['FREQ'])

postprocset = {"SOLVERDATA": solverdata,
                "COMPUTER": {'structural': {'modes': True}},
                "PLOTSET": {'show': True, 'filename': 'output', 'savepng': True},
                "REPORT": {'log': True, 'get': {'nelem': True, 'nnode': True}},
            }
postprocdata = fea.PostProcess(postprocset)

vibration_solid.py

Relatório de Benchmark (PT-BR PDF)

import sys
# setting path
sys.path.append('../myfempy')

from myfempy import newAnalysis
from myfempy import DynamicEigenLinear

# ===============================================================================
#                                   FEA
# ===============================================================================
fea = newAnalysis(DynamicEigenLinear)

# MODEL SET
mat = {
    "NAME": "Aluminum_Alloy",
    "VXY": 0.33,
    "EXX": 71E6,        # MPa (N/mm2)
    "RHO": 2.77E-06,    # kg/mm3
    }

geo = {"NAME": "Solid"}

# MODEL SET
LX = 100
LY = 100
esize = 5

# gmsh config
points = [
    [0, 0, 0],
    [LX, 0, 0],
    [LX, LY, 0],
    [0, LY, 0]
]

lines = [[1, 2],
         [2, 3],
         [3, 4],
         [4, 1],
         ]

plane = [[1, 2, 3, 4]]


modeldata = {
   "MESH": {
        'TYPE': 'gmsh',
        'filename': 'mesh_gmsh',
        'pointlist': points,
        'linelist': lines,
        'planelist': plane,
        'meshconfig': {
            'mesh': 'hexa8',   #quad4 tria3
            'sizeelement': 2*esize,
            'extrude': 100,
            'meshmap': {'on': True,
                        'edge': 'all', #[[1,3], [2,4]], #'all'
                        # "numbernodes": [20, 10],
            }
            }
    },

    "ELEMENT": {
        'TYPE': 'structsolid',
        'SHAPE': 'hexa8',
        'INTGAUSS': 9,
    },

    "MATERIAL": {
        "MAT": 'solidelastic',
        "TYPE": 'isotropic',
        "PROPMAT": [mat],
    },

    "GEOMETRY": {
        "GEO": 'solid',
        "PROPGEO": [geo],
    },
}
fea.Model(modeldata)

physicdata = {
    "PHYSIC": {"DOMAIN": "structural",
               "LOAD": [],
               "BOUNDCOND": [],
    },
}
fea.Physic(physicdata)

previewset = {'RENDER': {'filename': 'preview', 'show': True, 'scale': 8, 'savepng': True, 'lines': True,
                        #  'plottags': {'point': True},
                         },
              }
fea.PreviewAnalysis(previewset)

# #-------------------------------- SOLVER -------------------------------------#
solverset = {"STEPSET": {'type': 'table',  # mode, freq, time ...
                        'start': 0,
                        'end': 12,
                        'step': 1},
             'SYMM':True,
            #  'MP':True,
            }
solverdata = fea.Solve(solverset)

print(solverdata['solution']['FREQ'])

postprocset = {"SOLVERDATA": solverdata,
                "COMPUTER": {
                    'structural': {'modes': True},
                    },
                "PLOTSET": {'filename': 'output', 'savepng': True},
                "REPORT": {'log': True, 'get': {'nelem': True, 'nnode': True}},           
                }
postprocdata = fea.PostProcess(postprocset)

tuning_fork.py

Relatório de Benchmark (PT-BR PDF) Extra file download

Relatório de Benchmark (PT-BR PDF)

from myfempy import newAnalysis
from myfempy import DynamicEigenLinear

# ===============================================================================
#                                   FEA
# ===============================================================================
fea = newAnalysis(DynamicEigenLinear, 'sim')
# MODEL SET
mat = {
    "NAME": "Aluminum_Alloy",
    "VXY": 0.33,
    "EXX": 71E6,        # MPa (N/mm2)
    "RHO": 2.77E-6,    # kg/mm3
    }

geo = {"NAME": "Solid"}

modeldata = {
   "MESH": {
        'TYPE': 'gmsh',
        'filename': 'mesh_gmsh',
        # !!! COLOCAR O CAD NO DIRETORIO DA SIMULACAO !!!
        'cadimport': {'object': 'tuning_fork.STEP'}, 
        'meshconfig': {
            'mesh': 'tetr4',
            'sizeelement': 2,
            },
    },

    "ELEMENT": {
        'TYPE': 'structsolid',
        'SHAPE': 'tetr4',
        # 'INTGAUSS': 4,
    },

    "MATERIAL": {
        "MAT": 'solidelastic',
        "TYPE": 'isotropic',
        "PROPMAT": [mat],
    },

    "GEOMETRY": {
        "GEO": 'solid',
        "PROPGEO": [geo],
    },
}
fea.Model(modeldata)

physicdata = {
    "PHYSIC": {"DOMAIN": "structural",
               "LOAD": [],
               "BOUNDCOND": [],
    },
}
fea.Physic(physicdata)

previewset = {'RENDER': {'filename': 'preview', 'show': True, 'scale': 4, 'savepng': True, 'lines': True,
                        #  'plottags': {'plane': True}
                         },
              }
fea.PreviewAnalysis(previewset)

# #-------------------------------- SOLVER -------------------------------------#
solverset = {"STEPSET": {'type': 'table',  # mode, freq, time ...
                        'start': 0,
                        'end': 12,
                        'step': 1},
             'SYMM':True,
            #  'MP':True,
            }
solverdata = fea.Solve(solverset)

print(solverdata['solution']['FREQ'])

postprocset = {"SOLVERDATA": solverdata,
                "COMPUTER": {
                    'structural': {'modes': True},
                    },
                "PLOTSET": {'filename': 'output', 'savepng': True},
                "REPORT": {'log': True, 'get': {'nelem': True, 'nnode': True}},           
                }
postprocdata = fea.PostProcess(postprocset)

Vibration Harmonic Linear Analysis

vibration_frf.py


Heat Flow

heat_StSd.py


Cyclic Symmetric

cyclic_symmetric_plane.py


Thermal-Mechanics

coup_struct_heat_StSd.py


sim_tira_bimetalica.py


Multi-Scale

myfempy_multi_escala_Al_core_square_hole.py