Rovings | Roving 1 Coordinates | Roving 1 Diameters | Roving 2 Coordinates | Roving 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 |
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.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'])