Ejemplo n.º 1
0
 def test_generalized_alpha_nonlinear_dynamics_solver(self):
     self.system.apply_neumann_boundaries(key=3,
                                          val=2.5e8,
                                          direct=(0, -1),
                                          time_func=lambda t: 1)
     self.solver = amfe.GeneralizedAlphaNonlinearDynamicsSolver(
         mechanical_system=self.system, **self.options)
     self.solver.solve()
     x = np.array([
         self.system.T_output[:],
         [displacement[2] for displacement in self.system.u_output]
     ])
     y = np.array([
         self.system.T_output[:],
         [displacement[3] for displacement in self.system.u_output]
     ])
     fnx = amfe.amfe_dir(
         'tests/kratos/Kratos_beam10x1Quad8_nonlinear_dynamics_x_wbzalpha_rhoinf095_dt1e-6.grf'
     )
     fny = amfe.amfe_dir(
         'tests/kratos/Kratos_beam10x1Quad8_nonlinear_dynamics_y_wbzalpha_rhoinf095_dt1e-6.grf'
     )
     reference_x = read_grf(fnx)
     reference_y = read_grf(fny)
     assert_allclose(x[1, 1:],
                     reference_x[1, 499::500],
                     rtol=1e-12,
                     atol=0.06)
     assert_allclose(y[1, 1:],
                     reference_y[1, 499::500],
                     rtol=1e-12,
                     atol=0.06)
Ejemplo n.º 2
0
 def setUp(self):
     # define input-file and prefix for output
     self.input_file = amfe.amfe_dir('meshes/gmsh/beam/Beam10x1Quad8.msh')
     self.output_file_prefix = amfe.amfe_dir('results/beam/Beam10x1Quad8')
     # setup mechanical system
     self.material = amfe.KirchhoffMaterial(E=2.1e11,
                                            nu=0.3,
                                            rho=7.867e3,
                                            plane_stress=False)
     self.system = amfe.MechanicalSystem()
     self.system.load_mesh_from_gmsh(self.input_file, 1, self.material)
     self.system.apply_dirichlet_boundaries(5, 'xy')
     ndof = self.system.dirichlet_class.no_of_constrained_dofs
     self.system.apply_rayleigh_damping(1e0, 1e-5)  # set damping and ...
     self.system.apply_no_damping()  # ... reset damping for testing
     self.options = {
         'number_of_load_steps': 10,
         'newton_damping': 1.0,
         'simplified_newton_iterations': 1,
         't': 1.0,
         't0': 0.0,
         't_end': 0.4,
         'dt': 5e-4,
         'dt_output': 5e-4,
         'rho_inf': 0.95,
         'initial_conditions': {
             'x0': np.zeros(2 * ndof),
             'q0': np.zeros(ndof),
             'dq0': np.zeros(ndof)
         },
         'relative_tolerance': 1.0E-6,
         'absolute_tolerance': 1.0E-9,
         'verbose': True,
         'max_number_of_iterations': 99,
         'convergence_abort': True,
         'write_iterations': False,
         'track_number_of_iterations': False,
         'save_solution': True
     }
     rho_inf = 0.95
     alpha = 0.0005
Ejemplo n.º 3
0
# Copyright (c) 2017, Lehrstuhl fuer Angewandte Mechanik, Technische
# Universitaet Muenchen.
#
# Distributed under BSD-3-Clause License. See LICENSE-File for more information
#
"""
Rubber boot example
"""

import amfe



input_file = amfe.amfe_dir('meshes/gmsh/rubber_boot.msh')
output_file = amfe.amfe_dir('results/rubber_boot/boot')

# PE-LD; better material would be Mooney-Rivlin
my_material = amfe.KirchhoffMaterial(E=200E6, nu=0.3, rho=1E3)

