Modelling Rovings on the Basis of Support Points

· 4 · 7376
*

Marvin Wolf

  • *
  • Posts: 5
    • View Profile
Modelling Rovings on the Basis of Support Points
« on: August 02, 2021, 03:29:06 PM »
Hello,

my aim is to modell a roving based on support points. I already found the object type "Curved Elliptical Fiber" in the "Create/Add GAD Object"-Dialog, where I can input the 3d-Coordinates of support points. As I have around 700 support points, it would be interesting to know if there is a way to input them with a macro or maybe by using an excel-sheet.

My support points are currently saved as triples (touple with 3 elements) within a python array. Is there an easy way to use these triples as an input for modelling?

Thanks for helping.
Marvin

*

Aaron Widera

  • Math2Market Employee
  • *****
  • Posts: 63
    • View Profile
    • Math2Market GmbH
  • Position: Sales Engineer Digital Material R&D
Re: Modelling Rovings on the Basis of Support Points
« Reply #1 on: August 10, 2021, 05:04:00 PM »
Hi Marvin,

yes it is possible to create elliptical rovings with the support points automated by using the "Add GAD Object" option. You can use a python macro for that, the tricky question would be how to access the data form the excel sheet.

Can you tell me a bit more how the support points in the sheet are formatted?
Then I can explain you how you on that expample how to create a macro for that. So can you show a table here to show me how the data looks like? For example:
RovingsRoving 1 CoordinatesRoving 1 DiametersRoving 2 CoordinatesRoving 2 Diameters
Support Point 1 X, Y, Z Diameter1, Diameter2, Diameter3 X, Y, Z Diameter1, Diameter2, Diameter3
Support Point 2 X, Y, Z Diameter1, Diameter2, Diameter3 X, Y, Z Diameter1, Diameter2, Diameter3
further support points

When I understand the table structure I can explain how to make the macro.

*

Marvin Wolf

  • *
  • Posts: 5
    • View Profile
Re: Modelling Rovings on the Basis of Support Points
« Reply #2 on: August 16, 2021, 10:56:20 AM »
Hello Aaron,

thank you for your answer.

For a first try, I only want to model one roving in x-direction and one in y-direction. The support points are created by a python script on the basis of two polynomials. These polynomials describe the routes of the rovings I want to modell (x- and y- direction). The result of my python script is currently one array for each roving-direction, containing the triples which describe the support points.
Do we need to create a excel sheet, or is it possible to integrate my python script (or at least the resulting data) into the GeoDict-Macro which I am using to create the model?

If I need to create a excel sheet, I could stick to your example. Roving 1 would be the x-Roving and Roving 2 the y-Roving.

*

Aaron Widera

  • Math2Market Employee
  • *****
  • Posts: 63
    • View Profile
    • Math2Market GmbH
  • Position: Sales Engineer Digital Material R&D
Re: Modelling Rovings on the Basis of Support Points
« Reply #3 on: August 18, 2021, 02:33:18 PM »
Hi Marvin,

I prepared you an example, I assume, that youzr python script to create the roving support points is named PolyNomial.py.
It should look like that:
Code: [Select]
def test_func(parameter1, parameter2):
  x = [[2e-05, 2e-05, 2e-05],[4.5e-05, 2e-05, 2e-05],[7e-05, 3e-05, 2e-05],[9.5e-05, 4e-05, 3e-05]]
  y = [[2e-05, 2e-05, 2e-05],[2e-05, 4.5e-05, 2e-05],[3e-05, 7e-05, 2e-05]]
  return [x, y]
So it is just a function "test_func" that gets two parameters. Then it calculates and get two list (x and y) with the support points. In this case the list is set, but you just need to enter you polynomial function.
Then the script returns the two lists combined as [x, y]

Now for the important part, you can copy and paste this code block into a blank python script and use it, I will use comments marked by # to comment in the script what is happening:
Code: [Select]
Header =  {
  'Release'      : '2021',
  }

Description = '''
'''

