curve refinement

General discussion about TexGen.

Moderators: Martin, Developers

Post Reply
whyzjuhit
Regular
Posts: 13
Joined: Sun Jun 16, 2019 8:37 am

curve refinement

Post by whyzjuhit »

Hi,
When I try to render the yarn surface, it seems differenrt from what I defined. Although all points are the same, the render looks different.

Then I try to import .inp into ABAQUS, it's right again.

I think TxeGen needs a curve refinement.
1.png
1.png (154.57 KiB) Viewed 9593 times
2.png
2.png (215.6 KiB) Viewed 9593 times
louisepb
Project Leader
Posts: 998
Joined: Tue Dec 08, 2009 2:27 pm
Location: Nottingham

Re: curve refinement

Post by louisepb »

Hello,

It looks like you may have linear interpolation selected with a fairly low resolution. If you render with the x-ray setting you should be able to see how many sections (slave nodes) the yarn has been split into. It looks like either the cubic or Bezier interpolation has been applied when the Abaqus export has been used.

I would need to see the tg3 file to work out exactly what is going on but TexGen will render the curves correctly if the interpolation and yarn resolutions have been set appropriately.

I hope that helps,
Louise
whyzjuhit
Regular
Posts: 13
Joined: Sun Jun 16, 2019 8:37 am

Re: curve refinement

Post by whyzjuhit »

Hi Louise,
I can't upload the file, The extension tg3 is not allowed. So I paste the code below.

Code: Select all

from _Embedded import *
from TexGen.Core import *
from TexGen.Renderer import *
from TexGen.Export import *
from TexGen.WeavePattern import *
from TexGen.WiseTex import *
from TexGen.FlowTex import * 
from math import * 

#----------parameter defination----------
weftyarnw = 2.3e-3
weftyarnh = 0.52e-3
weftyarndisx = 4.67e-3
weftyarndisy = 1.0e-3
warpyarnw = 1e-3
warpyarnh = 0.4e-3

gap = (weftyarndisy-weftyarnh)*1.4
weftyarnwg = weftyarnw+gap/2
weftyarnhg = weftyarnh+gap/1.35
syarnw = 5.42e-4
syarnh = 0.5e-4
binderyarndisy = warpyarnw + syarnh

def cross(a, b):
    c = [a[1]*b[2] - a[2]*b[1],
         a[2]*b[0] - a[0]*b[2],
         a[0]*b[1] - a[1]*b[0]]
    return c