my_system = amfe.MechanicalSystem(stress_recovery=False)
my_system.load_mesh_from_gmsh(input_file, 977, my_material, scale_factor=1E-3)
my_system.apply_dirichlet_boundaries(978, 'xyz')
my_system.apply_neumann_boundaries(979, 1E7, (0,1,0), lambda t:t)

#%%

amfe.vibration_modes(my_system, save=True)

my_system.export_paraview(output_file + '_modes')

#%%
Ejemplo n.º 4
0
# Copyright (c) 2017, Lehrstuhl fuer Angewandte Mechanik, Technische
# Universitaet Muenchen.
#
# Distributed under BSD-3-Clause License. See LICENSE-File for more information
#
"""
File running the hexahedron elements
"""

import amfe
import numpy as np

gmsh_input_file = amfe.amfe_dir('meshes/gmsh/plate_transfinite.msh')
paraview_output_file = amfe.amfe_dir('results/plate/plate_transfinite')

my_material = amfe.KirchhoffMaterial()
my_system = amfe.MechanicalSystem()

my_system.load_mesh_from_gmsh(gmsh_input_file, 30, my_material)
my_system.apply_dirichlet_boundaries(31, 'xyz')

#my_system.apply_neumann_boundaries(32, 1E8, np.array([0,0,1]),
#                                   time_func=lambda t: t)
# pulling the system
my_system.apply_neumann_boundaries(32, -1E10, 'normal', time_func=lambda t: t)

# Test the paraview basic output
# my_system.export_paraview(paraview_output_file)

#%%
nlsolver = amfe.NonlinearStaticsSolver(my_system, number_of_load_steps=20)
Ejemplo n.º 5
0
# Copyright (c) 2017, Lehrstuhl fuer Angewandte Mechanik, Technische Universitaet Muenchen.
#
# Distributed under BSD-3-Clause License. See LICENSE-File for more information.
#
"""
Example: Cantilever beam loaded at tip.
"""

# load packages
import amfe
import scipy as sp
import numpy as np

# define input files
input_file1 = amfe.amfe_dir('meshes/gmsh/beam/Beam10x1Quad8.msh')
input_file2 = amfe.amfe_dir('meshes/gmsh/beam/Beam10x1Quad4.msh')

# define system 1
material1 = amfe.KirchhoffMaterial(E=2.1e11,
                                   nu=0.3,
                                   rho=7.867e3,
                                   plane_stress=False)
system1 = amfe.MechanicalSystem()
system1.load_mesh_from_gmsh(input_file1, 1, material1)
system1.apply_dirichlet_boundaries(5, 'xy')
ndof1 = system1.dirichlet_class.no_of_constrained_dofs
system1.apply_neumann_boundaries(key=3,
                                 val=1.0,
                                 direct=(0, -1),
                                 time_func=lambda t: 1)
system1.apply_rayleigh_damping(1e0, 1e-5)
Ejemplo n.º 6
0
# set simulation type
###############################################################################
#  > static (True) or dynamic (False) analysis
statics = False
###############################################################################
#  > linear (True) or nonlinear (False) analysis
linear = False
###############################################################################
#  > time integration scheme ('GeneralizedAlpha', 'WBZAlpha', 'HHTAlpha',
#    'NewmarkBeta', 'JWHAlpha' or 'JWHAlphaStateSpace') for dynamic analysis
scheme = 'GeneralizedAlpha'
###############################################################################


# define in- and output files
input_file = amfe.amfe_dir('meshes/gmsh/compositeBeam_50x10_Ns10.msh')
output_file = amfe.amfe_dir('results/compositeBeam_50x10_Ns10')
if not linear:
    output_file += '_nonlinear'
else:
    output_file += '_linear'
if not statics:
    output_file += '_dynamics'
else:
    output_file += '_statics'
if scheme is 'GeneralizedAlpha':
    output_file += '_generalizedalpha'
elif scheme is 'WBZAlpha':
    output_file += '_wbzalpha'
elif scheme is 'HHTAlpha':
    output_file += '_hhtalpha'
