Scripting Examples

From TexGen
Jump to navigationJump to search

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 functionality is not yet accessible from the graphical user interface.

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')