#----------textile creation----------
# cnl = ['Lxn', 'Wyn', 'Hzn']
cnl = ['Lxn']
for ii in range(len(cnl)):
    cn = cnl[ii]
    for jj in range(3,4):
        AddTextile('plain', CTextile())
        cnn = jj
        if cn == 'Lxn':
            Lxn = jj
            Wyn = 3
            Hzn = 1
        if cn == 'Wyn':
            Lxn = 1
            Wyn = jj
            Hzn = 1
        if cn == 'Hzn':
            Lxn = 1
            Wyn = 1
            Hzn = jj
        wtx = 2*Lxn+1
        wtz = 3*Hzn+1
        b1zn = 3*Hzn+1
        b1yn = Wyn
        b2zn = 3*Hzn+1
        b2yn = Wyn
        wpx = 2*Lxn
        wpy = 2*Wyn+1
        tyn = wtx*wtz + (b1zn + b2zn)*Wyn + wpx*wpy
        Yarns = []
        for i in range(tyn):
            Yarns.append(CYarn())

        textile = GetTextile('plain')
        #----------weft yarn creation----------

        for i in range(wtx):
            for j in range(wtz):
                for k in range(2):
                    Node = CNode(XYZ(weftyarndisx*i,2*Wyn*(warpyarnw+syarnh)*k,weftyarndisy*j))
                    Yarns[wtz*i+j].AddNode(Node)
                textile.AddYarn(Yarns[wtz*i+j])
                section = CSectionPowerEllipse(weftyarnw, weftyarnh, 0.6, 0)
                yarnsection = CYarnSectionConstant(section)
                textile.GetYarn(wtz*i+j).AssignSection(yarnsection)
        #----------warp1 yarn creation----------
        warpt1s = []
        y = warpyarnw/2+syarnh/2
        wtyn = wtx*wtz
        pp = 0.2
        nn = 10
        warpt1s.append([-weftyarndisx/2,y,-weftyarndisy/2])
        for j in range(Lxn):
            for i in range(nn-1,0,-2):
                x = weftyarnwg*cos(pi*i/nn)/2
                z = weftyarnhg*sin(pi*i/nn)**pp/2
                warpt1s.append([x+2*j*weftyarndisx,y,z])

            # warpt1s.append([-weftyarndisx/2+(2*j+1)*weftyarndisx,y,-weftyarndisy/2])  

            for i in range(1,nn,2):
                x = weftyarnwg*cos(pi+pi*i/nn)/2
                z = -weftyarnhg*(abs(sin(pi+pi*i/nn)))**pp/2
                warpt1s.append([x+(2*j+1)*weftyarndisx,y,z-weftyarndisy])

        # warpt1s.append([-weftyarndisx/2+2*Lxn*weftyarndisx,y,-weftyarndisy/2])

        for i in range(nn-1,0,-2):
            x = weftyarnwg*cos(pi*i/nn)/2
            z = weftyarnhg*sin(pi*i/nn)**pp/2
            warpt1s.append([x+2*Lxn*weftyarndisx,y,z])

        warpt1s.append([-weftyarndisx/2+(2*Lxn+1)*weftyarndisx,y,-weftyarndisy/2])

        vec1 = []
        for i in range(len(warpt1s)-1):
            vec1.append([warpt1s[i+1][0]-warpt1s[i][0],warpt1s[i+1][1]-warpt1s[i][1],warpt1s[i+1][2]-warpt1s[i][2]])
        vec1.append(vec1[7])

        upvec1 = []
        yvec = [0,1,0]
        for i in range(len(warpt1s)):
            upvec1.append(cross(vec1[i],yvec))
        for k in range(Wyn):
            for i in range(b1zn):
                for j in range(len(warpt1s)):
                    Node = CNode(XYZ(warpt1s[j][0],warpt1s[j][1]+2*k*binderyarndisy,warpt1s[j][2]+weftyarndisy*i),
                    XYZ(vec1[j][0],vec1[j][1],vec1[j][2]),XYZ(upvec1[j][0],upvec1[j][1],upvec1[j][2]))
                    Yarns[wtyn+i+b1zn*k].AddNode(Node)
                textile.AddYarn(Yarns[wtyn+i+b1zn*k])
                section = CSectionPowerEllipse(warpyarnw, warpyarnh, 1.2, 0)
                yarnsection = CYarnSectionConstant(section)
                textile.GetYarn(wtyn+i+b1zn*k).AssignSection(yarnsection)

        #----------warp2 yarn creation----------
        warpt2s = []
        y = 3*(warpyarnw+syarnh)/2
        wb1yn = wtyn + b1zn*b1yn


        for j in range(Lxn):

            warpt2s.append([-weftyarndisx/2+2*j*weftyarndisx,y,weftyarndisy/2])

            for i in range(1,nn,2):
                x = weftyarnwg*cos(pi+pi*i/nn)/2
                z = -weftyarnhg*(abs(sin(pi+pi*i/nn)))**pp/2
                warpt2s.append([x+2*j*weftyarndisx,y,z])

            warpt2s.append([-weftyarndisx/2+(2*j+1)*weftyarndisx,y,weftyarndisy/2])  

            for i in range(nn-1,0,-2):
                x = weftyarnwg*cos(pi*i/nn)/2
                z = weftyarnhg*sin(pi*i/nn)**pp/2
                warpt2s.append([x+(2*j+1)*weftyarndisx,y,z+weftyarndisy])

        warpt2s.append([-weftyarndisx/2+2*Lxn*weftyarndisx,y,weftyarndisy/2]) 

        for i in range(1,nn,2):
            x = weftyarnwg*cos(pi+pi*i/nn)/2
            z = -weftyarnhg*(abs(sin(pi+pi*i/nn)))**pp/2
            warpt2s.append([x+2*Lxn*weftyarndisx,y,z])

        warpt2s.append([-weftyarndisx/2+(2*Lxn+1)*weftyarndisx,y,weftyarndisy/2]) 

        vec2 = []
        for i in range(len(warpt2s)-1):
            vec2.append([warpt2s[i+1][0]-warpt2s[i][0],warpt2s[i+1][1]-warpt2s[i][1],warpt2s[i+1][2]-warpt2s[i][2]])
        vec2.append(vec2[7])

        upvec2 = []

        for i in range(len(warpt2s)):
            upvec2.append(cross(vec2[i],yvec))
        for k in range(Wyn):
            for i in range(b2zn):
                for j in range(len(warpt2s)):
                    Node = CNode(XYZ(warpt2s[j][0],warpt2s[j][1]+2*k*binderyarndisy,warpt2s[j][2]+weftyarndisy*(i-1)),
                    XYZ(vec2[j][0],vec2[j][1],vec2[j][2]),XYZ(upvec2[j][0],upvec2[j][1],upvec2[j][2]))
                    Yarns[wb1yn+i+b2zn*k].AddNode(Node)
                textile.AddYarn(Yarns[wb1yn+i+b2zn*k])
                section = CSectionPowerEllipse(warpyarnw, warpyarnh, 1.2, 0)
                yarnsection = CYarnSectionConstant(section)
                textile.GetYarn(wb1yn+i+b2zn*k).AssignSection(yarnsection)

        #----------straight yarn creation----------
        wb2yn = wb1yn + b2zn*b2yn
        for i in range(wpx):
            for j in range(wpy):
                for k in range(2):
                    Node = CNode(XYZ(weftyarndisx/2+weftyarndisx*i,(warpyarnw+syarnh)*j,(3*Hzn-1)*weftyarndisy*k),XYZ(),XYZ(0,1,0))
                    Yarns[wb2yn+wpy*i+j].AddNode(Node)
                textile.AddYarn(Yarns[wb2yn+wpy*i+j])
                section = CSectionPowerEllipse(syarnw, syarnh, 0.6, 0)
                yarnsection = CYarnSectionConstant(section)
                textile.GetYarn(wb2yn+wpy*i+j).AssignSection(yarnsection)

        #----------property assign----------
        textile.SetMatrixYoungsModulus(2.87044e+09, 'Pa')
        textile.SetMatrixPoissonsRatio(0.3326)
        textile.SetMatrixAlpha(6.5e-06)

        NumYarns = textile.GetNumYarns()
        for i in range(NumYarns):
            textile.GetYarn(i).SetFibresPerYarn(0)
            textile.GetYarn(i).SetYoungsModulusX(5.23689e+10, 'Pa')
            textile.GetYarn(i).SetYoungsModulusY(17394481298, 'Pa')
            textile.GetYarn(i).SetYoungsModulusZ(17394481298, 'Pa')
            textile.GetYarn(i).SetShearModulusXY(6658239333, 'Pa')
            textile.GetYarn(i).SetShearModulusXZ(6658239333, 'Pa')
            textile.GetYarn(i).SetShearModulusYZ(6658239333, 'Pa')
            textile.GetYarn(i).SetPoissonsRatioX(0.2427)
            textile.GetYarn(i).SetPoissonsRatioY(0.2427)
            textile.GetYarn(i).SetPoissonsRatioZ(0.306)

        #----------domain create----------

        domain = CDomainPlanes()
        domain.AddPlane(PLANE(XYZ(1, 0, 0), 0))
        domain.AddPlane(PLANE(XYZ(-1, 0, 0), -2*Lxn*weftyarndisx))
        domain.AddPlane(PLANE(XYZ(0, 1, 0), 0))
        domain.AddPlane(PLANE(XYZ(0, -1, 0), -2*Wyn*(warpyarnw+syarnh)))
        domain.AddPlane(PLANE(XYZ(0, 0, 1), 0))
        domain.AddPlane(PLANE(XYZ(0, 0, -1), -2*Hzn*weftyarndisy))
        GetTextile('plain').AssignDomain(domain)

        # YarnMeshes = MeshVector()

        # YarnMeshes.resize(NumYarns)

        #----------intersections remove----------
        # # May need to adjust tolerance depending on model
        # Tol = 1e-6

        # # Create a volume mesh for each yarn, clipped to domain and add to mesh vector
        # Domain = textile.GetDomain()
        # for i in range(NumYarns):
        #     yarn = textile.GetYarn(i)
        #     yarn.AddVolumeToMesh(YarnMeshes[i], Domain)
        
        # # Initialise class which does the interference adjustment  
        # AdjustMesh = CAdjustMeshInterference()

        # # Mesh is only adjusted if interference is less than one volume mesh element deep
        # if ( AdjustMesh.AdjustMesh(textile, YarnMeshes, Tol) == False ):
        #     print("Unable to adjust mesh: intersection depths too large")
        # else:
        #     AdjustMesh.AdjustSectionMeshes(textile, YarnMeshes)

        #----------voxel save---------- 
        vx = 120*Lxn
        vy = 60*Wyn
        vz = 40*Hzn
        GetRenderWindow('plain').RenderTextile('plain')
louisepb
Project Leader
Posts: 998
Joined: Tue Dec 08, 2009 2:27 pm
Location: Nottingham

Re: curve refinement

Post by louisepb »

Hi,

Apologies for the slow reply, I have been on annual leave.
It is the yarn resolution which is the problem. The yarn.SetResolution function sets the number of points around a cross-section and the number of slave nodes along the length of the yarn. At the moment your textile has 40 points around the cross-section but only 20 slave nodes along the whole length of the yarn (shown by this entry in the .tg3 file NumSlaveNodes="20" NumSectionPoints="40" ). You can either change this manually in the tg3 file or use the SetResolution function as described here: http://texgen.sourceforge.net/api/class ... 0c0b3f5291 Note that there are two versions of the function depending on whether you want to set the two parameters independently or not.

Hope that helps,
Louise
Post Reply