Difference between revisions of "Scripting Examples"
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | This page contains a number of example scripts which show off some of the more advanced classes used to achieve specific tasks within TexGen. This | + | This page contains a number of example scripts which show off some of the more advanced classes used to achieve specific tasks within TexGen. |
+ | ===Correction of Small Intersections=== | ||
+ | |||
+ | This script enables small intersections to be corrected automatically. It is the method which is used when correcting intersections in the ABAQUS Dry Fibre File export function and is based on the volume mesh (as drawn by the Rendering->Render Textile Volume option). It is intended to remove small intersections which may cause problems when running simulations and makes small adjustments to the local cross-sections of the yarn to remove these. Intersections which are greater than the depth of the outside volume element will not be corrected. In these cases correction to the yarn path and cross-sections specified are probably more appropriate. | ||
+ | |||
+ | <pre> | ||
+ | # Correct small intersections in textile (intersections greater than one volume mesh element in depth will not be corrected) | ||
+ | |||
+ | Tolerance = 0.0000001 | ||
+ | # Get the current textile - pass name as parameter if more than one textile loaded | ||
+ | Textile = GetTextile() | ||
+ | # Set up vector of yarn volume meshes | ||
+ | YarnMeshes = MeshVector() | ||
+ | # Create the interference correction class object | ||
+ | AdjustMesh = CAdjustMeshInterference() | ||
+ | # Fill the YarnMeshes vector with the individual yarn volume meshes for the textile | ||
+ | AdjustMesh.CreateVolumeMeshes(Textile, YarnMeshes) | ||
+ | # Correct the intersections in the YarnMeshes | ||
+ | AdjustMesh.AdjustMesh( Textile, YarnMeshes, Tolerance ) | ||
+ | # Adjust the textile cross-sections to reflect the corrections calculated in the previous command | ||
+ | AdjustMesh.AdjustSectionMeshes( Textile, YarnMeshes ) | ||
+ | </pre> | ||
=== Geometry Solver === | === Geometry Solver === | ||
Line 48: | Line 69: | ||
tension = CLinearTransformation() | tension = CLinearTransformation() | ||
# Add a scale in the X direction | # Add a scale in the X direction | ||
− | tension.AddScale(1.1, 0, 0) | + | tension.AddScale(1.1, 1.0, 1.0) |
# Create an instance of the TextileDeformerAbaqus class | # Create an instance of the TextileDeformerAbaqus class |
Latest revision as of 11:55, 9 February 2015
This page contains a number of example scripts which show off some of the more advanced classes used to achieve specific tasks within TexGen.
Correction of Small Intersections
This script enables small intersections to be corrected automatically. It is the method which is used when correcting intersections in the ABAQUS Dry Fibre File export function and is based on the volume mesh (as drawn by the Rendering->Render Textile Volume option). It is intended to remove small intersections which may cause problems when running simulations and makes small adjustments to the local cross-sections of the yarn to remove these. Intersections which are greater than the depth of the outside volume element will not be corrected. In these cases correction to the yarn path and cross-sections specified are probably more appropriate.
# Correct small intersections in textile (intersections greater than one volume mesh element in depth will not be corrected) Tolerance = 0.0000001 # Get the current textile - pass name as parameter if more than one textile loaded Textile = GetTextile() # Set up vector of yarn volume meshes YarnMeshes = MeshVector() # Create the interference correction class object AdjustMesh = CAdjustMeshInterference() # Fill the YarnMeshes vector with the individual yarn volume meshes for the textile AdjustMesh.CreateVolumeMeshes(Textile, YarnMeshes) # Correct the intersections in the YarnMeshes AdjustMesh.AdjustMesh( Textile, YarnMeshes, Tolerance ) # Adjust the textile cross-sections to reflect the corrections calculated in the previous command AdjustMesh.AdjustSectionMeshes( Textile, YarnMeshes )
Geometry Solver
The theory behind the geometry solver is described in a paper submitted to "The First World Conference on 3D Fabrics and Their Applications" held in Manchester on the 10-11th of April 2008 titled "Prediction of textile geometry using strain energy minimisation". A longer more detailed version of this can be found here: Sherburn, M., Long, A., Jones, A., Crookston, J., & Brown, L. Prediction of textile geometry using an energy minimization approach. Journal of Industrial Textiles, 41(4), 345-369
from TexGen.Core import * # Read in a textile ReadFromXML('800s4.tg3') Textile = GetTextile() # Create an instance of the geometry solver Solver = CGeometrySolver() # Set some parameters Solver.SetContactStiffness(1e6) Solver.SetDisabledStiffness(1e-6) Solver.SetSeed(1.0) # Create the system of equations to be solved Solver.CreateSystem(Textile) # Solve the system Solver.SolveSystem() # Save the result to a VTK file for viewing purposes Solver.SaveToVTK("GeomSolve") # Deform the textile Solver.DeformTextile() # Save the result back to a TG3 file SaveToXML('Def-800s4.tg3')
ABAQUS Dry Fabric Simulation
This code consists of running ABAQUS dry fabric simulations from TexGen geometrical models and using the results to modify that model. The basic procedure is outlined below:
- TexGen meshes the yarns using a combination of Hexahedral and Wedge elements.
- TexGen generates an ABAQUS input file which contains the mesh, element orientations, element volume fractions, material definitions, contact surfaces and definitions, compression plates, periodic boundary conditions and loading steps. Some of this information cannot be determined automatically by TexGen, in these cases they must be specified by the user. These are material definitions, loading steps and initial gap between compression plates if they are to be included.
- TexGen launches ABAQUS feeding it the input file generated and waits for the process to terminate before continuing. In the case where the simulation failed for an unknown reason an error message is printed and it is up to the user to determine what went wrong.
- If the simulation succeeded TexGen parses the ABAQUS .dat file to obtain the nodal displacements and .inp file to obtain element connectivity. Using this information, the yarn path and cross-sections of the TexGen model are deformed by the predicted displacement field.
The theory behind this will be described in more depth in a journal paper. Until then the following short example script shows how to use this:
from TexGen.Abaqus import * # Define a linear transformation tension = CLinearTransformation() # Add a scale in the X direction tension.AddScale(1.1, 1.0, 1.0) # Create an instance of the TextileDeformerAbaqus class deformer = TextileDeformerAbaqus() # Add the tensile deformation step deformer.AddDeformationStep(tension) # Read in a TexGen model ReadFromXML('pweave.tg3') textile = GetTextile() # This is where all the work is done, note this may take a long time to run deformer.DeformTextile(textile) # Save the result back to a new TexGen model SaveToXML('pweave-tensioned.tg3')