Ejemplo n.º 7
0
              'in {0:1d} iterations'.format(n_iter))
    normal = np.cross(jac[:, 0], jac[:, 1])
    normal /= np.sqrt(normal @ normal)
    e1 = jac[:, 0]
    e1 /= np.sqrt(e1 @ e1)
    e2 = np.cross(normal, e1)
    rot_basis = np.zeros((3, 3))
    rot_basis[:, 0] = normal
    rot_basis[:, 1] = e1
    rot_basis[:, 2] = e2
    return valid_element, N, rot_basis, xi


#%%

input_file = amfe.amfe_dir('meshes/gmsh/plate_mesh_tying.msh')
output_file = amfe.amfe_dir('results/mesh_tying/plate_mesh_tying')

my_mesh = amfe.Mesh()
my_mesh.import_msh(input_file)

my_material = amfe.KirchhoffMaterial(E=210E9,
                                     nu=0.3,
                                     rho=1E4,
                                     plane_stress=True)

my_mesh.load_group_to_mesh(1, my_material, 'phys_group')  # box
my_mesh.load_group_to_mesh(2, my_material, 'phys_group')  # platform

my_mesh.save_mesh_xdmf(output_file + '_all')
Ejemplo n.º 8
0
Created on Thu May 21 17:44:13 2015

Test the mesh-module

