├── doc ├── example_code │ ├── postproc │ │ ├── HistoryOutput.py~ │ │ ├── HistoryOutput-plotable.png │ │ ├── GetMesh.py │ │ ├── FieldOutput-get_data.py │ │ ├── GetTensorFieldOutput.py~ │ │ ├── GetVectorFieldOutput.py │ │ ├── GetVectorFieldOutput.py~ │ │ ├── HystoryOutput_test.py~ │ │ ├── vector.vtk │ │ ├── vector.vtk~ │ │ ├── Identity_like.py │ │ ├── GetTensorFieldOutput.py │ │ ├── Identity_like.py~ │ │ ├── FieldOutput-dump2vtk.vtk │ │ ├── FieldOutput.py │ │ ├── VectorFieldOutput-get_data.py │ │ ├── VectorFieldOutput-get_data.py~ │ │ ├── HystoryOutput.py~ │ │ ├── GetTensorFieldOutput_byRpt.py~ │ │ ├── GetVectorFieldOutput_byRpt.py │ │ ├── GetVectorFieldOutput_byRpt.py~ │ │ ├── GetFieldOutput_byRpt.py │ │ ├── GetFieldOutput_byRpt.py~ │ │ ├── GetTensorFieldOutput_byRpt.py │ │ ├── VectorFieldOutput-dump2vtk.py │ │ ├── VectorFieldOutput-dump2vtk.py~ │ │ ├── TensoFieldOutput-eigen.py │ │ ├── TensorFieldOutput-tresca.py │ │ ├── TensorFieldOutput-tresca.py~ │ │ ├── HistoryOutput-average.py │ │ ├── HystoryOutput.py │ │ ├── HistoryOutput-average.py~ │ │ ├── TensoFieldOutput-eigen.py~ │ │ ├── historyOutput-plotable.py │ │ ├── HistoryOutput-integral.py │ │ ├── HistoryOutput-integral.py~ │ │ ├── TensorFieldOutput.py │ │ ├── FieldOutput-dump2vtk.py │ │ ├── TensorFieldOutput.py~ │ │ ├── GetFieldOutput.py │ │ ├── GetFieldOutput.py~ │ │ ├── VectorFieldOutput.py │ │ ├── VectorFieldOutput.py~ │ │ ├── ReadFieldOutputReport.py │ │ ├── indentation_core_step0_frame1_U1_nodal.rpt │ │ ├── indentation_core_step0_frame1_S11_nodes.rpt │ │ ├── ReadFieldOutputReport.py~ │ │ ├── MakeFieldOutputReport.py │ │ ├── MakeFieldOutputReport.py~ │ │ ├── indentation_core_step0_frame1_S11_elements.rpt │ │ └── indentation_core_step0_frame1_S11_element-nodal.rpt │ ├── indentation │ │ ├── indentation-Step.py │ │ ├── image.gsf │ │ ├── ContactData.pckl │ │ ├── ContactData_axi.pckl │ │ ├── ContactData_berk.pckl │ │ ├── workdir │ │ │ ├── indentation.pckl │ │ │ ├── indentation_axi.pckl │ │ │ ├── indentation_field.png │ │ │ └── indentation_load-disp.png │ │ ├── DeformableCone2D.py │ │ ├── DeformableCone3D.py │ │ ├── Get_ContactData.py │ │ ├── MakeInp_abqpostproc.py │ │ ├── ContactData-contact_contour.py │ │ ├── ContactData-export2spym.py │ │ ├── IndentationMesh.py │ │ ├── ContactData.py │ │ ├── Hertz.py │ │ ├── ContactData-get_3D_data.py │ │ ├── Hanson.py │ │ ├── Boussinesq.py │ │ ├── MakeInp_plot.py │ │ ├── ContactData-interpolate.py │ │ └── MakeInp.py │ ├── mesh │ │ ├── Mesh-dump2vtk.png │ │ ├── Mesh.sweep.py~ │ │ ├── Nodes-sweep.py~ │ │ ├── Mesh-replace_node.py │ │ ├── Mesh-replace_node.py~ │ │ ├── Nodes-closest_node.py │ │ ├── Nodes-closet_node.py │ │ ├── Nodes-closet_node.py~ │ │ ├── Nodes-replace_node.py │ │ ├── Nodes-replace_node.py~ │ │ ├── Mesh-add_surface.py │ │ ├── Mesh-add_surface.py~ │ │ ├── Mesh-node_set_to_surface.py │ │ ├── Mesh-simplify_nodes.py │ │ ├── Mesh-simplify_nodes.py~ │ │ ├── IndentationMesh.py │ │ ├── IndentationMesh.py~ │ │ ├── Mesh-drop_element.py~ │ │ ├── Mesh_apply_reflection.py │ │ ├── Nodes_apply_reflection.py │ │ ├── Nodes_apply_reflection.py~ │ │ ├── Mesh-drop_element.py │ │ ├── Mesh_union.py │ │ ├── Mesh_union.py~ │ │ ├── Mesh-add_set.py~ │ │ ├── Mesh-add_element.py │ │ ├── Mesh-add_element.py~ │ │ ├── Mesh-extrude.py │ │ ├── Mesh-drop_node.py │ │ ├── Mesh-drop_node.py~ │ │ ├── Mesh-extrude.py~ │ │ ├── Mesh-dump2inp.py │ │ ├── Mesh-dump2inp.py~ │ │ ├── RegularQuadMesh.py │ │ ├── RegularQuadMesh.py~ │ │ ├── Mesh-add_set.py │ │ ├── Nodes-eval_function.py │ │ ├── Nodes-eval_function.py~ │ │ ├── Mesh-sweep.py │ │ ├── Mesh-sweep.py~ │ │ ├── Mesh-dump2polygons.py │ │ ├── Nodes-apply_displacement.py │ │ ├── Nodes-apply_displacement.py~ │ │ ├── Mesh-centroids.py │ │ ├── Mesh-dump2polygons_3D.py │ │ ├── Mesh-volume.py │ │ ├── Mesh-dump2vtk.py │ │ ├── Mesh-convert2tri3.py~ │ │ ├── Mesh-convert2tri3.py │ │ ├── Mesh-draw.py │ │ ├── Mesh-draw_3D.py │ │ ├── TransitionMesh.py │ │ ├── Mesh-sweep.vtk │ │ ├── Nodes-eval_vectorFunction.py │ │ ├── Nodes-eval_vectorFunction.py~ │ │ ├── Nodes-eval_tensorFunction.py │ │ └── Nodes-eval_tensorFunction.py~ │ ├── tutorial │ │ ├── workdir │ │ │ ├── indentation_axi.pckl │ │ │ └── indentation_axi_fancier.pckl │ │ ├── first_example_abq.py │ │ ├── fancier_example_abq.py │ │ ├── first_example.py │ │ └── fancier_example.py │ ├── future │ │ ├── clean_connectivity2.msh │ │ ├── volume.msh │ │ ├── volume_2D.msh │ │ ├── volume_3D.msh │ │ ├── clean_connectivity.inp │ │ ├── clean_connectivity.msh │ │ ├── mesh-volume.py │ │ ├── mesh-centroid.py │ │ └── clean_connectivity.py │ ├── materials │ │ ├── Hollomon.py │ │ └── Hollomon.py~ │ └── logo │ │ ├── abapy_logo.py │ │ ├── abapy_logo.py~ │ │ └── abapy_logo2.py ├── misc.rst ├── advanced_examples │ └── indentation │ │ └── simulations │ │ ├── workdir │ │ └── empty │ │ ├── launcher │ │ ├── plots │ │ ├── basic_plot_DP.png │ │ └── basic_plot_mesh_DP.png │ │ ├── launcher.py │ │ ├── delete_instance.py │ │ ├── settings.py │ │ ├── tests.py │ │ ├── basic_plot_DP.py │ │ ├── basic_plot_Hol.py │ │ ├── sketch.py │ │ └── loader.py ├── materials.rst ├── index.rst ├── compile_doc.py ├── advanced_examples.rst ├── mesh.rst ├── indentation.rst ├── sphinxext │ ├── numpydoc.py │ ├── ipython_console_highlighting.py │ └── docscrape_sphinx.py ├── Makefile ├── postproc.rst └── make.bat ├── .gitignore ├── requirements.txt ├── AUTHORS ├── setup.py └── abapy ├── misc.py └── __init__.py /doc/example_code/postproc/HistoryOutput.py~: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /doc/misc.rst: -------------------------------------------------------------------------------- 1 | .. automodule:: abapy.misc 2 | :members: -------------------------------------------------------------------------------- /doc/advanced_examples/indentation/simulations/workdir/empty: -------------------------------------------------------------------------------- 1 | emmpty 2 | -------------------------------------------------------------------------------- /doc/advanced_examples/indentation/simulations/launcher: -------------------------------------------------------------------------------- 1 | python launcher.py 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | makedoc/ 2 | *~ 3 | *.pyc 4 | doc/_build/* 5 | *.pdf 6 | *.rpy 7 | *.odb 8 | -------------------------------------------------------------------------------- /doc/example_code/indentation/indentation-Step.py: -------------------------------------------------------------------------------- 1 | from abapy.indentation import Step 2 | step = Step('mystep') 3 | -------------------------------------------------------------------------------- /doc/example_code/indentation/image.gsf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lcharleux/abapy/HEAD/doc/example_code/indentation/image.gsf -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-dump2vtk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lcharleux/abapy/HEAD/doc/example_code/mesh/Mesh-dump2vtk.png -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh.sweep.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | 3 | m = RegularQuadMesh() 4 | m2 = m.sweep() 5 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Nodes-sweep.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | 3 | m = RegularQuadMesh() 4 | m2 = m.sweep() 5 | -------------------------------------------------------------------------------- /doc/example_code/indentation/ContactData.pckl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lcharleux/abapy/HEAD/doc/example_code/indentation/ContactData.pckl -------------------------------------------------------------------------------- /doc/example_code/indentation/ContactData_axi.pckl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lcharleux/abapy/HEAD/doc/example_code/indentation/ContactData_axi.pckl -------------------------------------------------------------------------------- /doc/example_code/indentation/ContactData_berk.pckl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lcharleux/abapy/HEAD/doc/example_code/indentation/ContactData_berk.pckl -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | matplotlib>=1.1.1rc 2 | numpy>=1.6.1 3 | scipy>=0.9.0 4 | ipython>=0.12.1 5 | git+https://github.com/lcharleux/spym.git 6 | 7 | 8 | -------------------------------------------------------------------------------- /doc/example_code/indentation/workdir/indentation.pckl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lcharleux/abapy/HEAD/doc/example_code/indentation/workdir/indentation.pckl -------------------------------------------------------------------------------- /doc/example_code/postproc/HistoryOutput-plotable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lcharleux/abapy/HEAD/doc/example_code/postproc/HistoryOutput-plotable.png -------------------------------------------------------------------------------- /doc/example_code/tutorial/workdir/indentation_axi.pckl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lcharleux/abapy/HEAD/doc/example_code/tutorial/workdir/indentation_axi.pckl -------------------------------------------------------------------------------- /doc/example_code/indentation/workdir/indentation_axi.pckl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lcharleux/abapy/HEAD/doc/example_code/indentation/workdir/indentation_axi.pckl -------------------------------------------------------------------------------- /doc/example_code/indentation/workdir/indentation_field.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lcharleux/abapy/HEAD/doc/example_code/indentation/workdir/indentation_field.png -------------------------------------------------------------------------------- /doc/example_code/indentation/workdir/indentation_load-disp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lcharleux/abapy/HEAD/doc/example_code/indentation/workdir/indentation_load-disp.png -------------------------------------------------------------------------------- /doc/example_code/tutorial/workdir/indentation_axi_fancier.pckl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lcharleux/abapy/HEAD/doc/example_code/tutorial/workdir/indentation_axi_fancier.pckl -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-replace_node.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | N1, N2 = 1,1 3 | mesh = RegularQuadMesh(N1, N2) 4 | mesh.replace_node(1,2) 5 | print mesh 6 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-replace_node.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | N1, N2 = 1,1 3 | mesh = RegularQuadMesh(N1, N2) 4 | mesh.replace_node(1,2) 5 | print mesh 6 | -------------------------------------------------------------------------------- /doc/example_code/postproc/GetMesh.py: -------------------------------------------------------------------------------- 1 | from abapy.postproc import GetMesh 2 | from odbAccess import openOdb 3 | odb = openOdb('myOdb.odb') 4 | mesh = GetMesh(odb,'MYINSTANCE') 5 | -------------------------------------------------------------------------------- /doc/advanced_examples/indentation/simulations/plots/basic_plot_DP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lcharleux/abapy/HEAD/doc/advanced_examples/indentation/simulations/plots/basic_plot_DP.png -------------------------------------------------------------------------------- /doc/advanced_examples/indentation/simulations/launcher.py: -------------------------------------------------------------------------------- 1 | # Setting up the database 2 | execfile('settings.py') 3 | 4 | # Running all simulations 5 | db_manager.run_all() 6 | #db_manager.run_next() 7 | -------------------------------------------------------------------------------- /doc/advanced_examples/indentation/simulations/plots/basic_plot_mesh_DP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lcharleux/abapy/HEAD/doc/advanced_examples/indentation/simulations/plots/basic_plot_mesh_DP.png -------------------------------------------------------------------------------- /doc/example_code/mesh/Nodes-closest_node.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | N = 1 3 | l1, l2 = 1., 2. 4 | mesh = RegularQuadMesh(N1 = N, N2 = N, l1 = l1, l2 = l2) 5 | mesh.nodes.closest_node(1) 6 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Nodes-closet_node.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | N = 1 3 | l1, l2 = 1., 2. 4 | mesh = RegularQuadMesh(N1 = N, N2 = N, l1 = l1, l2 = l2) 5 | mesh.nodes.closest_node(1) 6 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Nodes-closet_node.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | N = 1 3 | l1, l2 = 1., 2. 4 | mesh = RegularQuadMesh(N1 = N, N2 = N, l1 = l1, l2 = l2) 5 | mesh.nodes.closest_node(1) 6 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Nodes-replace_node.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | N1, N2 = 1,1 3 | mesh = RegularQuadMesh(N1, N2) 4 | nodes = mesh.nodes 5 | nodes.replace_node(1,2) 6 | print nodes 7 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Nodes-replace_node.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | N1, N2 = 1,1 3 | mesh = RegularQuadMesh(N1, N2) 4 | nodes = mesh.nodes 5 | nodes.replace_node(1,2) 6 | print nodes 7 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Ludovic Charleux ludovic.charleux@univ-smb.fr 2 | Vincent Keryvin vincent.keryvin@univ-ubs.fr 3 | Laurent Bizet laurent.bizet@univ-smb.fr 4 | Moustapha Issack issackm@univ-savoie.fr 5 | Arnaud Faivre 6 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-add_surface.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | mesh = RegularQuadMesh() 3 | mesh.add_surface('topsurface', [ ('top', 1) ]) 4 | mesh.add_surface('topsurface', [ ('top', 2) ]) 5 | mesh.surfaces 6 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-add_surface.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | mesh = RegularQuadMesh() 3 | mesh.add_surface('topsurface', [ ('top', 1) ]) 4 | mesh.add_surface('topsurface', [ ('top', 2) ]) 5 | mesh.surfaces 6 | -------------------------------------------------------------------------------- /doc/example_code/postproc/FieldOutput-get_data.py: -------------------------------------------------------------------------------- 1 | from abapy.postproc import FieldOutput 2 | data = [1,2,3,5,6,0] 3 | labels = range(1,len(data)+1) 4 | fo = FieldOutput(data=data, labels = labels) 5 | print fo.get_data(6) 6 | print fo.get_data(10) 7 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-node_set_to_surface.py: -------------------------------------------------------------------------------- 1 | from abapy import mesh 2 | 3 | m = mesh.RegularQuadMesh(N1 = 4, N2 = 4, l1 = 2., l2 = 6.) 4 | m.nodes.sets = {} 5 | m.nodes.add_set_by_func("top_nodes", lambda x,y,z,labels : y == 6.) 6 | m.node_set_to_surface("top_surface", "top_nodes") 7 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-simplify_nodes.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | N1,N2 = 2,2 3 | l1, l2 = 1., 1. 4 | mesh1 = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) 5 | mesh2 = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) 6 | 7 | mesh2.translate(x = l1, y = l2) 8 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-simplify_nodes.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | N1,N2 = 2,2 3 | l1, l2 = 1., 1. 4 | mesh1 = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) 5 | mesh2 = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) 6 | 7 | mesh2.translate(x = l1, y = l2) 8 | -------------------------------------------------------------------------------- /doc/example_code/postproc/GetTensorFieldOutput.py~: -------------------------------------------------------------------------------- 1 | from abapy.postproc import GetFieldOutput, GetVectorFieldOutput, GetTensorFieldOutput 2 | from odbAccess import openOdb 3 | odb = openOdb('indentation.odb') 4 | S = GetTensorFieldOutput(odb, step = 'LOADING', frame = -1, instance ='I_SAMPLE', position = 'node', field = 'S') 5 | -------------------------------------------------------------------------------- /doc/example_code/postproc/GetVectorFieldOutput.py: -------------------------------------------------------------------------------- 1 | from abapy.postproc import GetFieldOutput, GetVectorFieldOutput, GetTensorFieldOutput 2 | from odbAccess import openOdb 3 | odb = openOdb('indentation.odb') 4 | U = GetVectorFieldOutput(odb, step = 'LOADING', frame = -1, instance ='I_SAMPLE', position = 'node', field = 'U') 5 | -------------------------------------------------------------------------------- /doc/example_code/postproc/GetVectorFieldOutput.py~: -------------------------------------------------------------------------------- 1 | from abapy.postproc import GetFieldOutput, GetVectorFieldOutput, GetTensorFieldOutput 2 | from odbAccess import openOdb 3 | odb = openOdb('indentation.odb') 4 | U = GetVectorFieldOutput(odb, step = 'LOADING', frame = -1, instance ='I_SAMPLE', position = 'node', field = 'U') 5 | -------------------------------------------------------------------------------- /doc/example_code/postproc/HystoryOutput_test.py~: -------------------------------------------------------------------------------- 1 | from abapy.postproc import HistoryOutput_test 2 | time = [ [1., 2.,3.] , [3.,4.,5.] , [5.,6.,7.] ] 3 | data = [ [2.,2.,2.] , [3.,3.,3.] , [4.,4.,4.] ] 4 | N = 10000 5 | time = [ range(N), range(N), range(N) ] 6 | data = [ range(N), range(N), range(N) ] 7 | Force = HistoryOutput_test(time, data) 8 | Force + Force 9 | -------------------------------------------------------------------------------- /doc/example_code/indentation/DeformableCone2D.py: -------------------------------------------------------------------------------- 1 | from abapy.indentation import DeformableCone2D 2 | from matplotlib import pyplot as plt 3 | c = DeformableCone2D(Na =8, Nb = 8, Ns = 1) 4 | f = open('DeformableCone2D.inp', 'w') 5 | f.write(c.dump2inp()) 6 | f.close() 7 | x,y,z = c.mesh.get_edges() 8 | plt.plot(x,y) 9 | plt.gca().set_aspect('equal') 10 | plt.show() 11 | 12 | -------------------------------------------------------------------------------- /doc/example_code/postproc/vector.vtk: -------------------------------------------------------------------------------- 1 | # vtk DataFile Version 2.0 2 | Unstructured Grid Example 3 | ASCII 4 | DATASET UNSTRUCTURED_GRID 5 | POINTS 4 float 6 | 0.0 0.0 0.0 7 | 1.0 0.0 0.0 8 | 0.0 1.0 0.0 9 | 1.0 1.0 0.0 10 | CELLS 1 5 11 | 4 0 1 3 2 12 | CELL_TYPES 1 13 | 9 14 | POINT_DATA 4 15 | VECTORS vectorFieldOutput float 16 | 2.0 1.0 0.0 17 | 2.0 1.0 0.0 18 | 5.0 1.0 0.0 19 | 10.0 1.0 0.0 20 | -------------------------------------------------------------------------------- /doc/example_code/postproc/vector.vtk~: -------------------------------------------------------------------------------- 1 | # vtk DataFile Version 2.0 2 | Unstructured Grid Example 3 | ASCII 4 | DATASET UNSTRUCTURED_GRID 5 | POINTS 4 float 6 | 0.0 0.0 0.0 7 | 1.0 0.0 0.0 8 | 0.0 1.0 0.0 9 | 1.0 1.0 0.0 10 | CELLS 1 5 11 | 4 0 1 3 2 12 | CELL_TYPES 1 13 | 9 14 | POINT_DATA 4 15 | VECTORS vectorFieldOutput float 16 | LOOKUP_TABLE default 17 | 2.0 1.0 0.0 18 | 2.0 1.0 0.0 19 | 5.0 1.0 0.0 20 | 10.0 1.0 0.0 21 | -------------------------------------------------------------------------------- /doc/example_code/postproc/Identity_like.py: -------------------------------------------------------------------------------- 1 | from abapy.postproc import FieldOutput, TensorFieldOutput, Identity_like 2 | data1 = [1,2,3,5,6,] 3 | data2 = [1. for i in data1] 4 | labels = range(1,len(data1)+1) 5 | fo1, fo2 = FieldOutput(labels = labels, data=data1, position='node' ), FieldOutput(labels = labels, data=data2,position='node') 6 | tensor = TensorFieldOutput(data11 = fo1, data22 = fo2 ) 7 | identity = Identity_like(tensor) 8 | -------------------------------------------------------------------------------- /doc/example_code/future/clean_connectivity2.msh: -------------------------------------------------------------------------------- 1 | $MeshFormat 2 | 2.2 0 8 3 | $EndMeshFormat 4 | $Nodes 5 | 8 6 | 1 1.0 0.0 0.0 7 | 2 2.0 0.0 0.0 8 | 3 2.0 1.0 0.0 9 | 4 1.0 1.0 0.0 10 | 5 1.0 0.0 1.0 11 | 6 2.0 0.0 1.0 12 | 7 2.0 1.0 1.0 13 | 8 1.0 1.0 1.0 14 | $EndNodes 15 | $Elements 16 | 6 17 | 1 4 1 1 1 2 4 5 18 | 2 4 1 1 2 3 4 5 19 | 3 4 1 1 3 4 8 5 20 | 4 4 1 1 3 7 8 5 21 | 5 4 1 1 2 6 3 5 22 | 6 4 1 1 3 6 7 5 23 | $EndElements 24 | -------------------------------------------------------------------------------- /doc/example_code/postproc/GetTensorFieldOutput.py: -------------------------------------------------------------------------------- 1 | from abapy.postproc import GetFieldOutput, GetVectorFieldOutput, GetTensorFieldOutput 2 | from odbAccess import openOdb 3 | odb = openOdb('indentation.odb') 4 | S = GetTensorFieldOutput(odb, step = 'LOADING', frame = -1, instance ='I_SAMPLE', position = 'node', field = 'S') 5 | S = GetTensorFieldOutput(odb, step = 'LOADING', frame = -1, instance ='I_SAMPLE', position = 'element', field = 'S') 6 | 7 | -------------------------------------------------------------------------------- /doc/example_code/postproc/Identity_like.py~: -------------------------------------------------------------------------------- 1 | from abapy.postproc import FieldOutput, TensorFieldOutput, VectorFieldOutput, Identity_like 2 | data1 = [1,2,3,5,6,] 3 | data2 = [1. for i in data1] 4 | labels = range(1,len(data1)+1) 5 | fo1, fo2 = FieldOutput(labels = labels, data=data1, position='node' ), FieldOutput(labels = labels, data=data2,position='node') 6 | tensor = TensorFieldOutput(data11 = fo1, data22 = fo2 ) 7 | identity = Identity_like(tensor) 8 | -------------------------------------------------------------------------------- /doc/example_code/future/volume.msh: -------------------------------------------------------------------------------- 1 | $MeshFormat 2 | 2.2 0 8 3 | $EndMeshFormat 4 | $Nodes 5 | 10 6 | 1 0.0 1.0 0.0 7 | 2 0.0 2.0 0.0 8 | 3 0.0 3.0 0.0 9 | 4 1.0 4.0 0.0 10 | 5 1.0 3.0 0.0 11 | 6 1.0 2.0 0.0 12 | 7 2.0 1.0 0.0 13 | 8 1.0 0.0 0.0 14 | 9 2.0 3.0 0.0 15 | 10 2.0 2.0 0.0 16 | $EndNodes 17 | $Elements 18 | 6 19 | 1 3 1 1 1 8 7 6 20 | 2 3 1 1 2 6 5 3 21 | 3 2 1 1 1 6 2 22 | 4 2 1 1 3 5 4 23 | 5 2 1 1 6 7 10 24 | 6 3 1 1 5 6 10 9 25 | $EndElements -------------------------------------------------------------------------------- /doc/example_code/future/volume_2D.msh: -------------------------------------------------------------------------------- 1 | $MeshFormat 2 | 2.2 0 8 3 | $EndMeshFormat 4 | $Nodes 5 | 10 6 | 1 0.0 1.0 0.0 7 | 2 0.0 2.0 0.0 8 | 3 0.0 3.0 0.0 9 | 4 1.0 4.0 0.0 10 | 5 1.0 3.0 0.0 11 | 6 1.0 2.0 0.0 12 | 7 2.0 1.0 0.0 13 | 8 1.0 0.0 0.0 14 | 9 2.0 3.0 0.0 15 | 10 2.0 2.0 0.0 16 | $EndNodes 17 | $Elements 18 | 6 19 | 1 3 1 1 1 8 7 6 20 | 2 3 1 1 2 6 5 3 21 | 3 2 1 1 1 6 2 22 | 4 2 1 1 3 5 4 23 | 5 2 1 1 6 7 10 24 | 6 3 1 1 5 6 10 9 25 | $EndElements -------------------------------------------------------------------------------- /doc/example_code/postproc/FieldOutput-dump2vtk.vtk: -------------------------------------------------------------------------------- 1 | # vtk DataFile Version 2.0 2 | Unstructured Grid Example 3 | ASCII 4 | DATASET UNSTRUCTURED_GRID 5 | POINTS 3 float 6 | 0.0 0.0 0.0 7 | 1.0 0.0 0.0 8 | 0.0 1.0 0.0 9 | CELLS 1 4 10 | 3 0 1 2 11 | CELL_TYPES 1 12 | 5 13 | POINT_DATA 3 14 | SCALARS nodeField float 1 15 | LOOKUP_TABLE default 16 | 0.0 17 | 10.0 18 | 20.0 19 | CELL_DATA 1 20 | SCALARS elementField float 1 21 | LOOKUP_TABLE default 22 | 10.0 23 | -------------------------------------------------------------------------------- /doc/example_code/postproc/FieldOutput.py: -------------------------------------------------------------------------------- 1 | from abapy.postproc import FieldOutput 2 | data = [-1.,5.,3.] 3 | labels = [1,3,2] 4 | fo = FieldOutput(data=data, labels = labels, position = 'node') 5 | print fo # data is sorted by labels 6 | print fo[1:2] # slicing 7 | print fo[2] # indexing 8 | print fo[1,3] # multiple indexing 9 | print fo*2 # multiplication 10 | fo2 = fo**2 #power 11 | print fo2 12 | print fo * fo2 13 | print fo + fo2 14 | print abs(fo) 15 | 16 | -------------------------------------------------------------------------------- /doc/example_code/mesh/IndentationMesh.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import IndentationMesh 2 | from matplotlib import pyplot as plt 3 | Na = 2 4 | Nb = 3 5 | 6 | l, ltot = 1., 2 7 | mesh = IndentationMesh(Na,Nb,l) 8 | ''' 9 | xe, ye, ze = mesh.get_edges() 10 | plt.figure() 11 | plt.gca().set_aspect('equal') 12 | plt.plot(xe, ye, 'r-') 13 | plt.plot(mesh.nodes.x, mesh.nodes.y, 'ob') 14 | bbox = mesh.nodes.boundingBox() 15 | plt.xlim(bbox[0]) 16 | plt.ylim(bbox[1]) 17 | plt.show() 18 | ''' 19 | -------------------------------------------------------------------------------- /doc/example_code/mesh/IndentationMesh.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import IndentationMesh 2 | from matplotlib import pyplot as plt 3 | Na = 2 4 | Nb = 3 5 | 6 | l, ltot = 1., 2 7 | mesh = IndentationMesh(Na,Nb,l) 8 | ''' 9 | xe, ye, ze = mesh.get_edges() 10 | plt.figure() 11 | plt.gca().set_aspect('equal') 12 | plt.plot(xe, ye, 'r-') 13 | plt.plot(mesh.nodes.x, mesh.nodes.y, 'ob') 14 | bbox = mesh.nodes.boundingBox() 15 | plt.xlim(bbox[0]) 16 | plt.ylim(bbox[1]) 17 | plt.show() 18 | ''' 19 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-drop_element.py~: -------------------------------------------------------------------------------- 1 | from abapy.indentation import ParamInfiniteMesh 2 | from copy import copy 3 | 4 | # Let's create a mesh containing a surface: 5 | m = ParamInfiniteMesh(Na = 2, Nb = 2) 6 | print m.surfaces 7 | elem_to_remove = copy(m.sets['top_elem']) 8 | # Let's remove all elements in the surface: 9 | for e in elem_to_remove: 10 | m.drop_element(e) 11 | # We can see that sets and surfaces are removed when they become empty 12 | print m.surfaces 13 | 14 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh_apply_reflection.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | from abapy.indentation import ParamInfiniteMesh 3 | import matplotlib.pyplot as plt 4 | 5 | point = (0., 0., 0.) 6 | normal = (1., 0., 0.) 7 | m0 = ParamInfiniteMesh() 8 | x0, y0, z0 = m0.get_edges() 9 | m1 = m0.apply_reflection(normal = normal, point = point) 10 | x1, y1, z1 = m1.get_edges() 11 | plt.plot(x0, y0) 12 | plt.plot(x1, y1) 13 | plt.gca().set_aspect('equal') 14 | plt.show() 15 | 16 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Nodes_apply_reflection.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | from abapy.indentation import ParamInfiniteMesh 3 | import matplotlib.pyplot as plt 4 | 5 | point = (0., 0., 0.) 6 | normal = (1., 0., 0.) 7 | m0 = ParamInfiniteMesh() 8 | x0, y0, z0 = m0.get_edges() 9 | m1 = m0.apply_reflection(normal = normal, point = point) 10 | x1, y1, z1 = m1.get_edges() 11 | plt.plot(x0, y0) 12 | plt.plot(x1, y1) 13 | plt.gca().set_aspect('equal') 14 | plt.show() 15 | 16 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Nodes_apply_reflection.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | from abapy.indentation import ParamInfiniteMesh 3 | import matplotlib.pyplot as plt 4 | 5 | point = (0., 0., 0.) 6 | normal = (1., 0., 0.) 7 | m0 = ParamInfiniteMesh() 8 | x0, y0, z0 = m0.get_edges() 9 | m1 = m0.apply_reflection(normal = normal, point = point) 10 | x1, y1, z1 = m1.get_edges() 11 | plt.plot(x0, y0) 12 | plt.plot(x1, y1) 13 | plt.gca().set_aspect('equal') 14 | plt.show() 15 | 16 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-drop_element.py: -------------------------------------------------------------------------------- 1 | from abapy.indentation import ParamInfiniteMesh 2 | from copy import copy 3 | 4 | # Let's create a mesh containing a surface: 5 | m = ParamInfiniteMesh(Na = 2, Nb = 2) 6 | print m.surfaces 7 | elem_to_remove = copy(m.sets['top_elem']) 8 | # Let's remove all elements in the surface: 9 | for e in elem_to_remove: 10 | m.drop_element(e) 11 | # We can see that sets and surfaces are removed when they become empty 12 | 13 | print m.surfaces 14 | 15 | -------------------------------------------------------------------------------- /doc/example_code/postproc/VectorFieldOutput-get_data.py: -------------------------------------------------------------------------------- 1 | from abapy.postproc import FieldOutput, VectorFieldOutput 2 | data1 = [1,2,3,5,6,0] 3 | data2 = [1. for i in data1] 4 | labels = range(1,len(data1)+1) 5 | fo1, fo2 = FieldOutput(data=data1, labels = labels), FieldOutput(data=data2, labels = labels) 6 | vector = VectorFieldOutput(data1 = fo1, data2 = fo2 ) 7 | print vector.get_data(6) 8 | x, y, z = vector.get_data(5) 9 | print x, y, z 10 | print vector.get_data(10) 11 | norm = vector.get_norm() 12 | 13 | -------------------------------------------------------------------------------- /doc/example_code/postproc/VectorFieldOutput-get_data.py~: -------------------------------------------------------------------------------- 1 | from abapy.postproc import FieldOutput, VectorFieldOutput 2 | data1 = [1,2,3,5,6,0] 3 | data2 = [1. for i in data1] 4 | labels = range(1,len(data1)+1) 5 | fo1, fo2 = FieldOutput(data=data1, labels = labels), FieldOutput(data=data2, labels = labels) 6 | vector = VectorFieldOutput(data1 = fo1, data2 = fo2 ) 7 | print vector.get_data(6) 8 | x, y, z = vector.get_data(5) 9 | print x, y, z 10 | print vector.get_data(10) 11 | norm = vector.get_norm() 12 | 13 | -------------------------------------------------------------------------------- /doc/example_code/postproc/HystoryOutput.py~: -------------------------------------------------------------------------------- 1 | from abapy.postproc import HistoryOutput 2 | time = [ [1., 2.,3.] , [3.,4.,5.] , [5.,6.,7.] ] # Time separated in 3 steps 3 | data = [ [2.,2.,2.] , [3.,3.,3.] , [4.,4.,4.] ] # Data separated in 3 steps 4 | Data = HistoryOutput(time, data) 5 | print Data 6 | # +, *, **, abs, neg act only on data, not on time 7 | print Data + Data + 1. # addition 8 | print Data * Data * 2. # multiplication 9 | print ( Data / Data ) / 2. # division 10 | print Data ** 2 11 | print abs(Data) 12 | 13 | -------------------------------------------------------------------------------- /doc/materials.rst: -------------------------------------------------------------------------------- 1 | Materials 2 | =============== 3 | 4 | Material definitions. 5 | 6 | Elastic materials 7 | ~~~~~~~~~~~~~~~~~ 8 | 9 | .. autoclass:: abapy.materials.Elastic 10 | :members: 11 | 12 | 13 | Elastic-plastic materials 14 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 15 | 16 | .. autoclass:: abapy.materials.VonMises 17 | :members: 18 | .. autoclass:: abapy.materials.Hollomon 19 | :members: 20 | .. autoclass:: abapy.materials.DruckerPrager 21 | :members: 22 | .. autoclass:: abapy.materials.Bilinear 23 | :members: 24 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | setup(name='abapy', 4 | version='0.1', 5 | description="Finite element pre/post processing using Python", 6 | long_description="", 7 | author='Ludovic Charleux, Vincent Keryvin', 8 | author_email='ludovic.charleux@univ-savoie.fr', 9 | license='GPL v2', 10 | packages=['abapy'], 11 | zip_safe=False, 12 | install_requires=[ 13 | "numpy", 14 | "scipy", 15 | "matplotlib" 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh_union.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | from matplotlib import pyplot as plt 3 | N1,N2 = 20,20 4 | l1, l2 = 1., 1. 5 | mesh1 = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2, name = 'mesh1_el') 6 | mesh2 = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2, name = 'mesh2_el') 7 | mesh2.add_set('set2',[1,3]) 8 | 9 | mesh2.nodes.translate(x = l1, y = l2) 10 | 11 | mesh1.union(mesh2) 12 | 13 | 14 | 15 | plt.figure() 16 | xe, ye, ze = mesh1.get_edges() 17 | plt.plot(xe, ye) 18 | plt.show() 19 | -------------------------------------------------------------------------------- /doc/example_code/postproc/GetTensorFieldOutput_byRpt.py~: -------------------------------------------------------------------------------- 1 | from odbAccess import openOdb 2 | from abapy.postproc import GetVectorFieldOutput_byRpt 3 | odb_name = 'indentation.odb' 4 | odb = openOdb(odb_name) 5 | U = GetVectorFieldOutput_byRpt( 6 | odb = odb, 7 | instance = 'I_SAMPLE', 8 | step = 0, 9 | frame = -1, 10 | original_position = 'NODAL', 11 | new_position = 'NODAL', 12 | position = 'node', 13 | field = 'U', 14 | sub_set_type = 'element', 15 | sub_set = 'CORE', 16 | delete_report = True) 17 | 18 | 19 | -------------------------------------------------------------------------------- /doc/example_code/postproc/GetVectorFieldOutput_byRpt.py: -------------------------------------------------------------------------------- 1 | from odbAccess import openOdb 2 | from abapy.postproc import GetVectorFieldOutput_byRpt 3 | odb_name = 'indentation.odb' 4 | odb = openOdb(odb_name) 5 | U = GetVectorFieldOutput_byRpt( 6 | odb = odb, 7 | instance = 'I_SAMPLE', 8 | step = 0, 9 | frame = -1, 10 | original_position = 'NODAL', 11 | new_position = 'NODAL', 12 | position = 'node', 13 | field = 'U', 14 | sub_set_type = 'element', 15 | sub_set = 'CORE', 16 | delete_report = True) 17 | 18 | 19 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh_union.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | from matplotlib import pyplot as plt 3 | N1,N2 = 20,20 4 | l1, l2 = 1., 1. 5 | mesh1 = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2, name = 'mesh1_el') 6 | mesh2 = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2, name = 'mesh2_el') 7 | mesh2.add_set('set2',[1,3]) 8 | 9 | mesh2.nodes.translate(x = l1, y = l2) 10 | 11 | mesh1.union(mesh2) 12 | 13 | 14 | 15 | plt.figure() 16 | xe, ye, ze = mesh1.get_edges() 17 | plt.plot(xe, ye) 18 | plt.show() 19 | -------------------------------------------------------------------------------- /doc/example_code/postproc/GetVectorFieldOutput_byRpt.py~: -------------------------------------------------------------------------------- 1 | from odbAccess import openOdb 2 | from abapy.postproc import GetVectorFieldOutput_byRpt 3 | odb_name = 'indentation.odb' 4 | odb = openOdb(odb_name) 5 | U = GetVectorFieldOutput_byRpt( 6 | odb = odb, 7 | instance = 'I_SAMPLE', 8 | step = 0, 9 | frame = -1, 10 | original_position = 'NODAL', 11 | new_position = 'NODAL', 12 | position = 'node', 13 | field = 'U', 14 | sub_set_type = 'element', 15 | sub_set = 'CORE', 16 | delete_report = False) 17 | 18 | 19 | -------------------------------------------------------------------------------- /doc/example_code/postproc/GetFieldOutput_byRpt.py: -------------------------------------------------------------------------------- 1 | from odbAccess import openOdb 2 | from abapy.postproc import GetFieldOutput_byRpt 3 | odb_name = 'indentation.odb' 4 | odb = openOdb(odb_name) 5 | S11 = GetFieldOutput_byRpt( 6 | odb = odb, 7 | instance = 'I_SAMPLE', 8 | step = 0, 9 | frame = -1, 10 | original_position = 'INTEGRATION_POINT', 11 | new_position = 'NODAL', 12 | position = 'node', 13 | field = 'S', 14 | sub_field = 11, 15 | sub_set_type = 'element', 16 | sub_set = 'CORE', 17 | delete_report = False) 18 | 19 | -------------------------------------------------------------------------------- /doc/example_code/postproc/GetFieldOutput_byRpt.py~: -------------------------------------------------------------------------------- 1 | from odbAccess import openOdb 2 | from abapy.postproc import GetFieldOutput_byRpt 3 | odb_name = 'indentation.odb' 4 | odb = openOdb(odb_name) 5 | S11 = GetFieldOutput_byRpt( 6 | odb = odb, 7 | instance = 'I_SAMPLE', 8 | step = 0, 9 | frame = -1, 10 | original_position = 'INTEGRATION_POINT', 11 | new_position = 'NODAL', 12 | position = 'node', 13 | field = 'S', 14 | sub_field = 11, 15 | sub_set_type = 'element', 16 | sub_set = 'CORE' 17 | delete_report = False) 18 | 19 | -------------------------------------------------------------------------------- /doc/example_code/postproc/GetTensorFieldOutput_byRpt.py: -------------------------------------------------------------------------------- 1 | from odbAccess import openOdb 2 | from abapy.postproc import GetTensorFieldOutput_byRpt 3 | odb_name = 'indentation.odb' 4 | odb = openOdb(odb_name) 5 | S = GetTensorFieldOutput_byRpt( 6 | odb = odb, 7 | instance = 'I_SAMPLE', 8 | step = 0, 9 | frame = -1, 10 | original_position = 'INTEGRATION_POINT', 11 | new_position = 'NODAL', 12 | position = 'node', 13 | field = 'S', 14 | sub_set_type = 'element', 15 | sub_set = 'CORE', 16 | delete_report = True) 17 | 18 | 19 | -------------------------------------------------------------------------------- /doc/example_code/indentation/DeformableCone3D.py: -------------------------------------------------------------------------------- 1 | from abapy.indentation import DeformableCone3D 2 | from matplotlib import pyplot as plt 3 | c = DeformableCone3D(Na =4, Nb = 4, Ns = 1, N = 10, sweep_angle = 120.) 4 | c.make_mesh() 5 | f = open('DeformableCone3D.vtk', 'w') 6 | f.write(c.mesh.dump2vtk()) 7 | f.close() 8 | x,y,z = c.mesh.get_edges() 9 | # Adding some 3D "home made" perspective: 10 | zx, zy = .3, .3 11 | for i in xrange(len(x)): 12 | if x[i] != None: 13 | x[i] += zx * z[i] 14 | y[i] += zy * z[i] 15 | plt.plot(x,y) 16 | plt.show() 17 | -------------------------------------------------------------------------------- /doc/example_code/postproc/VectorFieldOutput-dump2vtk.py: -------------------------------------------------------------------------------- 1 | from abapy.postproc import FieldOutput, VectorFieldOutput 2 | from abapy.mesh import RegularQuadMesh 3 | mesh = RegularQuadMesh() 4 | data1 = [2,2,5,10] 5 | data2 = [1. for i in data1] 6 | labels = range(1,len(data1)+1) 7 | fo1, fo2 = FieldOutput(labels = labels, data=data1, position='node' ), FieldOutput(labels = labels, data=data2,position='node') 8 | vector = VectorFieldOutput(data1 = fo1, data2 = fo2 ) 9 | out = mesh.dump2vtk() + vector.dump2vtk() 10 | f = open('vector.vtk','w') 11 | f.write("out") 12 | f.close() 13 | 14 | -------------------------------------------------------------------------------- /doc/example_code/postproc/VectorFieldOutput-dump2vtk.py~: -------------------------------------------------------------------------------- 1 | from abapy.postproc import FieldOutput, VectorFieldOutput 2 | from abapy.mesh import RegularQuadMesh 3 | mesh = RegularQuadMesh() 4 | data1 = [2,2,5,10] 5 | data2 = [1. for i in data1] 6 | labels = range(1,len(data1)+1) 7 | fo1, fo2 = FieldOutput(labels = labels, data=data1, position='node' ), FieldOutput(labels = labels, data=data2,position='node') 8 | vector = VectorFieldOutput(data1 = fo1, data2 = fo2 ) 9 | out = mesh.dump2vtk() + vector.dump2vtk() 10 | f = open('vector.vtk','w') 11 | f.write(out) 12 | f.close() 13 | 14 | -------------------------------------------------------------------------------- /doc/example_code/postproc/TensoFieldOutput-eigen.py: -------------------------------------------------------------------------------- 1 | from abapy.postproc import FieldOutput, TensorFieldOutput, VectorFieldOutput, Identity_like 2 | data11 = [0., 0., 1.] 3 | data22 = [0., 0., -1] 4 | data12 = [1., 2., 0.] 5 | labels = range(1,len(data11)+1) 6 | fo11 = FieldOutput(labels = labels, data=data11,position='node') 7 | fo22 = FieldOutput(labels = labels, data=data22,position='node') 8 | fo12 = FieldOutput(labels = labels, data=data12,position='node') 9 | tensor = TensorFieldOutput(data11 = fo11, data22 = fo22, data12 = fo12 ) 10 | t1, t2, t3, v1, v2, v3 = tensor.eigen() 11 | -------------------------------------------------------------------------------- /doc/example_code/postproc/TensorFieldOutput-tresca.py: -------------------------------------------------------------------------------- 1 | from abapy.postproc import FieldOutput, TensorFieldOutput, VectorFieldOutput, Identity_like 2 | data11 = [0., 0., 1.] 3 | data22 = [0., 0., -1] 4 | data12 = [1., 2., 0.] 5 | labels = range(1,len(data11)+1) 6 | fo11 = FieldOutput(labels = labels, data=data11,position='node') 7 | fo22 = FieldOutput(labels = labels, data=data22,position='node') 8 | fo12 = FieldOutput(labels = labels, data=data12,position='node') 9 | tensor = TensorFieldOutput(data11 = fo11, data22 = fo22, data12 = fo12 ) 10 | tresca = tensor.tresca() 11 | tresca 12 | -------------------------------------------------------------------------------- /doc/example_code/postproc/TensorFieldOutput-tresca.py~: -------------------------------------------------------------------------------- 1 | rom abapy.postproc import FieldOutput, TensorFieldOutput, VectorFieldOutput, Identity_like 2 | data11 = [0., 0., 1.] 3 | data22 = [0., 0., -1] 4 | data12 = [1., 2., 0.] 5 | labels = range(1,len(data11)+1) 6 | fo11 = FieldOutput(labels = labels, data=data11,position='node') 7 | fo22 = FieldOutput(labels = labels, data=data22,position='node') 8 | fo12 = FieldOutput(labels = labels, data=data12,position='node') 9 | tensor = TensorFieldOutput(data11 = fo11, data22 = fo22, data12 = fo12 ) 10 | tresca = tensor.tresca() 11 | tresca 12 | -------------------------------------------------------------------------------- /doc/example_code/postproc/HistoryOutput-average.py: -------------------------------------------------------------------------------- 1 | from abapy.postproc import HistoryOutput 2 | from math import sin, pi 3 | N = 100 4 | hist = HistoryOutput() 5 | time = [pi / 2 * float(i)/N for i in xrange(N+1)] 6 | data = [sin(t) for t in time] 7 | hist.add_step(time_step = time, data_step = data) 8 | time2 = [10., 11.] 9 | data2 = [1., 1.] 10 | hist.add_step(time_step = time2, data_step = data2) 11 | sol = 2. / pi + 1. 12 | print 'Print computed value:', hist.average() 13 | print 'Analytic solution:', sol 14 | print 'Relative error: {0:.4}%'.format( (hist.average() - sol)/sol * 100.) 15 | -------------------------------------------------------------------------------- /doc/example_code/postproc/HystoryOutput.py: -------------------------------------------------------------------------------- 1 | from abapy.postproc import HistoryOutput 2 | time = [ [1., 2.,3.] , [3.,4.,5.] , [5.,6.,7.] ] # Time separated in 3 steps 3 | data = [ [2.,2.,2.] , [3.,3.,3.] , [4.,4.,4.] ] # Data separated in 3 steps 4 | Data = HistoryOutput(time, data) 5 | print Data 6 | # +, *, **, abs, neg act only on data, not on time 7 | print Data + Data + 1. # addition 8 | print Data * Data * 2. # multiplication 9 | print ( Data / Data ) / 2. # division 10 | print Data ** 2 11 | print abs(Data) 12 | print Data[1] # step 1 13 | print Data[0:2] 14 | print Data[0,2] 15 | 16 | -------------------------------------------------------------------------------- /doc/example_code/postproc/HistoryOutput-average.py~: -------------------------------------------------------------------------------- 1 | from abapy.postproc import HistoryOutput 2 | from math import sin, pi 3 | N = 100 4 | hist = HistoryOutput() 5 | time = [pi / 2 * float(i)/N for i in xrange(N+1)] 6 | data = [sin(t) for t in time] 7 | hist.add_step(time_step = time, data_step = data) 8 | time2 = [10., 11.] 9 | data2 = [1., 1.] 10 | hist.add_step(time_step = time2, data_step = data2) 11 | sol = 2. / pi + 1. 12 | print 'Print computed value:', hist.average() 13 | print 'Analytic solution:', sol 14 | print 'Relative error: {0:.4}%'.format( (hist.average(method = 'simps') - sol)/sol * 100.) 15 | -------------------------------------------------------------------------------- /doc/index.rst: -------------------------------------------------------------------------------- 1 | .. abapy documentation master file, created by 2 | sphinx-quickstart on Sat Mar 31 15:44:59 2012. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | .. automodule:: abapy 7 | :members: 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 3 13 | 14 | tutorial 15 | mesh 16 | materials 17 | postproc 18 | indentation 19 | misc 20 | advanced_examples 21 | 22 | Indices and tables 23 | ================== 24 | 25 | * :ref:`genindex` 26 | * :ref:`modindex` 27 | * :ref:`search` 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /doc/example_code/postproc/TensoFieldOutput-eigen.py~: -------------------------------------------------------------------------------- 1 | from abapy.postproc import FieldOutput, TensorFieldOutput, VectorFieldOutput, Identity_like 2 | data12 = [1., 2., 0.] 3 | data11 = [0., 0., 1.] 4 | data22 = [0., 0., -1] 5 | labels = range(1,len(data11)+1) 6 | fo12 = FieldOutput(labels = labels, data=data12,position='node') 7 | fo11 = FieldOutput(labels = labels, data=data11,position='node') 8 | fo22 = FieldOutput(labels = labels, data=data22,position='node') 9 | vector = VectorFieldOutput(data1 = fo2) 10 | tensor = TensorFieldOutput(data11 = fo1, data22 = fo2 ) 11 | tensor2 = TensorFieldOutput(data33= fo2 ) 12 | t1, t2, t3, v1, v2, v3 = tensor2.eigen() 13 | -------------------------------------------------------------------------------- /doc/example_code/indentation/Get_ContactData.py: -------------------------------------------------------------------------------- 1 | from abapy.indentation import Get_ContactData 2 | from odbAccess import openOdb 3 | from abapy.misc import dump 4 | 5 | # Odb opening 6 | Berk_name = 'workdir/indentation_berko' 7 | Axi_name = 'workdir/indentation_axi' 8 | Berk_odb = openOdb(Berk_name + '.odb') 9 | Axi_odb = openOdb(Axi_name + '.odb') 10 | # Getting data 11 | Berk_out = Get_ContactData(odb = Berk_odb, instance = 'I_SAMPLE', node_set = 'TOP_NODES') 12 | Axi_out = Get_ContactData(odb = Axi_odb, instance = 'I_SAMPLE', node_set = 'TOP_NODES') 13 | # Dumping data 14 | dump(Axi_out, 'ContactData_axi.pckl') 15 | dump(Berk_out, 'ContactData_berk.pckl') 16 | 17 | 18 | -------------------------------------------------------------------------------- /doc/example_code/postproc/historyOutput-plotable.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | from abapy.postproc import HistoryOutput 3 | time = [ [1., 2.,3.] , [3.,4.,5.] , [5.,6.,7.] ] 4 | force = [ [2.,2.,2.] , [3.,3.,3.] , [4.,4.,4.] ] 5 | Force = HistoryOutput(time, force) 6 | fig = plt.figure(0, figsize=(8,4)) 7 | plt.clf() 8 | ax = fig.add_subplot(121) 9 | ax2 = fig.add_subplot(122) 10 | x,y = Force[[0,2]].toArray() 11 | x2,y2 = Force[[0,2]].plotable() 12 | ax.plot(x,y) 13 | ax2.plot(x2,y2) 14 | ax.set_ylim([1,5]) 15 | ax2.set_ylim([1,5]) 16 | plt.savefig('HistoryOutput-plotable.png') 17 | ax.set_title('HistorytOutput.toArray') 18 | ax2.set_title('HistorytOutput.plotable') 19 | plt.show() 20 | -------------------------------------------------------------------------------- /doc/example_code/future/volume_3D.msh: -------------------------------------------------------------------------------- 1 | $MeshFormat 2 | 2.2 0 8 3 | $EndMeshFormat 4 | $Nodes 5 | 20 6 | 1 0.0 1.0 0.0 7 | 2 0.0 2.0 0.0 8 | 3 0.0 3.0 0.0 9 | 4 1.0 4.0 0.0 10 | 5 1.0 3.0 0.0 11 | 6 1.0 2.0 0.0 12 | 7 2.0 1.0 0.0 13 | 8 1.0 0.0 0.0 14 | 9 2.0 3.0 0.0 15 | 10 2.0 2.0 0.0 16 | 11 0.0 1.0 1.0 17 | 12 0.0 2.0 1.0 18 | 13 0.0 3.0 1.0 19 | 14 1.0 4.0 1.0 20 | 15 1.0 3.0 1.0 21 | 16 1.0 2.0 1.0 22 | 17 2.0 1.0 1.0 23 | 18 1.0 0.0 1.0 24 | 19 2.0 3.0 1.0 25 | 20 2.0 2.0 1.0 26 | $EndNodes 27 | $Elements 28 | 6 29 | 1 5 1 1 1 8 7 6 11 18 17 16 30 | 2 5 1 1 2 6 5 3 12 16 15 13 31 | 3 6 1 1 1 6 2 11 16 12 32 | 4 6 1 1 3 5 4 13 15 14 33 | 5 6 1 1 6 7 10 16 17 20 34 | 6 5 1 1 5 6 10 9 15 16 20 19 35 | $EndElements -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-add_set.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import Mesh, Nodes 2 | mesh = Mesh() 3 | nodes = mesh.nodes 4 | # Adding some nodes 5 | nodes.add_node(label = 1, x = 0. ,y = 0. , z = 0.) 6 | nodes.add_node(label = 2, x = 1. ,y = 0. , z = 0.) 7 | nodes.add_node(label = 3, x = 1. ,y = 1. , z = 0.) 8 | nodes.add_node(label = 4, x = 0. ,y = 1. , z = 0.) 9 | nodes.add_node(label = 5, x = 2. ,y = 0. , z = 0.) 10 | nodes.add_node(label = 6, x = 2. ,y = 1. , z = 0.) 11 | # Adding some elements 12 | mesh.add_element(label=1, connectivity = (1,2,3,4), space =2, name = 'QUAD4', toset='mySet' ) 13 | mesh.add_element(label=2, connectivity = (2,5,6,3), space =2, name = 'QUAD4', toset = ['mySet','myOtherSet'] ) 14 | print mesh 15 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-add_element.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import Mesh, Nodes 2 | mesh = Mesh() 3 | nodes = mesh.nodes 4 | # Adding some nodes 5 | nodes.add_node(label = 1, x = 0. ,y = 0. , z = 0.) 6 | nodes.add_node(label = 2, x = 1. ,y = 0. , z = 0.) 7 | nodes.add_node(label = 3, x = 1. ,y = 1. , z = 0.) 8 | nodes.add_node(label = 4, x = 0. ,y = 1. , z = 0.) 9 | nodes.add_node(label = 5, x = 2. ,y = 0. , z = 0.) 10 | nodes.add_node(label = 6, x = 2. ,y = 1. , z = 0.) 11 | # Adding some elements 12 | mesh.add_element(label=1, connectivity = (1,2,3,4), space =2, name = 'QUAD4', toset='mySet' ) 13 | mesh.add_element(label=2, connectivity = (2,5,6,3), space =2, name = 'QUAD4', toset = ['mySet','myOtherSet'] ) 14 | print mesh 15 | -------------------------------------------------------------------------------- /doc/advanced_examples/indentation/simulations/delete_instance.py: -------------------------------------------------------------------------------- 1 | 2 | # Setting up the database 3 | execfile('settings.py') 4 | 5 | # Delaunay disp func 6 | def disp(c1, c2): 7 | k = .1 8 | r = (c1**2 +c2**2)**.5 9 | r = r + (r==0.) 10 | c1 = c1 / r 11 | c2 = c2 / r 12 | theta = np.arccos(c1) 13 | theta += -2 * theta * (c2 < 0.) 14 | r = r * (1 + k* np.cos(theta * 3) / (1+k)) 15 | return c1 * r, c2 * r 16 | 17 | 18 | # creating some shortcuts 19 | d = db_manager # database manager 20 | c = db_manager.cls # useful to call Simulation attributs 21 | 22 | simus2delete = d.query().filter(c.completed == False).all() 23 | 24 | for s in simus2delete: 25 | d.session.delete(s) 26 | d.session.commit() 27 | 28 | -------------------------------------------------------------------------------- /doc/example_code/postproc/HistoryOutput-integral.py: -------------------------------------------------------------------------------- 1 | from abapy.postproc import HistoryOutput 2 | time = [ [0., 1.], [3., 4.] ] 3 | data = [ [.5, 1.5], [.5, 1.5] ] 4 | hist = HistoryOutput(time = time, data = data) 5 | hist[0].integral() 6 | hist[1].integral() 7 | hist.integral() 8 | N = 10 9 | from math import sin, pi 10 | time = [pi / 2 * float(i)/N for i in xrange(N+1)] 11 | data = [sin(t) for t in time] 12 | hist = HistoryOutput() 13 | hist.add_step(time_step = time, data_step = data) 14 | trap = hist.integral() 15 | simp = hist.integral(method = 'simps') 16 | trap_error = (trap -1.) 17 | simp_error = (simp -1.) 18 | print 'Relative errors:\nTrapezoid rule: {0:.2}%\nSimpson rule: {1:.2}%'.format(trap_error*100, simp_error*100) 19 | -------------------------------------------------------------------------------- /doc/example_code/postproc/HistoryOutput-integral.py~: -------------------------------------------------------------------------------- 1 | from abapy.postproc import HistoryOutput 2 | time = [ [0., 1.], [3., 4.] ] 3 | data = [ [.5, 1.5], [.5, 1.5] ] 4 | hist = HistoryOutput(time = time, data = data) 5 | hist[0].integral() 6 | hist[1].integral() 7 | hist.integral() 8 | N = 10 9 | from math import sin, pi 10 | time = [pi / 2 * float(i)/N for i in xrange(N+1)] 11 | data = [sin(t) for t in time] 12 | hist = HistoryOutput() 13 | hist.add_step(time_step = time, data_step = data) 14 | trap = hist.integral() 15 | simp = hist.integral(method = 'simps') 16 | trap_error = (trap -1.) 17 | simp_error = (simp -1.) 18 | print 'Relative errors:\nTrapezoid rule: {0:.2}%\nSimpson rule: {1:.2}%'.format(trap_error*100, simp_error*100) 19 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-add_element.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import Mesh, Nodes 2 | import numpy as np 3 | mesh = Mesh() 4 | nodes = mesh.nodes 5 | # Adding some nodes 6 | nodes.add_node(label = 1, x = 0. ,y = 0. , z = 0.) 7 | nodes.add_node(label = 2, x = 1. ,y = 0. , z = 0.) 8 | nodes.add_node(label = 3, x = 1. ,y = 1. , z = 0.) 9 | nodes.add_node(label = 4, x = 0. ,y = 1. , z = 0.) 10 | nodes.add_node(label = 5, x = 2. ,y = 0. , z = 0.) 11 | nodes.add_node(label = 6, x = 2. ,y = 1. , z = 0.) 12 | # Adding some elements 13 | mesh.add_element(label=1, connectivity = (1,2,3,4), space =2, name = 'QUAD4', toset='mySet' ) 14 | mesh.add_element(label=2, connectivity = (2,5,6,3), space =2, name = 'QUAD4', toset = ['mySet','myOtherSet'] ) 15 | print mesh 16 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-extrude.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh, Mesh 2 | from matplotlib import pyplot as plt 3 | 4 | m = RegularQuadMesh(N1 = 2, N2 =2) 5 | m.add_set('el_set',[1,2]) 6 | m.add_surface('my_surface',[('el_set',2), ]) 7 | m2 = m.extrude(l = 1., N = 2) 8 | x,y,z = m.get_edges() 9 | x2,y2,z2 = m2.get_edges() 10 | 11 | # Adding some 3D "home made" perspective: 12 | zx, zy = .3, .3 13 | for i in xrange(len(x2)): 14 | if x2[i] != None: 15 | x2[i] += zx * z2[i] 16 | y2[i] += zy * z2[i] 17 | 18 | # Plotting stuff 19 | plt.figure() 20 | plt.clf() 21 | plt.gca().set_aspect('equal') 22 | plt.axis('off') 23 | plt.plot(x,y, 'b-', linewidth = 4., label = 'Orginal Mesh') 24 | plt.plot(x2,y2, 'r-', linewidth = 1., label = 'Extruded mesh') 25 | plt.legend() 26 | plt.show() 27 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-drop_node.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | from matplotlib import pyplot as plt 3 | # Creating a mesh 4 | m = RegularQuadMesh(N1 = 2, N2 = 2) 5 | x0, y0, z0 = m.get_edges() 6 | # Finding the node located at x = y =0.: 7 | nodes = m.nodes 8 | for i in xrange(len(nodes.labels)): 9 | if nodes.x[i] == 0. and nodes.y[i] == 0.: node = nodes.labels[i] 10 | # Removing this node 11 | m.drop_node(node) 12 | x1, y1, z1 = m.get_edges() 13 | bbx, bby, bbz = m.nodes.boundingBox() 14 | plt.figure() 15 | plt.clf() 16 | plt.gca().set_aspect('equal') 17 | plt.axis('off') 18 | plt.xlim(bbx) 19 | plt.ylim(bby) 20 | plt.plot(x0,y0, 'r-', linewidth = 2., label = 'Removed element') 21 | plt.plot(x1,y1, 'b-', linewidth = 2., label = 'New mesh') 22 | plt.legend() 23 | plt.show() 24 | 25 | 26 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-drop_node.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | from matplotlib import pyplot as plt 3 | # Creating a mesh 4 | m = RegularQuadMesh(N1 = 2, N2 = 2) 5 | x0, y0, z0 = m.get_edges() 6 | # Finding the node located at x = y =0.: 7 | nodes = m.nodes 8 | for i in xrange(len(nodes.labels)): 9 | if nodes.x[i] == 0. and nodes.y[i] == 0.: node = nodes.labels[i] 10 | # Removing this node 11 | m.drop_node(node) 12 | x1, y1, z1 = m.get_edges() 13 | bbx, bby, bbz = m.nodes.boundingBox() 14 | plt.figure() 15 | plt.clf() 16 | plt.gca().set_aspect('equal') 17 | plt.axis('off') 18 | plt.xlim(bbx) 19 | plt.ylim(bby) 20 | plt.plot(x0,y0, 'r-', linewidth = 2., label = 'Removed element') 21 | plt.plot(x1,y1, 'b-', linewidth = 2., label = 'New mesh') 22 | plt.legend() 23 | plt.show() 24 | 25 | 26 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-extrude.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh, Mesh 2 | from matplotlib import pyplot as plt 3 | 4 | m = RegularQuadMesh(N1 = 2, N2 =2) 5 | m.add_set('el_set',[1,2]) 6 | m.add_surface('my_surface',[('el_set',2), ]) 7 | m2 = m.extrude(l = 1., N = 2) 8 | x,y,z = m.get_edges() 9 | x2,y2,z2 = m2.get_edges() 10 | 11 | # Adding some 3D "home made" perspective: 12 | zx, zy = .3, .3 13 | for i in xrange(len(x2)): 14 | if x2[i] != None: 15 | x2[i] += zx * z2[i] 16 | y2[i] += zy * z2[i] 17 | 18 | # Plotting stuff 19 | plt.figure() 20 | plt.clf() 21 | plt.gca().set_aspect('equal') 22 | plt.axis('off') 23 | plt.plot(x,y, 'b-', linewidth = 4., label = 'Orginal Mesh') 24 | plt.plot(x2,y2, 'r-', linewidth = 1., label = 'Extruded mesh') 25 | plt.legend() 26 | plt.show() 27 | -------------------------------------------------------------------------------- /doc/example_code/indentation/MakeInp_abqpostproc.py: -------------------------------------------------------------------------------- 1 | # Launch with 'abaqus viewer -noGUI MakeInp_abqpostproc.py' 2 | from odbAccess import openOdb 3 | from abapy.postproc import GetTensorFieldOutput_byRpt, GetMesh 4 | from abapy.misc import dump 5 | path_to_odb = 'workdir/' 6 | odb_name = path_to_odb + 'indentation_axi.odb' 7 | odb = openOdb(odb_name) 8 | S = GetTensorFieldOutput_byRpt( 9 | odb = odb, 10 | instance = 'I_SAMPLE', 11 | step = 0, 12 | frame = -1, 13 | original_position = 'INTEGRATION_POINT', 14 | new_position = 'NODAL', 15 | position = 'node', 16 | field = 'S', 17 | sub_set_type = 'element', 18 | delete_report = True) 19 | mesh = GetMesh(odb = odb, instance = 'I_SAMPLE' ) 20 | dump(S, path_to_odb + 'indentation_S.pckl') 21 | dump(mesh, path_to_odb + 'indentation_mesh.pckl') 22 | -------------------------------------------------------------------------------- /doc/example_code/postproc/TensorFieldOutput.py: -------------------------------------------------------------------------------- 1 | from abapy.postproc import FieldOutput, TensorFieldOutput, VectorFieldOutput 2 | data11 = [1., 1., 1.] 3 | data22 = [2., 4., -1] 4 | data12 = [1., 2., 0.] 5 | labels = range(1,len(data11)+1) 6 | fo11 = FieldOutput(labels = labels, data=data11,position='node') 7 | fo22 = FieldOutput(labels = labels, data=data22,position='node') 8 | fo12 = FieldOutput(labels = labels, data=data12,position='node') 9 | tensor = TensorFieldOutput(data11 = fo11, data22 = fo22, data12 = fo12 ) 10 | tensor2 = TensorFieldOutput(data11= fo22 ) 11 | tensor 12 | print tensor 13 | print tensor[1,2] 14 | print tensor *2. + 1. 15 | print tensor ** 2 # Piecewise power 16 | vector = VectorFieldOutput(data1 = fo11) 17 | print tensor * vector # Matrix product 18 | print tensor * tensor2 # Contracted tensor product 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /doc/example_code/postproc/FieldOutput-dump2vtk.py: -------------------------------------------------------------------------------- 1 | from abapy.postproc import FieldOutput 2 | from abapy.mesh import Mesh, Nodes 3 | x = [0.,1.,0.] 4 | y = [0.,0.,1.] 5 | z = [0.,0.,0.] 6 | labels = [1,2,3] 7 | nodes = Nodes(x=x,y=y,z=z, labels=labels) 8 | mesh = Mesh(nodes=nodes) 9 | mesh.add_element(label = 1 , connectivity = [1,2,3], space = 2 , name = 'tri3') # triangle element 10 | nodeField = FieldOutput() 11 | nodeField.add_data(data = 0., label = 1) 12 | nodeField.add_data(data = 10., label = 2) 13 | nodeField.add_data(data = 20., label = 3) 14 | elementField = FieldOutput(position='element') 15 | elementField.add_data(label = 1, data =10.) 16 | out = '' 17 | out+=mesh.dump2vtk() 18 | out+=nodeField.dump2vtk('nodeField') 19 | out+=elementField.dump2vtk('elementField') 20 | f = open("FieldOutput-dump2vtk.vtk", "w") 21 | f.write(out) 22 | f.close() 23 | -------------------------------------------------------------------------------- /doc/example_code/future/clean_connectivity.inp: -------------------------------------------------------------------------------- 1 | *NODE 2 | 1, 0.0, 1.0, 0.0 3 | 2, 0.0, 2.0, 0.0 4 | 3, 0.0, 3.0, 0.0 5 | 4, 1.0, 4.0, 0.0 6 | 5, 1.0, 3.0, 0.0 7 | 6, 1.0, 2.0, 0.0 8 | 7, 2.0, 1.0, 0.0 9 | 8, 1.0, 0.0, 0.0 10 | 9, 2.0, 3.0, 0.0 11 | 10, 2.0, 2.0, 0.0 12 | 14, 6.12323399574e-17, 4.0, 1.0 13 | 15, 6.12323399574e-17, 3.0, 1.0 14 | 16, 6.12323399574e-17, 2.0, 1.0 15 | 17, 1.22464679915e-16, 1.0, 2.0 16 | 18, 6.12323399574e-17, 0.0, 1.0 17 | 19, 1.22464679915e-16, 3.0, 2.0 18 | 20, 1.22464679915e-16, 2.0, 2.0 19 | *ELEMENT, TYPE=C3D8 20 | 12, 5, 6, 10, 9, 15, 16, 20, 19 21 | *ELEMENT, TYPE=C3D6 22 | 11, 6, 7, 10, 16, 17, 20 23 | *ELEMENT, TYPE=C3D4 24 | 1, 6, 7, 16, 1 25 | 2, 7, 17, 16, 1 26 | 3, 8, 18, 7, 1 27 | 4, 7, 18, 17, 1 28 | 5, 5, 15, 3, 2 29 | 6, 6, 16, 5, 2 30 | 7, 5, 16, 15, 2 31 | 8, 6, 2, 1, 16 32 | 9, 5, 4, 3, 15 33 | 10, 4, 3, 15, 14 34 | -------------------------------------------------------------------------------- /doc/example_code/future/clean_connectivity.msh: -------------------------------------------------------------------------------- 1 | $MeshFormat 2 | 2.2 0 8 3 | $EndMeshFormat 4 | $Nodes 5 | 17 6 | 1 0.0 1.0 0.0 7 | 2 0.0 2.0 0.0 8 | 3 0.0 3.0 0.0 9 | 4 1.0 4.0 0.0 10 | 5 1.0 3.0 0.0 11 | 6 1.0 2.0 0.0 12 | 7 2.0 1.0 0.0 13 | 8 1.0 0.0 0.0 14 | 9 2.0 3.0 0.0 15 | 10 2.0 2.0 0.0 16 | 14 6.12323399574e-17 4.0 1.0 17 | 15 6.12323399574e-17 3.0 1.0 18 | 16 6.12323399574e-17 2.0 1.0 19 | 17 1.22464679915e-16 1.0 2.0 20 | 18 6.12323399574e-17 0.0 1.0 21 | 19 1.22464679915e-16 3.0 2.0 22 | 20 1.22464679915e-16 2.0 2.0 23 | $EndNodes 24 | $Elements 25 | 12 26 | 1 4 1 1 6 7 16 1 27 | 2 4 1 1 7 17 16 1 28 | 3 4 1 1 8 18 7 1 29 | 4 4 1 1 7 18 17 1 30 | 5 4 1 1 5 15 3 2 31 | 6 4 1 1 6 16 5 2 32 | 7 4 1 1 5 16 15 2 33 | 8 4 1 1 6 2 1 16 34 | 9 4 1 1 5 4 3 15 35 | 10 4 1 1 4 3 15 14 36 | 11 6 1 1 6 7 10 16 17 20 37 | 12 5 1 1 5 6 10 9 15 16 20 19 38 | $EndElements -------------------------------------------------------------------------------- /doc/example_code/postproc/TensorFieldOutput.py~: -------------------------------------------------------------------------------- 1 | from abapy.postproc import FieldOutput, TensorFieldOutput, VectorFieldOutput, Identity_like 2 | data11 = [1., 1., 1.] 3 | data22 = [2., 4., -1] 4 | data12 = [1., 2., 0.] 5 | labels = range(1,len(data11)+1) 6 | fo11 = FieldOutput(labels = labels, data=data11,position='node') 7 | fo22 = FieldOutput(labels = labels, data=data22,position='node') 8 | fo12 = FieldOutput(labels = labels, data=data12,position='node') 9 | tensor = TensorFieldOutput(data11 = fo11, data22 = fo22, data12 = fo12 ) 10 | tensor2 = TensorFieldOutput(data11= fo22 ) 11 | tensor 12 | print tensor 13 | print tensor[1,2] 14 | print tensor *2. + 1. 15 | print tensor ** 2 # Piecewise power 16 | vector = VectorFieldOutput(data1 = fo11) 17 | print tensor * vector # Matrix product 18 | print tensor * tensor2 # Contracted tensor product 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-dump2inp.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import Mesh, Nodes 2 | mesh = Mesh() 3 | nodes = mesh.nodes 4 | # Adding some nodes 5 | nodes.add_node(label = 1, x = 0. ,y = 0. , z = 0.) 6 | nodes.add_node(label = 2, x = 1. ,y = 0. , z = 0.) 7 | nodes.add_node(label = 3, x = 1. ,y = 1. , z = 0.) 8 | nodes.add_node(label = 4, x = 0. ,y = 1. , z = 0.) 9 | nodes.add_node(label = 5, x = 2. ,y = 0. , z = 0.) 10 | nodes.add_node(label = 6, x = 2. ,y = 1. , z = 0.) 11 | # Adding some elements 12 | mesh.add_element(label=1, connectivity = (1,2,3,4), space =2, name = 'QUAD4') 13 | mesh.add_element(label=2, connectivity = (2,5,6,3), space =2, name = 'QUAD4') 14 | # Adding sets 15 | mesh.add_set(label = 'veryNiceSet', elements = [1,2]) 16 | # Adding surfaces 17 | mesh.add_surface(label = 'superNiceSurface', description = [ ('veryNiceSet', 2) ]) 18 | out = mesh.dump2inp() 19 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-dump2inp.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import Mesh, Nodes 2 | mesh = Mesh() 3 | nodes = mesh.nodes 4 | # Adding some nodes 5 | nodes.add_node(label = 1, x = 0. ,y = 0. , z = 0.) 6 | nodes.add_node(label = 2, x = 1. ,y = 0. , z = 0.) 7 | nodes.add_node(label = 3, x = 1. ,y = 1. , z = 0.) 8 | nodes.add_node(label = 4, x = 0. ,y = 1. , z = 0.) 9 | nodes.add_node(label = 5, x = 2. ,y = 0. , z = 0.) 10 | nodes.add_node(label = 6, x = 2. ,y = 1. , z = 0.) 11 | # Adding some elements 12 | mesh.add_element(label=1, connectivity = (1,2,3,4), space =2, name = 'QUAD4') 13 | mesh.add_element(label=2, connectivity = (2,5,6,3), space =2, name = 'QUAD4') 14 | # Adding sets 15 | mesh.add_set(label = 'veryNiceSet', elements = [1,2]) 16 | # Adding surfaces 17 | mes.add_surface(label = 'superNiceSurface', description = [ ('veryNiceSet', 2) ]) 18 | out = mesh.dump2inp() 19 | -------------------------------------------------------------------------------- /doc/compile_doc.py: -------------------------------------------------------------------------------- 1 | # DOC COMPILER 2 | # Use only as a standalone script in order to compile the Sphinx doc 3 | 4 | 5 | if __name__ == '__main__': 6 | import os, subprocess 7 | os.system('git checkout master') 8 | proc = subprocess.Popen(["git status"], stdout=subprocess.PIPE, shell=True) 9 | (out, err) = proc.communicate() 10 | out = out.split('\n')[0] 11 | if out == "# On branch master": 12 | os.system('sphinx-build -a . _build/html') 13 | os.system('git checkout gh-pages') 14 | proc = subprocess.Popen(["git status"], stdout=subprocess.PIPE, shell=True) 15 | (out, err) = proc.communicate() 16 | out = out.split('\n')[0] 17 | if out == "# On branch gh-pages": 18 | os.system('cp -R _build/html/* ../') 19 | else: 20 | print "Commit before compiling doc" 21 | else: 22 | print "Commit before compiling doc" 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /doc/example_code/mesh/RegularQuadMesh.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | from matplotlib import pyplot as plt 3 | N1,N2 = 30,5 # Number of elements 4 | l1, l2 = 4., 1. # Mesh size 5 | fs = 20. # fontsize 6 | mesh = RegularQuadMesh(N1,N2,l1,l2) 7 | plt.figure(figsize=(8,3)) 8 | plt.gca().set_aspect('equal') 9 | nodes = mesh.nodes 10 | xn, yn, zn = nodes.x, nodes.y, nodes.z # Nodes coordinates 11 | xe,ye,ze = mesh.get_edges() # Mesh edges 12 | xb,yb,zb = mesh.get_border() # Mesh border 13 | plt.plot(xe,ye,'r-',label = 'edges') 14 | plt.plot(xb,yb,'b-',label = 'border') 15 | plt.plot(xn,yn,'go',label = 'nodes') 16 | plt.xlim([-.1*l1,1.1*l1]) 17 | plt.ylim([-.1*l2,1.1*l2]) 18 | plt.xticks([0,l1],['$0$', '$l_1$'],fontsize = fs) 19 | plt.yticks([0,l2],['$0$', '$l_2$'],fontsize = fs) 20 | plt.xlabel('$N_1$',fontsize = fs) 21 | plt.ylabel('$N_2$',fontsize = fs) 22 | plt.legend() 23 | plt.show() 24 | 25 | -------------------------------------------------------------------------------- /doc/example_code/mesh/RegularQuadMesh.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | from matplotlib import pyplot as plt 3 | N1,N2 = 30,5 # Number of elements 4 | l1, l2 = 4., 1. # Mesh size 5 | fs = 20. # fontsize 6 | mesh = RegularQuadMesh(N1,N2,l1,l2) 7 | plt.figure(figsize=(8,3)) 8 | plt.gca().set_aspect('equal') 9 | nodes = mesh.nodes 10 | xn, yn, zn = nodes.x, nodes.y, nodes.z # Nodes coordinates 11 | xe,ye,ze = mesh.get_edges() # Mesh edges 12 | xb,yb,zb = mesh.get_border() # Mesh border 13 | plt.plot(xe,ye,'r-',label = 'edges') 14 | plt.plot(xb,yb,'b-',label = 'border') 15 | plt.plot(xn,yn,'go',label = 'nodes') 16 | plt.xlim([-.1*l1,1.1*l1]) 17 | plt.ylim([-.1*l2,1.1*l2]) 18 | plt.xticks([0,l1],['$0$', '$l_1$'],fontsize = fs) 19 | plt.yticks([0,l2],['$0$', '$l_2$'],fontsize = fs) 20 | plt.xlabel('$N_1$',fontsize = fs) 21 | plt.ylabel('$N_2$',fontsize = fs) 22 | plt.legend() 23 | plt.show() 24 | 25 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-add_set.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import Mesh, Nodes 2 | mesh = Mesh() 3 | nodes = mesh.nodes 4 | # Adding some nodes 5 | nodes.add_node(label = 1, x = 0. ,y = 0. , z = 0.) 6 | nodes.add_node(label = 2, x = 1. ,y = 0. , z = 0.) 7 | nodes.add_node(label = 3, x = 1. ,y = 1. , z = 0.) 8 | nodes.add_node(label = 4, x = 0. ,y = 1. , z = 0.) 9 | nodes.add_node(label = 5, x = 2. ,y = 0. , z = 0.) 10 | nodes.add_node(label = 6, x = 2. ,y = 1. , z = 0.) 11 | # Adding some elements 12 | mesh.add_element(label=1, connectivity = (1,2,3,4), space =2, name = 'QUAD4') 13 | mesh.add_element(label=2, connectivity = (2,5,6,3), space =2, name = 'QUAD4') 14 | # Adding sets 15 | mesh.add_set(label = 'niceSet', elements = 1) 16 | mesh.add_set(label = 'veryNiceSet', elements = [1,2]) 17 | mesh.add_set(label = 'simplyTheBestSet', elements = 1) 18 | mesh.add_set(label = 'simplyTheBestSet', elements = 2) 19 | print mesh 20 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Nodes-eval_function.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import Mesh, Nodes, RegularQuadMesh 2 | import matplotlib.pyplot as plt 3 | from numpy import cos, pi 4 | def function(x, y, z, labels): 5 | r = (x**2 + y**2)**.5 6 | return cos(2*pi*x)*cos(2*pi*y)/(r+1.) 7 | N1, N2 = 100, 25 8 | l1, l2 = 4., 1. 9 | Ncolor = 20 10 | mesh = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) 11 | field = mesh.nodes.eval_function(function) 12 | x,y,z = mesh.get_edges() # Mesh edges 13 | X,Y,Z,tri = mesh.dump2triplot() 14 | xb,yb,zb = mesh.get_border() 15 | fig = plt.figure(figsize=(16,4)) 16 | fig.gca().set_aspect('equal') 17 | fig.frameon = True 18 | plt.plot(xb,yb,'k-', linewidth = 2.) 19 | plt.xticks([0,l1],['$0$', '$l_1$'], fontsize = 15.) 20 | plt.yticks([0,l2],['$0$', '$l_2$'], fontsize = 15.) 21 | plt.tricontourf(X,Y,tri,field.data, Ncolor) 22 | plt.tricontour(X,Y,tri,field.data, Ncolor, colors = 'black') 23 | plt.show() 24 | 25 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Nodes-eval_function.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import Mesh, Nodes, RegularQuadMesh 2 | import matplotlib.pyplot as plt 3 | from numpy import cos, pi 4 | def function(x, y, z, labels): 5 | r = (x**2 + y**2)**.5 6 | return cos(2*pi*x)*cos(2*pi*y)/(r+1.) 7 | N1, N2 = 100, 25 8 | l1, l2 = 4., 1. 9 | Ncolor = 20 10 | mesh = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) 11 | field = mesh.nodes.eval_function(function) 12 | x,y,z = mesh.get_edges() # Mesh edges 13 | X,Y,Z,tri = mesh.dump2triplot() 14 | xb,yb,zb = mesh.get_border() 15 | fig = plt.figure(figsize=(16,4)) 16 | fig.gca().set_aspect('equal') 17 | fig.frameon(False) 18 | plt.plot(xb,yb,'k-', linewidth = 2.) 19 | plt.xticks([0,l1],['$0$', '$l_1$'], fontsize = 15.) 20 | plt.yticks([0,l2],['$0$', '$l_2$'], fontsize = 15.) 21 | plt.tricontourf(X,Y,tri,field.data, Ncolor) 22 | plt.tricontour(X,Y,tri,field.data, Ncolor, colors = 'black') 23 | plt.show() 24 | 25 | -------------------------------------------------------------------------------- /doc/example_code/postproc/GetFieldOutput.py: -------------------------------------------------------------------------------- 1 | from abapy.postproc import GetFieldOutput 2 | from odbAccess import openOdb 3 | odb = openOdb('indentation.odb') 4 | U2 = GetFieldOutput(odb, step = 'LOADING0', frame = -1, instance ='I_SAMPLE', position = 'node', field = 'U', subField = 'U1') # Gets U2 at all nodes of instance 'I_SAMPLE' 5 | U1 = GetFieldOutput(odb, step = 'LOADING0', frame = -1, instance ='I_SAMPLE', position = 'node', field = 'U', subField = 'U1', labels = [5,6]) # Here labels refer to nodes 5 and 6 6 | S11 = GetFieldOutput(odb, step = 'LOADING0', frame = -1, instance ='I_SAMPLE', position = 'node', field = 'S', subField = 'S11', labels = 'CORE') # Here labels refers to nodes belonging to the node set 'CORE' 7 | S12 = GetFieldOutput(odb, step = 'LOADING0', frame = -1, instance ='I_SAMPLE', position = 'element', field = 'S', subField = 'S12', labels = 'CORE') # Here labels refers to nodes belonging to the node set 'CORE' 8 | -------------------------------------------------------------------------------- /doc/example_code/postproc/GetFieldOutput.py~: -------------------------------------------------------------------------------- 1 | from abapy.postproc import GetFieldOutput 2 | from odbAccess import openOdb 3 | odb = openOdb('indentation.odb') 4 | U2 = GetFieldOutput(odb, step = 'LOADING0', frame = -1, instance ='I_SAMPLE', position = 'node', field = 'U', subField = 'U1') # Gets U2 at all nodes of instance 'I_SAMPLE' 5 | U1 = GetFieldOutput(odb, step = 'LOADING0', frame = -1, instance ='I_SAMPLE', position = 'node', field = 'U', subField = 'U1', labels = [5,6]) # Here labels refer to nodes 5 and 6 6 | S11 = GetFieldOutput(odb, step = 'LOADING0', frame = -1, instance ='I_SAMPLE', position = 'node', field = 'S', subField = 'S11', labels = 'CORE') # Here labels refers to nodes belonging to the node set 'CORE' 7 | S12 = GetFieldOutput(odb, step = 'LOADING0', frame = -1, instance ='I_SAMPLE', position = 'element', field = 'S', subField = 'S12', labels = 'CORE') # Here labels refers to nodes belonging to the node set 'CORE' 8 | -------------------------------------------------------------------------------- /doc/example_code/indentation/ContactData-contact_contour.py: -------------------------------------------------------------------------------- 1 | from abapy.misc import load 2 | import numpy as np 3 | from matplotlib import pyplot as plt 4 | 5 | 6 | # In this case, a 3D FEM simulation has beed performed and the results are stored in the file ``ContactData_berk.pckl``. See ``Get_ContactData`` to understand how this data has been extracted from an Abaqus odb file. 7 | 8 | 9 | out = load('ContactData_berk.pckl') 10 | cd0 = out[1][-1] # First step data: loading 11 | cd1 = out[2][-1] # Second step data: unloading 12 | hmax = -cd0.min_altitude() 13 | 14 | p2, p1, p0 = cd0.contact_contour() 15 | x0, y0 = p0[:,0], p0[:,1] 16 | x1, y1 = p1[:,0], p1[:,1] 17 | x2, y2 = p2[:,0], p2[:,1] 18 | 19 | 20 | plt.figure() 21 | plt.clf() 22 | plt.title('Contact area contour') 23 | plt.plot(x0, y0, label = 'upper bound') 24 | plt.plot(x1, y1, label = 'middle') 25 | plt.plot(x2, y2, label = 'lower bound') 26 | plt.grid() 27 | plt.legend() 28 | plt.show() 29 | -------------------------------------------------------------------------------- /doc/example_code/indentation/ContactData-export2spym.py: -------------------------------------------------------------------------------- 1 | from abapy.misc import load 2 | import numpy as np 3 | import matplotlib.pyplot as plt 4 | 5 | # In this case, a 3D FEM simulation has beed performed and the results are stored in the file ``ContactData.pckl``. See ``Get_ContactData`` to understand how this data has been extracted from an Abaqus odb file. 6 | 7 | 8 | out = load('ContactData_berk.pckl') 9 | cdl = out[1][-1] # loading 10 | cdu = out[2][-1] # unloading 11 | hmax = -cdl.min_altitude() 12 | l = 7. * hmax 13 | alt, press = cdu.export2spym(lx = l, ly = l, nx = 512, ny = 512) 14 | alt.dump2gsf('image.gsf') 15 | xlabel, ylabel, zlabel = alt.get_labels() 16 | X,Y,Z = alt.get_xyz() 17 | plt.figure() 18 | plt.clf() 19 | plt.gca().set_aspect('equal') 20 | plt.grid() 21 | plt.contourf(X, Y, Z, 10) 22 | cbar = plt.colorbar() 23 | cbar.set_label(zlabel) 24 | plt.contour(X, Y, Z, 10, colors = 'black') 25 | plt.xlabel(xlabel) 26 | plt.ylabel(ylabel) 27 | plt.show() 28 | 29 | 30 | -------------------------------------------------------------------------------- /doc/advanced_examples/indentation/simulations/settings.py: -------------------------------------------------------------------------------- 1 | from classes import Simulation, Database_Manager 2 | 3 | #---------------------------------------------------------------------------------------------------------------- 4 | # SETTINGS 5 | work_dir = 'workdir/' 6 | plot_dir = 'plots/' 7 | database_dir = 'database/' 8 | database_name = 'database' 9 | abqlauncher = '/opt/Abaqus/6.9/Commands/abaqus' 10 | cls = Simulation 11 | #---------------------------------------------------------------------------------------------------------------- 12 | 13 | #---------------------------------------------------------------------------------------------------------------- 14 | # Starting Database Manager 15 | db_manager = Database_Manager( 16 | work_dir = work_dir, 17 | database_dir = database_dir, 18 | database_name = database_name, 19 | abqlauncher = abqlauncher, 20 | cls = cls) 21 | #---------------------------------------------------------------------------------------------------------------- 22 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-sweep.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh, Mesh 2 | from matplotlib import pyplot as plt 3 | from array import array 4 | from abapy.indentation import IndentationMesh 5 | 6 | m = RegularQuadMesh(N1 = 2, N2 =2) 7 | m.connectivity[2] = array(m.dti,[5, 7, 4]) 8 | m.connectivity[3] = array(m.dti,[5, 6, 9]) 9 | m.add_set('el_set',[1,2]) 10 | m.add_set('el_set2',[2,4]) 11 | m.add_surface('my_surface',[('el_set',1),]) 12 | m2 = m.sweep(sweep_angle = 70., N = 2, extrude=True) 13 | x,y,z = m.get_edges() 14 | x2,y2,z2 = m2.get_edges() 15 | 16 | # Adding some 3D "home made" perspective: 17 | zx, zy = .3, .3 18 | for i in xrange(len(x2)): 19 | if x2[i] != None: 20 | x2[i] += zx * z2[i] 21 | y2[i] += zy * z2[i] 22 | 23 | # Plotting stuff 24 | plt.figure() 25 | plt.clf() 26 | plt.gca().set_aspect('equal') 27 | plt.axis('off') 28 | plt.plot(x,y, 'b-', linewidth = 4., label = 'Orginal Mesh') 29 | plt.plot(x2,y2, 'r-', linewidth = 1., label = 'Sweeped mesh') 30 | plt.legend() 31 | plt.show() 32 | 33 | 34 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-sweep.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh, Mesh 2 | from matplotlib import pyplot as plt 3 | from array import array 4 | from abapy.indentation import IndentationMesh 5 | 6 | m = RegularQuadMesh(N1 = 2, N2 =2) 7 | m.connectivity[2] = array(m.dti,[5, 7, 4]) 8 | m.connectivity[3] = array(m.dti,[5, 6, 9]) 9 | m.add_set('el_set',[1,2]) 10 | m.add_set('el_set2',[2,4]) 11 | m.add_surface('my_surface',[('el_set',1),]) 12 | m2 = m.sweep(sweep_angle = 45., N = 2, extrude=True) 13 | x,y,z = m.get_edges() 14 | x2,y2,z2 = m2.get_edges() 15 | 16 | # Adding some 3D "home made" perspective: 17 | zx, zy = .3, .3 18 | for i in xrange(len(x2)): 19 | if x2[i] != None: 20 | x2[i] += zx * z2[i] 21 | y2[i] += zy * z2[i] 22 | 23 | # Plotting stuff 24 | plt.figure() 25 | plt.clf() 26 | plt.gca().set_aspect('equal') 27 | plt.axis('off') 28 | plt.plot(x,y, 'b-', linewidth = 4., label = 'Orginal Mesh') 29 | plt.plot(x2,y2, 'r-', linewidth = 1., label = 'Sweeped mesh') 30 | plt.legend() 31 | plt.show() 32 | 33 | 34 | -------------------------------------------------------------------------------- /doc/example_code/indentation/IndentationMesh.py: -------------------------------------------------------------------------------- 1 | from abapy.indentation import IndentationMesh 2 | from matplotlib import pyplot as plt 3 | 4 | Na = 16 # Elements along x axis in the square zone 5 | Nb = 16 # Elements along y axis in the square zone 6 | Ns = 2 # Radial number of elements in the shell 7 | Nf = 2 # Minimal number of orthoradial elements in heach half shell 8 | l = 1. # Size of the square zone 9 | name = 'CAX4' # Name of the elements 10 | 11 | m = IndentationMesh(Na = Na, Nb = Nb, Ns = Ns, Nf= Nf, l = l, name = name) 12 | 13 | m_core = m['core_elements'] 14 | m_shell = m['shell_elements'] 15 | 16 | x_core, y_core, z_core = m_core.get_edges() 17 | x_shell, y_shell, z_shell = m_shell.get_edges() 18 | plt.figure(0) 19 | plt.clf() 20 | plt.axis('off') 21 | plt.grid() 22 | xlim, ylim, zlim = m.nodes.boundingBox() 23 | plt.gca().set_aspect('equal') 24 | plt.xlim(xlim) 25 | plt.ylim(ylim) 26 | plt.plot(x_core,y_core, 'b-', label = 'Core elements') 27 | plt.plot(x_shell,y_shell, 'r-', label = 'Shell elements') 28 | plt.legend() 29 | plt.show() 30 | -------------------------------------------------------------------------------- /doc/example_code/tutorial/first_example_abq.py: -------------------------------------------------------------------------------- 1 | # ABAQUS/PYTHON POST PROCESSING SCRIPT 2 | # Run using abaqus python / abaqus viewer -noGUI / abaqus cae -noGUI 3 | 4 | # Packages (Abaqus, Abapy and built-in only here) 5 | from odbAccess import openOdb 6 | from abapy.misc import dump 7 | from abapy.postproc import GetHistoryOutputByKey as gho 8 | 9 | # Setting up some pathes 10 | workdir = 'workdir' 11 | name = 'indentation_axi' 12 | 13 | # Opening the Odb File 14 | odb = openOdb(workdir + '/' + name + '.odb') 15 | 16 | # Finding back the position of the reference node of the indenter. Its number is stored inside a node set named REF_NODE. 17 | ref_node_label = odb.rootAssembly.instances['I_INDENTER'].nodeSets['REF_NODE'].nodes[0].label 18 | 19 | # Getting back the reaction forces along Y (RF2) and displacements along Y (U2) where they are recorded. 20 | RF2 = gho(odb, 'RF2') 21 | U2 = gho(odb, 'U2') 22 | 23 | # Packing data 24 | data = {'ref_node_label': ref_node_label, 'RF2':RF2, 'U2':U2} 25 | 26 | # Dumping data 27 | dump(data, workdir + '/' + name + '.pckl') 28 | 29 | # Closing Odb 30 | odb.close() 31 | 32 | -------------------------------------------------------------------------------- /doc/example_code/indentation/ContactData.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from abapy.indentation import ContactData 3 | 4 | X = np.linspace(-3., 3., 512) 5 | Y = np.linspace(-3., 3., 512) 6 | X, Y = np.meshgrid(X, Y) 7 | # Axi 8 | cd = ContactData() 9 | x = [0, 1, 2, 10] 10 | alt = [-1,.1, 0, 0] 11 | press = [1, 0, 0, 0] 12 | cd.add_data(x, altitude = alt, pressure = press) 13 | Alt_axi, Press_axi = cd.interpolate(X, Y, method ='linear') 14 | area = cd.contact_area() 15 | 16 | 17 | # 3D 18 | cd = ContactData(repeat = 3, is_3D = True) 19 | k = np.cos(np.radians(60)) 20 | p = np.sin(np.radians(60)) 21 | x = [0, 4, 10, k*4, k*10] 22 | y = [0, 0, 0, p*4, p*10] 23 | alt = [-1, 0, 0, 0, 0] 24 | cd.add_data(x, altitude = alt) 25 | Alt_3D, Press_3D = cd.interpolate(X, Y, method ='linear') 26 | 27 | 28 | from matplotlib import pyplot as plt 29 | 30 | fig = plt.figure() 31 | plt.clf() 32 | ax1 = fig.add_subplot(121) 33 | grad = plt.imshow(Alt_axi) 34 | plt.contour(Alt_axi, colors= 'black') 35 | plt.title('axi contact') 36 | ax1 = fig.add_subplot(122) 37 | grad = plt.imshow(Alt_3D) 38 | plt.contour(Alt_3D, colors= 'black') 39 | plt.title('3D contact') 40 | plt.show() 41 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-dump2polygons.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | from abapy.indentation import IndentationMesh 3 | import matplotlib.pyplot as plt 4 | from matplotlib.path import Path 5 | import matplotlib.patches as patches 6 | import matplotlib.collections as collections 7 | import numpy as np 8 | from matplotlib import cm 9 | from scipy import interpolate 10 | 11 | 12 | def function(x, y, z, labels): 13 | r0 = 1. 14 | theta = .5 * np.pi * x 15 | r = y + r0 16 | ux = -x + r * np.cos(theta**2) 17 | uy = -y + r * np.sin(theta**2) 18 | uz = 0. * z 19 | return ux, uy, uz 20 | N1, N2 = 30, 30 21 | l1, l2 = .75, 1. 22 | 23 | 24 | 25 | m = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) 26 | vectorField = m.nodes.eval_vectorFunction(function) 27 | m.nodes.apply_displacement(vectorField) 28 | patches = m.dump2polygons() 29 | bb = m.nodes.boundingBox() 30 | patches.set_linewidth(1.) 31 | fig = plt.figure(0) 32 | plt.clf() 33 | ax = fig.add_subplot(111) 34 | ax.set_aspect("equal") 35 | ax.add_collection(patches) 36 | plt.grid() 37 | plt.xlim(bb[0]) 38 | plt.ylim(bb[1]) 39 | plt.xlabel("$x$ position") 40 | plt.ylabel("$y$ position") 41 | plt.show() 42 | 43 | -------------------------------------------------------------------------------- /doc/example_code/postproc/VectorFieldOutput.py: -------------------------------------------------------------------------------- 1 | from abapy.postproc import FieldOutput, VectorFieldOutput 2 | data1 = [1,2,3,5,6,0] 3 | data2 = [1. for i in data1] 4 | labels = range(1,len(data1)+1) 5 | fo1, fo2 = FieldOutput(labels = labels, data=data1, position='node' ), FieldOutput(labels = labels, data=data2,position='node') 6 | vector = VectorFieldOutput(data1 = fo1, data2 = fo2 ) 7 | vector2 = VectorFieldOutput(data2 = fo2 ) 8 | vector # short description 9 | print vector # long description 10 | print vector[6] # Returns a VectorFieldOutput instance 11 | print vector[1,4,6] # Picking label by label 12 | print vector[1:6:2] # Slicing 13 | vector.get_data(6) # Returns 3 floats 14 | vector.norm() # Returns norm 15 | vector.sum() # returns the sum of coords 16 | vector * vector2 # Itemwise product (like numpy, unlike matlab) 17 | vector.dot(vector2) # Dot/Scalar product 18 | vector.cross(vector2) # Cross/Vector product 19 | vector + 2 # Itemwise addition 20 | vector * 2 # Itemwise multiplication 21 | vector / 2 # Itemwise division 22 | vector / vector2 # Itemwise division between vectors (numpy way) 23 | abs(vector) # Absolute value 24 | vector ** 2 # Power 25 | vector ** vector # Itemwize power 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /doc/advanced_examples/indentation/simulations/tests.py: -------------------------------------------------------------------------------- 1 | # Importing packages 2 | from matplotlib import pyplot as plt 3 | import numpy as np 4 | from scipy.optimize import leastsq 5 | 6 | # Setting up the database 7 | execfile('settings.py') 8 | 9 | 10 | 11 | # creating some shortcuts 12 | d = db_manager # database manager 13 | c = db_manager.cls # useful to call Simulation attributs 14 | # Getting simulations: 15 | simus = d.query().filter(c.completed == True).all() 16 | 17 | unload = 2 18 | plt.figure(0) 19 | plt.clf() 20 | S = [] 21 | 22 | for simu in simus: 23 | disp = np.array(simu.disp_hist[unload].data[0]) 24 | force = np.array(simu.force_hist[unload].data[0]) 25 | max_force = force.max() 26 | max_disp = disp.max() 27 | loc = np.where(force >= max_force * .1) 28 | disp = disp[loc] /max_disp 29 | force = force[loc] / max_force 30 | func = lambda k, x: ( (x - k[0]) / (1. - k[0] ) )**k[1] 31 | err = lambda v, x, y: (func(v,x)-y) 32 | k0 = [0., 1.] 33 | k, success = leastsq(err, k0, args=(disp,force), maxfev=10000) 34 | force_fit = func(k,disp) 35 | plt.plot(disp, force, 'or') 36 | plt.plot(disp, force_fit, 'b-') 37 | S.append(k[1] / (1. - k[0]) ) 38 | 39 | 40 | plt.show() 41 | -------------------------------------------------------------------------------- /doc/example_code/postproc/VectorFieldOutput.py~: -------------------------------------------------------------------------------- 1 | from abapy.postproc import FieldOutput, VectorFieldOutput 2 | data1 = [1,2,3,5,6,0] 3 | data2 = [1. for i in data1] 4 | labels = range(1,len(data1)+1) 5 | fo1, fo2 = FieldOutput(labels = labels, data=data1, position='node' ), FieldOutput(labels = labels, data=data2,position='node') 6 | vector = VectorFieldOutput(data1 = fo1, data2 = fo2 ) 7 | vector2 = VectorFieldOutput(data2 = fo2 ) 8 | vector # short description 9 | print vector # long description 10 | print vector[6] # Returns a VectorFieldOutput instance 11 | print vector[1,4,6] # Picking label by label 12 | print vector[1:6:2] # Slicing 13 | vector.get_data(6) # Returns 3 floats 14 | vector.norm() # Returns norm 15 | vector.sum_coord() # returns the sum of coords 16 | vector * vector2 # Itemwise product (like numpy, unlike matlab) 17 | vector.dot(vector2) # Dot/Scalar product 18 | vector.cross(vector2) # Cross/Vector product 19 | vector + 2 # Itemwise addition 20 | vector * 2 # Itemwise multiplication 21 | vector / 2 # Itemwise division 22 | vector / vector2 # Itemwise division between vectors (numpy way) 23 | abs(vector) # Absolute value 24 | vector ** 2 # Power 25 | vector ** vector # Itemwize power 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /doc/example_code/indentation/Hertz.py: -------------------------------------------------------------------------------- 1 | from abapy.indentation import Hertz 2 | from abapy.mesh import Mesh, Nodes, RegularQuadMesh 3 | from matplotlib import pyplot as plt 4 | import numpy as np 5 | 6 | """ 7 | =========== 8 | Hertz model 9 | =========== 10 | """ 11 | 12 | H = Hertz(F = 1., E=1., nu = 0.1) 13 | Ne = 50 14 | 15 | mesh = RegularQuadMesh(N1 = Ne, N2 = Ne, l1 = H.a * 2., l2 = H.a * 2., dtf = 'd') 16 | mesh.nodes.translate(H.a/20., H.a/20.) 17 | S = mesh.nodes.eval_tensorFunction(H.sigma) 18 | R,Z,T,tri = mesh.dump2triplot() 19 | R, Z = np.array(R), np.array(Z) 20 | # Some fields 21 | srr = S.get_component(11) 22 | szz = S.get_component(22) 23 | stt = S.get_component(33) 24 | srz = S.get_component(12) 25 | smises = S.vonmises() 26 | s1, s2, s3, v1, v2, v3 = S.eigen() # Eigenvalues and eigenvectors 27 | data = smises.data 28 | 29 | N = 20 30 | levels = np.linspace(0., max(data), N) 31 | a = H.a 32 | plt.figure() 33 | plt.tricontourf(R/a, Z/a, tri, data, levels) 34 | plt.colorbar() 35 | plt.tricontour(R/a, Z/a, tri, data, levels, colors = 'black') 36 | plt.xlabel('$r/a$', fontsize = 14.) 37 | plt.ylabel('$z/a$', fontsize = 14.) 38 | #plt.quiver(R, Z, v1.data1, v1.data2) 39 | plt.grid() 40 | plt.show() 41 | 42 | -------------------------------------------------------------------------------- /doc/example_code/indentation/ContactData-get_3D_data.py: -------------------------------------------------------------------------------- 1 | from abapy.indentation import ContactData 2 | from matplotlib import pyplot as plt 3 | 4 | 5 | # Axi contact 6 | cd = ContactData() 7 | x = [0, 1, 2, 3] 8 | alt = [-1,.1, 0, 0] 9 | press = [1, 0, 0, 0] 10 | cd.add_data(x, altitude = alt, pressure = press) 11 | points_axi, alt_axi, press_axi, conn_axi = cd.get_3D_data(axi_repeat = 20) 12 | 13 | 14 | 15 | # 3D contact 16 | cd = ContactData(repeat = 3, is_3D = True) 17 | k = np.cos(np.radians(60)) 18 | p = np.sin(np.radians(60)) 19 | x = [0, 4, 10, k*4, k*10] 20 | y = [0, 0, 0, p*4, p*10] 21 | alt = [-1, 0, 0, 0, 0] 22 | cd.add_data(x, altitude = alt) 23 | points_3D, alt_3D, press_3D, conn_3D = cd.get_3D_data() 24 | 25 | 26 | 27 | fig = plt.figure() 28 | plt.clf() 29 | ax1 = fig.add_subplot(121) 30 | ax1.set_aspect('equal') 31 | plt.tricontourf(points_axi[:,0], points_axi[:,1], conn_axi, alt_axi) 32 | plt.triplot(points_axi[:,0], points_axi[:,1], conn_axi) 33 | 34 | plt.title('axi contact') 35 | ax1 = fig.add_subplot(122) 36 | ax1.set_aspect('equal') 37 | plt.tricontourf(points_3D[:,0], points_3D[:,1], conn_3D, alt_3D) 38 | plt.triplot(points_3D[:,0], points_3D[:,1], conn_3D) 39 | plt.title('3D contact') 40 | plt.show() 41 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Nodes-apply_displacement.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import Mesh, Nodes, RegularQuadMesh 2 | import matplotlib.pyplot as plt 3 | from numpy import cos, sin, pi 4 | from copy import copy 5 | def function(x, y, z, labels): 6 | r0 = 1. 7 | theta = 2 * pi * x 8 | r = y + r0 9 | ux = -x + r * cos(theta) 10 | uy = -y + r * sin(theta) 11 | uz = 0. * z 12 | return ux, uy, uz 13 | N1, N2 = 100, 25 14 | l1, l2 = .75, 1. 15 | Ncolor = 20 16 | mesh = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) 17 | vectorField = mesh.nodes.eval_vectorFunction(function) 18 | mesh.nodes.apply_displacement(vectorField) 19 | field = vectorField.get_coord(2) # we chose to plot coordinate 2 20 | field2 = vectorField.get_coord(2) # we chose to plot coordinate 2 21 | x,y,z = mesh.get_edges() # Mesh edges 22 | X,Y,Z,tri = mesh.dump2triplot() 23 | xb,yb,zb = mesh.get_border() # mesh borders 24 | xe, ye, ze = mesh.get_edges() 25 | fig = plt.figure(figsize=(10,10)) 26 | fig.gca().set_aspect('equal') 27 | plt.axis('off') 28 | plt.plot(xb,yb,'k-', linewidth = 2.) 29 | plt.plot(xe, ye,'k-', linewidth = .5) 30 | plt.tricontour(X,Y,tri,field.data, Ncolor, colors = 'black') 31 | color = plt.tricontourf(X,Y,tri,field.data, Ncolor) 32 | plt.colorbar(color) 33 | plt.show() 34 | 35 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Nodes-apply_displacement.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import Mesh, Nodes, RegularQuadMesh 2 | import matplotlib.pyplot as plt 3 | from numpy import cos, sin, pi 4 | from copy import copy 5 | def function(x, y, z, labels): 6 | r0 = 1. 7 | theta = 2 * pi * x 8 | r = y + r0 9 | ux = -x + r * cos(theta) 10 | uy = -y + r * sin(theta) 11 | uz = 0. * z 12 | return ux, uy, uz 13 | N1, N2 = 100, 25 14 | l1, l2 = .75, 1. 15 | Ncolor = 20 16 | mesh = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) 17 | vectorField = mesh.nodes.eval_vectorFunction(function) 18 | mesh.nodes.apply_displacement(vectorField) 19 | field = vectorField.get_coord(2) # we chose to plot coordinate 2 20 | field2 = vectorField.get_coord(2) # we chose to plot coordinate 2 21 | x,y,z = mesh.get_edges() # Mesh edges 22 | X,Y,Z,tri = mesh.dump2triplot() 23 | xb,yb,zb = mesh.get_border() # mesh borders 24 | xe, ye, ze = mesh.get_edges() 25 | fig = plt.figure(figsize=(10,10)) 26 | fig.gca().set_aspect('equal') 27 | plt.axis('off') 28 | plt.plot(xb,yb,'k-', linewidth = 2.) 29 | plt.plot(xe, ye,'k-', linewidth = .5) 30 | plt.tricontour(X,Y,tri,field.data, Ncolor, colors = 'black') 31 | color = plt.tricontourf(X,Y,tri,field.data, Ncolor) 32 | plt.colorbar(color) 33 | plt.show() 34 | 35 | -------------------------------------------------------------------------------- /doc/example_code/future/mesh-volume.py: -------------------------------------------------------------------------------- 1 | from abapy.future import Mesh, parseInp, writeInp, writeMsh, Node, Tri3, Quad4 2 | import numpy as np 3 | 4 | m = Mesh() 5 | m.nodes[1] = Node( (0., 1., 0.) ) 6 | m.nodes[2] = Node( (0., 2., 0.) ) 7 | m.nodes[3] = Node( (0., 3., 0.) ) 8 | m.nodes[4] = Node( (1., 4., 0.) ) 9 | m.nodes[5] = Node( (1., 3., 0.) ) 10 | m.nodes[6] = Node( (1., 2., 0.) ) 11 | m.nodes[7] = Node( (2., 1., 0.) ) 12 | m.nodes[8] = Node( (1., 0., 0.) ) 13 | m.nodes[9] = Node( (2., 3., 0.) ) 14 | m.nodes[10] = Node( (2., 2., 0.) ) 15 | 16 | 17 | m.elements[1] = Quad4(conn = (1,8,7,6)) 18 | m.elements[2] = Quad4(conn = (2,6,5,3)) 19 | m.elements[3] = Tri3(conn = (1,6,2)) 20 | m.elements[4] = Tri3(conn = (3,5,4)) 21 | m.elements[5] = Tri3(conn = (6,7,10)) 22 | m.elements[6] = Quad4(conn = (5,6,10,9)) 23 | 24 | for k, v in m.elements.iteritems(): 25 | print k, v.volume() 26 | 27 | def transformation(x, y, z): 28 | theta = np.pi / 4. * z 29 | r = x.copy() 30 | x = r * np.cos(theta) 31 | z = r * np.sin(theta) 32 | 33 | return x, y, z 34 | 35 | m = m.extrude(translation = [0, 0, 1], layers = 1) 36 | m = m.transform(transformation) 37 | 38 | for k, v in m.elements.iteritems(): 39 | print k, v.volume() 40 | 41 | writeMsh(m, "volume.msh") 42 | -------------------------------------------------------------------------------- /doc/example_code/indentation/Hanson.py: -------------------------------------------------------------------------------- 1 | from abapy.indentation import Hanson 2 | from abapy.mesh import Mesh, Nodes, RegularQuadMesh 3 | from matplotlib import pyplot as plt 4 | import numpy as np 5 | 6 | """ 7 | =========== 8 | Hanson model for conical indentation 9 | =========== 10 | """ 11 | 12 | H = Hanson(F = 1., E=1., nu = 0.3, half_angle = 70.29) 13 | Ne = 20 14 | 15 | mesh = RegularQuadMesh(N1 = Ne, N2 = Ne, l1 = H.a * 2., l2 = H.a * 2., dtf = 'd') 16 | mesh.nodes.translate(H.a/20., H.a/20.) 17 | S = mesh.nodes.eval_tensorFunction(H.sigma) 18 | R,Z,T,tri = mesh.dump2triplot() 19 | R, Z = np.array(R), np.array(Z) 20 | # Some fields 21 | srr = S.get_component(11) 22 | szz = S.get_component(22) 23 | stt = S.get_component(33) 24 | srz = S.get_component(12) 25 | smises = S.vonmises() 26 | s1, s2, s3, v1, v2, v3 = S.eigen() # Eigenvalues and eigenvectors 27 | data = smises.data 28 | 29 | N = 20 30 | levels = np.linspace(0., max(data), N) 31 | a = H.a 32 | plt.figure() 33 | plt.tricontourf(R/a, Z/a, tri, data, levels) 34 | plt.colorbar() 35 | plt.tricontour(R/a, Z/a, tri, data, levels, colors = 'black') 36 | plt.xlabel('$r/a$', fontsize = 14.) 37 | plt.ylabel('$z/a$', fontsize = 14.) 38 | #plt.quiver(R, Z, v1.data1, v1.data2) 39 | plt.grid() 40 | plt.show() 41 | 42 | -------------------------------------------------------------------------------- /doc/example_code/postproc/ReadFieldOutputReport.py: -------------------------------------------------------------------------------- 1 | from abapy.postproc import ReadFieldOutputReport 2 | import numpy as np 3 | import time 4 | 5 | def dummyReport(path, nl = 1000, nv = 10000): 6 | header = """******************************************************************************** 7 | Field Output Report, written Fri Apr 27 10:07:54 2012 8 | 9 | Source 1 10 | --------- 11 | 12 | ODB: /home/lcharleux/Documents/Prog/modules/python/abapy/doc/example_code/postproc/indentation.odb 13 | Step: LOADING0 14 | Frame: Increment 10: Step Time = 1.000 15 | 16 | Loc 1 : Nodal values from source 1 17 | 18 | Output sorted by column "Node Label". 19 | 20 | Field Output reported at nodes for part: I_SAMPLE 21 | 22 | Node U.Magnitude 23 | Label @Loc 1 24 | ---------------------------------\n""" 25 | labels = np.random.randint(1,nl+1, size = nv) 26 | values = np.random.rand(nv) 27 | out = header 28 | for i in xrange(nv): out += "{0} {1} \n".format(labels[i], values[i]) 29 | open(path, "w").write(out) 30 | 31 | path = 'test.rpt' 32 | nv = 100000 33 | dummyReport(path, nv = nv) 34 | 35 | t0 = time.time() 36 | field = ReadFieldOutputReport(path, position = 'nodes', dti = 'I', dtf = 'f') 37 | t1 = time.time() 38 | 39 | print "Read {0} values in {1} s".format(nv, t1-t0) 40 | 41 | 42 | -------------------------------------------------------------------------------- /doc/example_code/future/mesh-centroid.py: -------------------------------------------------------------------------------- 1 | from abapy.future import Mesh, parseInp, writeInp, writeMsh, Node, Tri3, Quad4 2 | import numpy as np 3 | 4 | m = Mesh() 5 | m.nodes[1] = Node( (0., 1., 0.) ) 6 | m.nodes[2] = Node( (0., 2., 0.) ) 7 | m.nodes[3] = Node( (0., 3., 0.) ) 8 | m.nodes[4] = Node( (1., 4., 0.) ) 9 | m.nodes[5] = Node( (1., 3., 0.) ) 10 | m.nodes[6] = Node( (1., 2., 0.) ) 11 | m.nodes[7] = Node( (2., 1., 0.) ) 12 | m.nodes[8] = Node( (1., 0., 0.) ) 13 | m.nodes[9] = Node( (2., 3., 0.) ) 14 | m.nodes[10] = Node( (2., 2., 0.) ) 15 | 16 | 17 | m.elements[1] = Quad4(conn = (1,8,7,6)) 18 | m.elements[2] = Quad4(conn = (2,6,5,3)) 19 | m.elements[3] = Tri3(conn = (1,6,2)) 20 | m.elements[4] = Tri3(conn = (3,5,4)) 21 | m.elements[5] = Tri3(conn = (6,7,10)) 22 | m.elements[6] = Quad4(conn = (5,6,10,9)) 23 | 24 | for k, v in m.elements.iteritems(): 25 | print k, v.volume(), v.centroid() 26 | 27 | writeMsh(m, "volume_2D.msh") 28 | 29 | def transformation(x, y, z): 30 | theta = np.pi / 4. * z 31 | r = x.copy() 32 | x = r * np.cos(theta) 33 | z = r * np.sin(theta) 34 | 35 | return x, y, z 36 | 37 | m = m.extrude(translation = [0, 0, 1], layers = 1) 38 | #m = m.transform(transformation) 39 | 40 | for k, v in m.elements.iteritems(): 41 | print k, v.volume(), v.centroid() 42 | 43 | writeMsh(m, "volume_3D.msh") 44 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-centroids.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import Mesh 2 | from matplotlib import pyplot as plt 3 | import numpy as np 4 | 5 | N1,N2 = 10,5 # Number of elements 6 | l1, l2 = 4., 2. # Mesh size 7 | fs = 20. # fontsize 8 | mesh = Mesh() 9 | nodes = mesh.nodes 10 | nodes.add_node(label = 1, x = 0., y = 0.) 11 | nodes.add_node(label = 2, x = 1., y = 0.) 12 | nodes.add_node(label = 3, x = 0., y = 1.) 13 | nodes.add_node(label = 4, x = 1.5, y = 1.) 14 | nodes.add_node(label = 5, x = 1., y = 2.) 15 | mesh.add_element(label = 1, connectivity = [1,2,3], space = 2) 16 | mesh.add_element(label = 2, connectivity = [2,4,5,3], space = 2) 17 | 18 | 19 | centroids = mesh.centroids() 20 | 21 | plt.figure(figsize=(8,3)) 22 | plt.gca().set_aspect('equal') 23 | nodes = mesh.nodes 24 | xn, yn, zn = np.array(nodes.x), np.array(nodes.y), np.array(nodes.z) # Nodes coordinates 25 | xe,ye,ze = mesh.get_edges() # Mesh edges 26 | xb,yb,zb = mesh.get_border() # Mesh border 27 | 28 | 29 | plt.plot(xe,ye,'r-',label = 'Edges') 30 | plt.plot(xb,yb,'b-',label = 'Border') 31 | plt.plot(xn,yn,'go',label = 'Nodes') 32 | plt.xlim([-.1*l1,1.1*l1]) 33 | plt.ylim([-.1*l2,1.1*l2]) 34 | plt.xlabel('$x$',fontsize = fs) 35 | plt.ylabel('$y$',fontsize = fs) 36 | plt.plot(centroids[:,0], centroids[:,1], '*', label = "Centroids") 37 | plt.legend() 38 | plt.grid() 39 | plt.show() 40 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-dump2polygons_3D.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | from abapy.indentation import IndentationMesh 3 | import matplotlib.pyplot as plt 4 | from matplotlib.path import Path 5 | import matplotlib.patches as patches 6 | import matplotlib.collections as collections 7 | import mpl_toolkits.mplot3d as a3 8 | import numpy as np 9 | from matplotlib import cm 10 | from scipy import interpolate 11 | 12 | 13 | def function(x, y, z, labels): 14 | r0 = 1. 15 | theta = .5 * np.pi * x 16 | r = y + r0 17 | ux = -x + r * np.cos(theta**2) 18 | uy = -y + r * np.sin(theta**2) 19 | uz = 0. * z 20 | return ux, uy, uz 21 | N1, N2, N3 = 10, 10, 5 22 | l1, l2, l3 = .75, 1., 1. 23 | 24 | 25 | 26 | m = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) 27 | m = m.extrude(l = l3, N = N3 ) 28 | vectorField = m.nodes.eval_vectorFunction(function) 29 | m.nodes.apply_displacement(vectorField) 30 | patches = m.dump2polygons(use_3D = True, 31 | face_color = None, 32 | edge_color = "black") 33 | bb = m.nodes.boundingBox() 34 | patches.set_linewidth(1.) 35 | 36 | fig = plt.figure(0) 37 | plt.clf() 38 | ax = a3.Axes3D(fig) 39 | ax.set_aspect("equal") 40 | ax.add_collection3d(patches) 41 | plt.xlim(bb[0]) 42 | plt.ylim(bb[1]) 43 | plt.xlabel("$x$ position") 44 | plt.ylabel("$y$ position") 45 | plt.show() 46 | 47 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-volume.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | from abapy.indentation import IndentationMesh 3 | import matplotlib.pyplot as plt 4 | from matplotlib.path import Path 5 | import matplotlib.patches as patches 6 | import matplotlib.collections as collections 7 | import numpy as np 8 | from matplotlib import cm 9 | from scipy import interpolate 10 | 11 | 12 | def function(x, y, z, labels): 13 | r0 = 1. 14 | theta = .5 * np.pi * x 15 | r = y + r0 16 | ux = -x + r * np.cos(theta**2) 17 | uy = -y + r * np.sin(theta**2) 18 | uz = 0. * z 19 | return ux, uy, uz 20 | N1, N2 = 30, 30 21 | l1, l2 = .75, 1. 22 | 23 | 24 | 25 | m = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) 26 | vectorField = m.nodes.eval_vectorFunction(function) 27 | m.nodes.apply_displacement(vectorField) 28 | patches = m.dump2polygons() 29 | volume = m.volume() 30 | bb = m.nodes.boundingBox() 31 | patches.set_facecolor(None) # Required to allow face color 32 | patches.set_array(volume) 33 | patches.set_linewidth(1.) 34 | fig = plt.figure(0) 35 | plt.clf() 36 | ax = fig.add_subplot(111) 37 | ax.set_aspect("equal") 38 | ax.add_collection(patches) 39 | plt.legend() 40 | cbar = plt.colorbar(patches) 41 | plt.grid() 42 | plt.xlim(bb[0]) 43 | plt.ylim(bb[1]) 44 | plt.xlabel("$x$ position") 45 | plt.ylabel("$y$ position") 46 | cbar.set_label("Element volume") 47 | plt.show() 48 | 49 | -------------------------------------------------------------------------------- /doc/example_code/postproc/indentation_core_step0_frame1_U1_nodal.rpt: -------------------------------------------------------------------------------- 1 | ******************************************************************************** 2 | Field Output Report, written Thu Apr 26 17:52:45 2012 3 | 4 | Source 1 5 | --------- 6 | 7 | ODB: /home/lcharleux/Documents/Prog/modules/python/abapy/doc/example_code/postproc/indentation.odb 8 | Step: LOADING0 9 | Frame: Increment 10: Step Time = 1.000 10 | 11 | Loc 1 : Nodal values from source 1 12 | 13 | Output sorted by column "Node Label". 14 | 15 | Field Output reported at nodes for part: I_SAMPLE 16 | 17 | Node U.U1 18 | Label @Loc 1 19 | --------------------------------- 20 | 1 0. 21 | 2 302.964E-06 22 | 3 408.671E-06 23 | 4 0. 24 | 5 2.07055E-03 25 | 6 356.213E-06 26 | 7 0. 27 | 8 21.6635E-03 28 | 9 424.236E-06 29 | 11 79.2532E-06 30 | 12 48.8439E-06 31 | 14 202.964E-06 32 | 15 50.2712E-06 33 | 17 153.152E-06 34 | 18 -2.90907E-06 35 | 25 -0. 36 | 26 36.9353E-06 37 | 28 0. 38 | 29 98.4084E-06 39 | 40 | 41 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-dump2vtk.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | from abapy.indentation import IndentationMesh 3 | import numpy as np 4 | 5 | def tensor_function(x, y, z, labels): 6 | """ 7 | Vector function used to produced the displacement field. 8 | """ 9 | r0 = 1. 10 | theta = .5 * np.pi * x 11 | r = y + r0 12 | s11 = z + x 13 | s22 = z + y 14 | s33 = x**2 15 | s12 = y**2 16 | s13 = x + y 17 | s23 = z 18 | return s11, s22, s33, s12, s13, s23 19 | 20 | def vector_function(x, y, z, labels): 21 | """ 22 | Vector function used to produced the displacement field. 23 | """ 24 | r0 = 1. 25 | theta = .5 * np.pi * x 26 | r = y + r0 27 | ux = -x + r * np.cos(theta**2) 28 | uy = -y + r * np.sin(theta**2) 29 | uz = 0. * z 30 | return ux, uy, uz 31 | 32 | def scalar_function(x, y, z, labels): 33 | """ 34 | Scalar function used to produced the plotted field. 35 | """ 36 | return x**2 + y**2 37 | #MESH GENERATION 38 | N1, N2, N3 = 8, 8, 8 39 | l1, l2, l3 = .75, 1., .5 40 | m = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2).extrude(N = N3, l = l3) 41 | #FIELDS GENERATION 42 | s = m.nodes.eval_tensorFunction(tensor_function) 43 | m.add_field(s, "s") 44 | u = m.nodes.eval_vectorFunction(vector_function) 45 | m.add_field(u, "u") 46 | m.nodes.apply_displacement(u) 47 | f = m.nodes.eval_function(scalar_function) 48 | m.add_field(f, "f") 49 | m.dump2vtk("Mesh-dump2vtk.vtk") 50 | 51 | 52 | -------------------------------------------------------------------------------- /doc/example_code/tutorial/fancier_example_abq.py: -------------------------------------------------------------------------------- 1 | # ABAQUS/PYTHON POST PROCESSING SCRIPT 2 | # Run using abaqus python / abaqus viewer -noGUI / abaqus cae -noGUI 3 | 4 | # Packages (Abaqus, Abapy and built-in only here) 5 | from odbAccess import openOdb 6 | from abapy.misc import dump 7 | from abapy.postproc import GetHistoryOutputByKey as gho 8 | from abaqusConstants import JOB_STATUS_COMPLETED_SUCCESSFULLY 9 | 10 | 11 | # Setting up some pathes 12 | workdir = 'workdir' 13 | name = 'indentation_axi_fancier' 14 | 15 | # Opening the Odb File 16 | odb = openOdb(workdir + '/' + name + '.odb') 17 | 18 | # Testing job status 19 | data = {} 20 | status = odb.diagnosticData.jobStatus 21 | if status == JOB_STATUS_COMPLETED_SUCCESSFULLY: 22 | data['completed'] = True 23 | # Finding back the position of the reference node of the indenter. Its number is stored inside a node set named REF_NODE. 24 | ref_node_label = odb.rootAssembly.instances['I_INDENTER'].nodeSets['REF_NODE'].nodes[0].label 25 | 26 | # Getting back the reaction forces along Y (RF2) and displacements along Y (U2) where they are recorded. 27 | RF2 = gho(odb, 'RF2') 28 | U2 = gho(odb, 'U2') 29 | 30 | # Packing data 31 | data['ref_node_label'] = ref_node_label 32 | data['RF2'] = RF2 33 | data['U2'] = U2 34 | 35 | 36 | else: 37 | data['completed'] = False 38 | # Dumping data 39 | dump(data, workdir + '/' + name + '.pckl') 40 | # Closing Odb 41 | odb.close() 42 | 43 | -------------------------------------------------------------------------------- /doc/example_code/materials/Hollomon.py: -------------------------------------------------------------------------------- 1 | from abapy.materials import Hollomon 2 | import matplotlib.pyplot as plt 3 | 4 | E = 1. # Young's modulus 5 | sy = 0.001 # Yield stress 6 | n = 0.15 # Hardening exponent 7 | nu = 0.3 8 | eps_max = .1 # maximum strain to be computed 9 | N = 30 # Number of points to be computed (30 is a low value useful for graphical reasons, in real simulations, 100 is a better value). 10 | mat1 = Hollomon(labels = 'my_material', E=E, nu=nu, sy=sy, n=n) 11 | table1 = mat1.get_table(0, N=N, eps_max=eps_max) 12 | eps1 = table1[:,0] 13 | sigma1 = table1[:,1] 14 | sigma_max1 = max(sigma1) 15 | 16 | mat2 = Hollomon(labels = 'my_material', E=E, nu=nu, sy=sy, n=n, kind = 2) 17 | table2 = mat2.get_table(0, N=N, eps_max=eps_max) 18 | eps2 = table2[:,0] 19 | sigma2 = table2[:,1] 20 | sigma_max2 = max(sigma2) 21 | 22 | 23 | plt.figure() 24 | plt.clf() 25 | plt.title('Hollomon tensile behavior: $n = {0:.2f}$, $\sigma_y / E = {1:.2e}$'.format(n, sy/E)) 26 | plt.xlabel('Strain $\epsilon$') 27 | plt.ylabel('Stress $\sigma$') 28 | plt.plot(eps1, sigma1, 'or-', label = 'Plasticity kind=1') 29 | plt.plot(eps2, sigma2, 'vg-', label = 'Plasticity kind=2') 30 | plt.plot([0., sy / E], [0., sy], 'b-', label = 'Elasticity') 31 | plt.xticks([0., sy/E, eps_max], ['$0$', '$\epsilon_y$', '$\epsilon_{max}$'], fontsize = 16.) 32 | plt.yticks([0., sy, sigma_max1], ['$0$', '$\sigma_y$', '$\sigma_{max}$'], fontsize = 16.) 33 | plt.grid() 34 | plt.legend(loc = "lower right") 35 | plt.show() 36 | -------------------------------------------------------------------------------- /doc/example_code/materials/Hollomon.py~: -------------------------------------------------------------------------------- 1 | from abapy.materials import Hollomon 2 | import matplotlib.pyplot as plt 3 | 4 | E = 1. # Young's modulus 5 | sy = 0.001 # Yield stress 6 | n = 0.15 # Hardening exponent 7 | nu = 0.3 8 | eps_max = .1 # maximum strain to be computed 9 | N = 30 # Number of points to be computed (30 is a low value useful for graphical reasons, in real simulations, 100 is a better value). 10 | mat1 = Hollomon(labels = 'my_material', E=E, nu=nu, sy=sy, n=n) 11 | table1 = mat1.get_table(0, N=N, eps_max=eps_max) 12 | eps1 = table1[:,0] 13 | sigma1 = table1[:,1] 14 | sigma_max1 = max(sigma1) 15 | 16 | mat2 = Hollomon(labels = 'my_material', E=E, nu=nu, sy=sy, n=n, kind = 2) 17 | table2 = mat2.get_table(0, N=N, eps_max=eps_max) 18 | eps2 = table2[:,0] 19 | sigma2 = table2[:,1] 20 | sigma_max2 = max(sigma2) 21 | 22 | 23 | plt.figure() 24 | plt.clf() 25 | plt.title('Hollomon tensile behavior: $n = {0:.1f}$, $\sigma_y / E = {1:.2e}$'.format(n, sy/E)) 26 | plt.xlabel('Strain $\epsilon$') 27 | plt.ylabel('Stress $\sigma$') 28 | plt.plot(eps1, sigma1, 'or-', label = 'Plasticity kind=1') 29 | plt.plot(eps2, sigma2, 'vg-', label = 'Plasticity kind=2') 30 | plt.plot([0., sy / E], [0., sy], 'b-', label = 'Elasticity') 31 | plt.xticks([0., sy/E, eps_max], ['$0$', '$\epsilon_y$', '$\epsilon_{max}$'], fontsize = 16.) 32 | plt.yticks([0., sy, sigma_max1], ['$0$', '$\sigma_y$', '$\sigma_{max}$'], fontsize = 16.) 33 | plt.grid() 34 | plt.legend(loc = "lower right") 35 | plt.show() 36 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-convert2tri3.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import Mesh, Nodes, RegularQuadMesh 2 | import matplotlib.pyplot as plt 3 | from numpy import cos, pi 4 | def function(x, y, z, labels): 5 | r = (x**2 + y**2)**.5 6 | return cos(2*pi*x)*cos(2*pi*y)/(r+1.) 7 | N1, N2 = 30, 30 8 | l1, l2 = 1., 1. 9 | Ncolor = 10 10 | mesh = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) 11 | field = mesh.nodes.eval_function(function) 12 | fig = plt.figure(figsize=(16,4)) 13 | ax = fig.add_subplot(131) 14 | ax2 = fig.add_subplot(132) 15 | ax3 = fig.add_subplot(133) 16 | ax.set_aspect('equal') 17 | ax2.set_aspect('equal') 18 | ax3.set_aspect('equal') 19 | ax.set_xticks([]) 20 | ax.set_yticks([]) 21 | ax2.set_xticks([]) 22 | ax2.set_yticks([]) 23 | ax3.set_xticks([]) 24 | ax3.set_yticks([]) 25 | ax.set_frame_on(False) 26 | ax2.set_frame_on(False) 27 | ax3.set_frame_on(False) 28 | ax.set_title('Orginal Mesh') 29 | ax2.set_title('Triangularized Mesh') 30 | ax3.set_title('Field') 31 | x,y,z = mesh.get_edges() # Mesh edges 32 | xt,yt,zt = mesh.convert2tri3().get_edges() # Triangular mesh edges 33 | xb,yb,zb = mesh.get_border() 34 | X,Y,Z,tri = mesh.dump2triplot() 35 | ax.plot(x,y,'k-') 36 | ax2.plot(xt,yt,'k-') 37 | ax3.tricontourf(X,Y,tri,field.data, Ncolor) 38 | ax3.tricontour(X,Y,tri,field.data, Ncolor, colors = 'black') 39 | ax.set_xlim([-.1*l1,1.1*l1]) 40 | ax.set_ylim([-.1*l2,1.1*l2]) 41 | ax2.set_xlim([-.1*l1,1.1*l1]) 42 | ax2.set_ylim([-.1*l2,1.1*l2]) 43 | ax3.set_xlim([-.1*l1,1.1*l1]) 44 | ax3.set_ylim([-.1*l2,1.1*l2]) 45 | plt.show() 46 | -------------------------------------------------------------------------------- /doc/example_code/postproc/indentation_core_step0_frame1_S11_nodes.rpt: -------------------------------------------------------------------------------- 1 | ******************************************************************************** 2 | Field Output Report, written Fri Apr 27 10:07:38 2012 3 | 4 | Source 1 5 | --------- 6 | 7 | ODB: /home/lcharleux/Documents/Prog/modules/python/abapy/doc/example_code/postproc/indentation.odb 8 | Step: LOADING0 9 | Frame: Increment 10: Step Time = 1.000 10 | 11 | Loc 1 : Nodal values from source 1 12 | 13 | Output sorted by column "Node Label". 14 | 15 | Field Output reported at nodes for region: I_SAMPLE.Region_1 16 | Computation algorithm: EXTRAPOLATE_COMPUTE_AVERAGE 17 | Averaged at nodes 18 | Averaging regions: ODB_REGIONS 19 | 20 | Node S.S11 21 | Label @Loc 1 22 | --------------------------------- 23 | 1 1.09260E-03 24 | 2 -220.352E-06 25 | 3 -490.897E-06 26 | 4 -1.62646E-03 27 | 5 -3.17961E-03 28 | 6 -1.24735E-03 29 | 7 -5.95788E-03 30 | 8 -4.98278E-03 31 | 9 -594.455E-06 32 | 11 -15.4724E-06 33 | 12 -31.4269E-06 34 | 14 -200.636E-06 35 | 15 -53.2875E-06 36 | 17 -399.030E-06 37 | 18 -28.0754E-06 38 | 25 25.7775E-06 39 | 26 5.41486E-06 40 | 28 66.3944E-06 41 | 29 54.0360E-06 42 | 43 | 44 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-convert2tri3.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import Mesh, Nodes, RegularQuadMesh 2 | import matplotlib.pyplot as plt 3 | from numpy import cos, pi 4 | def function(x, y, z, labels): 5 | r = (x**2 + y**2)**.5 6 | return cos(2*pi*x)*cos(2*pi*y)/(r+1.) 7 | N1, N2 = 30, 30 8 | l1, l2 = 1., 1. 9 | Ncolor = 10 10 | mesh = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) 11 | field = mesh.nodes.eval_function(function) 12 | fig = plt.figure(figsize=(16,4)) 13 | ax = fig.add_subplot(131) 14 | ax2 = fig.add_subplot(132) 15 | ax3 = fig.add_subplot(133) 16 | ax.set_aspect('equal') 17 | ax2.set_aspect('equal') 18 | ax3.set_aspect('equal') 19 | ax.set_xticks([]) 20 | ax.set_yticks([]) 21 | ax2.set_xticks([]) 22 | ax2.set_yticks([]) 23 | ax3.set_xticks([]) 24 | ax3.set_yticks([]) 25 | ax.set_frame_on(False) 26 | ax2.set_frame_on(False) 27 | ax3.set_frame_on(False) 28 | ax.set_title('Orginal Mesh') 29 | ax2.set_title('Triangularized Mesh') 30 | ax3.set_title('Field') 31 | x,y,z = mesh.get_edges() # Mesh edges 32 | xt,yt,zt = mesh.convert2tri3().get_edges() # Triangular mesh edges 33 | xb,yb,zb = mesh.get_border() 34 | X,Y,Z,tri = mesh.dump2triplot() 35 | ax.plot(x,y,'k-') 36 | ax2.plot(xt,yt,'k-') 37 | ax3.plot(xb,yb,'k-', linewidth = 2.) 38 | ax3.tricontourf(X,Y,tri,field.data, Ncolor) 39 | ax3.tricontour(X,Y,tri,field.data, Ncolor, colors = 'black') 40 | ax.set_xlim([-.1*l1,1.1*l1]) 41 | ax.set_ylim([-.1*l2,1.1*l2]) 42 | ax2.set_xlim([-.1*l1,1.1*l1]) 43 | ax2.set_ylim([-.1*l2,1.1*l2]) 44 | ax3.set_xlim([-.1*l1,1.1*l1]) 45 | ax3.set_ylim([-.1*l2,1.1*l2]) 46 | plt.show() 47 | -------------------------------------------------------------------------------- /doc/example_code/postproc/ReadFieldOutputReport.py~: -------------------------------------------------------------------------------- 1 | from abapy.postproc import ReadFieldOutputReport, ReadFieldOutputReport2 2 | import numpy as np 3 | import time 4 | 5 | def dummyReport(path, nl = 1000, nv = 10000): 6 | header = """******************************************************************************** 7 | Field Output Report, written Fri Apr 27 10:07:54 2012 8 | 9 | Source 1 10 | --------- 11 | 12 | ODB: /home/lcharleux/Documents/Prog/modules/python/abapy/doc/example_code/postproc/indentation.odb 13 | Step: LOADING0 14 | Frame: Increment 10: Step Time = 1.000 15 | 16 | Loc 1 : Nodal values from source 1 17 | 18 | Output sorted by column "Node Label". 19 | 20 | Field Output reported at nodes for part: I_SAMPLE 21 | 22 | Node U.Magnitude 23 | Label @Loc 1 24 | ---------------------------------\n""" 25 | labels = np.random.randint(1,nl+1, size = nv) 26 | values = np.random.rand(nv) 27 | out = header 28 | for i in xrange(nv): out += "{0} {1} \n".format(labels[i], values[i]) 29 | open(path, "w").write(out) 30 | 31 | path = 'test.rpt' 32 | nv = 100000 33 | dummyReport(path, nv = nv) 34 | 35 | t0 = time.time() 36 | field = ReadFieldOutputReport(path, position = 'nodes', dti = 'I', dtf = 'f') 37 | t1 = time.time() 38 | 39 | print "Method 1: Read {0} values in {1} s".format(nv, t1-t0) 40 | 41 | t0 = time.time() 42 | field = ReadFieldOutputReport2(path, position = 'nodes', dti = 'I', dtf = 'f') 43 | t1 = time.time() 44 | 45 | print "Method 2: Read {0} values in {1} s".format(nv, t1-t0) 46 | 47 | 48 | -------------------------------------------------------------------------------- /doc/example_code/indentation/Boussinesq.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import Mesh, Nodes, RegularQuadMesh 2 | from abapy import CFE 3 | from numpy import linspace 4 | import matplotlib.pyplot as plt 5 | 6 | """ 7 | Bousinesq model 8 | =============== 9 | """ 10 | Bo = CFE.Boussinesq(F = 10.) 11 | 12 | """ 13 | Mesh model 14 | """ 15 | N1, N2 = 50, 50 16 | l1, l2 = 1., 1. 17 | Ncolor = 200 18 | levels = linspace(0., 10., 20) 19 | 20 | mesh = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) 21 | nodes = mesh.nodes 22 | 23 | tensorField = mesh.nodes.eval_tensorFunction(Bo.sigma_boussinesq()) 24 | 25 | sigma_zz = tensorField.get_component(22) 26 | VM = tensorField.vonmises() 27 | P = tensorField.pressure() 28 | 29 | xt,yt,zt = mesh.convert2tri3().get_edges() 30 | xb,yb,zb = mesh.get_border() 31 | X,Y,Z,tri = mesh.dump2triplot() 32 | 33 | """ 34 | Display of stress fields 35 | """ 36 | fig = plt.figure(figsize=(16,4)) 37 | 38 | g1 = fig.add_subplot(131) 39 | g1.set_aspect('equal') 40 | g1.set_title(r'$\sigma_{zz}$') 41 | g1.tricontourf(X,Y,tri,sigma_zz.data, levels = levels) 42 | g1.tricontour(X,Y,tri,sigma_zz.data, levels = levels, colors = 'black') 43 | 44 | g2 = fig.add_subplot(132) 45 | g2.set_aspect('equal') 46 | g2.set_title(r'Von Mises $\sigma_{eq}$') 47 | g2.tricontourf(X,Y,tri,VM.data, levels = levels) 48 | g2.tricontour(X,Y,tri,VM.data, levels = levels, colors = 'black') 49 | 50 | g3 = fig.add_subplot(133) 51 | g3.set_aspect('equal') 52 | g3.set_title(r'Pressure $p$') 53 | g3.tricontourf(X,Y,tri,P.data, levels = sorted(-levels)) 54 | g3.tricontour(X,Y,tri,P.data, levels = sorted(-levels), colors = 'black') 55 | 56 | plt.show() 57 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-draw.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | from abapy.indentation import IndentationMesh 3 | import matplotlib.pyplot as plt 4 | from matplotlib.path import Path 5 | import matplotlib.patches as patches 6 | import matplotlib.collections as collections 7 | import numpy as np 8 | from matplotlib import cm 9 | from scipy import interpolate 10 | 11 | def vector_function(x, y, z, labels): 12 | """ 13 | Vector function used to produced the displacement field. 14 | """ 15 | r0 = 1. 16 | theta = .5 * np.pi * x 17 | r = y + r0 18 | ux = -x + r * np.cos(theta**2) 19 | uy = -y + r * np.sin(theta**2) 20 | uz = 0. * z 21 | return ux, uy, uz 22 | 23 | def scalar_function(x, y, z, labels): 24 | """ 25 | Scalar function used to produced the plotted field. 26 | """ 27 | return x**2 + y**2 28 | #MESH GENERATION 29 | N1, N2 = 30, 30 30 | l1, l2 = .75, 1. 31 | m = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) 32 | #FIELDS GENERATION 33 | u = m.nodes.eval_vectorFunction(vector_function) 34 | m.add_field(u, "u") 35 | f = m.nodes.eval_function(scalar_function) 36 | m.add_field(f, "f") 37 | #PLOTS 38 | fig = plt.figure(0) 39 | plt.clf() 40 | ax = fig.add_subplot(1,1,1) 41 | m.draw(ax, 42 | disp_func = lambda fields : fields["u"], 43 | field_func = lambda fields : fields["f"], 44 | cmap = cm.jet, 45 | cbar_orientation = "vertical", 46 | contour = False, 47 | contour_colors = "black", 48 | alpha = 1., 49 | cmap_levels = 10, 50 | edge_width = .1) 51 | ax.set_aspect("equal") 52 | plt.grid() 53 | plt.xlabel("$x$ position") 54 | plt.ylabel("$y$ position") 55 | plt.show() 56 | 57 | -------------------------------------------------------------------------------- /doc/example_code/tutorial/first_example.py: -------------------------------------------------------------------------------- 1 | # PYTHON POST PROCESSING SCRIPT 2 | # Run using python 3 | 4 | # Packages 5 | from abapy.misc import load 6 | import matplotlib.pyplot as plt 7 | import numpy as np 8 | 9 | # Setting up some pathes 10 | workdir = 'workdir' 11 | name = 'indentation_axi' 12 | 13 | # Getting back raw data 14 | data = load(workdir + '/' + name + '.pckl') 15 | 16 | # Post processing 17 | ref_node_label = data['ref_node_label'] 18 | force_hist = -data['RF2']['Node I_INDENTER.{0}'.format(ref_node_label)] 19 | disp_hist = -data['U2']['Node I_INDENTER.{0}'.format(ref_node_label)] 20 | 21 | time, force_l = force_hist[0,1].plotable() # Getting back force during loading 22 | time, disp_l = disp_hist[0,1].plotable() # Getting backdisplacement during loading 23 | time, force_u = force_hist[2].plotable() # Getting back force during unloading 24 | time, disp_u = disp_hist[2].plotable() # Getting backdisplacement during unloading 25 | 26 | # Dimensional analysis (E. Buckingham. Physical review, 4, 1914.) shows that the loading curve must be parabolic, let's build a parabolic fit 27 | 28 | 29 | C_factor = (force_hist[1] / disp_hist[1]**2).average() 30 | disp_fit = np.array(disp_hist[0,1].toArray()[1]) 31 | force_fit = C_factor * disp_fit**2 32 | 33 | 34 | plt.figure() 35 | plt.clf() 36 | plt.plot(disp_l, force_l, 'r-', linewidth = 2., label = 'Loading') 37 | plt.plot(disp_u, force_u, 'b-', linewidth = 2., label = 'Unloading') 38 | plt.plot(disp_fit, force_fit, 'g-', linewidth = 2., label = 'Parabolic fit') 39 | plt.xlabel('Displacement $d$') 40 | plt.ylabel('Force $F$') 41 | plt.grid() 42 | plt.legend(loc = 'upper left') 43 | plt.show() 44 | -------------------------------------------------------------------------------- /doc/example_code/future/clean_connectivity.py: -------------------------------------------------------------------------------- 1 | from abapy.future import Mesh, parseInp, writeInp, writeMsh, Node, Tri3, Quad4 2 | import numpy as np 3 | 4 | m = Mesh() 5 | 6 | m.nodes[1] = Node( (0., 1., 0.) ) 7 | m.nodes[2] = Node( (0., 2., 0.) ) 8 | m.nodes[3] = Node( (0., 3., 0.) ) 9 | m.nodes[4] = Node( (1., 4., 0.) ) 10 | m.nodes[5] = Node( (1., 3., 0.) ) 11 | m.nodes[6] = Node( (1., 2., 0.) ) 12 | m.nodes[7] = Node( (2., 1., 0.) ) 13 | m.nodes[8] = Node( (1., 0., 0.) ) 14 | m.nodes[9] = Node( (2., 3., 0.) ) 15 | m.nodes[10] = Node( (2., 2., 0.) ) 16 | 17 | 18 | m.elements[1] = Quad4(conn = (1,8,7,6)) 19 | m.elements[2] = Quad4(conn = (2,6,5,3)) 20 | m.elements[3] = Tri3(conn = (1,6,2)) 21 | m.elements[4] = Tri3(conn = (3,5,4)) 22 | m.elements[5] = Tri3(conn = (6,7,10)) 23 | m.elements[6] = Quad4(conn = (5,6,10,9)) 24 | 25 | m = m.extrude(translation = [0, 0, 1], layers = 1) 26 | 27 | def transformation(x, y, z): 28 | theta = np.pi / 2. * z 29 | r = x.copy() 30 | x = r * np.cos(theta) 31 | z = r * np.sin(theta) 32 | return x, y, z 33 | 34 | m = m.transform(transformation) 35 | mapping = m.overlapping_nodes() 36 | m = m.merge_nodes(mapping) 37 | m2 = m.copy() 38 | """ 39 | m2.elements.clear() 40 | counter = 1 41 | for label in m.elements.keys(): 42 | el = m.elements[label] 43 | simplices = el.simplex_decomposition() 44 | for simplex in simplices: 45 | m2.elements[cunter] = simplex 46 | counter +=1 47 | """ 48 | m2 = m2.clean_connectivity() 49 | 50 | 51 | writeInp(m2, path = "clean_connectivity.inp", mapping = {"Tri3": "CAX3", "Quad4": "CAX4", "Hexa8": "C3D8", "Prism6":"C3D6", "Tetra4": "C3D4"}) 52 | writeMsh(m2, path = "clean_connectivity.msh") 53 | 54 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-draw_3D.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | from abapy.indentation import IndentationMesh 3 | import matplotlib.pyplot as plt 4 | from matplotlib.path import Path 5 | import matplotlib.patches as patches 6 | import matplotlib.collections as collections 7 | import mpl_toolkits.mplot3d as a3 8 | import numpy as np 9 | from matplotlib import cm 10 | from scipy import interpolate 11 | 12 | def vector_function(x, y, z, labels): 13 | """ 14 | Vector function used to produced the displacement field. 15 | """ 16 | r0 = 1. 17 | theta = .5 * np.pi * x 18 | r = y + r0 19 | ux = -x + r * np.cos(theta**2) 20 | uy = -y + r * np.sin(theta**2) 21 | uz = 0. * z 22 | return ux, uy, uz 23 | 24 | def scalar_function(x, y, z, labels): 25 | """ 26 | Scalar function used to produced the plotted field. 27 | """ 28 | return x**2 + y**2 29 | #MESH GENERATION 30 | N1, N2 = 30, 30 31 | l1, l2 = .75, 1. 32 | m = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) 33 | #FIELDS GENERATION 34 | u = m.nodes.eval_vectorFunction(vector_function) 35 | m.add_field(u, "u") 36 | f = m.nodes.eval_function(scalar_function) 37 | m.add_field(f, "f") 38 | #PLOTS 39 | fig = plt.figure(0) 40 | plt.clf() 41 | ax = fig.add_subplot(1,1,1) 42 | m.draw(ax, 43 | disp_func = lambda fields : fields["u"], 44 | field_func = lambda fields : fields["f"], 45 | cmap = cm.jet, 46 | cbar_orientation = "vertical", 47 | contour = False, 48 | contour_colors = "black", 49 | alpha = 1., 50 | cmap_levels = 10, 51 | edge_width = .1) 52 | ax.set_aspect("equal") 53 | plt.grid() 54 | plt.xlabel("$x$ position") 55 | plt.ylabel("$y$ position") 56 | plt.show() 57 | 58 | -------------------------------------------------------------------------------- /doc/example_code/mesh/TransitionMesh.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import TransitionMesh 2 | from matplotlib import pyplot as plt 3 | 4 | fig = plt.figure(0) 5 | plt.clf() 6 | 7 | ax = fig.add_subplot(221) 8 | ax.set_aspect("equal") 9 | ax.set_title('direction = x+') 10 | m = TransitionMesh(N1 = 4, N2 = 2,l1 = 1., l2 = 2., direction = "x+") 11 | patches = m.dump2polygons() 12 | bb = m.nodes.boundingBox() 13 | patches.set_linewidth(1.) 14 | ax.add_collection(patches) 15 | plt.xlim(bb[0]) 16 | plt.ylim(bb[1]) 17 | plt.xticks([]) 18 | plt.yticks([]) 19 | 20 | ax = fig.add_subplot(222) 21 | ax.set_aspect("equal") 22 | ax.set_title('direction = x-') 23 | m = TransitionMesh(N1 =32, N2 = 4,l1 = 1., l2 = 2., direction = "x-") 24 | patches = m.dump2polygons() 25 | bb = m.nodes.boundingBox() 26 | patches.set_linewidth(1.) 27 | ax.add_collection(patches) 28 | plt.xlim(bb[0]) 29 | plt.ylim(bb[1]) 30 | plt.xticks([]) 31 | plt.yticks([]) 32 | 33 | ax = fig.add_subplot(223) 34 | ax.set_aspect("equal") 35 | ax.set_title('direction = y+') 36 | m = TransitionMesh(N1 = 16, N2 = 2,l1 = 1, l2 = 1., direction = "y+") 37 | patches = m.dump2polygons() 38 | bb = m.nodes.boundingBox() 39 | patches.set_linewidth(1.) 40 | ax.add_collection(patches) 41 | plt.xlim(bb[0]) 42 | plt.ylim(bb[1]) 43 | plt.xticks([]) 44 | plt.yticks([]) 45 | 46 | ax = fig.add_subplot(224) 47 | ax.set_aspect("equal") 48 | ax.set_title('direction = y-') 49 | m = TransitionMesh(N1 =32, N2 = 8,l1 = 4., l2 = 1., direction = "y-") 50 | patches = m.dump2polygons() 51 | bb = m.nodes.boundingBox() 52 | patches.set_linewidth(1.) 53 | ax.add_collection(patches) 54 | plt.xlim(bb[0]) 55 | plt.ylim(bb[1]) 56 | plt.xticks([]) 57 | plt.yticks([]) 58 | 59 | plt.show() 60 | 61 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Mesh-sweep.vtk: -------------------------------------------------------------------------------- 1 | # vtk DataFile Version 2.0 2 | Unstructured Grid Example 3 | ASCII 4 | DATASET UNSTRUCTURED_GRID 5 | POINTS 33 float 6 | 0.0 0.0 0.0 7 | 0.5 0.0 0.0 8 | 1.0 0.0 0.0 9 | 0.0 0.5 0.0 10 | 0.5 0.5 0.0 11 | 1.0 0.5 0.0 12 | 0.0 1.0 0.0 13 | 0.5 1.0 0.0 14 | 1.0 1.0 0.0 15 | 0.461939752102 0.0 -0.191341713071 16 | 0.923879504204 0.0 -0.382683426142 17 | 0.461939752102 0.5 -0.191341713071 18 | 0.923879504204 0.5 -0.382683426142 19 | 0.461939752102 1.0 -0.191341713071 20 | 0.923879504204 1.0 -0.382683426142 21 | 0.353553384542 0.0 -0.353553384542 22 | 0.707106769085 0.0 -0.707106769085 23 | 0.353553384542 0.5 -0.353553384542 24 | 0.707106769085 0.5 -0.707106769085 25 | 0.353553384542 1.0 -0.353553384542 26 | 0.707106769085 1.0 -0.707106769085 27 | 0.191341713071 0.0 -0.461939752102 28 | 0.382683426142 0.0 -0.923879504204 29 | 0.191341713071 0.5 -0.461939752102 30 | 0.382683426142 0.5 -0.923879504204 31 | 0.191341713071 1.0 -0.461939752102 32 | 0.382683426142 1.0 -0.923879504204 33 | 3.06161713146e-17 0.0 -0.5 34 | 6.12323426293e-17 0.0 -1.0 35 | 3.06161713146e-17 0.5 -0.5 36 | 6.12323426293e-17 0.5 -1.0 37 | 3.06161713146e-17 1.0 -0.5 38 | 6.12323426293e-17 1.0 -1.0 39 | CELLS 16 128 40 | 6 0 1 9 3 4 11 41 | 8 1 2 5 4 9 10 12 11 42 | 6 3 4 11 6 7 13 43 | 8 4 5 8 7 11 12 14 13 44 | 6 0 9 15 3 11 17 45 | 8 9 10 12 11 15 16 18 17 46 | 6 3 11 17 6 13 19 47 | 8 11 12 14 13 17 18 20 19 48 | 6 0 15 21 3 17 23 49 | 8 15 16 18 17 21 22 24 23 50 | 6 3 17 23 6 19 25 51 | 8 17 18 20 19 23 24 26 25 52 | 6 0 21 27 3 23 29 53 | 8 21 22 24 23 27 28 30 29 54 | 6 3 23 29 6 25 31 55 | 8 23 24 26 25 29 30 32 31 56 | CELL_TYPES 16 57 | 13 58 | 12 59 | 13 60 | 12 61 | 13 62 | 12 63 | 13 64 | 12 65 | 13 66 | 12 67 | 13 68 | 12 69 | 13 70 | 12 71 | 13 72 | 12 73 | -------------------------------------------------------------------------------- /abapy/misc.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Miscellaneous 3 | ============= 4 | ''' 5 | 6 | import pickle 7 | import copy_reg 8 | import array 9 | 10 | 11 | 12 | def array_unpickler(data): 13 | return array.array(data[0], data[1:]) 14 | def array_pickler(arr): 15 | return array_unpickler, ("%s%s" % (arr.typecode, arr.tostring()),) 16 | copy_reg.pickle(array.ArrayType, array_pickler, array_unpickler) 17 | 18 | 19 | def load(name): 20 | ''' 21 | Loads back a pickled object. 22 | 23 | :param name: file name or path to file. 24 | :type name: string 25 | :rtype: unpickled object 26 | 27 | .. note:: This function allows clean array unpickling whereas standard ``pickle.load`` will raise an error if ``array.array`` are in the pickled object (which is the case of all objects in Abapy). 28 | ''' 29 | f = open(name, 'rb') 30 | out = pickle.load(f) 31 | f.close() 32 | return out 33 | 34 | def dump(data,name,protocol = 2): 35 | ''' 36 | Dumps an object to file using ``pickle``. 37 | 38 | :param data: object to dump. 39 | :type data: any 40 | :param name: file name or path to file. 41 | :type name: string 42 | 43 | .. note:: This function allows clean array pickling whereas standard ``pickle.dump`` will raise an error if ``array.array`` are in the pickled object (which is the case of all objects in Abapy). 44 | ''' 45 | f = open(name,'wb') 46 | pickle.dump(data,f,protocol) 47 | f.close() 48 | 49 | def read_file(path, ncol = 2, separator = None): 50 | """ 51 | Read a tabular data file and returns a `numpy.array` containing the data. Header lines must begin with a #. 52 | """ 53 | import numpy as np 54 | lines = open(path, "rb").readlines() 55 | out = [] 56 | for line in lines: 57 | if line[0] != "#": 58 | ldata = [] 59 | words = line.split() 60 | for i in xrange(ncol): 61 | ldata.append(float(words[i])) 62 | out.append(ldata) 63 | return np.array(out).transpose() 64 | 65 | 66 | -------------------------------------------------------------------------------- /abapy/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Abapy Documentation 3 | ================================= 4 | 5 | 6 | Abaqus Python "**AbaPy**" contains tools to build, postprocess and plot automatic finite element simulations using Abaqus. It is divided into four parts: 7 | * *mesh*: contains finite element mesh utilities allowing building, modifying, ploting and exporting to various formats. 8 | * *postproc*: contains utilities to read in Abaqus odb files and represent history and field outputs using custom classes. These classes allow easy calculations, export, storage (using pickle/cPickle). 9 | * *materials*: contains functions to preprocess materials before finite element simulations. 10 | * *indentation*: contains all indentation dedicated tools. 11 | * *advanced_examples*: contains examples using abapy and other python packages to perform research higher level tasks. 12 | 13 | .. plot:: example_code/logo/abapy_logo.py 14 | 15 | 16 | Contributors: 17 | * Ludovic Charleux 18 | * Laurent Bizet 19 | * Arnaud Faivre 20 | * Moustapha Issack 21 | * Vincent Keryvin 22 | 23 | 24 | For citation, please use the following link: 25 | 26 | .. raw:: html 27 | 28 | 10.5281/zenodo.17784 29 | 30 | 31 | Installation can be performed in many ways, here a two: 32 | 33 | * The right way: 34 | 35 | .. code-block:: bash 36 | 37 | pip install git+https://github.com/lcharleux/abapy.git 38 | 39 | * If you are contributing to the module, you can just clone the repository: 40 | 41 | .. code-block:: bash 42 | 43 | git clone https://github.com/lcharleux/abapy.git 44 | 45 | And remember to add the abapy/abapy directory to your ``PYTHONPATH``. For example, the following code can be used under Linux (in ``.bashrc`` or ``.profile``): 46 | 47 | .. code-block:: bash 48 | 49 | export PYTHONPATH=$PYTHONPATH:yourpath/abapy 50 | 51 | 52 | .. toctree:: 53 | :maxdepth: 2 54 | ''' 55 | 56 | import indentation, materials, mesh, misc, postproc 57 | -------------------------------------------------------------------------------- /doc/advanced_examples.rst: -------------------------------------------------------------------------------- 1 | Advanced Examples 2 | ================== 3 | 4 | Here we show some fancier examples using the tools available in abapy all together. 5 | 6 | Indentation 7 | ----------- 8 | 9 | 2D / 3D , multi material indentation 10 | _______________________________________ 11 | 12 | All files used in this example are available in ``doc/advanced_examples/indentation/simulations`` 13 | 14 | In this example, we focus on the indentation behavior of an elastic-plastic (von Mises) sample indented by an axisymmetric cone. To build this example, we first need to create 2 classes: ``Simulation`` and ``Database_Manager`` as follows in the file :download:`classes.py `: 15 | 16 | .. literalinclude:: advanced_examples/indentation/simulations/classes.py 17 | 18 | Then we need to define some basic settings here :download:`settings.py `: 19 | 20 | .. literalinclude:: advanced_examples/indentation/simulations/settings.py 21 | 22 | Then we can load simulations request in the SQLite database :download:`settings.py `: 23 | 24 | .. literalinclude:: advanced_examples/indentation/simulations/loader.py 25 | 26 | After executing loader, we see that all simulation have been entered in the database: 27 | 28 | >>> execfile('loader.py') 29 | 30 | Then we just launch the simulations using :download:`launcher.py `: 31 | 32 | .. literalinclude:: advanced_examples/indentation/simulations/launcher.py 33 | 34 | 35 | >>> execfile('launcher.py') 36 | 37 | 38 | And now after these fast simulations it's time to collect some results or perform some reverse analysis. Here is a very brief example of ploting :download:`basic_plot_DP.py `: 39 | 40 | .. literalinclude:: advanced_examples/indentation/simulations/basic_plot_DP.py 41 | 42 | .. image:: advanced_examples/indentation/simulations/plots/basic_plot_mesh_DP.png 43 | .. image:: advanced_examples/indentation/simulations/plots/basic_plot_DP.png 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Nodes-eval_vectorFunction.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import Mesh, Nodes, RegularQuadMesh 2 | import matplotlib.pyplot as plt 3 | from numpy import cos, sin, pi 4 | def function(x, y, z, labels): 5 | r0 = 1. 6 | theta = 2 * pi * x 7 | r = y + r0 8 | ux = -x + r * cos(theta) 9 | uy = -y + r * sin(theta) 10 | uz = 0. * z 11 | return ux, uy, uz 12 | N1, N2 = 100, 25 13 | l1, l2 = 1., 1. 14 | Ncolor = 20 15 | mesh = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) 16 | vectorField = mesh.nodes.eval_vectorFunction(function) 17 | field = vectorField.get_coord(1) # we chose to plot coordinate 1 18 | field2 = vectorField.get_coord(2) # we chose to plot coordinate 1 19 | field3 = vectorField.norm() # we chose to plot norm 20 | fig = plt.figure(figsize=(16,4)) 21 | ax = fig.add_subplot(131) 22 | ax2 = fig.add_subplot(132) 23 | ax3 = fig.add_subplot(133) 24 | ax.set_aspect('equal') 25 | ax2.set_aspect('equal') 26 | ax3.set_aspect('equal') 27 | ax.set_xticks([]) 28 | ax.set_yticks([]) 29 | ax2.set_xticks([]) 30 | ax2.set_yticks([]) 31 | ax3.set_xticks([]) 32 | ax3.set_yticks([]) 33 | ax.set_frame_on(False) 34 | ax2.set_frame_on(False) 35 | ax3.set_frame_on(False) 36 | ax.set_title(r'$V_1$') 37 | ax2.set_title(r'$V_2$') 38 | ax3.set_title(r'$\sqrt{\vec{V}^2}$') 39 | ax3.set_title(r'$||\vec{V}||$') 40 | x,y,z = mesh.get_edges() # Mesh edges 41 | xt,yt,zt = mesh.convert2tri3().get_edges() # Triangular mesh edges 42 | xb,yb,zb = mesh.get_border() 43 | X,Y,Z,tri = mesh.dump2triplot() 44 | ax.plot(xb,yb,'k-', linewidth = 2.) 45 | ax.tricontourf(X,Y,tri,field.data, Ncolor) 46 | ax.tricontour(X,Y,tri,field.data, Ncolor, colors = 'black') 47 | ax2.plot(xb,yb,'k-', linewidth = 2.) 48 | ax2.tricontourf(X,Y,tri,field2.data, Ncolor) 49 | ax2.tricontour(X,Y,tri,field2.data, Ncolor, colors = 'black') 50 | ax3.plot(xb,yb,'k-', linewidth = 2.) 51 | ax3.tricontourf(X,Y,tri,field3.data, Ncolor) 52 | ax3.tricontour(X,Y,tri,field3.data, Ncolor, colors = 'black') 53 | ax.set_xlim([-.1*l1,1.1*l1]) 54 | ax.set_ylim([-.1*l2,1.1*l2]) 55 | ax2.set_xlim([-.1*l1,1.1*l1]) 56 | ax2.set_ylim([-.1*l2,1.1*l2]) 57 | ax3.set_xlim([-.1*l1,1.1*l1]) 58 | ax3.set_ylim([-.1*l2,1.1*l2]) 59 | plt.show() 60 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Nodes-eval_vectorFunction.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import Mesh, Nodes, RegularQuadMesh 2 | import matplotlib.pyplot as plt 3 | from numpy import cos, sin, pi 4 | def function(x, y, z, labels): 5 | r0 = 1. 6 | theta = 2 * pi * x 7 | r = y + r0 8 | ux = -x + r * cos(theta) 9 | uy = -y + r * sin(theta) 10 | uz = 0. * z 11 | return ux, uy, uz 12 | N1, N2 = 100, 25 13 | l1, l2 = 1., 1. 14 | Ncolor = 20 15 | mesh = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) 16 | vectorField = mesh.nodes.eval_vectorFunction(function) 17 | field = vectorField.get_coord(1) # we chose to plot coordinate 1 18 | field2 = vectorField.get_coord(2) # we chose to plot coordinate 1 19 | field3 = vectorField.norm() # we chose to plot norm 20 | fig = plt.figure(figsize=(16,4)) 21 | ax = fig.add_subplot(131) 22 | ax2 = fig.add_subplot(132) 23 | ax3 = fig.add_subplot(133) 24 | ax.set_aspect('equal') 25 | ax2.set_aspect('equal') 26 | ax3.set_aspect('equal') 27 | ax.set_xticks([]) 28 | ax.set_yticks([]) 29 | ax2.set_xticks([]) 30 | ax2.set_yticks([]) 31 | ax3.set_xticks([]) 32 | ax3.set_yticks([]) 33 | ax.set_frame_on(False) 34 | ax2.set_frame_on(False) 35 | ax3.set_frame_on(False) 36 | ax.set_title(r'$V_1$') 37 | ax2.set_title(r'$V_2$') 38 | ax3.set_title(r'$\sqrt{\vec{V}^2}$') 39 | ax3.set_title(r'$||\vec{V}||$') 40 | x,y,z = mesh.get_edges() # Mesh edges 41 | xt,yt,zt = mesh.convert2tri3().get_edges() # Triangular mesh edges 42 | xb,yb,zb = mesh.get_border() 43 | X,Y,Z,tri = mesh.dump2triplot() 44 | ax.plot(xb,yb,'k-', linewidth = 2.) 45 | ax.tricontourf(X,Y,tri,field.data, Ncolor) 46 | ax.tricontour(X,Y,tri,field.data, Ncolor, colors = 'black') 47 | ax2.plot(xb,yb,'k-', linewidth = 2.) 48 | ax2.tricontourf(X,Y,tri,field2.data, Ncolor) 49 | ax2.tricontour(X,Y,tri,field2.data, Ncolor, colors = 'black') 50 | ax3.plot(xb,yb,'k-', linewidth = 2.) 51 | ax3.tricontourf(X,Y,tri,field3.data, Ncolor) 52 | ax3.tricontour(X,Y,tri,field3.data, Ncolor, colors = 'black') 53 | ax.set_xlim([-.1*l1,1.1*l1]) 54 | ax.set_ylim([-.1*l2,1.1*l2]) 55 | ax2.set_xlim([-.1*l1,1.1*l1]) 56 | ax2.set_ylim([-.1*l2,1.1*l2]) 57 | ax3.set_xlim([-.1*l1,1.1*l1]) 58 | ax3.set_ylim([-.1*l2,1.1*l2]) 59 | plt.show() 60 | -------------------------------------------------------------------------------- /doc/example_code/indentation/MakeInp_plot.py: -------------------------------------------------------------------------------- 1 | from abapy.misc import load 2 | from matplotlib import pyplot as plt 3 | import matplotlib.gridspec as gridspec 4 | from matplotlib import mpl 5 | import numpy as np 6 | 7 | path_to_odb = '../../../../testing/' 8 | title0 = 'title0' 9 | title1 = 'title1' 10 | title2 = 'title2' 11 | N_levels = 10 # Number os isovalues 12 | levels = np.linspace(0., 0.3, N_levels) 13 | 14 | S = load(path_to_odb + 'indentation_S.pckl') 15 | mesh0 = load(path_to_odb + 'indentation_mesh.pckl') 16 | #mesh0 = mesh0['core_1'] 17 | point = (0., 0., 0.) 18 | normal = (1., 0., 0.) 19 | mesh1 = mesh0.apply_reflection(normal = normal, point = point) 20 | S = S[mesh0.nodes.labels.tolist()] 21 | x0, y0, z0, tri0 = mesh0.dump2triplot() 22 | xe0, ye0, ze0 = mesh0.get_edges() 23 | xb0, yb0, zb0 = mesh0.get_border() 24 | xlim0, ylim0, zlim0 = mesh0.nodes.boundingBox() 25 | x1, y1, z1, tri1 = mesh1.dump2triplot() 26 | xe1, ye1, ze1 = mesh1.get_edges() 27 | xb1, yb1, zb1 = mesh1.get_border() 28 | xlim2, ylim1, zlim1 = mesh1.nodes.boundingBox() 29 | 30 | 31 | field0 = S.get_component(12) # What to plot ? 32 | field1 = field0 # What other field to plot ? 33 | 34 | fig = plt.figure(0) 35 | plt.clf() 36 | 37 | sp0 = plt.subplot(122) 38 | sp1 = plt.subplot(121) 39 | sp0.set_title(title0) 40 | sp1.set_title(title1) 41 | sp0.set_xlabel('$r$', fontsize =15.) 42 | sp1.set_xlabel('$r$', fontsize =15.) 43 | sp1.set_ylabel('$z$', fontsize =15.) 44 | 45 | sp0.set_xticks([]) 46 | sp0.set_yticks([]) 47 | sp1.set_xticks([]) 48 | sp1.set_yticks([]) 49 | sp0.set_aspect('equal') 50 | sp1.set_aspect('equal') 51 | sp0.plot(xe0,ye0, 'k-', linewidth = .5) # edge ploting 52 | sp0.plot(xb0,yb0, 'k-', linewidth = .5) # edge ploting 53 | sp1.plot(xe1,ye1, 'k-', linewidth = .5) # edge ploting 54 | sp1.plot(xb1,yb1, 'k-', linewidth = .5) # edge ploting 55 | 56 | sp0.tricontourf(x0,y0,tri0,field0.data, levels = levels) 57 | cs0 = sp0.tricontour(x0,y0,tri0,field0.data, levels = levels, colors = 'black') 58 | sp1.tricontourf(x1,y1,tri1,field1.data, levels = levels) 59 | cs1 = sp1.tricontour(x1,y1,tri1,field1.data, levels = levels, colors = 'black') 60 | plt.clabel(cs1, fmt = '%2.2f', colors = 'w', fontsize=14) 61 | plt.clabel(cs0, fmt = '%2.2f', colors = 'w', fontsize=14) 62 | 63 | plt.show() 64 | -------------------------------------------------------------------------------- /doc/example_code/postproc/MakeFieldOutputReport.py: -------------------------------------------------------------------------------- 1 | from odbAccess import openOdb 2 | from abapy.postproc import MakeFieldOutputReport 3 | # Some settings 4 | odb_name = 'indentation.odb' 5 | report_name = 'indentation_core_step0_frame1_S11_nodes.rpt' 6 | step = 0 7 | frame = -1 8 | new_position = 'NODAL' 9 | original_position = 'INTEGRATION_POINT' 10 | field = 'S' 11 | sub_field = 11 12 | instance = 'I_SAMPLE' 13 | sub_set = 'CORE' 14 | sub_set_type = 'element' 15 | # Function testing 16 | odb = openOdb(odb_name) 17 | MakeFieldOutputReport( 18 | odb = odb, 19 | instance = instance, 20 | step = step, 21 | frame = frame, 22 | report_name = report_name, 23 | original_position = original_position, 24 | new_position = new_position, 25 | field = field, 26 | sub_field = sub_field, 27 | sub_set_type = sub_set_type, 28 | sub_set = sub_set) 29 | new_position = 'INTEGRATION_POINT' 30 | report_name = 'indentation_core_step0_frame1_S11_elements.rpt' 31 | MakeFieldOutputReport( 32 | odb = odb, 33 | instance = instance, 34 | step = step, 35 | frame = frame, 36 | report_name = report_name, 37 | original_position = original_position, 38 | new_position = new_position, 39 | field = field, 40 | sub_field = sub_field, 41 | sub_set_type = sub_set_type, 42 | sub_set = sub_set) 43 | new_position = 'ELEMENT_NODAL' 44 | report_name = 'indentation_core_step0_frame1_S11_element-nodal.rpt' 45 | MakeFieldOutputReport( 46 | odb = odb, 47 | instance = instance, 48 | step = step, 49 | frame = frame, 50 | report_name = report_name, 51 | original_position = original_position, 52 | new_position = new_position, 53 | field = field, 54 | sub_field = sub_field, 55 | sub_set_type = sub_set_type, 56 | sub_set = sub_set) 57 | field = 'U' 58 | sub_field = 'Magnitude' 59 | original_position = 'NODAL' 60 | new_position = 'NODAL' 61 | report_name = 'indentation_core_step0_frame1_U-MAG_nodal.rpt' 62 | MakeFieldOutputReport( 63 | odb = odb, 64 | instance = instance, 65 | step = step, 66 | frame = frame, 67 | report_name = report_name, 68 | original_position = original_position, 69 | new_position = new_position, 70 | field = field, 71 | sub_field = sub_field, 72 | sub_set_type = sub_set_type, 73 | sub_set = sub_set) 74 | -------------------------------------------------------------------------------- /doc/example_code/postproc/MakeFieldOutputReport.py~: -------------------------------------------------------------------------------- 1 | from odbAccess import openOdb 2 | from abapy.postproc import MakeFieldOutputReport 3 | # Some settings 4 | odb_name = 'indentation.odb' 5 | report_name = 'indentation_core_step0_frame1_S11_nodes.rpt' 6 | step = 0 7 | frame = -1 8 | new_position = 'NODAL' 9 | original_position = 'INTEGRATION_POINT' 10 | field = 'S' 11 | sub_field = 11 12 | instance = 'I_SAMPLE' 13 | sub_set = 'CORE' 14 | sub_set_type = 'element' 15 | # Function testing 16 | odb = openOdb(odb_name) 17 | MakeFieldOutputReport( 18 | odb = odb, 19 | instance = instance, 20 | step = step, 21 | frame = frame, 22 | report_name = report_name, 23 | original_position = original_position, 24 | new_position = new_position, 25 | field = field, 26 | sub_field = sub_field, 27 | sub_set_type = sub_set_type, 28 | sub_set = sub_set) 29 | new_position = 'INTEGRATION_POINT' 30 | report_name = 'indentation_core_step0_frame1_S11_elements.rpt' 31 | MakeFieldOutputReport( 32 | odb = odb, 33 | instance = instance, 34 | step = step, 35 | frame = frame, 36 | report_name = report_name, 37 | original_position = original_position, 38 | new_position = new_position, 39 | field = field, 40 | sub_field = sub_field, 41 | sub_set_type = sub_set_type, 42 | sub_set = sub_set) 43 | new_position = 'ELEMENT_NODAL' 44 | report_name = 'indentation_core_step0_frame1_S11_element-nodal.rpt' 45 | MakeFieldOutputReport( 46 | odb = odb, 47 | instance = instance, 48 | step = step, 49 | frame = frame, 50 | report_name = report_name, 51 | original_position = original_position, 52 | new_position = new_position, 53 | field = field, 54 | sub_field = sub_field, 55 | sub_set_type = sub_set_type, 56 | sub_set = sub_set) 57 | field = 'U' 58 | sub_field = 'MAGNITUDE' 59 | original_position = 'NODAL' 60 | new_position = 'NODAL' 61 | report_name = 'indentation_core_step0_frame1_U-MAG_nodal.rpt' 62 | MakeFieldOutputReport( 63 | odb = odb, 64 | instance = instance, 65 | step = step, 66 | frame = frame, 67 | report_name = report_name, 68 | original_position = original_position, 69 | new_position = new_position, 70 | field = field, 71 | sub_field = sub_field, 72 | sub_set_type = sub_set_type, 73 | sub_set = sub_set) 74 | -------------------------------------------------------------------------------- /doc/example_code/indentation/ContactData-interpolate.py: -------------------------------------------------------------------------------- 1 | from abapy.misc import load 2 | import numpy as np 3 | from matplotlib import pyplot as plt 4 | 5 | 6 | # In this case, a 3D FEM simulation has beed performed and the results are stored in the file ``ContactData_berk.pckl``. See ``Get_ContactData`` to understand how this data has been extracted from an Abaqus odb file. 7 | 8 | 9 | out = load('ContactData_berk.pckl') 10 | cd0 = out[1][-1] # First step data: loading 11 | cd1 = out[2][-1] # Second step data: unloading 12 | hmax = -cd0.min_altitude() 13 | 14 | # First let's map altitude and pressure on cartesian grids. 15 | x = np.linspace(-2., 2., 256) 16 | X, Y = np.meshgrid(x, x) 17 | 18 | Alt0, Press0 = cd0.interpolate(X, Y, method ='linear') 19 | Alt1, Press1 = cd1.interpolate(X, Y, method ='linear') 20 | Alt0 = Alt0 / hmax 21 | Alt1 = Alt1 / hmax 22 | 23 | # Now we wan to get some sections of the imprint 24 | s = np.linspace(0., 2., 256) 25 | s = np.append((-s)[::-1], s) 26 | theta0 = np.radians(0.01) 27 | theta1 = np.radians(15.) 28 | xs0 = np.cos(theta0) * s 29 | ys0 = np.sin(theta0) * s 30 | xs1 = np.cos(theta1) * s 31 | ys1 = np.sin(theta1) * s 32 | # Sections under full load 33 | Alt0_sec_l, Press0_sec_l = cd0.interpolate(xs0, ys0, method ='linear') 34 | Alt1_sec_l, Press1_sec_l = cd0.interpolate(xs1, ys1, method ='linear') 35 | Alt0_sec_l = Alt0_sec_l / hmax 36 | Alt1_sec_l = Alt1_sec_l / hmax 37 | # Sections after unloading 38 | Alt0_sec_u, Press0_sec_u = cd1.interpolate(xs0, ys0, method ='linear') 39 | Alt1_sec_u, Press1_sec_u = cd1.interpolate(xs1, ys1, method ='linear') 40 | Alt0_sec_u = Alt0_sec_u / hmax 41 | Alt1_sec_u = Alt1_sec_u / hmax 42 | 43 | 44 | 45 | 46 | 47 | fig = plt.figure() 48 | plt.clf() 49 | ax1 = fig.add_subplot(221) 50 | ax1.set_xticks([]) 51 | ax1.set_yticks([]) 52 | grad = plt.contourf(X, Y, Alt0, 10) 53 | plt.contour(X, Y, Alt0, 10, colors = 'black') 54 | plt.grid() 55 | plt.plot(xs0, ys0, 'b-') 56 | plt.plot(xs1, ys1, 'r-') 57 | ax1.set_aspect('equal') 58 | plt.title('Altitude Loaded') 59 | ax2 = fig.add_subplot(222) 60 | ax2.set_xticks([]) 61 | ax2.set_yticks([]) 62 | grad = plt.contourf(X, Y, Alt1, 10) 63 | plt.contour(X, Y, Alt1, 10, colors = 'black') 64 | plt.grid() 65 | plt.plot(xs0, ys0, 'b-') 66 | plt.plot(xs1, ys1, 'r-') 67 | ax2.set_aspect('equal') 68 | plt.title('Altitude Unloaded') 69 | ax3 = fig.add_subplot(223) 70 | ax3.set_ylim([-1,0.3]) 71 | plt.plot(s, Alt0_sec_l, 'b-') 72 | plt.plot(s, Alt1_sec_l, 'r-') 73 | plt.title('Cross sections') 74 | plt.grid() 75 | ax4 = fig.add_subplot(224) 76 | ax4.set_ylim([-1,0.3]) 77 | plt.plot(s, Alt0_sec_u, 'b-') 78 | plt.plot(s, Alt1_sec_u, 'r-') 79 | plt.title('Cross sections') 80 | plt.grid() 81 | plt.show() 82 | 83 | 84 | -------------------------------------------------------------------------------- /doc/mesh.rst: -------------------------------------------------------------------------------- 1 | Mesh 2 | ==== 3 | 4 | Mesh processing tools. 5 | 6 | Nodes 7 | ~~~~~ 8 | 9 | .. autoclass:: abapy.mesh.Nodes 10 | 11 | Add/remove/get data 12 | ___________________ 13 | 14 | .. automethod:: abapy.mesh.Nodes.add_node 15 | .. automethod:: abapy.mesh.Nodes.drop_node 16 | .. automethod:: abapy.mesh.Nodes.add_set 17 | .. automethod:: abapy.mesh.Nodes.add_set_by_func 18 | .. automethod:: abapy.mesh.Nodes.drop_set 19 | 20 | Modifications 21 | _____________ 22 | 23 | .. automethod:: abapy.mesh.Nodes.translate 24 | .. automethod:: abapy.mesh.Nodes.apply_displacement 25 | .. automethod:: abapy.mesh.Nodes.closest_node 26 | .. automethod:: abapy.mesh.Nodes.replace_node 27 | .. automethod:: abapy.mesh.Mesh.apply_reflection 28 | 29 | Export 30 | ______ 31 | 32 | .. automethod:: abapy.mesh.Nodes.dump2inp 33 | 34 | 35 | Tools 36 | _____ 37 | 38 | .. automethod:: abapy.mesh.Nodes.eval_function 39 | .. automethod:: abapy.mesh.Nodes.eval_vectorFunction 40 | .. automethod:: abapy.mesh.Nodes.eval_tensorFunction 41 | .. automethod:: abapy.mesh.Nodes.boundingBox 42 | 43 | Mesh 44 | ~~~~ 45 | 46 | .. autoclass:: abapy.mesh.Mesh 47 | 48 | Add/remove/get data 49 | ___________________ 50 | 51 | .. automethod:: abapy.mesh.Mesh.add_element 52 | .. automethod:: abapy.mesh.Mesh.drop_element 53 | .. automethod:: abapy.mesh.Mesh.drop_node 54 | .. automethod:: abapy.mesh.Mesh.add_set 55 | .. automethod:: abapy.mesh.Mesh.drop_set 56 | .. automethod:: abapy.mesh.Mesh.add_surface 57 | .. automethod:: abapy.mesh.Mesh.node_set_to_surface 58 | .. automethod:: abapy.mesh.Mesh.replace_node 59 | .. automethod:: abapy.mesh.Mesh.simplify_nodes 60 | .. automethod:: abapy.mesh.Mesh.add_field 61 | 62 | Useful data 63 | ___________________ 64 | 65 | .. automethod:: abapy.mesh.Mesh.centroids 66 | .. automethod:: abapy.mesh.Mesh.volume 67 | 68 | Modifications 69 | _____________ 70 | 71 | .. automethod:: abapy.mesh.Mesh.extrude 72 | .. automethod:: abapy.mesh.Mesh.sweep 73 | .. automethod:: abapy.mesh.Mesh.union 74 | .. automethod:: abapy.mesh.Mesh.apply_reflection 75 | 76 | Export 77 | ______ 78 | 79 | .. automethod:: abapy.mesh.Mesh.dump2inp 80 | .. automethod:: abapy.mesh.Mesh.dump2vtk 81 | 82 | Ploting tools 83 | _____________ 84 | 85 | .. automethod:: abapy.mesh.Mesh.convert2tri3 86 | .. automethod:: abapy.mesh.Mesh.dump2triplot 87 | .. automethod:: abapy.mesh.Mesh.get_edges 88 | .. automethod:: abapy.mesh.Mesh.get_border 89 | .. automethod:: abapy.mesh.Mesh.dump2polygons 90 | .. automethod:: abapy.mesh.Mesh.draw 91 | 92 | Mesh generation 93 | ~~~~~~~~~~~~~~~ 94 | 95 | ``RegularQuadMesh`` functions 96 | _____________________________ 97 | .. autofunction:: abapy.mesh.RegularQuadMesh 98 | .. autofunction:: abapy.mesh.RegularQuadMesh_like 99 | 100 | Other meshes 101 | __________________ 102 | .. autofunction:: abapy.mesh.TransitionMesh 103 | 104 | .. note:: see also in ``abapy.indentation`` for indentation dedicated meshes. 105 | 106 | 107 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Nodes-eval_tensorFunction.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import Mesh, Nodes, RegularQuadMesh 2 | import matplotlib.pyplot as plt 3 | from numpy import cos, sin, pi, linspace 4 | def boussinesq(r, z, theta, labels): 5 | ''' 6 | Stress solution of the Boussinesq point loading of semi infinite elastic half space for a force F = 1. and nu = 0.3 7 | ''' 8 | from math import pi 9 | from numpy import zeros_like 10 | nu = 0.3 11 | rho = (r**2 + z**2)**.5 12 | s_rr = -1./(2. * pi * rho**2) * ( (-3. * r**2 * z)/(rho**3) + (1.-2. * nu)*rho / (rho + z) ) 13 | #s_rr = 1./(2.*pi) *( (1-2*nu) * ( r**-2 -z / (rho * r**2)) - 3 * z * r**2 / rho**5 ) 14 | s_zz = 3. / (2. *pi ) * z**3 / rho**5 15 | s_tt = -( 1. - 2. * nu) / (2. * pi * rho**2 ) * ( z/rho - rho / (rho + z) ) 16 | #s_tt = ( 1. - 2. * nu) / (2. * pi ) * ( 1. / r**2 -z/( rho * r**2) -z / rho**3 ) 17 | s_rz = -3./ (2. * pi) * r * z**2 / rho **5 18 | s_rt = zeros_like(r) 19 | s_zt = zeros_like(r) 20 | return s_rr, s_zz, s_tt, s_rz, s_rt, s_zt 21 | 22 | return ux, uy, uz 23 | 24 | 25 | N1, N2 = 50, 50 26 | l1, l2 = 1., 1. 27 | Ncolor = 200 28 | levels = linspace(0., 10., 20) 29 | 30 | mesh = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) 31 | # Finding the node located at x = y =0.: 32 | nodes = mesh.nodes 33 | for i in xrange(len(nodes.labels)): 34 | if nodes.x[i] == 0. and nodes.y[i] == 0.: node = nodes.labels[i] 35 | mesh.drop_node(node) 36 | tensorField = mesh.nodes.eval_tensorFunction(boussinesq) 37 | field = tensorField.get_component(22) # sigma_zz 38 | field2 = tensorField.vonmises() # von Mises stress 39 | field3 = tensorField.pressure() # pressure 40 | 41 | fig = plt.figure(figsize=(16,4)) 42 | ax = fig.add_subplot(131) 43 | ax2 = fig.add_subplot(132) 44 | ax3 = fig.add_subplot(133) 45 | ax.set_aspect('equal') 46 | ax2.set_aspect('equal') 47 | ax3.set_aspect('equal') 48 | ax.set_xticks([]) 49 | ax.set_yticks([]) 50 | ax2.set_xticks([]) 51 | ax2.set_yticks([]) 52 | ax3.set_xticks([]) 53 | ax3.set_yticks([]) 54 | ax.set_frame_on(False) 55 | ax2.set_frame_on(False) 56 | ax3.set_frame_on(False) 57 | ax.set_title(r'$\sigma_{zz}$') 58 | ax2.set_title(r'Von Mises $\sigma_{eq}$') 59 | ax3.set_title(r'Pressure $p$') 60 | xt,yt,zt = mesh.convert2tri3().get_edges() # Triangular mesh edges 61 | xb,yb,zb = mesh.get_border() 62 | 63 | X,Y,Z,tri = mesh.dump2triplot() 64 | 65 | ax.plot(xb,yb,'k-', linewidth = 2.) 66 | ax.tricontourf(X,Y,tri,field.data, levels = levels) 67 | ax.tricontour(X,Y,tri,field.data, levels = levels, colors = 'black') 68 | ax2.plot(xb,yb,'k-', linewidth = 2.) 69 | ax2.tricontourf(X,Y,tri,field2.data, levels = levels) 70 | ax2.tricontour(X,Y,tri,field2.data, levels = levels, colors = 'black') 71 | ax3.plot(xb,yb,'k-', linewidth = 2.) 72 | ax3.tricontourf(X,Y,tri,field3.data, levels = sorted(-levels)) 73 | ax3.tricontour(X,Y,tri,field3.data, levels = sorted(-levels), colors = 'black') 74 | ax.set_xlim([-.1*l1,1.1*l1]) 75 | ax.set_ylim([-.1*l2,1.1*l2]) 76 | ax2.set_xlim([-.1*l1,1.1*l1]) 77 | ax2.set_ylim([-.1*l2,1.1*l2]) 78 | ax3.set_xlim([-.1*l1,1.1*l1]) 79 | ax3.set_ylim([-.1*l2,1.1*l2]) 80 | plt.show() 81 | 82 | -------------------------------------------------------------------------------- /doc/example_code/mesh/Nodes-eval_tensorFunction.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import Mesh, Nodes, RegularQuadMesh 2 | import matplotlib.pyplot as plt 3 | from numpy import cos, sin, pi, linspace 4 | def boussinesq(r, z, theta, labels): 5 | ''' 6 | Stress solution of the Boussinesq point loading of semi infinite elastic half space for a force F = 1. and nu = 0.3 7 | ''' 8 | from math import pi 9 | from numpy import zeros_like 10 | nu = 0.3 11 | rho = (r**2 + z**2)**.5 12 | s_rr = -1./(2. * pi * rho**2) * ( (-3. * r**2 * z)/(rho**3) + (1.-2. * nu)*rho / (rho + z) ) 13 | #s_rr = 1./(2.*pi) *( (1-2*nu) * ( r**-2 -z / (rho * r**2)) - 3 * z * r**2 / rho**5 ) 14 | s_zz = - 3. / (2. *pi ) * z**3 / rho**5 15 | s_tt = -( 1. - 2. * nu) / (2. * pi * rho**2 ) * ( z/rho - rho / (rho + z) ) 16 | #s_tt = ( 1. - 2. * nu) / (2. * pi ) * ( 1. / r**2 -z/( rho * r**2) -z / rho**3 ) 17 | s_rz = -3./ (2. * pi) * r * z**2 / rho **5 18 | s_rt = zeros_like(r) 19 | s_zt = zeros_like(r) 20 | return s_rr, s_zz, s_tt, s_rz, s_rt, s_zt 21 | 22 | return ux, uy, uz 23 | 24 | 25 | N1, N2 = 50, 50 26 | l1, l2 = 1., 1. 27 | Ncolor = 200 28 | levels = linspace(0., 10., 20) 29 | 30 | mesh = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) 31 | # Finding the node located at x = y =0.: 32 | nodes = mesh.nodes 33 | for i in xrange(len(nodes.labels)): 34 | if nodes.x[i] == 0. and nodes.y[i] == 0.: node = nodes.labels[i] 35 | mesh.drop_node(node) 36 | tensorField = mesh.nodes.eval_tensorFunction(boussinesq) 37 | field = tensorField.get_component(22) # sigma_zz 38 | field2 = tensorField.vonmises() # von Mises stress 39 | field3 = tensorField.pressure() # pressure 40 | 41 | fig = plt.figure(figsize=(16,4)) 42 | ax = fig.add_subplot(131) 43 | ax2 = fig.add_subplot(132) 44 | ax3 = fig.add_subplot(133) 45 | ax.set_aspect('equal') 46 | ax2.set_aspect('equal') 47 | ax3.set_aspect('equal') 48 | ax.set_xticks([]) 49 | ax.set_yticks([]) 50 | ax2.set_xticks([]) 51 | ax2.set_yticks([]) 52 | ax3.set_xticks([]) 53 | ax3.set_yticks([]) 54 | ax.set_frame_on(False) 55 | ax2.set_frame_on(False) 56 | ax3.set_frame_on(False) 57 | ax.set_title(r'$\sigma_{zz}$') 58 | ax2.set_title(r'Von Mises $\sigma_{eq}$') 59 | ax3.set_title(r'Pressure $p$') 60 | xt,yt,zt = mesh.convert2tri3().get_edges() # Triangular mesh edges 61 | xb,yb,zb = mesh.get_border() 62 | 63 | X,Y,Z,tri = mesh.dump2triplot() 64 | 65 | ax.plot(xb,yb,'k-', linewidth = 2.) 66 | ax.tricontourf(X,Y,tri,field.data, levels = levels) 67 | ax.tricontour(X,Y,tri,field.data, levels = levels, colors = 'black') 68 | ax2.plot(xb,yb,'k-', linewidth = 2.) 69 | ax2.tricontourf(X,Y,tri,field2.data, levels = levels) 70 | ax2.tricontour(X,Y,tri,field2.data, levels = levels, colors = 'black') 71 | ax3.plot(xb,yb,'k-', linewidth = 2.) 72 | ax3.tricontourf(X,Y,tri,field3.data, levels = sorted(-levels)) 73 | ax3.tricontour(X,Y,tri,field3.data, levels = sorted(-levels), colors = 'black') 74 | ax.set_xlim([-.1*l1,1.1*l1]) 75 | ax.set_ylim([-.1*l2,1.1*l2]) 76 | ax2.set_xlim([-.1*l1,1.1*l1]) 77 | ax2.set_ylim([-.1*l2,1.1*l2]) 78 | ax3.set_xlim([-.1*l1,1.1*l1]) 79 | ax3.set_ylim([-.1*l2,1.1*l2]) 80 | plt.show() 81 | 82 | -------------------------------------------------------------------------------- /doc/example_code/postproc/indentation_core_step0_frame1_S11_elements.rpt: -------------------------------------------------------------------------------- 1 | ******************************************************************************** 2 | Field Output Report, written Fri Apr 27 10:07:46 2012 3 | 4 | Source 1 5 | --------- 6 | 7 | ODB: /home/lcharleux/Documents/Prog/modules/python/abapy/doc/example_code/postproc/indentation.odb 8 | Step: LOADING0 9 | Frame: Increment 10: Step Time = 1.000 10 | 11 | Loc 1 : Integration point values from source 1 12 | 13 | Output sorted by column "Element Label". 14 | 15 | Field Output reported at integration points for region: I_SAMPLE.Region_1 16 | 17 | Element Int S.S11 18 | Label Pt @Loc 1 19 | ------------------------------------------------- 20 | 1 1 1.24864E-03 21 | 1 2 -149.652E-06 22 | 1 3 892.497E-06 23 | 1 4 -239.819E-06 24 | 2 1 -1.00790E-03 25 | 2 2 -1.22918E-03 26 | 2 3 -1.81742E-03 27 | 2 4 -2.03871E-03 28 | 3 1 -5.57126E-03 29 | 3 2 -7.88495E-03 30 | 3 3 -6.14909E-03 31 | 3 4 -7.57448E-03 32 | 4 1 -1.46913E-03 33 | 4 2 -1.96458E-03 34 | 4 3 -1.79589E-03 35 | 4 4 -1.55563E-03 36 | 5 1 -279.052E-06 37 | 5 2 -112.742E-06 38 | 5 3 -237.106E-06 39 | 5 4 -84.3511E-06 40 | 6 1 7.52621E-06 41 | 6 2 -39.8219E-06 42 | 6 3 -15.0218E-06 43 | 6 4 -55.0932E-06 44 | 7 1 -73.1623E-06 45 | 7 2 -498.921E-06 46 | 7 3 -107.325E-06 47 | 7 4 -522.114E-06 48 | 8 1 -104.111E-06 49 | 8 2 -50.8303E-06 50 | 8 3 -99.8494E-06 51 | 8 4 -47.9453E-06 52 | 11 1 27.7503E-06 53 | 11 2 16.7550E-06 54 | 11 3 42.2174E-06 55 | 11 4 25.9816E-06 56 | 12 1 -6.29192E-06 57 | 12 2 -14.0480E-06 58 | 12 3 -19.1944E-06 59 | 12 4 -30.6470E-06 60 | 13 1 125.248E-06 61 | 13 2 148.608E-06 62 | 13 3 233.326E-06 63 | 13 4 267.825E-06 64 | 14 1 73.6469E-06 65 | 14 2 7.39159E-06 66 | 14 3 54.6300E-06 67 | 14 4 -43.1833E-06 68 | 69 | 70 | -------------------------------------------------------------------------------- /doc/example_code/logo/abapy_logo.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | from matplotlib import pyplot as plt 3 | import numpy as np 4 | from copy import deepcopy 5 | N1, N2 = 4, 16 6 | l1, l2 = 1., 1. 7 | 8 | def A(N1, N2, l1, l2): 9 | m = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1/4., l2 = l2) 10 | def U(x,y,z,label): 11 | ymax, xmax = y.max(), x.max() 12 | ux = y/ymax*xmax 13 | uy = 0.*x 14 | uz = 0.*x 15 | return ux, uy, uz 16 | u = m.nodes.eval_vectorFunction(U) 17 | m.nodes.apply_displacement(u) 18 | m.union( m.apply_reflection(point = (l1/2., 0., 0.), normal = (1., 0., 0.) ) ) 19 | return m 20 | 21 | def B(N1, N2, l1, l2): 22 | m = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1/4., l2 = l2) 23 | m1 = RegularQuadMesh(N1 = N2, N2 = N1, l1 = 1., l2 = l2/6.) 24 | def U(x, y, z, labels): 25 | r0y = l2/12. 26 | r0x = r0y 27 | theta = np.pi * (x-.5) 28 | rx = y + r0x 29 | ry = y + r0y 30 | ux = -x + rx * np.cos(theta) 31 | uy = -y + ry * np.sin(theta) 32 | uz = 0. * z 33 | return ux, uy, uz 34 | u = m1.nodes.eval_vectorFunction(U) 35 | m1.nodes.apply_displacement(u) 36 | m1.nodes.translate(x = l1/4., y = l2/4.) 37 | m2 = deepcopy(m1) 38 | m2.nodes.translate(y=l2/2.) 39 | m.union(m1) 40 | m.union(m2) 41 | return m 42 | 43 | def P(N1, N2, l1, l2): 44 | m = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1/4., l2 = l2) 45 | m1 = RegularQuadMesh(N1 = N2, N2 = N1, l1 = 1., l2 = l2/6.) 46 | def U(x, y, z, labels): 47 | r0y = l2/12. 48 | r0x = r0y 49 | theta = np.pi * (x-.5) 50 | rx = y + r0x 51 | ry = y + r0y 52 | ux = -x + rx * np.cos(theta) 53 | uy = -y + ry * np.sin(theta) 54 | uz = 0. * z 55 | return ux, uy, uz 56 | u = m1.nodes.eval_vectorFunction(U) 57 | m1.nodes.apply_displacement(u) 58 | m1.nodes.translate(x = l1/4., y = 3.*l2/4.) 59 | m.union(m1) 60 | return m 61 | 62 | 63 | def Y(N1, N2, l1, l2): 64 | m = A(N1, N2/2, l1, l2/2.) 65 | m = m.apply_reflection(point = (0., l2/2., 0.), normal = (0., 1., 0.) ) 66 | m2 = RegularQuadMesh(N1 = 2*N1, N2 = N2/2, l1 = l1/2., l2 = l2/2.) 67 | m2.nodes.translate(x=l1/4.) 68 | m.union( m2 ) 69 | return m 70 | 71 | mesh = A(N1, N2, l1, l2) 72 | temp = B(N1, N2, l1, l2) 73 | temp.nodes.translate(x = l1) 74 | mesh.union(temp) 75 | temp = A(N1, N2, l1, l2) 76 | temp.nodes.translate(x = 1.5*l1) 77 | mesh.union(temp) 78 | temp = P(N1, N2, l1, l2) 79 | temp.nodes.translate(x = 2.5*l1) 80 | mesh.union(temp) 81 | temp = Y(N1, N2, l1, l2) 82 | temp.nodes.translate(x = 3.*l1) 83 | mesh.union(temp) 84 | x,y,z, tri = mesh.dump2triplot() 85 | 86 | def Field(x,y,z,labels): 87 | f = y * np.sin(x * 5) 88 | return f 89 | 90 | field = mesh.nodes.eval_function(Field) 91 | 92 | 93 | 94 | plt.figure(0, figsize = (12., 4.)) 95 | plt.clf() 96 | plt.gca().set_aspect('equal') 97 | #plt.axis('off') 98 | plt.grid() 99 | plt.triplot(x,y,tri, 'k-', linewidth = .5) 100 | xe,ye,ze = mesh.get_border() 101 | plt.plot(xe,ye,'k-', linewidth =3.) 102 | plt.tricontourf(x,y,tri, field.data, 10) 103 | plt.tricontour(x,y,tri, field.data, 10, colors = 'black', linewidth= 1.) 104 | xlim, ylim, zlim = mesh.nodes.boundingBox() 105 | plt.xlim(xlim) 106 | plt.ylim(ylim) 107 | plt.show() 108 | -------------------------------------------------------------------------------- /doc/example_code/logo/abapy_logo.py~: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | from matplotlib import pyplot as plt 3 | import numpy as np 4 | from copy import deepcopy 5 | N1, N2 = 4, 16 6 | l1, l2 = 1., 1. 7 | 8 | def A(N1, N2, l1, l2): 9 | m = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1/4., l2 = l2) 10 | def U(x,y,z,label): 11 | ymax, xmax = y.max(), x.max() 12 | ux = y/ymax*xmax 13 | uy = 0.*x 14 | uz = 0.*x 15 | return ux, uy, uz 16 | u = m.nodes.eval_vectorFunction(U) 17 | m.nodes.apply_displacement(u) 18 | m.union( m.apply_reflection(point = (l1/2., 0., 0.), normal = (1., 0., 0.) ) ) 19 | return m 20 | 21 | def B(N1, N2, l1, l2): 22 | m = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1/4., l2 = l2) 23 | m1 = RegularQuadMesh(N1 = N2, N2 = N1, l1 = 1., l2 = l2/6.) 24 | def U(x, y, z, labels): 25 | r0y = l2/12. 26 | r0x = r0y 27 | theta = np.pi * (x-.5) 28 | rx = y + r0x 29 | ry = y + r0y 30 | ux = -x + rx * np.cos(theta) 31 | uy = -y + ry * np.sin(theta) 32 | uz = 0. * z 33 | return ux, uy, uz 34 | u = m1.nodes.eval_vectorFunction(U) 35 | m1.nodes.apply_displacement(u) 36 | m1.nodes.translate(x = l1/4., y = l2/4.) 37 | m2 = deepcopy(m1) 38 | m2.nodes.translate(y=l2/2.) 39 | m.union(m1) 40 | m.union(m2) 41 | return m 42 | 43 | def P(N1, N2, l1, l2): 44 | m = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1/4., l2 = l2) 45 | m1 = RegularQuadMesh(N1 = N2, N2 = N1, l1 = 1., l2 = l2/6.) 46 | def U(x, y, z, labels): 47 | r0y = l2/12. 48 | r0x = r0y 49 | theta = np.pi * (x-.5) 50 | rx = y + r0x 51 | ry = y + r0y 52 | ux = -x + rx * np.cos(theta) 53 | uy = -y + ry * np.sin(theta) 54 | uz = 0. * z 55 | return ux, uy, uz 56 | u = m1.nodes.eval_vectorFunction(U) 57 | m1.nodes.apply_displacement(u) 58 | m1.nodes.translate(x = l1/4., y = 3.*l2/4.) 59 | m.union(m1) 60 | return m 61 | 62 | 63 | def Y(N1, N2, l1, l2): 64 | m = A(N1, N2/2, l1, l2/2.) 65 | m = m.apply_reflection(point = (0., l2/2., 0.), normal = (0., 1., 0.) ) 66 | m2 = RegularQuadMesh(N1 = 2*N1, N2 = N2/2, l1 = l1/2., l2 = l2/2.) 67 | m2.nodes.translate(x=l1/4.) 68 | m.union( m2 ) 69 | return m 70 | 71 | mesh = A(N1, N2, l1, l2) 72 | temp = B(N1, N2, l1, l2) 73 | temp.nodes.translate(x = l1) 74 | mesh.union(temp) 75 | temp = A(N1, N2, l1, l2) 76 | temp.nodes.translate(x = 1.5*l1) 77 | mesh.union(temp) 78 | temp = P(N1, N2, l1, l2) 79 | temp.nodes.translate(x = 2.5*l1) 80 | mesh.union(temp) 81 | temp = Y(N1, N2, l1, l2) 82 | temp.nodes.translate(x = 3.*l1) 83 | mesh.union(temp) 84 | x,y,z, tri = mesh.dump2triplot() 85 | 86 | def Field(x,y,z,labels): 87 | f = y * np.sin(x * 5) 88 | return f 89 | 90 | field = mesh.nodes.eval_function(Field) 91 | 92 | 93 | 94 | plt.figure(0, figsize = (12., 4.)) 95 | plt.clf() 96 | plt.gca().set_aspect('equal') 97 | plt.axis('off') 98 | plt.grid() 99 | plt.triplot(x,y,tri, 'k-', linewidth = .5) 100 | xe,ye,ze = mesh.get_border() 101 | plt.plot(xe,ye,'k-', linewidth =3.) 102 | plt.tricontourf(x,y,tri, field.data, 10) 103 | plt.tricontour(x,y,tri, field.data, 10, colors = 'black', linewidth= 1.) 104 | xlim, ylim, zlim = mesh.nodes.boundingBox() 105 | plt.xlim(xlim) 106 | plt.ylim(ylim) 107 | plt.show() 108 | -------------------------------------------------------------------------------- /doc/example_code/logo/abapy_logo2.py: -------------------------------------------------------------------------------- 1 | from abapy.mesh import RegularQuadMesh 2 | from matplotlib import pyplot as plt 3 | import numpy as np 4 | from copy import deepcopy 5 | N1, N2 = 4, 16 6 | l1, l2 = 1., 1. 7 | 8 | def A(N1, N2, l1, l2): 9 | m = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1/4., l2 = l2) 10 | def U(x,y,z,label): 11 | ymax, xmax = y.max(), x.max() 12 | ux = y/ymax*xmax 13 | uy = 0.*x 14 | uz = 0.*x 15 | return ux, uy, uz 16 | u = m.nodes.eval_vectorFunction(U) 17 | m.nodes.apply_displacement(u) 18 | m.union( m.apply_reflection(point = (l1/2., 0., 0.), normal = (1., 0., 0.) ) ) 19 | return m 20 | 21 | def B(N1, N2, l1, l2): 22 | m = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1/4., l2 = l2) 23 | m1 = RegularQuadMesh(N1 = N2, N2 = N1, l1 = 1., l2 = l2/6.) 24 | def U(x, y, z, labels): 25 | r0y = l2/12. 26 | r0x = r0y 27 | theta = np.pi * (x-.5) 28 | rx = y + r0x 29 | ry = y + r0y 30 | ux = -x + rx * np.cos(theta) 31 | uy = -y + ry * np.sin(theta) 32 | uz = 0. * z 33 | return ux, uy, uz 34 | u = m1.nodes.eval_vectorFunction(U) 35 | m1.nodes.apply_displacement(u) 36 | m1.nodes.translate(x = l1/4., y = l2/4.) 37 | m2 = deepcopy(m1) 38 | m2.nodes.translate(y=l2/2.) 39 | m.union(m1) 40 | m.union(m2) 41 | return m 42 | 43 | def P(N1, N2, l1, l2): 44 | m = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1/4., l2 = l2) 45 | m1 = RegularQuadMesh(N1 = N2, N2 = N1, l1 = 1., l2 = l2/6.) 46 | def U(x, y, z, labels): 47 | r0y = l2/12. 48 | r0x = r0y 49 | theta = np.pi * (x-.5) 50 | rx = y + r0x 51 | ry = y + r0y 52 | ux = -x + rx * np.cos(theta) 53 | uy = -y + ry * np.sin(theta) 54 | uz = 0. * z 55 | return ux, uy, uz 56 | u = m1.nodes.eval_vectorFunction(U) 57 | m1.nodes.apply_displacement(u) 58 | m1.nodes.translate(x = l1/4., y = 3.*l2/4.) 59 | m.union(m1) 60 | return m 61 | 62 | 63 | def Y(N1, N2, l1, l2): 64 | m = A(N1, N2/2, l1, l2/2.) 65 | m = m.apply_reflection(point = (0., l2/2., 0.), normal = (0., 1., 0.) ) 66 | m2 = RegularQuadMesh(N1 = 2*N1, N2 = N2/2, l1 = l1/2., l2 = l2/2.) 67 | m2.nodes.translate(x=l1/4.) 68 | m.union( m2 ) 69 | return m 70 | 71 | mesh = A(N1, N2, l1, l2) 72 | temp = B(N1, N2, l1, l2) 73 | temp.nodes.translate(x = l1) 74 | mesh.union(temp) 75 | temp = A(N1, N2, l1, l2) 76 | temp.nodes.translate(x = 1.5*l1) 77 | mesh.union(temp) 78 | temp = P(N1, N2, l1, l2) 79 | temp.nodes.translate(x = 2.5*l1) 80 | mesh.union(temp) 81 | temp = Y(N1, N2, l1, l2) 82 | temp.nodes.translate(x = 3.*l1) 83 | mesh.union(temp) 84 | x,y,z, tri = mesh.dump2triplot() 85 | 86 | def Field(x,y,z,labels): 87 | f = y * np.sin(x * 5) 88 | return f 89 | 90 | field = mesh.nodes.eval_function(Field) 91 | 92 | 93 | 94 | plt.figure(0, figsize = (12., 4.)) 95 | plt.clf() 96 | plt.gca().set_aspect('equal') 97 | #plt.axis('off') 98 | plt.grid() 99 | plt.triplot(x,y,tri, 'k-', linewidth = .5) 100 | xe,ye,ze = mesh.get_border() 101 | plt.plot(xe,ye,'k-', linewidth =3.) 102 | plt.tricontourf(x,y,tri, field.data, 10) 103 | plt.tricontour(x,y,tri, field.data, 10, colors = 'black', linewidth= 1.) 104 | xlim, ylim, zlim = mesh.nodes.boundingBox() 105 | plt.xlim(xlim) 106 | plt.ylim(ylim) 107 | plt.show() 108 | -------------------------------------------------------------------------------- /doc/indentation.rst: -------------------------------------------------------------------------------- 1 | Indentation 2 | =============== 3 | 4 | Indentation simulation tools 5 | 6 | 7 | Indentation meshes 8 | ~~~~~~~~~~~~~~~~~~ 9 | 10 | ``ParamInfiniteMesh`` function 11 | ------------------------------ 12 | 13 | .. autofunction:: abapy.indentation.ParamInfiniteMesh 14 | 15 | ``IndentationMesh`` function 16 | ------------------------------ 17 | .. autofunction:: abapy.indentation.IndentationMesh 18 | 19 | 20 | 21 | 22 | 23 | 24 | Indenters 25 | ~~~~~~~~~ 26 | 27 | ``RigidCone2D`` class 28 | ---------------------- 29 | 30 | .. autoclass:: abapy.indentation.RigidCone2D 31 | :members: 32 | 33 | ``DeformableCone2D`` class 34 | --------------------------- 35 | 36 | .. autoclass:: abapy.indentation.DeformableCone2D 37 | :members: 38 | 39 | ``DeformableCone3D`` class 40 | --------------------------- 41 | 42 | .. autoclass:: abapy.indentation.DeformableCone3D 43 | :members: 44 | 45 | Indenter miscellaneous 46 | ------------------------- 47 | .. autofunction:: abapy.indentation.equivalent_half_angle 48 | 49 | 50 | Simulation tools 51 | ~~~~~~~~~~~~~~~~~~~ 52 | 53 | Steps definition 54 | ---------------- 55 | 56 | .. autoclass:: abapy.indentation.Step 57 | .. automethod:: abapy.indentation.Step.set_name 58 | .. automethod:: abapy.indentation.Step.set_displacement 59 | .. automethod:: abapy.indentation.Step.set_nframes 60 | .. automethod:: abapy.indentation.Step.set_nlgeom 61 | .. automethod:: abapy.indentation.Step.set_fieldOutputFreq 62 | .. automethod:: abapy.indentation.Step.set_nodeFieldOutput 63 | .. automethod:: abapy.indentation.Step.set_elemFieldOutput 64 | .. automethod:: abapy.indentation.Step.dump2inp 65 | 66 | Inp builder 67 | -------------------- 68 | 69 | .. autofunction:: abapy.indentation.MakeInp 70 | 71 | 72 | Simulation manager 73 | ------------------ 74 | 75 | .. autoclass:: abapy.indentation.Manager 76 | 77 | Settings 78 | ________ 79 | 80 | .. automethod:: abapy.indentation.Manager.set_simname 81 | .. automethod:: abapy.indentation.Manager.set_workdir 82 | .. automethod:: abapy.indentation.Manager.set_abqlauncher 83 | .. automethod:: abapy.indentation.Manager.set_samplemesh 84 | .. automethod:: abapy.indentation.Manager.set_indenter 85 | .. automethod:: abapy.indentation.Manager.set_samplemat 86 | .. automethod:: abapy.indentation.Manager.set_steps 87 | .. automethod:: abapy.indentation.Manager.set_files2delete 88 | .. automethod:: abapy.indentation.Manager.set_abqpostproc 89 | .. automethod:: abapy.indentation.Manager.set_pypostprocfunc 90 | 91 | Launchers 92 | __________ 93 | .. automethod:: abapy.indentation.Manager.erase_files 94 | .. automethod:: abapy.indentation.Manager.make_inp 95 | .. automethod:: abapy.indentation.Manager.run_sim 96 | .. automethod:: abapy.indentation.Manager.run_abqpostproc 97 | .. automethod:: abapy.indentation.Manager.run_pypostproc 98 | 99 | Indentation post-processing 100 | ------------------------------- 101 | 102 | Contact Data 103 | ____________ 104 | .. autoclass:: abapy.indentation.ContactData 105 | :members: 106 | 107 | Get Contact Data 108 | ________________ 109 | .. autofunction:: abapy.indentation.Get_ContactData 110 | 111 | 112 | Elasticity 113 | ~~~~~~~~~~ 114 | 115 | Hertz 116 | -------- 117 | .. autoclass:: abapy.indentation.Hertz 118 | :members: 119 | 120 | Hanson 121 | ---------- 122 | .. autoclass:: abapy.indentation.Hanson 123 | :members: 124 | 125 | 126 | -------------------------------------------------------------------------------- /doc/example_code/postproc/indentation_core_step0_frame1_S11_element-nodal.rpt: -------------------------------------------------------------------------------- 1 | ******************************************************************************** 2 | Field Output Report, written Fri Apr 27 10:07:47 2012 3 | 4 | Source 1 5 | --------- 6 | 7 | ODB: /home/lcharleux/Documents/Prog/modules/python/abapy/doc/example_code/postproc/indentation.odb 8 | Step: LOADING0 9 | Frame: Increment 10: Step Time = 1.000 10 | 11 | Loc 1 : Element nodal values from source 1 ( Average criteria = 75%, Not averaged across region boundaries ) 12 | 13 | Output sorted by column "Node Label". 14 | 15 | Field Output reported at element nodes for region: I_SAMPLE.Region_1 16 | Computation algorithm: EXTRAPOLATE_COMPUTE_AVERAGE 17 | Averaged at nodes 18 | Averaging regions: ODB_REGIONS 19 | 20 | Element Node S.S11 21 | Label Label @Loc 1 22 | ------------------------------------------------- 23 | 1 1 1.09260E-03 24 | 13 1 1.09260E-03 25 | 1 2 -220.352E-06 26 | 2 2 -220.352E-06 27 | 13 2 -220.352E-06 28 | 14 2 -220.352E-06 29 | 2 3 -490.897E-06 30 | 5 3 -490.897E-06 31 | 14 3 -490.897E-06 32 | 1 4 -1.62646E-03 33 | 3 4 -1.62646E-03 34 | 1 5 -651.646E-06 35 | 2 5 -2.03273E-03 36 | 3 5 -8.96446E-03 37 | 4 5 -1.06962E-03 38 | 2 6 -1.24735E-03 39 | 4 6 -1.24735E-03 40 | 5 6 -1.24735E-03 41 | 7 6 -1.24735E-03 42 | 3 7 -5.95788E-03 43 | 3 8 -4.98278E-03 44 | 4 8 -4.98278E-03 45 | 4 9 -594.455E-06 46 | 7 9 -594.455E-06 47 | 5 11 -15.4724E-06 48 | 6 11 -15.4724E-06 49 | 12 11 -15.4724E-06 50 | 14 11 -15.4724E-06 51 | 6 12 -31.4269E-06 52 | 12 12 -31.4269E-06 53 | 5 14 -200.636E-06 54 | 6 14 -200.636E-06 55 | 7 14 -200.636E-06 56 | 8 14 -200.636E-06 57 | 6 15 -53.2875E-06 58 | 8 15 -53.2875E-06 59 | 7 17 -399.030E-06 60 | 8 17 -399.030E-06 61 | 8 18 -28.0754E-06 62 | 11 25 25.7775E-06 63 | 11 26 5.41486E-06 64 | 12 26 5.41486E-06 65 | 11 28 66.3944E-06 66 | 13 28 66.3944E-06 67 | 11 29 54.0360E-06 68 | 12 29 54.0360E-06 69 | 13 29 54.0360E-06 70 | 14 29 54.0360E-06 71 | 72 | 73 | -------------------------------------------------------------------------------- /doc/example_code/tutorial/fancier_example.py: -------------------------------------------------------------------------------- 1 | # FANCIER_EXAMPLE: computing the loading prefactor of the indentation load vs. disp curve. 2 | # Run using python 3 | 4 | # Packages 5 | from abapy.misc import load 6 | import matplotlib.pyplot as plt 7 | import numpy as np 8 | 9 | 10 | 11 | 12 | def compute_C(E = 1. , nu = 0.3, sy = 0.01, abqlauncher = '/opt/Abaqus/6.9/Commands/abaqus', workdir = 'workdir', name = 'indentation_axi_fancier', frames = 50): 13 | ''' 14 | Computes the load prefactor C using Abaqus. 15 | 16 | Inputs: 17 | * E: sample's Young modulus. 18 | * nu: samples's Poisson's ratio 19 | * sy: sample's yield stress (von Mises yield criterion). 20 | * abqlauncher: absolute path to abaqus launcher. 21 | * wordir: path to working directory, can be relative. 22 | * name: name of simulation files. 23 | * frames: number of frames per step, increase if the simulation does not complete. 24 | 25 | Returns: 26 | * Load prefactor C (float) 27 | ''' 28 | import time, subprocess, os 29 | t0 = time.time() # Starting time recording 30 | path = workdir + '/' + name 31 | # Reading the INP target file 32 | f = open('indentation_axi_target.inp', 'r') 33 | inp = f.read() 34 | f.close() 35 | # Replace the targets in the file 36 | inp = inp.replace('#E', '{0}'.format(E)) 37 | inp = inp.replace('#NU', '{0}'.format(nu)) 38 | inp = inp.replace('#SY', '{0}'.format(sy)) 39 | inp = inp.replace('#FRAME', '{0}'.format(1./frames)) 40 | # Creating a new inp file 41 | f = open(path + '.inp', 'w') 42 | f.write(inp) 43 | f.close() 44 | print 'Created INP file: {0}.inp'.format(path) 45 | # Then we run the simulation 46 | print 'Running simulation in Abaqus' 47 | p = subprocess.Popen( '{0} job={1} input={1}.inp interactive ask_delete=OFF'.format(abqlauncher, name), cwd = workdir, shell=True, stdout = subprocess.PIPE) 48 | trash = p.communicate() 49 | 50 | # Now we test run the post processing script 51 | print 'Post processing the simulation in Abaqus/Python' 52 | p = subprocess.Popen( [abqlauncher, 'viewer', 'noGUI=fancier_example_abq.py'], cwd = '.',stdout = subprocess.PIPE ) 53 | trash = p.communicate() 54 | # Getting back raw data 55 | data = load(workdir + '/' + name + '.pckl') 56 | # Post processing 57 | print 'Post processing the simulation in Python' 58 | if data['completed']: 59 | ref_node_label = data['ref_node_label'] 60 | force_hist = -data['RF2']['Node I_INDENTER.{0}'.format(ref_node_label)] 61 | disp_hist = -data['U2']['Node I_INDENTER.{0}'.format(ref_node_label)] 62 | trash, force_l = force_hist[0,1].plotable() # Getting back force during loading 63 | trash, disp_l = disp_hist[0,1].plotable() # Getting backdisplacement during loading 64 | trash, force_u = force_hist[2].plotable() # Getting back force during unloading 65 | trash, disp_u = disp_hist[2].plotable() # Getting backdisplacement during unloading 66 | C_factor = (force_hist[1] / disp_hist[1]**2).average() 67 | 68 | else: 69 | print 'Simulation aborted, probably because frame number is to low' 70 | C_factor = None 71 | t1 = time.time() 72 | print 'Time used: {0:.2e} s'.format(t1-t0) 73 | return C_factor 74 | 75 | # Setting up some pathes 76 | workdir = 'workdir' 77 | name = 'indentation_axi_fancier' 78 | abqlauncher = '/opt/Abaqus/6.9/Commands/abaqus' 79 | 80 | # Setting material parameters 81 | E = 1. 82 | nu = 0.3 83 | sy = 0.01 84 | frames = 50 85 | 86 | # Testing it all 87 | C = compute_C(E = E, nu = nu, sy = sy, frames = frames) 88 | print 'C = {0}'.format(C) 89 | -------------------------------------------------------------------------------- /doc/advanced_examples/indentation/simulations/basic_plot_DP.py: -------------------------------------------------------------------------------- 1 | # Importing packages 2 | from matplotlib import pyplot as plt 3 | import numpy as np 4 | from matplotlib import cm 5 | from scipy.spatial import Delaunay 6 | 7 | # Setting up the database 8 | execfile('settings.py') 9 | 10 | 11 | # creating some shortcuts 12 | d = db_manager # database manager 13 | c = db_manager.cls # useful to call Simulation attributs 14 | 15 | # Load simulations 16 | simus = d.query().filter(c.completed == True).filter(c.sample_mat_type == 'druckerprager').all() 17 | 18 | #-------------------------- 19 | # PLOTING CONSTRAINT FACTOR 20 | #-------------------------- 21 | 22 | # Getting primary data 23 | sy = np.array([s.sample_mat_args['yield_stress'] for s in simus]) 24 | E = np.array([s.sample_mat_args['young_modulus'] for s in simus]) 25 | beta = np.array([s.sample_mat_args['beta'] for s in simus]) 26 | C = np.array([s.load_prefactor for s in simus]) 27 | Ac = np.array([s.contact_area for s in simus]) 28 | hmax = np.array([s.max_disp for s in simus]) 29 | phi = np.array([s.indenter_half_angle for s in simus]) 30 | wirr_wtot = np.array([s.irreversible_work_ratio for s in simus]) 31 | 32 | # Building secondary data 33 | ey = sy/E 34 | H = C/Ac 35 | hch = Ac / (np.pi*np.tan(np.radians(phi))**2) 36 | 37 | # Building Delaunay triangular connectivity 38 | x = ey 39 | y = beta 40 | points = np.array([x,y]).transpose() 41 | conn = Delaunay(points).vertices 42 | 43 | # For checking purpose, let's plot the generated mesh. You may see that the mesh is self improving has the simulations complete (this is quite nice). 44 | 45 | 46 | # Ploting stuff 47 | title = 'Playing with Drucker-Prager law' 48 | 49 | X, xlabel = C, r'$C$' 50 | #X, xlabel = ey, r'$\sigma_{yc}/E$' 51 | #X, xlabel = wirr_wtot, r'$W_{irr}/W_{tot}$' 52 | Y, ylabel = hch, '$\sqrt{A_c / A_{app}}$' 53 | #Y, ylabel = C, '$C/E$' 54 | 55 | Z, zlabel = beta, r'$\beta = %1.1f$' 56 | Zlevels = list(set(Z)) 57 | Z2, z2label = ey, r'$\epsilon_y = %1.3f$' 58 | Z2levels = list(set(Z2)) 59 | 60 | # For checking purpose, let's plot the generated mesh. You may see that the mesh is self improving has the simulations complete (this is quite nice). 61 | 62 | fig = plt.figure(0) 63 | plt.clf() 64 | fig.add_subplot(121) 65 | plt.triplot(x, y, conn) 66 | plt.title('Delaunay Mesh') 67 | plt.xlabel('x') 68 | plt.ylabel('y') 69 | fig.add_subplot(122) 70 | plt.triplot(X, Y, conn) 71 | plt.title('Deformed Delaunay Mesh') 72 | plt.xlabel('X') 73 | plt.ylabel('Y') 74 | plt.savefig('plots/basic_plot_mesh_DP.png') 75 | 76 | plt.figure(0) 77 | plt.clf() 78 | plt.title(title) 79 | plt.grid() 80 | plt.xlabel(xlabel) 81 | plt.ylabel(ylabel) 82 | #plt.triplot(X,Y,conn) 83 | #plt.tricontourf(X,Y,conn,Z, Zlevels) 84 | cont = plt.tricontour(X,Y,conn,Z, Zlevels, colors = 'blue') 85 | plt.clabel(cont, fmt = zlabel, fontsize=9, inline=1) 86 | cont = plt.tricontour(X,Y,conn,Z2, Z2levels, colors = 'red') 87 | plt.clabel(cont, fmt = z2label, fontsize=9, inline=1) 88 | plt.savefig('plots/basic_plot_DP.png') 89 | 90 | ''' 91 | #-------------------------- 92 | # PLOTING SECTIONS 93 | #-------------------------- 94 | plt.figure(0) 95 | plt.clf() 96 | plt.gca().set_aspect('equal') 97 | rmax = 6. 98 | x = np.linspace(0., rmax, 128) 99 | y = np.zeros_like(x) 100 | ey = np.array(list(set(ey))) 101 | ey.sort() 102 | for s in simus: 103 | cd = s.contact_data[2][-1] 104 | alt, press = cd.interpolate(x, y, method = 'linear') 105 | ey_s = s.sample_mat_args['yield_stress'] 106 | loc = np.where(ey==ey_s)[0][0] 107 | alt += -loc 108 | plt.plot(x, alt) 109 | plt.show() 110 | ''' 111 | -------------------------------------------------------------------------------- /doc/advanced_examples/indentation/simulations/basic_plot_Hol.py: -------------------------------------------------------------------------------- 1 | # Importing packages 2 | from matplotlib import pyplot as plt 3 | import numpy as np 4 | from matplotlib import cm 5 | from scipy.spatial import Delaunay 6 | 7 | # Setting up the database 8 | execfile('settings.py') 9 | 10 | 11 | # creating some shortcuts 12 | d = db_manager # database manager 13 | c = db_manager.cls # useful to call Simulation attributs 14 | 15 | # Load simulations 16 | simus = d.query().filter(c.completed == True).filter(c.sample_mat_type == 'hollomon').all() 17 | simus = [s for s in simus if s.sample_mat_args['yield_stress'] <= 0.01] 18 | 19 | #-------------------------- 20 | # PLOTING CONSTRAINT FACTOR 21 | #-------------------------- 22 | 23 | # Getting primary data 24 | sy = np.array([s.sample_mat_args['yield_stress'] for s in simus]) 25 | E = np.array([s.sample_mat_args['young_modulus'] for s in simus]) 26 | n = np.array([s.sample_mat_args['hardening'] for s in simus]) 27 | C = np.array([s.load_prefactor for s in simus]) 28 | Ac = np.array([s.contact_area for s in simus]) 29 | hmax = np.array([s.max_disp for s in simus]) 30 | phi = np.array([s.indenter_half_angle for s in simus]) 31 | wirr_wtot = np.array([s.irreversible_work_ratio for s in simus]) 32 | 33 | # Building secondary data 34 | ey = sy/E 35 | H = C/Ac 36 | hch = (Ac / (np.pi*np.tan(np.radians(phi))**2))**.5 37 | 38 | # Building Delaunay triangular connectivity 39 | x = ey 40 | y = n 41 | points = np.array([x,y]).transpose() 42 | conn = Delaunay(points).vertices 43 | 44 | # For checking purpose, let's plot the generated mesh. You may see that the mesh is self improving has the simulations complete (this is quite nice). 45 | 46 | 47 | # Ploting stuff 48 | title = 'Playing with Hollomon law' 49 | 50 | X, xlabel = C, r'$C$' 51 | #X, xlabel = ey, r'$\sigma_{yc}/E$' 52 | #X, xlabel = wirr_wtot, r'$W_{irr}/W_{tot}$' 53 | Y, ylabel = hch, '$\sqrt{A_c / A_{app}}$' 54 | #Y, ylabel = C, '$C/E$' 55 | 56 | Z, zlabel = n, r'$n = %1.1f$' 57 | Zlevels = list(set(Z)) 58 | Z2, z2label = ey, r'$\epsilon_y = %1.3f$' 59 | Z2levels = list(set(Z2)) 60 | 61 | # For checking purpose, let's plot the generated mesh. You may see that the mesh is self improving has the simulations complete (this is quite nice). 62 | 63 | fig = plt.figure(0) 64 | plt.clf() 65 | fig.add_subplot(121) 66 | plt.triplot(x, y, conn) 67 | plt.title('Delaunay Mesh') 68 | plt.xlabel('x') 69 | plt.ylabel('y') 70 | fig.add_subplot(122) 71 | plt.triplot(X, Y, conn) 72 | plt.title('Deformed Delaunay Mesh') 73 | plt.xlabel('X') 74 | plt.ylabel('Y') 75 | plt.savefig('plots/basic_plot_mesh_Hol.pdf') 76 | 77 | plt.figure(0) 78 | plt.clf() 79 | plt.title(title) 80 | plt.grid() 81 | plt.xlabel(xlabel) 82 | plt.ylabel(ylabel) 83 | #plt.triplot(X,Y,conn) 84 | #plt.tricontourf(X,Y,conn,Z, Zlevels) 85 | cont = plt.tricontour(X,Y,conn,Z, Zlevels, colors = 'blue') 86 | plt.clabel(cont, fmt = zlabel, fontsize=9, inline=1) 87 | cont = plt.tricontour(X,Y,conn,Z2, Z2levels, colors = 'red') 88 | plt.clabel(cont, fmt = z2label, fontsize=9, inline=1) 89 | plt.savefig('plots/basic_plot_Hol.pdf') 90 | 91 | ''' 92 | #-------------------------- 93 | # PLOTING SECTIONS 94 | #-------------------------- 95 | plt.figure(0) 96 | plt.clf() 97 | plt.gca().set_aspect('equal') 98 | rmax = 6. 99 | x = np.linspace(0., rmax, 128) 100 | y = np.zeros_like(x) 101 | ey = np.array(list(set(ey))) 102 | ey.sort() 103 | for s in simus: 104 | cd = s.contact_data[2][-1] 105 | alt, press = cd.interpolate(x, y, method = 'linear') 106 | ey_s = s.sample_mat_args['yield_stress'] 107 | loc = np.where(ey==ey_s)[0][0] 108 | alt += -loc 109 | plt.plot(x, alt) 110 | plt.show() 111 | ''' 112 | -------------------------------------------------------------------------------- /doc/example_code/indentation/MakeInp.py: -------------------------------------------------------------------------------- 1 | #----------------------- 2 | # PACKAGES 3 | from abapy.indentation import MakeInp, DeformableCone2D, DeformableCone3D, IndentationMesh, Step 4 | from abapy.materials import Elastic, VonMises 5 | from math import radians, tan 6 | #----------------------- 7 | 8 | #----------------------- 9 | # FIRST EXEMPLE: AXISYMMETRIC INDENTATION 10 | # Model parameters 11 | half_angle = 70.29 # Indenter half angle, 70.3 degrees is equivalent to Berkovich indenter 12 | Na, Nb, Ns, Nf, l = 8, 8, 16, 2, 1. 13 | E, nu = 1., 0.3 # E is the Young's modulus and nu is the Poisson's ratio. 14 | ey = 0.01 * E 15 | max_disp = l/3.*tan(radians(70.3))/tan(radians(half_angle)) # Maximum displacement 16 | 17 | # Building model 18 | indenter = DeformableCone2D(half_angle = half_angle, rigid = True, Na = Na, Nb = Nb, Ns = Ns, Nf = Nf, l=l) # Indenter 19 | sample_mesh = IndentationMesh(Na = Na, Nb = Nb, Ns = Ns, Nf = Nf, l=l)# Sample Mesh 20 | #sample_mat = Elastic(labels = 'SAMPLE_MAT', E = E, nu= nu) # Sample material 21 | sample_mat = VonMises(labels = 'SAMPLE_MAT', E = E, nu= nu, sy = E * ey) # Sample material 22 | indenter_mat = Elastic(labels = 'INDENTER_MAT') # Indenter material 23 | steps = [ # Steps 24 | Step(name='preloading', nframes = 50, disp = max_disp / 2.), 25 | Step(name='loading', nframes = 50, disp = max_disp ), 26 | Step(name='unloading', nframes = 50, disp = 0.), ] 27 | 28 | # Making INP file 29 | inp = MakeInp(indenter = indenter, 30 | sample_mesh = sample_mesh, 31 | sample_mat = sample_mat, 32 | indenter_mat = indenter_mat, 33 | steps = steps) 34 | f = open('workdir/indentation_axi.inp', 'w') 35 | f.write(inp) 36 | f.close() 37 | #----------------------- 38 | 39 | #----------------------- 40 | # SECOND EXAMPLE: 3D BERKOVICH INDENTATION 41 | # Model Parameters 42 | half_angle = 65.27 # Indenter half angle, 65.27 leads to a modified Berkovich geometry, see help(DeformableCone3D for further information) 43 | Na, Nb, Ns, Nf, l = 8, 8, 8, 2, 1. # with 4, 4, 4, 2, 1., simulation is very fast, the mesh is coarse (even crappy) but the result is surprisingly good! 44 | sweep_angle, N = 60., 8 45 | E, nu = 1., 0.3 # E is the Young's modulus and nu is the Poisson's ratio. 46 | ey = 0.01 # yield strain 47 | max_disp = l/3.*tan(radians(70.3))/tan(radians(half_angle)) # Maximum displacement 48 | pyramid = True 49 | 50 | # Building model 51 | indenter = DeformableCone3D(half_angle = half_angle, rigid = True, Na = Na, Nb = Nb, Ns = Ns, Nf = Nf, N= N, sweep_angle=sweep_angle, l=l, pyramid = pyramid) # Indenter 52 | sample_mesh = IndentationMesh(Na = Na, Nb = Nb, Ns = Ns, Nf = Nf, l=l).sweep(sweep_angle = sweep_angle, N = N) # Sample Mesh 53 | #sample_mat = Elastic(labels = 'SAMPLE_MAT', E = E, nu= nu) # Sample material 54 | sample_mat = VonMises(labels = 'SAMPLE_MAT', E = E, nu= nu, sy = E * ey) # Sample material 55 | indenter_mat = Elastic(labels = 'INDENTER_MAT') # Indenter material 56 | steps = [ # Steps 57 | Step(name='preloading', nframes = 100, disp = max_disp / 2., boundaries_3D=True), 58 | Step(name='loading', nframes = 100, disp = max_disp, boundaries_3D=True), 59 | Step(name='unloading', nframes = 200, disp = 0., boundaries_3D=True)] 60 | 61 | # Making INP file. 62 | inp = MakeInp(indenter = indenter, 63 | sample_mesh = sample_mesh, 64 | sample_mat = sample_mat, 65 | indenter_mat = indenter_mat, 66 | steps = steps, is_3D = True) 67 | f = open('workdir/indentation_berko.inp', 'w') 68 | f.write(inp) 69 | f.close() 70 | #----------------------- 71 | 72 | # Simulation can be launched using abaqus job=indentation and can be roughly post processed using abaqus viewer of more finely using abapy. 73 | -------------------------------------------------------------------------------- /doc/sphinxext/numpydoc.py: -------------------------------------------------------------------------------- 1 | """ 2 | ======== 3 | numpydoc 4 | ======== 5 | 6 | Sphinx extension that handles docstrings in the Numpy standard format. [1] 7 | 8 | It will: 9 | 10 | - Convert Parameters etc. sections to field lists. 11 | - Convert See Also section to a See also entry. 12 | - Renumber references. 13 | - Extract the signature from the docstring, if it can't be determined otherwise. 14 | 15 | .. [1] http://projects.scipy.org/scipy/numpy/wiki/CodingStyleGuidelines#docstring-standard 16 | 17 | """ 18 | 19 | import os, re, pydoc 20 | from docscrape_sphinx import get_doc_object, SphinxDocString 21 | import inspect 22 | 23 | def mangle_docstrings(app, what, name, obj, options, lines, 24 | reference_offset=[0]): 25 | if what == 'module': 26 | # Strip top title 27 | title_re = re.compile(r'^\s*[#*=]{4,}\n[a-z0-9 -]+\n[#*=]{4,}\s*', 28 | re.I|re.S) 29 | lines[:] = title_re.sub('', "\n".join(lines)).split("\n") 30 | else: 31 | doc = get_doc_object(obj, what, "\n".join(lines)) 32 | lines[:] = str(doc).split("\n") 33 | 34 | if app.config.numpydoc_edit_link and hasattr(obj, '__name__') and \ 35 | obj.__name__: 36 | if hasattr(obj, '__module__'): 37 | v = dict(full_name="%s.%s" % (obj.__module__, obj.__name__)) 38 | else: 39 | v = dict(full_name=obj.__name__) 40 | lines += ['', '.. htmlonly::', ''] 41 | lines += [' %s' % x for x in 42 | (app.config.numpydoc_edit_link % v).split("\n")] 43 | 44 | # replace reference numbers so that there are no duplicates 45 | references = [] 46 | for l in lines: 47 | l = l.strip() 48 | if l.startswith('.. ['): 49 | try: 50 | references.append(int(l[len('.. ['):l.index(']')])) 51 | except ValueError: 52 | print "WARNING: invalid reference in %s docstring" % name 53 | 54 | # Start renaming from the biggest number, otherwise we may 55 | # overwrite references. 56 | references.sort() 57 | if references: 58 | for i, line in enumerate(lines): 59 | for r in references: 60 | new_r = reference_offset[0] + r 61 | lines[i] = lines[i].replace('[%d]_' % r, 62 | '[%d]_' % new_r) 63 | lines[i] = lines[i].replace('.. [%d]' % r, 64 | '.. [%d]' % new_r) 65 | 66 | reference_offset[0] += len(references) 67 | 68 | def mangle_signature(app, what, name, obj, options, sig, retann): 69 | # Do not try to inspect classes that don't define `__init__` 70 | if (inspect.isclass(obj) and 71 | 'initializes x; see ' in pydoc.getdoc(obj.__init__)): 72 | return '', '' 73 | 74 | if not (callable(obj) or hasattr(obj, '__argspec_is_invalid_')): return 75 | if not hasattr(obj, '__doc__'): return 76 | 77 | doc = SphinxDocString(pydoc.getdoc(obj)) 78 | if doc['Signature']: 79 | sig = re.sub("^[^(]*", "", doc['Signature']) 80 | return sig, '' 81 | 82 | def initialize(app): 83 | try: 84 | app.connect('autodoc-process-signature', mangle_signature) 85 | except: 86 | monkeypatch_sphinx_ext_autodoc() 87 | 88 | def setup(app, get_doc_object_=get_doc_object): 89 | global get_doc_object 90 | get_doc_object = get_doc_object_ 91 | 92 | app.connect('autodoc-process-docstring', mangle_docstrings) 93 | app.connect('builder-inited', initialize) 94 | app.add_config_value('numpydoc_edit_link', None, True) 95 | 96 | #------------------------------------------------------------------------------ 97 | # Monkeypatch sphinx.ext.autodoc to accept argspecless autodocs (Sphinx < 0.5) 98 | #------------------------------------------------------------------------------ 99 | 100 | def monkeypatch_sphinx_ext_autodoc(): 101 | global _original_format_signature 102 | import sphinx.ext.autodoc 103 | 104 | if sphinx.ext.autodoc.format_signature is our_format_signature: 105 | return 106 | 107 | print "[numpydoc] Monkeypatching sphinx.ext.autodoc ..." 108 | _original_format_signature = sphinx.ext.autodoc.format_signature 109 | sphinx.ext.autodoc.format_signature = our_format_signature 110 | 111 | def our_format_signature(what, obj): 112 | r = mangle_signature(None, what, None, obj, None, None, None) 113 | if r is not None: 114 | return r[0] 115 | else: 116 | return _original_format_signature(what, obj) 117 | -------------------------------------------------------------------------------- /doc/sphinxext/ipython_console_highlighting.py: -------------------------------------------------------------------------------- 1 | """reST directive for syntax-highlighting ipython interactive sessions. 2 | 3 | XXX - See what improvements can be made based on the new (as of Sept 2009) 4 | 'pycon' lexer for the python console. At the very least it will give better 5 | highlighted tracebacks. 6 | """ 7 | 8 | #----------------------------------------------------------------------------- 9 | # Needed modules 10 | 11 | # Standard library 12 | import re 13 | 14 | # Third party 15 | from pygments.lexer import Lexer, do_insertions 16 | from pygments.lexers.agile import (PythonConsoleLexer, PythonLexer, 17 | PythonTracebackLexer) 18 | from pygments.token import Comment, Generic 19 | 20 | from sphinx import highlighting 21 | 22 | #----------------------------------------------------------------------------- 23 | # Global constants 24 | line_re = re.compile('.*?\n') 25 | 26 | #----------------------------------------------------------------------------- 27 | # Code begins - classes and functions 28 | 29 | class IPythonConsoleLexer(Lexer): 30 | """ 31 | For IPython console output or doctests, such as: 32 | 33 | .. sourcecode:: ipython 34 | 35 | In [1]: a = 'foo' 36 | 37 | In [2]: a 38 | Out[2]: 'foo' 39 | 40 | In [3]: print a 41 | foo 42 | 43 | In [4]: 1 / 0 44 | 45 | Notes: 46 | 47 | - Tracebacks are not currently supported. 48 | 49 | - It assumes the default IPython prompts, not customized ones. 50 | """ 51 | 52 | name = 'IPython console session' 53 | aliases = ['ipython'] 54 | mimetypes = ['text/x-ipython-console'] 55 | input_prompt = re.compile("(In \[[0-9]+\]: )|( \.\.\.+:)") 56 | output_prompt = re.compile("(Out\[[0-9]+\]: )|( \.\.\.+:)") 57 | continue_prompt = re.compile(" \.\.\.+:") 58 | tb_start = re.compile("\-+") 59 | 60 | def get_tokens_unprocessed(self, text): 61 | pylexer = PythonLexer(**self.options) 62 | tblexer = PythonTracebackLexer(**self.options) 63 | 64 | curcode = '' 65 | insertions = [] 66 | for match in line_re.finditer(text): 67 | line = match.group() 68 | input_prompt = self.input_prompt.match(line) 69 | continue_prompt = self.continue_prompt.match(line.rstrip()) 70 | output_prompt = self.output_prompt.match(line) 71 | if line.startswith("#"): 72 | insertions.append((len(curcode), 73 | [(0, Comment, line)])) 74 | elif input_prompt is not None: 75 | insertions.append((len(curcode), 76 | [(0, Generic.Prompt, input_prompt.group())])) 77 | curcode += line[input_prompt.end():] 78 | elif continue_prompt is not None: 79 | insertions.append((len(curcode), 80 | [(0, Generic.Prompt, continue_prompt.group())])) 81 | curcode += line[continue_prompt.end():] 82 | elif output_prompt is not None: 83 | # Use the 'error' token for output. We should probably make 84 | # our own token, but error is typicaly in a bright color like 85 | # red, so it works fine for our output prompts. 86 | insertions.append((len(curcode), 87 | [(0, Generic.Error, output_prompt.group())])) 88 | curcode += line[output_prompt.end():] 89 | else: 90 | if curcode: 91 | for item in do_insertions(insertions, 92 | pylexer.get_tokens_unprocessed(curcode)): 93 | yield item 94 | curcode = '' 95 | insertions = [] 96 | yield match.start(), Generic.Output, line 97 | if curcode: 98 | for item in do_insertions(insertions, 99 | pylexer.get_tokens_unprocessed(curcode)): 100 | yield item 101 | 102 | 103 | def setup(app): 104 | """Setup as a sphinx extension.""" 105 | 106 | # This is only a lexer, so adding it below to pygments appears sufficient. 107 | # But if somebody knows that the right API usage should be to do that via 108 | # sphinx, by all means fix it here. At least having this setup.py 109 | # suppresses the sphinx warning we'd get without it. 110 | pass 111 | 112 | #----------------------------------------------------------------------------- 113 | # Register the extension as a valid pygments lexer 114 | highlighting.lexers['ipython'] = IPythonConsoleLexer() 115 | -------------------------------------------------------------------------------- /doc/sphinxext/docscrape_sphinx.py: -------------------------------------------------------------------------------- 1 | import re, inspect, textwrap, pydoc 2 | from docscrape import NumpyDocString, FunctionDoc, ClassDoc 3 | 4 | class SphinxDocString(NumpyDocString): 5 | # string conversion routines 6 | def _str_header(self, name, symbol='`'): 7 | return ['.. rubric:: ' + name, ''] 8 | 9 | def _str_field_list(self, name): 10 | return [':' + name + ':'] 11 | 12 | def _str_indent(self, doc, indent=4): 13 | out = [] 14 | for line in doc: 15 | out += [' '*indent + line] 16 | return out 17 | 18 | def _str_signature(self): 19 | return [''] 20 | if self['Signature']: 21 | return ['``%s``' % self['Signature']] + [''] 22 | else: 23 | return [''] 24 | 25 | def _str_summary(self): 26 | return self['Summary'] + [''] 27 | 28 | def _str_extended_summary(self): 29 | return self['Extended Summary'] + [''] 30 | 31 | def _str_param_list(self, name): 32 | out = [] 33 | if self[name]: 34 | out += self._str_field_list(name) 35 | out += [''] 36 | for param,param_type,desc in self[name]: 37 | out += self._str_indent(['**%s** : %s' % (param.strip(), 38 | param_type)]) 39 | out += [''] 40 | out += self._str_indent(desc,8) 41 | out += [''] 42 | return out 43 | 44 | def _str_section(self, name): 45 | out = [] 46 | if self[name]: 47 | out += self._str_header(name) 48 | out += [''] 49 | content = textwrap.dedent("\n".join(self[name])).split("\n") 50 | out += content 51 | out += [''] 52 | return out 53 | 54 | def _str_see_also(self, func_role): 55 | out = [] 56 | if self['See Also']: 57 | see_also = super(SphinxDocString, self)._str_see_also(func_role) 58 | out = ['.. seealso::', ''] 59 | out += self._str_indent(see_also[2:]) 60 | return out 61 | 62 | def _str_warnings(self): 63 | out = [] 64 | if self['Warnings']: 65 | out = ['.. warning::', ''] 66 | out += self._str_indent(self['Warnings']) 67 | return out 68 | 69 | def _str_index(self): 70 | idx = self['index'] 71 | out = [] 72 | if len(idx) == 0: 73 | return out 74 | 75 | out += ['.. index:: %s' % idx.get('default','')] 76 | for section, references in idx.iteritems(): 77 | if section == 'default': 78 | continue 79 | elif section == 'refguide': 80 | out += [' single: %s' % (', '.join(references))] 81 | else: 82 | out += [' %s: %s' % (section, ','.join(references))] 83 | return out 84 | 85 | def _str_references(self): 86 | out = [] 87 | if self['References']: 88 | out += self._str_header('References') 89 | if isinstance(self['References'], str): 90 | self['References'] = [self['References']] 91 | out.extend(self['References']) 92 | out += [''] 93 | return out 94 | 95 | def __str__(self, indent=0, func_role="obj"): 96 | out = [] 97 | out += self._str_signature() 98 | out += self._str_index() + [''] 99 | out += self._str_summary() 100 | out += self._str_extended_summary() 101 | for param_list in ('Parameters', 'Attributes', 'Methods', 102 | 'Returns','Raises'): 103 | out += self._str_param_list(param_list) 104 | out += self._str_warnings() 105 | out += self._str_see_also(func_role) 106 | out += self._str_section('Notes') 107 | out += self._str_references() 108 | out += self._str_section('Examples') 109 | out = self._str_indent(out,indent) 110 | return '\n'.join(out) 111 | 112 | class SphinxFunctionDoc(SphinxDocString, FunctionDoc): 113 | pass 114 | 115 | class SphinxClassDoc(SphinxDocString, ClassDoc): 116 | pass 117 | 118 | def get_doc_object(obj, what=None, doc=None): 119 | if what is None: 120 | if inspect.isclass(obj): 121 | what = 'class' 122 | elif inspect.ismodule(obj): 123 | what = 'module' 124 | elif callable(obj): 125 | what = 'function' 126 | else: 127 | what = 'object' 128 | if what == 'class': 129 | return SphinxClassDoc(obj, '', func_doc=SphinxFunctionDoc, doc=doc) 130 | elif what in ('function', 'method'): 131 | return SphinxFunctionDoc(obj, '', doc=doc) 132 | else: 133 | if doc is None: 134 | doc = pydoc.getdoc(obj) 135 | return SphinxDocString(doc) 136 | 137 | -------------------------------------------------------------------------------- /doc/advanced_examples/indentation/simulations/sketch.py: -------------------------------------------------------------------------------- 1 | from matplotlib import pyplot as plt 2 | import numpy as np 3 | from scipy import interpolate 4 | 5 | # Setting up the database 6 | execfile('settings.py') 7 | 8 | # creating some shortcuts 9 | d = db_manager # database manager 10 | c = db_manager.cls # useful to call Simulation attributs 11 | 12 | # Chosing the simulation 13 | ''' 14 | simus = d.query().filter(c.completed == True).all() 15 | simus = [s for s in simus 16 | if s.sample_mat_type == 'druckerprager' 17 | and s.sample_mat_args['yield_stress'] == 0.015 18 | and s.sample_mat_args['beta'] == 15.] 19 | simu = simus[0] 20 | ''' 21 | s = d.query().filter(c.id == 12).first() 22 | 23 | # Force vs Disp curve 24 | F_hist = s.force_hist 25 | D_hist = s.disp_hist 26 | trash, F_l = F_hist[0:2].toArray() 27 | trash, D_l = D_hist[0:2].toArray() 28 | F_l, D_l = np.array(F_l), np.array(D_l) 29 | trash, F_u = F_hist[2].toArray() 30 | trash, D_u = D_hist[2].toArray() 31 | F_u, D_u = np.array(F_u), np.array(D_u) 32 | d_m = D_l.max() 33 | f_m = s.load_prefactor * d_m**2 34 | F_u = F_u[np.where(F_u > f_m * 1.e-6)] 35 | D_u = D_u[np.where(F_u > f_m * 1.e-6)] 36 | d_f = s.final_displacement 37 | F_l_fit = s.load_prefactor * D_l**2 38 | F_u_fit = f_m * ((D_u - d_f) / (d_m - d_f))**s.unload_exponent 39 | stiff = s.contact_stiffness *f_m /d_m 40 | S_u = (D_u - d_m) * stiff + f_m 41 | D_us = D_u[np.where(S_u > f_m * 1.e-6)] 42 | S_u = S_u[np.where(S_u > f_m * 1.e-6)] 43 | 44 | 45 | fs = 14. 46 | lw = 2. 47 | plt.figure(0) 48 | plt.clf() 49 | #plt.xticks([0., d_f, d_m, d_m - f_m/stiff], ['$0$', '$d_f$', '$d_m$', r'$d_m - \frac{F_m}{S}$'], fontsize = fs) 50 | plt.xticks([0., d_f, d_m], ['$0$', '$d_f$', '$d_m$'], fontsize = fs) 51 | plt.yticks([0., f_m], ['$0$', '$F_m$'], fontsize = fs) 52 | plt.xlabel('Displacement $d$', fontsize = fs) 53 | plt.ylabel('Force $F$', fontsize = fs) 54 | plt.grid() 55 | plt.plot(D_l, F_l, '+r', label = 'Loading data') 56 | plt.plot(D_l, F_l_fit, 'r-', label = r'Loading fit: $F = C d^2$ ', linewidth = lw) 57 | plt.plot(D_u, F_u, '+b', label = 'Unloading') 58 | plt.plot(D_u, F_u_fit, 'b-', label = r'Unloading fit: $F = F_m \left(\frac{d - d_f}{d_m-d_f}\right)^m$', linewidth = lw) 59 | plt.plot(D_us, S_u, 'g-', label = r'Unloading fit tangent', linewidth = 1.) 60 | plt.legend(loc = 'upper left') 61 | plt.savefig('plots/sketch_load_disp.pdf') 62 | 63 | # Sections: 64 | lw = 2. 65 | r, N = 4., 1024 66 | z_min, z_max = -1., .2 67 | R = np.linspace(0., r, N) 68 | CD_l = s.contact_data[1][-1] 69 | CD_u = s.contact_data[2][-1] 70 | Alt_l, Press_l = CD_l.interpolate(R, np.zeros_like(R), method = 'linear') 71 | Alt_u, trash = CD_u.interpolate(R, np.zeros_like(R), method = 'linear') 72 | alt_ml = max(0., z_max) 73 | alt_mu = max(0., z_max) 74 | phi = s.indenter_half_angle 75 | r_c = ((s.contact_area * d_m**2)/np.pi)**.5 76 | Ind_l = R/np.tan(np.radians(phi)) - d_m 77 | R_ind_l = R[np.where(Ind_l <=alt_ml)] 78 | Ind_l = Ind_l[np.where(Ind_l <=alt_ml)] 79 | Ind_u = R/np.tan(np.radians(phi)) + Alt_u.min() 80 | R_ind_u = R[np.where(Ind_u <=alt_mu)] 81 | Ind_u = Ind_u[np.where(Ind_u <=alt_mu)] 82 | Ind_v = R/np.tan(np.radians(phi)) + Alt_u.min() - Alt_u 83 | R_ind_v = R 84 | fig = plt.figure(0) 85 | plt.clf() 86 | ax = fig.add_subplot(311) 87 | plt.grid() 88 | ax.set_title('Virtual Indenter') 89 | #plt.xlabel('$r$', fontsize = fs) 90 | plt.ylabel('$z$', fontsize = fs) 91 | plt.plot(R / d_m,Alt_l/d_m, '-b', label = 'Sample$_{h=h_m}$', linewidth = lw) 92 | plt.plot(R_ind_l / d_m, Ind_l / d_m , '-r', label = 'Indenter$_{h=h_m}$', linewidth = lw) 93 | plt.xticks([0., r_c], ['', '$r_c$'], fontsize = fs) 94 | plt.yticks([-1., 0.], ['$d_m$', '$0$'], fontsize = fs) 95 | plt.legend(loc = 'upper left') 96 | plt.ylim([z_min, z_max]) 97 | ax = fig.add_subplot(312) 98 | plt.grid() 99 | #ax.set_title('Unloading: $h=h_f$', fontsize = fs) 100 | #plt.xlabel('$r$', fontsize = fs) 101 | plt.ylabel('$z$', fontsize = fs) 102 | plt.plot(R / d_m,Alt_u/d_m, '-b', label = 'Sample$_{h=h_f}$', linewidth = lw) 103 | plt.plot(R_ind_u / d_m, Ind_u / d_m , '-r', label = 'Indenter$_{h=h_f}$', linewidth = lw) 104 | plt.xticks([0., r_c], ['', '$r_c$'], fontsize = fs) 105 | plt.yticks([-1., -d_f/d_m, 0.], ['$d_m$', r'$d_f$' ,'0'], fontsize = fs) 106 | plt.legend(loc = 'upper left') 107 | plt.ylim([z_min, z_max]) 108 | ax = fig.add_subplot(313) 109 | plt.grid() 110 | #ax.set_title('Virtual indenter', fontsize = fs) 111 | plt.xlabel('$r$', fontsize = fs) 112 | plt.ylabel('$z$', fontsize = fs) 113 | plt.plot(R_ind_v / d_m, Ind_v / d_m , '-g', linewidth = lw, label = 'Virtual Indenter = Indenter$_{h=h_f}$ - Sample$_{h=h_f}$') 114 | d_u = d_m - d_f 115 | r_ind = interpolate.interp1d(Ind_v/d_m, R_ind_v/d_m) # Interpolation function of the radius of the virtual indenter 116 | r_c_me = r_ind(.5 *d_u) 117 | plt.xticks([0., r_c, r_c_me], ['$0$', '', '$r_{c}^*$'], fontsize = fs) 118 | plt.yticks([0., .5*d_u], ['$0$',r'$\frac{d_m - d_f}{2}$' ], fontsize = fs) 119 | plt.legend(loc = 'upper left') 120 | plt.savefig('plots/sketch_profiles.pdf') 121 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 14 | 15 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest 16 | 17 | help: 18 | @echo "Please use \`make ' where is one of" 19 | @echo " html to make standalone HTML files" 20 | @echo " dirhtml to make HTML files named index.html in directories" 21 | @echo " singlehtml to make a single large HTML file" 22 | @echo " pickle to make pickle files" 23 | @echo " json to make JSON files" 24 | @echo " htmlhelp to make HTML files and a HTML help project" 25 | @echo " qthelp to make HTML files and a qthelp project" 26 | @echo " devhelp to make HTML files and a Devhelp project" 27 | @echo " epub to make an epub" 28 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 29 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 30 | @echo " text to make text files" 31 | @echo " man to make manual pages" 32 | @echo " changes to make an overview of all changed/added/deprecated items" 33 | @echo " linkcheck to check all external links for integrity" 34 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 35 | 36 | clean: 37 | -rm -rf $(BUILDDIR)/* 38 | 39 | html: 40 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 41 | @echo 42 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 43 | 44 | dirhtml: 45 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 46 | @echo 47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 48 | 49 | singlehtml: 50 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 51 | @echo 52 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 53 | 54 | pickle: 55 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 56 | @echo 57 | @echo "Build finished; now you can process the pickle files." 58 | 59 | json: 60 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 61 | @echo 62 | @echo "Build finished; now you can process the JSON files." 63 | 64 | htmlhelp: 65 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 66 | @echo 67 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 68 | ".hhp project file in $(BUILDDIR)/htmlhelp." 69 | 70 | qthelp: 71 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 72 | @echo 73 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 74 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 75 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/abapy.qhcp" 76 | @echo "To view the help file:" 77 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/abapy.qhc" 78 | 79 | devhelp: 80 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 81 | @echo 82 | @echo "Build finished." 83 | @echo "To view the help file:" 84 | @echo "# mkdir -p $$HOME/.local/share/devhelp/abapy" 85 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/abapy" 86 | @echo "# devhelp" 87 | 88 | epub: 89 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 90 | @echo 91 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 92 | 93 | latex: 94 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 95 | @echo 96 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 97 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 98 | "(use \`make latexpdf' here to do that automatically)." 99 | 100 | latexpdf: 101 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 102 | @echo "Running LaTeX files through pdflatex..." 103 | make -C $(BUILDDIR)/latex all-pdf 104 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 105 | 106 | text: 107 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 108 | @echo 109 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 110 | 111 | man: 112 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 113 | @echo 114 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 115 | 116 | changes: 117 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 118 | @echo 119 | @echo "The overview file is in $(BUILDDIR)/changes." 120 | 121 | linkcheck: 122 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 123 | @echo 124 | @echo "Link check complete; look for any errors in the above output " \ 125 | "or in $(BUILDDIR)/linkcheck/output.txt." 126 | 127 | doctest: 128 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 129 | @echo "Testing of doctests in the sources finished, look at the " \ 130 | "results in $(BUILDDIR)/doctest/output.txt." 131 | -------------------------------------------------------------------------------- /doc/postproc.rst: -------------------------------------------------------------------------------- 1 | Post Processing 2 | =============== 3 | 4 | Finite Element Modeling post processing tools. 5 | 6 | Field Outputs 7 | ~~~~~~~~~~~~~ 8 | 9 | Scalar fields 10 | --------------------- 11 | 12 | .. autoclass:: abapy.postproc.FieldOutput 13 | 14 | Add/remove/get data 15 | ___________________ 16 | 17 | .. automethod:: abapy.postproc.FieldOutput.add_data 18 | 19 | .. automethod:: abapy.postproc.FieldOutput.get_data 20 | 21 | 22 | VTK Export 23 | __________ 24 | 25 | .. automethod:: abapy.postproc.FieldOutput.dump2vtk 26 | 27 | 28 | Operations and invariants 29 | _________________________ 30 | 31 | 32 | Vector fields 33 | --------------------------- 34 | 35 | .. autoclass:: abapy.postproc.VectorFieldOutput 36 | 37 | Add/remove/get data 38 | ___________________ 39 | 40 | .. automethod:: abapy.postproc.VectorFieldOutput.add_data 41 | 42 | .. automethod:: abapy.postproc.VectorFieldOutput.get_data 43 | 44 | .. automethod:: abapy.postproc.VectorFieldOutput.get_coord 45 | 46 | 47 | 48 | VTK Export 49 | __________ 50 | 51 | .. automethod:: abapy.postproc.VectorFieldOutput.dump2vtk 52 | 53 | 54 | Operations 55 | __________ 56 | 57 | .. automethod:: abapy.postproc.VectorFieldOutput.norm 58 | 59 | .. automethod:: abapy.postproc.VectorFieldOutput.sum 60 | 61 | .. automethod:: abapy.postproc.VectorFieldOutput.dot 62 | 63 | .. automethod:: abapy.postproc.VectorFieldOutput.cross 64 | 65 | 66 | 67 | Tensor fields 68 | --------------------------- 69 | 70 | .. autoclass:: abapy.postproc.TensorFieldOutput 71 | 72 | Add/remove/get data 73 | ___________________ 74 | 75 | .. automethod:: abapy.postproc.TensorFieldOutput.add_data 76 | 77 | .. automethod:: abapy.postproc.TensorFieldOutput.get_data 78 | 79 | .. automethod:: abapy.postproc.TensorFieldOutput.get_component 80 | 81 | VTK Export 82 | __________ 83 | 84 | 85 | 86 | 87 | .. automethod:: abapy.postproc.TensorFieldOutput.dump2vtk 88 | 89 | 90 | Operations and invariants 91 | _________________________ 92 | 93 | 94 | .. automethod:: abapy.postproc.TensorFieldOutput.sum 95 | 96 | .. automethod:: abapy.postproc.TensorFieldOutput.trace 97 | 98 | .. automethod:: abapy.postproc.TensorFieldOutput.deviatoric 99 | 100 | .. automethod:: abapy.postproc.TensorFieldOutput.spheric 101 | 102 | .. automethod:: abapy.postproc.TensorFieldOutput.i1 103 | 104 | .. automethod:: abapy.postproc.TensorFieldOutput.i2 105 | 106 | .. automethod:: abapy.postproc.TensorFieldOutput.i3 107 | 108 | .. automethod:: abapy.postproc.TensorFieldOutput.j2 109 | 110 | .. automethod:: abapy.postproc.TensorFieldOutput.j3 111 | 112 | .. automethod:: abapy.postproc.TensorFieldOutput.eigen 113 | 114 | .. automethod:: abapy.postproc.TensorFieldOutput.pressure 115 | 116 | .. automethod:: abapy.postproc.TensorFieldOutput.vonmises 117 | 118 | .. automethod:: abapy.postproc.TensorFieldOutput.tresca 119 | 120 | Getting field outputs from an Abaqus ODB 121 | ---------------------------------------- 122 | 123 | Scalar fields 124 | _____________ 125 | 126 | .. autofunction:: abapy.postproc.GetFieldOutput 127 | .. autofunction:: abapy.postproc.MakeFieldOutputReport 128 | .. autofunction:: abapy.postproc.ReadFieldOutputReport 129 | .. autofunction:: abapy.postproc.GetFieldOutput_byRpt 130 | 131 | 132 | 133 | Vector fields 134 | _____________ 135 | 136 | .. autofunction:: abapy.postproc.GetVectorFieldOutput 137 | .. autofunction:: abapy.postproc.GetVectorFieldOutput_byRpt 138 | 139 | Tensor fields 140 | _____________ 141 | 142 | .. autofunction:: abapy.postproc.GetTensorFieldOutput 143 | .. autofunction:: abapy.postproc.GetTensorFieldOutput_byRpt 144 | 145 | 146 | ``ZeroFieldOutput_like`` 147 | ------------------------ 148 | 149 | .. autofunction:: abapy.postproc.ZeroFieldOutput_like 150 | 151 | ``OneFieldOutput_like`` 152 | ------------------------ 153 | 154 | .. autofunction:: abapy.postproc.OneFieldOutput_like 155 | 156 | ``Identity_like`` 157 | ------------------------ 158 | 159 | .. autofunction:: abapy.postproc.Identity_like 160 | 161 | 162 | History Outputs 163 | ~~~~~~~~~~~~~~~ 164 | 165 | ``HistoryOutput`` class 166 | ----------------------- 167 | 168 | .. autoclass:: abapy.postproc.HistoryOutput 169 | 170 | Add/get data 171 | ____________ 172 | 173 | .. automethod:: abapy.postproc.HistoryOutput.add_step 174 | 175 | .. automethod:: abapy.postproc.HistoryOutput.plotable 176 | 177 | .. automethod:: abapy.postproc.HistoryOutput.toArray 178 | 179 | Utilities 180 | _________ 181 | 182 | .. automethod:: abapy.postproc.HistoryOutput.total 183 | .. automethod:: abapy.postproc.HistoryOutput.integral 184 | .. automethod:: abapy.postproc.HistoryOutput.average 185 | 186 | 187 | 188 | .. automethod:: abapy.postproc.HistoryOutput.data_min 189 | .. automethod:: abapy.postproc.HistoryOutput.data_max 190 | .. automethod:: abapy.postproc.HistoryOutput.time_min 191 | .. automethod:: abapy.postproc.HistoryOutput.time_max 192 | 193 | .. automethod:: abapy.postproc.HistoryOutput.duration 194 | 195 | ``GetHistoryOutputByKey`` function 196 | ---------------------------------- 197 | 198 | .. autofunction:: abapy.postproc.GetHistoryOutputByKey 199 | 200 | 201 | Mesh 202 | ~~~~ 203 | 204 | ``GetMesh`` function 205 | ----------------------- 206 | 207 | .. autofunction:: abapy.postproc.GetMesh 208 | 209 | 210 | -------------------------------------------------------------------------------- /doc/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | if NOT "%PAPER%" == "" ( 11 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 12 | ) 13 | 14 | if "%1" == "" goto help 15 | 16 | if "%1" == "help" ( 17 | :help 18 | echo.Please use `make ^` where ^ is one of 19 | echo. html to make standalone HTML files 20 | echo. dirhtml to make HTML files named index.html in directories 21 | echo. singlehtml to make a single large HTML file 22 | echo. pickle to make pickle files 23 | echo. json to make JSON files 24 | echo. htmlhelp to make HTML files and a HTML help project 25 | echo. qthelp to make HTML files and a qthelp project 26 | echo. devhelp to make HTML files and a Devhelp project 27 | echo. epub to make an epub 28 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 29 | echo. text to make text files 30 | echo. man to make manual pages 31 | echo. changes to make an overview over all changed/added/deprecated items 32 | echo. linkcheck to check all external links for integrity 33 | echo. doctest to run all doctests embedded in the documentation if enabled 34 | goto end 35 | ) 36 | 37 | if "%1" == "clean" ( 38 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 39 | del /q /s %BUILDDIR%\* 40 | goto end 41 | ) 42 | 43 | if "%1" == "html" ( 44 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 45 | if errorlevel 1 exit /b 1 46 | echo. 47 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 48 | goto end 49 | ) 50 | 51 | if "%1" == "dirhtml" ( 52 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 53 | if errorlevel 1 exit /b 1 54 | echo. 55 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 56 | goto end 57 | ) 58 | 59 | if "%1" == "singlehtml" ( 60 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 61 | if errorlevel 1 exit /b 1 62 | echo. 63 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 64 | goto end 65 | ) 66 | 67 | if "%1" == "pickle" ( 68 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 69 | if errorlevel 1 exit /b 1 70 | echo. 71 | echo.Build finished; now you can process the pickle files. 72 | goto end 73 | ) 74 | 75 | if "%1" == "json" ( 76 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 77 | if errorlevel 1 exit /b 1 78 | echo. 79 | echo.Build finished; now you can process the JSON files. 80 | goto end 81 | ) 82 | 83 | if "%1" == "htmlhelp" ( 84 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 85 | if errorlevel 1 exit /b 1 86 | echo. 87 | echo.Build finished; now you can run HTML Help Workshop with the ^ 88 | .hhp project file in %BUILDDIR%/htmlhelp. 89 | goto end 90 | ) 91 | 92 | if "%1" == "qthelp" ( 93 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 94 | if errorlevel 1 exit /b 1 95 | echo. 96 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 97 | .qhcp project file in %BUILDDIR%/qthelp, like this: 98 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\abapy.qhcp 99 | echo.To view the help file: 100 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\abapy.ghc 101 | goto end 102 | ) 103 | 104 | if "%1" == "devhelp" ( 105 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 106 | if errorlevel 1 exit /b 1 107 | echo. 108 | echo.Build finished. 109 | goto end 110 | ) 111 | 112 | if "%1" == "epub" ( 113 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 114 | if errorlevel 1 exit /b 1 115 | echo. 116 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 117 | goto end 118 | ) 119 | 120 | if "%1" == "latex" ( 121 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 122 | if errorlevel 1 exit /b 1 123 | echo. 124 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 125 | goto end 126 | ) 127 | 128 | if "%1" == "text" ( 129 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 130 | if errorlevel 1 exit /b 1 131 | echo. 132 | echo.Build finished. The text files are in %BUILDDIR%/text. 133 | goto end 134 | ) 135 | 136 | if "%1" == "man" ( 137 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 138 | if errorlevel 1 exit /b 1 139 | echo. 140 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 141 | goto end 142 | ) 143 | 144 | if "%1" == "changes" ( 145 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 146 | if errorlevel 1 exit /b 1 147 | echo. 148 | echo.The overview file is in %BUILDDIR%/changes. 149 | goto end 150 | ) 151 | 152 | if "%1" == "linkcheck" ( 153 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 154 | if errorlevel 1 exit /b 1 155 | echo. 156 | echo.Link check complete; look for any errors in the above output ^ 157 | or in %BUILDDIR%/linkcheck/output.txt. 158 | goto end 159 | ) 160 | 161 | if "%1" == "doctest" ( 162 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 163 | if errorlevel 1 exit /b 1 164 | echo. 165 | echo.Testing of doctests in the sources finished, look at the ^ 166 | results in %BUILDDIR%/doctest/output.txt. 167 | goto end 168 | ) 169 | 170 | :end 171 | -------------------------------------------------------------------------------- /doc/advanced_examples/indentation/simulations/loader.py: -------------------------------------------------------------------------------- 1 | # LOADER: loads simulations to do in the database 2 | import numpy as np 3 | from copy import copy 4 | from abapy.indentation import equivalent_half_angle 5 | 6 | # Setting up the database 7 | execfile('settings.py') 8 | 9 | # creating some shortcuts 10 | d = db_manager # database manager 11 | c = db_manager.cls # useful to call Simulation attributs 12 | 13 | 14 | #-------------------------- 15 | # FIXED PARAMETERS 16 | #-------------------------- 17 | 18 | # Fixed Parameters 19 | Na_berk, Nb_berk = 8, 8 # Mesh parameters 20 | Ns_berk, Nf_berk = 16, 2 # Mesh parameters 21 | Na_cone, Nb_cone = 16, 16 # Mesh parameters 22 | Ns_cone, Nf_cone = 16, 2 # Mesh parameters 23 | Nsweep, sweep_angle = 8, 60. # Mesh sweep parameters 24 | E_s = 1. # Sample's Young's modulus 25 | nu = 0.2 # Poisson's ratio 26 | half_angle = 65.27 # Indenter half angle of the modified Berkovich 27 | frames = 50 # Number frames per step 28 | 29 | 30 | #-------------------------- 31 | # DRUCKER PRAGER SIMULATIONS 32 | #-------------------------- 33 | 34 | ey = [0.01, 0.015,0.02, 0.025,0.03, 0.035,0.04, 0.045, 0.05] # Yield strain 35 | beta = [0., 5., 10., 15., 20., 25., 30.] 36 | 37 | print 'LOADING DRUCKER PRAGER SIMULATIONS' 38 | 39 | for i in xrange(len(ey)): 40 | print '* epsilon_y = ', ey[i] 41 | for j in xrange(len(beta)): 42 | print 'beta= ', beta[j] 43 | print '* Conical indenter' 44 | simu = Simulation( 45 | rigid_indenter= True, 46 | indenter_pyramid = True, 47 | three_dimensional = False, 48 | sweep_angle = sweep_angle, 49 | sample_mat_type = 'druckerprager', 50 | sample_mat_args = {'young_modulus': 1., 'poisson_ratio': 0.3, 'yield_stress': ey[i] * E_s, 'beta': beta[j], 'psi':beta[j], 'k': 1. }, 51 | indenter_mat_type = 'elastic', 52 | indenter_mat_args = {'young_modulus': 1., 'poisson_ratio': 0.3}, 53 | mesh_Na = Na_cone, 54 | mesh_Nb = Nb_cone, 55 | mesh_Ns = Ns_cone, 56 | mesh_Nf = Nf_cone, 57 | indenter_mesh_Na = 2, 58 | indenter_mesh_Nb = 2, 59 | indenter_mesh_Ns = 1, 60 | indenter_mesh_Nf = 1, 61 | indenter_mesh_Nsweep = 2, 62 | mesh_Nsweep = Nsweep, 63 | indenter_half_angle = equivalent_half_angle(half_angle, sweep_angle), 64 | frames = frames ) 65 | db_manager.add_simulation(simu) 66 | 67 | ''' 68 | print '* Berkovich indenter' 69 | simu = Simulation( 70 | rigid_indenter= True, 71 | indenter_pyramid = True, 72 | three_dimensional = True, 73 | sweep_angle = sweep_angle, 74 | sample_mat_type = 'druckerprager', 75 | sample_mat_args = {'young_modulus': 1., 'poisson_ratio': 0.3, 'yield_stress': ey[i] * E_s, 'beta': beta[j], 'psi':beta[j], 'k': 1. }, 76 | indenter_mat_type = 'elastic', 77 | indenter_mat_args = {'young_modulus': 1., 'poisson_ratio': 0.3}, 78 | mesh_Na = Na_berk, 79 | mesh_Nb = Nb_berk, 80 | mesh_Ns = Ns_berk, 81 | mesh_Nf = Nf_berk, 82 | mesh_Nsweep = Nsweep, 83 | indenter_mesh_Na = 2, 84 | indenter_mesh_Nb = 2, 85 | indenter_mesh_Ns = 1, 86 | indenter_mesh_Nf = 2, 87 | indenter_mesh_Nsweep = 2, 88 | indenter_half_angle = half_angle, 89 | sample_mesh_disp = False, 90 | frames = frames ) 91 | db_manager.add_simulation(simu) 92 | ''' 93 | 94 | #-------------------------- 95 | # HOLLOMON SIMULATIONS 96 | #-------------------------- 97 | #ey = [0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.009, 0.01] # Yield strain 98 | ey = [0.001] 99 | #n = [0., .1, .2, .3, .4] 100 | n = [.3, .4] 101 | 102 | print 'LOADING HOLLOMON SIMULATIONS' 103 | 104 | for i in xrange(len(ey)): 105 | print '* epsilon_y = ', ey[i] 106 | for j in xrange(len(n)): 107 | print '* n = ', n[j] 108 | print '* Conical indenter' 109 | simu = Simulation( 110 | rigid_indenter= True, 111 | indenter_pyramid = True, 112 | three_dimensional = False, 113 | sweep_angle = sweep_angle, 114 | sample_mat_type = 'hollomon', 115 | sample_mat_args = {'young_modulus': 1., 'poisson_ratio': 0.3, 'yield_stress': ey[i] * E_s, 'hardening': n[j]}, 116 | indenter_mat_type = 'elastic', 117 | indenter_mat_args = {'young_modulus': 1., 'poisson_ratio': 0.3}, 118 | mesh_Na = Na_cone, 119 | mesh_Nb = Nb_cone, 120 | mesh_Ns = Ns_cone, 121 | mesh_Nf = Nf_cone, 122 | indenter_mesh_Na = 2, 123 | indenter_mesh_Nb = 2, 124 | indenter_mesh_Ns = 1, 125 | indenter_mesh_Nf = 2, 126 | indenter_mesh_Nsweep = 2, 127 | mesh_Nsweep = Nsweep, 128 | indenter_half_angle = equivalent_half_angle(half_angle, sweep_angle), 129 | frames = frames ) 130 | db_manager.add_simulation(simu) 131 | 132 | ''' 133 | print '* Berkovich indenter' 134 | simu = Simulation( 135 | rigid_indenter= True, 136 | indenter_pyramid = True, 137 | three_dimensional = True, 138 | sweep_angle = sweep_angle, 139 | sample_mat_type = 'hollomon', 140 | sample_mat_args = {'young_modulus': 1., 'poisson_ratio': 0.3, 'yield_stress': ey[i] * E_s, 'hardening': n[j]}, 141 | indenter_mat_type = 'elastic', 142 | indenter_mat_args = {'young_modulus': 1., 'poisson_ratio': 0.3}, 143 | mesh_Na = Na_berk, 144 | mesh_Nb = Nb_berk, 145 | mesh_Ns = Ns_berk, 146 | mesh_Nf = Nf_berk, 147 | mesh_Nsweep = Nsweep, 148 | indenter_mesh_Na = 2, 149 | indenter_mesh_Nb = 2, 150 | indenter_mesh_Ns = 1, 151 | indenter_mesh_Nf = 2, 152 | indenter_mesh_Nsweep = 2, 153 | indenter_half_angle = half_angle, 154 | sample_mesh_disp = False, 155 | frames = frames ) 156 | db_manager.add_simulation(simu) 157 | ''' 158 | 159 | 160 | --------------------------------------------------------------------------------