Difference between revisions of "Scripting Examples"

From TexGen
Jump to navigationJump to search
Line 6: Line 6:
  
 
<pre>
 
<pre>
 +
from TexGen.Core import *
 +
 
# Read in a textile
 
# Read in a textile
 
ReadFromXML('800s4.tg3')
 
ReadFromXML('800s4.tg3')
Line 27: Line 29:
 
# Save the result back to a TG3 file
 
# Save the result back to a TG3 file
 
SaveToXML('Def-800s4.tg3')
 
SaveToXML('Def-800s4.tg3')
 +
</pre>
 +
 +
=== 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:
 +
 +
<pre>
 +
from TexGen.Abaqus import *
 +
 +
# Define a linear transformation
 +
tension = CLinearTransformation()
 +
# Add a scale in the X direction
 +
tension.Scale(1.1)
 +
 +
# 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')
 
</pre>
 
</pre>

Revision as of 08:59, 15 May 2008

This page contains a number of example scripts which show off some of the more advanced classes used to achieve specific tasks within TexGen.

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 will shortly be submitted as a journal paper.

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.Scale(1.1)

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