@author: johannesr
"""

import time

import numpy as np
import scipy as sp

import amfe

# test gmsh input-output functionality
gmsh_input_file = amfe.amfe_dir('meshes/test_meshes/bar_3d.msh')

#gmsh_input_file = 'meshes/test_meshes/bar_Tet4_finest_phys_group.msh'
paraview_output_file = amfe.amfe_dir('results/gmsh_test/gmsh_import')

my_mesh = amfe.Mesh()
my_mesh.import_msh(gmsh_input_file)

#%%
my_mesh.mesh_information('Sepp')

my_material = amfe.material.KirchhoffMaterial()
my_mesh.load_group_to_mesh(29, my_material)
my_assembly = amfe.Assembly(my_mesh)
my_mesh.set_dirichlet_bc(30, 'xyz')
my_mesh.set_neumann_bc(31, -1E10, 'normal')
Ejemplo n.º 9
0
"""
Load a NASTRAN mesh 
"""

import numpy as np
import pandas as pd
import amfe


#%%

filename = amfe.amfe_dir('meshes/nastran/conrod.bdf')
my_material = amfe.KirchhoffMaterial()
my_mesh = amfe.Mesh()
my_mesh.import_bdf(filename)

my_mesh.load_group_to_mesh(1, my_material)
my_mesh.load_group_to_mesh(10, my_material)
my_mesh.load_group_to_mesh(20, my_material)

#%% Deflate the mesh
my_mesh.deflate_mesh()

#%%

my_assembly = amfe.Assembly(my_mesh)
my_assembly.preallocate_csr()

u0 = np.zeros(my_mesh.no_of_dofs)
K_unconstr, f_unconstr = my_assembly.assemble_k_and_f(u=u0, t=1)
Ejemplo n.º 10
0
"""
Test run for the stress recovery implementation. 
"""

import numpy as np
import scipy as sp
import amfe

#%% Setting up the mesh

# test gmsh input-output functionality
# gmsh_input_file = amfe.amfe_dir() + '/meshes/test_meshes/bar_3d.msh'
gmsh_input_file = amfe.amfe_dir() + '/meshes/gmsh/bar_tri6.msh'

paraview_output_file = amfe.amfe_dir(
) + '/results/stress_recovery/stress_recovery'

my_mesh = amfe.Mesh()
my_mesh.import_msh(gmsh_input_file)

#%% Setting up the system

my_material = amfe.material.KirchhoffMaterial()
my_mesh.load_group_to_mesh(7, my_material)
my_assembly = amfe.Assembly(my_mesh)
my_mesh.set_dirichlet_bc(8, 'xy')
my_mesh.set_neumann_bc(9, 1E7, (0, 1))
my_assembly.preallocate_csr()

#%% run with mechanical system
my_system = amfe.MechanicalSystem(stress_recovery=True)
Ejemplo n.º 11
0
# Copyright (c) 2017, Lehrstuhl fuer Angewandte Mechanik, Technische
# Universitaet Muenchen.
#
# Distributed under BSD-3-Clause License. See LICENSE-File for more information
#
"""
Example showing a corner with pressure
"""

from matplotlib import pyplot as plt

import amfe
from amfe import hyper_red

input_file = amfe.amfe_dir('meshes/gmsh/pressure_corner.msh')
output_file = amfe.amfe_dir('results/pressure_corner/pressure_corner')

my_material = amfe.KirchhoffMaterial(E=210E9,
                                     nu=0.3,
                                     rho=1E4,
                                     plane_stress=True)
my_system = amfe.MechanicalSystem(stress_recovery=True)
my_system.load_mesh_from_gmsh(input_file, 11, my_material)
my_system.apply_dirichlet_boundaries(9, 'x')
my_system.apply_dirichlet_boundaries(10, 'y')
my_system.apply_neumann_boundaries(12, 1E10, 'normal', lambda t: t)

#amfe.solve_linear_displacement(my_system)
snapshots = amfe.solve_nonlinear_displacement(my_system,
                                              no_of_load_steps=50,
                                              track_niter=True)
Ejemplo n.º 12
0
import time

import numpy as np
import scipy as sp

import amfe

warning = '''
###############################################################################
#############    This file is heavily deprecated. Don't use it.   #############
###############################################################################
'''
print(warning)

# Mesh generation
input_file = amfe.amfe_dir('meshes/gmsh/2D_Rectangle_tri6_dehnstab.msh')
# Building the mechanical system
my_materal = amfe.KirchhoffMaterial(E=210E9, nu=0.3, rho=1E4)
my_mechanical_system = amfe.MechanicalSystem()
my_mechanical_system.load_mesh_from_gmsh(input_file,
                                         phys_group=0,
                                         material=my_materal)

#%%

# Boundary handling
bottom_line_indices = my_mechanical_system.mesh_class.boundary_list[6]
top_line_indices = my_mechanical_system.mesh_class.boundary_list[4]

bottom_fixation_x = [
    None, [amfe.node2total(i, 0) for i in bottom_line_indices], None
Ejemplo n.º 13
0
"""
Leaf spring file 2
"""

import amfe

input_file = amfe.amfe_dir('meshes/abaqus/A9603205802.inp')
output_file = amfe.amfe_dir('results/abaqus/leaf_spring_2')

my_system = amfe.MechanicalSystem()

my_mesh = my_system.mesh_class
my_mesh.import_inp(input_file)

steel = amfe.KirchhoffMaterial(E=210E9, nu=0.3, rho=1E4, plane_stress=True)
my_material = amfe.KirchhoffMaterial(E=210E9,
                                     nu=0.3,
                                     rho=1E4,
                                     plane_stress=True)

my_mesh.load_group_to_mesh('Leaf_1', steel, 'phys_group')
my_mesh.load_group_to_mesh('Leaf_2', steel, 'phys_group')

my_mesh.load_group_to_mesh('NX_3d_mesh(65)', my_material, 'phys_group')
my_mesh.load_group_to_mesh('Lager_Lower_Platte', my_material, 'phys_group')

my_mesh.load_group_to_mesh('LAger_Upper_Platte', my_material, 'phys_group')
my_mesh.load_group_to_mesh('Platte', my_material, 'phys_group')
my_mesh.load_group_to_mesh('P13', my_material, 'phys_group')

my_mesh.save_mesh_xdmf(output_file + '_solid')
Ejemplo n.º 14
0
# Copyright (c) 2017, Lehrstuhl fuer Angewandte Mechanik, Technische Universitaet Muenchen.
#
# Distributed under BSD-3-Clause License. See LICENSE-File for more information.
#
"""
Example: Cantilever beam loaded at tip solved with adaptive time stepping.
"""


# load packages
import amfe
import numpy as np


# define in- and output files
input_file = amfe.amfe_dir('meshes/gmsh/chimney/Chimney200x80Hex20.msh')
output_file = amfe.amfe_dir('results/chimney/Chimney200x80Hex20_nonlinear_dynamics_generalizedalpha')


# define system
material = amfe.KirchhoffMaterial(E=2.1e11, nu=0.3, rho=7.867e3)
system = amfe.MechanicalSystem()
system.load_mesh_from_gmsh(input_file, 1, material)
system.apply_dirichlet_boundaries(2, 'xy')
ndof = system.dirichlet_class.no_of_constrained_dofs
system.apply_neumann_boundaries(key=4, val=1.0e4, direct=(1, 1, 0), time_func=lambda t: np.sin(180.32*t))
# system.apply_rayleigh_damping(1e0, 1e-5)


# vibration modes
# amfe.vibration_modes(mechanical_system=system, n=10, save=True)
Ejemplo n.º 15
0
# Copyright (c) 2017, Lehrstuhl fuer Angewandte Mechanik, Technische Universitaet Muenchen.
#
# Distributed under BSD-3-Clause License. See LICENSE-File for more information.
#
"""
Example: Cantilever beam loaded at tip solved with adaptive time stepping.
"""

# load packages
import amfe
import numpy as np

# define in- and output files
input_file = amfe.amfe_dir('meshes/gmsh/beam/Beam10x1Quad8.msh')
output_file = amfe.amfe_dir(
    'results/beam/Beam10x1Quad8_nonlinear_dynamics_adaptive_time_stepping')

# define system
material = amfe.KirchhoffMaterial(E=2.1e11,
                                  nu=0.3,
                                  rho=7.867e3,
                                  plane_stress=False)
system = amfe.MechanicalSystem()
system.load_mesh_from_gmsh(input_file, 1, material)
system.apply_dirichlet_boundaries(5, 'xy')
ndof = system.dirichlet_class.no_of_constrained_dofs
system.apply_neumann_boundaries(key=3,
                                val=2.5e8,
                                direct=(0, -1),
                                time_func=lambda t: 1.)
system.apply_rayleigh_damping(1e0, 1e-6)
Ejemplo n.º 16
0
"""
Leaf spring file
"""

import amfe

input_file = amfe.amfe_dir('meshes/abaqus/A9483201605_max_loaded.inp')
output_file = amfe.amfe_dir('results/abaqus/leaf_spring')

my_mesh = amfe.Mesh()
my_mesh.import_inp(input_file)

my_material = amfe.KirchhoffMaterial(E=210E9,
                                     nu=0.3,
                                     rho=1E4,
                                     plane_stress=True)

my_mesh.load_group_to_mesh('Federbuegel', my_material, 'phys_group')
my_mesh.load_group_to_mesh('Federspannplate', my_material, 'phys_group')
my_mesh.load_group_to_mesh('Zwischenplatte', my_material, 'phys_group')
my_mesh.load_group_to_mesh('Blatt_01', my_material, 'phys_group')
my_mesh.load_group_to_mesh('Blatt_02', my_material, 'phys_group')
my_mesh.load_group_to_mesh('Blatt_03', my_material, 'phys_group')
my_mesh.load_group_to_mesh('Blatt_04', my_material, 'phys_group')
my_mesh.load_group_to_mesh('Blatt_05', my_material, 'phys_group')

my_mesh.save_mesh_xdmf(output_file + '_all')

#%%
my_mesh.load_group_to_mesh('et_10000', my_material, 'phys_group')
Ejemplo n.º 17
0
#
# Distributed under BSD-3-Clause License. See LICENSE-File for more information
#
"""
"""


import numpy as np
import scipy as sp
import time

import amfe



gmsh_input_file = amfe.amfe_dir('meshes/gmsh/c_bow_coarse.msh')
paraview_output_file = amfe.amfe_dir('results/c_bow_coarse/c_bow_coarse')


my_material = amfe.KirchhoffMaterial()
my_system = amfe.MechanicalSystem()

my_system.load_mesh_from_gmsh(gmsh_input_file, 15, my_material)
# Test the paraview basic output
# my_system.export_paraview(paraview_output_file)

my_system.apply_dirichlet_boundaries(13, 'xy')

harmonic_x = lambda t: np.sin(2*np.pi*t*30)
harmonic_y = lambda t: np.sin(2*np.pi*t*50)
Ejemplo n.º 18
0
# -*- coding: utf-8 -*-
# Copyright (c) 2017, Lehrstuhl fuer Angewandte Mechanik, Technische
# Universitaet Muenchen.
#
# Distributed under BSD-3-Clause License. See LICENSE-File for more information
#
"""
Running a 3D-tension bar
"""

import amfe

mesh_file = amfe.amfe_dir('meshes/test_meshes/bar_Tet4_fine.msh')
output_file = amfe.amfe_dir('results/bar_tet10/bar_tet4')

# Building the mechanical system
my_material = amfe.KirchhoffMaterial()
my_system = amfe.MechanicalSystem()
my_system.load_mesh_from_gmsh(mesh_file, 29, my_material)
# Fixations are simple to realize
my_system.apply_dirichlet_boundaries(30, 'xyz')
my_system.apply_dirichlet_boundaries(31, 'yz')

# make master-slave approach to add constraint that x-dofs are all the same at right end
nodes, dofs = my_system.mesh_class.set_dirichlet_bc(31, 'x', output='external')
my_system.dirichlet_class.apply_master_slave_list([
    [dofs[0], dofs[1:], None],
])
my_system.dirichlet_class.update()

# %%
Ejemplo n.º 19
0
###############################################################################
# set simulation type
###############################################################################
#  > static (True) or dynamic (False) analysis
statics = False
###############################################################################
#  > linear (True) or nonlinear (False) analysis
linear = False
###############################################################################
#  > time integration scheme ('GeneralizedAlpha', 'WBZAlpha', 'HHTAlpha',
#    'NewmarkBeta', 'JWHAlpha' or 'JWHAlphaStateSpace') for dynamic analysis
scheme = 'GeneralizedAlpha'
###############################################################################

# define in- and output files
input_file = amfe.amfe_dir('meshes/gmsh/beam/Beam10x1Quad8.msh')
output_file = amfe.amfe_dir('results/beam/Beam10x1Quad8')
if not linear:
    output_file += '_nonlinear'
else:
    output_file += '_linear'
if not statics:
    output_file += '_dynamics'
else:
    output_file += '_statics'
if scheme is 'GeneralizedAlpha':
    output_file += '_generalizedalpha'
elif scheme is 'WBZAlpha':
    output_file += '_wbzalpha'
elif scheme is 'HHTAlpha':
    output_file += '_hhtalpha'
Ejemplo n.º 20
0
# Copyright (c) 2017, Lehrstuhl fuer Angewandte Mechanik, Technische
# Universitaet Muenchen.
#
# Distributed under BSD-3-Clause License. See LICENSE-File for more information
#
"""
Dynamic Pipe test case
"""

import numpy as np
import amfe

input_file = amfe.amfe_dir('meshes/gmsh/pipe.msh')
output_file = amfe.amfe_dir('results/pipe/pipe')

# Steel
#my_material = amfe.KirchhoffMaterial(E=210E9, nu=0.3, rho=1E4, plane_stress=True)
# PE-LD
my_material = amfe.KirchhoffMaterial(E=200E6,
                                     nu=0.3,
                                     rho=1E3,
                                     plane_stress=True)

my_system = amfe.MechanicalSystem(stress_recovery=True)
my_system.load_mesh_from_gmsh(input_file, 84, my_material)
my_system.apply_dirichlet_boundaries(83, 'xyz')
my_system.apply_neumann_boundaries(85, 1E7, (0, 1, 0), lambda t: t)

#%%
#amfe.solve_linear_displacement(my_system)
amfe.solve_nonlinear_displacement(my_system,
Ejemplo n.º 21
0
# Copyright (c) 2017, Lehrstuhl fuer Angewandte Mechanik, Technische
# Universitaet Muenchen.
#
# Distributed under BSD-3-Clause License. See LICENSE-File for more information
#
"""
Created on Fri Dec 18 15:31:45 2015