Variables = {
  'NumberOfVariables' : 0,
  }
# until here it is just header and initialization which is not important

import PolyNomial    #here we import the python script

Roving_list = PolyNomial.test_func(123, 456) # by using .test_func(para1,para2) we are using the function from the script PolyNomial with the parameters para1 and para2. And save the returned values in the Roving_list

diam_1 = 2e-05      #Here you can set the Diameter of the Rovings. Here both Rovings in x and y directio have the same size. You could adapt it like below.
diam_2 = 1e-05

number_of_rovings = len(Roving_list)

#now we define a dictionary that is filled with all information GeoDict needs to create the GAD-Objects
#You might need to adjust the voxellenght and Domainsize (NX, NY, NZ) below by calculating the domainsize
GadAdd_args = {
  'ResultFileName'  : 'GadAdd.gdr',
  'KeepStructure'   : 0,
  'NumberOfObjects' : number_of_rovings,
  'Domain' : {
    'PeriodicX'         : False,
    'PeriodicY'         : False,
    'PeriodicZ'         : False,
    'OriginX'           : (0, 'm'),
    'OriginY'           : (0, 'm'),
    'OriginZ'           : (0, 'm'),
    'VoxelLength'       : (1e-06, 'm'),
    'DomainMode'        : 'VoxelNumber',   # Possible values: VoxelNumber, Length, VoxelNumberAndLength
    'NX'                : 100,
    'NY'                : 100,
    'NZ'                : 100,
    'Material' : {
      'Type'        : 'Fluid',     # Possible values: Fluid, Solid, Porous
      'Name'        : 'Undefined',
      'Information' : '',
      },
    'OverlapMode'       : 'GivenMaterial', # Possible values: OverlapMaterial, NewMaterial, OldMaterial, GivenMaterial
    'OverlapMaterialID' : 3,
    'NumOverlapRules'   : 0,
    'HollowMaterialID'  : 0,
    'PostProcessing' : {
      'ResolveOverlap'    : False,
      'MarkContactVoxels' : False,
      'ContactMaterialID' : 15,
      },
    },
  }
#This is the basic dictionary and now we fill it with the two Rovings. I Have it variable so when the polynomial script later returns more support lists, it should also work.

for i in range(number_of_rovings):
  GadAdd_args[f'Object{i+1}:MaterialID'] = 1
  GadAdd_args[f'Object{i+1}:Type'] = 'CurvedEllipticalFiber'
  GadAdd_args[f'Object{i+1}:NumberOfSegments'] = len(Roving_list[i])-1
  GadAdd_args[f'Object{i+1}:FiberEndType1'] = 'Flat'
  GadAdd_args[f'Object{i+1}:FiberEndType2'] = 'Flat'
  GadAdd_args[f'Object{i+1}:Diameter1'] = diam_1
  GadAdd_args[f'Object{i+1}:Diameter2'] = diam_2
  GadAdd_args[f'Object{i+1}:Perpendicular'] = [-1,0,0]
  #we iterate over the Roving number i and fill the Dictionary with Object1, Object2.
  #The command GadAdd_args[f'Object{i+1}:Diameter1'] = diam_1 takes the dictionary GaddAdd_args at fills it at the entry Object i :Diameter1 with the value diam1
  for j in range(len(Roving_list[i])):
    GadAdd_args[f'Object{i+1}:Point{j+1}'] =  Roving_list[i][j]
    #each support point generates a new entry in the dictionary, here we fill the dictionary with the entry from the Roving_list. Where i means whether it is Roving x or y and j means the current support point.
   
gd.runCmd("GadGeo:GadAdd", GadAdd_args, Header['Release'])

If you copy code block 1 into a scirpt called PolyNomial.py and code block 2 into another python script "Rovingcreation.py" and then exectue the Rovingcreation.py it should generate a small example.
Then you need to replace the test_func by your real polynomial function and it should still work. It is important that PolyNomial.py and Rovingcration.py are placed in the same folder.

Please let me know if you have any questions, because coding can always become a bit tricky.