@author: johannesr
"""

import numpy as np
import scipy as sp
import amfe

input_file = amfe.amfe_dir('meshes/gmsh/AMFE_logo.msh')
output_file = amfe.amfe_dir('results/AMFE_logo/logo_5')

material_1 = amfe.KirchhoffMaterial(E=5E6, rho=1E4)
material_2 = amfe.KirchhoffMaterial(E=5E7, rho=1E4)
my_system = amfe.MechanicalSystem()

my_system.load_mesh_from_gmsh(input_file, 299, material_1)
my_system.load_mesh_from_gmsh(input_file, 300, material_1)
my_system.load_mesh_from_gmsh(input_file, 301, material_2)
my_system.load_mesh_from_gmsh(input_file, 302, material_2)

my_system.apply_dirichlet_boundaries(298, 'xyz')
M_unconstr = my_system.assembly_class.assemble_m()
no_of_nodes = my_system.mesh_class.no_of_nodes
#g = [(0, -9.81, 0) for i in range(no_of_nodes)]
# Beam example

# Distributed under BSD-3-Clause License. See LICENSE-File for more information
#
"""
Example showing a cantilever beam which is loaded on the tip with a force
showing nonlinear displacements.
"""

import amfe

input_file = amfe.amfe_dir('meshes/gmsh/bar.msh')
output_file = amfe.amfe_dir('results/beam_nonlinear/beam_ecsw')

my_material = amfe.KirchhoffMaterial(E=210E9,
                                     nu=0.3,
                                     rho=1E4,
                                     plane_stress=True)
my_system = amfe.MechanicalSystem()
my_system.load_mesh_from_gmsh(input_file, 7, my_material)
my_system.apply_dirichlet_boundaries(8, 'xy')  # fixature of the left side
my_system.apply_neumann_boundaries(key=9,
                                   val=1E8,
                                   direct=(0, -1),
                                   time_func=lambda t: t)

amfe.solve_linear_displacement(my_system)
my_system.export_paraview(output_file + '_linear')

amfe.solve_nonlinear_displacement(my_system, no_of_load_steps=50)
my_system.export_paraview(output_file + '_nonlinear')
# Copyright (c) 2017, Lehrstuhl fuer Angewandte Mechanik, Technische Universitaet Muenchen.
#
# Distributed under BSD-3-Clause License. See LICENSE-File for more information.
#
"""
Example: Comparison of POD bases for cantilever beam loaded at tip.
"""

# load packages
import amfe
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt

# define in- and output files
input_file = amfe.amfe_dir('meshes/gmsh/beam/Beam10x1Quad8.msh')
output_file = amfe.amfe_dir(
    'results/beam/Beam10x1Quad8_nonlinear_dynamics_generalizedalpha')

# define system
material = amfe.KirchhoffMaterial(E=2.1e11,
                                  nu=0.3,
                                  rho=7.867e3,
                                  plane_stress=False)
system = amfe.MechanicalSystem()
system.load_mesh_from_gmsh(input_file, 1, material)
system.apply_dirichlet_boundaries(5, 'xy')
ndof = system.dirichlet_class.no_of_constrained_dofs
# system.apply_rayleigh_damping(1e0, 1e-6)

# define simulation parameters